aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-02-18 21:36:59 -0800
committerH. Peter Anvin <hpa@zytor.com>2009-02-18 21:36:59 -0800
commitb83eb9f9ba49d898e1d753ffee91f648a16f955b (patch)
treea815a727dec737dd8a66bcd0f7e50a3261ace79e
parentdcf5e1cc66a4d37867e891d05ee114e0cf929bcf (diff)
downloadsyslinux-elf-b83eb9f9ba49d898e1d753ffee91f648a16f955b.tar.gz
syslinux-elf-b83eb9f9ba49d898e1d753ffee91f648a16f955b.tar.xz
syslinux-elf-b83eb9f9ba49d898e1d753ffee91f648a16f955b.zip
entrydump: trivial program to probe PXE entry conditions
Small debugging hack program to probe the PXE stack entry conditions. This is mostly useful when developing a PXE stack, but might possibly be handy for finding workarounds for a stack, too.
-rw-r--r--com32/samples/Makefile2
-rw-r--r--com32/samples/entrydump.c62
2 files changed, 63 insertions, 1 deletions
diff --git a/com32/samples/Makefile b/com32/samples/Makefile
index 7f5ea190..482769ef 100644
--- a/com32/samples/Makefile
+++ b/com32/samples/Makefile
@@ -21,7 +21,7 @@ all: hello.c32 cat.c32 resolv.c32 serialinfo.c32 \
localboot.c32 \
fancyhello.c32 fancyhello.lnx \
keytest.c32 keytest.lnx \
- advdump.c32
+ advdump.c32 entrydump.c32
tidy dist:
rm -f *.o *.lo *.a *.lst *.elf .*.d *.tmp
diff --git a/com32/samples/entrydump.c b/com32/samples/entrydump.c
new file mode 100644
index 00000000..b36a30d3
--- /dev/null
+++ b/com32/samples/entrydump.c
@@ -0,0 +1,62 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ * Boston MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * entry.c
+ *
+ * Dump the entry point registers
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <inttypes.h>
+#include <console.h>
+#include <syslinux/config.h>
+
+struct stack_frame {
+ uint16_t gs, fs, es, ds;
+ uint32_t edi, esi, ebp, esp;
+ uint32_t ebx, edx, ecx, eax;
+ uint32_t eflags;
+ uint16_t ret_ip, ret_cs;
+ uint16_t pxe_ip, pxe_cs;
+};
+
+int main(void)
+{
+ const union syslinux_derivative_info *di;
+ const struct stack_frame *sf;
+ int i;
+ const unsigned char *p;
+
+ openconsole(&dev_null_r, &dev_stdcon_w);
+
+ di = syslinux_derivative_info();
+
+ if (di->c.filesystem != SYSLINUX_FS_PXELINUX) {
+ printf("Not running under PXELINUX (fs = %02x)\n", di->c.filesystem);
+ return 1;
+ }
+
+ sf = (const struct stack_frame *)di->pxe.stack;
+
+ printf("EAX: %08x EBX: %08x ECX: %08x EDX: %08x\n"
+ "ESP: %08x EBP: %08x ESI: %08x EDI: %08x\n"
+ "SS: %04x DS: %04x ES: %04x FS: %04x GS: %04x\n"
+ "EFLAGS: %08x RET: %04x:%04x PXE: %04x:%04x\n",
+ sf->eax, sf->ebx, sf->ecx, sf->edx,
+ sf->esp+4, sf->ebp, sf->esi, sf->edi,
+ di->rr.r.fs, sf->ds, sf->es, sf->fs, sf->gs,
+ sf->eflags, sf->ret_cs, sf->ret_ip, sf->pxe_cs, sf->pxe_ip);
+
+ return 0;
+}