Merge commit 'hpa/master' into for-erwan
authorPierre-Alexandre Meyer <pierre@mouraf.org>
Wed, 5 Aug 2009 03:23:16 +0000 (20:23 -0700)
committerPierre-Alexandre Meyer <pierre@mouraf.org>
Wed, 5 Aug 2009 04:01:32 +0000 (21:01 -0700)
Conflicts:
com32/cmenu/libmenu/com32io.h
com32/gplinclude/dmi/dmi.h
com32/gplinclude/dmi/dmi_base_board.h
com32/gplinclude/dmi/dmi_memory.h
com32/gplinclude/dmi/dmi_system.h
com32/gpllib/dmi/dmi.c
com32/gpllib/dmi/dmi_memory.c
com32/include/sys/pci.h
com32/lib/pci/scan.c
com32/modules/Makefile

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
1  2 
com32/cmenu/libmenu/com32io.h
com32/gplinclude/dmi/dmi.h
com32/gplinclude/dmi/dmi_base_board.h
com32/gplinclude/dmi/dmi_memory.h
com32/gplinclude/dmi/dmi_system.h
com32/gpllib/dmi/dmi.c
com32/gpllib/dmi/dmi_memory.c
com32/hdt/hdt-cli-pci.c
com32/include/sys/pci.h
com32/lib/pci/scan.c
com32/modules/Makefile

Simple merge
@@@ -62,40 -55,28 +59,40 @@@ struct dmi_header 
  };
  
  typedef struct {
 -    s_bios bios;
 -    s_system system;
 -    s_base_board base_board;
 -    s_chassis chassis;
 -    s_processor processor;
 -    s_battery battery;
 -    s_memory memory[MAX_DMI_MEMORY_ITEMS];
 -    s_ipmi ipmi;
 -    int memory_count;
 -    dmi_table dmitable;
 +       s_bios bios;
 +       s_system system;
 +       s_base_board base_board;
 +       s_chassis chassis;
 +       s_processor processor;
 +       s_battery battery;
 +       s_memory_module memory_module[MAX_DMI_MEMORY_ITEMS];
 +       s_memory memory[MAX_DMI_MEMORY_ITEMS];
 +       s_ipmi ipmi;
 +       s_cache cache[MAX_DMI_CACHE_ITEMS];
 +       int memory_module_count;
 +       int memory_count;
 +       int cache_count;
 +       dmi_table dmitable;
 +       char oem_strings[OEM_STRINGS_SIZE];
 +      struct {
 +              char power_on_passwd_status[HARDWARE_SECURITY_SIZE];
 +              char keyboard_passwd_status[HARDWARE_SECURITY_SIZE];
 +              char administrator_passwd_status[HARDWARE_SECURITY_SIZE];
 +              char front_panel_reset_status[HARDWARE_SECURITY_SIZE];
 +              bool filled;
 +      } hardware_security;
  } s_dmi;
  
- void to_dmi_header(struct dmi_header *h, uint8_t *data);
- void dmi_bios_runtime_size(uint32_t code, s_dmi *dmi);
+ void to_dmi_header(struct dmi_header *h, uint8_t * data);
+ void dmi_bios_runtime_size(uint32_t code, s_dmi * dmi);
  const char *dmi_string(struct dmi_header *dm, uint8_t s);
- int dmi_checksum(uint8_t *buf);
- void parse_dmitable(s_dmi *dmi);
- void dmi_decode(struct dmi_header *h, uint16_t ver, s_dmi *dmi);
- int dmi_iterate(s_dmi *dmi);
+ int dmi_checksum(uint8_t * buf);
+ void parse_dmitable(s_dmi * dmi);
+ void dmi_decode(struct dmi_header *h, uint16_t ver, s_dmi * dmi);
+ int dmi_iterate(s_dmi * dmi);
  
  /* dmi_utils.c */
- void display_bios_characteristics(s_dmi *dmi);
- void display_base_board_features(s_dmi *dmi);
- void display_processor_flags(s_dmi *dmi);
+ void display_bios_characteristics(s_dmi * dmi);
+ void display_base_board_features(s_dmi * dmi);
+ void display_processor_flags(s_dmi * dmi);
  #endif
@@@ -30,29 -30,24 +30,29 @@@ extern const char *base_board_features_
  /* this struct have BASE_BOARD_NB_ELEMENTS */
  /* each bool is associated to the relevant message above */
  typedef struct {
- bool hosting;
- bool board_needs_daughter;
- bool removable;
- bool replaceable;
- bool hot_swappable;
- } __attribute__((__packed__)) s_base_board_features;
 -    bool hosting;
 -    bool board_needs_daughter;
 -    bool removable;
 -    bool replaceable;
 -    bool hot_swappable;
++      bool hosting;
++      bool board_needs_daughter;
++      bool removable;
++      bool replaceable;
++      bool hot_swappable;
+ } __attribute__ ((__packed__)) s_base_board_features;
  
  typedef struct {
- char manufacturer[BASE_BOARD_MANUFACTURER_SIZE];
- char product_name[BASE_BOARD_PRODUCT_NAME_SIZE];
- char version[BASE_BOARD_VERSION_SIZE];
- char serial[BASE_BOARD_SERIAL_SIZE];
- char asset_tag[BASE_BOARD_ASSET_TAG_SIZE];
- char location[BASE_BOARD_LOCATION_SIZE];
- char type[BASE_BOARD_TYPE_SIZE];
- s_base_board_features features;
 -    char manufacturer[BASE_BOARD_MANUFACTURER_SIZE];
 -    char product_name[BASE_BOARD_PRODUCT_NAME_SIZE];
 -    char version[BASE_BOARD_VERSION_SIZE];
 -    char serial[BASE_BOARD_SERIAL_SIZE];
 -    char asset_tag[BASE_BOARD_ASSET_TAG_SIZE];
 -    char location[BASE_BOARD_LOCATION_SIZE];
 -    char type[BASE_BOARD_TYPE_SIZE];
 -    s_base_board_features features;
++      char manufacturer[BASE_BOARD_MANUFACTURER_SIZE];
++      char product_name[BASE_BOARD_PRODUCT_NAME_SIZE];
++      char version[BASE_BOARD_VERSION_SIZE];
++      char serial[BASE_BOARD_SERIAL_SIZE];
++      char asset_tag[BASE_BOARD_ASSET_TAG_SIZE];
++      char location[BASE_BOARD_LOCATION_SIZE];
++      char type[BASE_BOARD_TYPE_SIZE];
++      s_base_board_features features;
  /* The filled field have to be set to true when the dmitable implement that item */
- bool filled;
- struct {
-       char type[16];
-       uint8_t status;
-       char description[10];
- } devices_information[10];
 -    bool filled;
++      bool filled;
++      struct {
++              char type[16];
++              uint8_t status;
++              char description[10];
++      } devices_information[10];
  } s_base_board;
  
  #endif
  #define MEMORY_PART_NUMBER_SIZE               16
  
  typedef struct {
- char manufacturer[MEMORY_MANUFACTURER_SIZE];
- char error[MEMORY_ERROR_SIZE];
- char total_width[MEMORY_TOTAL_WIDTH_SIZE];
- char data_width[MEMORY_DATA_WIDTH_SIZE];
- char size[MEMORY_SIZE_SIZE];
- char form_factor[MEMORY_FORM_FACTOR_SIZE];
- char device_set[MEMORY_DEVICE_SET_SIZE];
- char device_locator[MEMORY_DEVICE_LOCATOR_SIZE];
- char bank_locator[MEMORY_BANK_LOCATOR_SIZE];
- char type[MEMORY_TYPE_SIZE];
- char type_detail[MEMORY_TYPE_DETAIL_SIZE];
- char speed[MEMORY_SPEED_SIZE];
- char serial[MEMORY_SERIAL_SIZE];
- char asset_tag[MEMORY_ASSET_TAG_SIZE];
- char part_number[MEMORY_PART_NUMBER_SIZE];
    char manufacturer[MEMORY_MANUFACTURER_SIZE];
    char error[MEMORY_ERROR_SIZE];
    char total_width[MEMORY_TOTAL_WIDTH_SIZE];
    char data_width[MEMORY_DATA_WIDTH_SIZE];
    char size[MEMORY_SIZE_SIZE];
    char form_factor[MEMORY_FORM_FACTOR_SIZE];
    char device_set[MEMORY_DEVICE_SET_SIZE];
    char device_locator[MEMORY_DEVICE_LOCATOR_SIZE];
    char bank_locator[MEMORY_BANK_LOCATOR_SIZE];
    char type[MEMORY_TYPE_SIZE];
    char type_detail[MEMORY_TYPE_DETAIL_SIZE];
    char speed[MEMORY_SPEED_SIZE];
    char serial[MEMORY_SERIAL_SIZE];
    char asset_tag[MEMORY_ASSET_TAG_SIZE];
    char part_number[MEMORY_PART_NUMBER_SIZE];
  /* The filled field have to be set to true when the dmitable implement that item */
- bool filled;
    bool filled;
  } s_memory;
  
- void dmi_memory_array_error_handle(uint16_t code,char *array);
 +typedef struct {
 +char socket_designation[8];
 +char bank_connections[8];
 +char speed[8];
 +char type[16];
 +char installed_size[8];
 +char enabled_size[8];
 +char error_status[8];
 +bool filled;
 +} s_memory_module;
 +
+ void dmi_memory_array_error_handle(uint16_t code, char *array);
  void dmi_memory_device_width(uint16_t code, char *width);
  void dmi_memory_device_size(uint16_t code, char *size);
  const char *dmi_memory_device_form_factor(uint8_t code);
  void dmi_memory_device_set(uint8_t code, char *set);
  const char *dmi_memory_device_type(uint8_t code);
