]> xenbits.xensource.com Git - seabios.git/commitdiff
smbios: Move smbios parsing logic from smbios.c to biostables.c.
authorKevin O'Connor <kevin@koconnor.net>
Mon, 7 Apr 2014 19:48:12 +0000 (15:48 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 7 Apr 2014 19:48:12 +0000 (15:48 -0400)
After this change, src/fw/smbios.c only contains the legacy code for
generating SMBIOS tables.  This change only contains code movement -
no logic is changed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/fw/biostables.c
src/fw/smbios.c
src/util.h

index b2a7231f1f4b44f3e3d33e6c3c58cb2790c553cb..48325a439bf3042aeaf3d0d323ee5ff54ad276e6 100644 (file)
@@ -231,6 +231,8 @@ find_acpi_features(void)
  * SMBIOS
  ****************************************************************/
 
+struct smbios_entry_point *SMBiosAddr;
+
 void
 copy_smbios(void *pos)
 {
@@ -255,6 +257,75 @@ copy_smbios(void *pos)
     SMBiosAddr = newpos;
 }
 
+void
+display_uuid(void)
+{
+    u32 addr, end;
+    u8 *uuid;
+    u8 empty_uuid[16] = { 0 };
+
+    if (SMBiosAddr == NULL)
+        return;
+
+    addr =        SMBiosAddr->structure_table_address;
+    end  = addr + SMBiosAddr->structure_table_length;
+
+    /* the following takes care of any initial wraparound too */
+    while (addr < end) {
+        const struct smbios_structure_header *hdr;
+
+        /* partial structure header */
+        if (end - addr < sizeof(struct smbios_structure_header))
+            return;
+
+        hdr = (struct smbios_structure_header *)addr;
+
+        /* partial structure */
+        if (end - addr < hdr->length)
+            return;
+
+        /* any Type 1 structure version will do that has the UUID */
+        if (hdr->type == 1 &&
+            hdr->length >= offsetof(struct smbios_type_1, uuid) + 16)
+            break;
+
+        /* done with formatted area, skip string-set */
+        addr += hdr->length;
+
+        while (end - addr >= 2 &&
+               (*(u8 *)addr     != '\0' ||
+                *(u8 *)(addr+1) != '\0'))
+            ++addr;
+
+        /* structure terminator not found */
+        if (end - addr < 2)
+            return;
+
+        addr += 2;
+    }
+
+    /* parsing finished or skipped entirely, UUID not found */
+    if (addr >= end)
+        return;
+
+    uuid = (u8 *)(addr + offsetof(struct smbios_type_1, uuid));
+    if (memcmp(uuid, empty_uuid, sizeof empty_uuid) == 0)
+        return;
+
+    printf("Machine UUID"
+             " %02x%02x%02x%02x"
+             "-%02x%02x"
+             "-%02x%02x"
+             "-%02x%02x"
+             "-%02x%02x%02x%02x%02x%02x\n"
+           , uuid[ 0], uuid[ 1], uuid[ 2], uuid[ 3]
+           , uuid[ 4], uuid[ 5]
+           , uuid[ 6], uuid[ 7]
+           , uuid[ 8], uuid[ 9]
+           , uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]);
+}
+
+
 void
 copy_table(void *pos)
 {
index 0c6a5b2ab8c54f3644074119ea74ab19b572137a..902e8abe0b6a50ac3ad504530f0640d9a3a768bd 100644 (file)
@@ -15,8 +15,6 @@
 #include "util.h" // MaxCountCPUs
 #include "x86.h" // cpuid
 
-struct smbios_entry_point *SMBiosAddr;
-
 static void
 smbios_entry_point_setup(u16 max_structure_size,
                          u16 structure_table_length,
@@ -589,71 +587,3 @@ smbios_setup(void)
     smbios_entry_point_setup(max_struct_size, p - start, start, nr_structs);
     free(start);
 }
-
-void
-display_uuid(void)
-{
-    u32 addr, end;
-    u8 *uuid;
-    u8 empty_uuid[16] = { 0 };
-
-    if (SMBiosAddr == NULL)
-        return;
-
-    addr =        SMBiosAddr->structure_table_address;
-    end  = addr + SMBiosAddr->structure_table_length;
-
-    /* the following takes care of any initial wraparound too */
-    while (addr < end) {
-        const struct smbios_structure_header *hdr;
-
-        /* partial structure header */
-        if (end - addr < sizeof(struct smbios_structure_header))
-            return;
-
-        hdr = (struct smbios_structure_header *)addr;
-
-        /* partial structure */
-        if (end - addr < hdr->length)
-            return;
-
-        /* any Type 1 structure version will do that has the UUID */
-        if (hdr->type == 1 &&
-            hdr->length >= offsetof(struct smbios_type_1, uuid) + 16)
-            break;
-
-        /* done with formatted area, skip string-set */
-        addr += hdr->length;
-
-        while (end - addr >= 2 &&
-               (*(u8 *)addr     != '\0' ||
-                *(u8 *)(addr+1) != '\0'))
-            ++addr;
-
-        /* structure terminator not found */
-        if (end - addr < 2)
-            return;
-
-        addr += 2;
-    }
-
-    /* parsing finished or skipped entirely, UUID not found */
-    if (addr >= end)
-        return;
-
-    uuid = (u8 *)(addr + offsetof(struct smbios_type_1, uuid));
-    if (memcmp(uuid, empty_uuid, sizeof empty_uuid) == 0)
-        return;
-
-    printf("Machine UUID"
-             " %02x%02x%02x%02x"
-             "-%02x%02x"
-             "-%02x%02x"
-             "-%02x%02x"
-             "-%02x%02x%02x%02x%02x%02x\n"
-           , uuid[ 0], uuid[ 1], uuid[ 2], uuid[ 3]
-           , uuid[ 4], uuid[ 5]
-           , uuid[ 6], uuid[ 7]
-           , uuid[ 8], uuid[ 9]
-           , uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]);
-}
index 2201da2971f7176e7db7a77380087673e13f3a48..088437bcfeb5f173c284f7242e0f8c749c571d0e 100644 (file)
@@ -70,7 +70,9 @@ void *find_acpi_rsdp(void);
 u32 find_resume_vector(void);
 void acpi_reboot(void);
 void find_acpi_features(void);
+extern struct smbios_entry_point *SMBiosAddr;
 void copy_smbios(void *pos);
+void display_uuid(void);
 void copy_table(void *pos);
 
 // fw/coreboot.c
@@ -109,9 +111,7 @@ void make_bios_readonly(void);
 void qemu_prep_reset(void);
 
 // fw/smbios.c
-extern struct smbios_entry_point *SMBiosAddr;
 void smbios_setup(void);
-void display_uuid(void);
 
 // fw/smm.c
 void smm_device_setup(void);