|
@@ -1,9 +1,25 @@
|
1
|
1
|
#ifndef REGISTERS_H
|
2
|
2
|
#define REGISTERS_H
|
3
|
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
|
+#include "compiler.h" /* for doxygen */
|
4
|
14
|
#include "stdint.h"
|
5
|
15
|
|
6
|
|
-/* Basic 16-bit and 32-bit register types */
|
|
16
|
+/**
|
|
17
|
+ * A 16-bit general register.
|
|
18
|
+ *
|
|
19
|
+ * This type encapsulates a 16-bit register such as %ax, %bx, %cx,
|
|
20
|
+ * %dx, %si, %di, %bp or %sp.
|
|
21
|
+ *
|
|
22
|
+ */
|
7
|
23
|
typedef union {
|
8
|
24
|
struct {
|
9
|
25
|
union {
|
|
@@ -15,12 +31,33 @@ typedef union {
|
15
|
31
|
uint16_t word;
|
16
|
32
|
} PACKED reg16_t;
|
17
|
33
|
|
|
34
|
+/**
|
|
35
|
+ * A 32-bit general register.
|
|
36
|
+ *
|
|
37
|
+ * This type encapsulates a 32-bit register such as %eax, %ebx, %ecx,
|
|
38
|
+ * %edx, %esi, %edi, %ebp or %esp.
|
|
39
|
+ *
|
|
40
|
+ */
|
18
|
41
|
typedef union {
|
19
|
|
- reg16_t;
|
|
42
|
+ struct {
|
|
43
|
+ union {
|
|
44
|
+ uint8_t l;
|
|
45
|
+ uint8_t byte;
|
|
46
|
+ };
|
|
47
|
+ uint8_t h;
|
|
48
|
+ } PACKED;
|
|
49
|
+ uint16_t word;
|
20
|
50
|
uint32_t dword;
|
21
|
51
|
} PACKED reg32_t;
|
22
|
52
|
|
23
|
|
-/* As created by pushal / read by popal */
|
|
53
|
+/**
|
|
54
|
+ * A 32-bit general register dump.
|
|
55
|
+ *
|
|
56
|
+ * This is the data structure that is created on the stack by the @c
|
|
57
|
+ * pushal instruction, and can be read back using the @c popal
|
|
58
|
+ * instruction.
|
|
59
|
+ *
|
|
60
|
+ */
|
24
|
61
|
struct i386_regs {
|
25
|
62
|
union {
|
26
|
63
|
uint16_t di;
|
|
@@ -72,7 +109,31 @@ struct i386_regs {
|
72
|
109
|
};
|
73
|
110
|
} PACKED;
|
74
|
111
|
|
75
|
|
-/* Our pushal/popal equivalent for segment registers */
|
|
112
|
+/**
|
|
113
|
+ * A segment register dump.
|
|
114
|
+ *
|
|
115
|
+ * The i386 has no equivalent of the @c pushal or @c popal
|
|
116
|
+ * instructions for the segment registers. We adopt the convention of
|
|
117
|
+ * always using the sequences
|
|
118
|
+ *
|
|
119
|
+ * @code
|
|
120
|
+ *
|
|
121
|
+ * pushw %gs ; pushw %fs ; pushw %es ; pushw %ds ; pushw %ss ; pushw %cs
|
|
122
|
+ *
|
|
123
|
+ * @endcode
|
|
124
|
+ *
|
|
125
|
+ * and
|
|
126
|
+ *
|
|
127
|
+ * @code
|
|
128
|
+ *
|
|
129
|
+ * addw $4, %sp ; popw %ds ; popw %es ; popw %fs ; popw %gs
|
|
130
|
+ *
|
|
131
|
+ * @endcode
|
|
132
|
+ *
|
|
133
|
+ * This is the data structure that is created and read back by these
|
|
134
|
+ * instruction sequences.
|
|
135
|
+ *
|
|
136
|
+ */
|
76
|
137
|
struct i386_seg_regs {
|
77
|
138
|
uint16_t cs;
|
78
|
139
|
uint16_t ss;
|
|
@@ -82,11 +143,37 @@ struct i386_seg_regs {
|
82
|
143
|
uint16_t gs;
|
83
|
144
|
} PACKED;
|
84
|
145
|
|
85
|
|
-/* All i386 registers, as passed in by prot_call or kir_call */
|
|
146
|
+/**
|
|
147
|
+ * A full register dump.
|
|
148
|
+ *
|
|
149
|
+ * This data structure is created by the instructions
|
|
150
|
+ *
|
|
151
|
+ * @code
|
|
152
|
+ *
|
|
153
|
+ * pushfl
|
|
154
|
+ * pushal
|
|
155
|
+ * pushw %gs ; pushw %fs ; pushw %es ; pushw %ds ; pushw %ss ; pushw %cs
|
|
156
|
+ *
|
|
157
|
+ * @endcode
|
|
158
|
+ *
|
|
159
|
+ * and can be read back using the instructions
|
|
160
|
+ *
|
|
161
|
+ * @code
|
|
162
|
+ *
|
|
163
|
+ * addw $4, %sp ; popw %ds ; popw %es ; popw %fs ; popw %gs
|
|
164
|
+ * popal
|
|
165
|
+ * popfl
|
|
166
|
+ *
|
|
167
|
+ * @endcode
|
|
168
|
+ *
|
|
169
|
+ * prot_call() and kir_call() create this data structure on the stack
|
|
170
|
+ * and pass in a pointer to this structure.
|
|
171
|
+ *
|
|
172
|
+ */
|
86
|
173
|
struct i386_all_regs {
|
87
|
|
- struct i386_seg_regs;
|
88
|
|
- struct i386_regs;
|
89
|
|
- uint32_t i386_flags;
|
|
174
|
+ struct i386_seg_regs segs;
|
|
175
|
+ struct i386_regs regs;
|
|
176
|
+ uint32_t flags;
|
90
|
177
|
} PACKED;
|
91
|
178
|
|
92
|
179
|
#endif /* REGISTERS_H */
|