grml...
[seabios.git] / src / smbios.c
index 8df0f2da49f5b7efade00081bdb66868f08f8c81..fe1e1835f6ad07797eb469f6384c203ede4319a5 100644 (file)
@@ -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,
@@ -17,7 +19,13 @@ smbios_entry_point_init(u16 max_structure_size,
                         u16 number_of_structures)
 {
     struct smbios_entry_point *ep = malloc_fseg(sizeof(*ep));
-    void *finaltable = malloc_high(structure_table_length);
+    void *finaltable;
+    if (structure_table_length <= BUILD_MAX_SMBIOS_FSEG)
+        // Table is small enough for f-seg - allocate there.  This
+        // works around a bug in JunOS (at least for small SMBIOS tables).
+        finaltable = malloc_fseg(structure_table_length);
+    else
+        finaltable = malloc_high(structure_table_length);
     if (!ep || !finaltable) {
         warn_noalloc();
         free(ep);
@@ -44,7 +52,9 @@ smbios_entry_point_init(u16 max_structure_size,
 
     ep->intermediate_checksum -= checksum((void*)ep + 0x10, ep->length - 0x10);
 
-    dprintf(1, "SMBIOS ptr=%p table=%p\n", ep, finaltable);
+    SMBiosAddr = ep;
+    dprintf(1, "SMBIOS ptr=%p table=%p size=%d\n"
+            , ep, finaltable, structure_table_length);
 }
 
 #define load_str_field_with_default(type, field, def)                   \