diff options
author | Jean Delvare <jdelvare@suse.de> | 2007-02-11 16:17:55 +0000 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2007-02-11 16:17:55 +0000 |
commit | 4b3c8b16bc31b9b69e6c18fc3a5c98ae059e338f (patch) | |
tree | f5aa2d40f242442b51f45d004b951c801980647f | |
parent | 7c97310806ede362ce12953070fc73df28724a67 (diff) | |
download | dmidecode-git-4b3c8b16bc31b9b69e6c18fc3a5c98ae059e338f.tar.gz |
Move the decoding of OEM-specific entries to a separate source file.
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | dmidecode.c | 127 | ||||
-rw-r--r-- | dmidecode.h | 11 | ||||
-rw-r--r-- | dmioem.c | 152 | ||||
-rw-r--r-- | dmioem.h | 25 |
5 files changed, 198 insertions, 128 deletions
@@ -3,7 +3,7 @@ # BIOS Decode # # (C) 2000-2002 Alan Cox <alan@redhat.com> -# (C) 2002-2005 Jean Delvare <khali@linux-fr.org> +# (C) 2002-2007 Jean Delvare <khali@linux-fr.org> # # Licensed under the GNU Public License. # @@ -40,8 +40,8 @@ all : dmidecode biosdecode ownership vpddecode # Programs # -dmidecode : dmidecode.o dmiopt.o util.o - $(CC) $(LDFLAGS) dmidecode.o dmiopt.o util.o -o $@ +dmidecode : dmidecode.o dmiopt.o dmioem.o util.o + $(CC) $(LDFLAGS) dmidecode.o dmiopt.o dmioem.o util.o -o $@ biosdecode : biosdecode.o util.o $(CC) $(LDFLAGS) biosdecode.o util.o -o $@ @@ -57,12 +57,15 @@ vpddecode : vpddecode.o vpdopt.o util.o # dmidecode.o : dmidecode.c version.h types.h util.h config.h dmidecode.h \ - dmiopt.h + dmiopt.h dmioem.h $(CC) $(CFLAGS) -c $< -o $@ dmiopt.o : dmiopt.c config.h types.h dmidecode.h dmiopt.h $(CC) $(CFLAGS) -c $< -o $@ +dmioem.o : dmioem.c types.h dmidecode.h dmioem.h + $(CC) $(CFLAGS) -c $< -o $@ + biosdecode.o : biosdecode.c version.h types.h util.h config.h $(CC) $(CFLAGS) -c $< -o $@ diff --git a/dmidecode.c b/dmidecode.c index f8655ea..669755d 100644 --- a/dmidecode.c +++ b/dmidecode.c @@ -2,7 +2,7 @@ * DMI Decode * * (C) 2000-2002 Alan Cox <alan@redhat.com> - * (C) 2002-2005 Jean Delvare <khali@linux-fr.org> + * (C) 2002-2007 Jean Delvare <khali@linux-fr.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,31 +58,16 @@ #include "util.h" #include "dmidecode.h" #include "dmiopt.h" +#include "dmioem.h" static const char *out_of_spec = "<OUT OF SPEC>"; static const char *bad_index = "<BAD INDEX>"; -struct dmi_header -{ - u8 type; - u8 length; - u16 handle; - u8 *data; -}; - -/* - * Globals for vendor-specific decodes - */ - -enum DMI_VENDORS { VENDOR_UNKNOWN, VENDOR_HP }; - -enum DMI_VENDORS dmi_vendor = VENDOR_UNKNOWN; - /* * Type-independant Stuff */ -static const char *dmi_string(struct dmi_header *dm, u8 s) +const char *dmi_string(struct dmi_header *dm, u8 s) { char *bp=(char *)dm->data; size_t i, len; @@ -2839,109 +2824,6 @@ static const char *dmi_power_supply_range_switching(u8 code) } /* - * HP-specific data structures are decoded here. - * - * Code contributed by John Cagle. - */ - -static int dmi_decode_hp(struct dmi_header *h) -{ - u8 *data=h->data; - int nic, ptr; - - switch(h->type) - { - case 204: - /* - * Vendor Specific: HP ProLiant System/Rack Locator - */ - printf("HP ProLiant System/Rack Locator\n"); - printf("\tRack Name: %s\n", dmi_string(h, 1)); - printf("\tEnclosure Name: %s\n", dmi_string(h, 2)); - printf("\tEnclosure Model: %s\n", dmi_string(h, 3)); - printf("\tEnclosure Serial: %s\n", dmi_string(h, 5)); - printf("\tEnclosure Bays: %d\n", data[8]); - printf("\tServer Bay: %s\n", dmi_string(h, 4)); - printf("\tBays Filled: %d\n", data[9]); - break; - - case 209: - /* - * Vendor Specific: HP ProLiant NIC MAC Information - * - * This prints the BIOS NIC number, - * PCI bus/device/function, and MAC address - */ - printf("HP BIOS NIC PCI and MAC Information\n"); - nic=1; - ptr=4; - while(h->length>=(ptr+8)) - { - if(data[ptr]==0x00 && data[ptr+1]==0x00) - printf("\tNIC %d [DISABLED]\n", nic); - else if(data[ptr]==0xFF && data[ptr+1]==0xFF) - printf("\tNIC %d [NOT_INSTALLED]\n", nic); - else - { - printf("\tNIC %d [%02x:%02x.%02x]", - nic, data[ptr+1], data[ptr]>>3, data[ptr]&7); - printf(" %02X:%02X:%02X:%02X:%02X:%02X\n", - data[ptr+2], data[ptr+3], - data[ptr+4], data[ptr+5], - data[ptr+6], data[ptr+7]); - } - nic++; - ptr+=8; - } - break; - - case 221: - /* Vendor Specific: HP ProLiant NIC iSCSI MAC Information - * - * This prints the BIOS NIC iSCSI number, - * PCI bus/device/function, and MAC address - */ - printf("HP BIOS iSCSI NIC PCI and MAC Information\n"); - nic=1; - ptr=4; - while(h->length>=(ptr+8)) - { - if(data[ptr]==0x00 && data[ptr+1]==0x00) - printf("\tNIC %d [DISABLED]\n", nic); - else if(data[ptr]==0xFF && data[ptr+1]==0xFF) - printf("\tNIC %d [NOT_INSTALLED]\n", nic); - else - { - printf("\tNIC %d [%02x:%02x.%02x]", - nic, data[ptr+1], data[ptr]>>3, data[ptr]&7); - printf(" %02X:%02X:%02X:%02X:%02X:%02X\n", - data[ptr+2], data[ptr+3], - data[ptr+4], data[ptr+5], - data[ptr+6], data[ptr+7]); - } - nic++; - ptr+=8; - } - break; - - default: - return 0; - } - return 1; -} - -static int dmi_decode_oem(struct dmi_header *h) -{ - switch(dmi_vendor) - { - case VENDOR_HP: - return dmi_decode_hp(h); - default: - return 0; - } -} - -/* * Main */ @@ -2963,8 +2845,7 @@ static void dmi_decode(struct dmi_header *h, u16 ver) /* * Assign vendor for vendor-specific decodes later */ - if(strcmp(dmi_string(h, data[0x04]), "HP")==0) - dmi_vendor=VENDOR_HP; + dmi_set_vendor(dmi_string(h, data[0x04])); printf("\tVersion: %s\n", dmi_string(h, data[0x05])); diff --git a/dmidecode.h b/dmidecode.h index 2dc0bf2..3a3b77a 100644 --- a/dmidecode.h +++ b/dmidecode.h @@ -1,7 +1,7 @@ /* * This file is part of the dmidecode project. * - * (C) 2005 Jean Delvare <khali@linux-fr.org> + * (C) 2005-2007 Jean Delvare <khali@linux-fr.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +struct dmi_header +{ + u8 type; + u8 length; + u16 handle; + u8 *data; +}; + +const char *dmi_string(struct dmi_header *dm, u8 s); void dmi_system_uuid(u8 *p); const char *dmi_chassis_type(u8 code); const char *dmi_processor_family(u8 code); diff --git a/dmioem.c b/dmioem.c new file mode 100644 index 0000000..f99cd20 --- /dev/null +++ b/dmioem.c @@ -0,0 +1,152 @@ +/* + * Decoding of OEM-specific entries + * This file is part of the dmidecode project. + * + * (C) 2007 Jean Delvare <khali@linux-fr.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdio.h> +#include <string.h> + +#include "types.h" +#include "dmidecode.h" +#include "dmioem.h" + +/* + * Globals for vendor-specific decodes + */ + +enum DMI_VENDORS { VENDOR_UNKNOWN, VENDOR_HP }; + +static enum DMI_VENDORS dmi_vendor=VENDOR_UNKNOWN; + +/* + * Remember the system vendor for later use. We only actually store the + * value if we know how to decode at least one specific entry type for + * that vendor. + */ +void dmi_set_vendor(const char *s) +{ + if(strcmp(s, "HP")==0) + dmi_vendor=VENDOR_HP; +} + +/* + * HP-specific data structures are decoded here. + * + * Code contributed by John Cagle. + */ + +static int dmi_decode_hp(struct dmi_header *h) +{ + u8 *data=h->data; + int nic, ptr; + + switch(h->type) + { + case 204: + /* + * Vendor Specific: HP ProLiant System/Rack Locator + */ + printf("HP ProLiant System/Rack Locator\n"); + printf("\tRack Name: %s\n", dmi_string(h, 1)); + printf("\tEnclosure Name: %s\n", dmi_string(h, 2)); + printf("\tEnclosure Model: %s\n", dmi_string(h, 3)); + printf("\tEnclosure Serial: %s\n", dmi_string(h, 5)); + printf("\tEnclosure Bays: %d\n", data[8]); + printf("\tServer Bay: %s\n", dmi_string(h, 4)); + printf("\tBays Filled: %d\n", data[9]); + break; + + case 209: + /* + * Vendor Specific: HP ProLiant NIC MAC Information + * + * This prints the BIOS NIC number, + * PCI bus/device/function, and MAC address + */ + printf("HP BIOS NIC PCI and MAC Information\n"); + nic=1; + ptr=4; + while(h->length>=ptr+8) + { + if(data[ptr]==0x00 && data[ptr+1]==0x00) + printf("\tNIC %d [DISABLED]\n", nic); + else if(data[ptr]==0xFF && data[ptr+1]==0xFF) + printf("\tNIC %d [NOT_INSTALLED]\n", nic); + else + { + printf("\tNIC %d [%02x:%02x.%02x]", + nic, data[ptr+1], data[ptr]>>3, data[ptr]&7); + printf(" %02X:%02X:%02X:%02X:%02X:%02X\n", + data[ptr+2], data[ptr+3], + data[ptr+4], data[ptr+5], + data[ptr+6], data[ptr+7]); + } + nic++; + ptr+=8; + } + break; + + case 221: + /* Vendor Specific: HP ProLiant NIC iSCSI MAC Information + * + * This prints the BIOS NIC iSCSI number, + * PCI bus/device/function, and MAC address + */ + printf("HP BIOS iSCSI NIC PCI and MAC Information\n"); + nic=1; + ptr=4; + while(h->length>=ptr+8) + { + if(data[ptr]==0x00 && data[ptr+1]==0x00) + printf("\tNIC %d [DISABLED]\n", nic); + else if(data[ptr]==0xFF && data[ptr+1]==0xFF) + printf("\tNIC %d [NOT_INSTALLED]\n", nic); + else + { + printf("\tNIC %d [%02x:%02x.%02x]", + nic, data[ptr+1], data[ptr]>>3, data[ptr]&7); + printf(" %02X:%02X:%02X:%02X:%02X:%02X\n", + data[ptr+2], data[ptr+3], + data[ptr+4], data[ptr+5], + data[ptr+6], data[ptr+7]); + } + nic++; + ptr+=8; + } + break; + + default: + return 0; + } + return 1; +} + +/* + * Dispatch vendor-specific entries decoding + * Return 1 if decoding was successful, 0 otherwise + */ +int dmi_decode_oem(struct dmi_header *h) +{ + switch(dmi_vendor) + { + case VENDOR_HP: + return dmi_decode_hp(h); + } + return 0; +} diff --git a/dmioem.h b/dmioem.h new file mode 100644 index 0000000..00483f2 --- /dev/null +++ b/dmioem.h @@ -0,0 +1,25 @@ +/* + * Decoding of OEM-specific entries + * This file is part of the dmidecode project. + * + * (C) 2007 Jean Delvare <khali@linux-fr.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +struct dmi_header; + +void dmi_set_vendor(const char *s); +int dmi_decode_oem(struct dmi_header *h); |