[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] hvmloader: allow the possibility to allocate the size of smbios table



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1306943363 -3600
# Node ID 303635b6fe5bd523e0919b0e60fd69b1a4322c55
# Parent  58a141a84d0f7e5d6c82a3f4fe1b23304b7177e2
hvmloader: allow the possibility to allocate the size of smbios table
we actually need.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---


diff -r 58a141a84d0f -r 303635b6fe5b tools/firmware/hvmloader/seabios.c
--- a/tools/firmware/hvmloader/seabios.c        Wed Jun 01 16:49:03 2011 +0100
+++ b/tools/firmware/hvmloader/seabios.c        Wed Jun 01 16:49:23 2011 +0100
@@ -103,8 +103,7 @@
 static void seabios_create_smbios_tables(void)
 {
     uint32_t ep = (uint32_t)scratch_alloc(sizeof(struct smbios_entry_point), 
0);
-    uint32_t t = (uint32_t)mem_alloc(32*1024, 0);
-    hvm_write_smbios_tables(ep, t, 32*1024);
+    hvm_write_smbios_tables(ep, 0UL, 0UL);
     add_table(ep);
 }
 
diff -r 58a141a84d0f -r 303635b6fe5b tools/firmware/hvmloader/smbios.c
--- a/tools/firmware/hvmloader/smbios.c Wed Jun 01 16:49:03 2011 +0100
+++ b/tools/firmware/hvmloader/smbios.c Wed Jun 01 16:49:23 2011 +0100
@@ -28,10 +28,11 @@
 #include "hypercall.h"
 
 static int
-write_smbios_tables(void *ep, void *start, unsigned long phys,
+write_smbios_tables(void *ep, void *start,
                     uint32_t vcpus, uint64_t memsize,
                     uint8_t uuid[16], char *xen_version,
-                    uint32_t xen_major_version, uint32_t xen_minor_version);
+                    uint32_t xen_major_version, uint32_t xen_minor_version,
+                    unsigned *nr_structs, unsigned *max_struct_size);
 
 static void
 get_cpu_manufacturer(char *buf, int len);
@@ -85,12 +86,13 @@
 }
 
 static int
-write_smbios_tables(void *ep, void *start, unsigned long phys,
+write_smbios_tables(void *ep, void *start,
                     uint32_t vcpus, uint64_t memsize,
                     uint8_t uuid[16], char *xen_version,
-                    uint32_t xen_major_version, uint32_t xen_minor_version)
+                    uint32_t xen_major_version, uint32_t xen_minor_version,
+                    unsigned *nr_structs, unsigned *max_struct_size)
 {
-    unsigned cpu_num, nr_structs = 0, max_struct_size = 0;
+    unsigned cpu_num;
     char *p, *q;
     char cpu_manufacturer[15];
     int i, nr_mem_devs;
@@ -101,9 +103,9 @@
 
 #define do_struct(fn) do {                      \
     q = (fn);                                   \
-    nr_structs++;                               \
-    if ( (q - p) > max_struct_size )            \
-        max_struct_size = q - p;                \
+    (*nr_structs)++;                            \
+    if ( (q - p) > *max_struct_size )           \
+        *max_struct_size = q - p;               \
     p = q;                                      \
 } while (0)
 
@@ -133,10 +135,6 @@
 
 #undef do_struct
 
-    smbios_entry_point_init(ep, max_struct_size,
-                            (p - (char *)start), phys,
-                            nr_structs);
-
     return ((char *)p - (char *)start);
 }
 
@@ -159,7 +157,7 @@
     return (sz + (1ul << 20) - 1) >> 20;
 }
 
-int
+void
 hvm_write_smbios_tables(unsigned long ep, unsigned long smbios_start, unsigned 
long smbios_end)
 {
     xen_domain_handle_t uuid;
@@ -173,6 +171,7 @@
     unsigned len = 0; /* length of string already composed */
     char tmp[16]; /* holds result of itoa() */
     unsigned tmp_len; /* length of next string to add */
+    unsigned nr_structs = 0, max_struct_size = 0;
 
     hypercall_xen_version(XENVER_guest_handle, uuid);
     BUILD_BUG_ON(sizeof(xen_domain_handle_t) != 16);
@@ -220,21 +219,26 @@
     xen_version_str[sizeof(xen_version_str)-1] = '\0';
 
     /* scratch_start is a safe large memory area for scratch. */
-    len = write_smbios_tables((void *)ep, (void *)scratch_start, smbios_start,
+    len = write_smbios_tables((void *)ep, (void *)scratch_start,
                               hvm_info->nr_vcpus, get_memsize(),
                               uuid, xen_version_str,
-                              xen_major_version, xen_minor_version);
-    if ( smbios_start + len > smbios_end )
+                              xen_major_version, xen_minor_version,
+                              &nr_structs, &max_struct_size);
+    if ( smbios_start && smbios_start + len > smbios_end )
         goto error_out;
-    /* Okay, not too large: copy out of scratch to final location. */
+
+    if ( !smbios_start )
+        smbios_start = (unsigned long)mem_alloc(len, 0);
+
     memcpy((void *)smbios_start, (void *)scratch_start, len);
 
-    return len;
+    smbios_entry_point_init((void *)ep, max_struct_size, len, smbios_start, 
nr_structs);
+
+    return;
 
  error_out:
     printf("Could not write SMBIOS tables, error in hvmloader.c:"
            "hvm_write_smbios_tables()\n");
-    return 0;
 }
 
 
diff -r 58a141a84d0f -r 303635b6fe5b tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h   Wed Jun 01 16:49:03 2011 +0100
+++ b/tools/firmware/hvmloader/util.h   Wed Jun 01 16:49:23 2011 +0100
@@ -192,7 +192,7 @@
 /* Miscellaneous. */
 void cacheattr_init(void);
 unsigned long create_mp_tables(void *table);
-int hvm_write_smbios_tables(unsigned long ep,
+void hvm_write_smbios_tables(unsigned long ep,
                            unsigned long smbios_start,
                            unsigned long smbios_end);
 void smp_initialise(void);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.