1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <acpi/acpigen.h>
5 #include <acpi/acpi_device.h>
7 #include <console/console.h>
11 #define BCD(x, y) (((x) << 4) | ((y) << 0))
13 static void set_package_element_op(const char *package_name
, unsigned int element
,
16 acpigen_write_store();
17 acpigen_emit_byte(src_op
);
18 acpigen_emit_byte(INDEX_OP
);
19 acpigen_emit_namestring(package_name
);
20 acpigen_write_integer(element
);
21 acpigen_emit_byte(ZERO_OP
); /* Ignore Index() Destination */
24 static void set_package_element_name(const char *package_name
, unsigned int element
,
27 acpigen_write_store();
28 acpigen_emit_namestring(src
);
29 acpigen_emit_byte(INDEX_OP
);
30 acpigen_emit_namestring(package_name
);
31 acpigen_write_integer(element
);
32 acpigen_emit_byte(ZERO_OP
); /* Ignore Index() Destination */
35 /* PPI function is passed in src_op. Converted to Local2. Clobbers Local1 and Local2 */
36 static void verify_supported_ppi(uint8_t src_op
)
39 * Old OSes incorrectly pass a Buffer instead of a Package.
40 * See TCG Physical Presence Interface Specification Chapter 8.1.2 for details.
43 /* If (ObjectType(Arg3) == Package) */
44 acpigen_write_store();
45 acpigen_emit_byte(OBJ_TYPE_OP
);
46 acpigen_emit_byte(src_op
);
47 acpigen_emit_byte(LOCAL1_OP
);
48 acpigen_write_if_lequal_op_int(LOCAL1_OP
, 4);
49 acpigen_get_package_op_element(src_op
, 0, LOCAL2_OP
);
52 /* If (ObjectType(Arg3) == Buffer) */
53 acpigen_write_store();
54 acpigen_emit_byte(OBJ_TYPE_OP
);
55 acpigen_emit_byte(src_op
);
56 acpigen_emit_byte(LOCAL1_OP
);
57 acpigen_write_if_lequal_op_int(LOCAL1_OP
, 3);
58 acpigen_write_to_integer(src_op
, LOCAL2_OP
);
61 /* Check if it's a valid PPI function */
62 acpigen_write_store();
63 acpigen_emit_namestring("^FSUP");
64 acpigen_emit_byte(LOCAL2_OP
);
65 acpigen_emit_byte(CONFIG(TPM1
) ? ONE_OP
: ZERO_OP
);
66 acpigen_emit_byte(LOCAL1_OP
);
67 acpigen_write_if_lequal_op_int(LOCAL1_OP
, 0);
70 * Note: Must fake success for 1-4, 6-13, 15-16, 19-20
71 * see "Trusted Execution Environment ACPI Profile"
73 * Even if not available, the TPM 1.2 PPI must be advertised as
74 * supported. Tests showed that Windows relies on it, even when
75 * a TPM2.0 is present!
76 * The functions aren't actually used when a TPM2.0 is present...
77 * Without this the Windows TPM 2.0 stack refuses to work.
81 * Check if we have TPM1.2 but a TPM2 PPI function was called
82 * or if we have TPM2.0 but a TPM1.2 PPI function was called.
84 acpigen_write_store();
85 acpigen_emit_namestring("^FSUP");
86 acpigen_emit_byte(LOCAL2_OP
);
87 acpigen_emit_byte(CONFIG(TPM1
) ? ZERO_OP
: ONE_OP
);
88 acpigen_emit_byte(LOCAL1_OP
);
90 acpigen_write_if_lequal_op_int(LOCAL1_OP
, 1);
91 acpigen_write_return_integer(PPI2_RET_SUCCESS
); /* As per TPM spec */
93 acpigen_write_return_integer(PPI2_RET_NOT_SUPPORTED
);
98 /* TPM PPI functions */
100 static void tpm_ppi_func0_cb(void *arg
)
103 u8 buf
[] = {0xff, 0x01};
104 acpigen_write_return_byte_buffer(buf
, 2);
108 * PPI 1.0: 2.1.1 Get Physical Presence Interface Version
110 * Arg2 (Integer): Function Index = 1
111 * Arg3 (Package): Arguments = Empty Package
113 * Returns: Type: String
115 static void tpm_ppi_func1_cb(void *arg
)
118 /* Interface version: 1.3 */
119 acpigen_write_return_string("1.3");
121 /* Interface version: 1.2 */
122 acpigen_write_return_string("1.2");
126 * Submit TPM Operation Request to Pre-OS Environment [Windows optional]
127 * PPI 1.0: 2.1.3 Submit TPM Operation Request to Pre-OS Environment
129 * Supported Revisions: 1
130 * Arg1 (Integer): Revision
131 * Arg2 (Integer): Function Index = 2
132 * Arg3 (Package): Arguments = Package: Type: Integer
133 * Operation Value of the Request
135 * Returns: Type: Integer
137 * 1: Operation Value of the Request Not Supported
140 static void tpm_ppi_func2_cb(void *arg
)
143 acpigen_write_to_integer(ARG1_OP
, LOCAL0_OP
);
144 acpigen_write_if_lequal_op_int(LOCAL0_OP
, 1);
146 /* Local2 = ConvertAndVerify(Arg3) */
147 verify_supported_ppi(ARG3_OP
);
149 acpigen_write_store_op_to_namestr(LOCAL2_OP
, "^CMDR");
150 acpigen_write_store_op_to_namestr(ZERO_OP
, "^OARG");
151 acpigen_write_store_op_to_namestr(ZERO_OP
, "^USER");
153 acpigen_write_return_integer(PPI2_RET_SUCCESS
);
156 acpigen_write_return_integer(PPI2_RET_GENERAL_FAILURE
);
160 * PPI 1.0: 2.1.4 Get Pending TPM Operation Requested By the OS
162 * Supported Revisions: 1, 2
163 * Arg1 (Integer): Revision
164 * Arg2 (Integer): Function Index = 3
165 * Arg3 (Package): Empty package
167 * Returns: Type: Package(Integer, Integer, Integer (optional))
172 * Pending TPM operation requested by OS
174 * Pending TPM operation argument requested by OS
176 static void tpm_ppi_func3_cb(void *arg
)
178 acpigen_write_store();
179 acpigen_write_integer(PPI3_RET_GENERAL_FAILURE
);
180 acpigen_emit_byte(LOCAL0_OP
);
182 /* ^TPM3 [0] = PPI3_RET_GENERAL_FAILURE */
183 set_package_element_op("^TPM3", 0, LOCAL0_OP
);
185 /* ^TPM2 [0] = PPI3_RET_GENERAL_FAILURE */
186 set_package_element_op("^TPM2", 0, LOCAL0_OP
);
188 acpigen_write_to_integer(ARG1_OP
, LOCAL0_OP
);
191 acpigen_write_if_lequal_op_int(LOCAL0_OP
, 1);
193 /* ^TPM2 [0] = PPI3_RET_SUCCESS */
194 acpigen_write_store();
195 acpigen_write_integer(PPI3_RET_SUCCESS
);
196 acpigen_emit_byte(LOCAL1_OP
);
197 set_package_element_op("^TPM2", 0, LOCAL1_OP
);
199 /* ^TPM2 [1] = ^CMDR */
200 set_package_element_name("^TPM2", 1, "^CMDR");
202 acpigen_emit_byte(RETURN_OP
);
203 acpigen_emit_namestring("^TPM2");
207 * A return value of {0, 23, 1} indicates that operation 23
208 * with argument 1 is pending.
212 acpigen_write_if_lequal_op_int(LOCAL0_OP
, 2);
214 /* ^TPM3 [0] = PPI3_RET_SUCCESS */
215 acpigen_write_store();
216 acpigen_write_integer(PPI3_RET_SUCCESS
);
217 acpigen_emit_byte(LOCAL1_OP
);
218 set_package_element_op("^TPM3", 0, LOCAL1_OP
);
220 /* ^TPM3 [1] = ^CMDR */
221 set_package_element_name("^TPM3", 1, "^CMDR");
223 /* ^TPM3 [2] = ^OARG */
224 set_package_element_name("^TPM3", 2, "^OARG");
226 acpigen_emit_byte(RETURN_OP
);
227 acpigen_emit_namestring("^TPM3");
230 acpigen_emit_byte(RETURN_OP
);
231 acpigen_emit_namestring("^TPM3");
235 * PPI 1.0: 2.1.5 Get Platform-Specific Action to Transition to Pre-OS Environment
237 * Arg1 (Integer): Revision
238 * Arg2 (Integer): Function Index = 4
239 * Arg3 (Package): Empty package
241 * Returns: Type: Integer
247 static void tpm_ppi_func4_cb(void *arg
)
249 /* Pre-OS transition method: reboot. */
250 acpigen_write_return_byte(PPI4_RET_REBOOT
);
254 * PPI 1.0: 2.1.6 Return TPM Operation Response to OS Environment
256 * Supported Revisions: 1
257 * Arg1 (Integer): Revision
258 * Arg2 (Integer): Function Index = 5
259 * Arg3 (Package): Empty package
261 * Returns: Type: Package(Integer, Integer, Integer)
266 * Most recent TPM operation requested by OS
268 * Response to most recent TPM operation requested by OS
270 static void tpm_ppi_func5_cb(void *arg
)
272 /* ^TPM3 [0] = PPI5_RET_GENERAL_FAILURE */
273 acpigen_write_store();
274 acpigen_write_integer(PPI5_RET_GENERAL_FAILURE
);
275 acpigen_emit_byte(LOCAL1_OP
);
276 set_package_element_op("^TPM3", 0, LOCAL1_OP
);
278 acpigen_write_to_integer(ARG1_OP
, LOCAL0_OP
);
281 acpigen_write_if_lequal_op_int(LOCAL0_OP
, 1);
283 /* ^TPM3 [0] = PPI5_RET_SUCCESS */
284 acpigen_write_store();
285 acpigen_write_integer(PPI5_RET_SUCCESS
);
286 acpigen_emit_byte(LOCAL1_OP
);
287 set_package_element_op("^TPM3", 0, LOCAL1_OP
);
289 /* ^TPM3 [1] = ^LCMD */
290 set_package_element_name("^TPM3", 1, "^LCMD");
292 /* ^TPM3 [2] = ^RESU */
293 set_package_element_name("^TPM3", 2, "^RESU");
297 acpigen_emit_byte(RETURN_OP
);
298 acpigen_emit_namestring("^TPM3");
302 * PPI 1.2: 2.1.6 Submit preferred user language [Windows optional]
304 * Arg1 (Integer): Revision
305 * Arg2 (Integer): Function Index = 5
306 * Arg3 (Package): Empty package
308 static void tpm_ppi_func6_cb(void *arg
)
311 * Set preferred user language: deprecated and must return 3 aka
314 acpigen_write_return_byte(PPI6_RET_NOT_IMPLEMENTED
);
318 * PPI 1.2: 2.1.7 Submit TPM Operation Request to Pre-OS Environment 2
320 * Supported Revisions: 1, 2
321 * Arg1 (Integer): Revision
322 * Arg2 (Integer): Function Index = 7
323 * Arg3 (Package): Integer
325 * Returns: Type: Integer
329 * 3: Blocked by current BIOS settings
331 static void tpm_ppi_func7_cb(void *arg
)
333 acpigen_write_to_integer(ARG1_OP
, LOCAL0_OP
);
335 /* Local2 = ConvertAndVerify(Arg3) */
336 verify_supported_ppi(ARG3_OP
);
338 /* If (ObjectType(Arg3) == Buffer) */
339 acpigen_write_store();
340 acpigen_emit_byte(OBJ_TYPE_OP
);
341 acpigen_emit_byte(ARG3_OP
);
342 acpigen_emit_byte(LOCAL1_OP
);
343 acpigen_write_if_lequal_op_int(LOCAL1_OP
, 3);
345 /* Enforce use of Revision 1 that doesn't take an optional argument. */
348 acpigen_write_store();
349 acpigen_emit_byte(ONE_OP
);
350 acpigen_emit_byte(LOCAL0_OP
);
354 // FIXME: Only advertise supported functions
357 acpigen_write_if_lequal_op_int(LOCAL0_OP
, 1);
360 acpigen_write_store_op_to_namestr(LOCAL2_OP
, "^CMDR");
363 acpigen_write_store_op_to_namestr(ZERO_OP
, "^OARG");
365 acpigen_write_return_byte(PPI7_RET_SUCCESS
);
369 acpigen_write_if_lequal_op_int(LOCAL0_OP
, 2);
371 acpigen_write_store_op_to_namestr(LOCAL2_OP
, "^CMDR");
373 /* ^OARG = Arg3 [1] */
374 acpigen_get_package_op_element(ARG3_OP
, 1, LOCAL3_OP
);
375 acpigen_write_store();
376 acpigen_emit_byte(LOCAL3_OP
);
377 acpigen_emit_namestring("^OARG");
379 acpigen_write_return_byte(PPI7_RET_SUCCESS
);
382 acpigen_write_return_byte(PPI7_RET_GENERAL_FAILURE
);
386 * PPI 1.2: 2.1.8 Get User Confirmation Status for Operation
388 * Returns if a command is supported and allowed by firmware
389 * Supported Revisions: 1
390 * Arg1 (Integer): Revision
391 * Arg2 (Integer): Function Index = 7
392 * Arg3 (Package): Integer
394 * Returns: Type: Integer
397 * 2: Blocked for OS by BIOS settings
398 * 3: Allowed and physical present user required
399 * 4: Allowed and physical present user not required
401 static void tpm_ppi_func8_cb(void *arg
)
403 acpigen_write_to_integer(ARG1_OP
, LOCAL0_OP
);
406 acpigen_write_if_lequal_op_int(LOCAL0_OP
, 1);
407 acpigen_get_package_op_element(ARG3_OP
, 0, LOCAL2_OP
);
409 /* Check if it's a valid PPI function */
410 acpigen_write_store();
411 acpigen_emit_namestring("^FSUP");
412 acpigen_emit_byte(LOCAL2_OP
);
413 acpigen_emit_byte(CONFIG(TPM1
) ? ONE_OP
: ZERO_OP
);
414 acpigen_emit_byte(LOCAL1_OP
);
415 acpigen_write_if_lequal_op_int(LOCAL1_OP
, 0);
416 acpigen_write_return_byte(0); /* Not implemented */
419 // FIXME: Only advertise supported functions
423 * Some functions do not require PP depending on configuration.
424 * Those aren't listed here, so the 'required PP' is always set for those.
426 static const u32 tpm1_funcs
[] = {
428 TPM_SET_NOPPICLEAR_TRUE
,
429 TPM_SET_NOPPIMAINTAINANCE_TRUE
,
430 TPM_SET_NOPPIPROVISION_TRUE
,
432 for (size_t i
= 0; i
< ARRAY_SIZE(tpm1_funcs
); i
++) {
433 acpigen_write_if_lequal_op_int(LOCAL2_OP
, tpm1_funcs
[i
]);
434 acpigen_write_return_integer(PPI8_RET_ALLOWED
);
435 acpigen_pop_len(); /* Pop : If */
437 } else if (CONFIG(TPM2
)) {
439 * Some functions do not require PP depending on configuration.
440 * Those aren't listed here, so the 'required PP' is always set for those.
442 static const u32 tpm2_funcs
[] = {
444 TPM2_SET_PP_REQUIRED_FOR_CLEAR_TRUE
,
445 TPM2_SET_PP_REQUIRED_FOR_CHANGE_PCRS_TRUE
,
446 TPM2_SET_PP_REQUIRED_FOR_TURN_ON_TRUE
,
447 TPM2_SET_PP_REQUIRED_FOR_CHANGE_EPS_TRUE
,
448 TPM2_SET_PP_REQUIRED_FOR_TURN_OFF_TRUE
,
449 TPM2_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_TRUE
,
450 TPM2_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_TRUE
,
452 for (size_t i
= 0; i
< ARRAY_SIZE(tpm2_funcs
); i
++) {
453 acpigen_write_if_lequal_op_int(LOCAL2_OP
, tpm2_funcs
[i
]);
454 acpigen_write_return_integer(PPI8_RET_ALLOWED
);
455 acpigen_pop_len(); /* Pop : If */
458 acpigen_write_return_integer(PPI8_RET_ALLOWED_WITH_PP
);
462 acpigen_write_return_integer(PPI8_RET_NOT_IMPLEMENTED
);
465 static void (*tpm_ppi_callbacks
[])(void *) = {
477 static void tpm_mci_func0_cb(void *arg
)
480 acpigen_write_return_singleton_buffer(0x3);
482 static void tpm_mci_func1_cb(void *arg
)
484 /* Just return success. */
485 acpigen_write_return_byte(0);
488 static void (*tpm_mci_callbacks
[])(void *) = {
493 void tpm_ppi_acpi_fill_ssdt(const struct device
*dev
)
495 struct cb_tpm_ppi_payload_handshake
*ppib
;
497 static const struct fieldlist list
[] = {
498 FIELDLIST_OFFSET(0x100),// FIXME: Add support for func
499 FIELDLIST_NAMESTR("PPIN", 8),// Not used
500 FIELDLIST_NAMESTR("PPIP", 32),// Not used
501 FIELDLIST_NAMESTR("RESU", 32),// Result of the last operation (TPM error code)
502 FIELDLIST_NAMESTR("CMDR", 32),// The command requested by OS. 0 for NOP
503 FIELDLIST_NAMESTR("OARG", 32),// The command optional argument requested by OS
504 FIELDLIST_NAMESTR("LCMD", 32),// The last command requested by OS.
505 FIELDLIST_NAMESTR("FRET", 32),// Not used
507 static const u8 tpm1_funcs
[] = {
515 TPM_DEACTIVATE_DISABLE
,
516 TPM_SETOWNERINSTALL_TRUE
,
517 TPM_SETOWNERINSTALL_FALSE
,
518 TPM_ENABLE_ACTIVATE_SETOWNERINSTALL_TRUE
,
519 TPM_SETOWNERINSTALL_FALSE_DEACTIVATE_DISABLE
,
520 TPM_CLEAR_ENABLE_ACTIVATE
,
521 TPM_SET_NOPPIPROVISION_FALSE
,
522 TPM_SET_NOPPIPROVISION_TRUE
,
523 TPM_ENABLE_ACTIVE_CLEAR
,
524 TPM_ENABLE_ACTIVE_CLEAR_ENABLE_ACTIVE
,
526 static const u8 tpm2_funcs
[] = {
531 TPM2_CLEAR_ENABLE_ACTIVE
,
532 TPM2_SET_PP_REQUIRED_FOR_CLEAR_TRUE
,
533 TPM2_SET_PP_REQUIRED_FOR_CLEAR_FALSE
,
538 TPM2_SET_PP_REQUIRED_FOR_CHANGE_PCRS_FALSE
,
539 TPM2_SET_PP_REQUIRED_FOR_CHANGE_PCRS_TRUE
,
540 TPM2_SET_PP_REQUIRED_FOR_TURN_ON_FALSE
,
541 TPM2_SET_PP_REQUIRED_FOR_TURN_ON_TRUE
,
542 TPM2_SET_PP_REQUIRED_FOR_TURN_OFF_FALSE
,
543 TPM2_SET_PP_REQUIRED_FOR_TURN_OFF_TRUE
,
544 TPM2_SET_PP_REQUIRED_FOR_CHANGE_EPS_FALSE
,
545 TPM2_SET_PP_REQUIRED_FOR_CHANGE_EPS_TRUE
,
547 TPM2_DISABLE_ENDORSMENT_ENABLE_STORAGE_HISTORY
,
548 TPM2_ENABLE_BLOCK_SID
,
549 TPM2_DISABLE_BLOCK_SID
,
550 TPM2_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_TRUE
,
551 TPM2_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FALSE
,
552 TPM2_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_TRUE
,
553 TPM2_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FALSE
,
557 * On hot reset/ACPI S3 the contents are preserved.
559 ppib
= (void *)cbmem_add(CBMEM_ID_TPM_PPI
, sizeof(*ppib
));
561 printk(BIOS_ERR
, "PPI: Failed to add CBMEM\n");
564 printk(BIOS_DEBUG
, "PPI: Pending OS request: 0x%x (0x%x)\n", ppib
->pprq
, ppib
->pprm
);
565 printk(BIOS_DEBUG
, "PPI: OS response: CMD 0x%x = 0x%x\n", ppib
->lppr
, ppib
->pprp
);
567 /* Clear unsupported fields */
569 ppib
->ppin
= 1; // Not used by ACPI. Read by EDK-2, must be 1.
575 /* Fill in defaults, the TPM command executor may overwrite this list */
576 memset(ppib
->func
, 0, sizeof(ppib
->func
));
578 for (size_t i
= 0; i
< ARRAY_SIZE(tpm1_funcs
); i
++) {
579 ppib
->func
[tpm1_funcs
[i
]] = 1;
580 if (ppib
->pprq
== tpm1_funcs
[i
])
584 for (size_t i
= 0; i
< ARRAY_SIZE(tpm2_funcs
); i
++) {
585 ppib
->func
[tpm2_funcs
[i
]] = 1;
586 if (ppib
->pprq
== tpm2_funcs
[i
])
597 /* Physical Presence OpRegion */
598 struct opregion opreg
= OPREGION("PPOP", SYSTEMMEMORY
, (uintptr_t)ppib
,
601 acpigen_write_opregion(&opreg
);
602 acpigen_write_field(opreg
.name
, list
, ARRAY_SIZE(list
),
603 FIELD_ANYACC
| FIELD_NOLOCK
| FIELD_PRESERVE
);
605 acpigen_write_name("TPM2");
606 acpigen_write_package(2);
607 acpigen_write_dword(0);
608 acpigen_write_dword(0);
609 acpigen_pop_len(); /* Package */
611 acpigen_write_name("TPM3");
612 acpigen_write_package(3);
613 acpigen_write_dword(0);
614 acpigen_write_dword(0);
615 acpigen_write_dword(0);
616 acpigen_pop_len(); /* Package */
619 * Returns One if the firmware implements this function.
621 * Arg0: Integer PPI function
623 acpigen_write_method_serialized("FUNC", 1);
625 acpigen_write_to_integer(ARG0_OP
, LOCAL0_OP
);
626 acpigen_write_to_integer(ARG1_OP
, LOCAL1_OP
);
628 acpigen_emit_byte(LGREATER_OP
);
629 acpigen_emit_byte(LOCAL0_OP
);
630 acpigen_write_integer(VENDOR_SPECIFIC_OFFSET
);
631 acpigen_write_return_integer(0);
632 acpigen_pop_len(); /* If */
634 /* TPPF = CreateField("PPOP", Local0) */
635 acpigen_emit_byte(CREATE_BYTE_OP
);
636 acpigen_emit_namestring("PPOP");
637 acpigen_emit_byte(LOCAL0_OP
);
638 acpigen_emit_namestring("TPPF");
640 /* Local0 = ToInteger("TPPF") */
641 acpigen_emit_byte(TO_INTEGER_OP
);
642 acpigen_emit_namestring("TPPF");
643 acpigen_emit_byte(LOCAL0_OP
);
645 acpigen_write_return_op(LOCAL0_OP
);
646 acpigen_pop_len(); /* Method */
649 * Returns One if the PPI spec supports this functions.
650 * That doesn't necessarily mean that the firmware implemtents it, or the
651 * TPM can execute the function.
653 * Arg0: Integer PPI function
654 * Arg1: Integer TPMversion (0: TPM2, 1: TPM1.2)
656 acpigen_write_method("FSUP", 2);
658 acpigen_write_to_integer(ARG0_OP
, LOCAL0_OP
);
659 acpigen_write_to_integer(ARG1_OP
, LOCAL1_OP
);
661 acpigen_emit_byte(LGREATER_OP
);
662 acpigen_emit_byte(LOCAL0_OP
);
663 acpigen_write_integer(VENDOR_SPECIFIC_OFFSET
);
664 acpigen_write_return_integer(0);
665 acpigen_pop_len(); /* If */
667 acpigen_write_if_lequal_op_int(LOCAL1_OP
, 1);
668 for (size_t i
= 0; i
< ARRAY_SIZE(tpm1_funcs
); i
++) {
669 acpigen_write_if_lequal_op_int(LOCAL0_OP
, tpm1_funcs
[i
]);
670 acpigen_write_return_integer(1);
671 acpigen_pop_len(); /* Pop : If */
673 acpigen_pop_len(); /* If */
675 acpigen_write_if_lequal_op_int(LOCAL1_OP
, 0);
677 for (size_t i
= 0; i
< ARRAY_SIZE(tpm2_funcs
); i
++) {
678 acpigen_write_if_lequal_op_int(LOCAL0_OP
, tpm2_funcs
[i
]);
679 acpigen_write_return_integer(1);
680 acpigen_pop_len(); /* Pop : If */
682 acpigen_pop_len(); /* If */
684 acpigen_write_return_integer(0);
685 acpigen_pop_len(); /* Method */
690 struct dsm_uuid ids
[] = {
691 /* Physical presence interface.
692 * This is used to submit commands like "Clear TPM" to
693 * be run at next reboot provided that user confirms
696 DSM_UUID(TPM_PPI_UUID
, &tpm_ppi_callbacks
[0],
697 ARRAY_SIZE(tpm_ppi_callbacks
), NULL
),
698 /* Memory clearing on boot: just a dummy. */
699 DSM_UUID(TPM_MCI_UUID
, &tpm_mci_callbacks
[0],
700 ARRAY_SIZE(tpm_mci_callbacks
), NULL
),
703 acpigen_write_dsm_uuid_arr(ids
, ARRAY_SIZE(ids
));
706 void lb_tpm_ppi(struct lb_header
*header
)
708 struct lb_tpm_physical_presence
*tpm_ppi
;
711 ppib
= cbmem_find(CBMEM_ID_TPM_PPI
);
715 tpm_ppi
= (struct lb_tpm_physical_presence
*)lb_new_record(header
);
716 tpm_ppi
->tag
= LB_TAG_TPM_PPI_HANDOFF
;
717 tpm_ppi
->size
= sizeof(*tpm_ppi
);
718 tpm_ppi
->ppi_address
= (uintptr_t)ppib
;
719 tpm_ppi
->tpm_version
= CONFIG(TPM1
) ? LB_TPM_VERSION_TPM_VERSION_1_2
:
720 LB_TPM_VERSION_TPM_VERSION_2
;
722 tpm_ppi
->ppi_version
= BCD(1, 3);