[SeaBIOS] [PATCH] copy SMBIOS table from coreboot

Kevin O'Connor kevin at koconnor.net
Fri Aug 19 02:36:35 CEST 2011


On Thu, Aug 18, 2011 at 08:40:57PM +0200, Sven Schnelle wrote:
> Signed-off-by: Sven Schnelle <svens at stackframe.org>
> ---
>  src/coreboot.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/src/coreboot.c b/src/coreboot.c
> index 5926939..46f25f1 100644
> --- a/src/coreboot.c
> +++ b/src/coreboot.c
> @@ -201,6 +201,7 @@ scan_tables(u32 start, u32 size)
>          copy_pir(p);
>          copy_mptable(p);
>          copy_acpi_rsdp(p);
> +	copy_smbios(p);
>      }

Thanks.  I'd like to see SeaBIOS be able to use an smbios table from
coreboot.  However, I think it needs to be a little smarter - your
patch above would result in two smbios tables (one copied from
coreboot and one created by SeaBIOS).

I think it needs to be something like what's below (totally untested).

-Kevin


diff --git a/src/biostables.c b/src/biostables.c
index d8b5067..57a5c57 100644
--- a/src/biostables.c
+++ b/src/biostables.c
@@ -86,6 +86,8 @@ copy_acpi_rsdp(void *pos)
 void
 copy_smbios(void *pos)
 {
+    if (SMBiosAddr)
+        return;
     struct smbios_entry_point *p = pos;
     if (memcmp(p->anchor_string, "_SM_", 4))
         return;
@@ -102,4 +104,5 @@ copy_smbios(void *pos)
     }
     dprintf(1, "Copying SMBIOS entry point from %p to %p\n", pos, newpos);
     memcpy(newpos, pos, p->length);
+    SMBiosAddr = newpos;
 }
diff --git a/src/coreboot.c b/src/coreboot.c
index 5926939..ee9dd8b 100644
--- a/src/coreboot.c
+++ b/src/coreboot.c
@@ -201,6 +201,7 @@ scan_tables(u32 start, u32 size)
         copy_pir(p);
         copy_mptable(p);
         copy_acpi_rsdp(p);
+        copy_smbios(p);
     }
 }
 
@@ -221,9 +222,9 @@ coreboot_copy_biostable(void)
             scan_tables(m->start, m->size);
     }
 
-    // XXX - just create dummy smbios table for now - should detect if
-    // smbios/dmi table is found from coreboot and use that instead.
-    smbios_init();
+    // XXX - create a dummy smbios table for now.
+    if (!SMBiosAddr)
+        smbios_init();
 }
 
 
diff --git a/src/smbios.c b/src/smbios.c
index 7db8cce..fe1e183 100644
--- a/src/smbios.c
+++ b/src/smbios.c
@@ -10,6 +10,8 @@
 #include "paravirt.h" // qemu_cfg_smbios_load_field
 #include "smbios.h" // struct smbios_entry_point
 
+struct smbios_entry_point *SMBiosAddr;
+
 static void
 smbios_entry_point_init(u16 max_structure_size,
                         u16 structure_table_length,
@@ -50,6 +52,7 @@ smbios_entry_point_init(u16 max_structure_size,
 
     ep->intermediate_checksum -= checksum((void*)ep + 0x10, ep->length - 0x10);
 
+    SMBiosAddr = ep;
     dprintf(1, "SMBIOS ptr=%p table=%p size=%d\n"
             , ep, finaltable, structure_table_length);
 }
diff --git a/src/smbios.h b/src/smbios.h
index 7bf2bed..9d54e80 100644
--- a/src/smbios.h
+++ b/src/smbios.h
@@ -24,6 +24,8 @@ struct smbios_entry_point {
     u8 smbios_bcd_revision;
 } PACKED;
 
+extern struct smbios_entry_point *SMBiosAddr;
+
 /* This goes at the beginning of every SMBIOS structure. */
 struct smbios_structure_header {
     u8 type;




More information about the SeaBIOS mailing list