mirror of https://github.com/vinc/moros.git
Fix random memory issues (#573)
* Move AmlContext * Add more information for already mapped pages * Increase stack size for ACPI shutdown * Refactor phys_to_virt
This commit is contained in:
parent
a511647bad
commit
13aeaeb8aa
|
@ -19,8 +19,6 @@ pub fn shutdown() {
|
|||
let slp_len = 1 << 13;
|
||||
|
||||
log!("ACPI Shutdown\n");
|
||||
let handler = Box::new(MorosAmlHandler);
|
||||
let mut aml = AmlContext::new(handler, DebugVerbosity::None);
|
||||
let res = unsafe { AcpiTables::search_for_rsdp_bios(MorosAcpiHandler) };
|
||||
match res {
|
||||
Ok(acpi) => {
|
||||
|
@ -36,6 +34,8 @@ pub fn shutdown() {
|
|||
let table = unsafe {
|
||||
core::slice::from_raw_parts(ptr , dsdt.length as usize)
|
||||
};
|
||||
let handler = Box::new(MorosAmlHandler);
|
||||
let mut aml = AmlContext::new(handler, DebugVerbosity::None);
|
||||
if aml.parse_table(table).is_ok() {
|
||||
let name = AmlName::from_str("\\_S5").unwrap();
|
||||
let res = aml.namespace.get_by_path(&name);
|
||||
|
@ -45,21 +45,22 @@ pub fn shutdown() {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
debug!("ACPI Failed to parse AML in DSDT");
|
||||
debug!("ACPI: Could not parse AML in DSDT");
|
||||
// FIXME: AML parsing works on QEMU and Bochs but not
|
||||
// on VirtualBox at the moment, so we use the following
|
||||
// hardcoded value:
|
||||
slp_typa = (5 & 7) << 10;
|
||||
}
|
||||
} else {
|
||||
debug!("ACPI: Could not find DSDT in BIOS");
|
||||
}
|
||||
}
|
||||
Err(_e) => {
|
||||
debug!("ACPI Could not find RDSP in BIOS\n");
|
||||
debug!("ACPI: Could not find RDSP in BIOS");
|
||||
}
|
||||
};
|
||||
|
||||
let mut port: Port<u16> = Port::new(pm1a_control_block as u16);
|
||||
//debug!("ACPI shutdown");
|
||||
unsafe {
|
||||
port.write(slp_typa | slp_len);
|
||||
}
|
||||
|
|
|
@ -83,6 +83,9 @@ pub fn alloc_pages(
|
|||
mapping.flush();
|
||||
} else {
|
||||
debug!("Could not map {:?} to {:?}", page, frame);
|
||||
if let Ok(old_frame) = mapper.translate_page(page) {
|
||||
debug!("Aleardy mapped to {:?}", old_frame);
|
||||
}
|
||||
return Err(());
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -7,7 +7,7 @@ use x86_64::structures::gdt::{
|
|||
use x86_64::structures::tss::TaskStateSegment;
|
||||
use x86_64::VirtAddr;
|
||||
|
||||
const STACK_SIZE: usize = 1024 * 8;
|
||||
const STACK_SIZE: usize = 1024 * 8 * 16;
|
||||
pub const DOUBLE_FAULT_IST: u16 = 0;
|
||||
pub const PAGE_FAULT_IST: u16 = 1;
|
||||
pub const GENERAL_PROTECTION_FAULT_IST: u16 = 2;
|
||||
|
|
|
@ -57,7 +57,9 @@ pub fn memory_size() -> u64 {
|
|||
}
|
||||
|
||||
pub fn phys_to_virt(addr: PhysAddr) -> VirtAddr {
|
||||
let phys_mem_offset = unsafe { PHYS_MEM_OFFSET.unwrap() };
|
||||
let phys_mem_offset = unsafe {
|
||||
PHYS_MEM_OFFSET.unwrap()
|
||||
};
|
||||
VirtAddr::new(addr.as_u64() + phys_mem_offset)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue