重写rust核心库,构建中断处理框架 #6

Merged
pointer-to-bios merged 18 commits from pointer-to-bios/metaverse-dev:main into main 2024-05-03 05:45:43 +08:00
2 changed files with 31 additions and 0 deletions
Showing only changes of commit 2d6b898c49 - Show all commits

View File

@ -51,7 +51,10 @@
add rsp, 4 add rsp, 4
%endmacro %endmacro
; 此处的cli在进入rust的中断处理函数后才会对应sti
; 因为在保存栈帧前中断不可以被打断
%macro interrupt_entry_enter 0 %macro interrupt_entry_enter 0
cli
push rbp push rbp
lea rbp, [rsp] lea rbp, [rsp]
store_regs store_regs
@ -62,6 +65,7 @@
retrieve_section retrieve_section
retrieve_regs retrieve_regs
leave leave
sti
%endmacro %endmacro
; 用于带有错误码的中断,创建一个没有错误码的上下文拷贝 ; 用于带有错误码的中断,创建一个没有错误码的上下文拷贝

View File

@ -9,3 +9,30 @@ interrupt_open:
interrupt_close: interrupt_close:
cli cli
ret 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