diff --git a/.cargo/config.toml b/.cargo/config.toml index c0bc335..252327e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,4 +4,7 @@ build-std = ["core", "compiler_builtins"] build-std-features = ["compiler-builtins-mem"] [build] -target = "x86_64-rust_kernel.json" \ No newline at end of file +target = "x86_64-rust_kernel.json" + +[target.'cfg(target_os = "none")'] +runner = "bootimage runner" \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index bce2cea..28b86d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "bootloader" +version = "0.9.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13f6a8a495d2f93fe3d6eb3a224f9aa749a63cfd746ed03eb5ddcbd00ade7d8f" + [[package]] name = "rust-kernel" version = "0.1.0" +dependencies = [ + "bootloader", +] diff --git a/Cargo.toml b/Cargo.toml index 0a7364b..498c5d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,4 @@ test = false bench = false [dependencies] +bootloader = "0.9" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e7a89b1..bba2eff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,19 @@ #![no_std] #![no_main] +static HELLLO: &[u8] = b"Hello World!"; -#![unsafe(no_mangle)] +#[unsafe(no_mangle)] pub extern "C" fn _start() -> ! { + let vga_buffer = 0xb8000 as *mut u8; + + for (i, &byte) in HELLLO.iter().enumerate() { + unsafe { + *vga_buffer.offset(i as isize * 2) = byte; + *vga_buffer.offset(i as isize * 2 +1) = 0xb; + } + } + loop { }