Compare commits

...

2 Commits

Author SHA1 Message Date
thatscringebro
b2f0b35307 Booting from the code 2024-09-09 20:00:34 -04:00
thatscringebro
a0b3d273b2 Free standing rust binary 2024-09-09 16:48:07 -04:00
4 changed files with 49 additions and 2 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

@ -4,3 +4,4 @@ version = "0.1.0"
edition = "2021"
[dependencies]
bootloader = "0.9"

View File

@ -1,3 +1,25 @@
fn main() {
println!("Hello, world!");
#![no_std]
#![no_main]
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 {}
}
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
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"
}