#![no_std]
#![no_main]
use core::arch::global_asm;
use core::panic::PanicInfo;
use os::{exit_qemu, hlt_loop, println, QemuExitCode};
global_asm!(
".section .text.entry",
".globl _start",
"_start:",
" la sp, stack_end",
" la t0, bss_start",
" la t1, bss_end",
"1:",
" bgeu t0, t1, 2f",
" sd zero, (t0)",
" addi t0, t0, 8",
" j 1b",
"2:",
" call test_kernel_main",
"3:",
" wfi",
" j 3b",
);
#[no_mangle]
pub extern "C" fn test_kernel_main() -> ! {
test_main();
loop {
hlt_loop();
}
}
fn test_main() {
test_runner(&[&test_println]);
}
fn test_runner(tests: &[&dyn Fn()]) {
println!("Running {} tests", tests.len());
for test in tests {
test();
}
exit_qemu(QemuExitCode::Success);
}
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
os::test_panic_handler(info)
}
fn test_println() {
println!("test_println output");
}