[i386] Add dump_regs() debug call
authorMichael Brown <mcb30@etherboot.org>
Sun, 28 Sep 2008 22:06:53 +0000 (23:06 +0100)
committerMichael Brown <mcb30@etherboot.org>
Sun, 28 Sep 2008 22:06:53 +0000 (23:06 +0100)
Use as "call dump_regs" from any real-mode code within .text16.
Should preserve all registers and flags.

src/arch/i386/core/dumpregs.c [new file with mode: 0644]

diff --git a/src/arch/i386/core/dumpregs.c b/src/arch/i386/core/dumpregs.c
new file mode 100644 (file)
index 0000000..89426d5
--- /dev/null
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <realmode.h>
+
+void __cdecl _dump_regs ( struct i386_all_regs *ix86 ) {
+
+       __asm__ __volatile__ (
+               TEXT16_CODE ( ".globl dump_regs\n\t"
+                             "\ndump_regs:\n\t"
+                             "pushl $_dump_regs\n\t"
+                             "pushw %%cs\n\t"
+                             "call prot_call\n\t"
+                             "addr32 leal 4(%%esp), %%esp\n\t"
+                             "ret\n\t" ) : : );
+
+       printf ( "EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx\n"
+                "ESI=%08lx EDI=%08lx EBP=%08lx ESP=%08lx\n"
+                "CS=%04x SS=%04x DS=%04x ES=%04x FS=%04x GS=%04x\n",
+                ix86->regs.eax, ix86->regs.ebx, ix86->regs.ecx,
+                ix86->regs.edx, ix86->regs.esi, ix86->regs.edi,
+                ix86->regs.ebp, ix86->regs.esp,
+                ix86->segs.cs, ix86->segs.ss, ix86->segs.ds,
+                ix86->segs.es, ix86->segs.fs, ix86->segs.gs );
+}