- void dmi_memory_device_type_detail(uint16_t code,char *type_detail);
+ void dmi_memory_device_type_detail(uint16_t code, char *type_detail);
  void dmi_memory_device_speed(uint16_t code, char *speed);
  
 +void dmi_memory_module_connections(uint8_t, char*);
 +void dmi_memory_module_speed(uint8_t, char*);
 +void dmi_memory_module_types(uint16_t, const char*, char*);
 +void dmi_memory_module_size(uint8_t, char*);
 +void dmi_memory_module_error(uint8_t, const char*, char*);
  #endif
  #define SYSTEM_SKU_NUMBER_SIZE                32
  #define SYSTEM_FAMILY_SIZE            32
  
 +#define SYSTEM_BOOT_STATUS_SIZE               50
 +#define SYSTEM_CONFIGURATION_OPTIONS_SIZE     50
 +
  typedef struct {
- char manufacturer[SYSTEM_MANUFACTURER_SIZE];
- char product_name[SYSTEM_PRODUCT_NAME_SIZE];
- char version[SYSTEM_VERSION_SIZE];
- char serial[SYSTEM_SERIAL_SIZE];
- char uuid[SYSTEM_UUID_SIZE];
- char wakeup_type[SYSTEM_WAKEUP_TYPE_SIZE];
- char sku_number[SYSTEM_SKU_NUMBER_SIZE];
- char family[SYSTEM_FAMILY_SIZE];
    char manufacturer[SYSTEM_MANUFACTURER_SIZE];
    char product_name[SYSTEM_PRODUCT_NAME_SIZE];
    char version[SYSTEM_VERSION_SIZE];
    char serial[SYSTEM_SERIAL_SIZE];
    char uuid[SYSTEM_UUID_SIZE];
    char wakeup_type[SYSTEM_WAKEUP_TYPE_SIZE];
    char sku_number[SYSTEM_SKU_NUMBER_SIZE];
    char family[SYSTEM_FAMILY_SIZE];
  /* The filled field have to be set to true when the dmitable implement that item */
 -    bool filled;
 +bool filled;
 +char system_boot_status[SYSTEM_BOOT_STATUS_SIZE];
 +char configuration_options[SYSTEM_CONFIGURATION_OPTIONS_SIZE];
 +struct {
 +      bool filled;
 +      uint8_t status;
 +      uint8_t watchdog;
 +      char boot_option[17];
 +      char boot_option_on_limit[17];
 +      char reset_count[8];
 +      char reset_limit[8];
 +      char timer_interval[8];
 +      char timeout[8];
 +} system_reset;
  } s_system;
 -
  #endif
  const char *out_of_spec = "<OUT OF SPEC>";
  const char *bad_index = "<BAD INDEX>";
  
 -void dmi_bios_runtime_size(uint32_t code, s_dmi * dmi)
 +/*
 + * Misc. util stuff
 + */
 +
 +/*
 + * 3.3.11 On Board Devices Information (Type 10)
 + */
 +
 +static const char *dmi_on_board_devices_type(uint8_t code)
 +{
 +      /* 3.3.11.1 */
 +      static const char *type[]={
 +              "Other", /* 0x01 */
 +              "Unknown",
 +              "Video",
 +              "SCSI Controller",
 +              "Ethernet",
 +              "Token Ring",
 +              "Sound",
 +              "PATA Controller",
 +              "SATA Controller",
 +              "SAS Controller" /* 0x0A */
 +      };
 +
 +      if (code>=0x01 && code<=0x0A)
 +              return type[code-0x01];
 +      return out_of_spec;
 +}
 +
 +static void dmi_on_board_devices(struct dmi_header *h, s_dmi* dmi)
 +{
 +      uint8_t *p = h->data+4;
 +      uint8_t count = (h->length-0x04)/2;
 +      unsigned int i;
 +
 +      for (i=0; i<count && i<sizeof dmi->base_board.devices_information/sizeof *dmi->base_board.devices_information; i++) {
 +              strncpy(dmi->base_board.devices_information[i].type,
 +                      dmi_on_board_devices_type(p[2*i]&0x7F),
 +                      sizeof dmi->base_board.devices_information[i].type);
 +              dmi->base_board.devices_information[i].status = p[2*i]&0x80;
 +              strncpy(dmi->base_board.devices_information[i].description,
 +                      dmi_string(h, p[2*i+1]),
 +                      sizeof dmi->base_board.devices_information[i].description);
 +      }
 +}
 +
 +/*
 + * 3.3.24 System Reset (Type 23)
 + */
 +
 +static const char *dmi_system_reset_boot_option(uint8_t code)
 +{
 +      static const char *option[]={
 +              "Operating System", /* 0x1 */
 +              "System Utilities",
 +              "Do Not Reboot" /* 0x3 */
 +      };
 +
 +      if (code >= 0x1)
 +              return option[code-0x1];
 +      return out_of_spec;
 +}
 +
 +static void dmi_system_reset_count(uint16_t code, char* array)
 +{
 +      if (code == 0xFFFF)
 +              strncpy(array, "Unknown", sizeof array);
 +      else
 +              snprintf(array, sizeof array, "%u", code);
 +}
 +
 +static void dmi_system_reset_timer(uint16_t code, char* array)
 +{
 +      if (code == 0xFFFF)
 +              strncpy(array, "Unknown", sizeof array);
 +      else
 +              snprintf(array, sizeof array, "%u min", code);
 +}
 +
 +/*
 + * 3.3.25 Hardware Security (Type 24)
 + */
 +
 +static const char *dmi_hardware_security_status(uint8_t code)
 +{
 +      static const char *status[]={
 +              "Disabled", /* 0x00 */
 +              "Enabled",
 +              "Not Implemented",
 +              "Unknown" /* 0x03 */
 +      };
 +
 +      return status[code];
 +}
 +
 +/*
 + * 3.3.12 OEM Strings (Type 11)
 + */
 +
 +static void dmi_oem_strings(struct dmi_header *h, const char *prefix, s_dmi *dmi)
 +{
 +      uint8_t *p=h->data+4;
 +      uint8_t count=p[0x00];
 +      int i;
 +
 +      for(i=1; i<=count; i++)
 +              snprintf(dmi->oem_strings, OEM_STRINGS_SIZE, "%s %s %s\n",
 +                       dmi->oem_strings, prefix, dmi_string(h, i));
 +}
 +
 +/*
 + * 3.3.13 System Configuration Options (Type 12)
 + */
 +static void dmi_system_configuration_options(struct dmi_header *h, const char *prefix, s_dmi *dmi)
 +{
 +      uint8_t *p = h->data+4;
 +      uint8_t count = p[0x00];
 +      int i;
 +
 +      for (i=1; i<=count; i++)
 +              snprintf(dmi->system.configuration_options, SYSTEM_CONFIGURATION_OPTIONS_SIZE, "%s %s %s\n",
 +                       dmi->system.configuration_options, prefix, dmi_string(h, i));
 +}
 +
 +static void dmi_system_boot_status(uint8_t code, char* array)
 +{
 +      static const char *status[]={
 +              "No errors detected", /* 0 */
 +              "No bootable media",
 +              "Operating system failed to load",
 +              "Firmware-detected hardware failure",
 +              "Operating system-detected hardware failure",
 +              "User-requested boot",
 +              "System security violation",
 +              "Previously-requested image",
 +              "System watchdog timer expired" /* 8 */
 +      };
 +
 +      if (code<=8)
 +              strncpy(array, status[code], SYSTEM_BOOT_STATUS_SIZE);
 +      if (code>=128 && code<=191)
 +              strncpy(array, "OEM-specific", SYSTEM_BOOT_STATUS_SIZE);
 +      if (code>=192)
 +              strncpy(array, "Product-specific", SYSTEM_BOOT_STATUS_SIZE);
 +}
 +
 +void dmi_bios_runtime_size(uint32_t code, s_dmi *dmi)
  {
-         if(code&0x000003FF) {
-                 dmi->bios.runtime_size=code;
-                 strcpy(dmi->bios.runtime_size_unit,"bytes");
-         } else {
-                 dmi->bios.runtime_size=code >>10;
-                 strcpy(dmi->bios.runtime_size_unit,"KB");
-         }
+     if (code & 0x000003FF) {
+       dmi->bios.runtime_size = code;
+       strcpy(dmi->bios.runtime_size_unit, "bytes");
+     } else {
+       dmi->bios.runtime_size = code >> 10;
+       strcpy(dmi->bios.runtime_size_unit, "KB");
+     }
  }
  
- void dmi_bios_characteristics(uint64_t code, s_dmi *dmi)
+ void dmi_bios_characteristics(uint64_t code, s_dmi * dmi)
  {
-         int i;
-         /*
-          * This isn't very clear what this bit is supposed to mean
-          */
-         //if(code.l&(1<<3))
-         if(code&&(1<<3))
-         {
-                 ((bool *)(& dmi->bios.characteristics))[0]=true;
-                 return;
-         }
-         for(i=4; i<=31; i++)
-                 //if(code.l&(1<<i))
-                 if(code&(1<<i))
-                         ((bool *)(& dmi->bios.characteristics))[i-3]=true;
+     int i;
+     /*
+      * This isn't very clear what this bit is supposed to mean
+      */
+     //if(code.l&(1<<3))
+     if (code && (1 << 3)) {
+       ((bool *) (&dmi->bios.characteristics))[0] = true;
+       return;
+     }
+     for (i = 4; i <= 31; i++)
+       //if(code.l&(1<<i))
+       if (code & (1 << i))
+           ((bool *) (&dmi->bios.characteristics))[i - 3] = true;
  }
  
- void dmi_bios_characteristics_x1(uint8_t code, s_dmi *dmi)
+ void dmi_bios_characteristics_x1(uint8_t code, s_dmi * dmi)
  {
-         int i;
+     int i;
  
-         for(i=0; i<=7; i++)
-                 if(code&(1<<i))
-                         ((bool *)(& dmi->bios.characteristics_x1))[i]=true;
+     for (i = 0; i <= 7; i++)
+       if (code & (1 << i))
+           ((bool *) (&dmi->bios.characteristics_x1))[i] = true;
  }
  
- void dmi_bios_characteristics_x2(uint8_t code, s_dmi *dmi)
+ void dmi_bios_characteristics_x2(uint8_t code, s_dmi * dmi)
  {
-         int i;
+     int i;
  
-         for(i=0; i<=2; i++)
-                 if(code&(1<<i))
-                         ((bool *)(& dmi->bios.characteristics_x2))[i]=true;
+     for (i = 0; i <= 2; i++)
+       if (code & (1 << i))
+           ((bool *) (&dmi->bios.characteristics_x2))[i] = true;
  }
  
- void dmi_system_uuid(uint8_t *p, s_dmi *dmi)
+ void dmi_system_uuid(uint8_t * p, s_dmi * dmi)
  {
-         int only0xFF=1, only0x00=1;
-         int i;
-         for(i=0; i<16 && (only0x00 || only0xFF); i++)
-         {
-                 if(p[i]!=0x00) only0x00=0;
-                 if(p[i]!=0xFF) only0xFF=0;
-         }
-         if(only0xFF)
-         {
-                 sprintf(dmi->system.uuid,"Not Present");
-                 return;
-         }
-         if(only0x00)
-         {
-                 sprintf(dmi->system.uuid,"Not Settable");
-                 return;
-         }
-         sprintf(dmi->system.uuid,"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
-                 p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
-                 p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
+     int only0xFF = 1, only0x00 = 1;
+     int i;
+     for (i = 0; i < 16 && (only0x00 || only0xFF); i++) {
+       if (p[i] != 0x00)
+           only0x00 = 0;
+       if (p[i] != 0xFF)
+           only0xFF = 0;
+     }
+     if (only0xFF) {
+       sprintf(dmi->system.uuid, "Not Present");
+       return;
+     }
+     if (only0x00) {
+       sprintf(dmi->system.uuid, "Not Settable");
+       return;
+     }
+     sprintf(dmi->system.uuid,
+           "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
+           p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10],
+           p[11], p[12], p[13], p[14], p[15]);
  }
  
