[e16e8f2] | 1 | /* ----------------------------------------------------------------------- * |
---|
| 2 | * |
---|
| 3 | * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved |
---|
| 4 | * |
---|
| 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. |
---|
| 10 | * |
---|
| 11 | * ----------------------------------------------------------------------- */ |
---|
| 12 | |
---|
| 13 | /* |
---|
| 14 | * entry.c |
---|
| 15 | * |
---|
| 16 | * Dump the entry point registers |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | #include <string.h> |
---|
| 20 | #include <stdio.h> |
---|
| 21 | #include <inttypes.h> |
---|
| 22 | #include <console.h> |
---|
| 23 | #include <syslinux/config.h> |
---|
| 24 | |
---|
| 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; |
---|
| 32 | }; |
---|
| 33 | |
---|
| 34 | int main(void) |
---|
| 35 | { |
---|
| 36 | const union syslinux_derivative_info *di; |
---|
| 37 | const struct stack_frame *sf; |
---|
| 38 | |
---|
| 39 | #if 0 |
---|
| 40 | /* this hangs! */ |
---|
| 41 | openconsole(&dev_null_r, &dev_stdcon_w); |
---|
| 42 | #else |
---|
| 43 | /* this works */ |
---|
| 44 | openconsole(&dev_rawcon_r, &dev_ansiserial_w); |
---|
| 45 | #endif |
---|
| 46 | |
---|
| 47 | di = syslinux_derivative_info(); |
---|
| 48 | |
---|
| 49 | if (di->c.filesystem != SYSLINUX_FS_PXELINUX) { |
---|
| 50 | printf("Not running under PXELINUX (fs = %02x)\n", di->c.filesystem); |
---|
| 51 | return 1; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | sf = (const struct stack_frame *)di->pxe.stack; |
---|
| 55 | |
---|
| 56 | printf("EAX: %08x EBX: %08x ECX: %08x EDX: %08x\n" |
---|
| 57 | "ESP: %08x EBP: %08x ESI: %08x EDI: %08x\n" |
---|
| 58 | "SS: %04x DS: %04x ES: %04x FS: %04x GS: %04x\n" |
---|
| 59 | "EFLAGS: %08x RET: %04x:%04x PXE: %04x:%04x\n", |
---|
| 60 | sf->eax, sf->ebx, sf->ecx, sf->edx, |
---|
| 61 | sf->esp + 4, sf->ebp, sf->esi, sf->edi, |
---|
| 62 | di->rr.r.fs, sf->ds, sf->es, sf->fs, sf->gs, |
---|
| 63 | sf->eflags, sf->ret_cs, sf->ret_ip, sf->pxe_cs, sf->pxe_ip); |
---|
| 64 | |
---|
| 65 | return 0; |
---|
| 66 | } |
---|