1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include <efi.h>
5 
6 /* This TPM PCR is where we extend the kernel command line and any passed credentials here. */
7 #define TPM_PCR_INDEX_KERNEL_PARAMETERS 12U
8 
9 /* We used to write the kernel command line/credentials into PCR 8, in systemd <= 250. Let's provide for
10  * some compatibility. (Remove in 2023!) */
11 #if EFI_TPM_PCR_COMPAT
12 #define TPM_PCR_INDEX_KERNEL_PARAMETERS_COMPAT 8U
13 #else
14 #define TPM_PCR_INDEX_KERNEL_PARAMETERS_COMPAT UINT32_MAX
15 #endif
16 
17 /* This TPM PCR is where most Linux infrastructure extends the initrd binary images into, and so do we. */
18 #define TPM_PCR_INDEX_INITRD 4U
19 
20 #if ENABLE_TPM
21 
22 BOOLEAN tpm_present(void);
23 EFI_STATUS tpm_log_event(UINT32 pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description);
24 EFI_STATUS tpm_log_load_options(const CHAR16 *cmdline);
25 
26 #else
27 
tpm_present(void)28 static inline BOOLEAN tpm_present(void) {
29         return FALSE;
30 }
31 
tpm_log_event(UINT32 pcrindex,EFI_PHYSICAL_ADDRESS buffer,UINTN buffer_size,const CHAR16 * description)32 static inline EFI_STATUS tpm_log_event(UINT32 pcrindex, EFI_PHYSICAL_ADDRESS buffer, UINTN buffer_size, const CHAR16 *description) {
33         return EFI_SUCCESS;
34 }
35 
tpm_log_load_options(const CHAR16 * cmdline)36 static inline EFI_STATUS tpm_log_load_options(const CHAR16 *cmdline) {
37         return EFI_SUCCESS;
38 }
39 
40 #endif
41