[SeaBIOS] [PATCH v2 2/6] Move assert_physical_presence and dependencies
Stefan Berger
stefanb at us.ibm.com
Thu Jan 7 13:55:37 CET 2016
From: Stefan Berger <stefanb at linux.vnet.ibm.com>
Move assert_physical_presence and dependencies in front of tpm_startup
so that the next patches can assert physical presence after TPM_ORD_Startup
ran.
Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
---
src/tcgbios.c | 146 +++++++++++++++++++++++++++++-----------------------------
1 file changed, 73 insertions(+), 73 deletions(-)
diff --git a/src/tcgbios.c b/src/tcgbios.c
index 965874c..51b3e78 100644
--- a/src/tcgbios.c
+++ b/src/tcgbios.c
@@ -410,6 +410,79 @@ tpm_smbios_measure(void)
(u8 *)&pcctes, sizeof(pcctes));
}
+static u32
+read_stclear_flags(char *buf, int buf_len)
+{
+ memset(buf, 0, buf_len);
+
+ struct tpm_res_getcap_stclear_flags stcf;
+ int ret = tpm_get_capability(TPM_CAP_FLAG, TPM_CAP_FLAG_VOLATILE
+ , &stcf.hdr, sizeof(stcf));
+ if (ret) {
+ dprintf(DEBUG_tcg, "Error reading STClear flags: 0x%08x\n", ret);
+ return -1;
+ }
+
+ memcpy(buf, &stcf.stclear_flags, buf_len);
+
+ return 0;
+}
+
+static int
+read_permanent_flags(char *buf, int buf_len)
+{
+ memset(buf, 0, buf_len);
+
+ struct tpm_res_getcap_perm_flags pf;
+ int ret = tpm_get_capability(TPM_CAP_FLAG, TPM_CAP_FLAG_PERMANENT
+ , &pf.hdr, sizeof(pf));
+ if (ret)
+ return -1;
+
+ memcpy(buf, &pf.perm_flags, buf_len);
+
+ return 0;
+}
+
+static u32
+assert_physical_presence(int verbose)
+{
+ struct tpm_stclear_flags stcf;
+ int ret = read_stclear_flags((char *)&stcf, sizeof(stcf));
+ if (ret)
+ return -1;
+
+ if (stcf.flags[STCLEAR_FLAG_IDX_PHYSICAL_PRESENCE])
+ /* physical presence already asserted */
+ return 0;
+
+ ret = tpm_send_check_cmd(0, TPM_ORD_PhysicalPresence,
+ PhysicalPresence_CMD_ENABLE,
+ sizeof(PhysicalPresence_CMD_ENABLE),
+ TPM_DURATION_TYPE_SHORT);
+ if (ret) {
+ if (verbose)
+ printf("Error: Could not enable physical presence.\n\n");
+ goto err_exit;
+ }
+
+ ret = tpm_send_check_cmd(0, TPM_ORD_PhysicalPresence,
+ PhysicalPresence_PRESENT,
+ sizeof(PhysicalPresence_PRESENT),
+ TPM_DURATION_TYPE_SHORT);
+ if (ret) {
+ if (verbose)
+ printf("Error: Could not set presence flag.\n\n");
+ goto err_exit;
+ }
+
+ return 0;
+
+err_exit:
+ dprintf(DEBUG_tcg, "TCGBIOS: Asserting physical presence failed: %x\n", ret);
+ return -1;
+}
+
static int
tpm_startup(void)
{
@@ -876,79 +949,6 @@ tpm_interrupt_handler32(struct bregs *regs)
* TPM Configuration Menu
****************************************************************/
-static u32
-read_stclear_flags(char *buf, int buf_len)
-{
- memset(buf, 0, buf_len);
-
- struct tpm_res_getcap_stclear_flags stcf;
- int ret = tpm_get_capability(TPM_CAP_FLAG, TPM_CAP_FLAG_VOLATILE
- , &stcf.hdr, sizeof(stcf));
- if (ret) {
- dprintf(DEBUG_tcg, "Error reading STClear flags: 0x%08x\n", ret);
- return -1;
- }
-
- memcpy(buf, &stcf.stclear_flags, buf_len);
-
- return 0;
-}
-
-static u32
-assert_physical_presence(int verbose)
-{
- struct tpm_stclear_flags stcf;
- int ret = read_stclear_flags((char *)&stcf, sizeof(stcf));
- if (ret)
- return -1;
-
- if (stcf.flags[STCLEAR_FLAG_IDX_PHYSICAL_PRESENCE])
- /* physical presence already asserted */
- return 0;
-
- ret = tpm_send_check_cmd(0, TPM_ORD_PhysicalPresence,
- PhysicalPresence_CMD_ENABLE,
- sizeof(PhysicalPresence_CMD_ENABLE),
- TPM_DURATION_TYPE_SHORT);
- if (ret) {
- if (verbose)
- printf("Error: Could not enable physical presence.\n\n");
- goto err_exit;
- }
-
- ret = tpm_send_check_cmd(0, TPM_ORD_PhysicalPresence,
- PhysicalPresence_PRESENT,
- sizeof(PhysicalPresence_PRESENT),
- TPM_DURATION_TYPE_SHORT);
- if (ret) {
- if (verbose)
- printf("Error: Could not set presence flag.\n\n");
- goto err_exit;
- }
-
- return 0;
-
-err_exit:
- dprintf(DEBUG_tcg, "TCGBIOS: Asserting physical presence failed: %x\n", ret);
- return -1;
-}
-
-static int
-read_permanent_flags(char *buf, int buf_len)
-{
- memset(buf, 0, buf_len);
-
- struct tpm_res_getcap_perm_flags pf;
- int ret = tpm_get_capability(TPM_CAP_FLAG, TPM_CAP_FLAG_PERMANENT
- , &pf.hdr, sizeof(pf));
- if (ret)
- return -1;
-
- memcpy(buf, &pf.perm_flags, buf_len);
-
- return 0;
-}
-
static int
read_has_owner(int *has_owner)
{
--
2.4.3
More information about the SeaBIOS
mailing list