# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1306917980 -3600
# Node ID 7e6e8594316a62193f9ab629ee2b8848224cce22
# Parent 5d695cfaded597bb9e70818a9225bde3a91d3355
hvmloader: allow the possibility to allocate the size of smbios table we
actually need.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
diff -r 5d695cfaded5 -r 7e6e8594316a tools/firmware/hvmloader/seabios.c
--- a/tools/firmware/hvmloader/seabios.c Wed Jun 01 09:45:58 2011 +0100
+++ b/tools/firmware/hvmloader/seabios.c Wed Jun 01 09:46:20 2011 +0100
@@ -103,8 +103,7 @@ static void seabios_create_mp_tables(voi
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 5d695cfaded5 -r 7e6e8594316a tools/firmware/hvmloader/smbios.c
--- a/tools/firmware/hvmloader/smbios.c Wed Jun 01 09:45:58 2011 +0100
+++ b/tools/firmware/hvmloader/smbios.c Wed Jun 01 09:46:20 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 @@ get_cpu_manufacturer(char *buf, int len)
}
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 @@ write_smbios_tables(void *ep, void *star
#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 @@ write_smbios_tables(void *ep, void *star
#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 @@ get_memsize(void)
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 @@ hvm_write_smbios_tables(unsigned long ep
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 @@ hvm_write_smbios_tables(unsigned long ep
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 5d695cfaded5 -r 7e6e8594316a tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h Wed Jun 01 09:45:58 2011 +0100
+++ b/tools/firmware/hvmloader/util.h Wed Jun 01 09:46:20 2011 +0100
@@ -192,7 +192,7 @@ uint32_t rombios_highbios_setup(void);
/* 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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|