vga/testing/tests/vga.rs

40 lines
829 B
Rust
Raw Normal View History

2020-03-12 18:34:48 +00:00
#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![reexport_test_harness_main = "test_main"]
#![test_runner(testing::test_runner)]
use core::panic::PanicInfo;
2020-03-13 04:41:00 +00:00
use testing::{gdt, interrupts, serial_print, serial_println};
use vga::{VideoMode, VGA};
2020-03-12 18:34:48 +00:00
#[no_mangle] // don't mangle the name of this function
pub extern "C" fn _start() -> ! {
2020-03-13 04:41:00 +00:00
init();
2020-03-12 18:34:48 +00:00
test_main();
loop {}
}
2020-03-13 04:41:00 +00:00
fn init() {
gdt::init();
interrupts::init_idt();
unsafe { interrupts::PICS.lock().initialize() };
x86_64::instructions::interrupts::enable();
}
2020-03-12 18:34:48 +00:00
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
testing::test_panic_handler(info)
}
#[test_case]
2020-03-13 04:41:00 +00:00
fn set_mode_80x25() {
serial_print!("mode 80x25... ");
let mut vga = VGA.lock();
vga.set_video_mode(VideoMode::Mode80x25);
2020-03-12 18:34:48 +00:00
serial_println!("[ok]");
}