mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-27 02:03:29 +04:00
Add Invalid Opcode handler. Set rsp when going to user.
This commit is contained in:
parent
40b02c33cb
commit
9723d7c1a3
@ -14,6 +14,7 @@ pub fn init() {
|
|||||||
idt[T_BRKPT].set_handler_fn(breakpoint);
|
idt[T_BRKPT].set_handler_fn(breakpoint);
|
||||||
idt[T_PGFLT].set_handler_fn(page_fault);
|
idt[T_PGFLT].set_handler_fn(page_fault);
|
||||||
idt[T_GPFLT].set_handler_fn(general_protection_fault);
|
idt[T_GPFLT].set_handler_fn(general_protection_fault);
|
||||||
|
idt[T_ILLOP].set_handler_fn(invalid_opcode);
|
||||||
idt[T_IRQ0 + IRQ_COM1].set_handler_fn(com1);
|
idt[T_IRQ0 + IRQ_COM1].set_handler_fn(com1);
|
||||||
idt[T_IRQ0 + IRQ_COM2].set_handler_fn(com2);
|
idt[T_IRQ0 + IRQ_COM2].set_handler_fn(com2);
|
||||||
idt[T_IRQ0 + IRQ_KBD].set_handler_fn(keyboard);
|
idt[T_IRQ0 + IRQ_KBD].set_handler_fn(keyboard);
|
||||||
|
@ -28,6 +28,12 @@ interrupt_error_p!(general_protection_fault, stack, {
|
|||||||
loop {}
|
loop {}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
interrupt_stack_p!(invalid_opcode, stack, {
|
||||||
|
println!("\nEXCEPTION: Invalid Opcode");
|
||||||
|
stack.dump();
|
||||||
|
loop {}
|
||||||
|
});
|
||||||
|
|
||||||
#[cfg(feature = "use_apic")]
|
#[cfg(feature = "use_apic")]
|
||||||
use arch::driver::apic::ack;
|
use arch::driver::apic::ack;
|
||||||
#[cfg(not(feature = "use_apic"))]
|
#[cfg(not(feature = "use_apic"))]
|
||||||
|
@ -336,16 +336,18 @@ macro_rules! interrupt_switch {
|
|||||||
let mut rsp: usize;
|
let mut rsp: usize;
|
||||||
asm!("" : "={rsp}"(rsp) : : : "intel", "volatile");
|
asm!("" : "={rsp}"(rsp) : : : "intel", "volatile");
|
||||||
|
|
||||||
// Map kernel
|
|
||||||
// $crate::arch::x86_64::pti::map();
|
|
||||||
|
|
||||||
// Call inner rust function
|
// Call inner rust function
|
||||||
inner(&mut rsp);
|
inner(&mut rsp);
|
||||||
|
|
||||||
asm!("" : : "{rsp}"(rsp) : : "intel", "volatile");
|
// Set return rsp if to user
|
||||||
|
use arch::gdt;
|
||||||
|
use core::mem::size_of;
|
||||||
|
let tf = &mut *(rsp as *mut TrapFrame);
|
||||||
|
if tf.iret.cs == gdt::UCODE_SELECTOR.0 as usize {
|
||||||
|
gdt::set_ring0_rsp(rsp + size_of::<TrapFrame>());
|
||||||
|
}
|
||||||
|
|
||||||
// Unmap kernel
|
asm!("" : : "{rsp}"(rsp) : : "intel", "volatile");
|
||||||
// $crate::arch::x86_64::pti::unmap();
|
|
||||||
|
|
||||||
// Pop scratch registers and return
|
// Pop scratch registers and return
|
||||||
fs_pop!();
|
fs_pop!();
|
||||||
|
Loading…
Reference in New Issue
Block a user