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
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 * -----------------------------------------------------------------------
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);
49 snprintf(buffer
, sizeof buffer
, "CPU Model : %s", hardware
->cpu
.model
);
50 snprintf(statbuffer
, sizeof statbuffer
, "CPU Model: %s",
52 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
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
);
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");
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);
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);
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);
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);
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);
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);
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);
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);
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",
146 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
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);
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
169 for_each_pci_func(pci_device
, hardware
->pci_domain
) {
170 memset(kernel_modules
, 0, sizeof kernel_modules
);
172 i
< pci_device
->dev_info
->linux_kernel_module_count
; i
++) {
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
,
188 pci_device
->dev_info
->vendor_name
,
189 pci_device
->dev_info
->product_name
);
191 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
197 printf("MENU: Summary menu done (%d items)\n", menu
->items_count
);