]> xenbits.xen.org Git - xenclient/xen-pq.git/commitdiff
SMBIOS type 7, 22 changes.
authorKamala Narasimhan <kamala.narasimhan@citrix.com>
Wed, 29 Jul 2009 18:42:55 +0000 (14:42 -0400)
committerKamala Narasimhan <kamala.narasimhan@citrix.com>
Wed, 29 Jul 2009 18:42:55 +0000 (14:42 -0400)
master/smbios

index 678a07e84fd952b5463af06f53fd1e090a243979..092326163e47725b2c2a5455044382c7b86d59cd 100644 (file)
@@ -327,7 +327,7 @@ index 0000000..7673d22
 +
 +#endif /* __HVMLOADER_MARKERS_H__ */
 diff --git a/tools/firmware/hvmloader/smbios.c b/tools/firmware/hvmloader/smbios.c
-index 64fa799..a58dac4 100644
+index 64fa799..c6024c4 100644
 --- a/tools/firmware/hvmloader/smbios.c
 +++ b/tools/firmware/hvmloader/smbios.c
 @@ -27,6 +27,7 @@
@@ -338,16 +338,23 @@ index 64fa799..a58dac4 100644
  
  static int
  write_smbios_tables(void *start,
-@@ -54,6 +55,8 @@ static void *
+@@ -54,6 +55,10 @@ static void *
  smbios_type_4_init(void *start, unsigned int cpu_number,
                     char *cpu_manufacturer);
  static void *
++smbios_type_7_init(void *start, uint32_t memory_size_mb, int instance);
++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);
-@@ -65,6 +68,8 @@ static void *
+@@ -62,9 +67,13 @@ smbios_type_19_init(void *start, uint32_t memory_size_mb, int instance);
+ static void *
+ smbios_type_20_init(void *start, uint32_t memory_size_mb, int instance);
+ static void *
++smbios_type_22_init(void *start);
++static void *
  smbios_type_32_init(void *start);
  static void *
  smbios_type_127_init(void *start);
@@ -356,7 +363,7 @@ index 64fa799..a58dac4 100644
  
  static void
  get_cpu_manufacturer(char *buf, int len)
