aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErwan Velu <erwan.velu@free.fr>2009-02-22 17:51:11 +0100
committerH. Peter Anvin <hpa@zytor.com>2009-02-25 20:58:44 -0800
commit4675b2b23fbd096e385df865f9f628b228401e99 (patch)
tree50ed1b024084e87d2cb2a5a886f627afbba39154
parentc1dbfc8e0951131aead115abcc371337aed41404 (diff)
downloadsyslinux-elf-4675b2b23fbd096e385df865f9f628b228401e99.tar.gz
syslinux-elf-4675b2b23fbd096e385df865f9f628b228401e99.tar.xz
syslinux-elf-4675b2b23fbd096e385df865f9f628b228401e99.zip
hdt: Enabling "Switch to CLI" from the menu Menu: switch from "PCI <D>evice" to "PC<I> Device" to avoid conflit with the "Disk" menu Sharing s_hardware between CLI & Menu system
-rw-r--r--com32/hdt/hdt-cli.c20
-rw-r--r--com32/hdt/hdt-cli.h2
-rw-r--r--com32/hdt/hdt-common.h4
-rw-r--r--com32/hdt/hdt-menu.c20
-rw-r--r--com32/hdt/hdt-menu.h2
-rw-r--r--com32/hdt/hdt.c13
6 files changed, 36 insertions, 25 deletions
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index ebb2abcc..d86c6cb1 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -72,15 +72,11 @@ void handle_hdt_commands(char *cli_line, struct s_cli_mode *cli_mode, struct s_h
}
/* Code that manage the cli mode */
-void start_cli_mode(int argc, char *argv[]) {
+void start_cli_mode(struct s_hardware *hardware, int argc, char *argv[]) {
char cli_line[256];
- struct s_hardware hardware;
struct s_cli_mode cli_mode;
- /* Cleaning structures */
- init_hardware(&hardware);
-
- set_mode(&cli_mode,HDT_MODE,&hardware);
+ set_mode(&cli_mode,HDT_MODE,hardware);
printf("Entering CLI mode\n");
@@ -96,7 +92,7 @@ void start_cli_mode(int argc, char *argv[]) {
int mode=do_exit(&cli_mode);
if (mode == EXIT_MODE)
return;
- set_mode(&cli_mode,mode,&hardware);
+ set_mode(&cli_mode,mode,hardware);
continue;
}
@@ -106,7 +102,7 @@ void start_cli_mode(int argc, char *argv[]) {
}
if ( !strncmp(cli_line, CLI_PCI, sizeof(CLI_PCI) - 1) ) {
- set_mode(&cli_mode,PCI_MODE,&hardware);
+ set_mode(&cli_mode,PCI_MODE,hardware);
continue;
}
if ( !strncmp(cli_line, CLI_CLEAR, sizeof(CLI_CLEAR) - 1) ) {
@@ -114,15 +110,15 @@ void start_cli_mode(int argc, char *argv[]) {
continue;
}
if ( !strncmp(cli_line, CLI_DMI, sizeof(CLI_DMI) - 1) ) {
- set_mode(&cli_mode,DMI_MODE,&hardware);
+ set_mode(&cli_mode,DMI_MODE,hardware);
continue;
}
/* All commands before that line are common for all cli modes
* the following will be specific for every mode */
switch(cli_mode.mode) {
- case DMI_MODE: handle_dmi_commands(cli_line,&cli_mode, &hardware); break;
- case PCI_MODE: handle_pci_commands(cli_line,&cli_mode, &hardware); break;
- case HDT_MODE: handle_hdt_commands(cli_line,&cli_mode, &hardware); break;
+ case DMI_MODE: handle_dmi_commands(cli_line,&cli_mode, hardware); break;
+ case PCI_MODE: handle_pci_commands(cli_line,&cli_mode, hardware); break;
+ case HDT_MODE: handle_hdt_commands(cli_line,&cli_mode, hardware); break;
case EXIT_MODE: break; /* should not happend */
}
}
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 0c7085d7..52084567 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -55,7 +55,7 @@ struct s_cli_mode {
void show_cli_help(struct s_cli_mode *cli_mode);
-void start_cli_mode(int argc, char *argv[]);
+void start_cli_mode(struct s_hardware *hardware, int argc, char *argv[]);
void main_show(char *item, struct s_hardware *hardware, struct s_cli_mode *cli_mode);
int do_exit(struct s_cli_mode *cli_mode);
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index f568ea19..51a2b353 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -34,6 +34,10 @@
#include "dmi/dmi.h"
#include "hdt-ata.h"
+/* This two values are used for switching for the menu to the CLI mode*/
+#define HDT_SWITCH_TO_CLI "hdt_switch_to_cli"
+#define HDT_RETURN_TO_CLI 100
+
extern int display_line_nb;
#define more_printf(...) do {\
diff --git a/com32/hdt/hdt-menu.c b/com32/hdt/hdt-menu.c
index e24866e1..6a8d660c 100644
--- a/com32/hdt/hdt-menu.c
+++ b/com32/hdt/hdt-menu.c
@@ -30,25 +30,22 @@
-int start_menu_mode(char *version_string) {
+int start_menu_mode(struct s_hardware *hardware, char *version_string) {
struct s_hdt_menu hdt_menu;
- struct s_hardware hardware;
- /* Cleaning structures */
- init_hardware(&hardware);
memset(&hdt_menu,0,sizeof (hdt_menu));
/* Detect every kind of hardware */
- detect_hardware(&hardware);
+ detect_hardware(hardware);
/* Setup the menu system*/
setup_menu(version_string);
/* Compute all sub menus */
- compute_submenus(&hdt_menu, &hardware);
+ compute_submenus(&hdt_menu, hardware);
/* Compute main menu */
- compute_main_menu(&hdt_menu,&hardware);
+ compute_main_menu(&hdt_menu,hardware);
#ifdef WITH_MENU_DISPLAY
t_menuitem * curr;
@@ -61,7 +58,11 @@ int start_menu_mode(char *version_string) {
/* When want to execute something */
if (curr->action == OPT_RUN)
{
- strcpy(cmd,curr->data);
+ /* Tweak, we want to switch to the cli*/
+ if (! strncmp(curr->data,HDT_SWITCH_TO_CLI,sizeof(HDT_SWITCH_TO_CLI))) {
+ return HDT_RETURN_TO_CLI;
+ }
+ strcpy(cmd,curr->data);
/* Use specific syslinux call if needed */
if (issyslinux())
@@ -154,7 +155,7 @@ void compute_main_menu(struct s_hdt_menu *hdt_menu,struct s_hardware *hardware)
set_item_options(-1,24);
#ifdef WITH_PCI
- add_item("PCI <D>evices","PCI Devices Menu",OPT_SUBMENU,NULL,hdt_menu->pci_menu.menu);
+ add_item("PC<I> Devices","PCI Devices Menu",OPT_SUBMENU,NULL,hdt_menu->pci_menu.menu);
hdt_menu->main_menu.items_count++;
hdt_menu->total_menu_count+=hdt_menu->pci_menu.items_count;
#endif
@@ -205,6 +206,7 @@ if (hardware->is_dmi_valid) {
#endif
add_item("<S>yslinux","Syslinux Information Menu",OPT_SUBMENU,NULL,hdt_menu->syslinux_menu.menu);
hdt_menu->main_menu.items_count++;
+ add_item("S<w>itch to CLI","Switch to Command Line",OPT_RUN,HDT_SWITCH_TO_CLI,0);
add_item("<A>bout","About Menu",OPT_SUBMENU,NULL,hdt_menu->about_menu.menu);
hdt_menu->main_menu.items_count++;
diff --git a/com32/hdt/hdt-menu.h b/com32/hdt/hdt-menu.h
index bebdff58..9c614595 100644
--- a/com32/hdt/hdt-menu.h
+++ b/com32/hdt/hdt-menu.h
@@ -105,7 +105,7 @@ void compute_syslinuxmenu(struct s_my_menu *menu);
// About menu
void compute_aboutmenu(struct s_my_menu *menu);
-int start_menu_mode(char *version_string);
+int start_menu_mode(struct s_hardware *hardware, char *version_string);
void setup_menu(char *version);
void compute_main_menu(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware);
void compute_submenus(struct s_hdt_menu *hdt_menu,struct s_hardware *hardware);
diff --git a/com32/hdt/hdt.c b/com32/hdt/hdt.c
index 7ee39048..c96d0b97 100644
--- a/com32/hdt/hdt.c
+++ b/com32/hdt/hdt.c
@@ -45,9 +45,13 @@ int main(int argc, char *argv[])
{
char version_string[256];
char *arg;
+ struct s_hardware hardware;
snprintf(version_string,sizeof version_string,"%s %s by %s",PRODUCT_NAME,VERSION,AUTHOR);
+ /* Cleaning structures */
+ init_hardware(&hardware);
+
/* Opening the syslinux console */
openconsole(&dev_stdcon_r, &dev_ansicon_w);
@@ -55,9 +59,14 @@ int main(int argc, char *argv[])
printf("%s\n",version_string);
if ((arg = find_argument(argv+1, "nomenu"))) {
- start_cli_mode(argc, argv);
+ start_cli_mode(&hardware, argc, argv);
} else{
- return start_menu_mode(version_string);
+ int return_code = start_menu_mode(&hardware, version_string);
+ if (return_code == HDT_RETURN_TO_CLI) {
+ start_cli_mode(&hardware,argc,argv);
+ } else {
+ return return_code;
+ }
}
return 0;