iPXE
registers.h
Go to the documentation of this file.
1 #ifndef REGISTERS_H
2 #define REGISTERS_H
3 
4 /** @file
5  *
6  * i386 registers.
7  *
8  * This file defines data structures that allow easy access to i386
9  * register dumps.
10  *
11  */
12 
13 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
14 
15 #include <stdint.h>
16 
17 /**
18  * A 16-bit general register.
19  *
20  * This type encapsulates a 16-bit register such as %ax, %bx, %cx,
21  * %dx, %si, %di, %bp or %sp.
22  *
23  */
24 typedef union {
25  struct {
26  union {
29  };
31  } __attribute__ (( packed ));
33 } __attribute__ (( packed )) reg16_t;
34 
35 /**
36  * A 32-bit general register.
37  *
38  * This type encapsulates a 32-bit register such as %eax, %ebx, %ecx,
39  * %edx, %esi, %edi, %ebp or %esp.
40  *
41  */
42 typedef union {
43  struct {
44  union {
45  uint8_t l;
46  uint8_t byte;
47  };
48  uint8_t h;
49  } __attribute__ (( packed ));
50  uint16_t word;
52 } __attribute__ (( packed )) reg32_t;
53 
54 /**
55  * A 32-bit general register dump.
56  *
57  * This is the data structure that is created on the stack by the @c
58  * pushal instruction, and can be read back using the @c popal
59  * instruction.
60  *
61  */
62 struct i386_regs {
63  union {
66  };
67  union {
70  };
71  union {
74  };
75  union {
78  };
79  union {
80  struct {
83  } __attribute__ (( packed ));
86  };
87  union {
88  struct {
91  } __attribute__ (( packed ));
94  };
95  union {
96  struct {
99  } __attribute__ (( packed ));
102  };
103  union {
104  struct {
107  } __attribute__ (( packed ));
110  };
111 } __attribute__ (( packed ));
112 
113 /**
114  * A segment register dump.
115  *
116  * The i386 has no equivalent of the @c pushal or @c popal
117  * instructions for the segment registers. We adopt the convention of
118  * always using the sequences
119  *
120  * @code
121  *
122  * pushw %gs ; pushw %fs ; pushw %es ; pushw %ds ; pushw %ss ; pushw %cs
123  *
124  * @endcode
125  *
126  * and
127  *
128  * @code
129  *
130  * addw $4, %sp ; popw %ds ; popw %es ; popw %fs ; popw %gs
131  *
132  * @endcode
133  *
134  * This is the data structure that is created and read back by these
135  * instruction sequences.
136  *
137  */
145 } __attribute__ (( packed ));
146 
147 /**
148  * A full register dump.
149  *
150  * This data structure is created by the instructions
151  *
152  * @code
153  *
154  * pushfl
155  * pushal
156  * pushw %gs ; pushw %fs ; pushw %es ; pushw %ds ; pushw %ss ; pushw %cs
157  *
158  * @endcode
159  *
160  * and can be read back using the instructions
161  *
162  * @code
163  *
164  * addw $4, %sp ; popw %ds ; popw %es ; popw %fs ; popw %gs
165  * popal
166  * popfl
167  *
168  * @endcode
169  *
170  * virt_call() and kir_call() create this data structure on the stack
171  * and pass in a pointer to this structure.
172  *
173  */
176  struct i386_regs regs;
178 } __attribute__ (( packed ));
179 
180 /* Flags */
181 #define CF ( 1 << 0 )
182 #define PF ( 1 << 2 )
183 #define AF ( 1 << 4 )
184 #define ZF ( 1 << 6 )
185 #define SF ( 1 << 7 )
186 #define OF ( 1 << 11 )
187 
188 /* Segment:offset structure. Note that the order within the structure
189  * is offset:segment.
190  */
191 struct segoff {
194 } __attribute__ (( packed ));
195 
196 typedef struct segoff segoff_t;
197 
198 #endif /* REGISTERS_H */
uint16_t segment
Definition: registers.h:193
A segment register dump.
Definition: registers.h:138
unsigned short uint16_t
Definition: stdint.h:11
uint8_t l
Definition: registers.h:15
struct i386_seg_regs segs
Definition: registers.h:175
uint32_t ebp
Definition: registers.h:73
uint32_t esp
Definition: registers.h:77
uint16_t es
Definition: registers.h:142
uint8_t dh
Definition: registers.h:90
uint16_t cs
Definition: registers.h:139
typedef __attribute__
uint32_t flags
Definition: registers.h:177
uint16_t fs
Definition: registers.h:143
uint8_t byte
Definition: registers.h:16
uint32_t eax
Definition: registers.h:109
A full register dump.
Definition: registers.h:174
uint8_t bl
Definition: registers.h:81
uint32_t edi
Definition: registers.h:65
uint32_t esi
Definition: registers.h:69
struct i386_regs regs
Definition: registers.h:176
uint16_t cx
Definition: registers.h:100
uint8_t h
Definition: registers.h:18
uint16_t offset
Definition: registers.h:192
uint16_t dx
Definition: registers.h:92
uint16_t bx
Definition: registers.h:84
uint8_t h
Definition: registers.h:30
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint8_t ah
Definition: registers.h:106
uint16_t ds
Definition: registers.h:141
unsigned char uint8_t
Definition: stdint.h:10
uint16_t ss
Definition: registers.h:140
unsigned int uint32_t
Definition: stdint.h:12
uint32_t ecx
Definition: registers.h:101
A 32-bit general register dump.
Definition: registers.h:62
uint8_t cl
Definition: registers.h:97
uint16_t di
Definition: registers.h:64
uint16_t gs
Definition: registers.h:144
uint16_t word
Definition: registers.h:32
uint32_t ebx
Definition: registers.h:85
uint16_t ax
Definition: registers.h:108
uint16_t sp
Definition: registers.h:76
unsigned short word
Definition: smc9000.h:39
uint32_t edx
Definition: registers.h:93
uint16_t si
Definition: registers.h:68
uint8_t al
Definition: registers.h:105
uint16_t bp
Definition: registers.h:72
uint8_t bh
Definition: registers.h:82
uint8_t ch
Definition: registers.h:98
unsigned long int dword
Definition: smc9000.h:40
uint8_t dl
Definition: registers.h:89