Adding debian version 4.03+dfsg-7.
[syslinux-debian/hramrach.git] / com32 / hdt / hdt-menu-summary.c
blobe9d56caf97ff0c7780e1212eca3c4959796c0d7f
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2009 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 * -----------------------------------------------------------------------
29 #include "hdt-menu.h"
31 /* Computing Summary menu */
32 void compute_summarymenu(struct s_my_menu *menu, struct s_hardware *hardware)
34 char buffer[SUBMENULEN + 1];
35 char statbuffer[STATLEN + 1];
37 menu->menu = add_menu(" Summary ", -1);
38 menu->items_count = 0;
40 set_menu_pos(SUBMENU_Y, SUBMENU_X);
42 snprintf(buffer, sizeof buffer, "CPU Vendor : %s", hardware->cpu.vendor);
43 snprintf(statbuffer, sizeof statbuffer, "CPU Vendor: %s",
44 hardware->cpu.vendor);
45 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
46 menu->items_count++;
48 snprintf(buffer, sizeof buffer, "CPU Model : %s", hardware->cpu.model);
49 snprintf(statbuffer, sizeof statbuffer, "CPU Model: %s",
50 hardware->cpu.model);
51 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
52 menu->items_count++;
54 char features[SUBMENULEN + 1];
55 memset(features, 0, sizeof(features));
56 sprintf(features, "%d cores, %dK L2 Cache", hardware->cpu.num_cores,
57 hardware->cpu.l2_cache_size);
58 if (hardware->cpu.flags.lm)
59 strcat(features, ", 64bit");
60 else
61 strcat(features, ", 32bit");
62 if (hardware->cpu.flags.smp)
63 strcat(features, ", SMP ");
64 if (hardware->cpu.flags.vmx || hardware->cpu.flags.svm)
65 strcat(features, ", HwVIRT ");
66 snprintf(buffer, sizeof buffer, "%s", features);
67 snprintf(statbuffer, sizeof statbuffer, "Features : %s", features);
68 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
69 menu->items_count++;
71 add_item("", "", OPT_SEP, "", 0);
72 if (hardware->is_dmi_valid == true) {
74 snprintf(buffer, sizeof buffer, "System Vendor : %s",
75 hardware->dmi.system.manufacturer);
76 snprintf(statbuffer, sizeof statbuffer, "System Vendor: %s",
77 hardware->dmi.system.manufacturer);
78 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
79 menu->items_count++;
81 snprintf(buffer, sizeof buffer, "System Product: %s",
82 hardware->dmi.system.product_name);
83 snprintf(statbuffer, sizeof statbuffer,
84 "System Product Name: %s", hardware->dmi.system.product_name);
85 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
86 menu->items_count++;
88 snprintf(buffer, sizeof buffer, "System Serial : %s",
89 hardware->dmi.system.serial);
90 snprintf(statbuffer, sizeof statbuffer,
91 "System Serial Number: %s", hardware->dmi.system.serial);
92 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
93 menu->items_count++;
95 add_item("", "", OPT_SEP, "", 0);
97 snprintf(buffer, sizeof buffer, "Bios Version : %s",
98 hardware->dmi.bios.version);
99 snprintf(statbuffer, sizeof statbuffer, "Bios Version: %s",
100 hardware->dmi.bios.version);
101 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
102 menu->items_count++;
104 snprintf(buffer, sizeof buffer, "Bios Release : %s",
105 hardware->dmi.bios.release_date);
106 snprintf(statbuffer, sizeof statbuffer, "Bios Release Date: %s",
107 hardware->dmi.bios.release_date);
108 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
109 menu->items_count++;
112 add_item("", "", OPT_SEP, "", 0);
114 snprintf(buffer, sizeof buffer, "Memory Size : %lu MiB (%lu KiB)",
115 (hardware->detected_memory_size + (1 << 9)) >> 10,
116 hardware->detected_memory_size);
117 snprintf(statbuffer, sizeof statbuffer,
118 "Detected Memory Size: %lu MiB (%lu KiB)",
119 (hardware->detected_memory_size + (1 << 9)) >> 10,
120 hardware->detected_memory_size);
121 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
122 menu->items_count++;
124 add_item("", "", OPT_SEP, "", 0);
126 snprintf(buffer, sizeof buffer, "Nb PCI Devices: %d",
127 hardware->nb_pci_devices);
128 snprintf(statbuffer, sizeof statbuffer, "Number of PCI Devices: %d",
129 hardware->nb_pci_devices);
130 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
131 menu->items_count++;
133 if (hardware->is_pxe_valid == true) {
134 add_item("", "", OPT_SEP, "", 0);
136 struct s_pxe *p = &hardware->pxe;
138 snprintf(buffer, sizeof buffer, "PXE MAC Address: %s", p->mac_addr);
139 snprintf(statbuffer, sizeof statbuffer, "PXE MAC Address: %s",
140 p->mac_addr);
141 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
142 menu->items_count++;
144 snprintf(buffer, sizeof buffer, "PXE IP Address : %d.%d.%d.%d",
145 p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
146 snprintf(statbuffer, sizeof statbuffer,
147 "PXE IP Address: %d.%d.%d.%d", p->ip_addr[0],
148 p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
149 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
150 menu->items_count++;
153 if (hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) {
154 add_item("", "", OPT_SEP, "", 0);
156 bool kmod = false;
157 struct pci_device *pci_device;
158 char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
159 MAX_KERNEL_MODULES_PER_PCI_DEVICE];
162 * For every detected pci device, grab its kernel module to compute
163 * this submenu
165 for_each_pci_func(pci_device, hardware->pci_domain) {
166 memset(kernel_modules, 0, sizeof kernel_modules);
167 for (int i = 0;
168 i < pci_device->dev_info->linux_kernel_module_count; i++) {
169 if (i > 0) {
170 strncat(kernel_modules, " | ", 3);
172 strncat(kernel_modules,
173 pci_device->dev_info->linux_kernel_module[i],
174 LINUX_KERNEL_MODULE_SIZE - 1);
176 /* No need to add unknown kernel modules */
177 if (strlen(kernel_modules) > 0) {
178 snprintf(buffer, sizeof buffer, "%s (%s)",
179 kernel_modules, pci_device->dev_info->class_name);
180 snprintf(statbuffer, sizeof statbuffer,
181 "%04x:%04x %s : %s",
182 pci_device->vendor,
183 pci_device->product,
184 pci_device->dev_info->vendor_name,
185 pci_device->dev_info->product_name);
187 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
188 menu->items_count++;
189 kmod = true;
194 printf("MENU: Summary menu done (%d items)\n", menu->items_count);