Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / arch / i386 / include / gdbmach.h
1 #ifndef GDBMACH_H
2 #define GDBMACH_H
3
4 /** @file
5  *
6  * GDB architecture specifics
7  *
8  * This file declares functions for manipulating the machine state and
9  * debugging context.
10  *
11  */
12
13 #include <stdint.h>
14
15 typedef unsigned long gdbreg_t;
16
17 /* The register snapshot, this must be in sync with interrupt handler and the
18  * GDB protocol. */
19 enum {
20         GDBMACH_EAX,
21         GDBMACH_ECX,
22         GDBMACH_EDX,
23         GDBMACH_EBX,
24         GDBMACH_ESP,
25         GDBMACH_EBP,
26         GDBMACH_ESI,
27         GDBMACH_EDI,
28         GDBMACH_EIP,
29         GDBMACH_EFLAGS,
30         GDBMACH_CS,
31         GDBMACH_SS,
32         GDBMACH_DS,
33         GDBMACH_ES,
34         GDBMACH_FS,
35         GDBMACH_GS,
36         GDBMACH_NREGS,
37         GDBMACH_SIZEOF_REGS = GDBMACH_NREGS * sizeof ( gdbreg_t )
38 };
39
40 /* Breakpoint types */
41 enum {
42         GDBMACH_BPMEM,
43         GDBMACH_BPHW,
44         GDBMACH_WATCH,
45         GDBMACH_RWATCH,
46         GDBMACH_AWATCH,
47 };
48
49 /* Interrupt vectors */
50 extern void gdbmach_nocode_sigfpe ( void );
51 extern void gdbmach_nocode_sigtrap ( void );
52 extern void gdbmach_nocode_sigstkflt ( void );
53 extern void gdbmach_nocode_sigill ( void );
54 extern void gdbmach_withcode_sigbus ( void );
55 extern void gdbmach_withcode_sigsegv ( void );
56
57 static inline void gdbmach_set_pc ( gdbreg_t *regs, gdbreg_t pc ) {
58         regs [ GDBMACH_EIP ] = pc;
59 }
60
61 static inline void gdbmach_set_single_step ( gdbreg_t *regs, int step ) {
62         regs [ GDBMACH_EFLAGS ] &= ~( 1 << 8 ); /* Trace Flag (TF) */
63         regs [ GDBMACH_EFLAGS ] |= ( step << 8 );
64 }
65
66 static inline void gdbmach_breakpoint ( void ) {
67         __asm__ __volatile__ ( "int $3\n" );
68 }
69
70 extern int gdbmach_set_breakpoint ( int type, unsigned long addr, size_t len, int enable );
71
72 extern void gdbmach_init ( void );
73
74 #endif /* GDBMACH_H */