Booting from the code

This commit is contained in:
thatscringebro 2024-09-09 20:00:34 -04:00
parent a0b3d273b2
commit b2f0b35307
4 changed files with 36 additions and 6 deletions

9
.cargo/config.toml Normal file
View File

@ -0,0 +1,9 @@
[build]
target = "x86_64-simpleos.json"
[unstable]
build-std-features = ["compiler-builtins-mem"]
build-std = ["core", "compiler_builtins"]
[target.'cfg(target_os = "none")']
runner = "bootimage runner"

View File

@ -3,10 +3,5 @@ name = "simpleos"
version = "0.1.0"
edition = "2021"
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
[dependencies]
bootloader = "0.9"

View File

@ -3,8 +3,19 @@
use core::panic::PanicInfo;
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-simpleos.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"
}