github.com/icexin/eggos@v0.4.2-0.20220216025428-78b167e4f349/kernel/trap.s (about) 1 #include "textflag.h" 2 3 #define m_fpstate 32 4 5 TEXT alltraps(SB), NOSPLIT, $0 6 PUSHQ R15 7 PUSHQ R14 8 PUSHQ R13 9 PUSHQ R12 10 PUSHQ R11 11 PUSHQ R10 12 PUSHQ R9 13 PUSHQ R8 14 PUSHQ DI 15 PUSHQ SI 16 PUSHQ BP 17 PUSHQ DX 18 PUSHQ CX 19 PUSHQ BX 20 PUSHQ AX 21 22 // CX store mythread 23 MOVQ 0(GS), CX 24 MOVQ m_fpstate(CX), DX 25 FXSAVE (DX) 26 27 // make top stack frame 28 XORQ BP, BP 29 PUSHQ SP 30 CALL ·dotrap(SB) 31 ADDQ $8, SP 32 JMP ·trapret(SB) 33 34 TEXT ·trapret(SB), NOSPLIT, $0 35 // CX store mythread 36 MOVQ 0(GS), CX 37 38 // restore FPU 39 MOVQ m_fpstate(CX), DX 40 FXRSTOR (DX) 41 42 POPQ AX 43 POPQ BX 44 POPQ CX 45 POPQ DX 46 POPQ BP 47 POPQ SI 48 POPQ DI 49 POPQ R8 50 POPQ R9 51 POPQ R10 52 POPQ R11 53 POPQ R12 54 POPQ R13 55 POPQ R14 56 POPQ R15 57 58 ADDQ $16, SP // skip trapno and errcode 59 60 IRETQ 61