Adding upstream version 4.00~pre54+dfsg.
[syslinux-debian/hramrach.git] / com32 / samples / entrydump.c
blobd50859f4e6c6b36d5acd21b110d2098a3c0cbcb9
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
14 * entry.c
16 * Dump the entry point registers
19 #include <string.h>
20 #include <stdio.h>
21 #include <inttypes.h>
22 #include <console.h>
23 #include <syslinux/config.h>
25 struct stack_frame {
26 uint16_t gs, fs, es, ds;
27 uint32_t edi, esi, ebp, esp;
28 uint32_t ebx, edx, ecx, eax;
29 uint32_t eflags;
30 uint16_t ret_ip, ret_cs;
31 uint16_t pxe_ip, pxe_cs;
34 int main(void)
36 const union syslinux_derivative_info *di;
37 const struct stack_frame *sf;
39 openconsole(&dev_null_r, &dev_stdcon_w);
41 di = syslinux_derivative_info();
43 if (di->c.filesystem != SYSLINUX_FS_PXELINUX) {
44 printf("Not running under PXELINUX (fs = %02x)\n", di->c.filesystem);
45 return 1;
48 sf = (const struct stack_frame *)di->pxe.stack;
50 printf("EAX: %08x EBX: %08x ECX: %08x EDX: %08x\n"
51 "ESP: %08x EBP: %08x ESI: %08x EDI: %08x\n"
52 "SS: %04x DS: %04x ES: %04x FS: %04x GS: %04x\n"
53 "EFLAGS: %08x RET: %04x:%04x PXE: %04x:%04x\n",
54 sf->eax, sf->ebx, sf->ecx, sf->edx,
55 sf->esp + 4, sf->ebp, sf->esi, sf->edi,
56 di->rr.r.fs, sf->ds, sf->es, sf->fs, sf->gs,
57 sf->eflags, sf->ret_cs, sf->ret_ip, sf->pxe_cs, sf->pxe_ip);
59 return 0;