aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--com32/gplinclude/dmi/dmi.h2
-rw-r--r--com32/gplinclude/dmi/dmi_memory.h16
-rw-r--r--com32/gpllib/dmi/dmi.c16
-rw-r--r--com32/gpllib/dmi/dmi_memory.c91
-rw-r--r--com32/hdt/hdt-cli-dmi.c53
-rw-r--r--com32/hdt/hdt-cli-hdt.c19
-rw-r--r--com32/hdt/hdt-cli-memory.c7
-rw-r--r--com32/hdt/hdt-cli.c25
-rw-r--r--com32/hdt/hdt-cli.h1
-rw-r--r--com32/hdt/hdt-common.c11
-rw-r--r--com32/hdt/hdt-menu-dmi.c141
-rw-r--r--com32/hdt/hdt-menu-memory.c277
-rw-r--r--com32/hdt/hdt-menu.c3
-rw-r--r--com32/hdt/hdt.h2
-rw-r--r--com32/hdt/lib-ansi.c7
-rw-r--r--com32/hdt/lib-ansi.h1
16 files changed, 503 insertions, 169 deletions
diff --git a/com32/gplinclude/dmi/dmi.h b/com32/gplinclude/dmi/dmi.h
index 50cd4cac..f087df56 100644
--- a/com32/gplinclude/dmi/dmi.h
+++ b/com32/gplinclude/dmi/dmi.h
@@ -66,9 +66,11 @@ typedef struct {
s_chassis chassis;
s_processor processor;
s_battery battery;
+ s_memory_module memory_module[MAX_DMI_MEMORY_ITEMS];
s_memory memory[MAX_DMI_MEMORY_ITEMS];
s_ipmi ipmi;
s_cache cache[MAX_DMI_CACHE_ITEMS];
+ int memory_module_count;
int memory_count;
int cache_count;
dmi_table dmitable;
diff --git a/com32/gplinclude/dmi/dmi_memory.h b/com32/gplinclude/dmi/dmi_memory.h
index 2b744b5c..6939cd00 100644
--- a/com32/gplinclude/dmi/dmi_memory.h
+++ b/com32/gplinclude/dmi/dmi_memory.h
@@ -49,6 +49,17 @@ char part_number[MEMORY_PART_NUMBER_SIZE];
bool filled;
} s_memory;
+typedef struct {
+char socket_designation[8];
+char bank_connections[8];
+char speed[8];
+char type[16];
+char installed_size[8];
+char enabled_size[8];
+char error_status[8];
+bool filled;
+} s_memory_module;
+
void dmi_memory_array_error_handle(uint16_t code,char *array);
void dmi_memory_device_width(uint16_t code, char *width);
void dmi_memory_device_size(uint16_t code, char *size);
@@ -58,4 +69,9 @@ const char *dmi_memory_device_type(uint8_t code);
void dmi_memory_device_type_detail(uint16_t code,char *type_detail);
void dmi_memory_device_speed(uint16_t code, char *speed);
+void dmi_memory_module_connections(uint8_t, char*);
+void dmi_memory_module_speed(uint8_t, char*);
+void dmi_memory_module_types(uint16_t, const char*, char*);
+void dmi_memory_module_size(uint8_t, char*);
+void dmi_memory_module_error(uint8_t, const char*, char*);
#endif
diff --git a/com32/gpllib/dmi/dmi.c b/com32/gpllib/dmi/dmi.c
index d0e92a80..352483e9 100644
--- a/com32/gpllib/dmi/dmi.c
+++ b/com32/gpllib/dmi/dmi.c
@@ -517,6 +517,20 @@ void dmi_decode(struct dmi_header *h, uint16_t ver, s_dmi *dmi)
strcpy(dmi->processor.asset_tag,dmi_string(h, data[0x21]));
strcpy(dmi->processor.part_number,dmi_string(h, data[0x22]));
break;
+ case 6: /* 3.3.7 Memory Module Information */
+ if(h->length<0x0C) break;
+ dmi->memory_module_count++;
+ s_memory_module *module = &dmi->memory_module[dmi->memory_module_count-1];
+ dmi->memory_module[dmi->memory_module_count-1].filled=true;
+ strncpy(module->socket_designation, dmi_string(h, data[0x04]),
+ sizeof(module->socket_designation));
+ dmi_memory_module_connections(data[0x05], module->bank_connections);
+ dmi_memory_module_speed(data[0x06], module->speed);
+ dmi_memory_module_types(WORD(data+0x07), " ", module->type);
+ dmi_memory_module_size(data[0x09], module->installed_size);
+ dmi_memory_module_size(data[0x0A], module->enabled_size);
+ dmi_memory_module_error(data[0x0B], "\t\t", module->error_status);
+ break;
case 7: /* 3.3.8 Cache Information */
if(h->length<0x0F) break;
dmi->cache_count++;
@@ -549,7 +563,7 @@ void dmi_decode(struct dmi_header *h, uint16_t ver, s_dmi *dmi)
strcpy(dmi->cache[dmi->cache_count-1].associativity,
dmi_cache_associativity(data[0x12]));
break;
- case 17: /* 3.3.18 Memory Device */
+ case 17: /* 3.3.18 Memory Device */
if (h->length < 0x15) break;
dmi->memory_count++;
if (dmi->memory_count > MAX_DMI_MEMORY_ITEMS) break;
diff --git a/com32/gpllib/dmi/dmi_memory.c b/com32/gpllib/dmi/dmi_memory.c
index dc354df1..87edb6e9 100644
--- a/com32/gpllib/dmi/dmi_memory.c
+++ b/com32/gpllib/dmi/dmi_memory.c
@@ -170,3 +170,94 @@ void dmi_memory_device_speed(uint16_t code, char *speed)
sprintf(speed,"%u MHz", code);
}
+/*
+ * 3.3.7 Memory Module Information (Type 6)
+ */
+
+void dmi_memory_module_types(uint16_t code, const char *sep, char *type)
+{
+ /* 3.3.7.1 */
+ static const char *types[]={
+ "Other", /* 0 */
+ "Unknown",
+ "Standard",
+ "FPM",
+ "EDO",
+ "Parity",
+ "ECC",
+ "SIMM",
+ "DIMM",
+ "Burst EDO",
+ "SDRAM" /* 10 */
+ };
+
+ if((code&0x07FF)==0)
+ sprintf(type, "%s", "None");
+ else
+ {
+ int i;
+
+ for(i=0; i<=10; i++)
+ if(code&(1<<i))
+ sprintf(type, "%s%s", sep, types[i]);
+ }
+}
+
+void dmi_memory_module_connections(uint8_t code, char* connection)
+{
+ if(code==0xFF)
+ sprintf(connection, "%s", "None");
+ else
+ {
+ if((code&0xF0)!=0xF0)
+ sprintf(connection, "%u", code>>4);
+ if((code&0x0F)!=0x0F)
+ sprintf(connection, "%u", code&0x0F);
+ }
+}
+
+void dmi_memory_module_speed(uint8_t code, char* speed)
+{
+ if(code==0)
+ sprintf(speed, "%s", "Unknown");
+ else
+ sprintf(speed, "%u ns", code);
+}
+
+void dmi_memory_module_size(uint8_t code, char* size)
+{
+ /* 3.3.7.2 */
+ switch(code&0x7F)
+ {
+ case 0x7D:
+ sprintf(size, "%s", "Not Determinable");
+ break;
+ case 0x7E:
+ sprintf(size, "%s", "Disabled");
+ break;
+ case 0x7F:
+ sprintf(size, "%s", "Not Installed");
+ return;
+ default:
+ sprintf(size, "%u MB", 1<<(code&0x7F));
+ }
+
+ if(code&0x80)
+ printf(size, "%s", "(Double-bank Connection)");
+ else
+ printf(size, "%s", "(Single-bank Connection)");
+}
+
+void dmi_memory_module_error(uint8_t code, const char *prefix, char *error)
+{
+ if(code&(1<<2))
+ sprintf(error, "%s", "See Event Log\n");
+ else
+ { if((code&0x03)==0)
+ printf(error, "%s", "OK\n");
+ if(code&(1<<0))
+ printf(error, "%sUncorrectable Errors\n", prefix);
+ if(code&(1<<1))
+ printf(error, "%sCorrectable Errors\n", prefix);
+ }
+}
diff --git a/com32/hdt/hdt-cli-dmi.c b/com32/hdt/hdt-cli-dmi.c
index 3602ef8b..af289d14 100644
--- a/com32/hdt/hdt-cli-dmi.c
+++ b/com32/hdt/hdt-cli-dmi.c
@@ -55,6 +55,12 @@ static void show_dmi_modules(int argc __unused, char** argv __unused,
break;
}
}
+ for (int i = 0; i < hardware->dmi.memory_module_count; i++) {
+ if (hardware->dmi.memory_module[i].filled == true) {
+ printf("\tmodule <number>\n");
+ break;
+ }
+ }
if (hardware->dmi.processor.filled == true)
printf("\t%s\n", CLI_DMI_PROCESSOR);
if (hardware->dmi.system.filled == true)
@@ -309,7 +315,7 @@ static void show_dmi_cpu(int argc __unused, char** argv __unused,
}
}
-static void show_dmi_memory_bank(int argc, char** argv,
+void show_dmi_memory_bank(int argc, char** argv,
struct s_hardware *hardware)
{
int bank = -1;
@@ -410,6 +416,47 @@ static void show_dmi_cache(int argc, char** argv,
hardware->dmi.cache[cache].associativity);
}
+void show_dmi_memory_module(int argc, char** argv,
+ struct s_hardware *hardware)
+{
+ int module = -1;
+
+ /* Sanitize arguments */
+ if (argc > 0)
+ module = strtol(argv[0], (char **)NULL, 10);
+
+ if (errno == ERANGE || module < 0) {
+ printf("This module number is incorrect\n");
+ return;
+ }
+
+ if ((module >= hardware->dmi.memory_module_count) || (module < 0)) {
+ printf("Module number %d doesn't exist\n", module);
+ return;
+ }
+
+ if (hardware->dmi.memory_module[module].filled == false) {
+ printf("Module %d doesn't contain any information\n", module);
+ return;
+ }
+
+ printf("Memory Module %d\n", module);
+ printf(" Socket Designation : %s\n",
+ hardware->dmi.memory_module[module].socket_designation);
+ printf(" Bank Connections : %s\n",
+ hardware->dmi.memory_module[module].bank_connections);
+ printf(" Current Speed : %s\n",
+ hardware->dmi.memory_module[module].speed);
+ printf(" Type : %s\n",
+ hardware->dmi.memory_module[module].type);
+ printf(" Installed Size : %s\n",
+ hardware->dmi.memory_module[module].installed_size);
+ printf(" Enabled Size : %s\n",
+ hardware->dmi.memory_module[module].enabled_size);
+ printf(" Error Status : %s\n",
+ hardware->dmi.memory_module[module].error_status);
+}
+
void main_show_dmi(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
@@ -511,6 +558,10 @@ struct cli_callback_descr list_dmi_show_modules[] = {
.exec = show_dmi_memory_bank,
},
{
+ .name = "module",
+ .exec = show_dmi_memory_module,
+ },
+ {
.name = CLI_DMI_PROCESSOR,
.exec = show_dmi_cpu,
},
diff --git a/com32/hdt/hdt-cli-hdt.c b/com32/hdt/hdt-cli-hdt.c
index 8069b190..5bebf584 100644
--- a/com32/hdt/hdt-cli-hdt.c
+++ b/com32/hdt/hdt-cli-hdt.c
@@ -54,9 +54,10 @@ static void main_show_modes(int argc __unused, char** argv __unused,
printf("Available modes:\n");
while (list_modes[i]) {
- printf("\t%s\n", list_modes[i]->name);
+ printf("%s ", list_modes[i]->name);
i++;
}
+ printf("\n");
}
/**
@@ -132,25 +133,27 @@ static void show_cli_help(int argc __unused, char** argv __unused,
/* List secondly the show modules of the mode */
if (current_mode->show_modules &&
current_mode->show_modules->modules) {
- printf("show commands:\n");
+ printf("\nshow commands:\n");
j = 0;
while (current_mode->show_modules->modules[j].name) {
- printf("\t%s\n",
+ printf("%s ",
current_mode->show_modules->modules[j].name);
j++;
}
+ printf("\n");
}
/* List thirdly the set modules of the mode */
if (current_mode->set_modules &&
current_mode->set_modules->modules) {
- printf("set commands:\n");
+ printf("\nset commands:\n");
j = 0;
while (current_mode->set_modules->modules[j].name) {
- printf("\t%s\n",
+ printf("%s ",
current_mode->set_modules->modules[j].name);
j++;
}
+ printf("\n");
}
/* List finally the default modules of the hdt mode */
@@ -177,6 +180,7 @@ static void show_cli_help(int argc __unused, char** argv __unused,
printf("\n");
}
+ printf("\n");
main_show_modes(argc, argv, hardware);
}
@@ -312,7 +316,10 @@ struct cli_callback_descr list_hdt_show_modules[] = {
.name = CLI_VPD,
.exec = main_show_vpd,
},
-
+ {
+ .name = CLI_MEMORY,
+ .exec = show_dmi_memory_modules,
+ },
{
.name = "modes",
.exec = main_show_modes,
diff --git a/com32/hdt/hdt-cli-memory.c b/com32/hdt/hdt-cli-memory.c
index e0516aef..89f871e1 100644
--- a/com32/hdt/hdt-cli-memory.c
+++ b/com32/hdt/hdt-cli-memory.c
@@ -42,6 +42,7 @@ static void show_memory_e820(int argc __unused, char **argv __unused,
detect_memory_e820(map, E820MAX, &count);
printf("BIOS-provided physical RAM e820 map:\n");
+ reset_more_printf();
for (int i = 0; i < count; i++) {
get_type(map[i].type, type, 14);
more_printf("%016llx - %016llx %016llx (%s)\n",
@@ -55,6 +56,7 @@ static void show_memory_e801(int argc __unused, char **argv __unused,
{
int mem_low, mem_high = 0;
+ reset_more_printf();
if (detect_memory_e801(&mem_low, &mem_high)) {
more_printf("e801 bogus!\n");
} else {
@@ -68,6 +70,7 @@ static void show_memory_88(int argc __unused, char **argv __unused,
{
int mem_size = 0;
+ reset_more_printf();
if (detect_memory_88(&mem_size)) {
more_printf("8800h bogus!\n");
} else {
@@ -89,6 +92,10 @@ struct cli_callback_descr list_memory_show_modules[] = {
.name = "88",
.exec = show_memory_88,
},
+ {
+ .name = CLI_DMI_MEMORY_BANK,
+ .exec = show_dmi_memory_bank,
+ },
{
.name = NULL,
.exec = NULL,
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index c77a8bef..0d38fb2b 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -775,16 +775,23 @@ void start_cli_mode(struct s_hardware *hardware)
printf("Entering CLI mode\n");
- /* Display the cursor */
- display_cursor(true);
-
reset_prompt();
while (hdt_cli.mode != EXIT_MODE) {
- //fgets(cli_line, sizeof cli_line, stdin);
+ /* Display the cursor */
+ display_cursor(true);
+
+ /* Let's put the cursor blinking until we get an input */
+ set_cursor_blink(true);
+
+ /* We wait endlessly for a keyboard input*/
current_key = get_key(stdin, 0);
+ /* We have to cancel the blinking mode to prevent
+ * input text to blink */
+ set_cursor_blink(false);
+
/* Reset autocomplete buffer unless TAB is pressed */
if (current_key != KEY_TAB)
autocomplete_destroy_list();
@@ -977,14 +984,10 @@ void start_cli_mode(struct s_hardware *hardware)
/* Print the resulting buffer */
printf("%s", hdt_cli.input + hdt_cli.cursor_pos - 1);
- /* Realing to the place we were */
- move_cursor_left(strlen(hdt_cli.input + hdt_cli.cursor_pos - 1));
- move_cursor_right(1);
+ /* Realing to a char before the place we were */
+ hdt_cli.cursor_pos--;
+ move_cursor_to_column(strlen(hdt_cli.prompt)+hdt_cli.cursor_pos+1);
- /* Don't decrement the position unless
- * if we are at then end of the line*/
- if (hdt_cli.cursor_pos > (int)strlen(hdt_cli.input))
- hdt_cli.cursor_pos--;
break;
case KEY_F1:
diff --git a/com32/hdt/hdt-cli.h b/com32/hdt/hdt-cli.h
index 7c435959..88999408 100644
--- a/com32/hdt/hdt-cli.h
+++ b/com32/hdt/hdt-cli.h
@@ -171,6 +171,7 @@ void main_show(char *item, struct s_hardware *hardware);
#define CLI_DMI_LIST CLI_SHOW_LIST
void main_show_dmi(int argc, char **argv, struct s_hardware *hardware);
void show_dmi_memory_modules(int argc, char** argv, struct s_hardware *hardware);
+void show_dmi_memory_bank(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 33645ffb..0f98ab9e 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -257,18 +257,17 @@ void detect_disks(struct s_hardware *hardware)
if (hardware->disk_detection)
return;
- /* FIXME: this is needed to have the int13 working.
- * Until we figured why, we need this workaround*/
- detect_vesa(hardware);
-
hardware->disk_detection = true;
for (int drive = 0x80; drive < 0xff; drive++) {
i++;
hardware->disk_info[i].disk = drive;
err = get_drive_parameters(&hardware->disk_info[i]);
- /* Do not print output when drive does not exists */
- if (err == -1)
+ /*
+ * Do not print output when drive does not exist or
+ * doesn't support int13 (cdrom, ...)
+ */
+ if (err == -1 || !hardware->disk_info[i].cbios)
continue;
if (err) {
diff --git a/com32/hdt/hdt-menu-dmi.c b/com32/hdt/hdt-menu-dmi.c
index a3a3a8e6..77ee90e5 100644
--- a/com32/hdt/hdt-menu-dmi.c
+++ b/com32/hdt/hdt-menu-dmi.c
@@ -245,147 +245,6 @@ void compute_motherboard(struct s_my_menu *menu, s_dmi * dmi)
printf("MENU: Motherboard menu done (%d items)\n", menu->items_count);
}
-/* Compute the Memory submenu */
-static void compute_memory_module(struct s_my_menu *menu, s_dmi * dmi,
- int slot_number)
-{
- int i = slot_number;
- char buffer[MENULEN + 1];
- char statbuffer[STATLEN + 1];
-
- sprintf(buffer, " Bank <%d> ", i);
- menu->items_count = 0;
- menu->menu = add_menu(buffer, -1);
-
- snprintf(buffer, sizeof buffer, "Form Factor : %s",
- dmi->memory[i].form_factor);
- snprintf(statbuffer, sizeof statbuffer, "Form Factor: %s",
- dmi->memory[i].form_factor);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Type : %s",
- dmi->memory[i].type);
- snprintf(statbuffer, sizeof statbuffer, "Type: %s",
- dmi->memory[i].type);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Type Details : %s",
- dmi->memory[i].type_detail);
- snprintf(statbuffer, sizeof statbuffer, "Type Details: %s",
- dmi->memory[i].type_detail);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Speed : %s",
- dmi->memory[i].speed);
- snprintf(statbuffer, sizeof statbuffer, "Speed (Mhz): %s",
- dmi->memory[i].speed);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Size : %s",
- dmi->memory[i].size);
- snprintf(statbuffer, sizeof statbuffer, "Size: %s",
- dmi->memory[i].size);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Device Set : %s",
- dmi->memory[i].device_set);
- snprintf(statbuffer, sizeof statbuffer, "Device Set: %s",
- dmi->memory[i].device_set);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Device Loc. : %s",
- dmi->memory[i].device_locator);
- snprintf(statbuffer, sizeof statbuffer, "Device Location: %s",
- dmi->memory[i].device_locator);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Bank Locator : %s",
- dmi->memory[i].bank_locator);
- snprintf(statbuffer, sizeof statbuffer, "Bank Locator: %s",
- dmi->memory[i].bank_locator);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Total Width : %s",
- dmi->memory[i].total_width);
- snprintf(statbuffer, sizeof statbuffer, "Total bit Width: %s",
- dmi->memory[i].total_width);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Data Width : %s",
- dmi->memory[i].data_width);
- snprintf(statbuffer, sizeof statbuffer, "Data bit Width: %s",
- dmi->memory[i].data_width);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Error : %s",
- dmi->memory[i].error);
- snprintf(statbuffer, sizeof statbuffer, "Error: %s",
- dmi->memory[i].error);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Vendor : %s",
- dmi->memory[i].manufacturer);
- snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
- dmi->memory[i].manufacturer);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Serial : %s",
- dmi->memory[i].serial);
- snprintf(statbuffer, sizeof statbuffer, "Serial: %s",
- dmi->memory[i].serial);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Asset Tag : %s",
- dmi->memory[i].asset_tag);
- snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s",
- dmi->memory[i].asset_tag);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
- snprintf(buffer, sizeof buffer, "Part Number : %s",
- dmi->memory[i].part_number);
- snprintf(buffer, sizeof statbuffer, "Part Number: %s",
- dmi->memory[i].part_number);
- add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
-
-}
-
-/* Compute the Memory menu */
-void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi, struct s_hardware *hardware)
-{
- char buffer[MENULEN + 1];
- for (int i = 0; i < dmi->memory_count; i++) {
- compute_memory_module(&(menu->memory_sub_menu[i]), dmi, i);
- }
-
- menu->memory_menu.menu = add_menu(" Memory Banks ", -1);
- menu->memory_menu.items_count = 0;
-
- for (int i = 0; i < dmi->memory_count; i++) {
- snprintf(buffer, sizeof buffer, " Bank <%d> ", i);
- add_item(buffer, "Memory Bank", OPT_SUBMENU, NULL,
- menu->memory_sub_menu[i].menu);
- menu->memory_menu.items_count++;
- }
- printf("MENU: Memory menu done (%d items)\n",
- menu->memory_menu.items_count);
- add_item("Run Test", "Run Test", OPT_RUN, hardware->memtest_label, 0);
-}
-
/* Compute Main IPMI menu */
void compute_ipmi(struct s_my_menu *menu, s_dmi * dmi)
{
diff --git a/com32/hdt/hdt-menu-memory.c b/com32/hdt/hdt-menu-memory.c
new file mode 100644
index 00000000..ddc26fef
--- /dev/null
+++ b/com32/hdt/hdt-menu-memory.c
@@ -0,0 +1,277 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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 <memory.h>
+#include "hdt-menu.h"
+#define E820MAX 128
+
+/* Compute the e820 submenu */
+static void compute_e820(struct s_my_menu *menu)
+{
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ sprintf(buffer, " e820 Physical RAM map ");
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
+
+ struct e820entry map[E820MAX];
+ int count = 0;
+ char type[14];
+
+ detect_memory_e820(map, E820MAX, &count);
+ for (int j = 0; j < count; j++) {
+ get_type(map[j].type, type, 14);
+ snprintf(buffer, sizeof buffer,
+ "%016llx - %016llx (%s)",
+ map[j].addr, map[j].size,
+ remove_spaces(type));
+ snprintf(statbuffer, sizeof statbuffer,
+ "%016llx - %016llx (%s)",
+ map[j].addr, map[j].size,
+ remove_spaces(type));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ }
+}
+
+/* Compute the e801 submenu */
+static void compute_e801(struct s_my_menu *menu)
+{
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ sprintf(buffer, " e801 information ");
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
+
+ int mem_low, mem_high = 0;
+ if (detect_memory_e801(&mem_low, &mem_high)) {
+ snprintf(buffer, sizeof buffer, "%s", "e801 output is bogus");
+ snprintf(statbuffer, sizeof statbuffer, "%s", "e801 output is bogus");
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ } else {
+ snprintf(buffer, sizeof buffer, "%d Kb (%d MiB) - %d Kb (%d MiB)",
+ mem_low, mem_low >> 10, mem_high << 6, mem_high >> 4);
+ snprintf(statbuffer, sizeof statbuffer, "%d Kb (%d MiB) - %d Kb (%d MiB)",
+ mem_low, mem_low >> 10, mem_high << 6, mem_high >> 4);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ }
+ menu->items_count++;
+}
+
+/* Compute the e88 submenu */
+static void compute_e88(struct s_my_menu *menu)
+{
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ sprintf(buffer, " e88 information ");
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
+
+ int mem_size = 0;
+ if (detect_memory_88(&mem_size)) {
+ snprintf(buffer, sizeof buffer, "%s", "e88 output is bogus");
+ snprintf(statbuffer, sizeof statbuffer, "%s", "e88 output is bogus");
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+ } else {
+ snprintf(buffer, sizeof buffer, "%d Kb (%d MiB)",
+ mem_size, mem_size >> 10);
+ snprintf(statbuffer, sizeof statbuffer, "%d Kb (%d MiB)",
+ mem_size, mem_size >> 10);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ }
+ menu->items_count++;
+}
+/* Compute the Memory submenu */
+static void compute_memory_module(struct s_my_menu *menu, s_dmi * dmi,
+ int slot_number)
+{
+ int i = slot_number;
+ char buffer[MENULEN + 1];
+ char statbuffer[STATLEN + 1];
+
+ sprintf(buffer, " Bank <%d> ", i);
+ menu->items_count = 0;
+ menu->menu = add_menu(buffer, -1);
+
+ snprintf(buffer, sizeof buffer, "Form Factor : %s",
+ dmi->memory[i].form_factor);
+ snprintf(statbuffer, sizeof statbuffer, "Form Factor: %s",
+ dmi->memory[i].form_factor);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Type : %s",
+ dmi->memory[i].type);
+ snprintf(statbuffer, sizeof statbuffer, "Type: %s",
+ dmi->memory[i].type);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Type Details : %s",
+ dmi->memory[i].type_detail);
+ snprintf(statbuffer, sizeof statbuffer, "Type Details: %s",
+ dmi->memory[i].type_detail);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Speed : %s",
+ dmi->memory[i].speed);
+ snprintf(statbuffer, sizeof statbuffer, "Speed (Mhz): %s",
+ dmi->memory[i].speed);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Size : %s",
+ dmi->memory[i].size);
+ snprintf(statbuffer, sizeof statbuffer, "Size: %s",
+ dmi->memory[i].size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Device Set : %s",
+ dmi->memory[i].device_set);
+ snprintf(statbuffer, sizeof statbuffer, "Device Set: %s",
+ dmi->memory[i].device_set);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Device Loc. : %s",
+ dmi->memory[i].device_locator);
+ snprintf(statbuffer, sizeof statbuffer, "Device Location: %s",
+ dmi->memory[i].device_locator);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Bank Locator : %s",
+ dmi->memory[i].bank_locator);
+ snprintf(statbuffer, sizeof statbuffer, "Bank Locator: %s",
+ dmi->memory[i].bank_locator);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Total Width : %s",
+ dmi->memory[i].total_width);
+ snprintf(statbuffer, sizeof statbuffer, "Total bit Width: %s",
+ dmi->memory[i].total_width);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Data Width : %s",
+ dmi->memory[i].data_width);
+ snprintf(statbuffer, sizeof statbuffer, "Data bit Width: %s",
+ dmi->memory[i].data_width);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Error : %s",
+ dmi->memory[i].error);
+ snprintf(statbuffer, sizeof statbuffer, "Error: %s",
+ dmi->memory[i].error);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Vendor : %s",
+ dmi->memory[i].manufacturer);
+ snprintf(statbuffer, sizeof statbuffer, "Vendor: %s",
+ dmi->memory[i].manufacturer);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Serial : %s",
+ dmi->memory[i].serial);
+ snprintf(statbuffer, sizeof statbuffer, "Serial: %s",
+ dmi->memory[i].serial);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Asset Tag : %s",
+ dmi->memory[i].asset_tag);
+ snprintf(statbuffer, sizeof statbuffer, "Asset Tag: %s",
+ dmi->memory[i].asset_tag);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ snprintf(buffer, sizeof buffer, "Part Number : %s",
+ dmi->memory[i].part_number);
+ snprintf(buffer, sizeof statbuffer, "Part Number: %s",
+ dmi->memory[i].part_number);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+}
+
+/* Compute the Memory menu */
+void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi, struct s_hardware *hardware)
+{
+ char buffer[MENULEN + 1];
+ int i=0;
+ for (i = 0; i < dmi->memory_count; i++) {
+ compute_memory_module(&(menu->memory_sub_menu[i]), dmi, i);
+ }
+
+ compute_e820(&(menu->memory_sub_menu[++i]));
+ compute_e801(&(menu->memory_sub_menu[++i]));
+ compute_e88(&(menu->memory_sub_menu[++i]));
+
+ menu->memory_menu.menu = add_menu(" Memory Banks ", -1);
+ menu->memory_menu.items_count = 0;
+
+ for (i = 0; i < dmi->memory_count; i++) {
+ snprintf(buffer, sizeof buffer, " Bank <%d> ", i);
+ add_item(buffer, "Memory Bank", OPT_SUBMENU, NULL,
+ menu->memory_sub_menu[i].menu);
+ menu->memory_menu.items_count++;
+ }
+
+ add_item("", "", OPT_SEP, "", 0);
+
+ snprintf(buffer, sizeof buffer, " e820 ");
+ add_item(buffer, "e820 mapping", OPT_SUBMENU, NULL,
+ menu->memory_sub_menu[++i].menu);
+ menu->memory_menu.items_count++;
+
+ snprintf(buffer, sizeof buffer, " e801 ");
+ add_item(buffer, "e801 information", OPT_SUBMENU, NULL,
+ menu->memory_sub_menu[++i].menu);
+ menu->memory_menu.items_count++;
+
+ snprintf(buffer, sizeof buffer, " e88 ");
+ add_item(buffer, "e88 information", OPT_SUBMENU, NULL,
+ menu->memory_sub_menu[++i].menu);
+ menu->memory_menu.items_count++;
+
+ add_item("", "", OPT_SEP, "", 0);
+ printf("MENU: Memory menu done (%d items)\n",
+ menu->memory_menu.items_count);
+ add_item("Run Test", "Run Test", OPT_RUN, hardware->memtest_label, 0);
+}
diff --git a/com32/hdt/hdt-menu.c b/com32/hdt/hdt-menu.c
index ff615017..c37fd41b 100644
--- a/com32/hdt/hdt-menu.c
+++ b/com32/hdt/hdt-menu.c
@@ -195,8 +195,7 @@ void compute_main_menu(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
}
if (hdt_menu->memory_menu.items_count > 0) {
- snprintf(menu_item, sizeof(menu_item), "<M>emory (%2d)\n",
- hdt_menu->memory_menu.items_count);
+ snprintf(menu_item, sizeof(menu_item), "<M>emory\n");
add_item(menu_item, "Memory Menu", OPT_SUBMENU, NULL,
hdt_menu->memory_menu.menu);
hdt_menu->main_menu.items_count++;
diff --git a/com32/hdt/hdt.h b/com32/hdt/hdt.h
index e29c7bfe..94ce1f48 100644
--- a/com32/hdt/hdt.h
+++ b/com32/hdt/hdt.h
@@ -32,7 +32,7 @@
#define PRODUCT_NAME "Hardware Detection Tool"
#define AUTHOR "Erwan Velu"
#define CONTACT "hdt@zytor.com"
-#define VERSION "0.3.2"
+#define VERSION "0.3.3"
#define NB_CONTRIBUTORS 2
#define CONTRIBUTORS {"Pierre-Alexandre Meyer", "Sebastien Gonzalve"}
diff --git a/com32/hdt/lib-ansi.c b/com32/hdt/lib-ansi.c
index 12e5ecc7..411dba80 100644
--- a/com32/hdt/lib-ansi.c
+++ b/com32/hdt/lib-ansi.c
@@ -61,6 +61,13 @@ void move_cursor_right(int count) {
fputs(buffer, stdout);
}
+void set_cursor_blink(bool status) {
+ if (status == true)
+ fputs("\033[05m",stdout);
+ else
+ fputs("\033[0m",stdout);
+}
+
void clear_line() {
fputs("\033[2K", stdout);
}
diff --git a/com32/hdt/lib-ansi.h b/com32/hdt/lib-ansi.h
index 2a17766f..0b0d0d18 100644
--- a/com32/hdt/lib-ansi.h
+++ b/com32/hdt/lib-ansi.h
@@ -40,4 +40,5 @@ void disable_utf8();
void set_g1_special_char();
void set_us_g0_charset();
void clear_entire_screen();
+void set_cursor_blink(bool status);
#endif