mirror of
https://github.com/iceHtwoO/novaOS.git
synced 2026-04-17 04:32:27 +00:00
feat: implement MMU core functionality
* feat: Implement a basic MMU configuration * feat: Enhance MMU by separating sections and configuring permissions * feat: Update MMU configuration and memory allocation functions * fix: Level 3 translation fault * docs: add code documentation * fix: linter * feat: map translation tables to kernel space * feat: move el1 stack to kernel VA space * feat: use virtual memory for heap allocation * docs: update Readme
This commit is contained in:
committed by
GitHub
parent
55f410e2bb
commit
f78388ee2c
@@ -5,7 +5,7 @@ use alloc::vec::Vec;
|
||||
use crate::{
|
||||
aarch64::registers::{
|
||||
daif::{mask_all, unmask_irq},
|
||||
read_esr_el1, read_exception_source_el,
|
||||
read_elr_el1, read_esr_el1, read_exception_source_el,
|
||||
},
|
||||
get_current_el,
|
||||
peripherals::{
|
||||
@@ -82,7 +82,7 @@ unsafe extern "C" fn rust_irq_handler() {
|
||||
println!("Return register address: {:#x}", read_esr_el1());
|
||||
}
|
||||
|
||||
if let Some(handler_vec) = unsafe { INTERRUPT_HANDLERS.as_ref() } {
|
||||
if let Some(handler_vec) = unsafe { &*core::ptr::addr_of_mut!(INTERRUPT_HANDLERS) } {
|
||||
for handler in handler_vec {
|
||||
if (pending_irqs & (1 << (handler.source.clone() as u32))) != 0 {
|
||||
(handler.function)();
|
||||
@@ -118,15 +118,17 @@ unsafe extern "C" fn rust_synchronous_interrupt_imm_lower_aarch64() {
|
||||
println!("--------Sync Exception in EL{}--------", source_el);
|
||||
println!("Exception escalated to EL {}", get_current_el());
|
||||
println!("Current EL: {}", get_current_el());
|
||||
let esr = EsrElX::from(read_esr_el1());
|
||||
println!("{:?}", EsrElX::from(esr));
|
||||
println!("Return register address: {:#x}", read_esr_el1());
|
||||
let esr: EsrElX = EsrElX::from(read_esr_el1());
|
||||
println!("{:?}", esr);
|
||||
println!("Return address: {:#x}", read_elr_el1());
|
||||
|
||||
match esr.ec {
|
||||
0b100100 => {
|
||||
println!("Cause: Data Abort from a lower Exception level");
|
||||
}
|
||||
_ => {}
|
||||
_ => {
|
||||
println!("Unknown Error Code: {:b}", esr.ec);
|
||||
}
|
||||
}
|
||||
println!("-------------------------------------");
|
||||
|
||||
@@ -136,7 +138,9 @@ unsafe extern "C" fn rust_synchronous_interrupt_imm_lower_aarch64() {
|
||||
fn clear_interrupt_for_source(source: IRQSource) {
|
||||
match source {
|
||||
IRQSource::UartInt => clear_uart_interrupt_state(),
|
||||
_ => {}
|
||||
_ => {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,12 +216,13 @@ pub fn get_irq_pending_sources() -> u64 {
|
||||
pending
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn initialize_interrupt_handler() {
|
||||
unsafe { INTERRUPT_HANDLERS = Some(Vec::new()) };
|
||||
}
|
||||
|
||||
pub fn register_interrupt_handler(source: IRQSource, function: fn()) {
|
||||
if let Some(handler_vec) = unsafe { INTERRUPT_HANDLERS.as_mut() } {
|
||||
if let Some(handler_vec) = unsafe { &mut *core::ptr::addr_of_mut!(INTERRUPT_HANDLERS) } {
|
||||
handler_vec.push(InterruptHandlers { source, function });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user