cleaned up a few page allocation page issues, still crashing
git-svn-id: svn://anubis/hos/trunk@92 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
parent
4816102139
commit
ca82cc32ac
@ -20,10 +20,11 @@ static u64_t * mm_gdt;
|
||||
static u32_t mm_heap_base;
|
||||
|
||||
/* physical addresses of page allocation pages to map in before the heap */
|
||||
static u32_t page_alloc_pages[1025]; /* supports 4GB physical memory */
|
||||
static u32_t page_alloc_page_numbers[1025]; /* supports 4GB physical memory */
|
||||
static u32_t num_page_alloc_pages = 0;
|
||||
static mm_page_alloc_page_t * current_page_alloc_page = NULL;
|
||||
static u32_t page_alloc_page_index = 0;
|
||||
static mm_page_alloc_page_t * page_alloc_pages;
|
||||
|
||||
/**************************************************************************
|
||||
* Internal Functions *
|
||||
@ -69,6 +70,9 @@ void mm_bootstrap()
|
||||
k_early_panic("No mmap entries read from bootloader!");
|
||||
}
|
||||
|
||||
mm_heap_base = (u32_t) KERNEL_END;
|
||||
page_alloc_pages = (mm_page_alloc_page_t *) mm_heap_base;
|
||||
|
||||
for (int mmap_idx = 0; mmap_idx < mm_mmap_num_entries; mmap_idx++)
|
||||
{
|
||||
u32_t base_address = mm_mmap_entries[mmap_idx].base;
|
||||
@ -91,8 +95,6 @@ void mm_bootstrap()
|
||||
max_ram_address = (address_limit - 1);
|
||||
}
|
||||
|
||||
mm_heap_base = (u32_t) KERNEL_END;
|
||||
|
||||
/*
|
||||
* loop through every page in the mmap range and add
|
||||
* pages into the free page linked list
|
||||
@ -110,10 +112,11 @@ void mm_bootstrap()
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_page_alloc_pages; i++)
|
||||
for (unsigned int i = 0; i < num_page_alloc_pages; i++)
|
||||
{
|
||||
mm_early_map(mm_heap_base, page_alloc_pages[i], 0, 1);
|
||||
mm_early_map(mm_heap_base, page_alloc_page_numbers[i], 0, 1);
|
||||
current_page_alloc_page = (mm_page_alloc_page_t *) mm_heap_base;
|
||||
/* move the heap back to after the page allocation pages */
|
||||
mm_heap_base += PAGE_SIZE;
|
||||
}
|
||||
|
||||
@ -189,12 +192,11 @@ static void record_phys_page(u32_t base_address)
|
||||
page_alloc_page_index =
|
||||
sizeof(current_page_alloc_page->pages)
|
||||
/ sizeof(current_page_alloc_page->pages[0]) - 1;
|
||||
page_alloc_pages[num_page_alloc_pages++] = base_address;
|
||||
page_alloc_page_numbers[num_page_alloc_pages++] = base_address;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_page_alloc_page->pages[page_alloc_page_index] = base_address;
|
||||
page_alloc_page_index--;
|
||||
current_page_alloc_page->pages[page_alloc_page_index--] = base_address;
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,7 +284,8 @@ u32_t mm_page_alloc()
|
||||
u32_t page_address = 0;
|
||||
if (current_page_alloc_page != NULL)
|
||||
{
|
||||
if (page_alloc_page_index == PAGE_SIZE / sizeof(u32_t) - 1)
|
||||
if (page_alloc_page_index == sizeof(current_page_alloc_page->pages)
|
||||
/ sizeof(current_page_alloc_page->pages[0]) - 1)
|
||||
{
|
||||
page_address = ((u32_t) current_page_alloc_page) - KERNEL_OFFSET;
|
||||
current_page_alloc_page = current_page_alloc_page->next;
|
||||
|
Loading…
x
Reference in New Issue
Block a user