1
0
Fork 0
forked from AbleOS/ableos

Arm is now feature parity with x86

This commit is contained in:
able 2023-09-17 16:03:32 -05:00
parent 008a8eb336
commit e7bbb9a375
3 changed files with 100 additions and 5 deletions

View file

@ -7,8 +7,17 @@ SECTIONS
.text : { *(.text) } .text : { *(.text) }
.data : { *(.data) } .data : { *(.data) }
.rodata : { *(.rodata) } .rodata : { *(.rodata) }
.bss : { *(.bss) } .bss : {
*(COMMON)
*(.bss .bss.*)
/* Align initial kernel heap to page boundary */
. = ALIGN(4K);
PROVIDE(_initial_kernel_heap_start = .);
/* PROVIDE(_initial_kernel_heap_size = 1024 * 1024); */
PROVIDE(_initial_kernel_heap_size = 1024 * 4096 * 100);
. += _initial_kernel_heap_size;
} :data
. = ALIGN(8); . = ALIGN(8);
. = . + 0x4000; . = . + 0x4000;
LD_STACK_PTR = .; LD_STACK_PTR = .;

View file

@ -1,7 +1,17 @@
use {core::arch::asm, limine::FramebufferRequest};
pub mod logging;
pub use logging::log; pub use logging::log;
use {
crate::{allocator, bootmodules::BootModule, kmain::kmain},
core::arch::asm,
limine::FramebufferRequest,
};
pub mod logging;
use limine::HhdmRequest;
extern "C" {
fn _initial_kernel_heap_start();
fn _initial_kernel_heap_size();
}
const INITIAL_KERNEL_HEAP_START: *mut u8 = _initial_kernel_heap_start as _;
const INITIAL_KERNEL_HEAP_SIZE: *const () = _initial_kernel_heap_size as _;
pub const PAGE_SIZE: usize = 4096; pub const PAGE_SIZE: usize = 4096;
@ -20,6 +30,80 @@ unsafe extern "C" fn _kernel_start() -> ! {
} }
} }
static HDHM_REQ: HhdmRequest = HhdmRequest::new(0);
// memory::init_pt(VirtAddr::new(
// HDHM_REQ
// .get_response()
// .get()
// .expect("tried to get physical memory mapping offset from Limine")
// .offset,
// ));
allocator::init(INITIAL_KERNEL_HEAP_START, INITIAL_KERNEL_HEAP_SIZE as _);
let bm = MOD_REQ.get_response().get();
use limine::{KernelFileRequest, ModuleRequest};
static KFILE_REQ: KernelFileRequest = KernelFileRequest::new(0);
static MOD_REQ: ModuleRequest = ModuleRequest::new(0);
let mut bootmodules = alloc::vec::Vec::new();
if bm.is_some() {
let bm = bm.unwrap();
for x in 0..bm.module_count {
let file = bm.modules().get(x as usize);
if file.is_some() {
let file = file.unwrap();
let raw_bytes = core::slice::from_raw_parts(
file.base.as_ptr().expect("invalid initrd"),
file.length as usize,
)
.to_vec();
let file_path = alloc::string::String::from_utf8(
file.path.to_str().unwrap().to_bytes().to_vec(),
);
if file_path.is_err() {
panic!("invalid file path: {:?}", file_path);
}
let file_cmd = alloc::string::String::from_utf8(
file.cmdline.to_str().unwrap().to_bytes().to_vec(),
);
if file_cmd.is_err() {
panic!("invalid module cmd: {:?}", file_cmd);
}
log::trace!("module path: {:?}", file_path);
log::trace!("module cmd: {:?}", file_cmd);
bootmodules.push(BootModule::new(
file_path.unwrap(),
raw_bytes,
file_cmd.unwrap(),
));
} else {
log::error!("You should not be here");
break;
}
}
log::info!("Boot module count: {:?}", bootmodules.len());
assert_eq!(bm.module_count, bootmodules.len() as u64);
}
crate::kmain::kmain(
KFILE_REQ
.get_response()
.get()
.and_then(|r| r.kernel_file.get())
.expect("failed to get kernel file from Limine")
.cmdline
.to_str()
.map(core::ffi::CStr::to_str)
.transpose()
.expect("expected valid cmdline string")
.unwrap_or_default(),
bootmodules,
);
spin_loop(); spin_loop();
} }
@ -34,3 +118,5 @@ pub fn hardware_random_u64() -> u64 {
} }
pub fn register_dump() {} pub fn register_dump() {}
#[no_mangle]
pub fn fmod() {}

View file

@ -4,7 +4,7 @@ use log::{Level, SetLoggerError};
pub fn init() -> Result<(), SetLoggerError> { pub fn init() -> Result<(), SetLoggerError> {
log::set_logger(&crate::logger::Logger)?; log::set_logger(&crate::logger::Logger)?;
log::set_max_level(log::LevelFilter::Trace); log::set_max_level(log::LevelFilter::Debug);
Ok(()) Ok(())
} }