add IDT and GDT initialization

This commit is contained in:
Zoe
2026-08-18 12:39:28 -05:00
parent 8dc3839ba4
commit 2a1bf17d8b
11 changed files with 599 additions and 49 deletions
+15 -41
View File
@@ -1,66 +1,40 @@
#![feature(abi_x86_interrupt, negative_impls)]
#![feature(abi_x86_interrupt)]
#![allow(clippy::needless_return)]
#![no_std]
#![no_main]
mod arch;
mod boot;
mod drivers;
mod debug;
mod memory;
use boot::limine::{BASE_REVISION, FRAMEBUFFER_REQUEST};
use crate::drivers::serial;
use crate::debug::serial;
#[unsafe(no_mangle)]
pub extern "C" fn _start() -> ! {
serial::init().unwrap();
assert!(BASE_REVISION.is_supported());
arch::init();
let _boot_info = boot::load_boot_info().unwrap();
draw_gradient();
let addr = 0xDEADBEEF as *mut u32;
unsafe {
*addr = 0xDEADBEEF;
}
hcf();
}
fn draw_gradient() {
if let Some(framebuffer_response) = FRAMEBUFFER_REQUEST.response() {
if let Some(&framebuffer) = framebuffer_response.framebuffers().first() {
let buffer = unsafe {
core::slice::from_raw_parts_mut(
framebuffer.address().cast::<u32>(),
framebuffer.size() / 4,
)
};
for y in 0..framebuffer.height {
for x in 0..framebuffer.width {
let r = (255 * x) / (framebuffer.width - 1);
let g = (255 * y) / (framebuffer.height - 1);
let b = 255 - r;
let pixel = ((r as u32) << 16) | ((g as u32) << 8) | (b as u32);
buffer
[(((y * framebuffer.pitch) / (framebuffer.bpp as u64 / 8)) + x) as usize] =
pixel
}
}
}
}
}
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
fn panic(info: &core::panic::PanicInfo) -> ! {
println!("Uh oh, something went wrong!");
println!("{}", info);
hcf();
}
pub fn hcf() -> ! {
loop {
unsafe {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
core::arch::asm!("hlt");
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
core::arch::asm!("wfi");
}
arch::halt();
}
}