]> xenbits.xensource.com Git - seabios.git/commitdiff
tpm: Open code tpm_ipl() into callers
authorKevin O'Connor <kevin@koconnor.net>
Sun, 22 Nov 2015 16:15:51 +0000 (11:15 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 23 Nov 2015 00:23:03 +0000 (19:23 -0500)
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>
src/tcgbios.c
src/tcgbios.h

index 88652fecd6dc5aaac9dbd5b3a98b45b0da8c5634..1f73593c665de9e3265b3f084681a44913152574 100644 (file)
@@ -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
index 26a492c1638993c584601801d01c86e95555d110..0f9d5c3b1227bf949e929703b36f484dfc845dec 100644 (file)
@@ -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);