mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
35 lines
722 B
Rust
35 lines
722 B
Rust
#![cfg_attr(not(test), no_std)]
|
|
#![cfg_attr(not(test), no_main)]
|
|
#![cfg_attr(test, allow(unused_imports))]
|
|
#![feature(alloc_error_handler)]
|
|
|
|
use blog_os::memory::allocator::DummyAllocator;
|
|
use blog_os::{exit_qemu, serial_println};
|
|
use core::alloc::Layout;
|
|
use core::panic::PanicInfo;
|
|
|
|
#[cfg(not(test))]
|
|
#[no_mangle]
|
|
pub extern "C" fn _start() -> ! {
|
|
panic!();
|
|
}
|
|
|
|
#[cfg(not(test))]
|
|
#[panic_handler]
|
|
fn panic(_info: &PanicInfo) -> ! {
|
|
serial_println!("ok");
|
|
|
|
unsafe {
|
|
exit_qemu();
|
|
}
|
|
loop {}
|
|
}
|
|
|
|
#[global_allocator]
|
|
static ALLOCATOR: DummyAllocator = DummyAllocator;
|
|
|
|
#[alloc_error_handler]
|
|
fn out_of_memory(layout: Layout) -> ! {
|
|
panic!("out of memory: allocation for {:?} failed", layout);
|
|
}
|