使中断支持重入
This commit is contained in:
parent
8352069285
commit
2d6b898c49
|
@ -51,7 +51,10 @@
|
|||
add rsp, 4
|
||||
%endmacro
|
||||
|
||||
; 此处的cli在进入rust的中断处理函数后才会对应sti
|
||||
; 因为在保存栈帧前中断不可以被打断
|
||||
%macro interrupt_entry_enter 0
|
||||
cli
|
||||
push rbp
|
||||
lea rbp, [rsp]
|
||||
store_regs
|
||||
|
@ -62,6 +65,7 @@
|
|||
retrieve_section
|
||||
retrieve_regs
|
||||
leave
|
||||
sti
|
||||
%endmacro
|
||||
|
||||
; 用于带有错误码的中断,创建一个没有错误码的上下文拷贝
|
||||
|
|
|
@ -9,3 +9,30 @@ interrupt_open:
|
|||
interrupt_close:
|
||||
cli
|
||||
ret
|
||||
|
||||
global interrupt_rust_enter
|
||||
extern TSS
|
||||
; usize interrupt_rust_enter()
|
||||
; 返回值用于为寄存器rax占位
|
||||
interrupt_rust_enter:
|
||||
; *(rsp - 8) = *(TSS + 36)
|
||||
mov rax, [TSS + 36]
|
||||
mov qword [rsp - 8], rax
|
||||
; *(TSS + 36) = rsp - 8
|
||||
mov rax, TSS
|
||||
lea rax, [rax + 36]
|
||||
mov [rax], rsp
|
||||
sub qword [rax], 8
|
||||
sti
|
||||
ret
|
||||
|
||||
global interrupt_rust_leave
|
||||
extern TSS
|
||||
; usize interrupt_rust_leave()
|
||||
; 返回值用于为寄存器rax占位
|
||||
interrupt_rust_leave:
|
||||
cli
|
||||
; *(TSS + 36) = *(rsp - 8)
|
||||
mov rax, [rsp - 8]
|
||||
mov [TSS + 36], rax
|
||||
ret
|
||||
|
|
Reference in New Issue