aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErwan Velu <erwan@seanodes.com>2006-08-14 22:10:33 +0200
committerH. Peter Anvin <hpa@zytor.com>2006-08-14 22:25:26 -0700
commit1442feb3e09f6752a58191b4630a76e3051bca60 (patch)
tree5eb98c7a2012479ac12562998459c427ea14fb46
parent104dd7b80670b7180cd1ea84f5f9832e92bbcf54 (diff)
downloadsyslinux-1442feb3e09f6752a58191b4630a76e3051bca60.tar.gz
syslinux-1442feb3e09f6752a58191b4630a76e3051bca60.tar.xz
syslinux-1442feb3e09f6752a58191b4630a76e3051bca60.zip
Adding a com32 module to handle DMI
From : Erwan Velu <erwan.velu@free.fr> This patch add a new com32 module named dmi. It can parse DMI Hanldes number 0,1,2,3,4. Using a very simple API, you can read the values of the following "Handles" - BIOS - CHASSIS - SYSTEM - BASE_BOARD - PROCESSOR It's possible and easy to extend to many other Handles. A sample code program called dmitest shows how you can use and display this structures. The codes is mainly taken from the Linux Kernel and the smartmontool projects. Both are GPL, my code too. Testing and feedback are welcomed. Signed-off-by:Erwan Velu <erwan.velu@free.fr>
-rw-r--r--com32/include/dmi/dmi.h80
-rw-r--r--com32/include/dmi/dmi_base_board.h57
-rw-r--r--com32/include/dmi/dmi_bios.h148
-rw-r--r--com32/include/dmi/dmi_chassis.h123
-rw-r--r--com32/include/dmi/dmi_processor.h479
-rw-r--r--com32/include/dmi/dmi_system.h36
-rw-r--r--com32/modules/Makefile5
-rw-r--r--com32/modules/dmi.c489
-rw-r--r--com32/modules/dmi_utils.c52
-rw-r--r--com32/modules/dmitest.c146
10 files changed, 1614 insertions, 1 deletions
diff --git a/com32/include/dmi/dmi.h b/com32/include/dmi/dmi.h
new file mode 100644
index 00000000..5e72b82c
--- /dev/null
+++ b/com32/include/dmi/dmi.h
@@ -0,0 +1,80 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2006 Erwan Velu - All Rights Reserved
+ *
+ * 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, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#ifndef DMI_H
+#define DMI_H
+
+#define u32 unsigned int
+#define u16 unsigned short
+#define u8 unsigned char
+#define PAGE_SIZE 4096
+
+typedef struct {
+ u32 l;
+ u32 h;
+} u64;
+
+static const char *out_of_spec = "<OUT OF SPEC>";
+static const char *bad_index = "<BAD INDEX>";
+
+#define WORD(x) (u16)(*(const u16 *)(x))
+#define DWORD(x) (u32)(*(const u32 *)(x))
+#define QWORD(x) (*(const u64 *)(x))
+
+#include "dmi_bios.h"
+#include "dmi_system.h"
+#include "dmi_base_board.h"
+#include "dmi_chassis.h"
+#include "dmi_processor.h"
+
+extern char display_line;
+#define moreprintf(...) do { display_line++; if (display_line == 24) { char tempbuf[10]; display_line=0; printf("Press enter to continue"); fgets(tempbuf, sizeof tempbuf, stdin);} printf ( __VA_ARGS__); } while (0);
+
+typedef struct {
+u16 num;
+u16 len;
+u16 ver;
+u32 base;
+} dmi_table;
+
+static dmi_table dmitable;
+
+
+struct dmi_header
+{
+ u8 type;
+ u8 length;
+ u16 handle;
+ u8 *data;
+};
+
+typedef struct {
+ s_bios bios;
+ s_system system;
+ s_base_board base_board;
+ s_chassis chassis;
+ s_processor processor;
+} s_dmi;
+
+void to_dmi_header(struct dmi_header *h, u8 *data);
+void dmi_bios_runtime_size(u32 code, s_dmi *dmi);
+const char *dmi_string(struct dmi_header *dm, u8 s);
+inline int dmi_checksum(u8 *buf);
+void parse_dmitable(s_dmi *dmi);
+void dmi_decode(struct dmi_header *h, u16 ver, s_dmi *dmi);
+int dmi_interate();
+
+/* 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);
+#endif
diff --git a/com32/include/dmi/dmi_base_board.h b/com32/include/dmi/dmi_base_board.h
new file mode 100644
index 00000000..8de8adc0
--- /dev/null
+++ b/com32/include/dmi/dmi_base_board.h
@@ -0,0 +1,57 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2006 Erwan Velu - All Rights Reserved
+ *
+ * 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, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#ifndef DMI_BASE_BOARD_H
+#define DMI_BASE_BOARD_H
+
+#include "stdbool.h"
+#define BASE_BOARD_MANUFACTURER_SIZE 32
+#define BASE_BOARD_PRODUCT_NAME_SIZE 32
+#define BASE_BOARD_VERSION_SIZE 16
+#define BASE_BOARD_SERIAL_SIZE 32
+#define BASE_BOARD_ASSET_TAG_SIZE 32
+#define BASE_BOARD_LOCATION_SIZE 32
+#define BASE_BOARD_FEATURES_SIZE 32
+#define BASE_BOARD_TYPE_SIZE 32
+
+#define BASE_BOARD_NB_ELEMENTS 5
+
+static const char *base_board_features_strings[]={
+ "Board is a hosting board", /* 0 */
+ "Board requires at least one daughter board",
+ "Board is removable",
+ "Board is replaceable",
+ "Board is hot swappable" /* 4 */
+};
+
+/* 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;
+
+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;
+} s_base_board;
+
+#endif
diff --git a/com32/include/dmi/dmi_bios.h b/com32/include/dmi/dmi_bios.h
new file mode 100644
index 00000000..735647ff
--- /dev/null
+++ b/com32/include/dmi/dmi_bios.h
@@ -0,0 +1,148 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2006 Erwan Velu - All Rights Reserved
+ *
+ * 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, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#ifndef DMI_BIOS_H
+#define DMI_BIOS_H
+
+#include "stdbool.h"
+#define BIOS_VENDOR_SIZE 32
+#define BIOS_VERSION_SIZE 32
+#define BIOS_RELEASE_SIZE 16
+#define BIOS_RUNTIME_SIZE_UNIT_SIZE 16
+#define BIOS_ROM_UNIT_SIZE 16
+#define BIOS_BIOS_REVISION_SIZE 16
+#define BIOS_FIRMWARE_REVISION_SIZE 16
+
+#define BIOS_CHAR_NB_ELEMENTS 27
+#define BIOS_CHAR_X1_NB_ELEMENTS 8
+#define BIOS_CHAR_X2_NB_ELEMENTS 3
+
+static const char *bios_charac_strings[]={
+ "BIOS characteristics not supported", /* 3 */
+ "ISA is supported",
+ "MCA is supported",
+ "EISA is supported",
+ "PCI is supported",
+ "PC Card (PCMCIA) is supported",
+ "PNP is supported",
+ "APM is supported",
+ "BIOS is upgradeable",
+ "BIOS shadowing is allowed",
+ "VLB is supported",
+ "ESCD support is available",
+ "Boot from CD is supported",
+ "Selectable boot is supported",
+ "BIOS ROM is socketed",
+ "Boot from PC Card (PCMCIA) is supported",
+ "EDD is supported",
+ "Japanese floppy for NEC 9800 1.2 MB is supported (int 13h)",
+ "Japanese floppy for Toshiba 1.2 MB is supported (int 13h)",
+ "5.25\"/360 KB floppy services are supported (int 13h)",
+ "5.25\"/1.2 MB floppy services are supported (int 13h)",
+ "3.5\"/720 KB floppy services are supported (int 13h)",
+ "3.5\"/2.88 MB floppy services are supported (int 13h)",
+ "Print screen service is supported (int 5h)",
+ "8042 keyboard services are supported (int 9h)",
+ "Serial services are supported (int 14h)",
+ "Printer services are supported (int 17h)",
+ "CGA/mono video services are supported (int 10h)",
+ "NEC PC-98" /* 31 */
+};
+
+/* this struct have BIOS_CHAR_NB_ELEMENTS */
+/* each bool is associated to the relevant message above */
+typedef struct {
+bool bios_characteristics_not_supported;
+bool isa;
+bool mca;
+bool eisa;
+bool pci;
+bool pc_card;
+bool pnp;
+bool apm;
+bool bios_upgreadable;
+bool bios_shadowing;
+bool vlb;
+bool escd;
+bool boot_from_cd;
+bool selectable_boot;
+bool bios_rom_socketed;
+bool edd;
+bool japanese_floppy_nec_9800_1_2MB;
+bool japanese_floppy_toshiba_1_2MB;
+bool floppy_5_25_360KB;
+bool floppy_5_25_1_2MB;
+bool floppy_3_5_720KB;
+bool floppy_3_5_2_88MB;
+bool print_screen;
+bool keyboard_8042_support;
+bool serial_support;
+bool printer_support;
+bool cga_mono_support;
+bool nec_pc_98;
+} __attribute__((__packed__)) s_characteristics;
+
+static const char *bios_charac_x1_strings[]={
+ "ACPI is supported", /* 0 */
+ "USB legacy is supported",
+ "AGP is supported",
+ "I2O boot is supported",
+ "LS-120 boot is supported",
+ "ATAPI Zip drive boot is supported",
+ "IEEE 1394 boot is supported",
+ "Smart battery is supported" /* 7 */
+};
+
+/* this struct have BIOS_CHAR_X1_NB_ELEMENTS */
+/* each bool is associated to the relevant message above */
+typedef struct {
+bool acpi;
+bool usb_legacy;
+bool agp;
+bool i2o_boot;
+bool ls_120_boot;
+bool zip_drive_boot;
+bool ieee_1394_boot;
+bool smart_battery;
+} __attribute__((__packed__)) s_characteristics_x1;
+
+static const char *bios_charac_x2_strings[]={
+ "BIOS boot specification is supported", /* 0 */
+ "Function key-initiated network boot is supported",
+ "Targeted content distribution is supported" /* 2 */
+};
+
+/* this struct have BIOS_CHAR_X2_NB_ELEMENTS */
+/* each bool is associated to the relevant message above */
+typedef struct {
+bool bios_boot_specification;
+bool bios_network_boot_by_keypress;
+bool target_content_distribution;
+} __attribute__((__packed__)) s_characteristics_x2;
+
+typedef struct {
+char vendor[BIOS_VENDOR_SIZE];
+char version[BIOS_VERSION_SIZE];
+char release_date[BIOS_RELEASE_SIZE];
+u16 address;
+u16 runtime_size;
+char runtime_size_unit[BIOS_RUNTIME_SIZE_UNIT_SIZE];
+u16 rom_size;
+char rom_size_unit[BIOS_ROM_UNIT_SIZE];
+s_characteristics characteristics;
+s_characteristics_x1 characteristics_x1;
+s_characteristics_x2 characteristics_x2;
+char bios_revision [BIOS_BIOS_REVISION_SIZE];
+char firmware_revision [BIOS_FIRMWARE_REVISION_SIZE];
+} s_bios;
+
+#endif
diff --git a/com32/include/dmi/dmi_chassis.h b/com32/include/dmi/dmi_chassis.h
new file mode 100644
index 00000000..933b80b9
--- /dev/null
+++ b/com32/include/dmi/dmi_chassis.h
@@ -0,0 +1,123 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2006 Erwan Velu - All Rights Reserved
+ *
+ * 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, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#ifndef DMI_CHASSIS_H
+#define DMI_CHASSIS_H
+
+#define CHASSIS_MANUFACTURER_SIZE 32
+#define CHASSIS_TYPE_SIZE 16
+#define CHASSIS_LOCK_SIZE 16
+#define CHASSIS_VERSION_SIZE 16
+#define CHASSIS_SERIAL_SIZE 32
+#define CHASSIS_ASSET_TAG_SIZE 32
+#define CHASSIS_BOOT_UP_STATE_SIZE 32
+#define CHASSIS_POWER_SUPPLY_STATE_SIZE 32
+#define CHASSIS_THERMAL_STATE_SIZE 32
+#define CHASSIS_SECURITY_STATUS_SIZE 32
+#define CHASSIS_OEM_INFORMATION_SIZE 32
+
+typedef struct {
+char manufacturer[CHASSIS_MANUFACTURER_SIZE];
+char type[CHASSIS_TYPE_SIZE];
+char lock[CHASSIS_LOCK_SIZE];
+char version[CHASSIS_VERSION_SIZE];
+char serial[CHASSIS_SERIAL_SIZE];
+char asset_tag[CHASSIS_ASSET_TAG_SIZE];
+char boot_up_state[CHASSIS_BOOT_UP_STATE_SIZE];
+char power_supply_state[CHASSIS_POWER_SUPPLY_STATE_SIZE];
+char thermal_state[CHASSIS_THERMAL_STATE_SIZE];
+char security_status[CHASSIS_SECURITY_STATUS_SIZE];
+char oem_information[CHASSIS_OEM_INFORMATION_SIZE];
+u16 height;
+u16 nb_power_cords;
+} s_chassis;
+
+static const char *dmi_chassis_type(u8 code)
+{
+ /* 3.3.4.1 */
+ static const char *type[]={
+ "Other", /* 0x01 */
+ "Unknown",
+ "Desktop",
+ "Low Profile Desktop",
+ "Pizza Box",
+ "Mini Tower",
+ "Tower",
+ "Portable",
+ "Laptop",
+ "Notebook",
+ "Hand Held",
+ "Docking Station",
+ "All In One",
+ "Sub Notebook",
+ "Space-saving",
+ "Lunch Box",
+ "Main Server Chassis", /* master.mif says System */
+ "Expansion Chassis",
+ "Sub Chassis",
+ "Bus Expansion Chassis",
+ "Peripheral Chassis",
+ "RAID Chassis",
+ "Rack Mount Chassis",
+ "Sealed-case PC",
+ "Multi-system" /* 0x19 */
+ };
+
+ if(code>=0x01 && code<=0x19)
+ return type[code-0x01];
+ return out_of_spec;
+}
+
+static const char *dmi_chassis_lock(u8 code)
+{
+ static const char *lock[]={
+ "Not Present", /* 0x00 */
+ "Present" /* 0x01 */
+ };
+
+ return lock[code];
+}
+
+static const char *dmi_chassis_state(u8 code)
+{
+ /* 3.3.4.2 */
+ static const char *state[]={
+ "Other", /* 0x01 */
+ "Unknown",
+ "Safe", /* master.mif says OK */
+ "Warning",
+ "Critical",
+ "Non-recoverable" /* 0x06 */
+ };
+
+ if(code>=0x01 && code<=0x06)
+ return(state[code-0x01]);
+ return out_of_spec;
+}
+
+static const char *dmi_chassis_security_status(u8 code)
+{
+ /* 3.3.4.3 */
+ static const char *status[]={
+ "Other", /* 0x01 */
+ "Unknown",
+ "None",
+ "External Interface Locked Out",
+ "External Interface Enabled" /* 0x05 */
+ };
+
+ if(code>=0x01 && code<=0x05)
+ return(status[code-0x01]);
+ return out_of_spec;
+}
+
+#endif
diff --git a/com32/include/dmi/dmi_processor.h b/com32/include/dmi/dmi_processor.h
new file mode 100644
index 00000000..4473d935
--- /dev/null
+++ b/com32/include/dmi/dmi_processor.h
@@ -0,0 +1,479 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2006 Erwan Velu - All Rights Reserved
+ *
+ * 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, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#ifndef DMI_PROCESSOR_H
+#define DMI_PROCESSOR_H
+
+#include "stdbool.h"
+#define PROCESSOR_SOCKET_DESIGNATION_SIZE 32
+#define PROCESSOR_TYPE_SIZE 32
+#define PROCESSOR_FAMILY_SIZE 32
+#define PROCESSOR_MANUFACTURER_SIZE 64
+#define PROCESSOR_VERSION_SIZE 32
+#define PROCESSOR_VOLTAGE_SIZE 16
+#define PROCESSOR_STATUS_SIZE 16
+#define PROCESSOR_UPGRADE_SIZE 16
+#define PROCESSOR_CACHE_SIZE 16
+#define PROCESSOR_SERIAL_SIZE 32
+#define PROCESSOR_ASSET_TAG_SIZE 32
+#define PROCESSOR_PART_NUMBER_SIZE 32
+#define PROCESSOR_ID_SIZE 32
+
+#define PROCESSOR_FLAGS_ELEMENTS 32
+/* Intel AP-485 revision 28, table 5 */
+static const char *cpu_flags_strings[32]={
+ "FPU (Floating-point unit on-chip)", /* 0 */
+ "VME (Virtual mode extension)",
+ "DE (Debugging extension)",
+ "PSE (Page size extension)",
+ "TSC (Time stamp counter)",
+ "MSR (Model specific registers)",
+ "PAE (Physical address extension)",
+ "MCE (Machine check exception)",
+ "CX8 (CMPXCHG8 instruction supported)",
+ "APIC (On-chip APIC hardware supported)",
+ NULL, /* 10 */
+ "SEP (Fast system call)",
+ "MTRR (Memory type range registers)",
+ "PGE (Page global enable)",
+ "MCA (Machine check architecture)",
+ "CMOV (Conditional move instruction supported)",
+ "PAT (Page attribute table)",
+ "PSE-36 (36-bit page size extension)",
+ "PSN (Processor serial number present and enabled)",
+ "CLFSH (CLFLUSH instruction supported)",
+ NULL, /* 20 */
+ "DS (Debug store)",
+ "ACPI (ACPI supported)",
+ "MMX (MMX technology supported)",
+ "FXSR (Fast floating-point save and restore)",
+ "SSE (Streaming SIMD extensions)",
+ "SSE2 (Streaming SIMD extensions 2)",
+ "SS (Self-snoop)",
+ "HTT (Hyper-threading technology)",
+ "TM (Thermal monitor supported)",
+ NULL, /* 30 */
+ "PBE (Pending break enabled)" /* 31 */
+};
+
+/* this struct have PROCESSOR_FLAGS_ELEMENTS */
+/* each bool is associated to the relevant message above */
+typedef struct {
+bool fpu;
+bool vme;
+bool de;
+bool pse;
+bool tsc;
+bool msr;
+bool pae;
+bool mce;
+bool cx8;
+bool apic;
+bool sep;
+bool mtrr;
+bool pge;
+bool mca;
+bool cmov;
+bool pat;
+bool pse_36;
+bool psn;
+bool clfsh;
+bool ds;
+bool acpi;
+bool mmx;
+bool fxsr;
+bool sse;
+bool sse2;
+bool ss;
+bool htt;
+bool tm;
+bool pbe;
+} __attribute__((__packed__)) s_cpu_flags;
+
+typedef struct {
+u8 type;
+u8 family;
+u8 model;
+u8 stepping;
+u8 minor_stepping;
+} __attribute__((__packed__)) s_signature;
+
+typedef struct {
+char socket_designation[PROCESSOR_SOCKET_DESIGNATION_SIZE];
+char type[PROCESSOR_TYPE_SIZE];
+char family[PROCESSOR_FAMILY_SIZE];
+char manufacturer[PROCESSOR_MANUFACTURER_SIZE];
+char version[PROCESSOR_VERSION_SIZE];
+float voltage;
+u16 external_clock;
+u16 max_speed;
+u16 current_speed;
+char status[PROCESSOR_STATUS_SIZE];
+char upgrade[PROCESSOR_UPGRADE_SIZE];
+char cache1[PROCESSOR_CACHE_SIZE];
+char cache2[PROCESSOR_CACHE_SIZE];
+char cache3[PROCESSOR_CACHE_SIZE];
+char serial[PROCESSOR_SERIAL_SIZE];
+char asset_tag[PROCESSOR_ASSET_TAG_SIZE];
+char part_number[PROCESSOR_PART_NUMBER_SIZE];
+char id[PROCESSOR_ID_SIZE];
+s_cpu_flags cpu_flags;
+s_signature signature;
+} s_processor;
+
+static const char *dmi_processor_type(u8 code)
+{
+ /* 3.3.5.1 */
+ static const char *type[]={
+ "Other", /* 0x01 */
+ "Unknown",
+ "Central Processor",
+ "Math Processor",
+ "DSP Processor",
+ "Video Processor" /* 0x06 */
+ };
+
+ if(code>=0x01 && code<=0x06)
+ return type[code-0x01];
+ return out_of_spec;
+}
+
+static const char *dmi_processor_family(u8 code)
+{
+ /* 3.3.5.2 */
+ static const char *family[]={
+ NULL, /* 0x00 */
+ "Other",
+ "Unknown",
+ "8086",
+ "80286",
+ "80386",
+ "80486",
+ "8087",
+ "80287",
+ "80387",
+ "80487",
+ "Pentium",
+ "Pentium Pro",
+ "Pentium II",
+ "Pentium MMX",
+ "Celeron",
+ "Pentium II Xeon",
+ "Pentium III",
+ "M1",
+ "M2",
+ NULL, /* 0x14 */
+ NULL,
+ NULL,
+ NULL, /* 0x17 */
+ "Duron",
+ "K5",
+ "K6",
+ "K6-2",
+ "K6-3",
+ "Athlon",
+ "AMD2900",
+ "K6-2+",
+ "Power PC",
+ "Power PC 601",
+ "Power PC 603",
+ "Power PC 603+",
+ "Power PC 604",
+ "Power PC 620",
+ "Power PC x704",
+ "Power PC 750",
+ NULL, /* 0x28 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,/* 0x2F */
+ "Alpha",
+ "Alpha 21064",
+ "Alpha 21066",
+ "Alpha 21164",
+ "Alpha 21164PC",
+ "Alpha 21164a",
+ "Alpha 21264",
+ "Alpha 21364",
+ NULL, /* 0x38 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /* 0x3F */
+ "MIPS",
+ "MIPS R4000",
+ "MIPS R4200",
+ "MIPS R4400",
+ "MIPS R4600",
+ "MIPS R10000",
+ NULL, /* 0x46 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /* 0x4F */
+ "SPARC",
+ "SuperSPARC",
+ "MicroSPARC II",
+ "MicroSPARC IIep",
+ "UltraSPARC",
+ "UltraSPARC II",
+ "UltraSPARC IIi",
+ "UltraSPARC III",
+ "UltraSPARC IIIi",
+ NULL, /* 0x59 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /* 0x5F */
+ "68040",
+ "68xxx",
+ "68000",
+ "68010",
+ "68020",
+ "68030",
+ NULL, /* 0x66 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /* 0x6F */
+ "Hobbit",
+ NULL, /* 0x71 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /* 0x77 */
+ "Crusoe TM5000",
+ "Crusoe TM3000",
+ "Efficeon TM8000",
+ NULL, /* 0x7B */
+ NULL,
+ NULL,
+ NULL,
+ NULL, /* 0x7F */
+ "Weitek",
+ NULL, /* 0x81 */
+ "Itanium",
+ "Athlon 64",
+ "Opteron",
+ "Sempron",
+ NULL, /* 0x86 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /* 0x8F */
+ "PA-RISC",
+ "PA-RISC 8500",
+ "PA-RISC 8000",
+ "PA-RISC 7300LC",
+ "PA-RISC 7200",
+ "PA-RISC 7100LC",
+ "PA-RISC 7100",
+ NULL, /* 0x97 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /* 0x9F */
+ "V30",
+ NULL, /* 0xA1 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /* 0xAF */
+ "Pentium III Xeon",
+ "Pentium III Speedstep",
+ "Pentium 4",
+ "Xeon",
+ "AS400",
+ "Xeon MP",
+ "Athlon XP",
+ "Athlon MP",
+ "Itanium 2",
+ "Pentium M",
+ NULL, /* 0xBA */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /* 0xC7 */
+ "IBM390",
+ "G4",
+ "G5",
+ NULL, /* 0xCB */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL, /* 0xF9 */
+ "i860",
+ "i960",
+ NULL, /* 0xFC */
+ NULL,
+ NULL,
+ NULL /* 0xFF */
+ /* master.mif has values beyond that, but they can't be used for DMI */
+ };
+
+ if(family[code]!=NULL) {
+ return family[code];
+ }
+ return out_of_spec;
+}
+
+static const char *dmi_processor_status(u8 code)
+{
+ static const char *status[]={
+ "Unknown", /* 0x00 */
+ "Enabled",
+ "Disabled By User",
+ "Disabled By BIOS",
+ "Idle", /* 0x04 */
+ "Other" /* 0x07 */
+ };
+
+ if(code<=0x04)
+ return status[code];
+ if(code==0x07)
+ return status[0x05];
+ return out_of_spec;
+}
+static const char *dmi_processor_upgrade(u8 code)
+{
+ /* 3.3.5.5 */
+ static const char *upgrade[]={
+ "Other", /* 0x01 */
+ "Unknown",
+ "Daughter Board",
+ "ZIF Socket",
+ "Replaceable Piggy Back",
+ "None",
+ "LIF Socket",
+ "Slot 1",
+ "Slot 2",
+ "370-pin Socket",
+ "Slot A",
+ "Slot M",
+ "Socket 423",
+ "Socket A (Socket 462)",
+ "Socket 478",
+ "Socket 754",
+ "Socket 940",
+ "Socket 939" /* 0x12 */
+ };
+
+ if(code>=0x01 && code<=0x11)
+ return upgrade[code-0x01];
+ return out_of_spec;
+}
+
+static void dmi_processor_cache(u16 code, const char *level, u16 ver, char *cache)
+{
+ if(code==0xFFFF)
+ {
+ if(ver>=0x0203)
+ sprintf(cache,"Not Provided");
+ else
+ sprintf(cache,"No %s Cache", level);
+ }
+ else
+ sprintf(cache,"0x%04X", code);
+}
+
+
+#endif
diff --git a/com32/include/dmi/dmi_system.h b/com32/include/dmi/dmi_system.h
new file mode 100644
index 00000000..02f2382c
--- /dev/null
+++ b/com32/include/dmi/dmi_system.h
@@ -0,0 +1,36 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2006 Erwan Velu - All Rights Reserved
+ *
+ * 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, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#ifndef DMI_SYSTEM_H
+#define DMI_SYSTEM_H
+
+#define SYSTEM_MANUFACTURER_SIZE 32
+#define SYSTEM_PRODUCT_NAME_SIZE 32
+#define SYSTEM_VERSION_SIZE 16
+#define SYSTEM_SERIAL_SIZE 32
+#define SYSTEM_UUID_SIZE 40
+#define SYSTEM_WAKEUP_TYPE_SIZE 32
+#define SYSTEM_SKU_NUMBER_SIZE 32
+#define SYSTEM_FAMILY_SIZE 32
+
+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];
+} s_system;
+
+#endif
diff --git a/com32/modules/Makefile b/com32/modules/Makefile
index e9736d78..b8984638 100644
--- a/com32/modules/Makefile
+++ b/com32/modules/Makefile
@@ -45,7 +45,7 @@ AUXDIR = $(LIBDIR)/syslinux
INCDIR = /usr/include
COM32DIR = $(AUXDIR)/com32
-MODULES = chain.c32 menu.c32 ethersel.c32 mboot.c32
+MODULES = chain.c32 menu.c32 ethersel.c32 mboot.c32 dmitest.c32
TESTFILES = menu.lnx
all: $(MODULES) $(TESTFILES)
@@ -77,6 +77,9 @@ all: $(MODULES) $(TESTFILES)
%.c32: %.elf
$(OBJCOPY) -O binary $< $@
+dmitest.elf : dmitest.o dmi_utils.o dmi.o $(LIBS)
+ $(LD) $(LDFLAGS) -o $@ $^
+
menu.elf : menu.o readconfig.o $(LIBS)
$(LD) $(LDFLAGS) -o $@ $^
diff --git a/com32/modules/dmi.c b/com32/modules/dmi.c
new file mode 100644
index 00000000..73b96d16
--- /dev/null
+++ b/com32/modules/dmi.c
@@ -0,0 +1,489 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2006 Erwan Velu - All Rights Reserved
+ *
+ * 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, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include <stdio.h>
+#include <string.h>
+#include "dmi/dmi.h"
+
+
+
+void to_dmi_header(struct dmi_header *h, u8 *data)
+{
+ h->type=data[0];
+ h->length=data[1];
+ h->handle=WORD(data+2);
+ h->data=data;
+}
+
+void dmi_system_uuid(u8 *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]);
+}
+
+static void dmi_base_board_features(u8 code, s_dmi *dmi)
+{
+ if((code&0x1F)!=0)
+ {
+ int i;
+
+ printf("\n");
+ for(i=0; i<=4; i++)
+ if(code&(1<<i))
+ ((bool *)(& dmi->base_board.features))[i]=true;
+ }
+}
+
+static void dmi_processor_voltage(u8 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];
+ }
+}
+
+static void dmi_processor_id(u8 type, u8 *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.
+ */
+ u32 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 */
+ {
+ u16 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 */
+ {
+ u16 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 dmi_system_wake_up_type(u8 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;
+}
+
+void dmi_bios_runtime_size(u32 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");
+
+ }
+}
+
+void dmi_bios_characteristics(u64 code, s_dmi *dmi)
+{
+ int i;
+ /*
+ * This isn't very clear what this bit is supposed to mean
+ */
+ if(code.l&(1<<3))
+ {
+ ((bool *)(& dmi->bios.characteristics))[0]=true;
+ return;
+ }
+
+ for(i=4; i<=31; i++)
+ if(code.l&(1<<i))
+ ((bool *)(& dmi->bios.characteristics))[i-3]=true;
+}
+
+void dmi_bios_characteristics_x1(u8 code, s_dmi *dmi)
+{
+ int i;
+
+ for(i=0; i<=7; i++)
+ if(code&(1<<i))
+ ((bool *)(& dmi->bios.characteristics_x1))[i]=true;
+}
+
+void dmi_bios_characteristics_x2(u8 code, s_dmi *dmi)
+{
+ int i;
+
+ for(i=0; i<=2; i++)
+ if(code&(1<<i))
+ ((bool *)(& dmi->bios.characteristics_x2))[i]=true;
+}
+
+const char *dmi_string(struct dmi_header *dm, u8 s)
+{
+ char *bp=(char *)dm->data;
+ size_t i, len;
+
+ if(s==0)
+ return "Not Specified";
+
+ bp+=dm->length;
+ while(s>1 && *bp)
+ {
+ bp+=strlen(bp);
+ bp++;
+ s--;
+ }
+
+ if(!*bp)
+ return bad_index;
+
+ /* ASCII filtering */
+ len=strlen(bp);
+ for(i=0; i<len; i++)
+ if(bp[i]<32 || bp[i]==127)
+ bp[i]='.';
+
+ return bp;
+}
+
+inline int dmi_checksum(u8 *buf)
+{
+ u8 sum=0;
+ int a;
+
+ for(a=0; a<15; a++)
+ sum+=buf[a];
+ return (sum==0);
+}
+
+int dmi_interate() {
+ u8 buf[16];
+ char *p,*q;
+ p=(char *)0xF0000; /* The start address to look at the dmi table */
+ for (q = p; q < p + 0x10000; q += 16) {
+ memcpy(buf, q, 15);
+ if(memcmp(buf, "_DMI_", 5)==0 && dmi_checksum(buf)) {
+ dmitable.num = buf[13]<<8|buf[12];
+ dmitable.len = buf[7]<<8|buf[6];
+ dmitable.base = buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8];
+ dmitable.ver = (buf[0x06]<<8)+buf[0x07];
+
+ /*
+ * DMI version 0.0 means that the real version is taken from
+ * the SMBIOS version, which we don't know at this point.
+ */
+ if(buf[14]!=0)
+ printf("DMI %d.%d present.\n",buf[14]>>4, buf[14]&0x0F);
+ else
+ printf("DMI present.\n");
+ printf("%d structures occupying %d bytes.\n",dmitable.num, dmitable.len);
+ printf("DMI table at 0x%08X.\n",dmitable.base);
+ return 1;
+ }
+ }
+ dmitable.base=0;
+ dmitable.num=0;
+ dmitable.ver=0;
+ dmitable.len=0;
+ return 0;
+}
+
+void dmi_decode(struct dmi_header *h, u16 ver, s_dmi *dmi)
+{
+ u8 *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;
+ 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;
+ 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;
+ 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(u16)) break;
+ break;
+ case 3: /* 3.3.4 Chassis Information */
+// printf("Chassis Information\n");
+ if(h->length<0x09) break;
+ 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 */
+// printf("Processor Information\n");
+ if(h->length<0x1A) break;
+ strcpy(dmi->processor.socket_designation,dmi_string(h, data[0x04]));
+ strcpy(dmi->processor.type,dmi_processor_type(data[0x05]));
+ strcpy(dmi->processor.family,dmi_processor_family(data[0x06]));
+ strcpy(dmi->processor.manufacturer,dmi_string(h, data[0x07]));
+ 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;
+ }
+}
+
+void parse_dmitable(s_dmi *dmi) {
+ int i=0;
+ u8 *data = NULL;
+ u8 buf[dmitable.len];
+
+ memcpy(buf,(int *)dmitable.base,sizeof(u8) * dmitable.len);
+ data=buf;
+ while(i<dmitable.num && data+4<=buf+dmitable.len) /* 4 is the length of an SMBIOS structure header */ {
+ u8 *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<dmitable.len && (next[0]!=0 || next[1]!=0))
+ next++;
+ next+=2;
+ if(next-buf<=dmitable.len)
+ {
+ dmi_decode(&h, dmitable.ver,dmi);
+ }
+ else
+ printf("\t<TRUNCATED>\n");
+ printf("\n");
+ data=next;
+ i++;
+ }
+}
+
diff --git a/com32/modules/dmi_utils.c b/com32/modules/dmi_utils.c
new file mode 100644
index 00000000..8d5da780
--- /dev/null
+++ b/com32/modules/dmi_utils.c
@@ -0,0 +1,52 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2006 Erwan Velu - All Rights Reserved
+ *
+ * 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, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+#include "stdio.h"
+#include "dmi/dmi.h"
+
+void display_bios_characteristics(s_dmi *dmi) {
+int i;
+ for (i=0;i<=BIOS_CHAR_NB_ELEMENTS; i++) {
+ if (((bool *)(& dmi->bios.characteristics))[i] == true) {
+ moreprintf("\t\t%s\n", bios_charac_strings[i]);
+ }
+ }
+ for (i=0;i<=BIOS_CHAR_X1_NB_ELEMENTS; i++) {
+ if (((bool *)(& dmi->bios.characteristics_x1))[i] == true) {
+ moreprintf("\t\t%s\n", bios_charac_x1_strings[i]);
+ }
+ }
+
+ for (i=0;i<=BIOS_CHAR_X2_NB_ELEMENTS; i++) {
+ if (((bool *)(& dmi->bios.characteristics_x2))[i] == true) {
+ moreprintf("\t\t%s\n", bios_charac_x2_strings[i]);
+ }
+ }
+}
+
+void display_base_board_features(s_dmi *dmi) {
+int i;
+ for (i=0;i<=BASE_BOARD_NB_ELEMENTS; i++) {
+ if (((bool *)(& dmi->base_board.features))[i] == true) {
+ moreprintf("\t\t%s\n", base_board_features_strings[i]);
+ }
+ }
+}
+
+void display_processor_flags(s_dmi *dmi) {
+int i;
+ for (i=0;i<=PROCESSOR_FLAGS_ELEMENTS; i++) {
+ if (((bool *)(& dmi->processor.cpu_flags))[i] == true) {
+ moreprintf("\t\t%s\n", cpu_flags_strings[i]);
+ }
+ }
+}
diff --git a/com32/modules/dmitest.c b/com32/modules/dmitest.c
new file mode 100644
index 00000000..1ebd92a4
--- /dev/null
+++ b/com32/modules/dmitest.c
@@ -0,0 +1,146 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2006 Erwan Velu - All Rights Reserved
+ *
+ * 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, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * dmitest.c
+ *
+ * DMI demo program using libcom32
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <console.h>
+#include "dmi/dmi.h"
+
+char display_line;
+
+void display_bios(s_dmi *dmi) {
+ moreprintf("BIOS\n");
+ moreprintf("\tVendor: %s\n",dmi->bios.vendor);
+ moreprintf("\tVersion: %s\n",dmi->bios.version);
+ moreprintf("\tRelease: %s\n",dmi->bios.release_date);
+ moreprintf("\tBios Revision %s\n",dmi->bios.bios_revision);
+ moreprintf("\tFirmware Revision %s\n",dmi->bios.firmware_revision);
+ moreprintf("\tAddress: 0x%04X0\n",dmi->bios.address);
+ moreprintf("\tRuntime address: %u %s\n",dmi->bios.runtime_size,dmi->bios.runtime_size_unit);
+ moreprintf("\tRom size: %u %s\n",dmi->bios.rom_size,dmi->bios.rom_size_unit);
+ display_bios_characteristics(dmi);
+}
+
+void display_system(s_dmi *dmi) {
+ moreprintf("\nSystem\n");
+ moreprintf("\tManufacturer %s\n",dmi->system.manufacturer);
+ moreprintf("\tProduct Name %s\n",dmi->system.product_name);
+ moreprintf("\tVersion %s\n",dmi->system.version);
+ moreprintf("\tSerial %s\n",dmi->system.serial);
+ moreprintf("\tUUID %s\n",dmi->system.uuid);
+ moreprintf("\tWakeup Type %s\n",dmi->system.wakeup_type);
+ moreprintf("\tSKU Number %s\n",dmi->system.sku_number);
+ moreprintf("\tFamily %s\n",dmi->system.family);
+}
+
+void display_base_board(s_dmi *dmi) {
+ moreprintf("Base board\n");
+ moreprintf("\tManufacturer %s\n",dmi->base_board.manufacturer);
+ moreprintf("\tProduct Name %s\n",dmi->base_board.product_name);
+ moreprintf("\tVersion %s\n",dmi->base_board.version);
+ moreprintf("\tSerial %s\n",dmi->base_board.serial);
+ moreprintf("\tAsset Tag %s\n",dmi->base_board.asset_tag);
+ moreprintf("\tLocation %s\n",dmi->base_board.location);
+ moreprintf("\tType %s\n",dmi->base_board.type);
+ display_base_board_features(dmi);
+}
+
+void display_chassis(s_dmi *dmi) {
+ moreprintf("\nChassis\n");
+ moreprintf("\tManufacturer %s\n",dmi->chassis.manufacturer);
+ moreprintf("\tType %s\n",dmi->chassis.type);
+ moreprintf("\tLock %s\n",dmi->chassis.lock);
+ moreprintf("\tVersion %s\n",dmi->chassis.version);
+ moreprintf("\tSerial %s\n",dmi->chassis.serial);
+ moreprintf("\tAsset Tag %s\n",dmi->chassis.asset_tag);
+ moreprintf("\tBoot up state %s\n",dmi->chassis.boot_up_state);
+ moreprintf("\tPower supply state %s\n",dmi->chassis.power_supply_state);
+ moreprintf("\tThermal state %s\n",dmi->chassis.thermal_state);
+ moreprintf("\tSecurity Status %s\n",dmi->chassis.security_status);
+ moreprintf("\tOEM Information %s\n",dmi->chassis.oem_information);
+ moreprintf("\tHeight %u\n",dmi->chassis.height);
+ moreprintf("\tNB Power Cords %u\n",dmi->chassis.nb_power_cords);
+}
+
+void display_cpu(s_dmi *dmi) {
+ moreprintf("\nCPU\n");
+ moreprintf("\tSocket Designation %s\n",dmi->processor.socket_designation);
+ moreprintf("\tType %s\n",dmi->processor.type);
+ moreprintf("\tFamily %s\n",dmi->processor.family);
+ moreprintf("\tManufacturer %s\n",dmi->processor.manufacturer);
+ moreprintf("\tVersion %s\n",dmi->processor.version);
+ moreprintf("\tExternal Clock %u\n",dmi->processor.external_clock);
+ moreprintf("\tMax Speed %u\n",dmi->processor.max_speed);
+ moreprintf("\tCurrent Speed %u\n",dmi->processor.current_speed);
+ moreprintf("\tCpu Type %u\n",dmi->processor.signature.type);
+ moreprintf("\tCpu Family %u\n",dmi->processor.signature.family);
+ moreprintf("\tCpu Model %u\n",dmi->processor.signature.model);
+ moreprintf("\tCpu Stepping %u\n",dmi->processor.signature.stepping);
+ moreprintf("\tCpu Minor Stepping %u\n",dmi->processor.signature.minor_stepping);
+ moreprintf("\tVoltage %f\n",dmi->processor.voltage);
+ moreprintf("\tStatus %s\n",dmi->processor.status);
+ moreprintf("\tUpgrade %s\n",dmi->processor.upgrade);
+ moreprintf("\tCache L1 Handle %s\n",dmi->processor.cache1);
+ moreprintf("\tCache L2 Handle %s\n",dmi->processor.cache2);
+ moreprintf("\tCache L3 Handle %s\n",dmi->processor.cache3);
+ moreprintf("\tSerial %s\n",dmi->processor.serial);
+ moreprintf("\tPart Number %s\n",dmi->processor.part_number);
+ moreprintf("\tID %s\n",dmi->processor.id);
+ display_processor_flags(dmi);
+}
+
+int main(void)
+{
+ char buffer[1024];
+ s_dmi dmi;
+ openconsole(&dev_stdcon_r, &dev_stdcon_w);
+
+ if ( ! dmi_interate() ) {
+ printf("No DMI Structure found\n");
+ return -1;
+ }
+
+ parse_dmitable(&dmi);
+
+ for (;;) {
+ printf("Available commands are system, chassis, base_board, cpu, bios, all, exit\n");
+ printf("dmi: ");
+ fgets(buffer, sizeof buffer, stdin);
+ if ( !strncmp(buffer, "exit", 4) )
+ break;
+ if ( !strncmp(buffer, "system", 6) )
+ display_system(&dmi);
+ if ( !strncmp(buffer, "chassis", 6) )
+ display_chassis(&dmi);
+ if ( !strncmp(buffer, "base_board", 10) )
+ display_base_board(&dmi);
+ if ( !strncmp(buffer, "cpu", 3) )
+ display_cpu(&dmi);
+ if ( !strncmp(buffer, "bios", 4) )
+ display_bios(&dmi);
+ if ( !strncmp(buffer, "all", 3) ) {
+ display_bios(&dmi);
+ display_system(&dmi);
+ display_chassis(&dmi);
+ display_base_board(&dmi);
+ display_cpu(&dmi);
+ }
+ }
+
+ return 0;
+}