- void dmi_system_wake_up_type(uint8_t code, s_dmi *dmi)
+ void dmi_system_wake_up_type(uint8_t code, s_dmi * dmi)
  {
-         /* 3.3.2.1 */
-         static const char *type[]={
-                 "Reserved", /* 0x00 */
-                 "Other",
-                 "Unknown",
-                 "APM Timer",
-                 "Modem Ring",
-                 "LAN Remote",
-                 "Power Switch",
-                 "PCI PME#",
-                 "AC Power Restored" /* 0x08 */
-         };
-         if(code<=0x08) {
-                 strcpy(dmi->system.wakeup_type,type[code]);
-         } else {
-                 strcpy(dmi->system.wakeup_type,out_of_spec);
-         }
- return;
+     /* 3.3.2.1 */
+     static const char *type[] = {
+       "Reserved",             /* 0x00 */
+       "Other",
+       "Unknown",
+       "APM Timer",
+       "Modem Ring",
+       "LAN Remote",
+       "Power Switch",
+       "PCI PME#",
+       "AC Power Restored"     /* 0x08 */
+     };
+     if (code <= 0x08) {
+       strcpy(dmi->system.wakeup_type, type[code]);
+     } else {
+       strcpy(dmi->system.wakeup_type, out_of_spec);
+     }
    return;
  }
  
- static void dmi_base_board_features(uint8_t code, s_dmi *dmi)
+ static void dmi_base_board_features(uint8_t code, s_dmi * dmi)
  {
-         if((code&0x1F)!=0)
-         {
-                 int i;
+     if ((code & 0x1F) != 0) {
+       int i;
  
-                 for(i=0; i<=4; i++)
-                         if(code&(1<<i))
-                         ((bool *)(& dmi->base_board.features))[i]=true;
-         }
+       for (i = 0; i <= 4; i++)
+           if (code & (1 << i))
+               ((bool *) (&dmi->base_board.features))[i] = true;
+     }
  }
  
- static void dmi_processor_voltage(uint8_t code, s_dmi *dmi)
+ static void dmi_processor_voltage(uint8_t code, s_dmi * dmi)
  {
-         /* 3.3.5.4 */
-         static const float voltage[]={
-                 5.0,
-                 3.3,
-                 2.9
-         };
-         int i;
-         if(code&0x80)
-                 dmi->processor.voltage=((float)(code&0x7f)/10);
-         else
-         {
-                 for(i=0; i<=2; i++)
-                         if(code&(1<<i))
-                                 dmi->processor.voltage=voltage[i];
-         }
+     /* 3.3.5.4 */
+     static const float voltage[] = {
+       5.0,
+       3.3,
+       2.9
+     };
+     int i;
+     if (code & 0x80)
+       dmi->processor.voltage = ((float)(code & 0x7f) / 10);
+     else {
+       for (i = 0; i <= 2; i++)
+           if (code & (1 << i))
+               dmi->processor.voltage = voltage[i];
+     }
  }
  
- static void dmi_processor_id(uint8_t type, uint8_t *p, const char *version, s_dmi *dmi)
+ static void dmi_processor_id(uint8_t type, uint8_t * p, const char *version,
+                            s_dmi * dmi)
  {
-         /*
-          * Extra flags are now returned in the ECX register when one calls
-          * the CPUID instruction. Their meaning is explained in table 6, but
-          * DMI doesn't support this yet.
-          */
-         uint32_t eax, edx;
-         int sig=0;
-         /*
-          * This might help learn about new processors supporting the
-          * CPUID instruction or another form of identification.
-          */
-         sprintf(dmi->processor.id,"ID: %02X %02X %02X %02X %02X %02X %02X %02X\n",
-                 p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
-         if(type==0x05) /* 80386 */
-         {
-                 uint16_t dx=WORD(p);
-                 /*
-                  * 80386 have a different signature.
-                  */
-                 dmi->processor.signature.type=(dx >>12);
-                 dmi->processor.signature.family=((dx>>8)&0xF);
-                 dmi->processor.signature.stepping=(dx>>4)&0xF;
-                 dmi->processor.signature.minor_stepping=(dx&0xF);
-                 return;
-         }
-         if(type==0x06) /* 80486 */
-         {
-                 uint16_t dx=WORD(p);
-                 /*
-                  * Not all 80486 CPU support the CPUID instruction, we have to find
-                  * wether the one we have here does or not. Note that this trick
-                  * works only because we know that 80486 must be little-endian.
-                  */
-                 if((dx&0x0F00)==0x0400
-                 && ((dx&0x00F0)==0x0040 || (dx&0x00F0)>=0x0070)
-                 && ((dx&0x000F)>=0x0003))
-                         sig=1;
-                 else
-                 {
-                         dmi->processor.signature.type=((dx >>12)&0x3);
-                         dmi->processor.signature.family=((dx>>8)&0xF);
-                         dmi->processor.signature.model=((dx>>4)&0xF);
-                         dmi->processor.signature.stepping=(dx&0xF);
-                         return;
-                 }
-         }
-         else if((type>=0x0B && type<=0x13) /* Intel, Cyrix */
-         || (type>=0xB0 && type<=0xB3) /* Intel */
-         || type==0xB5 /* Intel */
-         || type==0xB9) /* Intel */
-                 sig=1;
-         else if((type>=0x18 && type<=0x1D) /* AMD */
-         || type==0x1F /* AMD */
-         || (type>=0xB6 && type<=0xB7) /* AMD */
-         || (type>=0x83 && type<=0x85)) /* AMD */
-                 sig=2;
-         else if(type==0x01 || type==0x02)
-         {
-                 /*
-                  * Some X86-class CPU have family "Other" or "Unknown". In this case,
-                  * we use the version string to determine if they are known to
-                  * support the CPUID instruction.
-                  */
-                 if(strncmp(version, "Pentium III MMX", 15)==0)
-                         sig=1;
-                 else if(strncmp(version, "AMD Athlon(TM)", 14)==0
-                 || strncmp(version, "AMD Opteron(tm)", 15)==0)
-                         sig=2;
-                 else
-                         return;
-         }
-         else /* not X86-class */
-                 return;
-         eax=DWORD(p);
-         edx=DWORD(p+4);
-         switch(sig)
-         {
-                 case 1: /* Intel */
-                         dmi->processor.signature.type=((eax >>12)&0x3);
-                         dmi->processor.signature.family=(((eax>>16)&0xFF0)+((eax>>8)&0x00F));
-                         dmi->processor.signature.model=(((eax>>12)&0xF0)+((eax>>4)&0x0F));
-                         dmi->processor.signature.stepping=(eax&0xF);
-                         break;
-                 case 2: /* AMD */
-                         dmi->processor.signature.family=(((eax>>8)&0xF)==0xF?(eax>>20)&0xFF:(eax>>8)&0xF);
-                         dmi->processor.signature.model =(((eax>>4)&0xF)==0xF?(eax>>16)&0xF :(eax>>4)&0xF);
-                         dmi->processor.signature.stepping=(eax&0xF);
-                         break;
-         }
-         edx=DWORD(p+4);
-         if((edx&0x3FF7FDFF)!=0)
-         {
-                 int i;
-                 for(i=0; i<=31; i++)
-                         if(cpu_flags_strings[i]!=NULL && edx&(1<<i))
-                                 ((bool *)(& dmi->processor.cpu_flags))[i]=true;
-                                 //printf("%s\t%s\n", prefix, flags[i]);
-         }
+     /*
+      * Extra flags are now returned in the ECX register when one calls
+      * the CPUID instruction. Their meaning is explained in table 6, but
+      * DMI doesn't support this yet.
+      */
+     uint32_t eax, edx;
+     int sig = 0;
+     /*
+      * This might help learn about new processors supporting the
+      * CPUID instruction or another form of identification.
+      */
+     sprintf(dmi->processor.id, "ID: %02X %02X %02X %02X %02X %02X %02X %02X\n",
+           p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
+     if (type == 0x05) {               /* 80386 */
+       uint16_t dx = WORD(p);
+       /*
+        * 80386 have a different signature.
+        */
+       dmi->processor.signature.type = (dx >> 12);
+       dmi->processor.signature.family = ((dx >> 8) & 0xF);
+       dmi->processor.signature.stepping = (dx >> 4) & 0xF;
+       dmi->processor.signature.minor_stepping = (dx & 0xF);
+       return;
+     }
+     if (type == 0x06) {               /* 80486 */
+       uint16_t dx = WORD(p);
+       /*
+        * Not all 80486 CPU support the CPUID instruction, we have to find
+        * wether the one we have here does or not. Note that this trick
+        * works only because we know that 80486 must be little-endian.
+        */
+       if ((dx & 0x0F00) == 0x0400
+           && ((dx & 0x00F0) == 0x0040 || (dx & 0x00F0) >= 0x0070)
+           && ((dx & 0x000F) >= 0x0003))
+           sig = 1;
+       else {
+           dmi->processor.signature.type = ((dx >> 12) & 0x3);
+           dmi->processor.signature.family = ((dx >> 8) & 0xF);
+           dmi->processor.signature.model = ((dx >> 4) & 0xF);
+           dmi->processor.signature.stepping = (dx & 0xF);
+           return;
+       }
+     } else if ((type >= 0x0B && type <= 0x13) /* Intel, Cyrix */
+              ||(type >= 0xB0 && type <= 0xB3) /* Intel */
+              ||type == 0xB5   /* Intel */
+              || type == 0xB9) /* Intel */
+       sig = 1;
+     else if ((type >= 0x18 && type <= 0x1D)   /* AMD */
+            ||type == 0x1F     /* AMD */
+            || (type >= 0xB6 && type <= 0xB7)  /* AMD */
+            ||(type >= 0x83 && type <= 0x85))  /* AMD */
+       sig = 2;
+     else if (type == 0x01 || type == 0x02) {
+       /*
+        * Some X86-class CPU have family "Other" or "Unknown". In this case,
+        * we use the version string to determine if they are known to
+        * support the CPUID instruction.
+        */
+       if (strncmp(version, "Pentium III MMX", 15) == 0)
+           sig = 1;
+       else if (strncmp(version, "AMD Athlon(TM)", 14) == 0
+                || strncmp(version, "AMD Opteron(tm)", 15) == 0)
+           sig = 2;
+       else
+           return;
+     } else                    /* not X86-class */
+       return;
+     eax = DWORD(p);
+     edx = DWORD(p + 4);
+     switch (sig) {
+     case 1:                   /* Intel */
+       dmi->processor.signature.type = ((eax >> 12) & 0x3);
+       dmi->processor.signature.family =
+           (((eax >> 16) & 0xFF0) + ((eax >> 8) & 0x00F));
+       dmi->processor.signature.model =
+           (((eax >> 12) & 0xF0) + ((eax >> 4) & 0x0F));
+       dmi->processor.signature.stepping = (eax & 0xF);
+       break;
+     case 2:                   /* AMD */
+       dmi->processor.signature.family =
+           (((eax >> 8) & 0xF) == 0xF ? (eax >> 20) & 0xFF : (eax >> 8) & 0xF);
+       dmi->processor.signature.model =
+           (((eax >> 4) & 0xF) == 0xF ? (eax >> 16) & 0xF : (eax >> 4) & 0xF);
+       dmi->processor.signature.stepping = (eax & 0xF);
+       break;
+     }
+     edx = DWORD(p + 4);
+     if ((edx & 0x3FF7FDFF) != 0) {
+       int i;
+       for (i = 0; i <= 31; i++)
+           if (cpu_flags_strings[i] != NULL && edx & (1 << i))
+               ((bool *) (&dmi->processor.cpu_flags))[i] = true;
+       //printf("%s\t%s\n", prefix, flags[i]);
+     }
  }
  
- void to_dmi_header(struct dmi_header *h, uint8_t *data)
+ void to_dmi_header(struct dmi_header *h, uint8_t * data)
  {
-         h->type=data[0];
-         h->length=data[1];
-         h->handle=WORD(data+2);
-         h->data=data;
+     h->type = data[0];
+     h->length = data[1];
+     h->handle = WORD(data + 2);
+     h->data = data;
  }
  
  const char *dmi_string(struct dmi_header *dm, uint8_t s)
@@@ -513,348 -359,279 +505,356 @@@ int dmi_iterate(s_dmi * dmi
  /*              printf("DMI present (version %d.%d)\n", dmitable.major_version,dmitable.minor_version);
                printf("%d structures occupying %d bytes.\n",dmitable.num, dmitable.len);
                printf("DMI table at 0x%08X.\n",dmitable.base);*/
-             return DMI_TABLE_PRESENT;
-          }
-   }
-   dmi->dmitable.base=0;
-   dmi->dmitable.num=0;
-   dmi->dmitable.ver=0;
-   dmi->dmitable.len=0;
-   return -ENODMITABLE;
+           return DMI_TABLE_PRESENT;
+       }
+     }
+     dmi->dmitable.base = 0;
+     dmi->dmitable.num = 0;
+     dmi->dmitable.ver = 0;
+     dmi->dmitable.len = 0;
+     return -ENODMITABLE;
  }
  
