1 /* ----------------------------------------------------------------------- *
2 *
3 * Copyright 2009 Erwan Velu - All Rights Reserved
4 *
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:
13 *
14 * The above copyright notice and this permission notice shall
15 * be included in all copies or substantial portions of the Software.
16 *
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.
25 *
26 * -----------------------------------------------------------------------
27 */
28
29 #include "hdt-menu.h"
30
31 /* Compute System main menu */
compute_system(struct s_my_menu * menu,s_dmi * dmi)32 void compute_system(struct s_my_menu *menu, s_dmi * dmi)
33 {
34 char buffer[SUBMENULEN + 1];
35 char statbuffer[STATLEN + 1];
36
37 menu->menu = add_menu(" System ", -1);
38 menu->items_count = 0;
39 set_menu_pos(SUBMENU_Y, SUBMENU_X);
40
41 snprintf(buffer, sizeof buffer, "Vendor : %s", dmi->system.manufacturer);
42 snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
43 dmi->system.manufacturer);
44 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
45 menu->items_count++;
46
47 snprintf(buffer, sizeof buffer, "Product : %s", dmi->system.product_name);
48 snprintf(statbuffer, sizeof statbuffer, "Product Name: %s",
49 dmi->system.product_name);
50 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
51 menu->items_count++;
52
53 snprintf(buffer, sizeof buffer, "Version : %s", dmi->system.version);
54 snprintf(statbuffer, sizeof statbuffer, "Version: %s", dmi->system.version);
55 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
56 menu->items_count++;
57
58 snprintf(buffer, sizeof buffer, "Serial : %s", dmi->system.serial);
59 snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s",
60 dmi->system.serial);
61 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
62 menu->items_count++;
63
64 snprintf(buffer, sizeof buffer, "UUID : %s", dmi->system.uuid);
65 snprintf(statbuffer, sizeof statbuffer, "UUID: %s", dmi->system.uuid);
66 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
67 menu->items_count++;
68
69 snprintf(buffer, sizeof buffer, "Wakeup : %s", dmi->system.wakeup_type);
70 snprintf(statbuffer, sizeof statbuffer, "Wakeup Type: %s",
71 dmi->system.wakeup_type);
72 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
73 menu->items_count++;
74
75 snprintf(buffer, sizeof buffer, "SKU Number: %s", dmi->system.sku_number);
76 snprintf(statbuffer, sizeof statbuffer, "SKU Number: %s",
77 dmi->system.sku_number);
78 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
79 menu->items_count++;
80
81 snprintf(buffer, sizeof buffer, "Family : %s", dmi->system.family);
82 snprintf(statbuffer, sizeof statbuffer, "Family: %s", dmi->system.family);
83 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
84 menu->items_count++;
85
86 printf("MENU: System menu done (%d items)\n", menu->items_count);
87 }
88
89 /* Compute Chassis menu */
compute_chassis(struct s_my_menu * menu,s_dmi * dmi)90 void compute_chassis(struct s_my_menu *menu, s_dmi * dmi)
91 {
92 char buffer[SUBMENULEN + 1];
93 char statbuffer[STATLEN + 1];
94 menu->menu = add_menu(" Chassis ", -1);
95 menu->items_count = 0;
96 set_menu_pos(SUBMENU_Y, SUBMENU_X);
97
98 snprintf(buffer, sizeof buffer, "Vendor : %s",
99 dmi->chassis.manufacturer);
100 snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
101 dmi->chassis.manufacturer);
102 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
103 menu->items_count++;
104
105 snprintf(buffer, sizeof buffer, "Type : %s", dmi->chassis.type);
106 snprintf(statbuffer, sizeof statbuffer, "Type: %s", dmi->chassis.type);
107 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
108 menu->items_count++;
109
110 snprintf(buffer, sizeof buffer, "Version : %s", dmi->chassis.version);
111 snprintf(statbuffer, sizeof statbuffer, "Version: %s",
112 dmi->chassis.version);
113 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
114 menu->items_count++;
115
116 snprintf(buffer, sizeof buffer, "Serial : %s", dmi->chassis.serial);
117 snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s",
118 dmi->chassis.serial);
119 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
120 menu->items_count++;
121
122 snprintf(buffer, sizeof buffer, "Asset Tag : %s",
123 del_multi_spaces(dmi->chassis.asset_tag));
124 snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s",
125 del_multi_spaces(dmi->chassis.asset_tag));
126 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
127 menu->items_count++;
128
129 snprintf(buffer, sizeof buffer, "Lock : %s", dmi->chassis.lock);
130 snprintf(statbuffer, sizeof statbuffer, "Lock: %s", dmi->chassis.lock);
131 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
132 menu->items_count++;
133
134 printf("MENU: Chassis menu done (%d items)\n", menu->items_count);
135 }
136
137 /* Compute BIOS menu */
compute_bios(struct s_my_menu * menu,s_dmi * dmi)138 void compute_bios(struct s_my_menu *menu, s_dmi * dmi)
139 {
140 char buffer[SUBMENULEN + 1];
141 char statbuffer[STATLEN + 1];
142
143 menu->menu = add_menu(" BIOS ", -1);
144 menu->items_count = 0;
145 set_menu_pos(SUBMENU_Y, SUBMENU_X);
146
147 snprintf(buffer, sizeof buffer, "Vendor : %s", dmi->bios.vendor);
148 snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", dmi->bios.vendor);
149 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
150 menu->items_count++;
151
152 snprintf(buffer, sizeof buffer, "Version : %s", dmi->bios.version);
153 snprintf(statbuffer, sizeof statbuffer, "Version: %s", dmi->bios.version);
154 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
155 menu->items_count++;
156
157 snprintf(buffer, sizeof buffer, "Release : %s", dmi->bios.release_date);
158 snprintf(statbuffer, sizeof statbuffer, "Release Date: %s",
159 dmi->bios.release_date);
160 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
161 menu->items_count++;
162
163 snprintf(buffer, sizeof buffer, "Bios Rev. : %s", dmi->bios.bios_revision);
164 snprintf(statbuffer, sizeof statbuffer, "Bios Revision: %s",
165 dmi->bios.bios_revision);
166 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
167 menu->items_count++;
168
169 snprintf(buffer, sizeof buffer, "Fw. Rev. : %s",
170 dmi->bios.firmware_revision);
171 snprintf(statbuffer, sizeof statbuffer, "Firmware Revision : %s",
172 dmi->bios.firmware_revision);
173 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
174
175 printf("MENU: BIOS menu done (%d items)\n", menu->items_count);
176 }
177
178 /* Compute Motherboard main menu */
compute_motherboard(struct s_my_menu * menu,s_dmi * dmi)179 void compute_motherboard(struct s_my_menu *menu, s_dmi * dmi)
180 {
181 char buffer[SUBMENULEN + 1];
182 char statbuffer[STATLEN + 1];
183
184 menu->menu = add_menu(" Motherboard ", -1);
185 menu->items_count = 0;
186 set_menu_pos(SUBMENU_Y, SUBMENU_X);
187
188 snprintf(buffer, sizeof buffer, "Vendor : %s",
189 dmi->base_board.manufacturer);
190 snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
191 dmi->base_board.manufacturer);
192 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
193 menu->items_count++;
194
195 snprintf(buffer, sizeof buffer, "Product : %s",
196 dmi->base_board.product_name);
197 snprintf(statbuffer, sizeof statbuffer, "Product Name: %s",
198 dmi->base_board.product_name);
199 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
200 menu->items_count++;
201
202 snprintf(buffer, sizeof buffer, "Version : %s", dmi->base_board.version);
203 snprintf(statbuffer, sizeof statbuffer, "Version: %s",
204 dmi->base_board.version);
205 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
206 menu->items_count++;
207
208 snprintf(buffer, sizeof buffer, "Serial : %s", dmi->base_board.serial);
209 snprintf(statbuffer, sizeof statbuffer, "Serial Number: %s",
210 dmi->base_board.serial);
211 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
212 menu->items_count++;
213
214 snprintf(buffer, sizeof buffer, "Asset Tag : %s",
215 dmi->base_board.asset_tag);
216 snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s",
217 dmi->base_board.asset_tag);
218 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
219 menu->items_count++;
220
221 snprintf(buffer, sizeof buffer, "Location : %s", dmi->base_board.location);
222 snprintf(statbuffer, sizeof statbuffer, "Location: %s",
223 dmi->base_board.location);
224 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
225 menu->items_count++;
226
227 snprintf(buffer, sizeof buffer, "Type : %s", dmi->base_board.type);
228 snprintf(statbuffer, sizeof statbuffer, "Type: %s", dmi->base_board.type);
229 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
230 menu->items_count++;
231
232 printf("MENU: Motherboard menu done (%d items)\n", menu->items_count);
233 }
234
235 /* Compute Main IPMI menu */
compute_ipmi(struct s_my_menu * menu,s_dmi * dmi)236 void compute_ipmi(struct s_my_menu *menu, s_dmi * dmi)
237 {
238 char buffer[SUBMENULEN + 1];
239 char statbuffer[STATLEN + 1];
240 menu->menu = add_menu(" IPMI ", -1);
241 menu->items_count = 0;
242 set_menu_pos(SUBMENU_Y, SUBMENU_X);
243
244 snprintf(buffer, sizeof buffer, "Interface Type : %s",
245 dmi->ipmi.interface_type);
246 snprintf(statbuffer, sizeof statbuffer, "Interface Type: %s",
247 dmi->ipmi.interface_type);
248 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
249 menu->items_count++;
250
251 snprintf(buffer, sizeof buffer, "Spec. Version : %u.%u",
252 dmi->ipmi.major_specification_version,
253 dmi->ipmi.minor_specification_version);
254 snprintf(statbuffer, sizeof statbuffer, "Specification Version: %u.%u",
255 dmi->ipmi.major_specification_version,
256 dmi->ipmi.minor_specification_version);
257 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
258 menu->items_count++;
259
260 snprintf(buffer, sizeof buffer, "I2C Slave @ : 0x%02x",
261 dmi->ipmi.I2C_slave_address);
262 snprintf(statbuffer, sizeof statbuffer, "I2C Slave Address: 0x%02x",
263 dmi->ipmi.I2C_slave_address);
264 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
265 menu->items_count++;
266
267 snprintf(buffer, sizeof buffer, "NV Storage @ : %u",
268 dmi->ipmi.nv_address);
269 snprintf(statbuffer, sizeof statbuffer, "NV Storage Address: %u",
270 dmi->ipmi.nv_address);
271 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
272 menu->items_count++;
273
274 uint32_t high = dmi->ipmi.base_address >> 32;
275 uint32_t low = dmi->ipmi.base_address & 0xFFFF;
276
277 snprintf(buffer, sizeof buffer, "Base Address : %08X%08X",
278 high, (low & ~1));
279 snprintf(statbuffer, sizeof statbuffer, "Base Address : %08X%08X",
280 high, (low & ~1));
281 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
282 menu->items_count++;
283
284 snprintf(buffer, sizeof buffer, "IRQ : %d", dmi->ipmi.irq);
285 snprintf(statbuffer, sizeof statbuffer, "IRQ : %d", dmi->ipmi.irq);
286 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
287 menu->items_count++;
288
289 printf("MENU: IPMI menu done (%d items)\n", menu->items_count);
290 }
291
292 /* Compute Main Battery menu */
compute_battery(struct s_my_menu * menu,s_dmi * dmi)293 void compute_battery(struct s_my_menu *menu, s_dmi * dmi)
294 {
295 char buffer[SUBMENULEN + 1];
296 char statbuffer[STATLEN + 1];
297 menu->menu = add_menu(" Battery ", -1);
298 menu->items_count = 0;
299 set_menu_pos(SUBMENU_Y, SUBMENU_X);
300
301 snprintf(buffer, sizeof buffer, "Vendor : %s",
302 dmi->battery.manufacturer);
303 snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
304 dmi->battery.manufacturer);
305 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
306 menu->items_count++;
307
308 snprintf(buffer, sizeof buffer, "Manufacture Date: %s",
309 dmi->battery.manufacture_date);
310 snprintf(statbuffer, sizeof statbuffer, "Manufacture Date: %s",
311 dmi->battery.manufacture_date);
312 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
313 menu->items_count++;
314
315 snprintf(buffer, sizeof buffer, "Serial : %s",
316 dmi->battery.serial);
317 snprintf(statbuffer, sizeof statbuffer, "Serial: %s", dmi->battery.serial);
318 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
319 menu->items_count++;
320
321 snprintf(buffer, sizeof buffer, "Name : %s", dmi->battery.name);
322 snprintf(statbuffer, sizeof statbuffer, "Name: %s", dmi->battery.name);
323 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
324 menu->items_count++;
325
326 snprintf(buffer, sizeof buffer, "Chemistry : %s",
327 dmi->battery.chemistry);
328 snprintf(statbuffer, sizeof statbuffer, "Chemistry: %s",
329 dmi->battery.chemistry);
330 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
331 menu->items_count++;
332
333 snprintf(buffer, sizeof buffer, "Design Capacity : %s",
334 dmi->battery.design_capacity);
335 snprintf(statbuffer, sizeof statbuffer, "Design Capacity: %s",
336 dmi->battery.design_capacity);
337 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
338 menu->items_count++;
339
340 snprintf(buffer, sizeof buffer, "Design Voltage : %s",
341 dmi->battery.design_voltage);
342 snprintf(statbuffer, sizeof statbuffer, "Design Voltage : %s",
343 dmi->battery.design_voltage);
344 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
345 menu->items_count++;
346
347 snprintf(buffer, sizeof buffer, "SBDS : %s", dmi->battery.sbds);
348 snprintf(statbuffer, sizeof statbuffer, "SBDS: %s", dmi->battery.sbds);
349 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
350 menu->items_count++;
351
352 snprintf(buffer, sizeof buffer, "SBDS Manuf. Date: %s",
353 dmi->battery.sbds_manufacture_date);
354 snprintf(statbuffer, sizeof statbuffer, "SBDS Manufacture Date: %s",
355 dmi->battery.sbds_manufacture_date);
356 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
357 menu->items_count++;
358
359 snprintf(buffer, sizeof buffer, "SBDS Chemistry : %s",
360 dmi->battery.sbds_chemistry);
361 snprintf(statbuffer, sizeof statbuffer, "SBDS Chemistry : %s",
362 dmi->battery.sbds_chemistry);
363 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
364 menu->items_count++;
365
366 snprintf(buffer, sizeof buffer, "Maximum Error : %s",
367 dmi->battery.maximum_error);
368 snprintf(statbuffer, sizeof statbuffer, "Maximum Error (percent) : %s",
369 dmi->battery.maximum_error);
370 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
371 menu->items_count++;
372
373 snprintf(buffer, sizeof buffer, "OEM Info : %s",
374 dmi->battery.oem_info);
375 snprintf(statbuffer, sizeof statbuffer, "OEM Info: %s",
376 dmi->battery.oem_info);
377 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
378 menu->items_count++;
379
380 printf("MENU: Battery menu done (%d items)\n", menu->items_count);
381 }
382