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>
}
}
-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);
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);
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 ) {
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 */
},
};
+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,
.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,
.mode = HDT_MODE,
.name = CLI_HDT,
.default_modules = &hdt_default_modules,
- .show_modules = NULL,
+ .show_modules = &hdt_show_modules,
.set_modules = &hdt_set_modules,
};
#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;
}
}
-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);
#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));
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();
#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);
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();
#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");
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) ) {
&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
*/
find_cli_callback_descr(command, current_mode->default_modules,
¤t_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,
¤t_module);
return;
}
- printf("Command '%s' unknown.\n", command);
+ printf("Command '%s' incorrect. See `help'.\n", command);
}
}
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;
}
}
}
-
-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);
-}
#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