mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Fix frame stack filling
This commit is contained in:
@@ -37,4 +37,8 @@ SECTIONS {
|
||||
*(.data.rel.ro.local*) *(.data.rel.ro .data.rel.ro.*)
|
||||
}
|
||||
|
||||
.gcc_except_table BLOCK(4k) : {
|
||||
*(.gcc_except_table .gcc_except_table.*)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,8 +79,6 @@ fn init_core_map(multiboot: &Multiboot, lock: &mut paging::Lock, mut bump_pointe
|
||||
lock.mapper(&mut bump_pointer).map(CORE_MAP_PAGE, true, false);
|
||||
let mut frame_stack = DynamicFrameStack::new(CORE_MAP_PAGE);
|
||||
|
||||
println!("{:?}", bump_pointer);
|
||||
|
||||
for area in multiboot.memory_area_tag().expect("no memory tag").areas() {
|
||||
println!("area start {:x} length {:x}", area.base_addr, area.length);
|
||||
let start_frame = Frame::containing_address(area.base_addr as usize);
|
||||
@@ -89,22 +87,11 @@ fn init_core_map(multiboot: &Multiboot, lock: &mut paging::Lock, mut bump_pointe
|
||||
.map(|n| Frame{number:n})
|
||||
{
|
||||
let page = Page{number: frame.number};
|
||||
|
||||
if page.is_unused() && !bump_pointer.has_allocated(frame) {
|
||||
//print!("_{:x} ", frame.number);
|
||||
frame_stack.deallocate_frame(lock, frame)
|
||||
} else {
|
||||
if !page.is_unused() {
|
||||
print!("b{} ", frame.number);
|
||||
} else {
|
||||
print!("+{} ", frame.number);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
loop {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -139,7 +126,7 @@ impl BumpPointer {
|
||||
}
|
||||
|
||||
fn has_allocated(&self, frame: Frame) -> bool {
|
||||
frame.number > self.first_free_frame && frame.number < self.next_free_frame
|
||||
frame.number >= self.first_free_frame && frame.number < self.next_free_frame
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ pub fn map_to<A>(lock: &mut Lock, page: Page, frame: Frame, writable: bool,
|
||||
unsafe{page.p1_page().zero()};
|
||||
}
|
||||
let p1_field = page.p1_page().field(page.p1_index());
|
||||
//TODOassert!(p1_field.is_unused());
|
||||
assert!(p1_field.is_unused());
|
||||
p1_field.set(frame, flags);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,6 @@ impl Page {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO fix
|
||||
pub fn is_unused(&self) -> bool {
|
||||
self.p4_page().field(self.p4_index()).is_unused() ||
|
||||
self.p3_page().field(self.p3_index()).is_unused() ||
|
||||
@@ -129,8 +128,9 @@ struct Table(Page);
|
||||
|
||||
impl Table {
|
||||
unsafe fn zero(&mut self) {
|
||||
let page = self.0.pointer() as *mut () as *mut [u64; (PAGE_SIZE/64) as usize];
|
||||
*page = [0; (PAGE_SIZE/64) as usize];
|
||||
const ENTRIES: usize = PAGE_SIZE / 8;
|
||||
let page = self.0.pointer() as *mut () as *mut [u64; ENTRIES];
|
||||
*page = [0; ENTRIES];
|
||||
}
|
||||
|
||||
fn field(&self, index: usize) -> &'static mut TableField {
|
||||
|
||||
Reference in New Issue
Block a user