summaryrefslogtreecommitdiff
path: root/com32/hdt
diff options
context:
space:
mode:
authorErwan Velu <erwan.velu@free.fr>2009-11-23 13:44:51 +0100
committerErwan Velu <erwan.velu@free.fr>2009-11-23 13:44:51 +0100
commitbb88c66722eedcf2a2e5fb03051c6cef4c9ad5a3 (patch)
tree0fdcd43bbc4e93444a5c4a0f5ea573213e833e43 /com32/hdt
parentd7ddef0afcc7224a002a4e9cb3e54a3c216d0f6f (diff)
downloadsyslinux-bb88c66722eedcf2a2e5fb03051c6cef4c9ad5a3.tar.gz
hdt: Improving memory detection
Impact: Detect memory size even if dmi is broken This commit uses e820/e801/e88 memory detection to find the memory size. That allow to display the memory size even if the dmi table is broken
Diffstat (limited to 'com32/hdt')
-rw-r--r--com32/hdt/hdt-cli-dmi.c4
-rw-r--r--com32/hdt/hdt-cli-memory.c21
-rw-r--r--com32/hdt/hdt-common.c1
-rw-r--r--com32/hdt/hdt-common.h1
-rw-r--r--com32/hdt/hdt-menu-memory.c48
-rw-r--r--com32/hdt/hdt-menu-summary.c70
-rw-r--r--com32/hdt/hdt-menu.c7
7 files changed, 80 insertions, 72 deletions
diff --git a/com32/hdt/hdt-cli-dmi.c b/com32/hdt/hdt-cli-dmi.c
index 0bf0f976..766a3cba 100644
--- a/com32/hdt/hdt-cli-dmi.c
+++ b/com32/hdt/hdt-cli-dmi.c
@@ -528,6 +528,10 @@ void show_dmi_memory_modules(int argc __unused, char** argv __unused,
/* Needed, if called by the memory mode */
detect_dmi(hardware);
+
+ more_printf("Memory Size : %lu MB (%lu KB)\n",
+ hardware->detected_memory_size>>10,
+ hardware->detected_memory_size);
if ((hardware->dmi.memory_count <= 0) && (hardware->dmi.memory_module_count <= 0)) {
more_printf("No memory bank found\n");
diff --git a/com32/hdt/hdt-cli-memory.c b/com32/hdt/hdt-cli-memory.c
index 86a34ba2..a51569fc 100644
--- a/com32/hdt/hdt-cli-memory.c
+++ b/com32/hdt/hdt-cli-memory.c
@@ -31,17 +31,18 @@
#include "hdt-cli.h"
#include "hdt-common.h"
-#define E820MAX 128
-
static void show_memory_e820(int argc __unused, char **argv __unused,
struct s_hardware *hardware __unused)
{
struct e820entry map[E820MAX];
+ unsigned long memsize=0;
int count = 0;
char type[14];
detect_memory_e820(map, E820MAX, &count);
+ memsize=memsize_e820(map,count);
reset_more_printf();
+ more_printf("Detected RAM : %lu MiB (%lu KiB)\n",memsize>>10,memsize);
more_printf("BIOS-provided physical RAM e820 map:\n");
for (int i = 0; i < count; i++) {
get_type(map[i].type, type, 14);
@@ -49,6 +50,19 @@ static void show_memory_e820(int argc __unused, char **argv __unused,
map[i].addr, map[i].size, map[i].addr+map[i].size,
remove_spaces(type));
}
+ struct e820entry nm[E820MAX];
+
+ /* Clean up, adjust and copy the BIOS-supplied E820-map. */
+ int nr = sanitize_e820_map(map, nm, count);
+
+ more_printf("\n");
+ more_printf("Sanitized e820 map:\n");
+ for (int i = 0; i < nr; i++) {
+ get_type(nm[i].type, type, 14);
+ more_printf("%016llx - %016llx %016llx (%s)\n",
+ nm[i].addr, nm[i].size, nm[i].addr+nm[i].size,
+ remove_spaces(type));
+ }
}
static void show_memory_e801(int argc __unused, char **argv __unused,
@@ -60,7 +74,8 @@ static void show_memory_e801(int argc __unused, char **argv __unused,
if (detect_memory_e801(&mem_low, &mem_high)) {
more_printf("e801 bogus!\n");
} else {
- more_printf("e801: %d Kb (%d MiB) - %d Kb (%d MiB)\n",
+ more_printf("Detected RAM : %d MiB(%d KiB)\n",(mem_low>>10) + (mem_high>>4),mem_low+(mem_high << 6));
+ more_printf("e801 details : %d Kb (%d MiB) - %d Kb (%d MiB)\n",
mem_low, mem_low >> 10, mem_high << 6, mem_high >> 4);
}
}
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index 6ee67165..bde1f375 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -163,6 +163,7 @@ void init_hardware(struct s_hardware *hardware)
hardware->is_pxe_valid = false;
hardware->is_vpd_valid = false;
hardware->pci_domain = NULL;
+ hardware->detected_memory_size = 0;
/* Cleaning structures */
memset(hardware->disk_info, 0, sizeof(hardware->disk_info));
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index 204ba497..fc24f638 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -166,6 +166,7 @@ struct s_hardware {
int disks_count; /* Number of detected disks */
struct s_pxe pxe;
struct s_vesa vesa;
+ unsigned long detected_memory_size; /* The detected memory size (in KB) */
int pci_ids_return_code;
int modules_pcimap_return_code;
diff --git a/com32/hdt/hdt-menu-memory.c b/com32/hdt/hdt-menu-memory.c
index bbb29786..a85b1fa2 100644
--- a/com32/hdt/hdt-menu-memory.c
+++ b/com32/hdt/hdt-menu-memory.c
@@ -45,6 +45,14 @@ static void compute_e820(struct s_my_menu *menu)
char type[14];
detect_memory_e820(map, E820MAX, &count);
+ unsigned long memory_size = memsize_e820(map, count);
+ snprintf(buffer, sizeof buffer,"Detected Memory - %lu MiB (%lu KiB)",
+ memory_size>>10, memory_size);
+ snprintf(statbuffer, sizeof statbuffer,"Detected Memory : %lu MiB (%lu KiB)",
+ memory_size>>10, memory_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ add_item("", "", OPT_SEP, "", 0);
+
for (int j = 0; j < count; j++) {
get_type(map[j].type, type, 14);
snprintf(buffer, sizeof buffer,
@@ -70,6 +78,7 @@ static void compute_e801(struct s_my_menu *menu)
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");
@@ -77,11 +86,25 @@ static void compute_e801(struct s_my_menu *menu)
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);
+ snprintf(buffer, sizeof buffer, "Detected Memory : %d MiB (%d KiB)",
+ (mem_high >> 4)+(mem_low >> 10),mem_low+(mem_high << 6));
+ snprintf(statbuffer, sizeof statbuffer,"Detected Memory : %d MiB (%d KiB)",
+ (mem_high >> 4)+(mem_low >> 10),mem_low+(mem_high << 6));
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ add_item("", "", OPT_SEP, "", 0);
+ snprintf(buffer, sizeof buffer, "Low Memory : %d KiB (%d MiB)",
+ mem_low, mem_low >> 10);
+ snprintf(statbuffer, sizeof statbuffer, "Low Memory : %d KiB (%d MiB)",
+ mem_low, mem_low >> 10);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
+ snprintf(buffer, sizeof buffer, "High Memory : %d KiB (%d MiB)",
+ mem_high << 6, mem_high >> 4);
+ snprintf(statbuffer, sizeof statbuffer, "High Memory : %d KiB (%d MiB)",
+ mem_high << 6, mem_high >> 4);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+
}
menu->items_count++;
}
@@ -103,10 +126,10 @@ static void compute_e88(struct s_my_menu *menu)
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);
+ snprintf(buffer, sizeof buffer, "Detected Memory : %d MiB (%d KiB)",
+ mem_size >> 10, mem_size);
+ snprintf(statbuffer, sizeof statbuffer, "Detected Memory : %d MiB (%d KiB)",
+ mem_size >> 10, mem_size);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
}
menu->items_count++;
@@ -322,10 +345,17 @@ void compute_memory(struct s_hdt_menu *menu, s_dmi * dmi, struct s_hardware *har
menu->memory_menu.menu = add_menu(" Memory ", -1);
menu->memory_menu.items_count = 0;
+ snprintf(buffer, sizeof(buffer), " %lu MB detected ",
+ hardware->detected_memory_size>>10);
+ add_item(buffer, "Detected Memory", OPT_INACTIVE, NULL,menu->memory_sub_menu[0].menu);
+ menu->memory_menu.items_count++;
+
+ add_item("", "", OPT_SEP, "", 0);
+
if (memory_count==0) {
snprintf(buffer, sizeof buffer, " No memory bank detected ");
add_item(buffer, "Memory Bank", OPT_INACTIVE, NULL,
- menu->memory_sub_menu[0].menu);
+ menu->memory_sub_menu[1].menu);
menu->memory_menu.items_count++;
} else for (i = 0; i < memory_count; i++) {
snprintf(buffer, sizeof buffer, " Bank <%d> ", i);
diff --git a/com32/hdt/hdt-menu-summary.c b/com32/hdt/hdt-menu-summary.c
index eba01280..2cc0c8b9 100644
--- a/com32/hdt/hdt-menu-summary.c
+++ b/com32/hdt/hdt-menu-summary.c
@@ -33,7 +33,6 @@ void compute_summarymenu(struct s_my_menu *menu, struct s_hardware *hardware)
{
char buffer[SUBMENULEN + 1];
char statbuffer[STATLEN + 1];
- char bank_number[10];
menu->menu = add_menu(" Summary ", -1);
menu->items_count = 0;
@@ -95,73 +94,26 @@ void compute_summarymenu(struct s_my_menu *menu, struct s_hardware *hardware)
hardware->dmi.bios.release_date);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
menu->items_count++;
-
- /*if type 17 is available */
- if (hardware->dmi.memory_count>0) {
- add_item("", "", OPT_SEP, "", 0);
-
- for (int i = 0; i < hardware->dmi.memory_count; i++) {
- if (hardware->dmi.memory[i].filled == true) {
- memset(bank_number, 0, sizeof(bank_number));
- snprintf(bank_number, sizeof(bank_number),
- "%d ", i);
- if (strncmp
- (hardware->dmi.memory[i].size, "Free", 4)) {
- snprintf(buffer, sizeof buffer,
- "Mem bank %02d : %s %s@%s",
- i,
- hardware->dmi.memory[i].size,
- hardware->dmi.memory[i].type,
- hardware->dmi.memory[i].speed);
- snprintf(statbuffer, sizeof statbuffer,
- "Memory bank %02d : %s %s@%s",
- i,
- hardware->dmi.memory[i].size,
- hardware->dmi.memory[i].type,
- hardware->dmi.memory[i].speed);
- add_item(buffer, statbuffer,
- OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
- }
- }
- } else if (hardware->dmi.memory_module_count>0) {
- add_item("", "", OPT_SEP, "", 0);
-
- /* Let's use type 6 as a fallback of type 17*/
- for (int i = 0; i < hardware->dmi.memory_module_count; i++) {
- if (hardware->dmi.memory_module[i].filled == true) {
- memset(bank_number, 0, sizeof(bank_number));
- snprintf(bank_number, sizeof(bank_number),
- "%d ", i);
- snprintf(buffer, sizeof buffer,
- "Mem bank %02d : %s %s@%s",
- i,
- hardware->dmi.memory_module[i].enabled_size,
- hardware->dmi.memory_module[i].type,
- hardware->dmi.memory_module[i].speed);
- snprintf(statbuffer, sizeof statbuffer,
- "Memory bank %02d : %s %s@%s",
- i,
- hardware->dmi.memory_module[i].enabled_size,
- hardware->dmi.memory_module[i].type,
- hardware->dmi.memory_module[i].speed);
- add_item(buffer, statbuffer,
- OPT_INACTIVE, NULL, 0);
- menu->items_count++;
- }
- }
- }
}
add_item("", "", OPT_SEP, "", 0);
+ snprintf(buffer, sizeof buffer, "Memory Size : %lu MiB (%lu KiB)",
+ hardware->detected_memory_size>>10,
+ hardware->detected_memory_size);
+ snprintf(statbuffer, sizeof statbuffer, "Detected Memory Size: %lu MiB (%lu KiB)",
+ hardware->detected_memory_size>>10, hardware->detected_memory_size);
+ add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+ menu->items_count++;
+
+ add_item("", "", OPT_SEP, "", 0);
+
snprintf(buffer, sizeof buffer, "Nb PCI Devices: %d",
hardware->nb_pci_devices);
snprintf(statbuffer, sizeof statbuffer, "Number of PCI Devices: %d",
hardware->nb_pci_devices);
add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
- menu->items_count++;
+ menu->items_count++;
if (hardware->is_pxe_valid == true) {
add_item("", "", OPT_SEP, "", 0);
diff --git a/com32/hdt/hdt-menu.c b/com32/hdt/hdt-menu.c
index 5b52e8b7..6e2b5945 100644
--- a/com32/hdt/hdt-menu.c
+++ b/com32/hdt/hdt-menu.c
@@ -26,8 +26,9 @@
* -----------------------------------------------------------------------
*/
-#include "hdt-menu.h"
#include <unistd.h>
+#include <memory.h>
+#include "hdt-menu.h"
int start_menu_mode(struct s_hardware *hardware, char *version_string)
{
@@ -297,6 +298,10 @@ void compute_main_menu(struct s_hdt_menu *hdt_menu, struct s_hardware *hardware)
void detect_hardware(struct s_hardware *hardware)
{
if (!quiet)
+ more_printf("MEMORY: Detecting\n");
+ hardware->detected_memory_size = detect_memsize();
+
+ if (!quiet)
more_printf("DMI: Detecting Table\n");
if (detect_dmi(hardware) == -ENODMITABLE) {
printf("DMI: ERROR ! Table not found ! \n");