diff options
author | Pierre-Alexandre Meyer <pierre@mouraf.org> | 2009-04-19 08:31:57 -0700 |
---|---|---|
committer | Pierre-Alexandre Meyer <pierre@mouraf.org> | 2009-04-19 08:31:57 -0700 |
commit | 29feadbdcfb667e0faca8a6391fe19f3f9a6b327 (patch) | |
tree | 53d052e48df73a711a0127367f4ce6cf759c411d | |
parent | 3ff657d37c92d9fec9e9842216dfee3f5c21a6c3 (diff) | |
parent | 13c60849867ecc575b8f28dc259705b772611402 (diff) | |
download | syslinux.git-29feadbdcfb667e0faca8a6391fe19f3f9a6b327.tar.gz syslinux.git-29feadbdcfb667e0faca8a6391fe19f3f9a6b327.tar.xz syslinux.git-29feadbdcfb667e0faca8a6391fe19f3f9a6b327.zip |
Merge commit 'mouraf/for-erwan' into disklib
Conflicts:
com32/hdt/hdt-cli.c
com32/hdt/hdt-cli.h
31 files changed, 611 insertions, 300 deletions
@@ -8,6 +8,10 @@ Changes in 3.75: * MEMDISK: correct the extraction of geometry information from the MBR of a hard disk image, again broken in 3.74. * extlinux(1) man page from Brian Pellin. + * Simple menu: MENU SAVE is now controllable on a menu-by-menu + or entry-by-entry basis. + * gPXELINUX: fix interrupt-disabling bug. + * HDT: fix lockup on machines with certain PCI configurations. Changes in 3.74: * New UI directive, which allows a more natural way to specify diff --git a/com32/hdt/hdt-cli-cpu.c b/com32/hdt/hdt-cli-cpu.c index 9aea1149..388abc07 100644 --- a/com32/hdt/hdt-cli-cpu.c +++ b/com32/hdt/hdt-cli-cpu.c @@ -65,7 +65,7 @@ static void show_cpu(int argc __unused, char **argv __unused, { char buffer[81]; char buffer1[81]; - clear_screen(); + reset_more_printf(); more_printf("CPU\n"); more_printf("Vendor : %s\n", hardware->cpu.vendor); more_printf("Model : %s\n", hardware->cpu.model); @@ -182,7 +182,6 @@ static void show_cpu(int argc __unused, char **argv __unused, struct cli_module_descr cpu_show_modules = { .modules = NULL, - .nb_modules = 0, .default_callback = show_cpu, }; diff --git a/com32/hdt/hdt-cli-dmi.c b/com32/hdt/hdt-cli-dmi.c index 82b326d8..fb929050 100644 --- a/com32/hdt/hdt-cli-dmi.c +++ b/com32/hdt/hdt-cli-dmi.c @@ -40,38 +40,38 @@ static void show_dmi_modules(int argc __unused, char** argv __unused, char available_dmi_commands[1024]; memset(available_dmi_commands, 0, sizeof(available_dmi_commands)); - more_printf("Available DMI modules on your system:\n"); + printf("Available DMI modules on your system:\n"); if (hardware->dmi.base_board.filled == true) - more_printf("\t%s\n", CLI_DMI_BASE_BOARD); + printf("\t%s\n", CLI_DMI_BASE_BOARD); if (hardware->dmi.battery.filled == true) - more_printf("\t%s\n", CLI_DMI_BATTERY); + printf("\t%s\n", CLI_DMI_BATTERY); if (hardware->dmi.bios.filled == true) - more_printf("\t%s\n", CLI_DMI_BIOS); + printf("\t%s\n", CLI_DMI_BIOS); if (hardware->dmi.chassis.filled == true) - more_printf("\t%s\n", CLI_DMI_CHASSIS); + printf("\t%s\n", CLI_DMI_CHASSIS); for (int i = 0; i < hardware->dmi.memory_count; i++) { if (hardware->dmi.memory[i].filled == true) { - more_printf("\tbank <number>\n", CLI_DMI_MEMORY); + printf("\tbank <number>\n"); break; } } if (hardware->dmi.processor.filled == true) - more_printf("\t%s\n", CLI_DMI_PROCESSOR); + printf("\t%s\n", CLI_DMI_PROCESSOR); if (hardware->dmi.system.filled == true) - more_printf("\t%s\n", CLI_DMI_SYSTEM); + printf("\t%s\n", CLI_DMI_SYSTEM); if (hardware->dmi.ipmi.filled == true) - more_printf("\t%s\n", CLI_DMI_IPMI); + printf("\t%s\n", CLI_DMI_IPMI); } static void show_dmi_base_board(int argc __unused, char** argv __unused, struct s_hardware *hardware) { if (hardware->dmi.base_board.filled == false) { - more_printf("base_board information not found on your system, see " + printf("base_board information not found on your system, see " "`show list' to see which module is available.\n"); return; } - clear_screen(); + reset_more_printf(); more_printf("Base board\n"); more_printf(" Manufacturer : %s\n", hardware->dmi.base_board.manufacturer); @@ -93,31 +93,30 @@ static void show_dmi_system(int argc __unused, char** argv __unused, struct s_hardware *hardware) { if (hardware->dmi.system.filled == false) { - more_printf("system information not found on your system, see " + printf("system information not found on your system, see " "`show list' to see which module is available.\n"); return; } - clear_screen(); - more_printf("System\n"); - more_printf(" Manufacturer : %s\n", hardware->dmi.system.manufacturer); - more_printf(" Product Name : %s\n", hardware->dmi.system.product_name); - more_printf(" Version : %s\n", hardware->dmi.system.version); - more_printf(" Serial : %s\n", hardware->dmi.system.serial); - more_printf(" UUID : %s\n", hardware->dmi.system.uuid); - more_printf(" Wakeup Type : %s\n", hardware->dmi.system.wakeup_type); - more_printf(" SKU Number : %s\n", hardware->dmi.system.sku_number); - more_printf(" Family : %s\n", hardware->dmi.system.family); + printf("System\n"); + printf(" Manufacturer : %s\n", hardware->dmi.system.manufacturer); + printf(" Product Name : %s\n", hardware->dmi.system.product_name); + printf(" Version : %s\n", hardware->dmi.system.version); + printf(" Serial : %s\n", hardware->dmi.system.serial); + printf(" UUID : %s\n", hardware->dmi.system.uuid); + printf(" Wakeup Type : %s\n", hardware->dmi.system.wakeup_type); + printf(" SKU Number : %s\n", hardware->dmi.system.sku_number); + printf(" Family : %s\n", hardware->dmi.system.family); } static void show_dmi_bios(int argc __unused, char** argv __unused, struct s_hardware *hardware) { if (hardware->dmi.bios.filled == false) { - more_printf("bios information not found on your system, see " + printf("bios information not found on your system, see " "`show list' to see which module is available.\n"); return; } - clear_screen(); + reset_more_printf(); more_printf("BIOS\n"); more_printf(" Vendor : %s\n", hardware->dmi.bios.vendor); more_printf(" Version : %s\n", hardware->dmi.bios.version); @@ -164,29 +163,28 @@ static void show_dmi_chassis(int argc __unused, char** argv __unused, "`show list' to see which module is available.\n"); return; } - clear_screen(); - more_printf("Chassis\n"); - more_printf(" Manufacturer : %s\n", + printf("Chassis\n"); + printf(" Manufacturer : %s\n", hardware->dmi.chassis.manufacturer); - more_printf(" Type : %s\n", hardware->dmi.chassis.type); - more_printf(" Lock : %s\n", hardware->dmi.chassis.lock); - more_printf(" Version : %s\n", + printf(" Type : %s\n", hardware->dmi.chassis.type); + printf(" Lock : %s\n", hardware->dmi.chassis.lock); + printf(" Version : %s\n", hardware->dmi.chassis.version); - more_printf(" Serial : %s\n", hardware->dmi.chassis.serial); - more_printf(" Asset Tag : %s\n", + printf(" Serial : %s\n", hardware->dmi.chassis.serial); + printf(" Asset Tag : %s\n", hardware->dmi.chassis.asset_tag); - more_printf(" Boot up state : %s\n", + printf(" Boot up state : %s\n", hardware->dmi.chassis.boot_up_state); - more_printf(" Power supply state : %s\n", + printf(" Power supply state : %s\n", hardware->dmi.chassis.power_supply_state); - more_printf(" Thermal state : %s\n", + printf(" Thermal state : %s\n", hardware->dmi.chassis.thermal_state); - more_printf(" Security Status : %s\n", + printf(" Security Status : %s\n", hardware->dmi.chassis.security_status); - more_printf(" OEM Information : %s\n", + printf(" OEM Information : %s\n", hardware->dmi.chassis.oem_information); - more_printf(" Height : %u\n", hardware->dmi.chassis.height); - more_printf(" NB Power Cords : %u\n", + printf(" Height : %u\n", hardware->dmi.chassis.height); + printf(" NB Power Cords : %u\n", hardware->dmi.chassis.nb_power_cords); } @@ -197,22 +195,21 @@ static void show_dmi_ipmi(int argc __unused, char **argv __unused, more_printf("IPMI module not available\n"); return; } - clear_screen(); - more_printf("IPMI\n"); - more_printf(" Interface Type : %s\n", + printf("IPMI\n"); + printf(" Interface Type : %s\n", hardware->dmi.ipmi.interface_type); - more_printf(" Specification Ver. : %u.%u\n", + printf(" Specification Ver. : %u.%u\n", hardware->dmi.ipmi.major_specification_version, hardware->dmi.ipmi.minor_specification_version); - more_printf(" I2C Slave Address : 0x%02x\n", + printf(" I2C Slave Address : 0x%02x\n", hardware->dmi.ipmi.I2C_slave_address); - more_printf(" Nv Storage Address : %u\n", + printf(" Nv Storage Address : %u\n", hardware->dmi.ipmi.nv_address); uint32_t high = hardware->dmi.ipmi.base_address >> 32; uint32_t low = hardware->dmi.ipmi.base_address & 0xFFFF; - more_printf(" Base Address : %08X%08X\n", + printf(" Base Address : %08X%08X\n", high,(low & ~1)); - more_printf(" IRQ : %d\n", + printf(" IRQ : %d\n", hardware->dmi.ipmi.irq); } @@ -220,32 +217,31 @@ static void show_dmi_battery(int argc __unused, char** argv __unused, struct s_hardware *hardware) { if (hardware->dmi.battery.filled == false) { - more_printf("battery information not found on your system, see " + printf("battery information not found on your system, see " "`show list' to see which module is available.\n"); return; } - clear_screen(); - more_printf("Battery \n"); - more_printf(" Vendor : %s\n", + printf("Battery \n"); + printf(" Vendor : %s\n", hardware->dmi.battery.manufacturer); - more_printf(" Manufacture Date : %s\n", + printf(" Manufacture Date : %s\n", hardware->dmi.battery.manufacture_date); - more_printf(" Serial : %s\n", hardware->dmi.battery.serial); - more_printf(" Name : %s\n", hardware->dmi.battery.name); - more_printf(" Chemistry : %s\n", + printf(" Serial : %s\n", hardware->dmi.battery.serial); + printf(" Name : %s\n", hardware->dmi.battery.name); + printf(" Chemistry : %s\n", hardware->dmi.battery.chemistry); - more_printf(" Design Capacity : %s\n", + printf(" Design Capacity : %s\n", hardware->dmi.battery.design_capacity); - more_printf(" Design Voltage : %s\n", + printf(" Design Voltage : %s\n", hardware->dmi.battery.design_voltage); - more_printf(" SBDS : %s\n", hardware->dmi.battery.sbds); - more_printf(" SBDS Manuf. Date : %s\n", + printf(" SBDS : %s\n", hardware->dmi.battery.sbds); + printf(" SBDS Manuf. Date : %s\n", hardware->dmi.battery.sbds_manufacture_date); - more_printf(" SBDS Chemistry : %s\n", + printf(" SBDS Chemistry : %s\n", hardware->dmi.battery.sbds_chemistry); - more_printf(" Maximum Error : %s\n", + printf(" Maximum Error : %s\n", hardware->dmi.battery.maximum_error); - more_printf(" OEM Info : %s\n", + printf(" OEM Info : %s\n", hardware->dmi.battery.oem_info); } @@ -253,11 +249,11 @@ static void show_dmi_cpu(int argc __unused, char** argv __unused, struct s_hardware *hardware) { if (hardware->dmi.processor.filled == false) { - more_printf("processor information not found on your system, see " + printf("processor information not found on your system, see " "`show list' to see which module is available.\n"); return; } - clear_screen(); + reset_more_printf(); more_printf("CPU\n"); more_printf(" Socket Designation : %s\n", hardware->dmi.processor.socket_designation); @@ -310,51 +306,51 @@ static void show_dmi_cpu(int argc __unused, char** argv __unused, static void show_dmi_memory_bank(int argc, char** argv, struct s_hardware *hardware) { - long bank = -1; + int bank = -1; /* Sanitize arguments */ if (argc > 0) bank = strtol(argv[0], (char **)NULL, 10); if (errno == ERANGE || bank < 0) { - more_printf("This bank number is incorrect\n"); + printf("This bank number is incorrect\n"); return; } if ((bank >= hardware->dmi.memory_count) || (bank < 0)) { - more_printf("Bank %d number doesn't exists\n", bank); + printf("Bank %d number doesn't exists\n", bank); return; } if (hardware->dmi.memory[bank].filled == false) { - more_printf("Bank %d doesn't contain any information\n", bank); + printf("Bank %d doesn't contain any information\n", bank); return; } - more_printf("Memory Bank %d\n", bank); - more_printf(" Form Factor : %s\n", + printf("Memory Bank %d\n", bank); + printf(" Form Factor : %s\n", hardware->dmi.memory[bank].form_factor); - more_printf(" Type : %s\n", hardware->dmi.memory[bank].type); - more_printf(" Type Detail : %s\n", + printf(" Type : %s\n", hardware->dmi.memory[bank].type); + printf(" Type Detail : %s\n", hardware->dmi.memory[bank].type_detail); - more_printf(" Speed : %s\n", hardware->dmi.memory[bank].speed); - more_printf(" Size : %s\n", hardware->dmi.memory[bank].size); - more_printf(" Device Set : %s\n", + printf(" Speed : %s\n", hardware->dmi.memory[bank].speed); + printf(" Size : %s\n", hardware->dmi.memory[bank].size); + printf(" Device Set : %s\n", hardware->dmi.memory[bank].device_set); - more_printf(" Device Loc. : %s\n", + printf(" Device Loc. : %s\n", hardware->dmi.memory[bank].device_locator); - more_printf(" Bank Locator : %s\n", + printf(" Bank Locator : %s\n", hardware->dmi.memory[bank].bank_locator); - more_printf(" Total Width : %s\n", + printf(" Total Width : %s\n", hardware->dmi.memory[bank].total_width); - more_printf(" Data Width : %s\n", + printf(" Data Width : %s\n", hardware->dmi.memory[bank].data_width); - more_printf(" Error : %s\n", hardware->dmi.memory[bank].error); - more_printf(" Vendor : %s\n", + printf(" Error : %s\n", hardware->dmi.memory[bank].error); + printf(" Vendor : %s\n", hardware->dmi.memory[bank].manufacturer); - more_printf(" Serial : %s\n", hardware->dmi.memory[bank].serial); - more_printf(" Asset Tag : %s\n", + printf(" Serial : %s\n", hardware->dmi.memory[bank].serial); + printf(" Asset Tag : %s\n", hardware->dmi.memory[bank].asset_tag); - more_printf(" Part Number : %s\n", + printf(" Part Number : %s\n", hardware->dmi.memory[bank].part_number); } @@ -365,10 +361,10 @@ void main_show_dmi(int argc __unused, char **argv __unused, detect_dmi(hardware); if (hardware->is_dmi_valid == false) { - more_printf("No valid DMI table found, exiting.\n"); + printf("No valid DMI table found, exiting.\n"); return; } - more_printf("DMI Table version %d.%d found\n", + printf("DMI Table version %d.%d found\n", hardware->dmi.dmitable.major_version, hardware->dmi.dmitable.minor_version); @@ -479,11 +475,14 @@ struct cli_callback_descr list_dmi_show_modules[] = { .name = CLI_DMI_LIST, .exec = show_dmi_modules, }, + { + .name = NULL, + .exec = NULL, + }, }; struct cli_module_descr dmi_show_modules = { .modules = list_dmi_show_modules, - .nb_modules = CLI_DMI_MAX_MODULES, .default_callback = main_show_dmi, }; diff --git a/com32/hdt/hdt-cli-hdt.c b/com32/hdt/hdt-cli-hdt.c index cc7b30be..b8c36ba1 100644 --- a/com32/hdt/hdt-cli-hdt.c +++ b/com32/hdt/hdt-cli-hdt.c @@ -50,11 +50,13 @@ static void cli_clear_screen(int argc __unused, char** argv __unused, static void main_show_modes(int argc __unused, char** argv __unused, struct s_hardware *hardware __unused) { - int i; + int i = 0; - more_printf("Available modes:\n"); - for (i = 0; i < MAX_MODES; i++) + printf("Available modes:\n"); + while (list_modes[i]) { more_printf("\t%s\n", list_modes[i]->name); + i++; + } } /** @@ -68,7 +70,7 @@ static void cli_set_mode(int argc, char **argv, cli_mode_t new_mode; if (argc <= 0) { - more_printf("Which mode?\n"); + printf("Which mode?\n"); return; } @@ -108,45 +110,55 @@ static void do_exit(int argc __unused, char** argv __unused, static void show_cli_help(int argc __unused, char** argv __unused, struct s_hardware *hardware __unused) { - int j; + int j = 0; struct cli_mode_descr *current_mode; struct cli_callback_descr* associated_module = NULL; find_cli_mode_descr(hdt_cli.mode, ¤t_mode); - more_printf("Available commands are:\n"); + printf("Available commands are:\n"); /* List first default modules of the mode */ - if (current_mode->default_modules != NULL ) { - for (j = 0; j < current_mode->default_modules->nb_modules; j++) { + if (current_mode->default_modules && + current_mode->default_modules->modules) { + while (current_mode->default_modules->modules[j].name) { more_printf("%s ", current_mode->default_modules->modules[j].name); + j++; } more_printf("\n"); } /* List secondly the show modules of the mode */ - if (current_mode->show_modules != NULL && - current_mode->show_modules->nb_modules != 0) { - more_printf("show commands:\n"); - for (j = 0; j < current_mode->show_modules->nb_modules; j++) + if (current_mode->show_modules && + current_mode->show_modules->modules) { + printf("show commands:\n"); + j = 0; + while (current_mode->show_modules->modules[j].name) { more_printf("\t%s\n", current_mode->show_modules->modules[j].name); + j++; + } } /* List thirdly the set modules of the mode */ - if (current_mode->set_modules != NULL && - current_mode->set_modules->nb_modules != 0) { - more_printf("set commands:\n"); - for (j = 0; j < current_mode->set_modules->nb_modules; j++) + if (current_mode->set_modules && + current_mode->set_modules->modules) { + printf("set commands:\n"); + j = 0; + while (current_mode->set_modules->modules[j].name) { more_printf("\t%s\n", current_mode->set_modules->modules[j].name); + j++; + } } /* List finally the default modules of the hdt mode */ if (current_mode->mode != hdt_mode.mode && - hdt_mode.default_modules != NULL ) { - for (j = 0; j < hdt_mode.default_modules->nb_modules; j++) { + hdt_mode.default_modules && + hdt_mode.default_modules->modules) { + j = 0; + while (hdt_mode.default_modules->modules[j].name) { /* * Any default command that is present in hdt mode but * not in the current mode is available. A default @@ -158,10 +170,11 @@ static void show_cli_help(int argc __unused, char** argv __unused, current_mode->default_modules, &associated_module); if (associated_module == NULL) - more_printf("%s ", + printf("%s ", hdt_mode.default_modules->modules[j].name); + j++; } - more_printf("\n"); + printf("\n"); } main_show_modes(argc, argv, hardware); @@ -219,14 +232,14 @@ void main_show_summary(int argc __unused, char **argv __unused, void main_show_hdt(int argc __unused, char **argv __unused, struct s_hardware *hardware __unused) { - more_printf("HDT\n"); - more_printf(" Product : %s\n", PRODUCT_NAME); - more_printf(" Version : %s\n", VERSION); - more_printf(" Author : %s\n", AUTHOR); - more_printf(" Contact : %s\n", CONTACT); + printf("HDT\n"); + printf(" Product : %s\n", PRODUCT_NAME); + printf(" Version : %s\n", VERSION); + printf(" Author : %s\n", AUTHOR); + printf(" Contact : %s\n", CONTACT); char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS; for (int c = 0; c < NB_CONTRIBUTORS; c++) { - more_printf(" Contributor : %s\n", contributors[c]); + printf(" Contributor : %s\n", contributors[c]); } } @@ -248,6 +261,10 @@ struct cli_callback_descr list_hdt_default_modules[] = { .name = CLI_MENU, .exec = goto_menu, }, + { + .name = NULL, + .exec = NULL + }, }; struct cli_callback_descr list_hdt_show_modules[] = { @@ -291,6 +308,10 @@ struct cli_callback_descr list_hdt_show_modules[] = { .name = "modes", .exec = main_show_modes, }, + { + .name = NULL, + .exec = NULL, + }, }; struct cli_callback_descr list_hdt_set_modules[] = { @@ -298,22 +319,23 @@ struct cli_callback_descr list_hdt_set_modules[] = { .name = CLI_MODE, .exec = cli_set_mode, }, + { + .name = NULL, + .exec = NULL, + }, }; struct cli_module_descr hdt_default_modules = { .modules = list_hdt_default_modules, - .nb_modules = 4, }; struct cli_module_descr hdt_show_modules = { .modules = list_hdt_show_modules, - .nb_modules = 10, .default_callback = main_show_summary, }; struct cli_module_descr hdt_set_modules = { .modules = list_hdt_set_modules, - .nb_modules = 1, }; struct cli_mode_descr hdt_mode = { diff --git a/com32/hdt/hdt-cli-kernel.c b/com32/hdt/hdt-cli-kernel.c index 700f2381..d9ba27f8 100644 --- a/com32/hdt/hdt-cli-kernel.c +++ b/com32/hdt/hdt-cli-kernel.c @@ -104,19 +104,17 @@ static void show_kernel_modules(int argc __unused, char **argv __unused, if (hardware->pci_ids_return_code == -ENOPCIIDS) { nopciids = true; - more_printf(" Missing pci.ids, we can't compute the list\n"); + printf(" Missing pci.ids, we can't compute the list\n"); return; } if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) { nomodulespcimap = true; - more_printf + printf (" Missing modules.pcimap, we can't compute the list\n"); return; } - clear_screen(); - for_each_pci_func(pci_device, hardware->pci_domain) { memset(kernel_modules, 0, sizeof kernel_modules); @@ -141,14 +139,13 @@ static void show_kernel_modules(int argc __unused, char **argv __unused, /* Print the found items */ for (int i = 0; i < MAX_PCI_CLASSES; i++) { if (strlen(category_name[i]) > 1) { - more_printf("%s : %s\n", category_name[i], modules[i]); + printf("%s : %s\n", category_name[i], modules[i]); } } } struct cli_module_descr kernel_show_modules = { .modules = NULL, - .nb_modules = 0, .default_callback = show_kernel_modules, }; diff --git a/com32/hdt/hdt-cli-pci.c b/com32/hdt/hdt-cli-pci.c index a1b64c4f..389e750f 100644 --- a/com32/hdt/hdt-cli-pci.c +++ b/com32/hdt/hdt-cli-pci.c @@ -47,7 +47,7 @@ static void show_pci_device(int argc, char **argv, { int i = 0; struct pci_device *pci_device = NULL, *temp_pci_device; - long pcidev = -1; + int pcidev = -1; bool nopciids = false; bool nomodulespcimap = false; char kernel_modules[LINUX_KERNEL_MODULE_SIZE * @@ -56,17 +56,17 @@ static void show_pci_device(int argc, char **argv, /* Sanitize arguments */ if (argc <= 0) { - more_printf("show device <number>\n"); + printf("show device <number>\n"); return; } else pcidev = strtol(argv[0], (char **)NULL, 10); if (errno == ERANGE) { - more_printf("This PCI device number is incorrect\n"); + printf("This PCI device number is incorrect\n"); return; } if ((pcidev > hardware->nb_pci_devices) || (pcidev <= 0)) { - more_printf("PCI device %d doesn't exists\n", pcidev); + printf("PCI device %d doesn't exists\n", pcidev); return; } if (hardware->pci_ids_return_code == -ENOPCIIDS) { @@ -87,7 +87,7 @@ static void show_pci_device(int argc, char **argv, } if (pci_device == NULL) { - more_printf("We were enabled to find PCI device %d\n", pcidev); + printf("We were enabled to find PCI device %d\n", pcidev); return; } @@ -104,43 +104,41 @@ static void show_pci_device(int argc, char **argv, if (pci_device->dev_info->linux_kernel_module_count == 0) strlcpy(kernel_modules, "unknown", 7); - clear_screen(); - more_printf("PCI Device %d\n", pcidev); + printf("PCI Device %d\n", pcidev); if (nopciids == false) { - more_printf("Vendor Name : %s\n", + printf("Vendor Name : %s\n", pci_device->dev_info->vendor_name); - more_printf("Product Name : %s\n", + printf("Product Name : %s\n", pci_device->dev_info->product_name); - more_printf("Class Name : %s\n", + printf("Class Name : %s\n", pci_device->dev_info->class_name); } if (nomodulespcimap == false) { - more_printf("Kernel module : %s\n", kernel_modules); + printf("Kernel module : %s\n", kernel_modules); } - more_printf("Vendor ID : %04x\n", pci_device->vendor); - more_printf("Product ID : %04x\n", pci_device->product); - more_printf("SubVendor ID : %04x\n", pci_device->sub_vendor); - more_printf("SubProduct ID : %04x\n", pci_device->sub_product); - more_printf("Class ID : %02x.%02x.%02x\n", pci_device->class[2], + printf("Vendor ID : %04x\n", pci_device->vendor); + printf("Product ID : %04x\n", pci_device->product); + printf("SubVendor ID : %04x\n", pci_device->sub_vendor); + printf("SubProduct ID : %04x\n", pci_device->sub_product); + printf("Class ID : %02x.%02x.%02x\n", pci_device->class[2], pci_device->class[1], pci_device->class[0]); - more_printf("Revision : %02x\n", pci_device->revision); + printf("Revision : %02x\n", pci_device->revision); if ((pci_device->dev_info->irq > 0) && (pci_device->dev_info->irq < 255)) more_printf("IRQ : %0d\n", pci_device->dev_info->irq); - more_printf("Latency : %0d\n", pci_device->dev_info->latency); - more_printf("PCI Bus : %02d\n", bus); - more_printf("PCI Slot : %02d\n", slot); - more_printf("PCI Func : %02d\n", func); + printf("Latency : %0d\n", pci_device->dev_info->latency); + printf("PCI Bus : %02d\n", bus); + printf("PCI Slot : %02d\n", slot); + printf("PCI Func : %02d\n", func); if (hardware->is_pxe_valid == true) { - more_printf("Mac Address : %s\n", hardware->pxe.mac_addr); + printf("Mac Address : %s\n", hardware->pxe.mac_addr); if ((hardware->pxe.pci_device != NULL) && (hardware->pxe.pci_device == pci_device)) - more_printf("PXE : Current boot device\n", - func); + printf("PXE : Current boot device\n"); } } @@ -156,7 +154,7 @@ static void show_pci_devices(int argc __unused, char **argv __unused, char first_line[81]; char second_line[81]; - clear_screen(); + reset_more_printf(); more_printf("%d PCI devices detected\n", hardware->nb_pci_devices); if (hardware->pci_ids_return_code == -ENOPCIIDS) { @@ -216,7 +214,6 @@ static void show_pci_devices(int argc __unused, char **argv __unused, ("%02d: %04x:%04x [%04x:%04x] Kmod:%s\n", i, pci_device->vendor, pci_device->product, pci_device->sub_vendor, - pci_device->sub_product, kernel_modules, pci_device->sub_product, kernel_modules); } } @@ -231,7 +228,7 @@ static void show_pci_irq(int argc __unused, char **argv __unused, struct pci_device *pci_device; bool nopciids = false; - clear_screen(); + reset_more_printf(); more_printf("%d PCI devices detected\n", hardware->nb_pci_devices); more_printf("IRQ : product\n"); more_printf("-------------\n"); @@ -271,11 +268,14 @@ struct cli_callback_descr list_pci_show_modules[] = { .name = CLI_PCI_DEVICE, .exec = show_pci_device, }, + { + .name = NULL, + .exec = NULL, + }, }; struct cli_module_descr pci_show_modules = { .modules = list_pci_show_modules, - .nb_modules = 2, .default_callback = show_pci_devices, }; @@ -293,20 +293,20 @@ void cli_detect_pci(struct s_hardware *hardware) if (hardware->pci_detection == false) { detect_pci(hardware); if (hardware->pci_ids_return_code == -ENOPCIIDS) { - more_printf + printf ("The pci.ids file is missing, device names can't be computed.\n"); - more_printf("Please put one in same dir as hdt\n"); + printf("Please put one in same dir as hdt\n"); error = true; } if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) { - more_printf + printf ("The modules.pcimap file is missing, device names can't be computed.\n"); - more_printf("Please put one in same dir as hdt\n"); + printf("Please put one in same dir as hdt\n"); error = true; } if (error == true) { char tempbuf[10]; - more_printf("Press enter to continue\n"); + printf("Press enter to continue\n"); fgets(tempbuf, sizeof(tempbuf), stdin); } } diff --git a/com32/hdt/hdt-cli-pxe.c b/com32/hdt/hdt-cli-pxe.c index 601619c2..1d00cae5 100644 --- a/com32/hdt/hdt-cli-pxe.c +++ b/com32/hdt/hdt-cli-pxe.c @@ -42,19 +42,19 @@ void main_show_pxe(int argc __unused, char **argv __unused, char buffer[81]; memset(buffer, 0, sizeof(81)); if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) { - more_printf("You are not currently using PXELINUX\n"); + printf("You are not currently using PXELINUX\n"); return; } detect_pxe(hardware); - more_printf("PXE\n"); + printf("PXE\n"); if (hardware->is_pxe_valid == false) { - more_printf(" No valid PXE ROM found\n"); + printf(" No valid PXE ROM found\n"); return; } struct s_pxe *p = &hardware->pxe; - more_printf(" PCI device no: %d \n", p->pci_device_pos); + printf(" PCI device no: %d \n", p->pci_device_pos); if (hardware->pci_ids_return_code == -ENOPCIIDS || (p->pci_device == NULL)) { @@ -65,22 +65,21 @@ void main_show_pxe(int argc __unused, char **argv __unused, snprintf(buffer, sizeof(buffer), " PCI Bus pos. : %02x:%02x.%02x\n", p->pci_bus, p->pci_dev, p->pci_func); - more_printf(buffer); + printf(buffer); } else { snprintf(buffer, sizeof(buffer), " Manufacturer : %s \n", p->pci_device->dev_info->vendor_name); - more_printf(buffer); + printf(buffer); snprintf(buffer, sizeof(buffer), " Product : %s \n", p->pci_device->dev_info->product_name); - more_printf(buffer); + printf(buffer); } - more_printf(" Addresses : %d.%d.%d.%d @ %s\n", p->ip_addr[0], + printf(" Addresses : %d.%d.%d.%d @ %s\n", p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3], p->mac_addr); } struct cli_module_descr pxe_show_modules = { .modules = NULL, - .nb_modules = 0, .default_callback = main_show_pxe, }; diff --git a/com32/hdt/hdt-cli-syslinux.c b/com32/hdt/hdt-cli-syslinux.c index 168a3d3a..0d78bc66 100644 --- a/com32/hdt/hdt-cli-syslinux.c +++ b/com32/hdt/hdt-cli-syslinux.c @@ -39,17 +39,16 @@ void main_show_syslinux(int argc __unused, char **argv __unused, struct s_hardware *hardware) { - more_printf("SYSLINUX\n"); - more_printf(" Bootloader : %s\n", hardware->syslinux_fs); - more_printf(" Version : %s\n", hardware->sv->version_string + 2); - more_printf(" Version : %u\n", hardware->sv->version); - more_printf(" Max API : %u\n", hardware->sv->max_api); - more_printf(" Copyright : %s\n", hardware->sv->copyright_string + 1); + printf("SYSLINUX\n"); + printf(" Bootloader : %s\n", hardware->syslinux_fs); + printf(" Version : %s\n", hardware->sv->version_string + 2); + printf(" Version : %u\n", hardware->sv->version); + printf(" Max API : %u\n", hardware->sv->max_api); + printf(" Copyright : %s\n", hardware->sv->copyright_string + 1); } struct cli_module_descr syslinux_show_modules = { .modules = NULL, - .nb_modules = 0, .default_callback = main_show_syslinux, }; diff --git a/com32/hdt/hdt-cli-vesa.c b/com32/hdt/hdt-cli-vesa.c index 4234135d..70d1dc61 100644 --- a/com32/hdt/hdt-cli-vesa.c +++ b/com32/hdt/hdt-cli-vesa.c @@ -38,18 +38,18 @@ void main_show_vesa(int argc __unused, char **argv __unused, { detect_vesa(hardware); if (hardware->is_vesa_valid == false) { - more_printf("No VESA BIOS detected\n"); + printf("No VESA BIOS detected\n"); return; } - more_printf("VESA\n"); - more_printf(" Vesa version : %d.%d\n", hardware->vesa.major_version, + printf("VESA\n"); + printf(" Vesa version : %d.%d\n", hardware->vesa.major_version, hardware->vesa.minor_version); - more_printf(" Vendor : %s\n", hardware->vesa.vendor); - more_printf(" Product : %s\n", hardware->vesa.product); - more_printf(" Product rev. : %s\n", hardware->vesa.product_revision); - more_printf(" Software rev.: %s\n", hardware->vesa.software_rev); - more_printf(" Memory (KB) : %d\n", hardware->vesa.total_memory * 64); - more_printf(" Modes : %d\n", hardware->vesa.vmi_count); + printf(" Vendor : %s\n", hardware->vesa.vendor); + printf(" Product : %s\n", hardware->vesa.product); + printf(" Product rev. : %s\n", hardware->vesa.product_revision); + printf(" Software rev.: %d\n", hardware->vesa.software_rev); + printf(" Memory (KB) : %d\n", hardware->vesa.total_memory * 64); + printf(" Modes : %d\n", hardware->vesa.vmi_count); } static void show_vesa_modes(int argc __unused, char **argv __unused, @@ -57,14 +57,12 @@ static void show_vesa_modes(int argc __unused, char **argv __unused, { detect_vesa(hardware); if (hardware->is_vesa_valid == false) { - more_printf("No VESA BIOS detected\n"); + printf("No VESA BIOS detected\n"); return; } - clear_screen(); - more_printf(" ResH. x ResV x Bits : vga= : Vesa Mode\n", - hardware->vesa.vmi_count); - more_printf("----------------------------------------\n", - hardware->vesa.vmi_count); + reset_more_printf(); + printf(" ResH. x ResV x Bits : vga= : Vesa Mode\n"); + printf("----------------------------------------\n"); for (int i = 0; i < hardware->vesa.vmi_count; i++) { struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi; @@ -73,7 +71,7 @@ static void show_vesa_modes(int argc __unused, char **argv __unused, * We don't need to display that ones. */ if ((mi->h_res == 0) || (mi->v_res == 0)) continue; - more_printf("%5u %5u %3u %3d 0x%04x\n", + printf("%5u %5u %3u %3d 0x%04x\n", mi->h_res, mi->v_res, mi->bpp, hardware->vesa.vmi[i].mode + 0x200, hardware->vesa.vmi[i].mode); @@ -85,11 +83,14 @@ struct cli_callback_descr list_vesa_show_modules[] = { .name = CLI_MODES, .exec = show_vesa_modes, }, + { + .name = NULL, + .exec = NULL, + }, }; struct cli_module_descr vesa_show_modules = { .modules = list_vesa_show_modules, - .nb_modules = 1, .default_callback = main_show_vesa, }; diff --git a/com32/hdt/hdt-cli-vpd.c b/com32/hdt/hdt-cli-vpd.c new file mode 100644 index 00000000..03614d39 --- /dev/null +++ b/com32/hdt/hdt-cli-vpd.c @@ -0,0 +1,74 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2009 Pierre-Alexandre Meyer - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- + */ + +#include <string.h> +#include <vpd/vpd.h> + +#include "hdt-cli.h" +#include "hdt-common.h" + +void main_show_vpd(int argc __unused, char **argv __unused, + struct s_hardware *hardware) +{ + reset_more_printf(); + detect_vpd(hardware); + + if (!hardware->is_vpd_valid) { + printf("No VPD structure detected.\n"); + return; + } + + printf("VPD present at address : 0x%s\n", hardware->vpd.base_address); + if (strlen(hardware->vpd.bios_build_id) > 0) + more_printf("Bios Build ID : %s\n", hardware->vpd.bios_build_id); + if (strlen(hardware->vpd.bios_release_date) > 0) + more_printf("Bios Release Date : %s\n", hardware->vpd.bios_release_date); + if (strlen(hardware->vpd.bios_version) > 0) + more_printf("Bios Version : %s\n", hardware->vpd.bios_version); + if (strlen(hardware->vpd.default_flash_filename) > 0) + more_printf("Default Flash Filename : %s\n", hardware->vpd.default_flash_filename); + if (strlen(hardware->vpd.box_serial_number) > 0) + more_printf("Box Serial Number : %s\n", hardware->vpd.box_serial_number); + if (strlen(hardware->vpd.motherboard_serial_number) > 0) + more_printf("Motherboard Serial Number : %s\n", hardware->vpd.motherboard_serial_number); + if (strlen(hardware->vpd.machine_type_model) > 0) + more_printf("Machine Type/Model : %s\n", hardware->vpd.machine_type_model); +} + +struct cli_module_descr vpd_show_modules = { + .modules = NULL, + .default_callback = main_show_vpd, +}; + +struct cli_mode_descr vpd_mode = { + .mode = VPD_MODE, + .name = CLI_VPD, + .default_modules = NULL, + .show_modules = &vpd_show_modules, + .set_modules = NULL, +}; diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c index 21c7142d..324c74ae 100644 --- a/com32/hdt/hdt-cli.c +++ b/com32/hdt/hdt-cli.c @@ -44,6 +44,8 @@ struct cli_mode_descr *list_modes[] = { &pci_mode, &vesa_mode, &disk_mode, + &vpd_mode, + NULL, }; /* @@ -116,7 +118,7 @@ static void autocomplete_destroy_list() **/ void set_mode(cli_mode_t mode, struct s_hardware* hardware) { - int i; + int i = 0; switch (mode) { case EXIT_MODE: @@ -129,7 +131,7 @@ void set_mode(cli_mode_t mode, struct s_hardware* hardware) break; case PXE_MODE: if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) { - more_printf("You are not currently using PXELINUX\n"); + printf("You are not currently using PXELINUX\n"); break; } hdt_cli.mode = mode; @@ -171,7 +173,7 @@ void set_mode(cli_mode_t mode, struct s_hardware* hardware) case DMI_MODE: detect_dmi(hardware); if (!hardware->is_dmi_valid) { - more_printf("No valid DMI table found, exiting.\n"); + printf("No valid DMI table found, exiting.\n"); break; } hdt_cli.mode = mode; @@ -184,18 +186,30 @@ void set_mode(cli_mode_t mode, struct s_hardware* hardware) snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_DISK); break; + case VPD_MODE: + detect_vpd(hardware); + if (!hardware->is_vpd_valid) { + printf("No valid VPD table found, exiting.\n"); + break; + } + hdt_cli.mode = mode; + snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", + CLI_VPD); + break; default: /* Invalid mode */ - more_printf("Unknown mode, please choose among:\n"); - for (i = 0; i < MAX_MODES; i++) - more_printf("\t%s\n", list_modes[i]->name); + printf("Unknown mode, please choose among:\n"); + while (list_modes[i]) { + printf("\t%s\n", list_modes[i]->name); + i++; + } } find_cli_mode_descr(hdt_cli.mode, ¤t_mode); /* There is not cli_mode_descr struct for the exit mode */ if (current_mode == NULL && hdt_cli.mode != EXIT_MODE) { /* Shouldn't get here... */ - more_printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode); + printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode); } } @@ -206,12 +220,14 @@ cli_mode_t mode_s_to_mode_t(char *name) { int i = 0; - for (i = 0; i < MAX_MODES; i++) + while (list_modes[i]) { if (!strncmp(name, list_modes[i]->name, sizeof(list_modes[i]->name))) break; + i++; + } - if (i == MAX_MODES) + if (!list_modes[i]) return INVALID_MODE; else return list_modes[i]->mode; @@ -228,17 +244,17 @@ cli_mode_t mode_s_to_mode_t(char *name) **/ void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found) { - int modes_iter = 0; + int i = 0; - while (modes_iter < MAX_MODES && - list_modes[modes_iter]->mode != mode) - modes_iter++; + while (list_modes[i] && + list_modes[i]->mode != mode) + i++; /* Shouldn't get here... */ - if (modes_iter == MAX_MODES) + if (!list_modes[i]) *mode_found = NULL; else - *mode_found = list_modes[modes_iter]; + *mode_found = list_modes[i]; } /** @@ -420,13 +436,13 @@ void find_cli_callback_descr(const char* module_name, goto not_found; /* Find the callback to execute */ - while (modules_iter < modules_list->nb_modules - && strncmp(module_name, - modules_list->modules[modules_iter].name, - module_len) != 0) + while (modules_list->modules[modules_iter].name && + strncmp(module_name, + modules_list->modules[modules_iter].name, + module_len) != 0) modules_iter++; - if (modules_iter != modules_list->nb_modules) { + if (modules_list->modules[modules_iter].name) { *module_found = &(modules_list->modules[modules_iter]); dprintf("CLI DEBUG: module %s found\n", (*module_found)->name); return; @@ -447,16 +463,16 @@ not_found: **/ static void autocomplete_command(char *command) { - int j; + int j = 0; struct cli_callback_descr* associated_module = NULL; /* First take care of the two special commands: 'show' and 'set' */ if (strncmp(CLI_SHOW, command, strlen(command)) == 0) { - more_printf("%s\n", CLI_SHOW); + printf("%s\n", CLI_SHOW); autocomplete_add_token_to_list(CLI_SHOW); } if (strncmp(CLI_SET, command, strlen(command)) == 0) { - more_printf("%s\n", CLI_SET); + printf("%s\n", CLI_SET); autocomplete_add_token_to_list(CLI_SET); } @@ -464,25 +480,28 @@ static void autocomplete_command(char *command) * Then, go through the modes for the special case * '<mode>' -> 'set mode <mode>' */ - for (j = 0; j < MAX_MODES; j++) { + while (list_modes[j]) { if (strncmp(list_modes[j]->name, command, strlen(command)) == 0) { - more_printf("%s\n", list_modes[j]->name); + printf("%s\n", list_modes[j]->name); autocomplete_add_token_to_list(list_modes[j]->name); } + j++; } /* * Let's go now through the list of default_modules for the current mode * (single token commands for the current_mode) */ - for (j = 0; j < current_mode->default_modules->nb_modules; j++) { + j = 0; + while (current_mode->default_modules->modules[j].name) { if (strncmp(current_mode->default_modules->modules[j].name, command, strlen(command)) == 0) { - more_printf("%s\n", + printf("%s\n", current_mode->default_modules->modules[j].name); autocomplete_add_token_to_list(current_mode->default_modules->modules[j].name); } + j++; } /* @@ -492,7 +511,8 @@ static void autocomplete_command(char *command) if (current_mode->mode == HDT_MODE) return; - for (j = 0; j < hdt_mode.default_modules->nb_modules; j++) { + j = 0; + while (hdt_mode.default_modules->modules[j].name) { /* * Any default command that is present in hdt mode but * not in the current mode is available. A default @@ -507,10 +527,11 @@ static void autocomplete_command(char *command) strncmp(command, hdt_mode.default_modules->modules[j].name, strlen(command)) == 0) { - more_printf("%s\n", + printf("%s\n", hdt_mode.default_modules->modules[j].name); autocomplete_add_token_to_list(hdt_mode.default_modules->modules[j].name); } + j++; } } @@ -526,32 +547,35 @@ static void autocomplete_command(char *command) **/ static void autocomplete_module(char *command, char* module) { - int j; + int j = 0; char autocomplete_full_line[MAX_LINE_SIZE]; if (strncmp(CLI_SHOW, command, strlen(command)) == 0) { - for (j = 0; j < current_mode->show_modules->nb_modules; j++) { + while (current_mode->show_modules->modules[j].name) { if (strncmp(current_mode->show_modules->modules[j].name, module, strlen(module)) == 0) { - more_printf("%s\n", + printf("%s\n", current_mode->show_modules->modules[j].name); sprintf(autocomplete_full_line, "%s %s", CLI_SHOW, current_mode->show_modules->modules[j].name); autocomplete_add_token_to_list(autocomplete_full_line); } + j++; } } else if (strncmp(CLI_SET, command, strlen(command)) == 0) { - for (j = 0; j < current_mode->set_modules->nb_modules; j++) { + j = 0; + while (current_mode->set_modules->modules[j].name) { if (strncmp(current_mode->set_modules->modules[j].name, module, strlen(module)) == 0) { - more_printf("%s\n", + printf("%s\n", current_mode->set_modules->modules[j].name); sprintf(autocomplete_full_line, "%s %s", CLI_SET, current_mode->set_modules->modules[j].name); autocomplete_add_token_to_list(autocomplete_full_line); } + j++; } } } @@ -649,7 +673,7 @@ static void exec_command(char *line, return current_module->exec(argc, argv, hardware); } - more_printf("unknown command: '%s'\n", command); + printf("unknown command: '%s'\n", command); return; } @@ -679,7 +703,7 @@ static void exec_command(char *line, return current_module->exec(argc, argv, hardware); } - more_printf("unknown module: '%s'\n", module); + printf("unknown module: '%s'\n", module); return; } else if (!strncmp(command, CLI_SET, sizeof(CLI_SET) - 1)) { @@ -696,12 +720,12 @@ static void exec_command(char *line, return current_module->exec(argc, argv, hardware); } - more_printf("unknown module: '%s'\n", module); + printf("unknown module: '%s'\n", module); return; } - more_printf("I don't understand: '%s'. Try 'help'.\n", line); + printf("I don't understand: '%s'. Try 'help'.\n", line); /* Let's not forget to clean ourselves */ free(command); @@ -715,7 +739,7 @@ static void reset_prompt() { /* No need to display the prompt if we exit */ if (hdt_cli.mode != EXIT_MODE) { - more_printf("%s", hdt_cli.prompt); + printf("%s", hdt_cli.prompt); /* Reset the line */ memset(hdt_cli.input, '\0', MAX_LINE_SIZE); hdt_cli.cursor_pos = 0; @@ -741,11 +765,11 @@ void start_cli_mode(struct s_hardware *hardware) find_cli_mode_descr(hdt_cli.mode, ¤t_mode); if (current_mode == NULL) { /* Shouldn't get here... */ - more_printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode); + printf("!!! BUG: Mode '%d' unknown.\n", hdt_cli.mode); return; } - more_printf("Entering CLI mode\n"); + printf("Entering CLI mode\n"); /* Display the cursor */ display_cursor(true); @@ -771,7 +795,7 @@ void start_cli_mode(struct s_hardware *hardware) break; case KEY_CTRL('c'): - more_printf("\n"); + printf("\n"); reset_prompt(); break; @@ -884,16 +908,16 @@ void start_cli_mode(struct s_hardware *hardware) if (autocomplete_last_seen == NULL) autocomplete_last_seen = autocomplete_head; } else { - more_printf("\n"); + printf("\n"); autocomplete(skip_spaces(hdt_cli.input)); autocomplete_last_seen = autocomplete_head; - more_printf("%s%s", hdt_cli.prompt, hdt_cli.input); + printf("%s%s", hdt_cli.prompt, hdt_cli.input); } break; case KEY_ENTER: - more_printf("\n"); + printf("\n"); if (strlen(remove_spaces(hdt_cli.input)) < 1) { reset_prompt(); break; @@ -906,12 +930,12 @@ void start_cli_mode(struct s_hardware *hardware) reset_prompt(); break; - case KEY_CTRL('d'): - case KEY_DELETE: - /* No need to delete when input is empty */ - if (strlen(hdt_cli.input)==0) break; - /* Don't delete when cursor is at the end of the line */ - if (hdt_cli.cursor_pos>=strlen(hdt_cli.input)) break; + case KEY_CTRL('d'): + case KEY_DELETE: + /* No need to delete when input is empty */ + if (strlen(hdt_cli.input)==0) break; + /* Don't delete when cursor is at the end of the line */ + if (hdt_cli.cursor_pos>=strlen(hdt_cli.input)) break; for (int c = hdt_cli.cursor_pos; c < (int)strlen(hdt_cli.input) - 1; c++) @@ -960,7 +984,7 @@ void start_cli_mode(struct s_hardware *hardware) break; case KEY_F1: - more_printf("\n"); + printf("\n"); exec_command(CLI_HELP, hardware); reset_prompt(); break; diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h index 07193bfe..6f90e453 100644 --- a/com32/hdt/hdt-cli.h +++ b/com32/hdt/hdt-cli.h @@ -68,6 +68,7 @@ #define CLI_SHOW_LIST "list" #define CLI_IRQ "irq" #define CLI_MODES "modes" +#define CLI_VPD "vpd" typedef enum { INVALID_MODE, @@ -81,6 +82,7 @@ typedef enum { SYSLINUX_MODE, VESA_MODE, DISK_MODE, + VPD_MODE, } cli_mode_t; #define PROMPT_SIZE 32 @@ -111,7 +113,6 @@ struct cli_mode_descr { /* Describe a subset of commands in a module (default, show, set, ...) */ struct cli_module_descr { struct cli_callback_descr* modules; - const int nb_modules; void ( * default_callback ) ( int argc, char** argv, struct s_hardware *hardware ); }; @@ -130,8 +131,7 @@ struct cli_alias { }; /* List of implemented modes */ -#define MAX_MODES 9 -struct cli_mode_descr *list_modes[MAX_MODES]; +extern struct cli_mode_descr *list_modes[]; struct cli_mode_descr hdt_mode; struct cli_mode_descr dmi_mode; struct cli_mode_descr syslinux_mode; @@ -141,6 +141,7 @@ struct cli_mode_descr cpu_mode; struct cli_mode_descr pci_mode; struct cli_mode_descr vesa_mode; struct cli_mode_descr disk_mode; +struct cli_mode_descr vpd_mode; /* cli helpers */ void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found); @@ -164,7 +165,6 @@ void main_show(char *item, struct s_hardware *hardware); #define CLI_DMI_SYSTEM "system" #define CLI_DMI_IPMI "ipmi" #define CLI_DMI_LIST CLI_SHOW_LIST -#define CLI_DMI_MAX_MODULES 10 void main_show_dmi(int argc, char **argv, struct s_hardware *hardware); void show_dmi_memory_modules(int argc, char** argv, struct s_hardware *hardware); diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c index 0328fa96..d4f7cb21 100644 --- a/com32/hdt/hdt-common.c +++ b/com32/hdt/hdt-common.c @@ -36,6 +36,22 @@ #include "lib-ansi.h" #include <disk/util.h> +/* ISOlinux requires a 8.3 format */ +void convert_isolinux_filename(char *filename, struct s_hardware *hardware) { + /* Exit if we are not running ISOLINUX */ + if (hardware->sv->filesystem != SYSLINUX_FS_ISOLINUX) return; + /* Searching the dot */ + char *dot=strchr(filename,'.'); + /* Exiting if not dot exists in that string */ + if (dot==NULL) return; + /* Exiting if the extension is 3 char or less */ + if (strlen(dot)<=4) return; + + /* We have an extension bigger than .blah + * so we have to shorten it to 3*/ + dot[4]='\0'; +} + void detect_parameters(const int argc, const char *argv[], struct s_hardware *hardware) { @@ -43,12 +59,15 @@ void detect_parameters(const int argc, const char *argv[], if (!strncmp(argv[i], "modules=", 8)) { strncpy(hardware->modules_pcimap_path, argv[i] + 8, sizeof(hardware->modules_pcimap_path)); + convert_isolinux_filename(hardware->modules_pcimap_path,hardware); } else if (!strncmp(argv[i], "pciids=", 7)) { strncpy(hardware->pciids_path, argv[i] + 7, sizeof(hardware->pciids_path)); + convert_isolinux_filename(hardware->pciids_path,hardware); } else if (!strncmp(argv[i], "memtest=", 8)) { strncpy(hardware->memtest_label, argv[i] + 8, sizeof(hardware->memtest_label)); + convert_isolinux_filename(hardware->memtest_label,hardware); } } } @@ -88,9 +107,11 @@ void init_hardware(struct s_hardware *hardware) hardware->dmi_detection = false; hardware->pxe_detection = false; hardware->vesa_detection = false; + hardware->vpd_detection = false; hardware->nb_pci_devices = 0; hardware->is_dmi_valid = false; hardware->is_pxe_valid = false; + hardware->is_vpd_valid = false; hardware->pci_domain = NULL; /* Cleaning structures */ @@ -99,6 +120,7 @@ void init_hardware(struct s_hardware *hardware) memset(&hardware->cpu, 0, sizeof(s_cpu)); memset(&hardware->pxe, 0, sizeof(struct s_pxe)); memset(&hardware->vesa, 0, sizeof(struct s_vesa)); + memset(&hardware->vpd, 0, sizeof(s_vpd)); memset(hardware->syslinux_fs, 0, sizeof hardware->syslinux_fs); memset(hardware->pciids_path, 0, sizeof hardware->pciids_path); memset(hardware->modules_pcimap_path, 0, @@ -128,6 +150,30 @@ int detect_dmi(struct s_hardware *hardware) return 0; } +/** + * vpd_detection - populate the VPD structure + * + * VPD is a structure available on IBM machines. + * It is documented at: + * http://www.pc.ibm.com/qtechinfo/MIGR-45120.html + * (XXX the page seems to be gone) + **/ +int detect_vpd(struct s_hardware *hardware) +{ + if (hardware->vpd_detection) + return -1; + else + hardware->vpd_detection = true; + + if (vpd_decode(&hardware->vpd) == -ENOVPDTABLE) { + hardware->is_vpd_valid = false; + return -ENOVPDTABLE; + } else { + hardware->is_vpd_valid = true; + return 0; + } +} + /* Detection vesa stuff*/ int detect_vesa(struct s_hardware *hardware) { static com32sys_t rm; @@ -445,7 +491,7 @@ void clear_screen(void) set_us_g0_charset(); display_cursor(false); clear_entire_screen(); - display_line_nb = 0; + reset_more_printf(); } /* remove begining spaces */ @@ -475,3 +521,7 @@ char *remove_spaces(char *p) return p; } +/* Reset the more_printf counter */ +void reset_more_printf() { + display_line_nb=0; +} diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h index 7fe0e21c..2239fecb 100644 --- a/com32/hdt/hdt-common.h +++ b/com32/hdt/hdt-common.h @@ -38,6 +38,7 @@ #include "dmi/dmi.h" #include "hdt-ata.h" #include "../lib/sys/vesa/vesa.h" +#include <vpd/vpd.h> /* This two values are used for switching for the menu to the CLI mode */ #define HDT_SWITCH_TO_CLI "hdt_switch_to_cli" @@ -107,6 +108,7 @@ struct s_vesa { struct s_hardware { s_dmi dmi; /* DMI table */ s_cpu cpu; /* CPU information */ + s_vpd vpd; /* VPD information */ struct pci_domain *pci_domain; /* PCI Devices */ struct driveinfo disk_info[256]; /* Disk Information */ int disks_count; /* Number of detected disks */ @@ -119,6 +121,7 @@ struct s_hardware { bool is_dmi_valid; bool is_pxe_valid; bool is_vesa_valid; + bool is_vpd_valid; bool dmi_detection; /* Does the dmi stuff has already been detected? */ bool pci_detection; /* Does the pci stuff has already been detected? */ @@ -126,6 +129,7 @@ struct s_hardware { bool disk_detection;/* Does the disk stuff has already been detected? */ bool pxe_detection; /* Does the pxe stuff has already been detected? */ bool vesa_detection;/* Does the vesa sutff have been already detected? */ + bool vpd_detection; /* Does the vpd stuff has already been detected? */ char syslinux_fs[22]; const struct syslinux_version *sv; @@ -134,10 +138,12 @@ struct s_hardware { char memtest_label[255]; }; +void reset_more_printf(); const char *find_argument(const char **argv, const char *argument); char *remove_spaces(char *p); char *skip_spaces(char *p); int detect_dmi(struct s_hardware *hardware); +int detect_vpd(struct s_hardware *hardware); void detect_disks(struct s_hardware *hardware); void detect_pci(struct s_hardware *hardware); void cpu_detect(struct s_hardware *hardware); diff --git a/com32/hdt/hdt-menu-dmi.c b/com32/hdt/hdt-menu-dmi.c index 3915f2bf..fc353eb9 100644 --- a/com32/hdt/hdt-menu-dmi.c +++ b/com32/hdt/hdt-menu-dmi.c @@ -405,7 +405,7 @@ void compute_ipmi(struct s_my_menu *menu, s_dmi * dmi) snprintf(buffer, sizeof buffer, "Spec. Version : %u.%u", dmi->ipmi.major_specification_version, dmi->ipmi.minor_specification_version); - snprintf(statbuffer, sizeof statbuffer, "Specification Version: %u.u", + snprintf(statbuffer, sizeof statbuffer, "Specification Version: %u.%u", dmi->ipmi.major_specification_version, dmi->ipmi.minor_specification_version); add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); @@ -524,7 +524,7 @@ void compute_battery(struct s_my_menu *menu, s_dmi * dmi) snprintf(buffer, sizeof buffer, "Maximum Error : %s", dmi->battery.maximum_error); - snprintf(statbuffer, sizeof statbuffer, "Maximum Error (%) : %s", + snprintf(statbuffer, sizeof statbuffer, "Maximum Error (percent) : %s", dmi->battery.maximum_error); add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); menu->items_count++; diff --git a/com32/hdt/hdt-menu-pci.c b/com32/hdt/hdt-menu-pci.c index 496d5ac1..74c07107 100644 --- a/com32/hdt/hdt-menu-pci.c +++ b/com32/hdt/hdt-menu-pci.c @@ -89,7 +89,7 @@ static void compute_pci_device(struct s_my_menu *menu, menu->items_count++; } - snprintf(buffer,sizeof buffer,"Latency : %d",pci_device->dev_info->latency); + snprintf(buffer, sizeof buffer, "Latency : %d",pci_device->dev_info->latency); snprintf(statbuffer,sizeof statbuffer,"Latency : %d",pci_device->dev_info->latency); add_item(buffer,statbuffer,OPT_INACTIVE,NULL,0); menu->items_count++; diff --git a/com32/hdt/hdt-menu-vpd.c b/com32/hdt/hdt-menu-vpd.c new file mode 100644 index 00000000..817c1079 --- /dev/null +++ b/com32/hdt/hdt-menu-vpd.c @@ -0,0 +1,100 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2009 Pierre-Alexandre Meyer - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- + */ + +#include "hdt-menu.h" + +/** + * compute_vpd - generate vpd menu + **/ +void compute_vpd(struct s_my_menu *menu, struct s_hardware *hardware) +{ + char buffer[SUBMENULEN + 1]; + char statbuffer[STATLEN + 1]; /* Status bar */ + + menu->menu = add_menu(" VPD ", -1); + menu->items_count = 0; + set_menu_pos(SUBMENU_Y, SUBMENU_X); + + snprintf(buffer, sizeof buffer, "Address : %s", + hardware->vpd.base_address); + snprintf(statbuffer, sizeof statbuffer, "Address: %s", + hardware->cpu.vendor); + add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); + menu->items_count++; + + snprintf(buffer, sizeof buffer, "Bios Build ID : %s", + hardware->vpd.bios_build_id); + snprintf(statbuffer, sizeof statbuffer, "Bios Build ID: %s", + hardware->vpd.bios_build_id); + add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); + menu->items_count++; + + snprintf(buffer, sizeof buffer, "Bios Release Date : %s", + hardware->vpd.bios_release_date); + snprintf(statbuffer, sizeof statbuffer, "Bios Release Date: %s", + hardware->vpd.bios_release_date); + add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); + menu->items_count++; + + snprintf(buffer, sizeof buffer, "Bios Version : %s", + hardware->vpd.bios_version); + snprintf(statbuffer, sizeof statbuffer, "Bios Version: %s", + hardware->vpd.bios_version); + add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); + menu->items_count++; + + snprintf(buffer, sizeof buffer, "Default Flash Filename : %s", + hardware->vpd.default_flash_filename); + snprintf(statbuffer, sizeof statbuffer, "Default Flash Filename: %s", + hardware->vpd.default_flash_filename); + add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); + menu->items_count++; + + snprintf(buffer, sizeof buffer, "Box Serial Number : %s", + hardware->vpd.box_serial_number); + snprintf(statbuffer, sizeof statbuffer, "Box Serial Number: %s", + hardware->vpd.box_serial_number); + add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); + menu->items_count++; + + snprintf(buffer, sizeof buffer, "Motherboard Serial Number: %s", + hardware->vpd.motherboard_serial_number); + snprintf(statbuffer, sizeof statbuffer, "Motherboard Serial Number: %s", + hardware->vpd.motherboard_serial_number); + add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); + menu->items_count++; + + snprintf(buffer, sizeof buffer, "Machine Type/Model : %s", + hardware->vpd.machine_type_model); + snprintf(statbuffer, sizeof statbuffer, "Machine Type/Model: %s", + hardware->vpd.machine_type_model); + add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0); + menu->items_count++; + + printf("MENU: VPD menu done (%d items)\n", menu->items_count); +} diff --git a/com32/hdt/hdt-menu.c b/com32/hdt/hdt-menu.c index f7c1ba6f..bac3d21f 100644 --- a/com32/hdt/hdt-menu.c +++ b/com32/hdt/hdt-menu.c @@ -112,7 +112,7 @@ void setup_menu(char *version) { /* Creating the menu */ init_menusystem(version); - set_window_size(0, 0, 24, 80); + set_window_size(0, 0, 25, 80); /* Register the menusystem handler */ // reg_handler(HDLR_SCREEN,&msys_handler); @@ -153,6 +153,7 @@ void compute_submenus(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware) } compute_processor(&(hdt_menu->cpu_menu), hardware); + compute_vpd(&(hdt_menu->vpd_menu), hardware); compute_disks(hdt_menu, hardware->disk_info, hardware); #ifdef WITH_PCI @@ -242,6 +243,12 @@ void compute_main_menu(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware) } } + if (hardware->is_vpd_valid == true) { + add_item("VPD","VPD Information Menu", OPT_SUBMENU, NULL, + hdt_menu->vpd_menu.menu); + hdt_menu->main_menu.items_count++; + } + if (hardware->is_pxe_valid == true) { add_item("P<X>E", "PXE Information Menu", OPT_SUBMENU, NULL, hdt_menu->pxe_menu.menu); @@ -300,6 +307,10 @@ void detect_hardware(struct s_hardware *hardware) hardware->dmi.dmitable.major_version, hardware->dmi.dmitable.minor_version); } + + printf("VPD: Detecting\n"); + detect_vpd(hardware); + #ifdef WITH_PCI detect_pci(hardware); printf("PCI: %d Devices Found\n", hardware->nb_pci_devices); diff --git a/com32/hdt/hdt-menu.h b/com32/hdt/hdt-menu.h index 7b681007..04d6b580 100644 --- a/com32/hdt/hdt-menu.h +++ b/com32/hdt/hdt-menu.h @@ -77,6 +77,7 @@ struct s_hdt_menu { struct s_my_menu vesa_menu; struct s_my_menu vesa_card_menu; struct s_my_menu vesa_modes_menu; + struct s_my_menu vpd_menu; int total_menu_count; // Sum of all menus we have }; @@ -103,6 +104,9 @@ void compute_bios(struct s_my_menu *menu, s_dmi * dmi); void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi, struct s_hardware *hardware); void compute_ipmi(struct s_my_menu *menu, s_dmi * dmi); +// VPD Stuff +void compute_vpd(struct s_my_menu *menu, struct s_hardware *hardware); + // Processor Stuff void compute_processor(struct s_my_menu *menu, struct s_hardware *hardware); diff --git a/com32/hdt/hdt.c b/com32/hdt/hdt.c index 467fe1ca..a2b9b538 100644 --- a/com32/hdt/hdt.c +++ b/com32/hdt/hdt.c @@ -51,16 +51,17 @@ int main(const int argc, const char *argv[]) snprintf(version_string, sizeof version_string, "%s %s by %s", PRODUCT_NAME,VERSION,AUTHOR); + console_ansi_raw(); + /* Cleaning structures */ init_hardware(&hardware); - /* Detecting parameters */ - detect_parameters(argc, argv, &hardware); - /* Detecting Syslinux version */ detect_syslinux(&hardware); - console_ansi_raw(); + /* Detecting parameters */ + detect_parameters(argc, argv, &hardware); + /* Opening the Syslinux console */ // openconsole(&dev_stdcon_r, &dev_ansicon_w); diff --git a/com32/hdt/hdt.h b/com32/hdt/hdt.h index 14c94b36..f05f7a5e 100644 --- a/com32/hdt/hdt.h +++ b/com32/hdt/hdt.h @@ -32,7 +32,7 @@ #define PRODUCT_NAME "Hardware Detection Tool" #define AUTHOR "Erwan Velu" #define CONTACT "erwan(dot)velu(point)free(dot)fr" -#define VERSION "0.2.7" +#define VERSION "0.3.0" #define NB_CONTRIBUTORS 2 #define CONTRIBUTORS {"Pierre-Alexandre Meyer", "Sebastien Gonzalve"} diff --git a/com32/lib/pci/scan.c b/com32/lib/pci/scan.c index 39f743b5..07794102 100644 --- a/com32/lib/pci/scan.c +++ b/com32/lib/pci/scan.c @@ -518,36 +518,24 @@ struct pci_domain *pci_scan(void) /* gathering additional configuration*/ void gather_additional_pci_config(struct pci_domain *domain) { - struct pci_bus *bus = NULL; - struct pci_slot *slot = NULL; - unsigned int nbus, ndev, nfunc, maxfunc; - pciaddr_t a; + struct pci_device *dev; + pciaddr_t pci_addr; int cfgtype; cfgtype = pci_set_config_type(PCI_CFG_AUTO); if (cfgtype == PCI_CFG_NONE) return; - for (nbus = 0; nbus < MAX_PCI_BUSES; nbus++) { - bus = NULL; - - for (ndev = 0; ndev < MAX_PCI_DEVICES; ndev++) { - maxfunc = 1; /* Assume a single-function device */ - slot = NULL; - - for (nfunc = 0; nfunc < maxfunc; nfunc++) { - a = pci_mkaddr(nbus, ndev, nfunc, 0); - struct pci_device *dev = domain->bus[nbus]->slot[ndev]->func[nfunc]; - if (! dev->dev_info) { + for_each_pci_func3(dev, domain,pci_addr) { + if (! dev->dev_info) { dev->dev_info = zalloc(sizeof *dev->dev_info); - if (!dev->dev_info) + if (!dev->dev_info) { return; + } } - dev->dev_info->irq = pci_readb(a + 0x3c); - dev->dev_info->latency = pci_readb(a + 0x0d); - } - } - } + dev->dev_info->irq = pci_readb(pci_addr + 0x3c); + dev->dev_info->latency = pci_readb(pci_addr + 0x0d); + } } diff --git a/com32/menu/menu.h b/com32/menu/menu.h index 43f65947..98b6fa9b 100644 --- a/com32/menu/menu.h +++ b/com32/menu/menu.h @@ -60,6 +60,7 @@ struct menu_entry { int entry; /* Entry number inside menu */ enum menu_action action; unsigned char hotkey; + bool save; /* Save this entry if selected */ }; static inline bool is_disabled(struct menu_entry *me) @@ -149,9 +150,11 @@ struct menu { int nentries; int nentries_space; int defentry; - int allowedit; int timeout; + bool allowedit; + bool save; /* MENU SAVE default for this menu */ + int curentry; int curtop; @@ -174,7 +177,6 @@ extern struct menu *root_menu, *start_menu, *hide_menu, *menu_list; /* These are global parameters regardless of which menu we're displaying */ extern int shiftkey; extern int hiddenmenu; -extern bool menusave; extern long long totaltimeout; void parse_configs(char **argv); diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c index c3da97e4..b3131faf 100644 --- a/com32/menu/menumain.c +++ b/com32/menu/menumain.c @@ -879,7 +879,7 @@ run_menu(void) } if (done && !me->passwd) { /* Only save a new default if we don't have a password... */ - if (menusave && me->label) { + if (me->save && me->label) { syslinux_setadv(ADV_MENUSAVE, strlen(me->label), me->label); syslinux_adv_write(); } diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c index 768591d9..376d8181 100644 --- a/com32/menu/readconfig.c +++ b/com32/menu/readconfig.c @@ -35,11 +35,11 @@ struct menu *root_menu, *start_menu, *hide_menu, *menu_list; int shiftkey = 0; /* Only display menu if shift key pressed */ int hiddenmenu = 0; long long totaltimeout = 0; -bool menusave = false; /* Keep track of global default */ static int has_ui = 0; /* DEFAULT only counts if UI is found */ static const char *globaldefault = NULL; +static bool menusave = false; /* True if there is any "menu save" */ /* Linked list of all entires, hidden or not; used by unlabel() */ static struct menu_entry *all_entries; @@ -174,6 +174,7 @@ static struct menu * new_menu(struct menu *parent, m->allowedit = parent->allowedit; m->timeout = parent->timeout; + m->save = parent->save; m->ontimeout = refstr_get(parent->ontimeout); m->onerror = refstr_get(parent->onerror); @@ -193,7 +194,7 @@ static struct menu * new_menu(struct menu *parent, for (i = 0; i < NPARAMS; i++) m->mparm[i] = mparm[i].value; - m->allowedit = 1; /* Allow edits of the command line */ + m->allowedit = true; /* Allow edits of the command line */ m->color_table = default_color_table(); } @@ -219,6 +220,7 @@ struct labeldata { unsigned int menudisabled; unsigned int menuindent; enum menu_action action; + int save; struct menu *submenu; }; @@ -305,6 +307,7 @@ record(struct menu *m, struct labeldata *ld, const char *append) me->helptext = ld->helptext; me->hotkey = 0; me->action = ld->action ? ld->action : MA_CMD; + me->save = ld->save ? (ld->save > 0) : m->save; if ( ld->menuindent ) { const char *dn; @@ -673,6 +676,15 @@ static void parse_config_file(FILE *f) shiftkey = 1; } else if ( looking_at(p, "save") ) { menusave = true; + if (ld.label) + ld.save = 1; + else + m->save = true; + } else if ( looking_at(p, "nosave") ) { + if (ld.label) + ld.save = -1; + else + m->save = false; } else if ( looking_at(p, "onerror") ) { refstr_put(m->onerror); m->onerror = refstrdup(skipspace(p+7)); @@ -938,7 +950,7 @@ static void parse_config_file(FILE *f) } else if ( looking_at(p, "ontimeout") ) { m->ontimeout = refstrdup(skipspace(p+9)); } else if ( looking_at(p, "allowoptions") ) { - m->allowedit = atoi(skipspace(p+12)); + m->allowedit = !!atoi(skipspace(p+12)); } else if ( looking_at(p, "ipappend") ) { if (ld.label) ld.ipappend = atoi(skipspace(p+8)); diff --git a/com32/rosh/Makefile b/com32/rosh/Makefile index 3895cd89..7bf5059c 100644 --- a/com32/rosh/Makefile +++ b/com32/rosh/Makefile @@ -21,7 +21,7 @@ rosh.o: rosh.h rosh.lo: rosh.h -all: rosh.lnx rosh.c32 +all: rosh.c32 tidy dist: rm -f *.o *.lo *.a *.lst *.elf .*.d *.tmp diff --git a/doc/menu.txt b/doc/menu.txt index 72bc9dca..97e172fc 100644 --- a/doc/menu.txt +++ b/doc/menu.txt @@ -276,6 +276,7 @@ DEFAULT label MENU SAVE +MENU NOSAVE Remember the last entry selected and make that the default for the next boot. A password-protected menu entry is *not* @@ -289,7 +290,12 @@ MENU SAVE file gracefully. The MENU SAVE information can be cleared with - "extlinux --reset-adv". + "extlinux --reset-adv <bootdir>". + + A MENU SAVE or MENU NOSAVE at the top of a (sub)menu affects + all entries underneath that (sub)menu except those that in + turn have MENU SAVE or MENU NOSAVE declared. This can be used + to only save certain entires when selected. INCLUDE filename [tagname] diff --git a/doc/syslinux.txt b/doc/syslinux.txt index 72f38d34..94141415 100644 --- a/doc/syslinux.txt +++ b/doc/syslinux.txt @@ -2,7 +2,7 @@ A suite of bootloaders for Linux - Copyright 1994-2008 H. Peter Anvin - All Rights Reserved + Copyright 1994-2009 H. Peter Anvin and contributors This program is provided under the terms of the GNU General Public License, version 2 or, at your option, any later version. There is no @@ -271,7 +271,7 @@ LABEL label This is mostly useful for initramfs, which can be composed of multiple separate cpio or cpio.gz archives. Note: all files except the last one are zero-padded to a - 4K page boundary. This should not affect initramfs.) + 4K page boundary. This should not affect initramfs. IMPLICIT flag_val If flag_val is 0, do not load a kernel image unless it has been diff --git a/gpxe/src/arch/i386/firmware/pcbios/e820mangler.S b/gpxe/src/arch/i386/firmware/pcbios/e820mangler.S index 4ba3fb14..decb0835 100644 --- a/gpxe/src/arch/i386/firmware/pcbios/e820mangler.S +++ b/gpxe/src/arch/i386/firmware/pcbios/e820mangler.S @@ -490,6 +490,18 @@ get_mangled_e820: .size get_mangled_e820, . - get_mangled_e820 /**************************************************************************** + * Set/clear CF on the stack as appropriate, assumes stack is as it should + * be immediately before IRET + **************************************************************************** + */ +patch_cf: + pushw %bp + movw %sp, %bp + setc 8(%bp) /* Set/reset CF; clears PF, AF, ZF, SF */ + popw %bp + ret + +/**************************************************************************** * INT 15,e820 handler **************************************************************************** */ @@ -500,7 +512,8 @@ int15_e820: popw %ds call get_mangled_e820 popw %ds - lret $2 + call patch_cf + iret .size int15_e820, . - int15_e820 /**************************************************************************** @@ -512,7 +525,7 @@ int15_e801: /* Call previous handler */ pushfw lcall *%cs:int15_vector - pushfw + call patch_cf /* Edit result */ pushw %ds pushw %cs:rm_ds @@ -524,9 +537,7 @@ int15_e801: xchgw %ax, %cx xchgw %bx, %dx popw %ds - /* Restore flags returned by previous handler and return */ - popfw - lret $2 + iret .size int15_e801, . - int15_e801 /**************************************************************************** @@ -538,16 +549,14 @@ int15_88: /* Call previous handler */ pushfw lcall *%cs:int15_vector - pushfw + call patch_cf /* Edit result */ pushw %ds pushw %cs:rm_ds popw %ds call patch_1m popw %ds - /* Restore flags returned by previous handler and return */ - popfw - lret $2 + iret .size int15_88, . - int15_88 /**************************************************************************** diff --git a/gpxe/src/arch/i386/firmware/pcbios/fakee820.c b/gpxe/src/arch/i386/firmware/pcbios/fakee820.c index e171edfd..552bf41d 100644 --- a/gpxe/src/arch/i386/firmware/pcbios/fakee820.c +++ b/gpxe/src/arch/i386/firmware/pcbios/fakee820.c @@ -63,6 +63,8 @@ void fake_e820 ( void ) { "cmpl $0x534d4150, %%edx\n\t" "jne 99f\n\t" "pushaw\n\t" + "movw %%sp, %%bp\n\t" + "andb $~0x01, 22(%%bp)\n\t" /* Clear return CF */ "leaw e820map(%%bx), %%si\n\t" "cs rep movsb\n\t" "popaw\n\t" @@ -73,8 +75,7 @@ void fake_e820 ( void ) { "xorl %%ebx,%%ebx\n\t" "\n1:\n\t" "popfw\n\t" - "clc\n\t" - "lret $2\n\t" + "iret\n\t" "\n99:\n\t" "popfw\n\t" "ljmp *%%cs:real_int15_vector\n\t" ) diff --git a/gpxe/src/arch/i386/interface/pxe/pxe_entry.S b/gpxe/src/arch/i386/interface/pxe/pxe_entry.S index 22ef4181..0e8c8e2d 100644 --- a/gpxe/src/arch/i386/interface/pxe/pxe_entry.S +++ b/gpxe/src/arch/i386/interface/pxe/pxe_entry.S @@ -199,9 +199,12 @@ pxe_int_1a: shll $4, %edx addl $pxenv, %edx movw $0x564e, %ax + pushw %bp + movw %sp, %bp + andb $~0x01, 8(%bp) /* Clear CF on return */ + popw %bp popfw - clc - lret $2 + iret 1: /* INT 1A,other - pass through */ popfw ljmp *%cs:pxe_int_1a_vector |