diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..a697a9f --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,9 @@ +[unstable] +build-std-features = ["compiler-builtins-mem"] +build-std = ["core", "compiler_builtins"] + +[build] +target = ["x86_64-donald.json"] + +[target.'cfg(target_os = "none")'] +runner = "bootimage runner" \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index e574611..34cc842 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.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "365861702868e2a37b4247aaecc7bd8f4389baec8d025497ad8ba7ff37ee9440" + [[package]] name = "donald" version = "0.1.0" +dependencies = [ + "bootloader", +] diff --git a/Cargo.toml b/Cargo.toml index 61172f5..bb00d9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,4 +9,8 @@ panic = "abort" [profile.release] panic = "abort" +[unstable] +build-std = ["core", "compiler_builtins"] + [dependencies] +bootloader = "0.9" diff --git a/README.md b/README.md index e69de29..d096d6d 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,4 @@ +# Donald +An OS written in Rust. +# Building +Run `rustup override set nightly` to initialize the nightly branch. then run `./build.sh` \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..c158b24 --- /dev/null +++ b/build.sh @@ -0,0 +1,2 @@ +rustup component add rust-src +cargo build --target x86_64-donald.json \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 39486ea..14e47f5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,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-donald.json b/x86_64-donald.json new file mode 100644 index 0000000..0956b04 --- /dev/null +++ b/x86_64-donald.json @@ -0,0 +1,15 @@ +{ + "llvm-target": "x86_64-unknown-none", + "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-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