blob: c55826a7000b5e2844dda14d151f56c6a38b3781 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#![no_main]
#![feature(custom_test_frameworks)]
#![feature(abi_x86_interrupt)]
#![feature(panic_info_message)]
#![feature(asm)]
#![feature(core_intrinsics)]
#![feature(array_map)]
#![test_runner(crate::testing::test_runner)]
#![no_std]
pub mod interrupts;
#[macro_use]
pub mod io;
pub mod testing;
pub use io::qemu::{exit_qemu, QemuExitCode};
pub use io::{qemu, serial, vga_text};
#[no_mangle]
extern "C" fn _start() -> ! {
interrupts::gdt::init();
interrupts::idt::init();
let apic = interrupts::apic::Apic::new().expect("no APIC support");
let apic = unsafe { interrupts::apic::set_local_apic(apic) };
apic.set_timer_interrupt_handler(
interrupts::apic::TimerDivideConfig::Div16,
interrupts::InterruptType::Timer,
);
x86_64::instructions::interrupts::enable();
vga_println!("apic initialisation complete");
x86_64::instructions::interrupts::int3();
if cfg!(test) {
qemu::exit_qemu(qemu::QemuExitCode::Success);
}
loop {}
}
#[panic_handler]
#[no_mangle]
extern "C" fn panic_handler(info: &core::panic::PanicInfo) -> ! {
if cfg!(test) {
testing::serial_panic(info);
}
testing::panic(info);
}
|