}
/* 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");
int mode=do_exit(&cli_mode);
if (mode == EXIT_MODE)
return;
- set_mode(&cli_mode,mode,&hardware);
+ set_mode(&cli_mode,mode,hardware);
continue;
}
}
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) ) {
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 */
}
}
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);
#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 {\
-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;
/* 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())
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
#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++;
// 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);
{
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);
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;