Adding upstream version 6.02~pre8+dfsg.
[syslinux-debian/hramrach.git] / com32 / modules / dmitest.c
blob4ce2eaadd605a5d0df694aa25baa5d27843a1b71
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2006 Erwan Velu - All Rights Reserved
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following
12 * conditions:
14 * The above copyright notice and this permission notice shall
15 * be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
26 * -----------------------------------------------------------------------
30 * dmitest.c
32 * DMI demo program using libcom32
35 #include <string.h>
36 #include <stdio.h>
37 #include <console.h>
38 #include "dmi/dmi.h"
40 char display_line;
42 void display_memory(s_dmi * dmi)
44 int i;
45 for (i = 0; i < dmi->memory_count; i++) {
46 moreprintf("Memory Bank %d\n", i);
47 moreprintf("\tForm Factor : %s\n", dmi->memory[i].form_factor);
48 moreprintf("\tType : %s\n", dmi->memory[i].type);
49 moreprintf("\tType Detail : %s\n", dmi->memory[i].type_detail);
50 moreprintf("\tSpeed : %s\n", dmi->memory[i].speed);
51 moreprintf("\tSize : %s\n", dmi->memory[i].size);
52 moreprintf("\tDevice Set : %s\n", dmi->memory[i].device_set);
53 moreprintf("\tDevice Loc. : %s\n", dmi->memory[i].device_locator);
54 moreprintf("\tBank Locator : %s\n", dmi->memory[i].bank_locator);
55 moreprintf("\tTotal Width : %s\n", dmi->memory[i].total_width);
56 moreprintf("\tData Width : %s\n", dmi->memory[i].data_width);
57 moreprintf("\tError : %s\n", dmi->memory[i].error);
58 moreprintf("\tVendor : %s\n", dmi->memory[i].manufacturer);
59 moreprintf("\tSerial : %s\n", dmi->memory[i].serial);
60 moreprintf("\tAsset Tag : %s\n", dmi->memory[i].asset_tag);
61 moreprintf("\tPart Number : %s\n", dmi->memory[i].part_number);
65 void display_battery(s_dmi * dmi)
67 moreprintf("Battery\n");
68 moreprintf("\tVendor : %s\n", dmi->battery.manufacturer);
69 moreprintf("\tManufacture Date : %s\n", dmi->battery.manufacture_date);
70 moreprintf("\tSerial : %s\n", dmi->battery.serial);
71 moreprintf("\tName : %s\n", dmi->battery.name);
72 moreprintf("\tChemistry : %s\n", dmi->battery.chemistry);
73 moreprintf("\tDesign Capacity : %s\n", dmi->battery.design_capacity);
74 moreprintf("\tDesign Voltage : %s\n", dmi->battery.design_voltage);
75 moreprintf("\tSBDS : %s\n", dmi->battery.sbds);
76 moreprintf("\tSBDS Manufact. Date : %s\n",
77 dmi->battery.sbds_manufacture_date);
78 moreprintf("\tSBDS Chemistry : %s\n", dmi->battery.sbds_chemistry);
79 moreprintf("\tMaximum Error : %s\n", dmi->battery.maximum_error);
80 moreprintf("\tOEM Info : %s\n", dmi->battery.oem_info);
83 void display_bios(s_dmi * dmi)
85 moreprintf("BIOS\n");
86 moreprintf("\tVendor: %s\n", dmi->bios.vendor);
87 moreprintf("\tVersion: %s\n", dmi->bios.version);
88 moreprintf("\tRelease: %s\n", dmi->bios.release_date);
89 moreprintf("\tBios Revision %s\n", dmi->bios.bios_revision);
90 moreprintf("\tFirmware Revision %s\n", dmi->bios.firmware_revision);
91 moreprintf("\tAddress: 0x%04X0\n", dmi->bios.address);
92 moreprintf("\tRuntime address: %u %s\n", dmi->bios.runtime_size,
93 dmi->bios.runtime_size_unit);
94 moreprintf("\tRom size: %u %s\n", dmi->bios.rom_size,
95 dmi->bios.rom_size_unit);
96 display_bios_characteristics(dmi);
99 void display_system(s_dmi * dmi)
101 moreprintf("\nSystem\n");
102 moreprintf("\tManufacturer %s\n", dmi->system.manufacturer);
103 moreprintf("\tProduct Name %s\n", dmi->system.product_name);
104 moreprintf("\tVersion %s\n", dmi->system.version);
105 moreprintf("\tSerial %s\n", dmi->system.serial);
106 moreprintf("\tUUID %s\n", dmi->system.uuid);
107 moreprintf("\tWakeup Type %s\n", dmi->system.wakeup_type);
108 moreprintf("\tSKU Number %s\n", dmi->system.sku_number);
109 moreprintf("\tFamily %s\n", dmi->system.family);
112 void display_base_board(s_dmi * dmi)
114 moreprintf("Base board\n");
115 moreprintf("\tManufacturer %s\n", dmi->base_board.manufacturer);
116 moreprintf("\tProduct Name %s\n", dmi->base_board.product_name);
117 moreprintf("\tVersion %s\n", dmi->base_board.version);
118 moreprintf("\tSerial %s\n", dmi->base_board.serial);
119 moreprintf("\tAsset Tag %s\n", dmi->base_board.asset_tag);
120 moreprintf("\tLocation %s\n", dmi->base_board.location);
121 moreprintf("\tType %s\n", dmi->base_board.type);
122 display_base_board_features(dmi);
125 void display_chassis(s_dmi * dmi)
127 moreprintf("\nChassis\n");
128 moreprintf("\tManufacturer %s\n", dmi->chassis.manufacturer);
129 moreprintf("\tType %s\n", dmi->chassis.type);
130 moreprintf("\tLock %s\n", dmi->chassis.lock);
131 moreprintf("\tVersion %s\n", dmi->chassis.version);
132 moreprintf("\tSerial %s\n", dmi->chassis.serial);
133 moreprintf("\tAsset Tag %s\n", dmi->chassis.asset_tag);
134 moreprintf("\tBoot up state %s\n", dmi->chassis.boot_up_state);
135 moreprintf("\tPower supply state %s\n", dmi->chassis.power_supply_state);
136 moreprintf("\tThermal state %s\n", dmi->chassis.thermal_state);
137 moreprintf("\tSecurity Status %s\n", dmi->chassis.security_status);
138 moreprintf("\tOEM Information %s\n", dmi->chassis.oem_information);
139 moreprintf("\tHeight %u\n", dmi->chassis.height);
140 moreprintf("\tNB Power Cords %u\n", dmi->chassis.nb_power_cords);
143 void display_cpu(s_dmi * dmi)
145 moreprintf("\nCPU\n");
146 moreprintf("\tSocket Designation %s\n", dmi->processor.socket_designation);
147 moreprintf("\tType %s\n", dmi->processor.type);
148 moreprintf("\tFamily %s\n", dmi->processor.family);
149 moreprintf("\tManufacturer %s\n", dmi->processor.manufacturer);
150 moreprintf("\tVersion %s\n", dmi->processor.version);
151 moreprintf("\tExternal Clock %u\n", dmi->processor.external_clock);
152 moreprintf("\tMax Speed %u\n", dmi->processor.max_speed);
153 moreprintf("\tCurrent Speed %u\n", dmi->processor.current_speed);
154 moreprintf("\tCpu Type %u\n", dmi->processor.signature.type);
155 moreprintf("\tCpu Family %u\n", dmi->processor.signature.family);
156 moreprintf("\tCpu Model %u\n", dmi->processor.signature.model);
157 moreprintf("\tCpu Stepping %u\n", dmi->processor.signature.stepping);
158 moreprintf("\tCpu Minor Stepping %u\n",
159 dmi->processor.signature.minor_stepping);
160 moreprintf("\tVoltage %d mV\n", dmi->processor.voltage_mv);
161 moreprintf("\tStatus %s\n", dmi->processor.status);
162 moreprintf("\tUpgrade %s\n", dmi->processor.upgrade);
163 moreprintf("\tCache L1 Handle %s\n", dmi->processor.cache1);
164 moreprintf("\tCache L2 Handle %s\n", dmi->processor.cache2);
165 moreprintf("\tCache L3 Handle %s\n", dmi->processor.cache3);
166 moreprintf("\tSerial %s\n", dmi->processor.serial);
167 moreprintf("\tPart Number %s\n", dmi->processor.part_number);
168 if (dmi->processor.core_count != 0)
169 moreprintf("\tCores Count %d\n", dmi->processor.core_count);
170 if (dmi->processor.core_enabled != 0)
171 moreprintf("\tCores Enabled %d\n", dmi->processor.core_enabled);
172 if (dmi->processor.thread_count != 0)
173 moreprintf("\tThreads Count %d\n", dmi->processor.thread_count);
174 moreprintf("\tID %s\n", dmi->processor.id);
175 display_processor_flags(dmi);
178 int main(void)
180 char buffer[1024];
181 s_dmi dmi;
183 if (dmi_iterate(&dmi) == -ENODMITABLE) {
184 printf("No DMI Structure found\n");
185 return -1;
186 } else {
187 printf("DMI %u.%u present.\n", dmi.dmitable.major_version,
188 dmi.dmitable.minor_version);
189 printf("%d structures occupying %d bytes.\n", dmi.dmitable.num,
190 dmi.dmitable.len);
191 printf("DMI table at 0x%08X.\n", dmi.dmitable.base);
194 parse_dmitable(&dmi);
196 for (;;) {
197 printf
198 ("Available commands are system, chassis, base_board, cpu, bios, memory, battery, all, exit\n");
199 printf("dmi: ");
200 fgets(buffer, sizeof buffer, stdin);
201 if (!strncmp(buffer, "exit", 4))
202 break;
203 if (!strncmp(buffer, "system", 6))
204 display_system(&dmi);
205 if (!strncmp(buffer, "chassis", 6))
206 display_chassis(&dmi);
207 if (!strncmp(buffer, "base_board", 10))
208 display_base_board(&dmi);
209 if (!strncmp(buffer, "cpu", 3))
210 display_cpu(&dmi);
211 if (!strncmp(buffer, "bios", 4))
212 display_bios(&dmi);
213 if (!strncmp(buffer, "memory", 6))
214 display_memory(&dmi);
215 if (!strncmp(buffer, "battery", 7))
216 display_battery(&dmi);
217 if (!strncmp(buffer, "all", 3)) {
218 display_bios(&dmi);
219 display_system(&dmi);
220 display_chassis(&dmi);
221 display_base_board(&dmi);
222 display_cpu(&dmi);
223 display_memory(&dmi);
224 display_battery(&dmi);
228 return 0;