diff options
author | Pierre-Alexandre Meyer <pierre@mouraf.org> | 2009-04-17 16:29:49 -0700 |
---|---|---|
committer | Pierre-Alexandre Meyer <pierre@mouraf.org> | 2009-04-17 16:29:49 -0700 |
commit | 569617a6dceca02dea5c72f48911f8987a34f6d4 (patch) | |
tree | 590e00049dfa37250b117456d7ec75c48ac32706 | |
parent | a9d9adb8b91ea55007cbf5873ec322bca9c1d012 (diff) | |
download | hdt-569617a6dceca02dea5c72f48911f8987a34f6d4.tar.gz hdt-569617a6dceca02dea5c72f48911f8987a34f6d4.tar.xz hdt-569617a6dceca02dea5c72f48911f8987a34f6d4.zip |
hdt: Add vpd mode (CLI)
Add the vpd mode to dump the vpd structure, if found.
Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
-rw-r--r-- | com32/hdt/hdt-cli-vpd.c | 74 | ||||
-rw-r--r-- | com32/hdt/hdt-cli.c | 12 | ||||
-rw-r--r-- | com32/hdt/hdt-cli.h | 3 | ||||
-rw-r--r-- | com32/hdt/hdt-common.c | 27 | ||||
-rw-r--r-- | com32/hdt/hdt-common.h | 5 |
5 files changed, 121 insertions, 0 deletions
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 1e13759e..871fd76c 100644 --- a/com32/hdt/hdt-cli.c +++ b/com32/hdt/hdt-cli.c @@ -43,6 +43,7 @@ struct cli_mode_descr *list_modes[] = { &cpu_mode, &pci_mode, &vesa_mode, + &vpd_mode, NULL, }; @@ -178,6 +179,17 @@ void set_mode(cli_mode_t mode, struct s_hardware* hardware) snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ", CLI_DMI); 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 */ printf("Unknown mode, please choose among:\n"); diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h index 666af95d..516d2fc8 100644 --- a/com32/hdt/hdt-cli.h +++ b/com32/hdt/hdt-cli.h @@ -67,6 +67,7 @@ #define CLI_SHOW_LIST "list" #define CLI_IRQ "irq" #define CLI_MODES "modes" +#define CLI_VPD "vpd" typedef enum { INVALID_MODE, @@ -79,6 +80,7 @@ typedef enum { KERNEL_MODE, SYSLINUX_MODE, VESA_MODE, + VPD_MODE, } cli_mode_t; #define PROMPT_SIZE 32 @@ -136,6 +138,7 @@ struct cli_mode_descr kernel_mode; struct cli_mode_descr cpu_mode; struct cli_mode_descr pci_mode; struct cli_mode_descr vesa_mode; +struct cli_mode_descr vpd_mode; /* cli helpers */ void find_cli_mode_descr(cli_mode_t mode, struct cli_mode_descr **mode_found); diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c index cb53f9e7..68dca510 100644 --- a/com32/hdt/hdt-common.c +++ b/com32/hdt/hdt-common.c @@ -106,9 +106,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 */ @@ -117,6 +119,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, @@ -146,6 +149,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; diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h index 11e14669..65affc5b 100644 --- a/com32/hdt/hdt-common.h +++ b/com32/hdt/hdt-common.h @@ -36,6 +36,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" @@ -94,6 +95,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 diskinfo disk_info[256]; /* Disk Information */ int disks_count; /* Number of detected disks */ @@ -106,6 +108,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? */ @@ -113,6 +116,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; @@ -126,6 +130,7 @@ 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); |