Skip to content

Commit f011fb2

Browse files
committed
add trapframe structure for 64bit mode
1 parent 948ebcb commit f011fb2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

include/x86.h

+31
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,36 @@ lcr3(uintp val)
159159
//PAGEBREAK: 36
160160
// Layout of the trap frame built on the stack by the
161161
// hardware and by trapasm.S, and passed to trap().
162+
#if X64
163+
// lie about some register names in 64bit mode to avoid
164+
// clunky ifdefs in proc.c and trap.c.
165+
struct trapframe {
166+
uint64 eax; // rax
167+
uint64 rbx;
168+
uint64 rcx;
169+
uint64 rdx;
170+
uint64 rbp;
171+
uint64 rsi;
172+
uint64 rdi;
173+
uint64 r8;
174+
uint64 r9;
175+
uint64 r10;
176+
uint64 r11;
177+
uint64 r12;
178+
uint64 r13;
179+
uint64 r14;
180+
uint64 r15;
181+
182+
uint64 trapno;
183+
uint64 err;
184+
185+
uint64 eip; // rip
186+
uint64 cs;
187+
uint64 eflags; // rflags
188+
uint64 esp; // rsp
189+
uint64 ds; // ss
190+
};
191+
#else
162192
struct trapframe {
163193
// registers as pushed by pusha
164194
uint edi;
@@ -193,3 +223,4 @@ struct trapframe {
193223
ushort ss;
194224
ushort padding6;
195225
};
226+
#endif

0 commit comments

Comments
 (0)