- void dmi_decode(struct dmi_header *h, uint16_t ver, s_dmi *dmi)
+ void dmi_decode(struct dmi_header *h, uint16_t ver, s_dmi * dmi)
  {
-         uint8_t *data=h->data;
-         /*
-          * Note: DMI types 37, 38 and 39 are untested
-          */
-         switch(h->type)
-         {
-                 case 0: /* 3.3.1 BIOS Information */
- //                        printf("BIOS Information\n");
-                         if(h->length<0x12) break;
-                       dmi->bios.filled=true;
-                       strcpy(dmi->bios.vendor,dmi_string(h,data[0x04]));
-                       strcpy(dmi->bios.version,dmi_string(h,data[0x05]));
-                       strcpy(dmi->bios.release_date,dmi_string(h,data[0x08]));
-                       dmi->bios.address=WORD(data+0x06);
-                         dmi_bios_runtime_size((0x10000-WORD(data+0x06))<<4,dmi);
-                       dmi->bios.rom_size=(data[0x09]+1)<<6;
-                       strcpy(dmi->bios.rom_size_unit,"kB");
-                         dmi_bios_characteristics(QWORD(data+0x0A),dmi);
+     uint8_t *data = h->data;
  
-                       if(h->length<0x13) break;
-                         dmi_bios_characteristics_x1(data[0x12], dmi);
-                         if(h->length<0x14) break;
-                         dmi_bios_characteristics_x2(data[0x13], dmi);
-                         if(h->length<0x18) break;
-                         if(data[0x14]!=0xFF && data[0x15]!=0xFF)
-                                 sprintf(dmi->bios.bios_revision,"%u.%u",
-                                         data[0x14], data[0x15]);
-                         if(data[0x16]!=0xFF && data[0x17]!=0xFF)
-                                 sprintf(dmi->bios.firmware_revision,"%u.%u",
-                                         data[0x16], data[0x17]);
-                         break;
-                 case 1: /* 3.3.2 System Information */
+     /*
+      * Note: DMI types 37, 38 and 39 are untested
+      */
+     switch (h->type) {
+     case 0:                   /* 3.3.1 BIOS Information */
+ //                        printf("BIOS Information\n");
+       if (h->length < 0x12)
+           break;
+       dmi->bios.filled = true;
+       strcpy(dmi->bios.vendor, dmi_string(h, data[0x04]));
+       strcpy(dmi->bios.version, dmi_string(h, data[0x05]));
+       strcpy(dmi->bios.release_date, dmi_string(h, data[0x08]));
+       dmi->bios.address = WORD(data + 0x06);
+       dmi_bios_runtime_size((0x10000 - WORD(data + 0x06)) << 4, dmi);
+       dmi->bios.rom_size = (data[0x09] + 1) << 6;
+       strcpy(dmi->bios.rom_size_unit, "kB");
+       dmi_bios_characteristics(QWORD(data + 0x0A), dmi);
+       if (h->length < 0x13)
+           break;
+       dmi_bios_characteristics_x1(data[0x12], dmi);
+       if (h->length < 0x14)
+           break;
+       dmi_bios_characteristics_x2(data[0x13], dmi);
+       if (h->length < 0x18)
+           break;
+       if (data[0x14] != 0xFF && data[0x15] != 0xFF)
+           sprintf(dmi->bios.bios_revision, "%u.%u", data[0x14], data[0x15]);
+       if (data[0x16] != 0xFF && data[0x17] != 0xFF)
+           sprintf(dmi->bios.firmware_revision, "%u.%u",
+                   data[0x16], data[0x17]);
+       break;
+     case 1:                   /* 3.3.2 System Information */
  //                        printf("System Information\n");
-                         if(h->length<0x08) break;
-                       dmi->system.filled=true;
-                       strcpy(dmi->system.manufacturer,dmi_string(h,data[0x04]));
-                       strcpy(dmi->system.product_name,dmi_string(h,data[0x05]));
-                       strcpy(dmi->system.version,dmi_string(h,data[0x06]));
-                       strcpy(dmi->system.serial,dmi_string(h,data[0x07]));
-                         if(h->length<0x19) break;
-                         dmi_system_uuid(data+0x08,dmi);
-                         dmi_system_wake_up_type(data[0x18],dmi);
-                         if(h->length<0x1B) break;
-                       strcpy(dmi->system.sku_number,dmi_string(h,data[0x19]));
-                       strcpy(dmi->system.family,dmi_string(h,data[0x1A]));
-                         break;
-                 case 2: /* 3.3.3 Base Board Information */
+       if (h->length < 0x08)
+           break;
+       dmi->system.filled = true;
+       strcpy(dmi->system.manufacturer, dmi_string(h, data[0x04]));
+       strcpy(dmi->system.product_name, dmi_string(h, data[0x05]));
+       strcpy(dmi->system.version, dmi_string(h, data[0x06]));
+       strcpy(dmi->system.serial, dmi_string(h, data[0x07]));
+       if (h->length < 0x19)
+           break;
+       dmi_system_uuid(data + 0x08, dmi);
+       dmi_system_wake_up_type(data[0x18], dmi);
+       if (h->length < 0x1B)
+           break;
+       strcpy(dmi->system.sku_number, dmi_string(h, data[0x19]));
+       strcpy(dmi->system.family, dmi_string(h, data[0x1A]));
+       break;
+     case 2:                   /* 3.3.3 Base Board Information */
  //                        printf("Base Board Information\n");
-                         if(h->length<0x08) break;
-                       dmi->base_board.filled=true;
-                       strcpy(dmi->base_board.manufacturer,dmi_string(h,data[0x04]));
-                       strcpy(dmi->base_board.product_name,dmi_string(h,data[0x05]));
-                       strcpy(dmi->base_board.version,dmi_string(h,data[0x06]));
-                       strcpy(dmi->base_board.serial,dmi_string(h,data[0x07]));
-                         if(h->length<0x0F) break;
-                       strcpy(dmi->base_board.asset_tag,dmi_string(h,data[0x08]));
-                         dmi_base_board_features(data[0x09], dmi);
-                       strcpy(dmi->base_board.location,dmi_string(h,data[0x0A]));
-                       strcpy(dmi->base_board.type,dmi_string(h,data[0x0D]));
-                         if(h->length<0x0F+data[0x0E]*sizeof(uint16_t)) break;
-                         break;
-                 case 3: /* 3.3.4 Chassis Information */
+       if (h->length < 0x08)
+           break;
+       dmi->base_board.filled = true;
+       strcpy(dmi->base_board.manufacturer, dmi_string(h, data[0x04]));
+       strcpy(dmi->base_board.product_name, dmi_string(h, data[0x05]));
+       strcpy(dmi->base_board.version, dmi_string(h, data[0x06]));
+       strcpy(dmi->base_board.serial, dmi_string(h, data[0x07]));
+       if (h->length < 0x0F)
+           break;
+       strcpy(dmi->base_board.asset_tag, dmi_string(h, data[0x08]));
+       dmi_base_board_features(data[0x09], dmi);
+       strcpy(dmi->base_board.location, dmi_string(h, data[0x0A]));
+       strcpy(dmi->base_board.type, dmi_string(h, data[0x0D]));
+       if (h->length < 0x0F + data[0x0E] * sizeof(uint16_t))
+           break;
+       break;
+     case 3:                   /* 3.3.4 Chassis Information */
  //                        printf("Chassis Information\n");
 -      if (h->length < 0x09)
 -          break;
 -      dmi->chassis.filled = true;
 -      strcpy(dmi->chassis.manufacturer, dmi_string(h, data[0x04]));
 -      strcpy(dmi->chassis.type, dmi_chassis_type(data[0x05] & 0x7F));
 -      strcpy(dmi->chassis.lock, dmi_chassis_lock(data[0x05] >> 7));
 -      strcpy(dmi->chassis.version, dmi_string(h, data[0x06]));
 -      strcpy(dmi->chassis.serial, dmi_string(h, data[0x07]));
 -      strcpy(dmi->chassis.asset_tag, dmi_string(h, data[0x08]));
 -      if (h->length < 0x0D)
 -          break;
 -      strcpy(dmi->chassis.boot_up_state, dmi_chassis_state(data[0x09]));
 -      strcpy(dmi->chassis.power_supply_state, dmi_chassis_state(data[0x0A]));
 -      strcpy(dmi->chassis.thermal_state, dmi_chassis_state(data[0x0B]));
 -      strcpy(dmi->chassis.security_status,
 -             dmi_chassis_security_status(data[0x0C]));
 -      if (h->length < 0x11)
 -          break;
 -      sprintf(dmi->chassis.oem_information, "0x%08X\n", DWORD(data + 0x0D));
 -      if (h->length < 0x15)
 -          break;
 -      dmi->chassis.height = data[0x11];
 -      dmi->chassis.nb_power_cords = data[0x12];
 -      break;
 -
 -    case 4:                   /* 3.3.5 Processor Information */
 +                        if(h->length<0x09) break;
 +                      dmi->chassis.filled=true;
 +                      strcpy(dmi->chassis.manufacturer,dmi_string(h,data[0x04]));
 +                        strcpy(dmi->chassis.type,dmi_chassis_type(data[0x05]&0x7F));
 +                        strcpy(dmi->chassis.lock,dmi_chassis_lock(data[0x05]>>7));
 +                      strcpy(dmi->chassis.version,dmi_string(h,data[0x06]));
 +                      strcpy(dmi->chassis.serial,dmi_string(h,data[0x07]));
 +                      strcpy(dmi->chassis.asset_tag,dmi_string(h,data[0x08]));
 +                        if(h->length<0x0D) break;
 +                        strcpy(dmi->chassis.boot_up_state,dmi_chassis_state(data[0x09]));
 +                        strcpy(dmi->chassis.power_supply_state,dmi_chassis_state(data[0x0A]));
 +                        strcpy(dmi->chassis.thermal_state,dmi_chassis_state(data[0x0B]));
 +                        strcpy(dmi->chassis.security_status,dmi_chassis_security_status(data[0x0C]));
 +                        if(h->length<0x11) break;
 +                        sprintf(dmi->chassis.oem_information,"0x%08X",DWORD(data+0x0D));
 +                        if(h->length<0x15) break;
 +                        dmi->chassis.height=data[0x11];
 +                        dmi->chassis.nb_power_cords=data[0x12];
 +                        break;
 +
 +                      case 4: /* 3.3.5 Processor Information */
  //                        printf("Processor Information\n");
 -      if (h->length < 0x1A)
 -          break;
 -      dmi->processor.filled = true;
 -      strcpy(dmi->processor.socket_designation, dmi_string(h, data[0x04]));
 -      strcpy(dmi->processor.type, dmi_processor_type(data[0x05]));
 -      strcpy(dmi->processor.manufacturer, dmi_string(h, data[0x07]));
 -      strcpy(dmi->processor.family,
 -             dmi_processor_family(data[0x06], dmi->processor.manufacturer));
 -      dmi_processor_id(data[0x06], data + 8, dmi_string(h, data[0x10]), dmi);
 -      strcpy(dmi->processor.version, dmi_string(h, data[0x10]));
 -      dmi_processor_voltage(data[0x11], dmi);
 -      dmi->processor.external_clock = WORD(data + 0x12);
 -      dmi->processor.max_speed = WORD(data + 0x14);
 -      dmi->processor.current_speed = WORD(data + 0x16);
 -      if (data[0x18] & (1 << 6))
 -          strcpy(dmi->processor.status,
 -                 dmi_processor_status(data[0x18] & 0x07));
 -      else
 -          sprintf(dmi->processor.status, "Unpopulated");
 -      sprintf(dmi->processor.upgrade, dmi_processor_upgrade(data[0x19]));
 -      if (h->length < 0x20)
 -          break;
 -      dmi_processor_cache(WORD(data + 0x1A), "L1", ver,
 -                          dmi->processor.cache1);
 -      dmi_processor_cache(WORD(data + 0x1C), "L2", ver,
 -                          dmi->processor.cache2);
 -      dmi_processor_cache(WORD(data + 0x1E), "L3", ver,
 -                          dmi->processor.cache3);
 -      if (h->length < 0x23)
 -          break;
 -      strcpy(dmi->processor.serial, dmi_string(h, data[0x20]));
 -      strcpy(dmi->processor.asset_tag, dmi_string(h, data[0x21]));
 -      strcpy(dmi->processor.part_number, dmi_string(h, data[0x22]));
 -      break;
 -    case 17:                  /* 3.3.18 Memory Device */
 -      if (h->length < 0x15)
 -          break;
 -      dmi->memory_count++;
 -      s_memory *mem = &dmi->memory[dmi->memory_count - 1];
 -      dmi->memory[dmi->memory_count - 1].filled = true;
 -      dmi_memory_array_error_handle(WORD(data + 0x06), mem->error);
 -      dmi_memory_device_width(WORD(data + 0x08), mem->total_width);
 -      dmi_memory_device_width(WORD(data + 0x0A), mem->data_width);
 -      dmi_memory_device_size(WORD(data + 0x0C), mem->size);
 -      strcpy(mem->form_factor, dmi_memory_device_form_factor(data[0x0E]));
 -      dmi_memory_device_set(data[0x0F], mem->device_set);
 -      strcpy(mem->device_locator, dmi_string(h, data[0x10]));
 -      strcpy(mem->bank_locator, dmi_string(h, data[0x11]));
 -      strcpy(mem->type, dmi_memory_device_type(data[0x12]));
 -      dmi_memory_device_type_detail(WORD(data + 0x13), mem->type_detail);
 -      if (h->length < 0x17)
 -          break;
 -      dmi_memory_device_speed(WORD(data + 0x15), mem->speed);
 -      if (h->length < 0x1B)
 -          break;
 -      strcpy(mem->manufacturer, dmi_string(h, data[0x17]));
 -      strcpy(mem->serial, dmi_string(h, data[0x18]));
 -      strcpy(mem->asset_tag, dmi_string(h, data[0x19]));
 -      strcpy(mem->part_number, dmi_string(h, data[0x1A]));
 -      break;
 -    case 22:                  /* 3.3.23 Portable Battery */
 -      if (h->length < 0x10)
 -          break;
 -      dmi->battery.filled = true;
 -      strcpy(dmi->battery.location, dmi_string(h, data[0x04]));
 -      strcpy(dmi->battery.manufacturer, dmi_string(h, data[0x05]));
 -
 -      if (data[0x06] || h->length < 0x1A)
 -          strcpy(dmi->battery.manufacture_date, dmi_string(h, data[0x06]));
 -
 -      if (data[0x07] || h->length < 0x1A)
 -          strcpy(dmi->battery.serial, dmi_string(h, data[0x07]));
 -
 -      strcpy(dmi->battery.name, dmi_string(h, data[0x08]));
 -
 -      if (data[0x09] != 0x02 || h->length < 0x1A)
 -          strcpy(dmi->battery.chemistry, dmi_battery_chemistry(data[0x09]));
 -
 -      if (h->length < 0x1A)
 -          dmi_battery_capacity(WORD(data + 0x0A), 1,
 -                               dmi->battery.design_capacity);
 -      else
 -          dmi_battery_capacity(WORD(data + 0x0A), data[0x15],
 -                               dmi->battery.design_capacity);
 -      dmi_battery_voltage(WORD(data + 0x0C), dmi->battery.design_voltage);
 -      strcpy(dmi->battery.sbds, dmi_string(h, data[0x0E]));
 -      dmi_battery_maximum_error(data[0x0F], dmi->battery.maximum_error);
 -      if (h->length < 0x1A)
 -          break;
 -      if (data[0x07] == 0)
 -          sprintf(dmi->battery.sbds_serial, "%04X", WORD(data + 0x10));
 -
 -      if (data[0x06] == 0)
 -          sprintf(dmi->battery.sbds_manufacture_date, "%u-%02u-%02u",
 -                  1980 + (WORD(data + 0x12) >> 9),
 -                  (WORD(data + 0x12) >> 5) & 0x0F, WORD(data + 0x12) & 0x1F);
 -      if (data[0x09] == 0x02)
 -          strcpy(dmi->battery.sbds_chemistry, dmi_string(h, data[0x14]));
 -
 -      //      sprintf(dmi->battery.oem_info,"0x%08X",DWORD(h, data+0x16));
 -      break;
 -    case 38:                  /* 3.3.39 IPMI Device Information */
 -      if (h->length < 0x10)
 -          break;
 -      dmi->ipmi.filled = true;
 -      snprintf(dmi->ipmi.interface_type, sizeof(dmi->ipmi.interface_type),
 -               "%s", dmi_ipmi_interface_type(data[0x04]));
 -      dmi->ipmi.major_specification_version = data[0x05] >> 4;
 -      dmi->ipmi.minor_specification_version = data[0x05] & 0x0F;
 -      dmi->ipmi.I2C_slave_address = data[0x06] >> 1;
 -      if (data[0x07] != 0xFF)
 -          dmi->ipmi.nv_address = data[0x07];
 -      else
 -          dmi->ipmi.nv_address = 0;   /* Not Present */
 -      dmi_ipmi_base_address(data[0x04], data + 0x08, &dmi->ipmi);
 -      if (h->length < 0x12)
 -          break;
 -      if (data[0x11] != 0x00) {
 -          dmi->ipmi.irq = data[0x11];
 -      }
 -      break;
 -    }
 +                        if(h->length<0x1A) break;
 +                      dmi->processor.filled=true;
 +                      strcpy(dmi->processor.socket_designation,dmi_string(h, data[0x04]));
 +                        strcpy(dmi->processor.type,dmi_processor_type(data[0x05]));
 +                      strcpy(dmi->processor.manufacturer,dmi_string(h, data[0x07]));
 +                        strcpy(dmi->processor.family,dmi_processor_family(data[0x06],dmi->processor.manufacturer));
 +                        dmi_processor_id(data[0x06], data+8, dmi_string(h, data[0x10]), dmi);
 +                        strcpy(dmi->processor.version,dmi_string(h, data[0x10]));
 +                        dmi_processor_voltage(data[0x11],dmi);
 +                        dmi->processor.external_clock=WORD(data+0x12);
 +                        dmi->processor.max_speed=WORD(data+0x14);
 +                        dmi->processor.current_speed=WORD(data+0x16);
 +                        if(data[0x18]&(1<<6))
 +                                strcpy(dmi->processor.status,dmi_processor_status(data[0x18]&0x07));
 +                        else
 +                                sprintf(dmi->processor.status,"Unpopulated");
 +                        sprintf(dmi->processor.upgrade,dmi_processor_upgrade(data[0x19]));
 +                        if(h->length<0x20) break;
 +                        dmi_processor_cache(WORD(data+0x1A), "L1", ver,dmi->processor.cache1);
 +                        dmi_processor_cache(WORD(data+0x1C), "L2", ver,dmi->processor.cache2);
 +                        dmi_processor_cache(WORD(data+0x1E), "L3", ver,dmi->processor.cache3);
 +                        if(h->length<0x23) break;
 +                        strcpy(dmi->processor.serial,dmi_string(h, data[0x20]));
 +                        strcpy(dmi->processor.asset_tag,dmi_string(h, data[0x21]));
 +                        strcpy(dmi->processor.part_number,dmi_string(h, data[0x22]));
 +                        break;
 +              case 6: /* 3.3.7 Memory Module Information */
 +                      if(h->length<0x0C) break;
 +                      dmi->memory_module_count++;
 +                      s_memory_module *module = &dmi->memory_module[dmi->memory_module_count-1];
 +                      dmi->memory_module[dmi->memory_module_count-1].filled=true;
 +                      strncpy(module->socket_designation, dmi_string(h, data[0x04]),
 +                              sizeof(module->socket_designation));
 +                      dmi_memory_module_connections(data[0x05], module->bank_connections);
 +                      dmi_memory_module_speed(data[0x06], module->speed);
 +                      dmi_memory_module_types(WORD(data+0x07), " ", module->type);
 +                      dmi_memory_module_size(data[0x09], module->installed_size);
 +                      dmi_memory_module_size(data[0x0A], module->enabled_size);
 +                      dmi_memory_module_error(data[0x0B], "\t\t", module->error_status);
 +                      break;
 +              case 7: /* 3.3.8 Cache Information */
 +                      if(h->length<0x0F) break;
 +                      dmi->cache_count++;
 +                      if (dmi->cache_count > MAX_DMI_CACHE_ITEMS) break;
 +                      strcpy(dmi->cache[dmi->cache_count-1].socket_designation,
 +                             dmi_string(h, data[0x04]));
 +                      sprintf(dmi->cache[dmi->cache_count-1].configuration,
 +                              "%s, %s, %u",
 +                              WORD(data+0x05)&0x0080?"Enabled":"Disabled",
 +                              WORD(data+0x05)&0x0008?"Socketed":"Not Socketed",
 +                              (WORD(data+0x05)&0x0007)+1);
 +                      strcpy(dmi->cache[dmi->cache_count-1].mode,
 +                             dmi_cache_mode((WORD(data+0x05)>>8)&0x0003));
 +                      strcpy(dmi->cache[dmi->cache_count-1].location,
 +                             dmi_cache_location((WORD(data+0x05)>>5)&0x0003));
 +                      dmi->cache[dmi->cache_count-1].installed_size =
 +                             dmi_cache_size(WORD(data+0x09));
 +                      dmi->cache[dmi->cache_count-1].max_size =
 +                             dmi_cache_size(WORD(data+0x07));
 +                      dmi_cache_types(WORD(data+0x0B), " ",
 +                             dmi->cache[dmi->cache_count-1].supported_sram_types);
 +                      dmi_cache_types(WORD(data+0x0D), " ",
 +                             dmi->cache[dmi->cache_count-1].installed_sram_types);
 +                      if(h->length<0x13) break;
 +                      dmi->cache[dmi->cache_count-1].speed = data[0x0F]; /* ns */
 +                      strcpy(dmi->cache[dmi->cache_count-1].error_correction_type,
 +                             dmi_cache_ec_type(data[0x10]));
 +                      strcpy(dmi->cache[dmi->cache_count-1].system_type,
 +                             dmi_cache_type(data[0x11]));
 +                      strcpy(dmi->cache[dmi->cache_count-1].associativity,
 +                             dmi_cache_associativity(data[0x12]));
 +                      break;
 +              case 10: /* 3.3.11 On Board Devices Information */
 +                      dmi_on_board_devices(h, dmi);
 +                      break;
 +              case 11: /* 3.3.12 OEM Strings */
 +                      if (h->length<0x05) break;
 +                      dmi_oem_strings(h, "\t", dmi);
 +                      break;
 +              case 12: /* 3.3.13 System Configuration Options */
 +                      if (h->length < 0x05) break;
 +                      dmi_system_configuration_options(h, "\t", dmi);
 +                      break;
 +                case 17: /* 3.3.18 Memory Device */
 +                        if (h->length < 0x15) break;
 +                      dmi->memory_count++;
 +                      if (dmi->memory_count > MAX_DMI_MEMORY_ITEMS) break;
 +                      s_memory *mem = &dmi->memory[dmi->memory_count-1];
 +                      dmi->memory[dmi->memory_count-1].filled=true;
 +                        dmi_memory_array_error_handle(WORD(data + 0x06),mem->error);
 +                        dmi_memory_device_width(WORD(data + 0x08),mem->total_width);
 +                        dmi_memory_device_width(WORD(data + 0x0A),mem->data_width);
 +                        dmi_memory_device_size(WORD(data + 0x0C),mem->size);
 +                        strcpy(mem->form_factor,dmi_memory_device_form_factor(data[0x0E]));
 +                        dmi_memory_device_set(data[0x0F],mem->device_set);
 +                        strcpy(mem->device_locator,dmi_string(h, data[0x10]));
 +                        strcpy(mem->bank_locator,dmi_string(h, data[0x11]));
 +                        strcpy(mem->type,dmi_memory_device_type(data[0x12]));
 +                        dmi_memory_device_type_detail(WORD(data + 0x13),mem->type_detail);
 +                        if (h->length < 0x17) break;
 +                        dmi_memory_device_speed(WORD(data + 0x15),mem->speed);
 +                      if (h->length < 0x1B) break;
 +                        strcpy(mem->manufacturer, dmi_string(h, data[0x17]));
 +                        strcpy(mem->serial,dmi_string(h, data[0x18]));
 +                        strcpy(mem->asset_tag,dmi_string(h, data[0x19]));
 +                        strcpy(mem->part_number,dmi_string(h, data[0x1A]));
 +                        break;
 +              case 22: /* 3.3.23 Portable Battery */
 +                        if (h->length < 0x10) break;
 +                      dmi->battery.filled=true;
 +                        strcpy(dmi->battery.location,dmi_string(h, data[0x04]));
 +                        strcpy(dmi->battery.manufacturer,dmi_string(h, data[0x05]));
 +
 +                      if (data[0x06] || h->length < 0x1A)
 +                              strcpy(dmi->battery.manufacture_date, dmi_string(h, data[0x06]));
 +
 +                      if (data[0x07] || h->length < 0x1A)
 +                              strcpy(dmi->battery.serial, dmi_string(h, data[0x07]));
 +
 +                      strcpy(dmi->battery.name,dmi_string(h, data[0x08]));
 +
 +                      if (data[0x09] != 0x02 || h->length < 0x1A)
 +                        strcpy(dmi->battery.chemistry,dmi_battery_chemistry(data[0x09]));
 +
 +                      if (h->length < 0x1A)
 +                                dmi_battery_capacity(WORD(data + 0x0A), 1,dmi->battery.design_capacity);
 +                        else
 +                                dmi_battery_capacity(WORD(data + 0x0A), data[0x15],dmi->battery.design_capacity);
 +                        dmi_battery_voltage(WORD(data + 0x0C),dmi->battery.design_voltage);
 +                        strcpy(dmi->battery.sbds,dmi_string(h, data[0x0E]));
 +                        dmi_battery_maximum_error(data[0x0F],dmi->battery.maximum_error);
 +                        if (h->length < 0x1A) break;
 +                        if (data[0x07] == 0)
 +                         sprintf(dmi->battery.sbds_serial,"%04X", WORD(data + 0x10));
 +
 +                      if (data[0x06] == 0)
 +                              sprintf(dmi->battery.sbds_manufacture_date,"%u-%02u-%02u",
 +                                              1980 + (WORD(data + 0x12) >> 9),
 +                                              (WORD(data + 0x12) >> 5) & 0x0F,
 +                                              WORD(data + 0x12) & 0x1F);
 +                        if (data[0x09] == 0x02)
 +                              strcpy(dmi->battery.sbds_chemistry, dmi_string(h, data[0x14]));
 +
 +              //      sprintf(dmi->battery.oem_info,"0x%08X",DWORD(h, data+0x16));
 +                        break;
 +              case 23: /* 3.3.24 System Reset */
 +                      if(h->length<0x0D) break;
 +                      dmi->system.system_reset.filled = true;
 +                      dmi->system.system_reset.status = data[0x04]&(1<<0);
 +                      dmi->system.system_reset.watchdog = data[0x04]&(1<<5);
 +                      if (!(data[0x04]&(1<<5)))
 +                              break;
 +                      strncpy(dmi->system.system_reset.boot_option,
 +                              dmi_system_reset_boot_option((data[0x04]>>1)&0x3),
 +                              sizeof dmi->system.system_reset.boot_option);
 +                      strncpy(dmi->system.system_reset.boot_option_on_limit,
 +                              dmi_system_reset_boot_option((data[0x04]>>3)&0x3),
 +                              sizeof dmi->system.system_reset.boot_option_on_limit);
 +                      dmi_system_reset_count(WORD(data+0x05), dmi->system.system_reset.reset_count);
 +                      dmi_system_reset_count(WORD(data+0x07), dmi->system.system_reset.reset_limit);
 +                      dmi_system_reset_timer(WORD(data+0x09), dmi->system.system_reset.timer_interval);
 +                      dmi_system_reset_timer(WORD(data+0x0B), dmi->system.system_reset.timeout);
 +                      break;
 +              case 24: /* 3.3.25 Hardware Security */
 +                      if (h->length<0x05) break;
 +                      dmi->hardware_security.filled = true;
 +                      strncpy(dmi->hardware_security.power_on_passwd_status,
 +                              dmi_hardware_security_status(data[0x04]>>6),
 +                              sizeof dmi->hardware_security.power_on_passwd_status);
 +                      strncpy(dmi->hardware_security.keyboard_passwd_status,
 +                              dmi_hardware_security_status((data[0x04]>>4)&0x3),
 +                              sizeof dmi->hardware_security.keyboard_passwd_status);
 +                      strncpy(dmi->hardware_security.administrator_passwd_status,
 +                              dmi_hardware_security_status((data[0x04]>>2)&0x3),
 +                              sizeof dmi->hardware_security.administrator_passwd_status);
 +                      strncpy(dmi->hardware_security.front_panel_reset_status,
 +                              dmi_hardware_security_status(data[0x04]&0x3),
 +                              sizeof dmi->hardware_security.front_panel_reset_status);
 +                      break;
 +            case 32: /* 3.3.33 System Boot Information */
 +                      if (h->length < 0x0B) break;
 +                      dmi_system_boot_status(data[0x0A],
 +                                             dmi->system.system_boot_status);
 +            case 38: /* 3.3.39 IPMI Device Information */
 +                        if (h->length < 0x10) break;
 +                      dmi->ipmi.filled=true;
 +                      snprintf(dmi->ipmi.interface_type,sizeof(dmi->ipmi.interface_type),
 +                              "%s", dmi_ipmi_interface_type(data[0x04]));
 +                      dmi->ipmi.major_specification_version=data[0x05] >> 4;
 +                      dmi->ipmi.minor_specification_version=data[0x05] & 0x0F;
 +                      dmi->ipmi.I2C_slave_address=data[0x06] >> 1;
 +                        if (data[0x07] != 0xFF)
 +                              dmi->ipmi.nv_address=data[0x07];
 +                        else
 +                              dmi->ipmi.nv_address=0; /* Not Present */
 +                        dmi_ipmi_base_address(data[0x04], data + 0x08,
 +                                &dmi->ipmi);
 +                        if (h->length < 0x12) break;
 +                      if (data[0x11] != 0x00)
 +                        {
 +                                dmi->ipmi.irq=data[0x11];
 +                        }
 +                        break;
 +        }
  }
  
