Temporarily map pages and run pass APIC init.

master
WangRunji 7 years ago
parent 5d03035f9e
commit ab37e359ac

@ -3,7 +3,7 @@ ENTRY(start)
SECTIONS {
. = 1M;
.rodata :
.rodata : ALIGN(4K)
{
/* ensure that the multiboot header is at the beginning */
KEEP(*(.multiboot_header))
@ -11,42 +11,44 @@ SECTIONS {
. = ALIGN(4K);
}
.text :
.text : ALIGN(4K)
{
*(.text .text.*)
. = ALIGN(4K);
}
.data :
.data : ALIGN(4K)
{
*(.data .data.*)
. = ALIGN(4K);
}
.bss :
.bss : ALIGN(4K)
{
*(.bss .bss.*)
. = ALIGN(4K);
}
.got :
.got : ALIGN(4K)
{
*(.got)
. = ALIGN(4K);
}
.got.plt :
.got.plt : ALIGN(4K)
{
*(.got.plt)
. = ALIGN(4K);
}
.data.rel.ro : ALIGN(4K) {
.data.rel.ro : ALIGN(4K)
{
*(.data.rel.ro.local*) *(.data.rel.ro .data.rel.ro.*)
. = ALIGN(4K);
}
.gcc_except_table : ALIGN(4K) {
.gcc_except_table : ALIGN(4K)
{
*(.gcc_except_table)
. = ALIGN(4K);
}

@ -5,12 +5,11 @@ use self::structs::*;
use consts::*;
pub fn init() -> Result<ACPI_Result, ACPI_Error> {
use core::mem::size_of;
use util::Checkable;
let rsdp = find_rsdp().expect("acpi: rsdp not found.");
if rsdp.RsdtPhysicalAddress > PHYSICAL_MEMORY_LIMIT {
return Err(ACPI_Error::NotMapped);
}
debug!("RSDT at {:#x}", rsdp.RsdtPhysicalAddress);
let rsdt = unsafe{ &*(rsdp.RsdtPhysicalAddress as *const rsdt) };
let mut madt: Option<&'static madt> = None;
for i in 0 .. rsdt.entry_count() {

@ -7,8 +7,6 @@ pub fn init(lapic_addr: *const ()) {
debug!("WARNING: lapic::init use C lib");
unsafe {
lapic = lapic_addr;
debug!("lapic = {:?}", lapic);
unimplemented!();
lapicinit();
}
}

@ -65,12 +65,19 @@ pub extern "C" fn rust_main(multiboot_information_address: usize) {
test!(guard_page);
test!(find_mp);
// TODO Build temp page map. Now page fault.
// TODO Handle this temp page map.
memory_controller.map_page_identity(0); // EBDA
for addr in (0xE0000 .. 0x100000).step_by(0x1000) {
memory_controller.map_page_identity(addr);
}
memory_controller.map_page_identity(0x7fe1000); // RSDT
memory_controller.print_page_table();
let acpi = arch::driver::acpi::init().expect("Failed to init ACPI");
debug!("{:?}", acpi);
unimplemented!();
memory_controller.map_page_identity(acpi.lapic_addr as usize); // LAPIC
arch::driver::apic::init(acpi.lapic_addr);
io::init();
test_end!();

@ -40,8 +40,6 @@ pub fn init(boot_info: &BootInformation) -> MemoryController {
let mut active_table = paging::remap_the_kernel(&mut frame_allocator,
boot_info);
println!("{:?}", active_table);
use self::paging::Page;
use {HEAP_START, HEAP_SIZE};
@ -131,4 +129,13 @@ impl MemoryController {
stack_allocator.alloc_stack(active_table, frame_allocator,
size_in_pages)
}
pub fn map_page_identity(&mut self, addr: usize) {
use self::paging::{WRITABLE};
let frame = Frame::containing_address(addr);
let flags = WRITABLE;
self.active_table.identity_map(frame, flags, &mut self.frame_allocator);
}
pub fn print_page_table(&self) {
debug!("{:?}", self.active_table);
}
}

Loading…
Cancel
Save