HVM firmware: customize the SMBIOS strings based on xenstore keys
PATCH 1/1 HVM firmware: customize the SMBIOS strings based on xenstore keys
These patches add a read-only xenstore client to hvmloader, and use it to customize the SMBIOS strings based on xenstore keys
PATCH 1/1 Add a xenbus frontend to hvmloader so it can read values from xenstore
# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1278671249 -3600
# Node ID 62b9338150160d6f7cea3e2c386f5e6f94e1b13b
# Parent 82f8371effffc7f3f405fc524cf27c3f07d27249
Add a xenbus frontend to hvmloader so it can read values from xenstore.
tools/firmware/hvmloader/Makefile +1 -1
@@ -29,7 +29,7 @@ CFLAGS += $(CFLAGS_include) -I. SRCS = hvmloader.c mp_tables.c util.c smbios.c -SRCS += 32bitbios_support.c smp.c cacheattr.c +SRCS += 32bitbios_support.c smp.c cacheattr.c xenbus.c ifeq ($(debug),y) SRCS += tests.c endif
tools/firmware/hvmloader/hvmloader.c +3 -0
@@ -704,6 +704,7 @@printf ("CPU speed is %u MHz\n" ,get_cpu_mhz ()); +xenbus_setup ();apic_setup ();pci_setup ();
@@ -803,6 +804,8 @@ bios_info->madt_lapic0_addr = madt_lapic0_addr; bios_info->bios32_entry = bios32_addr; +xenbus_shutdown (); +printf ("Invoking ROMBIOS ...\n" );return 0 ; }
tools/firmware/hvmloader/util.h +12 -0
@@ -155,6 +155,18 @@void *mem_alloc (uint32_t size,uint32_t align);#define virt_to_phys (v) ((unsigned long)(v)) +/* Connect our xenbus client to the backend. +* Call once, before any other xenbus actions. */ +void xenbus_setup (void ); + +/* Reset the xenbus connection so the next kernel can start again. */ +void xenbus_shutdown (void ); + +/* Read a xenstore key. Returns a nul-terminated string (even if the XS +* data wasn't nul-terminated) or NULL. The returned string is in a +* static buffer, so only valid until the next xenstore/xenbus operation. */ +char *xenstore_read (char *path); +/* Prepare the 32bit BIOS */ uint32_t highbios_setup (void );
tools/firmware/hvmloader/xenbus.c new file +193 -0
193 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
PATCH 1/1 HVM firmware: customize the SMBIOS strings based on xenstore keys
In reply to Tim Deeganwritten at domain creation time by xapi.
# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1278671252 -3600
# Node ID 1db4a00d68296688445df0455ff21fca1af42ab7
# Parent 62b9338150160d6f7cea3e2c386f5e6f94e1b13b
HVM firmware: customize the SMBIOS strings based on xenstore keys written at domain creation time by xapi.
tools/firmware/hvmloader/smbios.c +78 -12
@@ -53,6 +53,8 @@static void *smbios_type_4_init (void *start,unsigned int cpu_number,char *cpu_manufacturer); +static void * +smbios_type_11_init (void *start);static void *smbios_type_16_init (void *start,uint32_t memory_size_mb,int nr_mem_devs); static void *
@@ -112,6 +114,7 @@do_struct (smbios_type_3_init (p));for ( cpu_num =1 ; cpu_num <= vcpus; cpu_num++ )do_struct (smbios_type_4_init (p, cpu_num, cpu_manufacturer)); +do_struct (smbios_type_11_init (p));/* Each 'memory device' covers up to 16GB of address space. */ nr_mem_devs = (memsize +0x3fff ) >>14 ;
@@ -283,6 +286,7 @@ {struct smbios_type_0 *p = (struct smbios_type_0 *)start;static const char *smbios_release_date = __SMBIOS_DATE__; +const char *s;memset (p,0 ,sizeof (*p));
@@ -309,10 +313,16 @@ p->embedded_controller_minor =0xff ; start +=sizeof (struct smbios_type_0 ); -strcpy ((char *)start,"Xen" ); - start +=strlen ("Xen" ) +1 ; -strcpy ((char *)start, xen_version); - start +=strlen (xen_version) +1 ; +if ((s =xenstore_read ("bios-strings/bios-vendor" )) ==NULL || *s =='\0' ) + s ="Xen" ; +strcpy ((char *)start, s); + start +=strlen (s) +1 ; + +if ((s =xenstore_read ("bios-strings/bios-version" )) ==NULL || *s =='\0' ) + s = xen_version; +strcpy ((char *)start, s); + start +=strlen (s) +1 ; +strcpy ((char *)start, smbios_release_date); start +=strlen (smbios_release_date) +1 ;
@@ -327,6 +337,7 @@ {char uuid_str[37 ];struct smbios_type_1 *p = (struct smbios_type_1 *)start; +const char *s;memset (p,0 ,sizeof (*p));
@@ -347,15 +358,31 @@ start +=sizeof (struct smbios_type_1 ); -strcpy ((char *)start,"Xen" ); - start +=strlen ("Xen" ) +1 ; -strcpy ((char *)start,"HVM domU" ); - start +=strlen ("HVM domU" ) +1 ; -strcpy ((char *)start, xen_version); - start +=strlen (xen_version) +1 ; +if ((s =xenstore_read ("bios-strings/system-manufacturer" )) ==NULL + || *s =='\0' ) + s ="Xen" ; +strcpy ((char *)start, s); + start +=strlen (s) +1 ; + +if ((s =xenstore_read ("bios-strings/system-product-name" )) ==NULL + || *s =='\0' ) + s ="HVM domU" ; +strcpy ((char *)start, s); + start +=strlen (s) +1 ; + +if ((s =xenstore_read ("bios-strings/system-version" )) ==NULL + || *s =='\0' ) + s = xen_version; +strcpy ((char *)start, s); + start +=strlen (s) +1 ; +uuid_to_string (uuid_str, uuid); -strcpy ((char *)start, uuid_str); - start +=strlen (uuid_str) +1 ; +if ((s =xenstore_read ("bios-strings/system-serial-number" )) ==NULL + || *s =='\0' ) + s = uuid_str; +strcpy ((char *)start, s); + start +=strlen (s) +1 ; + *((uint8_t *)start) =0 ;return start+1 ;
@@ -438,6 +465,45 @@ start +=strlen (cpu_manufacturer) +1 ; *((uint8_t *)start) =0 ; +return start+1 ; +} + +/* Type 11 -- OEM Strings */ +static void * +smbios_type_11_init (void *start) +{ +struct smbios_type_11 *p = (struct smbios_type_11 *)start; +char path[20 ] ="bios-strings/oem-XX" ; +const char *s; +int i; + + p->header.type =11 ; + p->header.length =sizeof (struct smbios_type_11 ); + p->header.handle =0xB00 ; + + p->count =0 ; + + start +=sizeof (struct smbios_type_11 ); + +/* Pull out as many oem-* strings we find in xenstore */ +for (i =1 ; i <100 ; i++) { + path[(sizeof path) -3 ] ='0' + ((i <10 ) ? i : i /10 ); + path[(sizeof path) -2 ] = (i <10 ) ?'\0' :'0' + (i %10 ); +if ((s =xenstore_read (path)) ==NULL || *s =='\0' ) +break ; +strcpy ((char *)start, s); + start +=strlen (s) +1 ; + p->count++; + } + +/* Make sure there's at least one type-11 string */ +if (p->count ==0 ) { +strcpy ((char *)start,"Xen" ); + start +=strlen ("Xen" ) +1 ; + p->count++; + } + *((uint8_t *)start) =0 ; +return start+1 ; }
tools/firmware/hvmloader/smbios_types.h +6 -0
@@ -115,6 +115,12 @@uint8_t upgrade; } __attribute__ ((packed)); +/* SMBIOS type 11 - OEM Strings */ +struct smbios_type_11 { +struct smbios_structure_header header; +uint8_t count; +} __attribute__ ((packed)); +/* SMBIOS type 16 - Physical Memory Array * Associated with one type 17 (Memory Device). */
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel