summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--com32/hdt/Makefile23
-rw-r--r--com32/hdt/hdt-cli-dmi.c171
-rw-r--r--com32/hdt/hdt-cli-vesa.c4
-rw-r--r--com32/hdt/hdt-cli.c909
-rw-r--r--com32/hdt/hdt-cli.h43
-rw-r--r--com32/hdt/hdt-common.c10
-rw-r--r--com32/hdt/hdt-common.h6
-rw-r--r--com32/hdt/hdt-menu-about.c16
-rw-r--r--com32/hdt/hdt-menu-vesa.c2
-rw-r--r--com32/hdt/hdt.c5
-rw-r--r--com32/hdt/hdt.h4
11 files changed, 825 insertions, 368 deletions
diff --git a/com32/hdt/Makefile b/com32/hdt/Makefile
index d6766f34..787a845b 100644
--- a/com32/hdt/Makefile
+++ b/com32/hdt/Makefile
@@ -19,7 +19,8 @@ include $(topdir)/MCONFIG.embedded
MODULES = hdt.c32
-INCLUDES = -I$(com32)/include -I$(com32)/cmenu/libmenu -I$(com32)/gplinclude
+INCLUDES = -I$(com32)/include -I$(com32)/cmenu/libmenu -I$(com32)/gplinclude\
+ -I$(com32)/libutil/include
LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
LIB = liboldcom32.a
@@ -40,11 +41,11 @@ all: $(MODULES) $(LIB)
.PRECIOUS: %.o
%.o: %.c
- $(CC) $(CFLAGS) -std=gnu99 -D__COM32__ -c -o $@ $<
+ @$(CC) $(CFLAGS) -std=gnu99 -D__COM32__ -c -o $@ $<
.PRECIOUS: %.elf
%.elf: c32entry.o %.o $(LIB)
- $(LD) -Ttext 0x101000 -e _start -o $@ $^
+ @$(LD) -Ttext 0x101000 -e _start -o $@ $^
hdt.elf: hdt.o hdt-ata.o hdt-menu.o hdt-menu-pci.o hdt-menu-kernel.o \
hdt-menu-disk.o hdt-menu-dmi.o hdt-menu-processor.o \
@@ -54,26 +55,26 @@ hdt.elf: hdt.o hdt-ata.o hdt-menu.o hdt-menu-pci.o hdt-menu-kernel.o \
hdt-cli-syslinux.o hdt-cli-vesa.o\
hdt-menu-pxe.o hdt-menu-summary.o hdt-menu-vesa.o\
$(LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
+ @$(LD) $(LDFLAGS) -o $@ $^
%.c32: %.elf
- $(OBJCOPY) -O binary $< $@
+ @$(OBJCOPY) -O binary $< $@
%.com: %.asm
- $(NASM) $(NASMOPT) -f bin -o $@ -l $*.lst $<
+ @$(NASM) $(NASMOPT) -f bin -o $@ -l $*.lst $<
$(LIB):
- rm -f $@
- $(AR) cq $@ $^
- $(RANLIB) $@
+ @rm -f $@
+ @$(AR) cq $@ $^
+ @$(RANLIB) $@
tidy dist:
- rm -f *.o *.a *.lst *.elf
+ @rm -f *.o *.a *.lst *.elf
install: all
# Don't specify *.com since mdiskchk.com can't be built using Linux tools
clean: tidy
- rm -f *.o *.c32 *.c~ *.h~ Makefile~
+ @rm -f *.o *.c32 *.c~ *.h~ Makefile~
spotless: clean
diff --git a/com32/hdt/hdt-cli-dmi.c b/com32/hdt/hdt-cli-dmi.c
index 0fe0845b..4ec242d0 100644
--- a/com32/hdt/hdt-cli-dmi.c
+++ b/com32/hdt/hdt-cli-dmi.c
@@ -26,14 +26,16 @@
* -----------------------------------------------------------------------
*/
-#include "hdt-cli.h"
-#include "hdt-common.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
-static void show_dmi_modules(struct s_hardware *hardware)
+#include "hdt-cli.h"
+#include "hdt-common.h"
+
+static void show_dmi_modules(int argc, char** argv,
+ struct s_hardware *hardware)
{
char available_dmi_commands[1024];
memset(available_dmi_commands, 0, sizeof(available_dmi_commands));
@@ -80,16 +82,18 @@ static void show_dmi_modules(struct s_hardware *hardware)
printf("Available DMI modules: %s\n", available_dmi_commands);
}
-static void show_dmi_help(struct s_hardware *hardware)
+static void show_dmi_help(int argc, char** argv,
+ struct s_hardware *hardware)
{
more_printf("Show supports the following commands : \n");
more_printf(" %s\n", CLI_SHOW_LIST);
more_printf(" <module_name>\n");
more_printf(" -\n");
- show_dmi_modules(hardware);
+ show_dmi_modules(0, NULL, hardware);
}
-static void show_dmi_base_board(struct s_hardware *hardware)
+static void show_dmi_base_board(int argc, char** argv,
+ struct s_hardware *hardware)
{
if (hardware->dmi.base_board.filled == false) {
printf("Base_board module not available\n");
@@ -113,7 +117,8 @@ static void show_dmi_base_board(struct s_hardware *hardware)
}
}
-static void show_dmi_system(struct s_hardware *hardware)
+static void show_dmi_system(int argc, char** argv,
+ struct s_hardware *hardware)
{
if (hardware->dmi.system.filled == false) {
printf("System module not available\n");
@@ -131,7 +136,8 @@ static void show_dmi_system(struct s_hardware *hardware)
more_printf(" Family : %s\n", hardware->dmi.system.family);
}
-static void show_dmi_bios(struct s_hardware *hardware)
+static void show_dmi_bios(int argc, char** argv,
+ struct s_hardware *hardware)
{
if (hardware->dmi.bios.filled == false) {
printf("Bios module not available\n");
@@ -176,7 +182,8 @@ static void show_dmi_bios(struct s_hardware *hardware)
}
-static void show_dmi_chassis(struct s_hardware *hardware)
+static void show_dmi_chassis(int argc, char** argv,
+ struct s_hardware *hardware)
{
if (hardware->dmi.chassis.filled == false) {
printf("Chassis module not available\n");
@@ -208,7 +215,8 @@ static void show_dmi_chassis(struct s_hardware *hardware)
hardware->dmi.chassis.nb_power_cords);
}
-static void show_dmi_battery(struct s_hardware *hardware)
+static void show_dmi_battery(int argc, char** argv,
+ struct s_hardware *hardware)
{
if (hardware->dmi.battery.filled == false) {
printf("Battery module not available\n");
@@ -239,7 +247,8 @@ static void show_dmi_battery(struct s_hardware *hardware)
hardware->dmi.battery.oem_info);
}
-static void show_dmi_cpu(struct s_hardware *hardware)
+static void show_dmi_cpu(int argc, char** argv,
+ struct s_hardware *hardware)
{
if (hardware->dmi.processor.filled == false) {
printf("Processor module not available\n");
@@ -295,10 +304,16 @@ static void show_dmi_cpu(struct s_hardware *hardware)
}
}
-static void show_dmi_memory_bank(struct s_hardware *hardware, const char *item)
+static void show_dmi_memory_bank(int argc, char** argv,
+ struct s_hardware *hardware)
{
- long bank = strtol(item, (char **)NULL, 10);
- if (errno == ERANGE) {
+ long bank = -1;
+
+ /* Sanitize arguments */
+ if (argc > 0)
+ bank = strtol(argv[0], (char **)NULL, 10);
+
+ if (errno == ERANGE || bank < 0) {
printf("This bank number is incorrect\n");
return;
}
@@ -340,58 +355,6 @@ static void show_dmi_memory_bank(struct s_hardware *hardware, const char *item)
hardware->dmi.memory[bank].part_number);
}
-void dmi_show(char *item, struct s_hardware *hardware)
-{
- if (!strncmp(item, CLI_DMI_BASE_BOARD, sizeof(CLI_DMI_BASE_BOARD) - 1)) {
- show_dmi_base_board(hardware);
- return;
- }
- if (!strncmp(item, CLI_DMI_SYSTEM, sizeof(CLI_DMI_SYSTEM) - 1)) {
- show_dmi_system(hardware);
- return;
- }
- if (!strncmp(item, CLI_DMI_BIOS, sizeof(CLI_DMI_BIOS) - 1)) {
- show_dmi_bios(hardware);
- return;
- }
- if (!strncmp(item, CLI_DMI_CHASSIS, sizeof(CLI_DMI_CHASSIS) - 1)) {
- show_dmi_chassis(hardware);
- return;
- }
- if (!strncmp(item, CLI_DMI_PROCESSOR, sizeof(CLI_DMI_PROCESSOR) - 1)) {
- show_dmi_cpu(hardware);
- return;
- }
- if (!strncmp(item, CLI_DMI_MEMORY, sizeof(CLI_DMI_MEMORY) - 1)) {
- show_dmi_memory_modules(hardware, true, true);
- return;
- }
- if (!strncmp
- (item, CLI_DMI_MEMORY_BANK, sizeof(CLI_DMI_MEMORY_BANK) - 1)) {
- show_dmi_memory_bank(hardware,
- item + sizeof(CLI_DMI_MEMORY_BANK) - 1);
- return;
- }
- if (!strncmp(item, CLI_SHOW_LIST, sizeof(CLI_SHOW_LIST) - 1)) {
- show_dmi_modules(hardware);
- return;
- }
- if (!strncmp(item, CLI_DMI_BATTERY, sizeof(CLI_DMI_BATTERY) - 1)) {
- show_dmi_battery(hardware);
- return;
- }
-
- show_dmi_help(hardware);
-}
-
-void handle_dmi_commands(char *cli_line, struct s_hardware *hardware)
-{
- if (!strncmp(cli_line, CLI_SHOW, sizeof(CLI_SHOW) - 1)) {
- dmi_show(strstr(cli_line, "show") + sizeof(CLI_SHOW), hardware);
- return;
- }
-}
-
void main_show_dmi(struct s_hardware *hardware)
{
@@ -405,12 +368,27 @@ void main_show_dmi(struct s_hardware *hardware)
hardware->dmi.dmitable.major_version,
hardware->dmi.dmitable.minor_version);
- show_dmi_modules(hardware);
+ show_dmi_modules(0, NULL, hardware);
}
-void show_dmi_memory_modules(struct s_hardware *hardware, bool clear,
- bool show_free_banks)
+void show_dmi_memory_modules(int argc, char** argv,
+ struct s_hardware *hardware)
{
+ int clear = 1, show_free_banks = 1;
+
+ /* Sanitize arguments */
+ if (argc > 0) {
+ clear = strtol(argv[0], NULL, 10);
+ if (errno == ERANGE || clear < 0 || clear > 1)
+ goto usage;
+
+ if (argc > 1) {
+ show_free_banks = strtol(argv[1], NULL, 10);
+ if (errno == ERANGE || show_free_banks < 0 || show_free_banks > 1)
+ goto usage;
+ }
+ }
+
char bank_number[10];
char available_dmi_commands[1024];
memset(available_dmi_commands, 0, sizeof(available_dmi_commands));
@@ -447,5 +425,60 @@ void show_dmi_memory_modules(struct s_hardware *hardware, bool clear,
}
}
}
+
+ return;
//printf("Type 'show bank<bank_number>' for more details.\n");
+
+usage:
+ printf("show memory <clear screen? <show free banks?>>\n");
+ return;
}
+
+struct commands_module list_dmi_show_modules[] = {
+ {
+ .name = CLI_DMI_BASE_BOARD,
+ .exec = show_dmi_base_board,
+ },
+ {
+ .name = CLI_DMI_BIOS,
+ .exec = show_dmi_bios,
+ },
+ {
+ .name = CLI_DMI_BATTERY,
+ .exec = show_dmi_battery,
+ },
+ {
+ .name = CLI_DMI_CHASSIS,
+ .exec = show_dmi_chassis,
+ },
+ {
+ .name = CLI_DMI_MEMORY,
+ .exec = show_dmi_memory_modules,
+ },
+ {
+ .name = CLI_DMI_MEMORY_BANK,
+ .exec = show_dmi_memory_bank,
+ },
+ {
+ .name = CLI_DMI_PROCESSOR,
+ .exec = show_dmi_cpu,
+ },
+ {
+ .name = CLI_DMI_SYSTEM,
+ .exec = show_dmi_system,
+ },
+ {
+ .name = CLI_DMI_LIST,
+ .exec = show_dmi_modules,
+ },
+};
+
+struct commands_module_descr dmi_show_modules = {
+ .modules = list_dmi_show_modules,
+ .nb_modules = CLI_DMI_MAX_MODULES,
+};
+
+struct commands_mode dmi_mode = {
+ .mode = DMI_MODE,
+ .show_modules = &dmi_show_modules,
+};
diff --git a/com32/hdt/hdt-cli-vesa.c b/com32/hdt/hdt-cli-vesa.c
index 507a3abf..e6843eea 100644
--- a/com32/hdt/hdt-cli-vesa.c
+++ b/com32/hdt/hdt-cli-vesa.c
@@ -66,11 +66,11 @@ void show_vesa_modes(struct s_hardware *hardware) {
}
}
-void show_vesa_help() {
+static void show_vesa_help() {
more_printf("Show supports the following commands : %s %s\n",CLI_SHOW_LIST, CLI_MODES);
}
-void vesa_show(char *item, struct s_hardware *hardware) {
+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);
return;
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 7c1dc79c..adfbf944 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -29,308 +29,677 @@
#include <stdlib.h>
#include <string.h>
#include <syslinux/config.h>
-
+#include <getkey.h>
#include "hdt-cli.h"
#include "hdt-common.h"
-static void set_mode(struct s_cli_mode *cli_mode, cli_mode_t mode,
- struct s_hardware *hardware)
+#define MAX_MODES 1
+struct commands_mode *list_modes[] = {
+ &dmi_mode,
+};
+
+static void set_mode(struct s_cli *cli, cli_mode_t mode,
+ struct s_hardware *hardware)
{
- switch (mode) {
- case EXIT_MODE:
- cli_mode->mode = mode;
- snprintf(cli_mode->prompt, sizeof(cli_mode->prompt), "%s> ",
- CLI_EXIT);
- break;
-
- case HDT_MODE:
- cli_mode->mode = mode;
- snprintf(cli_mode->prompt, sizeof(cli_mode->prompt), "%s> ",
- CLI_HDT);
- break;
-
- case PXE_MODE:
- if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
- more_printf("You are not currently using PXELINUX\n");
- break;
- }
- cli_mode->mode = mode;
- snprintf(cli_mode->prompt, sizeof(cli_mode->prompt), "%s> ",
- CLI_PXE);
- break;
-
- case KERNEL_MODE:
- detect_pci(hardware);
- cli_mode->mode = mode;
- 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 VESA_MODE:
- cli_mode->mode=mode;
- snprintf(cli_mode->prompt, sizeof(cli_mode->prompt), "%s> ", CLI_VESA);
- break;
-
- case PCI_MODE:
- cli_mode->mode = mode;
- snprintf(cli_mode->prompt, sizeof(cli_mode->prompt), "%s> ",
- CLI_PCI);
- if (!hardware->pci_detection)
- cli_detect_pci(hardware);
- break;
-
- case CPU_MODE:
- cli_mode->mode = mode;
- snprintf(cli_mode->prompt, sizeof(cli_mode->prompt), "%s> ",
- CLI_CPU);
- if (!hardware->dmi_detection)
- detect_dmi(hardware);
- if (!hardware->cpu_detection)
- cpu_detect(hardware);
- break;
-
- case DMI_MODE:
- detect_dmi(hardware);
- if (!hardware->is_dmi_valid) {
- printf("No valid DMI table found, exiting.\n");
- break;
- }
- cli_mode->mode = mode;
- snprintf(cli_mode->prompt, sizeof(cli_mode->prompt), "%s> ",
- CLI_DMI);
- break;
- }
+ switch (mode) {
+ case EXIT_MODE:
+ cli->mode = mode;
+ break;
+
+ case HDT_MODE:
+ cli->mode = mode;
+ snprintf(cli->prompt, sizeof(cli->prompt), "%s> ", CLI_HDT);
+ break;
+
+ case PXE_MODE:
+ if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) {
+ more_printf("You are not currently using PXELINUX\n");
+ break;
+ }
+ cli->mode = mode;
+ snprintf(cli->prompt, sizeof(cli->prompt), "%s> ", CLI_PXE);
+ break;
+
+ case KERNEL_MODE:
+ detect_pci(hardware);
+ cli->mode = mode;
+ snprintf(cli->prompt, sizeof(cli->prompt), "%s> ", CLI_KERNEL);
+ break;
+
+ case SYSLINUX_MODE:
+ cli->mode = mode;
+ snprintf(cli->prompt, sizeof(cli->prompt), "%s> ",
+ CLI_SYSLINUX);
+ break;
+
+ case VESA_MODE:
+ cli->mode = mode;
+ snprintf(cli->prompt, sizeof(cli->prompt), "%s> ", CLI_VESA);
+ break;
+
+ case PCI_MODE:
+ cli->mode = mode;
+ snprintf(cli->prompt, sizeof(cli->prompt), "%s> ", CLI_PCI);
+ if (!hardware->pci_detection)
+ cli_detect_pci(hardware);
+ break;
+
+ case CPU_MODE:
+ cli->mode = mode;
+ snprintf(cli->prompt, sizeof(cli->prompt), "%s> ", CLI_CPU);
+ if (!hardware->dmi_detection)
+ detect_dmi(hardware);
+ if (!hardware->cpu_detection)
+ cpu_detect(hardware);
+ break;
+
+ case DMI_MODE:
+ detect_dmi(hardware);
+ if (!hardware->is_dmi_valid) {
+ more_printf("No valid DMI table found, exiting.\n");
+ break;
+ }
+ cli->mode = mode;
+ snprintf(cli->prompt, sizeof(cli->prompt), "%s> ", CLI_DMI);
+ break;
+ }
}
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;
- }
+ /* 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;
+ }
}
-static void show_cli_help(struct s_cli_mode *cli_mode)
+static void show_cli_help(struct s_cli *cli)
{
- switch (cli_mode->mode) {
- case HDT_MODE:
- 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_SYSLINUX);
- break;
- case SYSLINUX_MODE:
- case KERNEL_MODE:
- case PXE_MODE:
- case VESA_MODE:
- case CPU_MODE:
- case PCI_MODE:
- case DMI_MODE:
- printf("Available commands are : %s %s %s %s\n",
- CLI_CLEAR, CLI_EXIT, CLI_HELP, CLI_SHOW);
- break;
- case EXIT_MODE: /* Should not happen */
- break;
- }
+ switch (cli->mode) {
+ case HDT_MODE:
+ more_printf("Available commands are :\n");
+ more_printf
+ ("%s %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_SYSLINUX, CLI_VESA);
+ break;
+ case SYSLINUX_MODE:
+ case KERNEL_MODE:
+ case PXE_MODE:
+ case VESA_MODE:
+ case CPU_MODE:
+ case PCI_MODE:
+ case DMI_MODE:
+ printf("Available commands are : %s %s %s %s\n",
+ CLI_CLEAR, CLI_EXIT, CLI_HELP, CLI_SHOW);
+ break;
+ case EXIT_MODE: /* Should not happen */
+ break;
+ }
+}
+
+static void exec_command(char *command, struct s_cli *cli,
+ struct s_hardware *hardware)
+{
+ /* We use sizeof BLAH - 1 to remove the last \0 */
+// command[strlen(command) - 1] = '\0';
+
+ if (!strncmp(command, CLI_EXIT, sizeof(CLI_EXIT) - 1)) {
+ int mode = do_exit(cli);
+ set_mode(cli, mode, hardware);
+ return;
+ }
+
+ if (!strncmp(command, CLI_HELP, sizeof(CLI_HELP) - 1)) {
+ show_cli_help(cli);
+ return;
+ }
+
+ if (!strncmp(command, CLI_PCI, sizeof(CLI_PCI) - 1)) {
+ set_mode(cli, PCI_MODE, hardware);
+ return;
+ }
+
+ if (!strncmp(command, CLI_CLEAR, sizeof(CLI_CLEAR) - 1)) {
+ clear_screen();
+ return;
+ }
+
+ if (!strncmp(command, CLI_CPU, sizeof(CLI_CPU) - 1)) {
+ set_mode(cli, CPU_MODE, hardware);
+ return;
+ }
+
+ if (!strncmp(command, CLI_DMI, sizeof(CLI_DMI) - 1)) {
+ set_mode(cli, DMI_MODE, hardware);
+ return;
+ }
+
+ if (!strncmp(command, CLI_PXE, sizeof(CLI_PXE) - 1)) {
+ set_mode(cli, PXE_MODE, hardware);
+ return;
+ }
+
+ if (!strncmp(command, CLI_KERNEL, sizeof(CLI_KERNEL) - 1)) {
+ set_mode(cli, KERNEL_MODE, hardware);
+ return;
+ }
+
+ if (!strncmp(command, CLI_SYSLINUX, sizeof(CLI_SYSLINUX) - 1)) {
+ set_mode(cli, SYSLINUX_MODE, hardware);
+ return;
+ }
+
+ if (!strncmp(command, CLI_VESA, sizeof(CLI_VESA) - 1)) {
+ set_mode(cli, VESA_MODE, hardware);
+ return;
+ }
+
+ /*
+ * All commands before that line are common for all cli modes.
+ * The following will be specific for every mode.
+ */
+
+ int modes_iter = 0, modules_iter = 0;
+
+ /* Find the mode selected */
+ while (modes_iter < MAX_MODES &&
+ list_modes[modes_iter]->mode != cli->mode)
+ modes_iter++;
+
+ if (modes_iter != MAX_MODES) {
+ struct commands_mode *current_mode = list_modes[modes_iter];
+
+ /*
+ * Find the type of command.
+ *
+ * The syntax of the cli is the following:
+ * <type of command> <module on which to operate> <args>
+ * e.g.
+ * dmi> show system
+ * dmi> show bank 1
+ * dmi> show memory 0 1
+ * pci> show device 12
+ */
+ if (!strncmp(command, CLI_SHOW, sizeof(CLI_SHOW) - 1)) {
+ int module_len = 0, args_len = 0;
+ int argc = 0, args_iter = 0, argc_iter = 0;
+ char *module = NULL, *args = NULL, *args_cpy = NULL;
+ char **argv = NULL;
+
+ /* Get the module name and args */
+ while (strncmp
+ (command + sizeof(CLI_SHOW) + module_len,
+ CLI_SPACE, 1))
+ module_len++;
+
+ /* cli_line is filled with \0 when initialized */
+ while (strncmp
+ (command + sizeof(CLI_SHOW) + module_len + 1 +
+ args_len, "\0", 1))
+ args_len++;
+
+ module = malloc(module_len + 1);
+ strncpy(module, command + sizeof(CLI_SHOW), module_len);
+ module[module_len] = '\0';
+
+ /* Skip arguments handling if none is supplied */
+ if (!args_len)
+ goto find_callback;
+
+ args = malloc(args_len + 1);
+ strncpy(args,
+ command + sizeof(CLI_SHOW) + module_len + 1,
+ args_len);
+ args[args_len] = '\0';
+
+ /* Compute the number of arguments */
+ args_cpy = args;
+ read_argument:
+ args_iter = 0;
+ while (args_iter < args_len
+ && strncmp(args_cpy + args_iter, CLI_SPACE, 1))
+ args_iter++;
+ argc++;
+ args_iter++;
+ args_cpy += args_iter;
+ args_len -= args_iter;
+ if (args_len > 0)
+ goto read_argument;
+
+ /* Transform the arguments string into an array */
+ char *result = NULL;
+ argv = malloc(argc * sizeof(char *));
+ result = strtok(args, CLI_SPACE);
+ while (result != NULL) {
+ argv[argc_iter] = result;
+ argc_iter++;
+ result = strtok(NULL, CLI_SPACE);
+ }
+
+ find_callback:
+ /* Find the callback to execute */
+ while (modules_iter <
+ current_mode->show_modules->nb_modules
+ && strncmp(module,
+ current_mode->show_modules->
+ modules[modules_iter].name,
+ module_len + 1) != 0)
+ modules_iter++;
+
+ if (modules_iter !=
+ current_mode->show_modules->nb_modules) {
+ struct commands_module current_module =
+ current_mode->show_modules->
+ modules[modules_iter];
+ /* Execute the callback */
+ current_module.exec(argc, argv, hardware);
+ } else
+// printf("Module %s unknown.\n", module);
+ /* XXX Add a default help option for empty commands */
+
+ free(module);
+ if (args_len) {
+ free(args);
+ free(argv);
+ }
+ }
+ /* Handle here other keywords such as 'set', ... */
+ } else
+// printf("Mode '%s' unknown.\n", command);
+
+ /* Legacy cli */
+ switch (cli->mode) {
+ case PCI_MODE:
+ handle_pci_commands(command, hardware);
+ break;
+ case HDT_MODE:
+ handle_hdt_commands(command, hardware);
+ break;
+ case CPU_MODE:
+ handle_cpu_commands(command, hardware);
+ break;
+ case PXE_MODE:
+ handle_pxe_commands(command, hardware);
+ break;
+ case VESA_MODE:
+ handle_vesa_commands(command, hardware);
+ break;
+ case SYSLINUX_MODE:
+ handle_syslinux_commands(command, hardware);
+ break;
+ case KERNEL_MODE:
+ handle_kernel_commands(command, hardware);
+ break;
+ case EXIT_MODE:
+ break; /* should not happen */
+ }
+}
+
+static void reset_prompt(struct s_cli *cli)
+{
+ /* No need to display the prompt if we exit */
+ if (cli->mode != EXIT_MODE) {
+ printf("%s", cli->prompt);
+ /* Reset the line */
+ memset(cli->input, '\0', MAX_LINE_SIZE);
+ cli->cursor_pos = 0;
+ }
}
/* Code that manages the cli mode */
void start_cli_mode(struct s_hardware *hardware)
{
- char cli_line[256];
- struct s_cli_mode cli_mode;
-
- set_mode(&cli_mode, HDT_MODE, hardware);
-
- printf("Entering CLI mode\n");
-
- for (;;) {
- memset(cli_line, 0, sizeof cli_line);
- printf("%s", cli_mode.prompt);
-
- fgets(cli_line, sizeof cli_line, stdin);
- /* We use sizeof BLAH - 1 to remove the last \0 */
- cli_line[strlen(cli_line) - 1] = '\0';
-
- if (!strncmp(cli_line, CLI_EXIT, sizeof(CLI_EXIT) - 1)) {
- int mode = do_exit(&cli_mode);
- if (mode == EXIT_MODE)
- return;
- set_mode(&cli_mode, mode, hardware);
- continue;
- }
-
- if (!strncmp(cli_line, CLI_HELP, sizeof(CLI_HELP) - 1)) {
- show_cli_help(&cli_mode);
- continue;
- }
- if (!strncmp(cli_line, CLI_PCI, sizeof(CLI_PCI) - 1)) {
- set_mode(&cli_mode, PCI_MODE, hardware);
- continue;
- }
- if (!strncmp(cli_line, CLI_CLEAR, sizeof(CLI_CLEAR) - 1)) {
- clear_screen();
- continue;
- }
- if (!strncmp(cli_line, CLI_CPU, sizeof(CLI_CPU) - 1)) {
- set_mode(&cli_mode, CPU_MODE, hardware);
- continue;
- }
- if (!strncmp(cli_line, CLI_DMI, sizeof(CLI_DMI) - 1)) {
- set_mode(&cli_mode, DMI_MODE, hardware);
- continue;
- }
- if (!strncmp(cli_line, CLI_PXE, sizeof(CLI_PXE) - 1)) {
- set_mode(&cli_mode, PXE_MODE, hardware);
- continue;
- }
- if (!strncmp(cli_line, CLI_KERNEL, sizeof(CLI_KERNEL) - 1)) {
- 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;
- }
- if ( !strncmp(cli_line, CLI_VESA, sizeof(CLI_VESA) - 1) ) {
- set_mode(&cli_mode,VESA_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, hardware);
- break;
- case PCI_MODE:
- handle_pci_commands(cli_line, hardware);
- break;
- case HDT_MODE:
- handle_hdt_commands(cli_line, hardware);
- break;
- case CPU_MODE:
- handle_cpu_commands(cli_line, hardware);
- break;
- case PXE_MODE:
- handle_pxe_commands(cli_line, hardware);
- break;
- case VESA_MODE:
- handle_vesa_commands(cli_line, hardware);
- break;
- case SYSLINUX_MODE:
- handle_syslinux_commands(cli_line, hardware);
- break;
- case KERNEL_MODE:
- handle_kernel_commands(cli_line, hardware);
- break;
- case EXIT_MODE:
- break; /* should not happen */
- }
- }
+ int current_key = 0;
+ int future_history_pos=1; /* Temp variable*/
+ bool display_history=true; /* Temp Variable*/
+ char temp_command[MAX_LINE_SIZE];
+
+ struct s_cli cli;
+ cli.cursor_pos=0;
+ memset(cli.input, '\0', MAX_LINE_SIZE);
+ memset(cli.history, '\0', sizeof(cli.history));
+ cli.history_pos=1;
+ cli.max_history_pos=1;
+
+ set_mode(&cli, HDT_MODE, hardware);
+
+ printf("Entering CLI mode\n");
+
+ /* Display the cursor */
+ fputs("\033[?25h", stdout);
+
+ reset_prompt(&cli);
+
+ while (cli.mode != EXIT_MODE) {
+
+ //fgets(cli_line, sizeof cli_line, stdin);
+ current_key = get_key(stdin, 0);
+
+ switch (current_key) {
+ /* clear until then end of line */
+ case KEY_CTRL('k'):
+ /* Clear the end of the line */
+ fputs("\033[0K", stdout);
+ memset(&cli.input[cli.cursor_pos], 0,
+ strlen(cli.input) - cli.cursor_pos);
+ break;
+
+ case KEY_CTRL('c'):
+ more_printf("\n");
+ reset_prompt(&cli);
+ break;
+
+ case KEY_TAB:
+ break;
+
+ case KEY_LEFT:
+ if (cli.cursor_pos > 0) {
+ fputs("\033[1D", stdout);
+ cli.cursor_pos--;
+ }
+ break;
+
+ case KEY_RIGHT:
+ if (cli.cursor_pos < (int)strlen(cli.input)) {
+ fputs("\033[1C", stdout);
+ cli.cursor_pos++;
+ }
+ break;
+
+ case KEY_CTRL('e'):
+ case KEY_END:
+ /* Calling with a 0 value will make the cursor move */
+ /* So, let's move the cursor only if needed */
+ if ((strlen(cli.input) - cli.cursor_pos) > 0) {
+ memset(temp_command, 0, sizeof(temp_command));
+ sprintf(temp_command, "\033[%dC",
+ strlen(cli.input) - cli.cursor_pos);
+ /* Return to the begining of line */
+ fputs(temp_command, stdout);
+ cli.cursor_pos = strlen(cli.input);
+ }
+ break;
+
+ case KEY_CTRL('a'):
+ case KEY_HOME:
+ /* Calling with a 0 value will make the cursor move */
+ /* So, let's move the cursor only if needed */
+ if (cli.cursor_pos > 0) {
+ memset(temp_command, 0, sizeof(temp_command));
+ sprintf(temp_command, "\033[%dD",
+ cli.cursor_pos);
+ /* Return to the begining of line */
+ fputs(temp_command, stdout);
+ cli.cursor_pos = 0;
+ }
+ break;
+
+ case KEY_UP:
+ /* We have to compute the next position*/
+ future_history_pos=cli.history_pos;
+ if (future_history_pos==1) {
+ future_history_pos=MAX_HISTORY_SIZE-1;
+ } else {
+ future_history_pos--;
+ }
+ /* Does the next position is valid */
+ if (strlen(cli.history[future_history_pos])==0) break;
+
+ /* Let's make that future position the one we use*/
+ cli.history_pos=future_history_pos;
+
+ /* Clear the line */
+ fputs("\033[2K", stdout);
+
+ /* Move to the begining of line*/
+ fputs("\033[0G", stdout);
+
+ reset_prompt(&cli);
+ printf("%s",cli.history[cli.history_pos]);
+ strncpy(cli.input,cli.history[cli.history_pos],sizeof(cli.input));
+ cli.cursor_pos=strlen(cli.input);
+ break;
+
+ case KEY_DOWN:
+ display_history=true;
+
+ /* We have to compute the next position*/
+ future_history_pos=cli.history_pos;
+ if (future_history_pos==MAX_HISTORY_SIZE-1) {
+ future_history_pos=1;
+ } else {
+ future_history_pos++;
+ }
+ /* Does the next position is valid */
+ if (strlen(cli.history[future_history_pos])==0) display_history = false;
+
+ /* An exception is made to reach the last empty line */
+ if (future_history_pos==cli.max_history_pos) display_history=true;
+ if (display_history==false) break;
+
+ /* Let's make that future position the one we use*/
+ cli.history_pos=future_history_pos;
+
+ /* Clear the line */
+ fputs("\033[2K", stdout);
+
+ /* Move to the begining of line*/
+ fputs("\033[0G", stdout);
+
+ reset_prompt(&cli);
+ printf("%s",cli.history[cli.history_pos]);
+ strncpy(cli.input,cli.history[cli.history_pos],sizeof(cli.input));
+ cli.cursor_pos=strlen(cli.input);
+ break;
+
+ case KEY_ENTER:
+ more_printf("\n");
+ if (cli.history_pos == MAX_HISTORY_SIZE-1) cli.history_pos=1;
+ strncpy(cli.history[cli.history_pos],skipspace(cli.input),sizeof(cli.history[cli.history_pos]));
+ cli.history_pos++;
+ if (cli.history_pos>cli.max_history_pos) cli.max_history_pos=cli.history_pos;
+ exec_command(skipspace(cli.input), &cli, hardware);
+ reset_prompt(&cli);
+ break;
+
+ case KEY_BACKSPACE:
+ /* Don't delete prompt */
+ if (cli.cursor_pos == 0)
+ break;
+
+ for (int c = cli.cursor_pos - 1;
+ c < (int)strlen(cli.input) - 1; c++)
+ cli.input[c] = cli.input[c + 1];
+ cli.input[strlen(cli.input) - 1] = '\0';
+
+ /* Get one char back */
+ fputs("\033[1D", stdout);
+ /* Clear the end of the line */
+ fputs("\033[0K", stdout);
+
+ /* Print the resulting buffer */
+ printf("%s", cli.input + cli.cursor_pos - 1);
+
+ /* Realing to the place we were */
+ memset(temp_command, 0, sizeof(temp_command));
+ sprintf(temp_command, "\033[%dD",
+ strlen(cli.input + cli.cursor_pos - 1));
+ fputs(temp_command, stdout);
+ fputs("\033[1C", stdout);
+ /* Don't decrement the position unless
+ * if we are at then end of the line*/
+ if (cli.cursor_pos > (int)strlen(cli.input))
+ cli.cursor_pos--;
+ break;
+
+ case KEY_F1:
+ more_printf("\n");
+ exec_command(CLI_HELP, &cli, hardware);
+ reset_prompt(&cli);
+ break;
+
+ default:
+ if ( ( current_key < 0x20 ) || ( current_key > 0x7e ) ) break;
+ /* Prevent overflow */
+ if (cli.cursor_pos > MAX_LINE_SIZE - 2)
+ break;
+ /* If we aren't at the end of the input line, let's insert */
+ if (cli.cursor_pos < (int)strlen(cli.input)) {
+ char key[2];
+ int trailing_chars =
+ strlen(cli.input) - cli.cursor_pos;
+ memset(temp_command, 0, sizeof(temp_command));
+ strncpy(temp_command, cli.input,
+ cli.cursor_pos);
+ sprintf(key, "%c", current_key);
+ strncat(temp_command, key, 1);
+ strncat(temp_command,
+ cli.input + cli.cursor_pos,
+ trailing_chars);
+ memset(cli.input, 0, sizeof(cli.input));
+ snprintf(cli.input, sizeof(cli.input), "%s",
+ temp_command);
+
+ /* Clear the end of the line */
+ fputs("\033[0K", stdout);
+
+ /* Print the resulting buffer */
+ printf("%s", cli.input + cli.cursor_pos);
+ sprintf(temp_command, "\033[%dD",
+ trailing_chars);
+ /* Return where we must put the new char */
+ fputs(temp_command, stdout);
+
+ } else {
+ putchar(current_key);
+ cli.input[cli.cursor_pos] = current_key;
+ }
+ cli.cursor_pos++;
+ break;
+ }
+ }
}
-int do_exit(struct s_cli_mode *cli_mode)
+int do_exit(struct s_cli *cli)
{
- switch (cli_mode->mode) {
- case HDT_MODE:
- return EXIT_MODE;
- case KERNEL_MODE:
- case PXE_MODE:
- case SYSLINUX_MODE:
- case PCI_MODE:
- case DMI_MODE:
- case VESA_MODE:
- case CPU_MODE:
- return HDT_MODE;
- case EXIT_MODE:
- return EXIT_MODE; /* should not happen */
- }
- return HDT_MODE;
+ switch (cli->mode) {
+ case HDT_MODE:
+ return EXIT_MODE;
+ case KERNEL_MODE:
+ case PXE_MODE:
+ case SYSLINUX_MODE:
+ case PCI_MODE:
+ case DMI_MODE:
+ case VESA_MODE:
+ case CPU_MODE:
+ return HDT_MODE;
+ case EXIT_MODE:
+ return EXIT_MODE; /* should not happen */
+ }
+ return HDT_MODE;
}
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);
- show_dmi_memory_modules(hardware, false, false);
- }
- main_show_pci(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);
- if (hardware->is_pxe_valid)
- main_show_pxe(hardware);
+ int argc = 2;
+ char *argv[2] = { "0", "0" };
+ show_dmi_memory_modules(argc, argv, hardware);
+ }
+ main_show_pci(hardware);
- main_show_kernel(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);
+ 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);
+ more_printf(" %s\n", CLI_HDT);
+ if (hardware->sv->filesystem == SYSLINUX_FS_PXELINUX)
+ more_printf(" %s\n", CLI_PXE);
}
-void main_show(char *item, struct s_hardware *hardware)
+void main_show_hdt(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;
+ more_printf("HDT\n");
+ more_printf(" Product : %s\n", PRODUCT_NAME);
+ more_printf(" Version : %s\n", VERSION);
+ more_printf(" Author : %s\n", AUTHOR);
+ more_printf(" Contact : %s\n", CONTACT);
+ char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS;
+ for (int c=0; c<NB_CONTRIBUTORS; c++) {
+ more_printf(" Contributor : %s\n", contributors[c]);
}
+}
- show_main_help(hardware);
+
+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;
+ }
+ if (!strncmp(item, CLI_HDT, sizeof(CLI_HDT))) {
+ main_show_hdt(hardware);
+ return;
+ }
+ show_main_help(hardware);
}
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 72e46a36..05fb143b 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -29,9 +29,14 @@
#ifndef DEFINE_HDT_CLI_H
#define DEFINE_HDT_CLI_H
#include <stdio.h>
+#include <getkey.h>
#include "hdt-common.h"
+#define MAX_LINE_SIZE 256
+
+#define CLI_SPACE " "
+#define CLI_LF "\n"
#define CLI_CLEAR "clear"
#define CLI_EXIT "exit"
#define CLI_HELP "help"
@@ -62,14 +67,41 @@ typedef enum {
VESA_MODE,
} cli_mode_t;
-struct s_cli_mode {
+#define PROMPT_SIZE 32
+#define MAX_HISTORY_SIZE 32
+struct s_cli {
cli_mode_t mode;
- char prompt[32];
+ char prompt[PROMPT_SIZE];
+ char input[MAX_LINE_SIZE];
+ int cursor_pos;
+ char history[MAX_HISTORY_SIZE][MAX_LINE_SIZE];
+ int history_pos;
+ int max_history_pos;
+};
+
+/* A command-line command */
+struct commands_mode {
+ const unsigned int mode;
+ struct commands_module_descr* show_modules;
+ /* Future: set? */
+};
+
+struct commands_module {
+ const char *name;
+ void ( * exec ) ( int argc, char** argv, struct s_hardware *hardware );
+};
+
+/* Describe 'show', 'set', ... commands in a module */
+struct commands_module_descr {
+ struct commands_module* modules;
+ const int nb_modules;
};
+struct commands_mode dmi_mode;
+
void start_cli_mode(struct s_hardware *hardware);
void main_show(char *item, struct s_hardware *hardware);
-int do_exit(struct s_cli_mode *cli_mode);
+int do_exit(struct s_cli *cli);
// DMI STUFF
#define CLI_DMI_BASE_BOARD "base_board"
@@ -80,10 +112,11 @@ int do_exit(struct s_cli_mode *cli_mode);
#define CLI_DMI_MEMORY_BANK "bank"
#define CLI_DMI_PROCESSOR "cpu"
#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 handle_dmi_commands(char *cli_line, struct s_hardware *hardware);
-void show_dmi_memory_modules(struct s_hardware *hardware, bool clearscreen,
- bool show_free_banks);
+void show_dmi_memory_modules(int argc, char** argv, struct s_hardware *hardware);
// PCI STUFF
#define CLI_PCI_DEVICE "device"
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index fb0c4c9e..a2802f82 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -391,3 +391,13 @@ void clear_screen(void)
fputs("\033e\033%@\033)0\033(B\1#0\033[?25l\033[2J", stdout);
display_line_nb = 0;
}
+
+/* searching the next char that is not a space */
+char *skipspace(char *p)
+{
+ while (*p && *p <= ' ')
+ p++;
+
+ return p;
+}
+
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index 8cdf6636..99742f35 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -46,10 +46,9 @@ extern int display_line_nb;
#define more_printf(...) do {\
if (display_line_nb == 23) {\
- char tempbuf[10];\
- printf("Press enter to continue\n");\
+ printf("\nPress any key to continue\n");\
display_line_nb=0;\
- fgets(tempbuf, sizeof(tempbuf), stdin);\
+ get_key(stdin, 0);\
}\
printf ( __VA_ARGS__);\
display_line_nb++; \
@@ -121,6 +120,7 @@ struct s_hardware {
};
const char *find_argument(const char **argv, const char *argument);
+char *skipspace(char *p);
int detect_dmi(struct s_hardware *hardware);
void detect_disks(struct s_hardware *hardware);
void detect_pci(struct s_hardware *hardware);
diff --git a/com32/hdt/hdt-menu-about.c b/com32/hdt/hdt-menu-about.c
index ad3a820e..a5c1b0e6 100644
--- a/com32/hdt/hdt-menu-about.c
+++ b/com32/hdt/hdt-menu-about.c
@@ -39,25 +39,33 @@ void compute_aboutmenu(struct s_my_menu *menu)
set_menu_pos(SUBMENU_Y, SUBMENU_X);
- snprintf(buffer, sizeof buffer, "Product : %s", PRODUCT_NAME);
+ snprintf(buffer, sizeof buffer, "Product : %s", PRODUCT_NAME);
snprintf(statbuffer, sizeof statbuffer, "Product : %s", PRODUCT_NAME);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- snprintf(buffer, sizeof buffer, "Version : %s", VERSION);
+ snprintf(buffer, sizeof buffer, "Version : %s", VERSION);
snprintf(statbuffer, sizeof statbuffer, "Version : %s", VERSION);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- snprintf(buffer, sizeof buffer, "Author : %s", AUTHOR);
+ snprintf(buffer, sizeof buffer, "Author : %s", AUTHOR);
snprintf(statbuffer, sizeof statbuffer, "Author : %s", AUTHOR);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
- snprintf(buffer, sizeof buffer, "Contact : %s", CONTACT);
+ snprintf(buffer, sizeof buffer, "Contact : %s", CONTACT);
snprintf(statbuffer, sizeof statbuffer, "Contact : %s", CONTACT);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
+ char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS;
+ for (int c=0; c<NB_CONTRIBUTORS; c++) {
+ snprintf(buffer, sizeof buffer, "Contributor : %s", contributors[c]);
+ snprintf(statbuffer, sizeof statbuffer, "Contributor : %s", contributors[c]);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+
printf("MENU: About menu done (%d items)\n", menu->items_count);
}
diff --git a/com32/hdt/hdt-menu-vesa.c b/com32/hdt/hdt-menu-vesa.c
index d969a291..345d74bb 100644
--- a/com32/hdt/hdt-menu-vesa.c
+++ b/com32/hdt/hdt-menu-vesa.c
@@ -30,7 +30,7 @@
/* Submenu for the vesa card */
-void compute_vesa_card(struct s_my_menu *menu, struct s_hardware *hardware) {
+static void compute_vesa_card(struct s_my_menu *menu, struct s_hardware *hardware) {
char buffer[SUBMENULEN+1];
char statbuffer[STATLEN+1];
diff --git a/com32/hdt/hdt.c b/com32/hdt/hdt.c
index 93e2fa0b..467fe1ca 100644
--- a/com32/hdt/hdt.c
+++ b/com32/hdt/hdt.c
@@ -34,7 +34,7 @@
#include <stdio.h>
#include <console.h>
-
+#include <consoles.h>
#include "hdt.h"
#include "hdt-menu.h"
#include "hdt-cli.h"
@@ -60,8 +60,9 @@ int main(const int argc, const char *argv[])
/* Detecting Syslinux version */
detect_syslinux(&hardware);
+ console_ansi_raw();
/* Opening the Syslinux console */
- openconsole(&dev_stdcon_r, &dev_ansicon_w);
+// openconsole(&dev_stdcon_r, &dev_ansicon_w);
clear_screen();
printf("%s\n", version_string);
diff --git a/com32/hdt/hdt.h b/com32/hdt/hdt.h
index 9f96200b..a3a58771 100644
--- a/com32/hdt/hdt.h
+++ b/com32/hdt/hdt.h
@@ -32,7 +32,9 @@
#define PRODUCT_NAME "Hardware Detection Tool"
#define AUTHOR "Erwan Velu"
#define CONTACT "erwan(dot)velu(point)free(dot)fr"
-#define VERSION "0.2.4"
+#define VERSION "0.2.5"
+#define NB_CONTRIBUTORS 2
+#define CONTRIBUTORS {"Pierre-Alexandre Meyer", "Sebastien Gonzalve"}
#define ATTR_PACKED __attribute__((packed))