-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(kernel): change idt module structure
- Loading branch information
Showing
4 changed files
with
73 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use crate::{assign_isr, idt::descriptor::GateType}; | ||
|
||
// Interrupt Service Routines | ||
assign_isr!( | ||
0, GateType::TrapGate | ||
3, GateType::TrapGate); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use core::arch::naked_asm; | ||
|
||
use framebuffer::color; | ||
use hal::cpu_state::CpuState; | ||
|
||
use crate::println; | ||
|
||
pub(super) mod handler; | ||
pub(super) mod macros; | ||
|
||
fn dispatch(state: &CpuState) -> &CpuState { | ||
println!(color::INFO, "Hello DEBUG Interrupt!"); | ||
state | ||
} | ||
|
||
#[naked] | ||
extern "C" fn interrupt_stub() { | ||
unsafe { | ||
naked_asm!( | ||
"push rax", | ||
"push rbx", | ||
"push rcx", | ||
"push rdx", | ||
"push rsi", | ||
"push rdi", | ||
"push rbp", | ||
"push r8", | ||
"push r9", | ||
"push r10", | ||
"push r11", | ||
"push r12", | ||
"push r13", | ||
"push r14", | ||
"push r15", | ||
// pass rsp to the dispatch handler (stack pointer) | ||
"mov rdi, rsp", | ||
"call {interrupt_dispatch}", | ||
|
||
// restore the stack pointer returned by the dispatch handler | ||
"mov rsp, rax", | ||
|
||
"pop r15", | ||
"pop r14", | ||
"pop r13", | ||
"pop r12", | ||
"pop r11", | ||
"pop r10", | ||
"pop r9", | ||
"pop r8", | ||
"pop rbp", | ||
"pop rdi", | ||
"pop rsi", | ||
"pop rdx", | ||
"pop rcx", | ||
"pop rbx", | ||
"pop rax", | ||
// remove vector number + error code (16 bytes) | ||
"add rsp, 16", | ||
"iretq", | ||
interrupt_dispatch = sym dispatch | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters