[syslinux:master] sysdump: dump memory map information

syslinux-bot for H. Peter Anvin hpa at zytor.com
Sat Feb 6 23:12:02 PST 2010


Commit-ID:  33e6490865b14e331e6da82570cc0783252005d0
Gitweb:     http://syslinux.zytor.com/commit/33e6490865b14e331e6da82570cc0783252005d0
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Sat, 6 Feb 2010 23:10:24 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Sat, 6 Feb 2010 23:10:24 -0800

sysdump: dump memory map information

Dump the memory map information - e820 et al.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 com32/sysdump/main.c    |    1 +
 com32/sysdump/memmap.c  |   80 +++++++++++++++++++++++++++++++++++++++++++++++
 com32/sysdump/sysdump.h |    1 +
 3 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/com32/sysdump/main.c b/com32/sysdump/main.c
index f6aea9c..8012816 100644
--- a/com32/sysdump/main.c
+++ b/com32/sysdump/main.c
@@ -35,6 +35,7 @@ static void dump_all(struct backend *be, const char *argv[], size_t len)
 
     cpio_init(be, argv, len);
 
+    dump_memory_map(be);
     dump_memory(be);
     dump_dmi(be);
     dump_pci(be);
diff --git a/com32/sysdump/memmap.c b/com32/sysdump/memmap.c
new file mode 100644
index 0000000..bc938c9
--- /dev/null
+++ b/com32/sysdump/memmap.c
@@ -0,0 +1,80 @@
+/*
+ * Dump memory map information
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <com32.h>
+#include "sysdump.h"
+#include "backend.h"
+
+#define E820_CHUNK 128
+struct e820_info {
+    uint32_t ebx;
+    uint32_t len;
+    uint8_t  data[24];
+};
+
+static void dump_e820(struct backend *be)
+{
+    com32sys_t ireg, oreg;
+    struct e820_info *curr = __com32.cs_bounce;
+    struct e820_info *buf, *p;
+    int nentry, nalloc;
+
+    buf = p = NULL;
+    nentry = nalloc = 0;
+    memset(&ireg, 0, sizeof ireg);
+    memset(&curr, 0, sizeof curr);
+
+    ireg.eax.l = 0xe820;
+    ireg.edx.l = 0x534d4150;
+    ireg.ecx.l = sizeof curr->data;
+    ireg.es = SEG(curr->data);
+    ireg.edi.w[0] = OFFS(curr->data);
+    
+    do {
+	__intcall(0x15, &ireg, &oreg);
+	if ((oreg.eflags.l & EFLAGS_CF) ||
+	    oreg.eax.l != 0x534d4150)
+	    break;
+
+	if (nentry >= nalloc) {
+	    nalloc += E820_CHUNK;
+	    buf = realloc(buf, nalloc*sizeof *buf);
+	    if (!buf)
+		return;		/* FAILED */
+	}
+	memcpy(buf[nentry].data, curr->data, sizeof curr->data);
+	buf[nentry].ebx = ireg.ebx.l;
+	buf[nentry].len = oreg.ecx.l;
+
+	ireg.ebx.l = oreg.ebx.l;
+    } while (ireg.ebx.l);
+
+    if (nentry)
+	cpio_writefile(be, "memmap/15e820", buf, nentry*sizeof *buf);
+    free(buf);
+}
+
+void dump_memory_map(struct backend *be)
+{
+    com32sys_t ireg, oreg;
+
+    cpio_mkdir(be, "memmap");
+
+    memset(&ireg, 0, sizeof ireg);
+    __intcall(0x12, &ireg, &oreg);
+    cpio_writefile(be, "memmap/12", &oreg, sizeof oreg);
+
+    ireg.eax.b[1] = 0x88;
+    __intcall(0x15, &ireg, &oreg);
+    cpio_writefile(be, "memmap/1588", &oreg, sizeof oreg);
+
+    ireg.eax.w[0] = 0xe801;
+    __intcall(0x15, &ireg, &oreg);
+    cpio_writefile(be, "memmap/15e801", &oreg, sizeof oreg);
+
+    dump_e820(be);
+}
diff --git a/com32/sysdump/sysdump.h b/com32/sysdump/sysdump.h
index 4b58cf3..f2c8f7a 100644
--- a/com32/sysdump/sysdump.h
+++ b/com32/sysdump/sysdump.h
@@ -3,6 +3,7 @@
 
 struct backend;
 
+void dump_memory_map(struct backend *);
 void dump_memory(struct backend *);
 void dump_dmi(struct backend *);
 void dump_pci(struct backend *);



More information about the Syslinux-commits mailing list