syslinux.mk: use $(MAKEDIR) not $(makefiledir)
[syslinux.git] / com32 / hdt / hdt-menu-summary.c
blobad87c299acd825445420f054eb2266a8c6a58269
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 snprintf(buffer, sizeof(buffer), " Summary (%d CPU) ", hardware->physical_cpu_count);
38 menu->menu = add_menu(buffer, -1);
39 menu->items_count = 0;
41 set_menu_pos(SUBMENU_Y, SUBMENU_X);
43 snprintf(buffer, sizeof buffer, "CPU Vendor : %s", hardware->cpu.vendor);
44 snprintf(statbuffer, sizeof statbuffer, "CPU Vendor: %s",
45 hardware->cpu.vendor);
46 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
47 menu->items_count++;
49 snprintf(buffer, sizeof buffer, "CPU Model : %s", hardware->cpu.model);
50 snprintf(statbuffer, sizeof statbuffer, "CPU Model: %s",
51 hardware->cpu.model);
52 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
53 menu->items_count++;
55 char features[SUBMENULEN + 1];
56 memset(features, 0, sizeof(features));
57 if (hardware->dmi.processor.thread_count != 0)
58 sprintf(buffer, ", %d thread", hardware->dmi.processor.thread_count);
59 else
60 buffer[0] = 0x00;
61 sprintf(features, "%d core%s, %dK L2 Cache", hardware->cpu.num_cores,
62 buffer, hardware->cpu.l2_cache_size);
63 if (hardware->cpu.flags.lm)
64 strcat(features, ", 64bit");
65 else
66 strcat(features, ", 32bit");
67 if (hardware->cpu.flags.smp)
68 strcat(features, ", SMP");
69 if (hardware->cpu.flags.vmx || hardware->cpu.flags.svm)
70 strcat(features, ", HwVIRT");
71 snprintf(buffer, sizeof buffer, "%s", features);
72 snprintf(statbuffer, sizeof statbuffer, "Features : %s", features);
73 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
74 menu->items_count++;
76 add_item("", "", OPT_SEP, "", 0);
77 if (hardware->is_dmi_valid == true) {
79 snprintf(buffer, sizeof buffer, "System Vendor : %s",
80 hardware->dmi.system.manufacturer);
81 snprintf(statbuffer, sizeof statbuffer, "System Vendor: %s",
82 hardware->dmi.system.manufacturer);
83 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
84 menu->items_count++;
86 snprintf(buffer, sizeof buffer, "System Product: %s",
87 hardware->dmi.system.product_name);
88 snprintf(statbuffer, sizeof statbuffer,
89 "System Product Name: %s", hardware->dmi.system.product_name);
90 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
91 menu->items_count++;
93 snprintf(buffer, sizeof buffer, "System Serial : %s",
94 hardware->dmi.system.serial);
95 snprintf(statbuffer, sizeof statbuffer,
96 "System Serial Number: %s", hardware->dmi.system.serial);
97 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
98 menu->items_count++;
100 add_item("", "", OPT_SEP, "", 0);
102 snprintf(buffer, sizeof buffer, "Bios Version : %s",
103 hardware->dmi.bios.version);
104 snprintf(statbuffer, sizeof statbuffer, "Bios Version: %s",
105 hardware->dmi.bios.version);
106 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
107 menu->items_count++;
109 snprintf(buffer, sizeof buffer, "Bios Release : %s",
110 hardware->dmi.bios.release_date);
111 snprintf(statbuffer, sizeof statbuffer, "Bios Release Date: %s",
112 hardware->dmi.bios.release_date);
113 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
114 menu->items_count++;
117 add_item("", "", OPT_SEP, "", 0);
119 snprintf(buffer, sizeof buffer, "Memory Size : %lu MiB (%lu KiB)",
120 (hardware->detected_memory_size + (1 << 9)) >> 10,
121 hardware->detected_memory_size);
122 snprintf(statbuffer, sizeof statbuffer,
123 "Detected Memory Size: %lu MiB (%lu KiB)",
124 (hardware->detected_memory_size + (1 << 9)) >> 10,
125 hardware->detected_memory_size);
126 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
127 menu->items_count++;
129 add_item("", "", OPT_SEP, "", 0);
131 snprintf(buffer, sizeof buffer, "Nb PCI Devices: %d",
132 hardware->nb_pci_devices);
133 snprintf(statbuffer, sizeof statbuffer, "Number of PCI Devices: %d",
134 hardware->nb_pci_devices);
135 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
136 menu->items_count++;
138 if (hardware->is_pxe_valid == true) {
139 add_item("", "", OPT_SEP, "", 0);
141 struct s_pxe *p = &hardware->pxe;
143 snprintf(buffer, sizeof buffer, "PXE MAC Address: %s", p->mac_addr);
144 snprintf(statbuffer, sizeof statbuffer, "PXE MAC Address: %s",
145 p->mac_addr);
146 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
147 menu->items_count++;
149 snprintf(buffer, sizeof buffer, "PXE IP Address : %d.%d.%d.%d",
150 p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
151 snprintf(statbuffer, sizeof statbuffer,
152 "PXE IP Address: %d.%d.%d.%d", p->ip_addr[0],
153 p->ip_addr[1], p->ip_addr[2], p->ip_addr[3]);
154 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
155 menu->items_count++;
158 if (hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) {
159 add_item("", "", OPT_SEP, "", 0);
161 struct pci_device *pci_device;
162 char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
163 MAX_KERNEL_MODULES_PER_PCI_DEVICE];
166 * For every detected pci device, grab its kernel module to compute
167 * this submenu
169 for_each_pci_func(pci_device, hardware->pci_domain) {
170 memset(kernel_modules, 0, sizeof kernel_modules);
171 for (int i = 0;
172 i < pci_device->dev_info->linux_kernel_module_count; i++) {
173 if (i > 0) {
174 strncat(kernel_modules, " | ", 3);
176 strncat(kernel_modules,
177 pci_device->dev_info->linux_kernel_module[i],
178 LINUX_KERNEL_MODULE_SIZE - 1);
180 /* No need to add unknown kernel modules */
181 if (strlen(kernel_modules) > 0) {
182 snprintf(buffer, sizeof buffer, "%s (%s)",
183 kernel_modules, pci_device->dev_info->class_name);
184 snprintf(statbuffer, sizeof statbuffer,
185 "%04x:%04x %s : %s",
186 pci_device->vendor,
187 pci_device->product,
188 pci_device->dev_info->vendor_name,
189 pci_device->dev_info->product_name);
191 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
192 menu->items_count++;
197 printf("MENU: Summary menu done (%d items)\n", menu->items_count);