redox/src/arch/x86_64/main.rs

37 lines
1,021 B
Rust
Raw Normal View History

2016-08-14 02:21:46 +02:00
/// This function is where the kernel sets up IRQ handlers
/// It is increcibly unsafe, and should be minimal in nature
/// It must create the IDT with the correct entries, those entries are
/// defined in other files inside of the `arch` module
2016-08-14 02:58:31 +02:00
use super::idt::{IDTR, IDT};
2016-08-14 02:21:46 +02:00
#[naked]
#[no_mangle]
2016-08-14 03:08:40 +02:00
pub unsafe extern "C" fn kmain() {
2016-08-14 02:21:46 +02:00
asm!("xchg bx, bx" : : : : "intel", "volatile");
2016-08-14 02:58:31 +02:00
for entry in IDT.iter_mut() {
entry.attribute = 1 << 7 | 0xE;
entry.selector = 8;
2016-08-14 03:08:40 +02:00
entry.set_offset(blank as usize);
2016-08-14 02:58:31 +02:00
entry.zero = 0;
entry.zero2 = 0;
}
IDTR.set_slice(&IDT);
asm!("lidt [rax]" : : "{rax}"(&IDTR as *const _ as usize) : : "intel", "volatile");
asm!("xchg bx, bx" : : : : "intel", "volatile");
asm!("int 0xFF" : : : : "intel", "volatile");
loop{
asm!("hlt" : : : : "intel", "volatile");
}
}
#[naked]
2016-08-14 03:08:40 +02:00
pub unsafe extern "C" fn blank() {
2016-08-14 02:58:31 +02:00
asm!("xchg bx, bx" : : : : "intel", "volatile");
asm!("iretq" : : : : "intel", "volatile");
2016-08-14 02:21:46 +02:00
}