mirror of
https://github.com/XunilGroup/XunilOS.git
synced 2026-04-25 11:49:03 +02:00
Add interrupts and IDT and react to double, page, general prot faults
and breakpoints, add keyboard support through the keyboar interrupt, add paging memory management and a Frame Allocator, add a generic arch module that initializes arch-specific things, fix framebuffer and serialconsole being accessed from multiple places, move serial to driver since its not actually a serial console.
This commit is contained in:
@@ -2,25 +2,22 @@
|
||||
#![no_main]
|
||||
#![feature(abi_x86_interrupt)]
|
||||
|
||||
use core::arch::asm;
|
||||
use core::fmt::Write;
|
||||
|
||||
use limine::BaseRevision;
|
||||
use limine::request::{FramebufferRequest, RequestsEndMarker, RequestsStartMarker};
|
||||
|
||||
use limine::request::{
|
||||
FramebufferRequest, HhdmRequest, MemoryMapRequest, RequestsEndMarker, RequestsStartMarker,
|
||||
};
|
||||
pub mod arch;
|
||||
pub mod driver;
|
||||
|
||||
use crate::arch::serial::{ConsoleWriter, init_serial_console, with_serial_console};
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::arch::x86_64::gdt::load_gdt_x86_64;
|
||||
use crate::arch::arch::{idle, init};
|
||||
use crate::driver::graphics::base::rgb;
|
||||
use crate::driver::graphics::framebuffer::{init_framebuffer, with_framebuffer};
|
||||
use crate::driver::graphics::primitives::{
|
||||
circle_filled, circle_outline, rectangle_filled, rectangle_outline, triangle_outline,
|
||||
};
|
||||
|
||||
use crate::arch::x86_64::idt::init_idt_x86_64;
|
||||
use crate::driver::serial::{ConsoleWriter, init_serial_console, with_serial_console};
|
||||
|
||||
/// Sets the base revision to the latest revision supported by the crate.
|
||||
/// See specification for further info.
|
||||
@@ -34,6 +31,14 @@ static BASE_REVISION: BaseRevision = BaseRevision::new();
|
||||
#[unsafe(link_section = ".requests")]
|
||||
static FRAMEBUFFER_REQUEST: FramebufferRequest = FramebufferRequest::new();
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
static HHDM_REQUEST: HhdmRequest = HhdmRequest::new();
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
static MEMORY_MAP_REQUEST: MemoryMapRequest = MemoryMapRequest::new();
|
||||
|
||||
/// Define the stand and end markers for Limine requests.
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests_start_marker")]
|
||||
@@ -80,28 +85,36 @@ unsafe extern "C" fn kmain() -> ! {
|
||||
// removed by the linker.
|
||||
assert!(BASE_REVISION.is_supported());
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
{
|
||||
load_gdt_x86_64();
|
||||
init_idt_x86_64();
|
||||
}
|
||||
|
||||
if let Some(framebuffer_response) = FRAMEBUFFER_REQUEST.get_response() {
|
||||
if let Some(limine_framebuffer) = framebuffer_response.framebuffers().next() {
|
||||
init_framebuffer(&limine_framebuffer);
|
||||
with_framebuffer(|mut fb| {
|
||||
let (width, height) = (fb.width.clone(), fb.height.clone());
|
||||
init_serial_console(0, 0);
|
||||
rectangle_filled(&mut fb, 0, 0, width, height, rgb(253, 129, 0), true);
|
||||
rectangle_filled(&mut fb, 700, 400, 200, 200, rgb(0, 0, 0), true);
|
||||
rectangle_outline(&mut fb, 400, 400, 100, 100, rgb(0, 0, 0));
|
||||
circle_filled(&mut fb, 200, 200, 100.0, rgb(0, 0, 0));
|
||||
circle_outline(&mut fb, 400, 200, 100.0, rgb(0, 0, 0));
|
||||
triangle_outline(&mut fb, 100, 400, 200, 400, 150, 600, rgb(0, 0, 0));
|
||||
});
|
||||
// boot_animation();
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(hhdm_response) = HHDM_REQUEST.get_response() {
|
||||
if let Some(memory_map_response) = MEMORY_MAP_REQUEST.get_response() {
|
||||
let mapper = init(hhdm_response, memory_map_response);
|
||||
} else {
|
||||
init_serial_console(0, 0);
|
||||
panic!("Could not get required info from Limine's memory map. ")
|
||||
}
|
||||
} else {
|
||||
init_serial_console(0, 0);
|
||||
panic!("Could not get required info from the Limine's higher-half direct mapping. ")
|
||||
}
|
||||
|
||||
with_framebuffer(|mut fb| {
|
||||
let (width, height) = (fb.width.clone(), fb.height.clone());
|
||||
init_serial_console(0, 0);
|
||||
rectangle_filled(&mut fb, 0, 0, width, height, rgb(253, 129, 0), true);
|
||||
rectangle_filled(&mut fb, 700, 400, 200, 200, rgb(0, 0, 0), true);
|
||||
rectangle_outline(&mut fb, 400, 400, 100, 100, rgb(0, 0, 0));
|
||||
circle_filled(&mut fb, 200, 200, 100.0, rgb(0, 0, 0));
|
||||
circle_outline(&mut fb, 400, 200, 100.0, rgb(0, 0, 0));
|
||||
triangle_outline(&mut fb, 100, 400, 200, 400, 150, 600, rgb(0, 0, 0));
|
||||
});
|
||||
|
||||
idle();
|
||||
}
|
||||
|
||||
@@ -128,16 +141,3 @@ fn rust_panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
|
||||
idle();
|
||||
}
|
||||
|
||||
fn idle() -> ! {
|
||||
loop {
|
||||
unsafe {
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
asm!("hlt");
|
||||
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
|
||||
asm!("wfi");
|
||||
#[cfg(target_arch = "loongarch64")]
|
||||
asm!("idle 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user