syslinux/com32/hdt/hdt-menu-summary.c
<<
>>
Prefs
   1/* ----------------------------------------------------------------------- *
   2 *
   3 *   Copyright 2009 Erwan Velu - All Rights Reserved
   4 *
   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:
  13 *
  14 *   The above copyright notice and this permission notice shall
  15 *   be included in all copies or substantial portions of the Software.
  16 *
  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.
  25 *
  26 * -----------------------------------------------------------------------
  27*/
  28
  29#include "hdt-menu.h"
  30
  31/* Computing Summary menu */
  32void compute_summarymenu(struct s_my_menu *menu, struct s_hardware *hardware)
  33{
  34    char buffer[SUBMENULEN + 1];
  35    char statbuffer[STATLEN + 1];
  36
  37    snprintf(buffer, sizeof(buffer), " Summary (%d CPU) ", hardware->physical_cpu_count);
  38    menu->menu = add_menu(buffer, -1);
  39    menu->items_count = 0;
  40
  41    set_menu_pos(SUBMENU_Y, SUBMENU_X);
  42
  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++;
  48
  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++;
  54
  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++;
  75
  76    add_item("", "", OPT_SEP, "", 0);
  77    if (hardware->is_dmi_valid == true) {
  78
  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++;
  85
  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++;
  92
  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++;
  99
 100        add_item("", "", OPT_SEP, "", 0);
 101
 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++;
 108
 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++;
 115    }
 116
 117    add_item("", "", OPT_SEP, "", 0);
 118
 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++;
 128
 129    add_item("", "", OPT_SEP, "", 0);
 130
 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++;
 137
 138    if (hardware->is_pxe_valid == true) {
 139        add_item("", "", OPT_SEP, "", 0);
 140
 141        struct s_pxe *p = &hardware->pxe;
 142
 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++;
 148
 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++;
 156    }
 157
 158    if (hardware->modules_pcimap_return_code != -ENOMODULESPCIMAP) {
 159        add_item("", "", OPT_SEP, "", 0);
 160
 161        struct pci_device *pci_device;
 162        char kernel_modules[LINUX_KERNEL_MODULE_SIZE *
 163                            MAX_KERNEL_MODULES_PER_PCI_DEVICE];
 164
 165        /*
 166         * For every detected pci device, grab its kernel module to compute
 167         * this submenu
 168         */
 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);
 175                }
 176                strncat(kernel_modules,
 177                        pci_device->dev_info->linux_kernel_module[i],
 178                        LINUX_KERNEL_MODULE_SIZE - 1);
 179            }
 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);
 190
 191                add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
 192                menu->items_count++;
 193            }
 194        }
 195    }
 196
 197    printf("MENU: Summary menu done (%d items)\n", menu->items_count);
 198}
 199
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.