Hello, World!

This commit is contained in:
Conzer 2024-12-03 15:05:13 -05:00
parent 8c4afcd956
commit 22ad44dea7
7 changed files with 54 additions and 0 deletions

9
.cargo/config.toml Normal file
View file

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

9
Cargo.lock generated
View file

@ -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",
]

View file

@ -9,4 +9,8 @@ panic = "abort"
[profile.release]
panic = "abort"
[unstable]
build-std = ["core", "compiler_builtins"]
[dependencies]
bootloader = "0.9"

View file

@ -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`

2
build.sh Executable file
View file

@ -0,0 +1,2 @@
rustup component add rust-src
cargo build --target x86_64-donald.json

View file

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

15
x86_64-donald.json Normal file
View file

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