github.com/jspc/eggos@v0.5.1-0.20221028160421-556c75c878a5/kernel/seg.s (about) 1 #include "textflag.h" 2 3 // lgdt(gdtptr uint64) - Load Global Descriptor Table Register. 4 TEXT ·lgdt(SB), NOSPLIT, $0-8 5 MOVQ gdtptr+0(FP), AX 6 LGDT (AX) 7 RET 8 9 // lidt(idtptr uint64) - Load Interrupt Descriptor Table Register. 10 TEXT ·lidt(SB), NOSPLIT, $0-8 11 MOVQ idtptr+0(FP), AX 12 LIDT (AX) 13 RET 14 15 // ltr(sel uint64) - Load Task Register. 16 TEXT ·ltr(SB), NOSPLIT, $0-8 17 MOVQ sel+0(FP), AX 18 LTR AX 19 RET 20 21 // reloadCS returns from the current interrupt handler. 22 TEXT ·reloadCS(SB), NOSPLIT, $0 23 // save ip 24 MOVQ 0(SP), AX 25 26 // save sp 27 MOVQ SP, BX 28 ADDQ $8, BX 29 30 // rerange the stack, as in an interrupt stack 31 PUSHQ $0x10 // SS 32 PUSHQ BX 33 PUSHFQ 34 PUSHQ $8 35 PUSHQ AX 36 37 // IRET 38 IRETQ 39