aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErwan Velu <erwan.velu@free.fr>2009-02-21 16:16:06 +0100
committerH. Peter Anvin <hpa@zytor.com>2009-02-25 20:58:43 -0800
commita08ad3c383f507e6e9be90d6b7df50d327e29574 (patch)
tree8cdbdf45436afb6239a784be2b26f3a57c339eae
parent1ec10a1ea1122d85455dc7d2d8ce27831a35cf16 (diff)
downloadsyslinux-elf-a08ad3c383f507e6e9be90d6b7df50d327e29574.tar.gz
syslinux-elf-a08ad3c383f507e6e9be90d6b7df50d327e29574.tar.xz
syslinux-elf-a08ad3c383f507e6e9be90d6b7df50d327e29574.zip
hdt: Adding CLEAR command Support both memory & bank commands from dmi mode
-rw-r--r--com32/hdt/hdt-cli-dmi.c68
-rw-r--r--com32/hdt/hdt-cli.c10
-rw-r--r--com32/hdt/hdt-cli.h3
3 files changed, 77 insertions, 4 deletions
diff --git a/com32/hdt/hdt-cli-dmi.c b/com32/hdt/hdt-cli-dmi.c
index 0bc2e57b..5f0b543d 100644
--- a/com32/hdt/hdt-cli-dmi.c
+++ b/com32/hdt/hdt-cli-dmi.c
@@ -30,6 +30,64 @@
#include "hdt-common.h"
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+void show_dmi_memory_modules(struct s_hardware *hardware) {
+ char bank_number[10];
+ char available_dmi_commands[1024];
+ bool found=false;
+ memset(available_dmi_commands,0,sizeof(available_dmi_commands));
+
+ for (int i=0;i<hardware->dmi.memory_count;i++) {
+ if (hardware->dmi.memory[i].filled==true) {
+ found=true;
+ strncat(available_dmi_commands,CLI_DMI_MEMORY_BANK,sizeof(CLI_DMI_MEMORY_BANK)-1);
+ memset(bank_number,0,sizeof(bank_number));
+ snprintf(bank_number,sizeof(bank_number),"%d ",i);
+ strncat(available_dmi_commands,bank_number,sizeof(bank_number));
+ printf("bank%d: %s %s@%s\n",i,hardware->dmi.memory[i].size, hardware->dmi.memory[i].type, hardware->dmi.memory[i].speed);
+ }
+}
+ if (found == true) {
+ printf("Type 'show bank<bank_number>' for more details.\n");
+ } else {
+ printf("No memory module found\n");
+ }
+}
+
+void show_dmi_memory_bank(struct s_hardware *hardware, const char *item) {
+ long bank = strtol(item,(char **) NULL,10);
+ if (errno == ERANGE) {
+ printf("This bank number is incorrect\n");
+ return;
+ }
+ if ((bank>=hardware->dmi.memory_count) || (bank<0)) {
+ printf("Bank %d number doesn't exists\n",bank);
+ return;
+ }
+
+ if (hardware->dmi.memory[bank].filled==false) {
+ printf("Bank %d doesn't contain any information\n",bank);
+ return;
+ }
+ printf("Memory Bank %d\n",bank);
+ more_printf(" Form Factor : %s\n",hardware->dmi.memory[bank].form_factor);
+ more_printf(" Type : %s\n",hardware->dmi.memory[bank].type);
+ more_printf(" Type Detail : %s\n",hardware->dmi.memory[bank].type_detail);
+ more_printf(" Speed : %s\n",hardware->dmi.memory[bank].speed);
+ more_printf(" Size : %s\n",hardware->dmi.memory[bank].size);
+ more_printf(" Device Set : %s\n",hardware->dmi.memory[bank].device_set);
+ more_printf(" Device Loc. : %s\n",hardware->dmi.memory[bank].device_locator);
+ more_printf(" Bank Locator : %s\n",hardware->dmi.memory[bank].bank_locator);
+ more_printf(" Total Width : %s\n",hardware->dmi.memory[bank].total_width);
+ more_printf(" Data Width : %s\n",hardware->dmi.memory[bank].data_width);
+ more_printf(" Error : %s\n",hardware->dmi.memory[bank].error);
+ more_printf(" Vendor : %s\n",hardware->dmi.memory[bank].manufacturer);
+ more_printf(" Serial : %s\n",hardware->dmi.memory[bank].serial);
+ more_printf(" Asset Tag : %s\n",hardware->dmi.memory[bank].asset_tag);
+ more_printf(" Part Number : %s\n",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) ) {
@@ -52,6 +110,14 @@ void dmi_show(char *item, struct s_hardware *hardware) {
show_dmi_cpu(hardware);
return;
}
+ if ( !strncmp(item, CLI_DMI_MEMORY, sizeof(CLI_DMI_MEMORY) - 1) ) {
+ show_dmi_memory_modules(hardware);
+ 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_DMI_MODULES, sizeof(CLI_DMI_MODULES) - 1) ) {
show_dmi_modules(hardware);
return;
@@ -89,7 +155,7 @@ void show_dmi_modules(struct s_hardware *hardware) {
for (int i=0;i<hardware->dmi.memory_count;i++) {
if (hardware->dmi.memory[i].filled==true) {
strncat(available_dmi_commands,CLI_DMI_MEMORY,sizeof(CLI_DMI_MEMORY)-1);
- strncat(available_dmi_commands," ",1);
+ strncat(available_dmi_commands," bank<bank_number> ",19);
break;
}
}
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 0497f9eb..7b1d489b 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -101,6 +101,10 @@ void start_cli_mode(int argc, char *argv[]) {
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_DMI, sizeof(CLI_DMI) - 1) ) {
set_mode(&cli_mode,DMI_MODE,&hardware);
continue;
@@ -129,13 +133,13 @@ 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\n",CLI_EXIT,CLI_HELP,CLI_SHOW, CLI_PCI, CLI_DMI);
+ printf("Available commands are : %s %s %s %s %s %s\n",CLI_CLEAR, CLI_EXIT,CLI_HELP,CLI_SHOW, CLI_PCI, CLI_DMI);
break;
case PCI_MODE:
- printf("Available commands are : %s %s %s\n",CLI_EXIT, CLI_HELP, CLI_SHOW);
+ printf("Available commands are : %s %s %s %s\n",CLI_CLEAR, CLI_EXIT, CLI_HELP, CLI_SHOW);
break;
case DMI_MODE:
- printf("Available commands are : %s %s %s\n",CLI_EXIT, CLI_HELP, CLI_SHOW);
+ printf("Available commands are : %s %s %s %s\n",CLI_CLEAR, CLI_EXIT, CLI_HELP, CLI_SHOW);
break;
}
}
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index f4022e6e..e130b520 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -31,17 +31,20 @@
#include <stdio.h>
#include "hdt-common.h"
+#define CLI_CLEAR "clear"
#define CLI_EXIT "exit"
#define CLI_HELP "help"
#define CLI_SHOW "show"
#define CLI_HDT "hdt"
#define CLI_PCI "pci"
+#define CLI_COMMANDS "commands"
#define CLI_DMI "dmi"
#define CLI_DMI_BASE_BOARD "base_board"
#define CLI_DMI_BATTERY "battery"
#define CLI_DMI_BIOS "bios"
#define CLI_DMI_CHASSIS "chassis"
#define CLI_DMI_MEMORY "memory"
+#define CLI_DMI_MEMORY_BANK "bank"
#define CLI_DMI_PROCESSOR "processor"
#define CLI_DMI_SYSTEM "system"
#define CLI_DMI_MODULES "modules"