Changeset c0e9f3f in mainline
- Timestamp:
- 2010-07-13T21:48:00Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6b1a85c, 9171f12
- Parents:
- a7199c2
- Location:
- kernel/arch/amd64
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/include/interrupt.h
ra7199c2 rc0e9f3f 74 74 typedef struct istate { 75 75 uint64_t rax; 76 uint64_t rbx; 76 77 uint64_t rcx; 77 78 uint64_t rdx; 78 79 uint64_t rsi; 79 80 uint64_t rdi; 81 uint64_t rbp; 80 82 uint64_t r8; 81 83 uint64_t r9; 82 84 uint64_t r10; 83 85 uint64_t r11; 84 uint64_t rbp; 85 uint64_t error_word; 86 uint64_t r12; 87 uint64_t r13; 88 uint64_t r14; 89 uint64_t r15; 90 uint64_t alignment; /* align rbp_frame on multiple of 16 */ 91 uint64_t rbp_frame; /* imitation of frame pointer linkage */ 92 uint64_t rip_frame; /* imitation of return address linkage */ 93 uint64_t error_word; /* real or fake error word */ 86 94 uint64_t rip; 87 95 uint64_t cs; 88 96 uint64_t rflags; 89 uint64_t stack[]; /* Additional data on stack */ 97 uint64_t rsp; /* only if istate_t is from uspace */ 98 uint64_t ss; /* only if istate_t is from uspace */ 90 99 } istate_t; 91 100 -
kernel/arch/amd64/src/asm.S
ra7199c2 rc0e9f3f 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 29 #define IREGISTER_SPACE 8030 31 #define IOFFSET_RAX 0x0032 #define IOFFSET_RCX 0x0833 #define IOFFSET_RDX 0x1034 #define IOFFSET_RSI 0x1835 #define IOFFSET_RDI 0x2036 #define IOFFSET_R8 0x2837 #define IOFFSET_R9 0x3038 #define IOFFSET_R10 0x3839 #define IOFFSET_R11 0x4040 #define IOFFSET_RBP 0x4841 42 /**43 * Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int44 * has no error word and 1 means interrupt with error word45 *46 */47 #define ERROR_WORD_INTERRUPT_LIST 0x00027D0048 28 49 29 #include <arch/pm.h> … … 174 154 ret 175 155 176 /** Push all volatile general purpose registers on stack 177 * 178 */ 179 .macro save_all_gpr 180 movq %rax, IOFFSET_RAX(%rsp) 181 movq %rcx, IOFFSET_RCX(%rsp) 182 movq %rdx, IOFFSET_RDX(%rsp) 183 movq %rsi, IOFFSET_RSI(%rsp) 184 movq %rdi, IOFFSET_RDI(%rsp) 185 movq %r8, IOFFSET_R8(%rsp) 186 movq %r9, IOFFSET_R9(%rsp) 187 movq %r10, IOFFSET_R10(%rsp) 188 movq %r11, IOFFSET_R11(%rsp) 189 movq %rbp, IOFFSET_RBP(%rsp) 190 .endm 191 192 .macro restore_all_gpr 193 movq IOFFSET_RAX(%rsp), %rax 194 movq IOFFSET_RCX(%rsp), %rcx 195 movq IOFFSET_RDX(%rsp), %rdx 196 movq IOFFSET_RSI(%rsp), %rsi 197 movq IOFFSET_RDI(%rsp), %rdi 198 movq IOFFSET_R8(%rsp), %r8 199 movq IOFFSET_R9(%rsp), %r9 200 movq IOFFSET_R10(%rsp), %r10 201 movq IOFFSET_R11(%rsp), %r11 202 movq IOFFSET_RBP(%rsp), %rbp 203 .endm 204 205 #define INTERRUPT_ALIGN 128 156 #define ISTATE_OFFSET_RAX 0 157 #define ISTATE_OFFSET_RBX 8 158 #define ISTATE_OFFSET_RCX 16 159 #define ISTATE_OFFSET_RDX 24 160 #define ISTATE_OFFSET_RSI 32 161 #define ISTATE_OFFSET_RDI 40 162 #define ISTATE_OFFSET_RBP 48 163 #define ISTATE_OFFSET_R8 56 164 #define ISTATE_OFFSET_R9 64 165 #define ISTATE_OFFSET_R10 72 166 #define ISTATE_OFFSET_R11 80 167 #define ISTATE_OFFSET_R12 88 168 #define ISTATE_OFFSET_R13 96 169 #define ISTATE_OFFSET_R14 104 170 #define ISTATE_OFFSET_R15 112 171 #define ISTATE_OFFSET_ALIGNMENT 120 172 #define ISTATE_OFFSET_RBP_FRAME 128 173 #define ISTATE_OFFSET_RIP_FRAME 136 174 #define ISTATE_OFFSET_ERROR_WORD 144 175 #define ISTATE_OFFSET_RIP 152 176 #define ISTATE_OFFSET_CS 160 177 #define ISTATE_OFFSET_RFLAGS 168 178 #define ISTATE_OFFSET_RSP 176 179 #define ISTATE_OFFSET_SS 184 180 181 /* 182 * Size of the istate structure without the hardware-saved part and without the 183 * error word. 184 */ 185 #define ISTATE_SOFT_SIZE 144 186 187 /** 188 * Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int 189 * has no error word and 1 means interrupt with error word 190 * 191 */ 192 #define ERROR_WORD_INTERRUPT_LIST 0x00027D00 193 194 #define INTERRUPT_ALIGN 256 206 195 207 196 /** Declare interrupt handlers … … 229 218 * Version with error word. 230 219 */ 231 subq $I REGISTER_SPACE, %rsp220 subq $ISTATE_SOFT_SIZE, %rsp 232 221 .else 233 222 /* 234 * Version without error word ,223 * Version without error word. 235 224 */ 236 subq $(I REGISTER_SPACE + 8), %rsp225 subq $(ISTATE_SOFT_SIZE + 8), %rsp 237 226 .endif 238 227 .else 239 228 /* 240 * Version without error word ,229 * Version without error word. 241 230 */ 242 subq $(I REGISTER_SPACE + 8), %rsp231 subq $(ISTATE_SOFT_SIZE + 8), %rsp 243 232 .endif 244 233 245 save_all_gpr246 cld247 248 234 /* 235 * Save the general purpose registers. 236 */ 237 movq %rax, ISTATE_OFFSET_RAX(%rsp) 238 movq %rbx, ISTATE_OFFSET_RBX(%rsp) 239 movq %rcx, ISTATE_OFFSET_RCX(%rsp) 240 movq %rdx, ISTATE_OFFSET_RDX(%rsp) 241 movq %rsi, ISTATE_OFFSET_RSI(%rsp) 242 movq %rdi, ISTATE_OFFSET_RDI(%rsp) 243 movq %rbp, ISTATE_OFFSET_RBP(%rsp) 244 movq %r8, ISTATE_OFFSET_R8(%rsp) 245 movq %r9, ISTATE_OFFSET_R9(%rsp) 246 movq %r10, ISTATE_OFFSET_R10(%rsp) 247 movq %r11, ISTATE_OFFSET_R11(%rsp) 248 movq %r12, ISTATE_OFFSET_R12(%rsp) 249 movq %r13, ISTATE_OFFSET_R13(%rsp) 250 movq %r14, ISTATE_OFFSET_R14(%rsp) 251 movq %r15, ISTATE_OFFSET_R15(%rsp) 252 253 /* 254 * Imitate a regular stack frame linkage. 249 255 * Stop stack traces here if we came from userspace. 250 256 */ 251 movq %cs, %rax252 257 xorq %rdx, %rdx 253 cmpq %rax, IREGISTER_SPACE+16(%rsp) 254 cmovneq %rdx, %rbp 255 256 movq $(\i), %rdi /* %rdi - first argument */ 257 movq %rsp, %rsi /* %rsi - pointer to istate */ 258 258 cmpq $(gdtselector(KTEXT_DES)), ISTATE_OFFSET_CS(%rsp) 259 cmovnzq %rdx, %rbp 260 261 movq %rbp, ISTATE_OFFSET_RBP_FRAME(%rsp) 262 movq ISTATE_OFFSET_RIP(%rsp), %rax 263 movq %rax, ISTATE_OFFSET_RIP_FRAME(%rsp) 264 leaq ISTATE_OFFSET_RBP_FRAME(%rsp), %rbp 265 266 movq $(\i), %rdi /* pass intnum in the first argument */ 267 movq %rsp, %rsi /* pass istate address in the second argument */ 268 269 cld 270 259 271 /* Call exc_dispatch(i, istate) */ 260 272 call exc_dispatch 261 262 restore_all_gpr 273 274 /* 275 * Restore all scratch registers and the preserved registers we have 276 * clobbered in this handler (i.e. RBP). 277 */ 278 movq ISTATE_OFFSET_RAX(%rsp), %rax 279 movq ISTATE_OFFSET_RCX(%rsp), %rcx 280 movq ISTATE_OFFSET_RDX(%rsp), %rdx 281 movq ISTATE_OFFSET_RSI(%rsp), %rsi 282 movq ISTATE_OFFSET_RDI(%rsp), %rdi 283 movq ISTATE_OFFSET_RBP(%rsp), %rbp 284 movq ISTATE_OFFSET_R8(%rsp), %r8 285 movq ISTATE_OFFSET_R9(%rsp), %r9 286 movq ISTATE_OFFSET_R10(%rsp), %r10 287 movq ISTATE_OFFSET_R11(%rsp), %r11 263 288 264 289 /* $8 = Skip error word */ 265 addq $(I REGISTER_SPACE + 8), %rsp290 addq $(ISTATE_SOFT_SIZE + 8), %rsp 266 291 iretq 267 292
Note:
See TracChangeset
for help on using the changeset viewer.