aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Alexandre Meyer <pierre@mouraf.org>2009-04-22 23:57:33 -0700
committerPierre-Alexandre Meyer <pierre@mouraf.org>2009-04-22 23:57:33 -0700
commitd0a0e562d9554cb38650f64be6e9dab9c29d99de (patch)
tree8d95b1534e44569f7d0093230d2b755a329f1903
parent272c28d921ee807dc4c20634873af4b64765cacf (diff)
parent13c60849867ecc575b8f28dc259705b772611402 (diff)
downloadsyslinux.git-d0a0e562d9554cb38650f64be6e9dab9c29d99de.tar.gz
syslinux.git-d0a0e562d9554cb38650f64be6e9dab9c29d99de.tar.xz
syslinux.git-d0a0e562d9554cb38650f64be6e9dab9c29d99de.zip
Merge commit 'mouraf/for-erwan' into for-erwan
Conflicts: com32/hdt/hdt-cli-hdt.c
-rw-r--r--com32/hdt/hdt-cli-cpu.c1
-rw-r--r--com32/hdt/hdt-cli-dmi.c5
-rw-r--r--com32/hdt/hdt-cli-hdt.c54
-rw-r--r--com32/hdt/hdt-cli-kernel.c1
-rw-r--r--com32/hdt/hdt-cli-pci.c5
-rw-r--r--com32/hdt/hdt-cli-pxe.c1
-rw-r--r--com32/hdt/hdt-cli-syslinux.c1
-rw-r--r--com32/hdt/hdt-cli-vesa.c5
-rw-r--r--com32/hdt/hdt-cli-vpd.c74
-rw-r--r--com32/hdt/hdt-cli.c69
-rw-r--r--com32/hdt/hdt-cli.h8
-rw-r--r--com32/hdt/hdt-common.c27
-rw-r--r--com32/hdt/hdt-common.h5
-rw-r--r--com32/hdt/hdt-menu-vpd.c100
-rw-r--r--com32/hdt/hdt-menu.c11
-rw-r--r--com32/hdt/hdt-menu.h4
16 files changed, 322 insertions, 49 deletions
diff --git a/com32/hdt/hdt-cli-cpu.c b/com32/hdt/hdt-cli-cpu.c
index ec5e3b6a..f0f0a1bb 100644
--- a/com32/hdt/hdt-cli-cpu.c
+++ b/com32/hdt/hdt-cli-cpu.c
@@ -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 742c5fad..d395c672 100644
--- a/com32/hdt/hdt-cli-dmi.c
+++ b/com32/hdt/hdt-cli-dmi.c
@@ -475,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 8b92e939..46f3669a 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;
printf("Available modes:\n");
- for (i = 0; i < MAX_MODES; i++)
+ while (list_modes[i]) {
printf("\t%s\n", list_modes[i]->name);
+ i++;
+ }
}
/**
@@ -108,7 +110,7 @@ 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;
@@ -117,36 +119,46 @@ static void show_cli_help(int argc __unused, char** argv __unused,
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) {
printf("%s ",
current_mode->default_modules->modules[j].name);
+ j++;
}
printf("\n");
}
/* List secondly the show modules of the mode */
- if (current_mode->show_modules != NULL &&
- current_mode->show_modules->nb_modules != 0) {
+ if (current_mode->show_modules &&
+ current_mode->show_modules->modules) {
printf("show commands:\n");
- for (j = 0; j < current_mode->show_modules->nb_modules; j++)
+ j = 0;
+ while (current_mode->show_modules->modules[j].name) {
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) {
+ if (current_mode->set_modules &&
+ current_mode->set_modules->modules) {
printf("set commands:\n");
- for (j = 0; j < current_mode->set_modules->nb_modules; j++)
+ j = 0;
+ while (current_mode->set_modules->modules[j].name) {
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
@@ -160,6 +172,7 @@ static void show_cli_help(int argc __unused, char** argv __unused,
if (associated_module == NULL)
printf("%s ",
hdt_mode.default_modules->modules[j].name);
+ j++;
}
printf("\n");
}
@@ -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 7aec1faa..d9ba27f8 100644
--- a/com32/hdt/hdt-cli-kernel.c
+++ b/com32/hdt/hdt-cli-kernel.c
@@ -146,7 +146,6 @@ static void show_kernel_modules(int argc __unused, char **argv __unused,
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 aa6347ac..39bc0fb9 100644
--- a/com32/hdt/hdt-cli-pci.c
+++ b/com32/hdt/hdt-cli-pci.c
@@ -269,11 +269,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,
};
diff --git a/com32/hdt/hdt-cli-pxe.c b/com32/hdt/hdt-cli-pxe.c
index 9dd6c845..1d00cae5 100644
--- a/com32/hdt/hdt-cli-pxe.c
+++ b/com32/hdt/hdt-cli-pxe.c
@@ -80,7 +80,6 @@ void main_show_pxe(int argc __unused, char **argv __unused,
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 99741826..0d78bc66 100644
--- a/com32/hdt/hdt-cli-syslinux.c
+++ b/com32/hdt/hdt-cli-syslinux.c
@@ -49,7 +49,6 @@ void main_show_syslinux(int argc __unused, char **argv __unused,
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 1b07351d..70d1dc61 100644
--- a/com32/hdt/hdt-cli-vesa.c
+++ b/com32/hdt/hdt-cli-vesa.c
@@ -83,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 8700dacc..871fd76c 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -43,6 +43,8 @@ struct cli_mode_descr *list_modes[] = {
&cpu_mode,
&pci_mode,
&vesa_mode,
+ &vpd_mode,
+ NULL,
};
/*
@@ -115,7 +117,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:
@@ -177,11 +179,24 @@ 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");
- for (i = 0; i < MAX_MODES; i++)
+ while (list_modes[i]) {
printf("\t%s\n", list_modes[i]->name);
+ i++;
+ }
}
find_cli_mode_descr(hdt_cli.mode, &current_mode);
@@ -199,12 +214,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;
@@ -221,17 +238,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];
}
/**
@@ -413,13 +430,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;
@@ -440,7 +457,7 @@ 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' */
@@ -457,18 +474,20 @@ 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) {
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) {
@@ -476,6 +495,7 @@ static void autocomplete_command(char *command)
current_mode->default_modules->modules[j].name);
autocomplete_add_token_to_list(current_mode->default_modules->modules[j].name);
}
+ j++;
}
/*
@@ -485,7 +505,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
@@ -504,6 +525,7 @@ static void autocomplete_command(char *command)
hdt_mode.default_modules->modules[j].name);
autocomplete_add_token_to_list(hdt_mode.default_modules->modules[j].name);
}
+ j++;
}
}
@@ -519,11 +541,11 @@ 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) {
@@ -533,9 +555,11 @@ static void autocomplete_module(char *command, char* module)
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) {
@@ -545,6 +569,7 @@ static void autocomplete_module(char *command, char* module)
CLI_SET, current_mode->set_modules->modules[j].name);
autocomplete_add_token_to_list(autocomplete_full_line);
}
+ j++;
}
}
}
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 0b15fe97..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
@@ -109,7 +111,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 );
};
@@ -128,8 +129,7 @@ struct cli_alias {
};
/* List of implemented modes */
-#define MAX_MODES 8
-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;
@@ -138,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);
@@ -161,7 +162,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 f9b0dd80..8cda7f06 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 071db90b..7e3dc7d8 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;
@@ -127,6 +131,7 @@ char *remove_spaces(char *p);
char *skip_spaces(char *p);
char *del_multi_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-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 be0b4723..18158ae3 100644
--- a/com32/hdt/hdt-menu.c
+++ b/com32/hdt/hdt-menu.c
@@ -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);
@@ -299,6 +306,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 91809e2d..70fdb385 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);