iPXE
arch
x86
include
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
{
27
uint8_t
l
;
28
uint8_t
byte
;
29
};
30
uint8_t
h
;
31
}
__attribute__
(( packed ));
32
uint16_t
word
;
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
;
51
uint32_t
dword
;
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
{
64
uint16_t
di
;
65
uint32_t
edi
;
66
};
67
union
{
68
uint16_t
si
;
69
uint32_t
esi
;
70
};
71
union
{
72
uint16_t
bp
;
73
uint32_t
ebp
;
74
};
75
union
{
76
uint16_t
sp
;
77
uint32_t
esp
;
78
};
79
union
{
80
struct
{
81
uint8_t
bl
;
82
uint8_t
bh
;
83
}
__attribute__
(( packed ));
84
uint16_t
bx
;
85
uint32_t
ebx
;
86
};
87
union
{
88
struct
{
89
uint8_t
dl
;
90
uint8_t
dh
;
91
}
__attribute__
(( packed ));
92
uint16_t
dx
;
93
uint32_t
edx
;
94
};
95
union
{
96
struct
{
97
uint8_t
cl
;
98
uint8_t
ch
;
99
}
__attribute__
(( packed ));
100
uint16_t
cx
;
101
uint32_t
ecx
;
102
};
103
union
{
104
struct
{
105
uint8_t
al
;
106
uint8_t
ah
;
107
}
__attribute__
(( packed ));
108
uint16_t
ax
;
109
uint32_t
eax
;
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
*/
138
struct
i386_seg_regs
{
139
uint16_t
cs
;
140
uint16_t
ss
;
141
uint16_t
ds
;
142
uint16_t
es
;
143
uint16_t
fs
;
144
uint16_t
gs
;
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
*/
174
struct
i386_all_regs
{
175
struct
i386_seg_regs
segs
;
176
struct
i386_regs
regs
;
177
uint32_t
flags
;
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
{
192
uint16_t
offset
;
193
uint16_t
segment
;
194
}
__attribute__
(( packed ));
195
196
typedef
struct
segoff
segoff_t
;
197
198
#endif
/* REGISTERS_H */
segoff::segment
uint16_t segment
Definition:
registers.h:193
i386_seg_regs
A segment register dump.
Definition:
registers.h:138
uint16_t
unsigned short uint16_t
Definition:
stdint.h:11
l
uint8_t l
Definition:
registers.h:15
i386_all_regs::segs
struct i386_seg_regs segs
Definition:
registers.h:175
i386_regs::ebp
uint32_t ebp
Definition:
registers.h:73
i386_regs::esp
uint32_t esp
Definition:
registers.h:77
i386_seg_regs::es
uint16_t es
Definition:
registers.h:142
i386_regs::dh
uint8_t dh
Definition:
registers.h:90
i386_seg_regs::cs
uint16_t cs
Definition:
registers.h:139
i386_all_regs::flags
uint32_t flags
Definition:
registers.h:177
i386_seg_regs::fs
uint16_t fs
Definition:
registers.h:143
byte
uint8_t byte
Definition:
registers.h:16
i386_regs::eax
uint32_t eax
Definition:
registers.h:109
i386_all_regs
A full register dump.
Definition:
registers.h:174
i386_regs::bl
uint8_t bl
Definition:
registers.h:81
i386_regs::edi
uint32_t edi
Definition:
registers.h:65
i386_regs::esi
uint32_t esi
Definition:
registers.h:69
i386_all_regs::regs
struct i386_regs regs
Definition:
registers.h:176
segoff
Definition:
registers.h:191
i386_regs::cx
uint16_t cx
Definition:
registers.h:100
h
uint8_t h
Definition:
registers.h:18
segoff::offset
uint16_t offset
Definition:
registers.h:192
i386_regs::dx
uint16_t dx
Definition:
registers.h:92
i386_regs::bx
uint16_t bx
Definition:
registers.h:84
__attribute__::h
uint8_t h
Definition:
registers.h:30
FILE_LICENCE
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
i386_regs::ah
uint8_t ah
Definition:
registers.h:106
i386_seg_regs::ds
uint16_t ds
Definition:
registers.h:141
uint8_t
unsigned char uint8_t
Definition:
stdint.h:10
i386_seg_regs::ss
uint16_t ss
Definition:
registers.h:140
uint32_t
unsigned int uint32_t
Definition:
stdint.h:12
i386_regs::ecx
uint32_t ecx
Definition:
registers.h:101
i386_regs
A 32-bit general register dump.
Definition:
registers.h:62
__attribute__
typedef __attribute__
i386_regs::cl
uint8_t cl
Definition:
registers.h:97
i386_regs::di
uint16_t di
Definition:
registers.h:64
i386_seg_regs::gs
uint16_t gs
Definition:
registers.h:144
__attribute__::word
uint16_t word
Definition:
registers.h:32
i386_regs::ebx
uint32_t ebx
Definition:
registers.h:85
i386_regs::ax
uint16_t ax
Definition:
registers.h:108
i386_regs::sp
uint16_t sp
Definition:
registers.h:76
word
unsigned short word
Definition:
smc9000.h:39
stdint.h
i386_regs::edx
uint32_t edx
Definition:
registers.h:93
i386_regs::si
uint16_t si
Definition:
registers.h:68
i386_regs::al
uint8_t al
Definition:
registers.h:105
i386_regs::bp
uint16_t bp
Definition:
registers.h:72
i386_regs::bh
uint8_t bh
Definition:
registers.h:82
i386_regs::ch
uint8_t ch
Definition:
registers.h:98
dword
unsigned long int dword
Definition:
smc9000.h:40
i386_regs::dl
uint8_t dl
Definition:
registers.h:89
Generated by
1.8.15