aboutsummaryrefslogtreecommitdiffstats
path: root/com32/hdt
diff options
context:
space:
mode:
authorErwan Velu <erwanaliasr1@gmail.com>2011-03-29 23:25:26 +0200
committerErwan Velu <erwanaliasr1@gmail.com>2011-03-29 23:25:26 +0200
commit7ca6891c399a6e9155a50111f3af7f1366493415 (patch)
treec554cf282274ec9bd488524a8ad50a8051b5d6fb /com32/hdt
parentbc7ebf1eccf8899be05b0d8b476a7f504acf808b (diff)
downloadsyslinux-7ca6891c399a6e9155a50111f3af7f1366493415.tar.gz
syslinux-7ca6891c399a6e9155a50111f3af7f1366493415.tar.xz
syslinux-7ca6891c399a6e9155a50111f3af7f1366493415.zip
hdt: Dumping memory configuration
This patch dumps the 88, e801 & e820 memory mapping.
Diffstat (limited to 'com32/hdt')
-rw-r--r--com32/hdt/hdt-dump-memory.c136
-rw-r--r--com32/hdt/hdt-dump.c1
-rw-r--r--com32/hdt/hdt-dump.h1
3 files changed, 138 insertions, 0 deletions
diff --git a/com32/hdt/hdt-dump-memory.c b/com32/hdt/hdt-dump-memory.c
new file mode 100644
index 00000000..54823542
--- /dev/null
+++ b/com32/hdt/hdt-dump-memory.c
@@ -0,0 +1,136 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2011 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-common.h"
+#include "hdt-dump.h"
+
+void dump_88(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
+
+ (void) hardware;
+ int mem_size = 0;
+ if (detect_memory_88(&mem_size)) {
+ APPEND_ARRAY
+ add_as("memory.error","8800h memory configuration is invalid")
+ END_OF_APPEND;
+ return;
+ }
+
+ APPEND_ARRAY
+ add_as("dmi.item","memory via 88")
+ add_ai("memory.size (KiB)", mem_size)
+ add_ai("memory.size (MiB)", mem_size >> 10)
+ END_OF_APPEND;
+
+}
+
+void dump_e801(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
+
+ (void) hardware;
+ int mem_low, mem_high = 0;
+ if (detect_memory_e801(&mem_low,&mem_high)) {
+ APPEND_ARRAY
+ add_as("memory.error","e801 memory configuration is invalid")
+ END_OF_APPEND;
+ return;
+ }
+
+ APPEND_ARRAY
+ add_as("dmi.item","memory via e801")
+ add_ai("memory.total.size (KiB)", mem_low + (mem_high << 6))
+ add_ai("memory.total.size (MiB)", (mem_low >> 10) + (mem_high >> 4))
+ add_ai("memory.low.size (KiB)", mem_low )
+ add_ai("memory.low.size (MiB)", mem_low >> 10)
+ add_ai("memory.high.size (KiB)", mem_high << 6)
+ add_ai("memory.high.size (MiB)", mem_high >> 4)
+ END_OF_APPEND;
+
+}
+void dump_e820(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
+
+ (void) hardware;
+ struct e820entry map[E820MAX];
+ struct e820entry nm[E820MAX];
+ unsigned long memsize = 0;
+ int count = 0;
+ char type[14] = {0};
+
+ detect_memory_e820(map, E820MAX, &count);
+ memsize = memsize_e820(map, count);
+
+ APPEND_ARRAY
+ add_as("dmi.item","memory via e820")
+ add_ai("memory.total.size (KiB)", memsize)
+ add_ai("memory.total.size (MiB)", (memsize + (1 << 9)) >> 10)
+ END_OF_APPEND;
+
+ for (int i = 0; i < count; i++) {
+ get_type(map[i].type, type, sizeof(type));
+ char begin[24]={0};
+ char size[24]={0};
+ char end[24]={0};
+ snprintf(begin,sizeof(begin),"0x%016llx",map[i].addr);
+ snprintf(size,sizeof(size),"0x%016llx",map[i].size);
+ snprintf(end,sizeof(end),"0x%016llx",map[i].addr+map[i].size);
+ CREATE_TEMP_OBJECT
+ add_ts("memory.segment.start",begin);
+ add_ts("memory.segment.size ",size);
+ add_ts("memory.segment.end ",end);
+ add_ts("memory.segment.type ",remove_spaces(type));
+ APPEND_TEMP_OBJECT_ARRAY;
+ }
+
+ int nr = sanitize_e820_map(map, nm, count);
+ for (int i = 0; i < nr; i++) {
+ get_type(nm[i].type, type, sizeof(type));
+ char begin[24]={0};
+ char size[24]={0};
+ char end[24]={0};
+ snprintf(begin,sizeof(begin),"0x%016llx",nm[i].addr);
+ snprintf(size,sizeof(size),"0x%016llx",nm[i].size);
+ snprintf(end,sizeof(end),"0x%016llx",nm[i].addr+nm[i].size);
+ CREATE_TEMP_OBJECT
+ add_ts("sanitized_memory.segment.start",begin);
+ add_ts("sanitized_memory.segment.size ",size);
+ add_ts("sanitized_memory.segment.end ",end);
+ add_ts("sanitized_memory.segment.type ",remove_spaces(type));
+ APPEND_TEMP_OBJECT_ARRAY;
+ }
+}
+
+void dump_memory(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item) {
+
+ CREATE_ARRAY
+ add_as("Memory configuration","true")
+ END_OF_ARRAY;
+
+ dump_88(hardware,config,item);
+ dump_e801(hardware,config,item);
+ dump_e820(hardware,config,item);
+ flush("memory",config,item);
+}
diff --git a/com32/hdt/hdt-dump.c b/com32/hdt/hdt-dump.c
index 91ade017..89b409d4 100644
--- a/com32/hdt/hdt-dump.c
+++ b/com32/hdt/hdt-dump.c
@@ -121,6 +121,7 @@ void dump(struct s_hardware *hardware)
dump_vesa(hardware, &config, &json);
dump_disks(hardware, &config, &json);
dump_dmi(hardware, &config, &json);
+ dump_memory(hardware, &config, &json);
/* We close & flush the file to send */
cpio_close(upload);
diff --git a/com32/hdt/hdt-dump.h b/com32/hdt/hdt-dump.h
index da6f40bc..b0f07cda 100644
--- a/com32/hdt/hdt-dump.h
+++ b/com32/hdt/hdt-dump.h
@@ -80,3 +80,4 @@ void dump_vpd(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item)
void dump_vesa(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
void dump_disks(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
void dump_dmi(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
+void dump_memory(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);