init version

This commit is contained in:
2026-02-20 22:17:31 +01:00
commit c4c1a4350c
28 changed files with 755 additions and 0 deletions

1
members/oxide/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

13
members/oxide/Cargo.toml Normal file
View File

@@ -0,0 +1,13 @@
[package]
name = "oxide"
version = "0.1.0"
edition = "2024"
build = "build.rs"
[[bin]]
name = "oxide"
test = false
bench = false
[dependencies]
bios = { workspace = true }

10
members/oxide/build.rs Normal file
View File

@@ -0,0 +1,10 @@
const LINKER: &str = ".cargo/linker-multiboot.ld";
fn main() {
// println!("cargo:rustc-link-arg=-N");
// println!("cargo:rustc-link-arg=-s");
println!("cargo:rustc-link-arg=-n");
println!("cargo:rustc-link-arg=-T{LINKER}");
println!("cargo:rerun-if-changed={LINKER}");
}

43
members/oxide/src/main.rs Normal file
View File

@@ -0,0 +1,43 @@
#![no_std]
#![no_main]
#![deny(clippy::float_arithmetic)]
/// Triggers a linker failure if this reaches that phase
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
unsafe extern "C" {
static __PANIC_HANDLER_WAS_LINKED__DO_NOT_DEFINE: extern "C" fn() -> !;
}
unsafe { __PANIC_HANDLER_WAS_LINKED__DO_NOT_DEFINE() };
}
use core::{arch::asm, panic::PanicInfo};
pub mod multiboot2;
#[used]
#[unsafe(link_section = ".multiboot2_header")]
static HEADER: multiboot2::Header = multiboot2::Header::new();
const VGA_BUFFER: *mut u8 = 0xb8000 as *mut u8;
#[unsafe(no_mangle)]
fn start() -> ! {
// notes
// 1st nibble bg
// 2nd nibble fg
//
// 2: green 010
// 4: red 100
// F: white FFFF
// 1: blue 001
// conclussion: 4bit LRGB where L: Lightness
unsafe {
*VGA_BUFFER.offset(0) = b'O';
*VGA_BUFFER.offset(2) = b'K';
*VGA_BUFFER.offset(1) = 0x2F;
*VGA_BUFFER.offset(3) = 0xAF;
}
unsafe { asm!("hlt", "ud2", options(noreturn)) };
}

View File

@@ -0,0 +1,42 @@
pub const HEADER_MAGIC: u32 = 0xe85250d6;
#[repr(C, packed)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct Header {
magic: u32,
arch: HeaderArchitecture,
length: u32,
checksum: i32,
// optional flags
typ: u16,
flags: u16,
size: u32,
}
impl Header {
pub const fn new() -> Self {
let length = size_of::<Self>() as _;
let arch = HeaderArchitecture::ProtectedI386;
Header {
magic: HEADER_MAGIC,
arch,
length,
checksum: -(HEADER_MAGIC as i32 + length as i32 + arch as u32 as i32),
typ: 0,
flags: 0,
size: 0,
}
}
}
impl Default for Header {
fn default() -> Self {
Self::new()
}
}
#[repr(u32)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum HeaderArchitecture {
ProtectedI386 = 0,
}