add bootimage

This commit is contained in:
mindfreq 2026-04-13 10:25:43 +02:00
parent 5dcf4328d7
commit 7e145ef68b
4 changed files with 25 additions and 2 deletions

View file

@ -4,4 +4,7 @@ build-std = ["core", "compiler_builtins"]
build-std-features = ["compiler-builtins-mem"] build-std-features = ["compiler-builtins-mem"]
[build] [build]
target = "x86_64-rust_kernel.json" target = "x86_64-rust_kernel.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. # It is not intended for manual editing.
version = 4 version = 4
[[package]]
name = "bootloader"
version = "0.9.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13f6a8a495d2f93fe3d6eb3a224f9aa749a63cfd746ed03eb5ddcbd00ade7d8f"
[[package]] [[package]]
name = "rust-kernel" name = "rust-kernel"
version = "0.1.0" version = "0.1.0"
dependencies = [
"bootloader",
]

View file

@ -17,3 +17,4 @@ test = false
bench = false bench = false
[dependencies] [dependencies]
bootloader = "0.9"

View file

@ -1,9 +1,19 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
static HELLLO: &[u8] = b"Hello World!";
#![unsafe(no_mangle)] #[unsafe(no_mangle)]
pub extern "C" fn _start() -> ! { 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 { loop {
} }