aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2015-11-22 11:15:51 -0500
committerKevin O'Connor <kevin@koconnor.net>2015-11-22 19:23:03 -0500
commit7ea191bb4127052bfd5088584f0a93dd20d8d558 (patch)
treef9d3e2812a7fb94afd099c29aac7a233d2fe2a0d
parentf4820ac1269b3c855edc0d5139d4b4c319ef0e69 (diff)
downloadseabios-hppa-7ea191bb4127052bfd5088584f0a93dd20d8d558.zip
seabios-hppa-7ea191bb4127052bfd5088584f0a93dd20d8d558.tar.gz
seabios-hppa-7ea191bb4127052bfd5088584f0a93dd20d8d558.tar.bz2
tpm: Open code tpm_ipl() into callers
The only three callers of tpm_ipl() exactly correlate with the three switch branches in tpm_ipl(), so just move the appropriate code into the callers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/tcgbios.c80
-rw-r--r--src/tcgbios.h6
2 files changed, 24 insertions, 62 deletions
diff --git a/src/tcgbios.c b/src/tcgbios.c
index 88652fe..1f73593 100644
--- a/src/tcgbios.c
+++ b/src/tcgbios.c
@@ -930,59 +930,6 @@ tpm_add_bootdevice(u32 bootcd, u32 bootdrv)
(u8 *)string, strlen(string));
}
-/*
- * Add a measurement related to Initial Program Loader to the log.
- * Creates two log entries.
- *
- * Input parameter:
- * bootcd : 0: MBR of hdd, 1: boot image, 2: boot catalog of El Torito
- * addr : address where the IP data are located
- * length : IP data length in bytes
- */
-static u32
-tpm_ipl(enum ipltype bootcd, const u8 *addr, u32 length)
-{
- u32 rc;
- const char *string;
-
- switch (bootcd) {
- case IPL_EL_TORITO_1:
- /* specs: see section 'El Torito' */
- string = "EL TORITO IPL";
- rc = tpm_add_measurement_to_log(4, EV_IPL,
- string, strlen(string),
- addr, length);
- break;
-
- case IPL_EL_TORITO_2:
- /* specs: see section 'El Torito' */
- string = "BOOT CATALOG";
- rc = tpm_add_measurement_to_log(5, EV_IPL_PARTITION_DATA,
- string, strlen(string),
- addr, length);
- break;
-
- default:
- /* specs: see section 'Hard Disk Device or Hard Disk-Like Devices' */
- /* equivalent to: dd if=/dev/hda ibs=1 count=440 | sha1sum */
- string = "MBR";
- rc = tpm_add_measurement_to_log(4, EV_IPL,
- string, strlen(string),
- addr, 0x1b8);
-
- if (rc)
- break;
-
- /* equivalent to: dd if=/dev/hda ibs=1 count=72 skip=440 | sha1sum */
- string = "MBR PARTITION_TABLE";
- rc = tpm_add_measurement_to_log(5, EV_IPL_PARTITION_DATA,
- string, strlen(string),
- addr + 0x1b8, 0x48);
- }
-
- return rc;
-}
-
u32
tpm_add_bcv(u32 bootdrv, const u8 *addr, u32 length)
{
@@ -996,7 +943,20 @@ tpm_add_bcv(u32 bootdrv, const u8 *addr, u32 length)
if (rc)
return rc;
- return tpm_ipl(IPL_BCV, addr, length);
+ /* specs: see section 'Hard Disk Device or Hard Disk-Like Devices' */
+ /* equivalent to: dd if=/dev/hda ibs=1 count=440 | sha1sum */
+ const char *string = "MBR";
+ rc = tpm_add_measurement_to_log(4, EV_IPL,
+ string, strlen(string),
+ addr, 0x1b8);
+ if (rc)
+ return rc;
+
+ /* equivalent to: dd if=/dev/hda ibs=1 count=72 skip=440 | sha1sum */
+ string = "MBR PARTITION_TABLE";
+ return tpm_add_measurement_to_log(5, EV_IPL_PARTITION_DATA,
+ string, strlen(string),
+ addr + 0x1b8, 0x48);
}
u32
@@ -1012,7 +972,11 @@ tpm_add_cdrom(u32 bootdrv, const u8 *addr, u32 length)
if (rc)
return rc;
- return tpm_ipl(IPL_EL_TORITO_1, addr, length);
+ /* specs: see section 'El Torito' */
+ const char *string = "EL TORITO IPL";
+ return tpm_add_measurement_to_log(4, EV_IPL,
+ string, strlen(string),
+ addr, length);
}
u32
@@ -1028,7 +992,11 @@ tpm_add_cdrom_catalog(const u8 *addr, u32 length)
if (rc)
return rc;
- return tpm_ipl(IPL_EL_TORITO_2, addr, length);
+ /* specs: see section 'El Torito' */
+ const char *string = "BOOT CATALOG";
+ return tpm_add_measurement_to_log(5, EV_IPL_PARTITION_DATA,
+ string, strlen(string),
+ addr, length);
}
void
diff --git a/src/tcgbios.h b/src/tcgbios.h
index 26a492c..0f9d5c3 100644
--- a/src/tcgbios.h
+++ b/src/tcgbios.h
@@ -11,12 +11,6 @@ struct iovec
const void *data;
};
-enum ipltype {
- IPL_BCV = 0,
- IPL_EL_TORITO_1,
- IPL_EL_TORITO_2
-};
-
struct bregs;
void tpm_interrupt_handler32(struct bregs *regs);