-@@ -93,6 +98,10 @@ write_smbios_tables(void *start,
+@@ -93,6 +102,10 @@ write_smbios_tables(void *start,
      char *p, *q;
      char cpu_manufacturer[15];
      int i, nr_mem_devs;
@@ -367,17 +374,20 @@ index 64fa799..a58dac4 100644
  
      get_cpu_manufacturer(cpu_manufacturer, 15);
  
-@@ -112,6 +121,7 @@ write_smbios_tables(void *start,
+@@ -112,6 +125,8 @@ 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_7_init(p, memsize, 1));
 +    do_struct(smbios_type_11_init(p));
  
      /* Each 'memory device' covers up to 16GB of address space. */
      nr_mem_devs = (memsize + 0x3fff) >> 14;
-@@ -127,6 +137,24 @@ write_smbios_tables(void *start,
+@@ -126,7 +141,26 @@ write_smbios_tables(void *start,
+         do_struct(smbios_type_20_init(p, dev_memsize, i));
      }
  
++    do_struct(smbios_type_22_init(p));
      do_struct(smbios_type_32_init(p));
 +
 +    oem_types_header = get_smoem_types_ptr();
@@ -400,7 +410,7 @@ index 64fa799..a58dac4 100644
      do_struct(smbios_type_127_init(p));
  
  #undef do_struct
-@@ -280,9 +308,33 @@ static void *
+@@ -280,9 +314,33 @@ static void *
  smbios_type_0_init(void *start, const char *xen_version,
                     uint32_t xen_major_version, uint32_t xen_minor_version)
  {
@@ -435,7 +445,7 @@ index 64fa799..a58dac4 100644
      memset(p, 0, sizeof(*p));
  
      p->header.type = 0;
-@@ -295,6 +347,7 @@ smbios_type_0_init(void *start, const char *xen_version,
+@@ -295,6 +353,7 @@ smbios_type_0_init(void *start, const char *xen_version,
      p->release_date_str = 3;
      p->rom_size = 0;
  
@@ -443,7 +453,7 @@ index 64fa799..a58dac4 100644
      /* BIOS Characteristics. */
      p->characteristics[0] = 0x80; /* PCI is supported */
      p->characteristics[2] = 0x08; /* EDD is supported */
-@@ -308,10 +361,16 @@ smbios_type_0_init(void *start, const char *xen_version,
+@@ -308,10 +367,16 @@ smbios_type_0_init(void *start, const char *xen_version,
      p->embedded_controller_minor = 0xff;
  
      start += sizeof(struct smbios_type_0);
@@ -464,7 +474,7 @@ index 64fa799..a58dac4 100644
      strcpy((char *)start, smbios_release_date);
      start += strlen(smbios_release_date) + 1;
  
-@@ -326,7 +385,27 @@ smbios_type_1_init(void *start, const char *xen_version,
+@@ -326,7 +391,27 @@ smbios_type_1_init(void *start, const char *xen_version,
  {
      char uuid_str[37];
      struct smbios_type_1 *p = (struct smbios_type_1 *)start;
@@ -492,7 +502,7 @@ index 64fa799..a58dac4 100644
      memset(p, 0, sizeof(*p));
  
      p->header.type = 1;
-@@ -341,20 +420,46 @@ smbios_type_1_init(void *start, const char *xen_version,
+@@ -341,20 +426,46 @@ smbios_type_1_init(void *start, const char *xen_version,
      memcpy(p->uuid, uuid, 16);
  
      p->wake_up_type = 0x06; /* power switch */
@@ -550,7 +560,7 @@ index 64fa799..a58dac4 100644
      *((uint8_t *)start) = 0;
      
      return start+1; 
-@@ -365,7 +470,26 @@ static void *
+@@ -365,7 +476,26 @@ static void *
  smbios_type_3_init(void *start)
  {
      struct smbios_type_3 *p = (struct smbios_type_3 *)start;
@@ -578,7 +588,7 @@ index 64fa799..a58dac4 100644
      memset(p, 0, sizeof(*p));
  
      p->header.type = 3;
-@@ -384,8 +508,18 @@ smbios_type_3_init(void *start)
+@@ -384,8 +514,18 @@ smbios_type_3_init(void *start)
  
      start += sizeof(struct smbios_type_3);
      
@@ -599,10 +609,43 @@ index 64fa799..a58dac4 100644
      *((uint8_t *)start) = 0;
      return start+1;
  }
-@@ -440,6 +574,52 @@ smbios_type_4_init(
+@@ -440,6 +580,85 @@ smbios_type_4_init(
      return start+1;
  }
  
++/* Type 7 -- Cache Information */
++static void *
++smbios_type_7_init(void *start, uint32_t memory_size_mb, int instance)
++{
++    struct smbios_type_7 *p = (struct smbios_type_7 *)start;
++
++    memset(p, 0, sizeof(*p));
++
++    p->header.type = 7;
++    p->header.length = sizeof(struct smbios_type_7);
++    p->header.handle = 0x700 + instance;
++
++    p->socket_designation_str = 1;
++    /* Cache level 1; Not socketed; Location Unknown; Enabled; Op mode Unknown */
++    p->cache_configuration = 0x3e0;
++    p->max_cache_size = 2 * 1024; /* @TODO: Consider switching based on memory_size_mb */
++    p->installed_size = 2 * 1024;
++    p->supported_sram_type = 0x2; /* Unknown */
++    p->current_sram_type = 0x2; /* Unknown */
++    p->cache_speed = 0; /* Unknown */
++    p->err_correction_type = 0x2; /* Unknown */
++    p->system_cache_type =  0x2; /* Unknown */
++    p->associativity = 0x2; /* Unknown */
++
++    start += sizeof(struct smbios_type_7);
++
++    strcpy((char *)start, "Internal Cache"); 
++    start += strlen("Internal Cache") + 1;
++
++    *((uint8_t *)start) = 0;
++    return start+1;
++}
++
 +/* Type 11 -- OEM Strings */
 +static void *
 +smbios_type_11_init(void *start) 
@@ -652,7 +695,62 @@ index 64fa799..a58dac4 100644
  /* Type 16 -- Physical Memory Array */
  static void *
  smbios_type_16_init(void *start, uint32_t memsize, int nr_mem_devs)
-@@ -584,6 +764,17 @@ smbios_type_127_init(void *start)
+@@ -548,6 +767,54 @@ smbios_type_20_init(void *start, uint32_t memory_size_mb, int instance)
+     return start+2;
+ }
++/* Type 22 -- Portable battery */
++/* Currently we virtualize this table as we were requested to do so */
++/* For future we might want to consider at least partial pass-through */
++/* for this table */
++static void *
++smbios_type_22_init(void *start)
++{
++    struct smbios_type_22 *p = (struct smbios_type_22 *)start;
++
++    memset(p, 0, sizeof(*p));
++
++    p->header.type = 22;
++    p->header.length = sizeof(struct smbios_type_22);
++    p->header.handle = 0x1600;
++
++    p->location_str = 1;
++    p->manufacturer_str = 2;
++    p->manufacturer_date_str = 3;
++    p->serial_number_str = 4;
++    p->device_name_str = 5;
++    p->device_chemistry = 0x2; /* Unknown */
++    p->device_capacity = 0; /* Unknown */
++    p->device_voltage = 0; /* Unknown */
++    p->sbds_version_number = 0;
++    p->max_error = 0xff; /* Unknown */
++    p->sbds_serial_number = 0;
++    p->sbds_manufacturer_date = 0;
++    p->sbds_device_chemistry = 0;
++    p->design_capacity_multiplier = 0;
++    p->oem_specific = 0;
++
++    start += sizeof(struct smbios_type_22);
++
++    strcpy((char *)start, "Primary");
++    start += strlen("Primary") + 1;
++    strcpy((char *)start, "XEN-VIRT-BATTERY");
++    start += strlen("XEN-VIRT-BATTERY") + 1;
++    strcpy((char *)start, __SMBIOS_DATE__);
++    start += strlen(__SMBIOS_DATE__) + 1;
++    strcpy((char *)start, "1234");
++    start += strlen("1234") + 1;
++    strcpy((char *)start, "XEN-VIRT-BATTERY-DEV");
++    start += strlen("XEN-VIRT-BATTERY-DEV") + 1;
++
++    *((uint8_t *)start) = 0;
++    return start+1; 
++}
++
+ /* Type 32 -- System Boot Information */
+ static void *
+ smbios_type_32_init(void *start)
+@@ -584,6 +851,17 @@ smbios_type_127_init(void *start)
      return start + 2;
  }
  
@@ -671,13 +769,28 @@ index 64fa799..a58dac4 100644
   * Local variables:
   * mode: C
 diff --git a/tools/firmware/hvmloader/smbios_types.h b/tools/firmware/hvmloader/smbios_types.h
-index 273db4a..e57464e 100644
+index 273db4a..a867657 100644
 --- a/tools/firmware/hvmloader/smbios_types.h
 +++ b/tools/firmware/hvmloader/smbios_types.h
-@@ -115,6 +115,12 @@ struct smbios_type_4 {
+@@ -115,6 +115,27 @@ struct smbios_type_4 {
        uint8_t upgrade;
  } __attribute__ ((packed));
  
++/* SMBIOS type 7 - Cache Information */
++struct smbios_type_7 {
++        struct smbios_structure_header header;
++        uint8_t socket_designation_str;
++        uint16_t cache_configuration;
++        uint16_t max_cache_size;
++        uint16_t installed_size;
++        uint16_t supported_sram_type;
++        uint16_t current_sram_type;
++        uint8_t cache_speed;
++        uint8_t err_correction_type;
++        uint8_t system_cache_type;
++        uint8_t associativity;
++} __attribute__ ((packed));
++
 +/* SMBIOS type 11 - OEM Strings */
 +struct smbios_type_11 {
 +      struct smbios_structure_header header;
@@ -687,6 +800,33 @@ index 273db4a..e57464e 100644
  /* SMBIOS type 16 - Physical Memory Array
   *   Associated with one type 17 (Memory Device).
   */
+@@ -167,6 +188,26 @@ struct smbios_type_20 {
+       uint8_t interleaved_data_depth;
+ } __attribute__ ((packed));
++/* SMBIOS type 22 - Portable battery */
++struct smbios_type_22 {
++        struct smbios_structure_header header;
++        uint8_t location_str;
++        uint8_t manufacturer_str;
++        uint8_t manufacturer_date_str;
++        uint8_t serial_number_str;
++        uint8_t device_name_str;
++        uint8_t device_chemistry;
++        uint16_t device_capacity;
++        uint16_t device_voltage;
++        uint8_t sbds_version_number;
++        uint8_t max_error;
++        uint16_t sbds_serial_number;
++        uint16_t sbds_manufacturer_date;
++        uint8_t sbds_device_chemistry;
++        uint8_t design_capacity_multiplier;
++        uint32_t oem_specific;
++} __attribute__ ((packed));
++
+ /* SMBIOS type 32 - System Boot Information */
+ struct smbios_type_32 {
+       struct smbios_structure_header header;
 diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
 index ccf9bf9..530897c 100644
 --- a/tools/firmware/hvmloader/util.c