# HG changeset patch # User Tim Deegan # 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. Signed-off-by: Tim Deegan diff -r 62b933815016 -r 1db4a00d6829 tools/firmware/hvmloader/smbios.c --- a/tools/firmware/hvmloader/smbios.c Fri Jul 09 11:27:29 2010 +0100 +++ b/tools/firmware/hvmloader/smbios.c Fri Jul 09 11:27:32 2010 +0100 @@ -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; } diff -r 62b933815016 -r 1db4a00d6829 tools/firmware/hvmloader/smbios_types.h --- a/tools/firmware/hvmloader/smbios_types.h Fri Jul 09 11:27:29 2010 +0100 +++ b/tools/firmware/hvmloader/smbios_types.h Fri Jul 09 11:27:32 2010 +0100 @@ -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). */