aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerwan <erwan@laptopR1.(none)>2009-03-08 11:43:52 +0100
committererwan <erwan@laptopR1.(none)>2009-03-08 11:43:52 +0100
commitdbbaec5377d2820e72d730c915fc3e2ed58b83ba (patch)
tree425178375564e2a2763e88d500ed455b775686da
parent235a1968999eacf333005910136c6c62e85bd22e (diff)
downloadsyslinux-elf-dbbaec5377d2820e72d730c915fc3e2ed58b83ba.tar.gz
syslinux-elf-dbbaec5377d2820e72d730c915fc3e2ed58b83ba.tar.xz
syslinux-elf-dbbaec5377d2820e72d730c915fc3e2ed58b83ba.zip
hdt: adding syslinux mode in cli
cli mode now offer a syslinux mode to display : version product copyright
-rw-r--r--com32/hdt/Makefile1
-rw-r--r--com32/hdt/hdt-cli-syslinux.c65
-rw-r--r--com32/hdt/hdt-cli.c18
-rw-r--r--com32/hdt/hdt-cli.h6
4 files changed, 88 insertions, 2 deletions
diff --git a/com32/hdt/Makefile b/com32/hdt/Makefile
index b9fd49b4..653f2c93 100644
--- a/com32/hdt/Makefile
+++ b/com32/hdt/Makefile
@@ -46,6 +46,7 @@ hdt.elf: hdt.o hdt-ata.o hdt-menu.o hdt-menu-pci.o hdt-menu-kernel.o \
hdt-menu-syslinux.o hdt-menu-about.o \
hdt-cli.o hdt-common.o hdt-cli-pci.o hdt-cli-dmi.o \
hdt-cli-cpu.o hdt-cli-pxe.o hdt-cli-kernel.o \
+ hdt-cli-syslinux.o \
hdt-menu-pxe.o hdt-menu-summary.o\
$(com32)/modules/cpuid.o \
$(LIBS)
diff --git a/com32/hdt/hdt-cli-syslinux.c b/com32/hdt/hdt-cli-syslinux.c
new file mode 100644
index 00000000..1a0c1e0e
--- /dev/null
+++ b/com32/hdt/hdt-cli-syslinux.c
@@ -0,0 +1,65 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2009 Erwan Velu - 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-cli.h"
+#include "hdt-common.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <syslinux/pxe.h>
+#include <syslinux/config.h>
+
+void main_show_syslinux(struct s_hardware *hardware,struct s_cli_mode *cli_mode) {
+ more_printf("SYSLINUX\n");
+ more_printf(" Bootloader : %s\n", hardware->syslinux_fs);
+ more_printf(" Version : %s\n", hardware->sv->version_string+2);
+ more_printf(" Version : %u\n",hardware->sv->version);
+ more_printf(" Max API : %u\n",hardware->sv->max_api);
+ more_printf(" Copyright : %s\n", hardware->sv->copyright_string+1);
+}
+
+void show_syslinux_help() {
+ more_printf("Show supports the following commands : %s\n",CLI_SHOW_LIST);
+}
+
+void syslinux_show(char *item, struct s_hardware *hardware) {
+ if ( !strncmp(item, CLI_SHOW_LIST, sizeof(CLI_SHOW_LIST) - 1) ) {
+ main_show_syslinux(hardware,NULL);
+ return;
+ }
+ show_syslinux_help();
+}
+
+void handle_syslinux_commands(char *cli_line, struct s_cli_mode *cli_mode, struct s_hardware *hardware) {
+ if ( !strncmp(cli_line, CLI_SHOW, sizeof(CLI_SHOW) - 1) ) {
+ syslinux_show(strstr(cli_line,"show")+ sizeof(CLI_SHOW), hardware);
+ return;
+ }
+}
+
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index a92d5f5c..5b1da6f5 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -59,6 +59,11 @@ void set_mode(struct s_cli_mode *cli_mode, cli_mode_t mode, struct s_hardware *h
snprintf(cli_mode->prompt, sizeof(cli_mode->prompt), "%s> ", CLI_KERNEL);
break;
+ case SYSLINUX_MODE:
+ cli_mode->mode=mode;
+ snprintf(cli_mode->prompt, sizeof(cli_mode->prompt), "%s> ", CLI_SYSLINUX);
+ break;
+
case PCI_MODE:
cli_mode->mode=mode;
snprintf(cli_mode->prompt,sizeof(cli_mode->prompt),"%s> ", CLI_PCI);
@@ -149,6 +154,10 @@ void start_cli_mode(struct s_hardware *hardware, int argc, char *argv[]) {
set_mode(&cli_mode,KERNEL_MODE,hardware);
continue;
}
+ if ( !strncmp(cli_line, CLI_SYSLINUX, sizeof(CLI_SYSLINUX) - 1) ) {
+ set_mode(&cli_mode,SYSLINUX_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) {
@@ -157,6 +166,7 @@ void start_cli_mode(struct s_hardware *hardware, int argc, char *argv[]) {
case HDT_MODE: handle_hdt_commands(cli_line,&cli_mode, hardware); break;
case CPU_MODE: handle_cpu_commands(cli_line,&cli_mode, hardware); break;
case PXE_MODE: handle_pxe_commands(cli_line,&cli_mode, hardware); break;
+ case SYSLINUX_MODE: handle_syslinux_commands(cli_line,&cli_mode, hardware); break;
case KERNEL_MODE: handle_kernel_commands(cli_line,&cli_mode, hardware); break;
case EXIT_MODE: break; /* should not happend */
}
@@ -168,6 +178,7 @@ int do_exit(struct s_cli_mode *cli_mode) {
case HDT_MODE: return EXIT_MODE;
case KERNEL_MODE:
case PXE_MODE:
+ case SYSLINUX_MODE:
case PCI_MODE:
case DMI_MODE:
case CPU_MODE: return HDT_MODE;
@@ -179,10 +190,11 @@ return HDT_MODE;
void show_cli_help(struct s_cli_mode *cli_mode) {
switch (cli_mode->mode) {
case HDT_MODE:
- printf("Available commands are : %s %s %s %s %s %s %s %s %s\n",
+ printf("Available commands are : %s %s %s %s %s %s %s %s %s %s\n",
CLI_CLEAR, CLI_EXIT,CLI_HELP,CLI_SHOW, CLI_PCI,
- CLI_DMI, CLI_PXE, CLI_KERNEL, CLI_CPU);
+ CLI_DMI, CLI_PXE, CLI_KERNEL, CLI_CPU, CLI_SYSLINUX);
break;
+ case SYSLINUX_MODE:
case KERNEL_MODE:
case PXE_MODE:
case CPU_MODE:
@@ -225,6 +237,7 @@ void show_main_help(struct s_hardware *hardware) {
more_printf(" %s\n",CLI_DMI);
more_printf(" %s\n",CLI_CPU);
more_printf(" %s\n",CLI_KERNEL);
+ more_printf(" %s\n",CLI_SYSLINUX);
if (hardware->sv->filesystem == SYSLINUX_FS_PXELINUX)
more_printf(" %s\n",CLI_PXE);
}
@@ -235,6 +248,7 @@ void main_show(char *item, struct s_hardware *hardware, struct s_cli_mode *cli_m
if (!strncmp(item,CLI_DMI, sizeof (CLI_DMI))) { main_show_dmi(hardware,cli_mode); return; }
if (!strncmp(item,CLI_CPU, sizeof (CLI_CPU))) { main_show_cpu(hardware,cli_mode); return; }
if (!strncmp(item,CLI_PXE, sizeof (CLI_PXE))) { main_show_pxe(hardware,cli_mode); return; }
+ if (!strncmp(item,CLI_SYSLINUX, sizeof (CLI_SYSLINUX))) { main_show_syslinux(hardware,cli_mode); return; }
if (!strncmp(item,CLI_KERNEL, sizeof (CLI_KERNEL))) { main_show_kernel(hardware,cli_mode); return; }
show_main_help(hardware);
}
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 9a880128..92791c49 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -39,6 +39,7 @@
#define CLI_PCI "pci"
#define CLI_PXE "pxe"
#define CLI_KERNEL "kernel"
+#define CLI_SYSLINUX "syslinux"
#define CLI_SUMMARY "summary"
#define CLI_COMMANDS "commands"
#define CLI_DMI "dmi"
@@ -53,6 +54,7 @@ typedef enum {
CPU_MODE,
PXE_MODE,
KERNEL_MODE,
+ SYSLINUX_MODE,
} cli_mode_t;
struct s_cli_mode {
@@ -107,4 +109,8 @@ void handle_pxe_commands(char *cli_line, struct s_cli_mode *cli_mode, struct s_h
//KERNEL STUFF
void main_show_kernel(struct s_hardware *hardware,struct s_cli_mode *cli_mode);
void handle_kernel_commands(char *cli_line, struct s_cli_mode *cli_mode, struct s_hardware *hardware);
+
+//SYSLINUX STUFF
+void main_show_syslinux(struct s_hardware *hardware,struct s_cli_mode *cli_mode);
+void handle_syslinux_commands(char *cli_line, struct s_cli_mode *cli_mode, struct s_hardware *hardware);
#endif