aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
authorPierre-Alexandre Meyer <pierre@mouraf.org>2009-03-21 17:46:34 -0700
committerPierre-Alexandre Meyer <pierre@mouraf.org>2009-03-21 17:46:34 -0700
commit20a0f44277a8682beecf2042037b4920f6b24ea7 (patch)
tree0995480b645108224036d350eeca52fb463620d3 /com32
parent38811ac13b3e4f32aa781545e04f1edf308e16b6 (diff)
downloadsyslinux.git-20a0f44277a8682beecf2042037b4920f6b24ea7.tar.gz
syslinux.git-20a0f44277a8682beecf2042037b4920f6b24ea7.tar.xz
syslinux.git-20a0f44277a8682beecf2042037b4920f6b24ea7.zip
hdt: Implement show commands (hdt mode) with the new framework
Impact: Cleanups. The summary of each mode (show <module> in hdt mode) is now implemented using the new framework, as show modules of the hdt mode. Misc.: cleanups. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
Diffstat (limited to 'com32')
-rw-r--r--com32/hdt/hdt-cli-cpu.c3
-rw-r--r--com32/hdt/hdt-cli-dmi.c3
-rw-r--r--com32/hdt/hdt-cli-hdt.c94
-rw-r--r--com32/hdt/hdt-cli-kernel.c3
-rw-r--r--com32/hdt/hdt-cli-pci.c3
-rw-r--r--com32/hdt/hdt-cli-pxe.c5
-rw-r--r--com32/hdt/hdt-cli-syslinux.c5
-rw-r--r--com32/hdt/hdt-cli-vesa.c6
-rw-r--r--com32/hdt/hdt-cli.c102
-rw-r--r--com32/hdt/hdt-cli.h14
10 files changed, 119 insertions, 119 deletions
diff --git a/com32/hdt/hdt-cli-cpu.c b/com32/hdt/hdt-cli-cpu.c
index cfd66ef7..b57c1656 100644
--- a/com32/hdt/hdt-cli-cpu.c
+++ b/com32/hdt/hdt-cli-cpu.c
@@ -169,7 +169,8 @@ void handle_cpu_commands(char *cli_line, struct s_hardware *hardware)
}
}
-void main_show_cpu(struct s_hardware *hardware)
+void main_show_cpu(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
cpu_detect(hardware);
detect_dmi(hardware);
diff --git a/com32/hdt/hdt-cli-dmi.c b/com32/hdt/hdt-cli-dmi.c
index bc09e2d5..6fb954e5 100644
--- a/com32/hdt/hdt-cli-dmi.c
+++ b/com32/hdt/hdt-cli-dmi.c
@@ -330,7 +330,8 @@ static void show_dmi_memory_bank(int argc, char** argv,
hardware->dmi.memory[bank].part_number);
}
-void main_show_dmi(struct s_hardware *hardware)
+void main_show_dmi(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
detect_dmi(hardware);
diff --git a/com32/hdt/hdt-cli-hdt.c b/com32/hdt/hdt-cli-hdt.c
index 296bead6..fe2c11ee 100644
--- a/com32/hdt/hdt-cli-hdt.c
+++ b/com32/hdt/hdt-cli-hdt.c
@@ -108,17 +108,27 @@ static void show_cli_help(int argc __unused, char** argv __unused,
printf("%s ",
current_mode->default_modules->modules[j].name);
}
+ printf("\n");
}
/* List secondly the show modules of the mode */
if (current_mode->show_modules != NULL ) {
- more_printf("show commands:\n");
+ printf("show commands:\n");
for (j = 0; j < current_mode->show_modules->nb_modules; j++) {
- printf(" %s\n",
+ printf("\t%s\n",
current_mode->show_modules->modules[j].name);
}
}
+ /* List thirdly the set modules of the mode */
+ if (current_mode->set_modules != NULL ) {
+ printf("set commands:\n");
+ for (j = 0; j < current_mode->set_modules->nb_modules; j++) {
+ printf("\t%s\n",
+ current_mode->set_modules->modules[j].name);
+ }
+ }
+
/* List finally the default modules of the hdt mode */
if (current_mode->mode != hdt_mode.mode &&
hdt_mode.default_modules != NULL ) {
@@ -137,8 +147,44 @@ static void show_cli_help(int argc __unused, char** argv __unused,
printf("%s ",
hdt_mode.default_modules->modules[j].name);
}
+ printf("\n");
}
- printf("\n");
+}
+
+/**
+ * main_show_summary - give an overview of the system
+ **/
+void main_show_summary(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
+ detect_pci(hardware); /* pxe is detected in the pci */
+ detect_dmi(hardware);
+ cpu_detect(hardware);
+ clear_screen();
+ main_show_cpu(argc, argv, hardware);
+ if (hardware->is_dmi_valid) {
+ 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(" Serial : %s\n",
+ hardware->dmi.system.serial);
+ more_printf("Bios\n");
+ more_printf(" Version : %s\n", hardware->dmi.bios.version);
+ more_printf(" Release : %s\n",
+ hardware->dmi.bios.release_date);
+
+ int argc = 2;
+ char *argv[2] = { "0", "0" };
+ show_dmi_memory_modules(argc, argv, hardware);
+ }
+ main_show_pci(argc, argv, hardware);
+
+ if (hardware->is_pxe_valid)
+ main_show_pxe(argc, argv, hardware);
+
+ main_show_kernel(argc, argv, hardware);
}
/* Default hdt mode */
@@ -157,6 +203,41 @@ struct cli_callback_descr list_hdt_default_modules[] = {
},
};
+struct cli_callback_descr list_hdt_show_modules[] = {
+ {
+ .name = CLI_SUMMARY,
+ .exec = main_show_summary,
+ },
+ {
+ .name = CLI_PCI,
+ .exec = main_show_pci,
+ },
+ {
+ .name = CLI_DMI,
+ .exec = main_show_dmi,
+ },
+ {
+ .name = CLI_CPU,
+ .exec = main_show_cpu,
+ },
+ {
+ .name = CLI_PXE,
+ .exec = main_show_pxe,
+ },
+ {
+ .name = CLI_SYSLINUX,
+ .exec = main_show_syslinux,
+ },
+ {
+ .name = CLI_KERNEL,
+ .exec = main_show_kernel,
+ },
+ {
+ .name = CLI_VESA,
+ .exec = main_show_vesa,
+ },
+};
+
struct cli_callback_descr list_hdt_set_modules[] = {
{
.name = CLI_MODE,
@@ -169,6 +250,11 @@ struct cli_module_descr hdt_default_modules = {
.nb_modules = 3,
};
+struct cli_module_descr hdt_show_modules = {
+ .modules = list_hdt_show_modules,
+ .nb_modules = 8,
+};
+
struct cli_module_descr hdt_set_modules = {
.modules = list_hdt_set_modules,
.nb_modules = 1,
@@ -178,6 +264,6 @@ struct cli_mode_descr hdt_mode = {
.mode = HDT_MODE,
.name = CLI_HDT,
.default_modules = &hdt_default_modules,
- .show_modules = NULL,
+ .show_modules = &hdt_show_modules,
.set_modules = &hdt_set_modules,
};
diff --git a/com32/hdt/hdt-cli-kernel.c b/com32/hdt/hdt-cli-kernel.c
index 5b0df1d2..5a828766 100644
--- a/com32/hdt/hdt-cli-kernel.c
+++ b/com32/hdt/hdt-cli-kernel.c
@@ -34,7 +34,8 @@
#include "hdt-cli.h"
#include "hdt-common.h"
-void main_show_kernel(struct s_hardware *hardware)
+void main_show_kernel(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
char buffer[1024];
struct pci_device *pci_device;
diff --git a/com32/hdt/hdt-cli-pci.c b/com32/hdt/hdt-cli-pci.c
index 31cfe771..b5a4252d 100644
--- a/com32/hdt/hdt-cli-pci.c
+++ b/com32/hdt/hdt-cli-pci.c
@@ -299,7 +299,8 @@ void cli_detect_pci(struct s_hardware *hardware)
}
}
-void main_show_pci(struct s_hardware *hardware)
+void main_show_pci(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
cli_detect_pci(hardware);
diff --git a/com32/hdt/hdt-cli-pxe.c b/com32/hdt/hdt-cli-pxe.c
index 772c0dfd..f7972b0c 100644
--- a/com32/hdt/hdt-cli-pxe.c
+++ b/com32/hdt/hdt-cli-pxe.c
@@ -36,7 +36,8 @@
#include "hdt-cli.h"
#include "hdt-common.h"
-void main_show_pxe(struct s_hardware *hardware)
+void main_show_pxe(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
{
char buffer[81];
memset(buffer, 0, sizeof(81));
@@ -85,7 +86,7 @@ static void show_pxe_help()
static void pxe_show(char *item, struct s_hardware *hardware)
{
if (!strncmp(item, CLI_SHOW_LIST, sizeof(CLI_SHOW_LIST) - 1)) {
- main_show_pxe(hardware);
+ main_show_pxe(0, NULL, hardware);
return;
}
show_pxe_help();
diff --git a/com32/hdt/hdt-cli-syslinux.c b/com32/hdt/hdt-cli-syslinux.c
index 77a44f31..e483864c 100644
--- a/com32/hdt/hdt-cli-syslinux.c
+++ b/com32/hdt/hdt-cli-syslinux.c
@@ -36,7 +36,8 @@
#include "hdt-cli.h"
#include "hdt-common.h"
-void main_show_syslinux(struct s_hardware *hardware)
+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);
@@ -55,7 +56,7 @@ static void show_syslinux_help()
static void syslinux_show(char *item, struct s_hardware *hardware)
{
if (!strncmp(item, CLI_SHOW_LIST, sizeof(CLI_SHOW_LIST) - 1)) {
- main_show_syslinux(hardware);
+ main_show_syslinux(0, NULL, hardware);
return;
}
show_syslinux_help();
diff --git a/com32/hdt/hdt-cli-vesa.c b/com32/hdt/hdt-cli-vesa.c
index e6843eea..a48227df 100644
--- a/com32/hdt/hdt-cli-vesa.c
+++ b/com32/hdt/hdt-cli-vesa.c
@@ -33,7 +33,9 @@
#include <stdlib.h>
#include <errno.h>
-void main_show_vesa(struct s_hardware *hardware) {
+void main_show_vesa(int argc __unused, char **argv __unused,
+ struct s_hardware *hardware)
+{
detect_vesa(hardware);
if (hardware->is_vesa_valid==false) {
more_printf("No VESA BIOS detected\n");
@@ -72,7 +74,7 @@ static void show_vesa_help() {
static void vesa_show(char *item, struct s_hardware *hardware) {
if ( !strncmp(item, CLI_SHOW_LIST, sizeof(CLI_SHOW_LIST) - 1) ) {
- main_show_vesa(hardware);
+ main_show_vesa(0, NULL, hardware);
return;
}
if ( !strncmp(item, CLI_MODES, sizeof(CLI_MODES) - 1) ) {
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 1b1fded7..99163c41 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -38,16 +38,6 @@ struct cli_mode_descr *list_modes[] = {
&dmi_mode,
};
-static void handle_hdt_commands(char *cli_line, struct s_hardware *hardware)
-{
- /* hdt cli mode specific commands */
- if (!strncmp(cli_line, CLI_SHOW, sizeof(CLI_SHOW) - 1)) {
- main_show(strstr(cli_line, "show") + sizeof(CLI_SHOW),
- hardware);
- return;
- }
-}
-
/**
* set_mode - set the current mode of the cli
* @mode: mode to set
@@ -309,8 +299,10 @@ static void exec_command(char *line,
*/
find_cli_callback_descr(command, current_mode->default_modules,
&current_module);
- if (current_module != NULL)
+ if (current_module != NULL) {
current_module->exec(argc, argv, hardware);
+ return;
+ }
else {
find_cli_callback_descr(command, hdt_mode.default_modules,
&current_module);
@@ -319,7 +311,7 @@ static void exec_command(char *line,
return;
}
- printf("Command '%s' unknown.\n", command);
+ printf("Command '%s' incorrect. See `help'.\n", command);
}
}
@@ -363,9 +355,6 @@ old_cli:
case PCI_MODE:
handle_pci_commands(line, hardware);
break;
- case HDT_MODE:
- handle_hdt_commands(line, hardware);
- break;
case CPU_MODE:
handle_cpu_commands(line, hardware);
break;
@@ -556,86 +545,3 @@ void start_cli_mode(struct s_hardware *hardware)
}
}
}
-
-static void main_show_summary(struct s_hardware *hardware)
-{
- detect_pci(hardware); /* pxe is detected in the pci */
- detect_dmi(hardware);
- cpu_detect(hardware);
- clear_screen();
- main_show_cpu(hardware);
- if (hardware->is_dmi_valid) {
- 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(" Serial : %s\n",
- hardware->dmi.system.serial);
- more_printf("Bios\n");
- more_printf(" Version : %s\n", hardware->dmi.bios.version);
- more_printf(" Release : %s\n",
- hardware->dmi.bios.release_date);
-
- int argc = 2;
- char *argv[2] = { "0", "0" };
- show_dmi_memory_modules(argc, argv, hardware);
- }
- main_show_pci(hardware);
-
- if (hardware->is_pxe_valid)
- main_show_pxe(hardware);
-
- main_show_kernel(hardware);
-}
-
-void show_main_help(struct s_hardware *hardware)
-{
- more_printf("Show supports the following commands : \n");
- more_printf(" %s\n", CLI_SUMMARY);
- more_printf(" %s\n", CLI_PCI);
- more_printf(" %s\n", CLI_DMI);
- more_printf(" %s\n", CLI_CPU);
- more_printf(" %s\n", CLI_KERNEL);
- more_printf(" %s\n", CLI_SYSLINUX);
- more_printf(" %s\n", CLI_VESA);
- if (hardware->sv->filesystem == SYSLINUX_FS_PXELINUX)
- more_printf(" %s\n", CLI_PXE);
-}
-
-void main_show(char *item, struct s_hardware *hardware)
-{
- if (!strncmp(item, CLI_SUMMARY, sizeof(CLI_SUMMARY))) {
- main_show_summary(hardware);
- return;
- }
- if (!strncmp(item, CLI_PCI, sizeof(CLI_PCI))) {
- main_show_pci(hardware);
- return;
- }
- if (!strncmp(item, CLI_DMI, sizeof(CLI_DMI))) {
- main_show_dmi(hardware);
- return;
- }
- if (!strncmp(item, CLI_CPU, sizeof(CLI_CPU))) {
- main_show_cpu(hardware);
- return;
- }
- if (!strncmp(item, CLI_PXE, sizeof(CLI_PXE))) {
- main_show_pxe(hardware);
- return;
- }
- if (!strncmp(item, CLI_SYSLINUX, sizeof(CLI_SYSLINUX))) {
- main_show_syslinux(hardware);
- return;
- }
- if (!strncmp(item, CLI_KERNEL, sizeof(CLI_KERNEL))) {
- main_show_kernel(hardware);
- return;
- }
- if (!strncmp(item, CLI_VESA, sizeof(CLI_VESA))) {
- main_show_vesa(hardware);
- return;
- }
- show_main_help(hardware);
-}
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 4bb9566d..186c015a 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -140,33 +140,33 @@ void main_show(char *item, struct s_hardware *hardware);
#define CLI_DMI_SYSTEM "system"
#define CLI_DMI_LIST CLI_SHOW_LIST
#define CLI_DMI_MAX_MODULES 9
-void main_show_dmi(struct s_hardware *hardware);
+void main_show_dmi(int argc, char **argv, struct s_hardware *hardware);
void handle_dmi_commands(char *cli_line, struct s_hardware *hardware);
void show_dmi_memory_modules(int argc, char** argv, struct s_hardware *hardware);
// PCI STUFF
#define CLI_PCI_DEVICE "device"
-void main_show_pci(struct s_hardware *hardware);
+void main_show_pci(int argc, char **argv, struct s_hardware *hardware);
void handle_pci_commands(char *cli_line, struct s_hardware *hardware);
void cli_detect_pci(struct s_hardware *hardware);
// CPU STUFF
-void main_show_cpu(struct s_hardware *hardware);
+void main_show_cpu(int argc, char **argv, struct s_hardware *hardware);
void handle_cpu_commands(char *cli_line, struct s_hardware *hardware);
// PXE STUFF
-void main_show_pxe(struct s_hardware *hardware);
+void main_show_pxe(int argc, char **argv, struct s_hardware *hardware);
void handle_pxe_commands(char *cli_line, struct s_hardware *hardware);
// KERNEL STUFF
-void main_show_kernel(struct s_hardware *hardware);
+void main_show_kernel(int argc, char **argv, struct s_hardware *hardware);
void handle_kernel_commands(char *cli_line, struct s_hardware *hardware);
// SYSLINUX STUFF
-void main_show_syslinux(struct s_hardware *hardware);
+void main_show_syslinux(int argc, char **argv, struct s_hardware *hardware);
void handle_syslinux_commands(char *cli_line, struct s_hardware *hardware);
// VESA STUFF
-void main_show_vesa(struct s_hardware *hardware);
+void main_show_vesa(int argc, char **argv, struct s_hardware *hardware);
void handle_vesa_commands(char *cli_line, struct s_hardware *hardware);
#endif