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
[255]={0};
56 if (hardware
->dmi
.processor
.thread_count
!= 0)
57 sprintf(buffer
, ", %d thread", hardware
->dmi
.processor
.thread_count
);
60 sprintf(features
, "%d core%s, %dK L2 Cache", hardware
->cpu
.num_cores
,
61 buffer
, hardware
->cpu
.l2_cache_size
);
62 if (hardware
->cpu
.flags
.lm
)
63 strcat(features
, ", 64bit");
65 strcat(features
, ", 32bit");
66 if (hardware
->cpu
.flags
.smp
)
67 strcat(features
, ", SMP");
68 if (hardware
->cpu
.flags
.vmx
|| hardware
->cpu
.flags
.svm
)
69 strcat(features
, ", HwVIRT");
70 snprintf(buffer
, sizeof buffer
, "%s", features
);
71 snprintf(statbuffer
, sizeof statbuffer
, "Features : %s", features
);
72 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
75 add_item("", "", OPT_SEP
, "", 0);
76 if (hardware
->is_dmi_valid
== true) {
78 snprintf(buffer
, sizeof buffer
, "System Vendor : %s",
79 hardware
->dmi
.system
.manufacturer
);
80 snprintf(statbuffer
, sizeof statbuffer
, "System Vendor: %s",
81 hardware
->dmi
.system
.manufacturer
);
82 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
85 snprintf(buffer
, sizeof buffer
, "System Product: %s",
86 hardware
->dmi
.system
.product_name
);
87 snprintf(statbuffer
, sizeof statbuffer
,
88 "System Product Name: %s", hardware
->dmi
.system
.product_name
);
89 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
92 snprintf(buffer
, sizeof buffer
, "System Serial : %s",
93 hardware
->dmi
.system
.serial
);
94 snprintf(statbuffer
, sizeof statbuffer
,
95 "System Serial Number: %s", hardware
->dmi
.system
.serial
);
96 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
99 add_item("", "", OPT_SEP
, "", 0);
101 snprintf(buffer
, sizeof buffer
, "Bios Version : %s",
102 hardware
->dmi
.bios
.version
);
103 snprintf(statbuffer
, sizeof statbuffer
, "Bios Version: %s",
104 hardware
->dmi
.bios
.version
);
105 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
108 snprintf(buffer
, sizeof buffer
, "Bios Release : %s",
109 hardware
->dmi
.bios
.release_date
);
110 snprintf(statbuffer
, sizeof statbuffer
, "Bios Release Date: %s",
111 hardware
->dmi
.bios
.release_date
);
112 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
116 add_item("", "", OPT_SEP
, "", 0);
118 snprintf(buffer
, sizeof buffer
, "Memory Size : %lu MiB (%lu KiB)",
119 (hardware
->detected_memory_size
+ (1 << 9)) >> 10,
120 hardware
->detected_memory_size
);
121 snprintf(statbuffer
, sizeof statbuffer
,
122 "Detected Memory Size: %lu MiB (%lu KiB)",
123 (hardware
->detected_memory_size
+ (1 << 9)) >> 10,
124 hardware
->detected_memory_size
);
125 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
128 add_item("", "", OPT_SEP
, "", 0);
130 snprintf(buffer
, sizeof buffer
, "Nb PCI Devices: %d",
131 hardware
->nb_pci_devices
);
132 snprintf(statbuffer
, sizeof statbuffer
, "Number of PCI Devices: %d",
133 hardware
->nb_pci_devices
);
134 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
137 if (hardware
->is_pxe_valid
== true) {
138 add_item("", "", OPT_SEP
, "", 0);
140 struct s_pxe
*p
= &hardware
->pxe
;
142 snprintf(buffer
, sizeof buffer
, "PXE MAC Address: %s", p
->mac_addr
);
143 snprintf(statbuffer
, sizeof statbuffer
, "PXE MAC Address: %s",
145 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
148 snprintf(buffer
, sizeof buffer
, "PXE IP Address : %d.%d.%d.%d",
149 p
->ip_addr
[0], p
->ip_addr
[1], p
->ip_addr
[2], p
->ip_addr
[3]);
150 snprintf(statbuffer
, sizeof statbuffer
,
151 "PXE IP Address: %d.%d.%d.%d", p
->ip_addr
[0],
152 p
->ip_addr
[1], p
->ip_addr
[2], p
->ip_addr
[3]);
153 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
157 if (hardware
->modules_pcimap_return_code
!= -ENOMODULESPCIMAP
) {
158 add_item("", "", OPT_SEP
, "", 0);
160 struct pci_device
*pci_device
;
161 char kernel_modules
[LINUX_KERNEL_MODULE_SIZE
*
162 MAX_KERNEL_MODULES_PER_PCI_DEVICE
];
165 * For every detected pci device, grab its kernel module to compute
168 for_each_pci_func(pci_device
, hardware
->pci_domain
) {
169 memset(kernel_modules
, 0, sizeof kernel_modules
);
171 i
< pci_device
->dev_info
->linux_kernel_module_count
; i
++) {
173 strncat(kernel_modules
, " | ", 3);
175 strncat(kernel_modules
,
176 pci_device
->dev_info
->linux_kernel_module
[i
],
177 LINUX_KERNEL_MODULE_SIZE
- 1);
179 /* No need to add unknown kernel modules */
180 if (strlen(kernel_modules
) > 0) {
181 snprintf(buffer
, sizeof buffer
, "%s (%s)",
182 kernel_modules
, pci_device
->dev_info
->class_name
);
183 snprintf(statbuffer
, sizeof statbuffer
,
187 pci_device
->dev_info
->vendor_name
,
188 pci_device
->dev_info
->product_name
);
190 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
196 printf("MENU: Summary menu done (%d items)\n", menu
->items_count
);