]> git.lizzy.rs Git - loadnothing.git/blobdiff - stage2/src/main.rs
Start VGA API
[loadnothing.git] / stage2 / src / main.rs
index 33e691cb47320141c986e02a2359f640fc8d6f36..4894afbeca33e0cb1d1f45b0bfce158a512baae4 100644 (file)
@@ -3,12 +3,11 @@
 
 #![warn(clippy::arithmetic)]
 
+mod vga;
+
 use core::arch::asm;
-use core::ops::{Add, Mul};
 use core::panic::PanicInfo;
 
-static HELLO: &[u8] = b"Hello Stage2!";
-
 #[panic_handler]
 fn panic(_info: &PanicInfo) -> ! {
     loop {}
@@ -16,24 +15,7 @@ fn panic(_info: &PanicInfo) -> ! {
 
 #[no_mangle]
 pub extern "C" fn _start() -> ! {
-    let vga_buffer = 0xb8000 as *mut u8;
-    let vga_max = 0xf9e;
-
-    // Clear the screen
-    for i in 0..vga_max {
-        unsafe {
-            *vga_buffer.offset((i as isize).mul(2)) = 0x00;
-            *vga_buffer.offset((i as isize).mul(2).add(1)) = 0x07;
-        }
-    }
-
-    // Print welcome message
-    for (i, &byte) in HELLO.iter().enumerate() {
-        unsafe {
-            *vga_buffer.offset((i as isize).mul(2)) = byte;
-            *vga_buffer.offset((i as isize).mul(2).add(1)) = 0x07;
-        }
-    }
+    vga::test_print();
 
     unsafe {
         loop {