diff options
Diffstat (limited to 'src/dmidecode')
-rw-r--r-- | src/dmidecode/dmidecode.c | 107 | ||||
-rw-r--r-- | src/dmidecode/dmidecode.h | 13 | ||||
-rw-r--r-- | src/dmidecode/dmioem.c | 1 | ||||
-rw-r--r-- | src/dmidecode/util.c | 3 |
4 files changed, 57 insertions, 67 deletions
diff --git a/src/dmidecode/dmidecode.c b/src/dmidecode/dmidecode.c index 5c542a6..ec91305 100644 --- a/src/dmidecode/dmidecode.c +++ b/src/dmidecode/dmidecode.c @@ -29,6 +29,7 @@ #include <string.h> #include <stdlib.h> #include <unistd.h> +#include <ctype.h> #include "config.h" #include "types.h" @@ -37,8 +38,8 @@ #include "dmioem.h" #include "../state.h" #include "../pci.h" +#include "../naming_policy.h" -static const char *out_of_spec = "<OUT OF SPEC>"; static const char *bad_index = "<BAD INDEX>"; /* @@ -73,76 +74,48 @@ const char *dmi_string(struct dmi_header *dm, u8 s) return bp; } -static const char *dmi_slot_current_usage(u8 code) -{ - /* 3.3.10.3 */ - static const char *usage[]={ - "Other", /* 0x01 */ - "Unknown", - "Available", - "In Use" /* 0x04 */ - }; - - if(code>=0x01 && code<=0x04) - return usage[code-0x01]; - return out_of_spec; -} +/* + * Main + */ -static void dmi_slot_segment_bus_func(u16 code1, u8 code2, u8 code3, u8 type, const char *prefix) +#define MIN(a,b) (((a)<(b))?(a):(b)) + +static void strip_right(char *s) { - /* 3.3.10.8 */ - if (!(code1==0xFFFF && code2==0xFF && code3==0xFF)) - printf("%sSegment Group %u, Bus %u, Device %u, Function %u ", - prefix, code1, code2, (code3>>3)&0x1F, (code3&0x7)); - switch(type) - { - case 0x06: /* PCI */ - case 0x0E: /* PCI */ - case 0x0F: /* AGP */ - case 0x10: /* AGP */ - case 0x11: /* AGP */ - case 0x12: /* PCI-X */ - case 0x13: /* AGP */ - case 0xA5: /* PCI Express */ - printf("\n"); - break; - default: - if (code1 != 0xFF || code2 != 0xFF || code3 != 0xFF) - printf("%s\n", out_of_spec); + int i, len = strlen(s); + for (i=len; i>=0; i--) { + if (isspace(s[i-1])) + s[i-1] = '\0'; + else break; } } -static u8 onboard_device_type(u8 code, const char *prefix) +static void fill_one_slot_function(struct pci_device *pdev, struct dmi_header *h) { - /* 3.3.x.2 */ - u8 e = (code & 0x80)>>7; - static const char *type[]={ - "Other", /* 1 */ - "Unknown", - "Video", - "SCSI Controller", - "Ethernet", - "Token Ring", - "Sound", - "PATA Controller", - "SATA Controller", - "SAS Controller" /* 0x0A */ - }; - code = code & 0x7F; - if(code>=0x01 && code<=0x0A) { - printf("%sStatus: %s\n", prefix, e?"Enabled":"Disabled"); - printf("%sDevice Type: %s\n", prefix, type[code-0x01]); + u8 *data = h->data; + pdev->physical_slot = WORD(data+0x09); + pdev->smbios_type = 0; + pdev->smbios_instance = 0; + pdev->uses_smbios |= HAS_SMBIOS_SLOT; + if (dmi_string(h, data[0x04])) { + pdev->smbios_label=strdup(dmi_string(h, data[0x04])); + pdev->uses_smbios |= HAS_SMBIOS_LABEL; } - else - printf("%sDevice Type: %s\n", prefix, out_of_spec); + strip_right(pdev->smbios_label); } -/* - * Main - */ - -#define MIN(a,b) (((a)<(b))?(a):(b)) +static void fill_all_slot_functions(const struct libbiosdevname_state *state, int domain, int bus, int device, struct dmi_header *h) +{ + struct pci_device *pdev; + list_for_each_entry(pdev, &state->pci_devices, node) { + if (pdev->pci_dev->domain == domain && + pdev->pci_dev->bus == bus && + pdev->pci_dev->dev == device && + ! (pdev->uses_smbios & HAS_SMBIOS_EXACT_MATCH)) + fill_one_slot_function(pdev, h); + } +} static void dmi_decode(struct dmi_header *h, u16 ver, const struct libbiosdevname_state *state) { @@ -162,10 +135,10 @@ static void dmi_decode(struct dmi_header *h, u16 ver, const struct libbiosdevnam function = data[0x10] & 7; pdev = find_pci_dev_by_pci_addr(state, domain, bus, device, function); if (pdev) { - pdev->physical_slot = WORD(data+0x09); - pdev->smbios_type = 0; - pdev->smbios_instance = 0; + fill_one_slot_function(pdev, h); + pdev->uses_smbios |= HAS_SMBIOS_EXACT_MATCH; } + fill_all_slot_functions(state, domain, bus, device, h); } } break; @@ -180,6 +153,12 @@ static void dmi_decode(struct dmi_header *h, u16 ver, const struct libbiosdevnam pdev->smbios_enabled = !!(data[0x05] & 0x80); pdev->smbios_type = data[0x05] & 0x7F; pdev->smbios_instance = data[0x06]; + pdev->uses_smbios |= HAS_SMBIOS_INSTANCE | HAS_SMBIOS_SLOT; + if (dmi_string(h, data[0x04])) { + pdev->smbios_label=strdup(dmi_string(h, data[0x04])); + pdev->uses_smbios |= HAS_SMBIOS_LABEL; + } + strip_right(pdev->smbios_label); } break; diff --git a/src/dmidecode/dmidecode.h b/src/dmidecode/dmidecode.h index db8f7bd..3427866 100644 --- a/src/dmidecode/dmidecode.h +++ b/src/dmidecode/dmidecode.h @@ -50,6 +50,19 @@ struct dmi_addon_device const char *reference_designation; }; +enum dmi_onboard_device_type { + DMI_OTHER=1, + DMI_UNKNOWN, + DMI_VIDEO, + DMI_SCSI, + DMI_ETHERNET, + DMI_TOKEN_RING, + DMI_SOUND, + DMI_PATA, + DMI_SATA, + DMI_SAS, +}; + struct libbiosdevname_state; int dmidecode_main(const struct libbiosdevname_state *state); diff --git a/src/dmidecode/dmioem.c b/src/dmidecode/dmioem.c index 217c13a..234dbf4 100644 --- a/src/dmidecode/dmioem.c +++ b/src/dmidecode/dmioem.c @@ -91,6 +91,7 @@ static int dmi_decode_hp(struct dmi_header *h, const struct libbiosdevname_state pdev->smbios_enabled = 1; pdev->smbios_type = smbios_type; pdev->smbios_instance = nic; + pdev->physical_slot = 0; } } nic++; diff --git a/src/dmidecode/util.c b/src/dmidecode/util.c index 9eda714..b703b3a 100644 --- a/src/dmidecode/util.c +++ b/src/dmidecode/util.c @@ -105,7 +105,6 @@ void *mem_chunk(size_t base, size_t len, const char *devmem) if((fd=open(devmem, O_RDONLY))==-1) { - perror(devmem); return NULL; } @@ -129,8 +128,6 @@ void *mem_chunk(size_t base, size_t len, const char *devmem) mmp=mmap(0, mmoffset+len, PROT_READ, MAP_SHARED, fd, base-mmoffset); if(mmp==MAP_FAILED) { - fprintf(stderr, "%s: ", devmem); - perror("mmap"); free(p); return NULL; } |