diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 0000000..8fb36b9 --- /dev/null +++ b/.cargo/config @@ -0,0 +1,5 @@ +[build] +target = "x86_64-blog_os.json" + +[target.'cfg(target_os = "none")'] +runner = "bootimage runner" \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index f579ba5..9599aca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,4 +3,14 @@ [[package]] name = "blog_os" version = "0.1.0" +dependencies = [ + "bootloader 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] +[[package]] +name = "bootloader" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum bootloader 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "45dd858bd74a742ec0fe887722952c263abd0825aa8d33a3704917a97d7bd41e" diff --git a/Cargo.toml b/Cargo.toml index 1556d0b..cc56755 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,13 @@ [package] name = "blog_os" version = "0.1.0" -authors = ["Timothy Warren "] +authors = ["Timothy Warren "] edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +bootloader = "0.8.1" [profile.dev] panic = "abort" diff --git a/src/main.rs b/src/main.rs index cc8ed53..8c705df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,18 @@ fn panic(_info: &PanicInfo) -> ! { loop {} } +static HELLO: &[u8] = b"Hello World!"; + #[no_mangle] pub extern "C" fn _start() -> ! { + let vga_buffer = 0xb8000 as *mut u8; + + for (i, &byte) in HELLO.iter().enumerate() { + unsafe { + *vga_buffer.offset(i as isize * 2) = byte; + *vga_buffer.offset(i as isize * 2 + 1) = 0xb; + } + } + loop {} } diff --git a/x86_64-blog_os.json b/x86_64-blog_os.json new file mode 100644 index 0000000..97da923 --- /dev/null +++ b/x86_64-blog_os.json @@ -0,0 +1,15 @@ +{ + "llvm-target": "x86_64-unknown-none", + "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", + "arch": "x86_64", + "target-endian": "little", + "target-pointer-width": "64", + "target-c-int-width": "32", + "os": "none", + "executables": true, + "linker-flavor": "ld.lld", + "linker": "rust-lld", + "panic-strategy": "abort", + "disable-redzone": true, + "features": "-mmx,-sse,+soft-float" +} \ No newline at end of file