- void parse_dmitable(s_dmi *dmi) {
-   int i=0;
-   uint8_t *data = NULL;
-   uint8_t buf[dmi->dmitable.len];
-   memcpy(buf,(int *)dmi->dmitable.base,sizeof(uint8_t) * dmi->dmitable.len);
-   data=buf;
-   dmi->memory_count=0;
-   while(i<dmi->dmitable.num && data+4<=buf+dmi->dmitable.len) /* 4 is the length of an SMBIOS structure header */ {
-         uint8_t *next;
-         struct dmi_header h;
-         to_dmi_header(&h, data);
-         /*
-         * If a short entry is found (less than 4 bytes), not only it
-         * is invalid, but we cannot reliably locate the next entry.
-         * Better stop at this point, and let the user know his/her
-         * table is broken.
-         */
-         if(h.length<4)
-           {
-             printf("Invalid entry length (%u). DMI table is broken! Stop.\n\n", (unsigned int)h.length);
-             break;
-           }
+ void parse_dmitable(s_dmi * dmi)
+ {
+     int i = 0;
+     uint8_t *data = NULL;
+     uint8_t buf[dmi->dmitable.len];
+     memcpy(buf, (int *)dmi->dmitable.base, sizeof(uint8_t) * dmi->dmitable.len);
+     data = buf;
+     dmi->memory_count = 0;
+     while (i < dmi->dmitable.num && data + 4 <= buf + dmi->dmitable.len) {    /* 4 is the length of an SMBIOS structure header */
+       uint8_t *next;
+       struct dmi_header h;
+       to_dmi_header(&h, data);
+       /*
+        * If a short entry is found (less than 4 bytes), not only it
+        * is invalid, but we cannot reliably locate the next entry.
+        * Better stop at this point, and let the user know his/her
+        * table is broken.
+        */
+       if (h.length < 4) {
+           printf("Invalid entry length (%u). DMI table is broken! Stop.\n\n",
+                  (unsigned int)h.length);
+           break;
+       }
  //        printf("Handle 0x%04X, DMI type %d, %d bytes\n", h.handle, h.type, h.length);
  
-         /* loo for the next handle */
-         next=data+h.length;
-         while(next-buf+1<dmi->dmitable.len && (next[0]!=0 || next[1]!=0))
-                next++;
-         next+=2;
-         if(next-buf<=dmi->dmitable.len)
-            {
-              dmi_decode(&h, dmi->dmitable.ver,dmi);
-            }
-         data=next;
-         i++;
-   }
+       /* loo for the next handle */
+       next = data + h.length;
+       while (next - buf + 1 < dmi->dmitable.len
+              && (next[0] != 0 || next[1] != 0))
+           next++;
+       next += 2;
+       if (next - buf <= dmi->dmitable.len) {
+           dmi_decode(&h, dmi->dmitable.ver, dmi);
+       }
+       data = next;
+       i++;
+     }
  }
@@@ -164,100 -163,8 +163,100 @@@ void dmi_memory_device_type_detail(uint
  
  void dmi_memory_device_speed(uint16_t code, char *speed)
  {
-  if (code == 0)
-       sprintf(speed,"%s","Unknown");
-  else
-       sprintf(speed,"%u MHz", code);
+     if (code == 0)
+       sprintf(speed, "%s", "Unknown");
+     else
+       sprintf(speed, "%u MHz", code);
  }
 +
 +/*
 + * 3.3.7 Memory Module Information (Type 6)
 + */
 +
 +void dmi_memory_module_types(uint16_t code, const char *sep, char *type)
 +{
 +      /* 3.3.7.1 */
 +      static const char *types[]={
 +              "Other", /* 0 */
 +              "Unknown",
 +              "Standard",
 +              "FPM",
 +              "EDO",
 +              "Parity",
 +              "ECC",
 +              "SIMM",
 +              "DIMM",
 +              "Burst EDO",
 +              "SDRAM" /* 10 */
 +      };
 +
 +      if((code&0x07FF)==0)
 +              sprintf(type, "%s", "None");
 +      else
 +      {
 +              int i;
 +
 +              for(i=0; i<=10; i++)
 +                      if(code&(1<<i))
 +                              sprintf(type, "%s%s", sep, types[i]);
 +      }
 +}
 +
 +void dmi_memory_module_connections(uint8_t code, char* connection)
 +{
 +      if(code==0xFF)
 +              sprintf(connection, "%s", "None");
 +      else
 +      {
 +              if((code&0xF0)!=0xF0)
 +                      sprintf(connection, "%u", code>>4);
 +              if((code&0x0F)!=0x0F)
 +                      sprintf(connection, "%u", code&0x0F);
 +      }
 +}
 +
 +void dmi_memory_module_speed(uint8_t code, char* speed)
 +{
 +      if(code==0)
 +              sprintf(speed, "%s", "Unknown");
 +      else
 +              sprintf(speed, "%u ns", code);
 +}
 +
 +void dmi_memory_module_size(uint8_t code, char* size)
 +{
 +      /* 3.3.7.2 */
 +      switch(code&0x7F)
 +      {
 +              case 0x7D:
 +                      sprintf(size, "%s", "Not Determinable");
 +                      break;
 +              case 0x7E:
 +                      sprintf(size, "%s", "Disabled");
 +                      break;
 +              case 0x7F:
 +                      sprintf(size, "%s", "Not Installed");
 +                      return;
 +              default:
 +                      sprintf(size, "%u MB", 1<<(code&0x7F));
 +      }
 +
 +      if(code&0x80)
 +              printf(size, "%s", "(Double-bank Connection)");
 +      else
 +              printf(size, "%s", "(Single-bank Connection)");
 +}
 +
 +void dmi_memory_module_error(uint8_t code, const char *prefix, char *error)
 +{
 +      if(code&(1<<2))
 +              sprintf(error, "%s", "See Event Log\n");
 +      else
 +      {       if((code&0x03)==0)
 +                      printf(error, "%s", "OK\n");
 +              if(code&(1<<0))
 +                      printf(error, "%sUncorrectable Errors\n", prefix);
 +              if(code&(1<<1))
 +                      printf(error, "%sCorrectable Errors\n", prefix);
 +      }
 +}
Simple merge
@@@ -142,11 -142,12 +143,11 @@@ void pci_writel(uint32_t, pciaddr_t)
  
  struct pci_domain *pci_scan(void);
  void free_pci_domain(struct pci_domain *domain);
- struct match * find_pci_device(const struct pci_domain *pci_domain,
-                              struct match *list);
+ struct match *find_pci_device(const struct pci_domain *pci_domain,
+                             struct match *list);
  int get_name_from_pci_ids(struct pci_domain *pci_domain, char *pciids_path);
 -int get_module_name_from_pcimap(struct pci_domain *pci_domain,
 -                              char *modules_pcimap_path);
 -int get_class_name_from_pci_ids(struct pci_domain *pci_domain,
 -                              char *pciids_path);
 +int get_module_name_from_pcimap(struct pci_domain *pci_domain, char *modules_pcimap_path);
 +int get_module_name_from_alias(struct pci_domain *pci_domain, char *modules_alias_path);
 +int get_class_name_from_pci_ids(struct pci_domain *pci_domain, char *pciids_path);
  void gather_additional_pci_config(struct pci_domain *domain);
  #endif /* _SYS_PCI_H */
@@@ -73,91 -75,103 +75,92 @@@ static int hex_to_int(char *hexa
  
  /* Try to match any pci device to the appropriate kernel module */
  /* it uses the modules.pcimap from the boot device */
- int get_module_name_from_pcimap(struct pci_domain *domain, char *modules_pcimap_path)
+ int get_module_name_from_pcimap(struct pci_domain *domain,
+                               char *modules_pcimap_path)
  {
 -    char line[MAX_LINE];
 -    char module_name[21];     // the module name field is 21 char long
 -    char delims[] = " ";      // colums are separated by spaces
 -    char vendor_id[16];
 -    char product_id[16];
 -    char sub_vendor_id[16];
 -    char sub_product_id[16];
 -    FILE *f;
 -    struct pci_device *dev = NULL;
 -
 -    /* Intializing the linux_kernel_module for each pci device to "unknown" */
 -    /* adding a dev_info member if needed */
 -    for_each_pci_func(dev, domain) {
 -      /* initialize the dev_info structure if it doesn't exist yet. */
 -      if (!dev->dev_info) {
 -          dev->dev_info = zalloc(sizeof *dev->dev_info);
 -          if (!dev->dev_info)
 -              return -1;
 -      }
 -      for (int i = 0; i < MAX_KERNEL_MODULES_PER_PCI_DEVICE; i++) {
 -          strlcpy(dev->dev_info->linux_kernel_module[i], "unknown", 7);
 -      }
 +  char line[MAX_LINE];
 +  char module_name[21]; // the module name field is 21 char long
 +  char delims[]=" ";    // colums are separated by spaces
 +  char vendor_id[16];
 +  char product_id[16];
 +  char sub_vendor_id[16];
 +  char sub_product_id[16];
 +  FILE *f;
 +  struct pci_device *dev=NULL;
 +
 +  /* Intializing the linux_kernel_module for each pci device to "unknown" */
 +  /* adding a dev_info member if needed */
 +  for_each_pci_func(dev, domain) {
 +    /* initialize the dev_info structure if it doesn't exist yet. */
 +    if (! dev->dev_info) {
 +      dev->dev_info = zalloc(sizeof *dev->dev_info);
 +      if (!dev->dev_info)
 +      return -1;
      }
 -
 -    /* Opening the modules.pcimap (of a linux kernel) from the boot device */
 -    f = fopen(modules_pcimap_path, "r");
 -    if (!f)
 -      return -ENOMODULESPCIMAP;
 -
 -    strcpy(vendor_id, "0000");
 -    strcpy(product_id, "0000");
 -    strcpy(sub_product_id, "0000");
 -    strcpy(sub_vendor_id, "0000");
 -    dev->dev_info->linux_kernel_module_count = 0;
 -
 -    /* for each line we found in the modules.pcimap */
 -    while (fgets(line, sizeof line, f)) {
 -      /* skipping unecessary lines */
 -      if ((line[0] == '#') || (line[0] == ' ') || (line[0] == 10))
 -          continue;
 -
 -      char *result = NULL;
 -      int field = 0;
 -
 -      /* looking for the next field */
 -      result = strtok(line, delims);
 -      while (result != NULL) {
 -          /* if the column is larger than 1 char */
 -          /* multiple spaces generates some empty fields */
 -          if (strlen(result) > 1) {
 -              switch (field) {
 -              case 0:
 -                  strcpy(module_name, result);
 -                  break;
 -              case 1:
 -                  strcpy(vendor_id, result);
 -                  break;
 -              case 2:
 -                  strcpy(product_id, result);
 -                  break;
 -              case 3:
 -                  strcpy(sub_vendor_id, result);
 -                  break;
 -              case 4:
 -                  strcpy(sub_product_id, result);
 -                  break;
 -              }
 -              field++;
 -          }
 -          /* Searching the next field */
 -          result = strtok(NULL, delims);
 -      }
 -      int int_vendor_id = hex_to_int(vendor_id);
 -      int int_sub_vendor_id = hex_to_int(sub_vendor_id);
 -      int int_product_id = hex_to_int(product_id);
 -      int int_sub_product_id = hex_to_int(sub_product_id);
 -      /* if a pci_device matches an entry, fill the linux_kernel_module with
 -         the appropriate kernel module */
 -      for_each_pci_func(dev, domain) {
 -          if (int_vendor_id == dev->vendor &&
 -              int_product_id == dev->product &&
 -              (int_sub_product_id & dev->sub_product)
 -              == dev->sub_product && (int_sub_vendor_id & dev->sub_vendor)
 -              == dev->sub_vendor) {
 -              strcpy(dev->dev_info->
 -                     linux_kernel_module[dev->dev_info->
 -                                         linux_kernel_module_count],
 -                     module_name);
 -              dev->dev_info->linux_kernel_module_count++;
 -          }
 -      }
 +    for (int i=0;i<MAX_KERNEL_MODULES_PER_PCI_DEVICE;i++) {
 +     if (strlen(dev->dev_info->linux_kernel_module[i])==0)
 +       strlcpy(dev->dev_info->linux_kernel_module[i], "unknown",7);
      }
 -    fclose(f);
 -    return 0;
 +  }
 +
 +  /* Opening the modules.pcimap (of a linux kernel) from the boot device */
 +  f=fopen(modules_pcimap_path, "r");
 +  if (!f)
 +    return -ENOMODULESPCIMAP;
 +
 +  strcpy(vendor_id,"0000");
 +  strcpy(product_id,"0000");
 +  strcpy(sub_product_id,"0000");
 +  strcpy(sub_vendor_id,"0000");
 +  dev->dev_info->linux_kernel_module_count=0;
 +
 +  /* for each line we found in the modules.pcimap */
 +  while ( fgets(line, sizeof line, f) ) {
 +    /* skipping unecessary lines */
 +    if ((line[0] == '#') || (line[0] == ' ') || (line[0] == 10))
 +        continue;
 +
 +    char *result = NULL;
 +    int field=0;
 +
 +    /* looking for the next field */
 +    result = strtok(line, delims);
 +    while( result != NULL ) {
 +       /* if the column is larger than 1 char */
 +       /* multiple spaces generates some empty fields */
 +       if (strlen(result)>1) {
 +       switch (field) {
 +       case 0:strcpy(module_name,result); break;
 +       case 1:strcpy(vendor_id,result); break;
 +       case 2:strcpy(product_id,result); break;
 +       case 3:strcpy(sub_vendor_id,result); break;
 +       case 4:strcpy(sub_product_id,result); break;
 +       }
 +       field++;
 +       }
 +       /* Searching the next field */
 +       result = strtok( NULL, delims );
 +   }
 +    int int_vendor_id=hex_to_int(vendor_id);
 +    int int_sub_vendor_id=hex_to_int(sub_vendor_id);
 +    int int_product_id=hex_to_int(product_id);
 +    int int_sub_product_id=hex_to_int(sub_product_id);
 +    /* if a pci_device matches an entry, fill the linux_kernel_module with
 +       the appropriate kernel module */
 +    for_each_pci_func(dev, domain) {
 +      if (int_vendor_id == dev->vendor &&
 +        int_product_id == dev->product &&
 +        (int_sub_product_id & dev->sub_product)
 +        == dev->sub_product &&
 +        (int_sub_vendor_id & dev->sub_vendor)
 +        == dev->sub_vendor) {
 +      strcpy(dev->dev_info->linux_kernel_module[dev->dev_info->linux_kernel_module_count], module_name);
 +      dev->dev_info->linux_kernel_module_count++;
 +      }
 +    }
 +  }
 +  fclose(f);
 +  return 0;
  }
  
  /* Try to match any pci device to the appropriate class name */
@@@ -519,181 -544,54 +533,180 @@@ bail
  /* gathering additional configuration*/
  void gather_additional_pci_config(struct pci_domain *domain)
  {
-   struct pci_device *dev;
-   pciaddr_t pci_addr;
-   int cfgtype;
-   cfgtype = pci_set_config_type(PCI_CFG_AUTO);
-   if (cfgtype == PCI_CFG_NONE)
-     return;
-   for_each_pci_func3(dev, domain,pci_addr) {
-     if (! dev->dev_info) {
-           dev->dev_info = zalloc(sizeof *dev->dev_info);
-           if (!dev->dev_info) {
-             return;
-         }
-           }
-         dev->dev_info->irq = pci_readb(pci_addr + 0x3c);
-         dev->dev_info->latency = pci_readb(pci_addr + 0x0d);
-    }
+     struct pci_device *dev;
+     pciaddr_t pci_addr;
+     int cfgtype;
+     cfgtype = pci_set_config_type(PCI_CFG_AUTO);
+     if (cfgtype == PCI_CFG_NONE)
+       return;
+     for_each_pci_func3(dev, domain, pci_addr) {
+       if (!dev->dev_info) {
+           dev->dev_info = zalloc(sizeof *dev->dev_info);
+           if (!dev->dev_info) {
+               return;
+           }
+       }
+       dev->dev_info->irq = pci_readb(pci_addr + 0x3c);
+       dev->dev_info->latency = pci_readb(pci_addr + 0x0d);
+     }
  }
  
  void free_pci_domain(struct pci_domain *domain)
  {
-   struct pci_bus    *bus;
-   struct pci_slot   *slot;
-   struct pci_device *func;
-   unsigned int nbus, ndev, nfunc;
-   if (domain) {
-     for (nbus = 0; nbus < MAX_PCI_BUSES; nbus++) {
-       bus = domain->bus[nbus];
-       if (bus) {
-       for (ndev = 0; ndev < MAX_PCI_DEVICES; ndev++) {
-         slot = bus->slot[ndev];
-         if (slot) {
-           for (nfunc = 0; nfunc < MAX_PCI_FUNC; nfunc++) {
-             func = slot->func[nfunc];
-             if (func) {
-               if (func->dev_info)
-                 free(func->dev_info);
-               free(func);
-             }
-             free(slot);
+     struct pci_bus *bus;
+     struct pci_slot *slot;
+     struct pci_device *func;
+     unsigned int nbus, ndev, nfunc;
+     if (domain) {
+       for (nbus = 0; nbus < MAX_PCI_BUSES; nbus++) {
+           bus = domain->bus[nbus];
+           if (bus) {
+               for (ndev = 0; ndev < MAX_PCI_DEVICES; ndev++) {
+                   slot = bus->slot[ndev];
+                   if (slot) {
+                       for (nfunc = 0; nfunc < MAX_PCI_FUNC; nfunc++) {
+                           func = slot->func[nfunc];
+                           if (func) {
+                               if (func->dev_info)
+                                   free(func->dev_info);
+                               free(func);
+                           }
+                           free(slot);
+                       }
+                   }
+                   free(bus);
+               }
            }
-         }
-         free(bus);
+           free(domain);
        }
-       }
-       free(domain);
      }
-   }
  }
 +
 +/* Try to match any pci device to the appropriate kernel module */
 +/* it uses the modules.alias from the boot device */
 +int get_module_name_from_alias(struct pci_domain *domain, char *modules_alias_path)
 +{
 +  char line[MAX_LINE];
 +  char module_name[21]; // the module name field is 21 char long
 +  char delims[]="*";    // colums are separated by spaces
 +  char vendor_id[16];
 +  char product_id[16];
 +  char sub_vendor_id[16];
 +  char sub_product_id[16];
 +  FILE *f;
 +  struct pci_device *dev=NULL;
 +
 +  /* Intializing the linux_kernel_module for each pci device to "unknown" */
 +  /* adding a dev_info member if needed */
 +  for_each_pci_func(dev, domain) {
 +    /* initialize the dev_info structure if it doesn't exist yet. */
 +    if (! dev->dev_info) {
 +      dev->dev_info = zalloc(sizeof *dev->dev_info);
 +      if (!dev->dev_info)
 +      return -1;
 +    }
 +    for (int i=0;i<MAX_KERNEL_MODULES_PER_PCI_DEVICE;i++) {
 +     if (strlen(dev->dev_info->linux_kernel_module[i])==0)
 +       strlcpy(dev->dev_info->linux_kernel_module[i], "unknown",7);
 +    }
 +  }
 +
 +  /* Opening the modules.pcimap (of a linux kernel) from the boot device */
 +  f=fopen(modules_alias_path, "r");
 +  if (!f)
 +    return -ENOMODULESALIAS;
 +
 +  dev->dev_info->linux_kernel_module_count=0;
 +
 +  /* for each line we found in the modules.pcimap */
 +  while ( fgets(line, sizeof line, f) ) {
 +    /* skipping unecessary lines */
 +    if ((line[0] == '#') || (strstr(line,"alias pci:v")==NULL))
 +        continue;
 +
 +    /* Resetting temp buffer*/
 +    memset(module_name,0,sizeof(module_name));
 +    memset(vendor_id,0,sizeof(vendor_id));
 +    memset(sub_vendor_id,0,sizeof(sub_vendor_id));
 +    memset(product_id,0,sizeof(product_id));
 +    memset(sub_product_id,0,sizeof(sub_product_id));
 +    strcpy(vendor_id,"0000");
 +    strcpy(product_id,"0000");
 +    /* ffff will be used to match any device as in modules.alias
 +     * a missing subvendor/product have to be considered as  0xFFFF*/
 +    strcpy(sub_product_id,"ffff");
 +    strcpy(sub_vendor_id,"ffff");
 +
 +    char *result = NULL;
 +    int field=0;
 +
 +    /* looking for the next field */
 +    result = strtok(line+strlen("alias pci:v"), delims);
 +    while( result != NULL ) {
 +      if (field==0) {
 +
 +              /* Searching for the vendor separator*/
 +              char *temp = strstr(result,"d");
 +              if (temp != NULL) {
 +                      strncpy(vendor_id,result,temp-result);
 +                      result+=strlen(vendor_id)+1;
 +              }
 +
 +              /* Searching for the product separator*/
 +              temp = strstr(result,"sv");
 +              if (temp != NULL) {
 +                      strncpy(product_id,result,temp-result);
 +                      result+=strlen(product_id)+1;
 +              }
 +
 +              /* Searching for the sub vendor separator*/
 +              temp = strstr(result,"sd");
 +              if (temp != NULL) {
 +                      strncpy(sub_vendor_id,result,temp-result);
 +                      result+=strlen(sub_vendor_id)+1;
 +              }
 +
 +              /* Searching for the sub product separator*/
 +              temp = strstr(result,"bc");
 +              if (temp != NULL) {
 +                      strncpy(sub_product_id,result,temp-result);
 +                      result+=strlen(sub_product_id)+1;
 +              }
 +      /* That's the module name */
 +      } else if ((strlen(result)>2) &&
 +                      (result[0]==0x20))
 +              strcpy(module_name,result+1);
 +              /* We have to replace \n by \0*/
 +              module_name[strlen(module_name)-1]='\0';
 +      field++;
 +
 +      /* Searching the next field */
 +        result = strtok( NULL, delims );
 +    }
 +
 +    /* Now we have extracted informations from the modules.alias
 +     * Let's compare it with the devices we know*/
 +    int int_vendor_id=hex_to_int(vendor_id);
 +    int int_sub_vendor_id=hex_to_int(sub_vendor_id);
 +    int int_product_id=hex_to_int(product_id);
 +    int int_sub_product_id=hex_to_int(sub_product_id);
 +    /* if a pci_device matches an entry, fill the linux_kernel_module with
 +       the appropriate kernel module */
 +    for_each_pci_func(dev, domain) {
 +      if (int_vendor_id == dev->vendor &&
 +        int_product_id == dev->product &&
 +        (int_sub_product_id & dev->sub_product)
 +        == dev->sub_product &&
 +        (int_sub_vendor_id & dev->sub_vendor)
 +        == dev->sub_vendor) {
 +      strcpy(dev->dev_info->linux_kernel_module[dev->dev_info->linux_kernel_module_count], module_name);
 +      dev->dev_info->linux_kernel_module_count++;
 +      }
 +    }
 +  }
 +  fclose(f);
 +  return 0;
 +}
@@@ -18,8 -18,7 +18,7 @@@
  topdir = ../..
  include ../MCONFIG
  
- MODULES         = chain.c32 config.c32 ethersel.c32 mboot.c32 dmitest.c32 \
-           cpuidtest.c32 disk.c32 \
 -MODULES         = chain.c32 config.c32 ethersel.c32 dmitest.c32 cpuidtest.c32 \
++MODULES         = chain.c32 config.c32 ethersel.c32 dmitest.c32 cpuidtest.c32 disk.c32 \
            pcitest.c32 elf.c32 linux.c32 reboot.c32 pmload.c32 meminfo.c32 \
            sdi.c32 sanboot.c32 ifcpu64.c32 vesainfo.c32 kbdmap.c32 cmd.c32 \
            vpdtest.c32