Merging with origin/unified

This commit is contained in:
2025-03-05 21:04:58 +00:00
38 changed files with 674 additions and 154 deletions
+23 -11
View File
@@ -12,42 +12,43 @@
)]
extern crate alloc;
use crate::{
arch::x86_64::memory::init_page_table,
prelude::*,
};
use crate::{arch::x86_64::memory::init_page_table, prelude::*};
use arch::x86_64::memory::allocation::heap_alloc::init_heap;
use arch::x86_64::memory::mapping;
use core::arch::asm;
use limine::BaseRevision;
use std::unwind;
use std::unwind::eh_info::ELF;
use x86_64::VirtAddr;
use arch::x86_64::memory::allocation::page_alloc::FoundryOSFrameAllocator;
use crate::arch::x86_64::cpu::apic::enable_apic;
use crate::arch::x86_64::drivers::ascii::screensize_chars;
use crate::arch::x86_64::drivers::framebuffer::display::screensize_px;
use crate::arch::x86_64::memory::allocation::heap_alloc::FoundryAllocator;
use crate::arch::x86_64::memory::FRAME_ALLOCATOR;
use crate::arch::x86_64::memory::units::MemoryUnits;
pub mod arch;
mod panic;
pub mod resources;
#[allow(unused)] // We aren't using much of this right now.
pub mod std;
pub mod util;
pub mod prelude {
pub use crate::std::io::{_print, _print_log, _serial_write};
pub use crate::std::debug::_debug;
pub use crate::{
print, print_log, printerr, println, println_log, printlnerr, serial_print, serial_println, debug
eprint, eprintln, print, print_log, println, println_log, serial_print,
serial_println,
std::io::{_print, _print_err, _print_log, _serial_write},
};
}
/// Sets the base revision to the latest revision supported by the crate.
/// See specification for further info.
/// Be sure to mark all limine requests with #[used], otherwise they may be removed by the compiler.
/// Be sure to mark all limine requests with #[used], otherwise they may be
/// removed by the compiler.
#[used]
// The .requests section allows limine to find the requests faster and more safely.
// The .requests section allows limine to find the requests faster and more
// safely.
#[unsafe(link_section = ".requests")]
static BASE_REVISION: BaseRevision = BaseRevision::new();
@@ -69,7 +70,7 @@ pub fn hcf() -> ! {
pub fn boot() -> Result<(), &'static str> {
if !BASE_REVISION.is_supported() {
return Err("base revision not supported");
return Err("Base revision not supported");
}
use arch::x86_64::{gdt, interrupts};
@@ -131,5 +132,16 @@ pub fn boot() -> Result<(), &'static str> {
x86_64::instructions::interrupts::enable();
debugln!("[Success]");
debug!(" Setting up stack unwinder, panic handler... ");
// Setup stack traces and proper panic handler. TODO: Handle panics
// differently if not initialised.
let eh_frame_ptr = ELF
.get_section_addr(".eh_frame_hdr")
.expect("Could not get `.eh_frame_hdr` address.");
let _eh_info =
unsafe { unwind::eh_info::EhInfo::from_hdr_ptr(eh_frame_ptr) };
debugln!("[Success]");
Ok(())
}