]> xenbits.xen.org Git - xenclient/xen.git/commitdiff
patch compiled_vendor_smbios
authorVincent Hanquez <vincent@snarc.org>
Wed, 17 Dec 2008 17:32:01 +0000 (17:32 +0000)
committerVincent Hanquez <vincent@snarc.org>
Wed, 17 Dec 2008 17:32:01 +0000 (17:32 +0000)
tools/firmware/hvmloader/smbios.c
tools/firmware/hvmloader/smbios_types.h

index e1464220d0fda8ef0236a09637bba3d0b93b6d56..7b3b64a21631d54ba096bb0a506ecbe70cf7216d 100644 (file)
@@ -27,6 +27,7 @@
 #include "util.h"
 #include "hypercall.h"
 #include "e820.h"
+#include "markers.h"
 
 static int
 write_smbios_tables(void *start,
@@ -54,6 +55,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 *
 smbios_type_17_init(void *start, uint32_t memory_size_mb, int instance);
@@ -112,6 +115,7 @@ write_smbios_tables(void *start,
     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;
@@ -304,6 +308,7 @@ smbios_type_0_init(void *start, const char *xen_version,
     p->release_date_str = 3;
     p->rom_size = 0;
 
+    memset(p->characteristics, 0, 8);
     /* BIOS Characteristics. */
     p->characteristics[0] = 0x80; /* PCI is supported */
     p->characteristics[2] = 0x08; /* EDD is supported */
@@ -317,10 +322,16 @@ smbios_type_0_init(void *start, const char *xen_version,
     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;
+    strcpy((char *)start, bios_vendor.value);
+    start += strlen(bios_vendor.value) + 1;
+    
+    if ( strlen(bios_version.value) == 0 ) {
+        strncpy(bios_version.value, xen_version, sizeof(bios_version.value));
+    }
+    
+    strcpy((char *)start, bios_version.value);
+    start += strlen(bios_version.value) + 1;
+
     strcpy((char *)start, smbios_release_date);
     start += strlen(smbios_release_date) + 1;
 
@@ -335,6 +346,7 @@ smbios_type_1_init(void *start, const char *xen_version,
 {
     char uuid_str[37];
     struct smbios_type_1 *p = (struct smbios_type_1 *)start;
+    int next = 5;
 
     memset(p, 0, sizeof(*p));
 
@@ -350,20 +362,46 @@ smbios_type_1_init(void *start, const char *xen_version,
     memcpy(p->uuid, uuid, 16);
 
     p->wake_up_type = 0x06; /* power switch */
-    p->sku_str = 0;
-    p->family_str = 0;
 
     start += sizeof(struct smbios_type_1);
+
+    strcpy((char *)start, sys_manufacturer.value);
+    start += strlen(sys_manufacturer.value) + 1;
+    strcpy((char *)start, sys_product_name.value);
+    start += strlen(sys_product_name.value) + 1;
+
+    if ( strlen(sys_product_version.value) == 0 ) {
+        strncpy(sys_product_version.value, xen_version, sizeof(sys_product_version.value));
+    }
     
-    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;
-    uuid_to_string(uuid_str, uuid); 
-    strcpy((char *)start, uuid_str);
-    start += strlen(uuid_str) + 1;
+    strcpy((char *)start, sys_product_version.value);
+    start += strlen(sys_product_version.value) + 1;
+
+    if ( strlen(sys_product_serial.value) == 0 ) {
+        uuid_to_string(uuid_str, uuid); 
+        strncpy(sys_product_serial.value, uuid_str, sizeof(sys_product_serial.value));
+    }
+    
+    strcpy((char *)start, sys_product_serial.value);
+    start += strlen(sys_product_serial.value) + 1;
+
+    /* no internal defaults for these if the value is not set */
+    if ( strlen(sys_product_sku.value) != 0 ) {
+        strcpy((char *)start, sys_product_sku.value);
+        start += strlen(sys_product_sku.value) + 1;
+        p->sku_str = next++;
+    }
+    else
+        p->sku_str = 0;
+
+    if ( strlen(sys_product_family.value) != 0 ) {
+        strcpy((char *)start, sys_product_family.value);
+        start += strlen(sys_product_family.value) + 1;
+        p->family_str = next++;
+    }
+    else
+        p->family_str = 0;
+
     *((uint8_t *)start) = 0;
     
     return start+1; 
@@ -393,8 +431,18 @@ smbios_type_3_init(void *start)
 
     start += sizeof(struct smbios_type_3);
     
-    strcpy((char *)start, "Xen");
-    start += strlen("Xen") + 1;
+    strcpy((char *)start, sys_enclosure_manufacturer.value);
+    start += strlen(sys_enclosure_manufacturer.value) + 1;
+
+    /* no internal defaults for this if the value is not set */
+    if ( strlen(sys_enclosure_serial.value) != 0 ) {
+        strcpy((char *)start, sys_enclosure_serial.value);
+        start += strlen(sys_enclosure_serial.value) + 1;
+        p->serial_number_str = 2;
+    }
+    else
+        p->serial_number_str = 0;
+
     *((uint8_t *)start) = 0;
     return start+1;
 }
@@ -449,6 +497,32 @@ smbios_type_4_init(
     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;
+    int i = 0;
+    
+    if ( oem_strings_array[0] == NULL )
+        return start; /* no OEM strings to add */
+
+    p->header.type = 11;
+    p->header.length = sizeof(struct smbios_type_11);
+    p->header.handle = 0xB00;
+    start += sizeof(struct smbios_type_11);
+
+    while ( oem_strings_array[i] != NULL ) {
+        strcpy((char *)start, oem_strings_array[i]);
+        start += strlen(oem_strings_array[i]) + 1;
+        i++;
+    }
+       p->count = i;
+    *((uint8_t *)start) = 0;
+
+    return start+1;
+}
+
 /* Type 16 -- Physical Memory Array */
 static void *
 smbios_type_16_init(void *start, uint32_t memsize, int nr_mem_devs)
index 273db4ae7a8416bfe916138960fab94ecd0ad9b4..e57464ed0a7f09695b321026a49a390b8627c378 100644 (file)
@@ -115,6 +115,12 @@ struct smbios_type_4 {
        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).
  */