hdt: Improving CPU display
authorErwan Velu <erwanaliasr1@gmail.com>
Sun, 30 Jan 2011 14:06:40 +0000 (15:06 +0100)
committerErwan Velu <erwanaliasr1@gmail.com>
Sun, 30 Jan 2011 14:06:40 +0000 (15:06 +0100)
com32/hdt/hdt-cli-cpu.c
com32/hdt/hdt-common.c
com32/hdt/hdt-common.h
com32/hdt/hdt-menu-processor.c
com32/hdt/hdt-menu-summary.c

index de0c9cd..ca095a6 100644 (file)
@@ -45,8 +45,7 @@ void main_show_cpu(int argc __unused, char **argv __unused,
     if (hardware->acpi.madt.processor_local_apic_count > 0) {
        more_printf("CPU (%d logical / %d phys)\n",
                    hardware->acpi.madt.processor_local_apic_count,
-                   hardware->acpi.madt.processor_local_apic_count /
-                   hardware->cpu.num_cores);
+                   hardware->physical_cpu_count);
     } else
        more_printf("CPU\n");
     more_printf(" Manufacturer : %s \n", hardware->cpu.vendor);
index ded079e..5953be3 100644 (file)
@@ -184,6 +184,7 @@ void init_hardware(struct s_hardware *hardware)
     hardware->is_acpi_valid = false;
     hardware->pci_domain = NULL;
     hardware->detected_memory_size = 0;
+    hardware->physical_cpu_count =1; /* we have at least one cpu */
 
     /* Cleaning structures */
     memset(hardware->disk_info, 0, sizeof(hardware->disk_info));
@@ -563,6 +564,10 @@ void cpu_detect(struct s_hardware *hardware)
      * That makes some weird display in console/menu
      * Let's remove that mulitple spaces */
     strlcpy(hardware->cpu.model,del_multi_spaces(hardware->cpu.model),sizeof(hardware->cpu.model));
+
+    if ((hardware->is_acpi_valid) && (hardware->acpi.madt.valid)) {
+       hardware->physical_cpu_count=hardware->acpi.madt.processor_local_apic_count / hardware->cpu.num_cores;
+    }
     hardware->cpu_detection = true;
 }
 
index 3aa5a50..df7d2c9 100644 (file)
@@ -173,6 +173,7 @@ struct s_vesa {
 struct s_hardware {
     s_dmi dmi;                 /* DMI table */
     s_cpu cpu;                 /* CPU information */
+    uint8_t physical_cpu_count; /* Number of physical cpu */
     s_vpd vpd;                 /* VPD information */
     s_acpi acpi;
     struct pci_domain *pci_domain;     /* PCI Devices */
index ca3e154..ad4a8ba 100644 (file)
@@ -58,8 +58,7 @@ void compute_processor(struct s_my_menu *menu, struct s_hardware *hardware)
        snprintf(buffer, sizeof buffer,
                 " Main Processors (%d logical / %d phys. ) ",
                 hardware->acpi.madt.processor_local_apic_count,
-                hardware->acpi.madt.processor_local_apic_count /
-                hardware->cpu.num_cores);
+                hardware->physical_cpu_count);
        menu->menu = add_menu(buffer, -1);
        menu->items_count = 0;
        set_menu_pos(SUBMENU_Y, SUBMENU_X);
index e9d56ca..d02f3c3 100644 (file)
@@ -34,7 +34,8 @@ void compute_summarymenu(struct s_my_menu *menu, struct s_hardware *hardware)
     char buffer[SUBMENULEN + 1];
     char statbuffer[STATLEN + 1];
 
-    menu->menu = add_menu(" Summary ", -1);
+    snprintf(buffer, sizeof(buffer), " Summary (%d CPU) ", hardware->physical_cpu_count);
+    menu->menu = add_menu(buffer, -1);
     menu->items_count = 0;
 
     set_menu_pos(SUBMENU_Y, SUBMENU_X);
@@ -60,9 +61,9 @@ void compute_summarymenu(struct s_my_menu *menu, struct s_hardware *hardware)
     else
        strcat(features, ", 32bit");
     if (hardware->cpu.flags.smp)
-       strcat(features, ", SMP ");
+       strcat(features, ", SMP");
     if (hardware->cpu.flags.vmx || hardware->cpu.flags.svm)
-       strcat(features, ", HwVIRT ");
+       strcat(features, ", HwVIRT");
     snprintf(buffer, sizeof buffer, "%s", features);
     snprintf(statbuffer, sizeof statbuffer, "Features : %s", features);
     add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);