This commit is contained in:
Timothy Warren 2019-09-23 16:31:22 -04:00
parent a295995442
commit b91cab1d91
5 changed files with 43 additions and 1 deletions

5
.cargo/config Normal file
View File

@ -0,0 +1,5 @@
[build]
target = "x86_64-blog_os.json"
[target.'cfg(target_os = "none")']
runner = "bootimage runner"

10
Cargo.lock generated
View File

@ -3,4 +3,14 @@
[[package]] [[package]]
name = "blog_os" name = "blog_os"
version = "0.1.0" 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"

View File

@ -1,12 +1,13 @@
[package] [package]
name = "blog_os" name = "blog_os"
version = "0.1.0" version = "0.1.0"
authors = ["Timothy Warren <twarren@nabancard.com>"] authors = ["Timothy Warren <tim@timshomepage.net>"]
edition = "2018" edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
bootloader = "0.8.1"
[profile.dev] [profile.dev]
panic = "abort" panic = "abort"

View File

@ -9,7 +9,18 @@ fn panic(_info: &PanicInfo) -> ! {
loop {} loop {}
} }
static HELLO: &[u8] = b"Hello World!";
#[no_mangle] #[no_mangle]
pub extern "C" fn _start() -> ! { 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 {} loop {}
} }

15
x86_64-blog_os.json Normal file
View File

@ -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"
}