- updated to-dos
- removed unnecessary debugging code - moved x86_64-kernel.json to the project root
This commit is contained in:
@@ -1,15 +1,7 @@
|
||||
use linked_list_allocator::LockedHeap;
|
||||
use x86_64::{
|
||||
VirtAddr,
|
||||
structures::paging::{
|
||||
FrameAllocator, Mapper, Page, PageTableFlags, Size4KiB,
|
||||
mapper::{MapToError, MapperFlushAll},
|
||||
},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
drivers::memory::{FRAME_ALLOCATOR, OFFSET_PAGE_TABLE},
|
||||
serial_print, serial_println,
|
||||
use x86_64::structures::paging::{
|
||||
mapper::MapToError,
|
||||
Size4KiB,
|
||||
};
|
||||
|
||||
/// We are currently using a linked list heap allocator which uses our underlying page allocator.
|
||||
@@ -24,46 +16,7 @@ pub const HEAP_SIZE: usize = 1024 * 1024 * 1024;
|
||||
|
||||
/// Sets up the heap using the backing page frame allocator.
|
||||
pub fn init_heap() -> Result<(), MapToError<Size4KiB>> {
|
||||
// let mut frame_allocator = if let Some(f) = FRAME_ALLOCATOR.get() {
|
||||
// f.lock()
|
||||
// } else {
|
||||
// return Err(MapToError::FrameAllocationFailed);
|
||||
// };
|
||||
|
||||
// let mut mapper = if let Some(m) = OFFSET_PAGE_TABLE.get() {
|
||||
// m.lock()
|
||||
// } else {
|
||||
// return Err(MapToError::FrameAllocationFailed);
|
||||
// };
|
||||
|
||||
// let range = {
|
||||
// let heap_start = VirtAddr::new(HEAP_START as u64);
|
||||
// let heap_end = heap_start + HEAP_SIZE as u64 - 1u64;
|
||||
// let heap_start_page = Page::<Size4KiB>::containing_address(heap_start);
|
||||
// let heap_end_page = Page::<Size4KiB>::containing_address(heap_end);
|
||||
// Page::range_inclusive(heap_start_page, heap_end_page)
|
||||
// };
|
||||
|
||||
// let usable_frames = frame_allocator.count_usable_frames();
|
||||
// serial_println!("usable frames: {}", usable_frames);
|
||||
|
||||
// let mut i = 0;
|
||||
// for page in range {
|
||||
// i += 1;
|
||||
// if i % 128 == 0 {
|
||||
// serial_println!("allocated {} pages", i);
|
||||
// }
|
||||
// let frame = frame_allocator
|
||||
// .allocate_frame()
|
||||
// .ok_or(MapToError::FrameAllocationFailed)?;
|
||||
// let flags = PageTableFlags::PRESENT | PageTableFlags::WRITABLE;
|
||||
// unsafe {
|
||||
// // IMPORTANT: make sure to flush the mapper!!!!
|
||||
// let _ = mapper.map_to(page, frame, flags, &mut *frame_allocator)?;
|
||||
// }
|
||||
// }
|
||||
|
||||
// MapperFlushAll::new().flush_all();
|
||||
// code to allocate frames is now done in the page fault interrupt handler!
|
||||
|
||||
unsafe {
|
||||
ALLOCATOR.lock().init(HEAP_START as *mut u8, HEAP_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user