Skip to content

Commit

Permalink
Clear the page tables on creation, use macros for counts.
Browse files Browse the repository at this point in the history
This makes it less likely that uninitialized entries cause troubles.
Also panic if we encounter an unknown entry type instead of defaulting
to 4K pages.
  • Loading branch information
mmlr committed Dec 4, 2012
1 parent 89564c0 commit a438da7
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/system/boot/arch/arm/arch_mmu.cpp
Expand Up @@ -253,27 +253,38 @@ get_next_page_table(uint32 type)
sNextPageTableAddress, kPageTableRegionEnd, type));

size_t size = 0;
size_t entryCount = 0;
switch (type) {
case ARM_MMU_L1_TYPE_COARSE:
default:
size = ARM_MMU_L2_COARSE_TABLE_SIZE;
entryCount = ARM_MMU_L2_COARSE_ENTRY_COUNT;
break;
case ARM_MMU_L1_TYPE_FINE:
size = ARM_MMU_L2_FINE_TABLE_SIZE;
entryCount = ARM_MMU_L2_FINE_ENTRY_COUNT;
break;
case ARM_MMU_L1_TYPE_SECTION:
// TODO: Figure out parameters for section types.
size = 16384;
break;
default:
panic("asked for unknown page table type: %#" B_PRIx32 "\n", type);
return NULL;
}

addr_t address = sNextPageTableAddress;
if (address >= kPageTableRegionEnd) {
TRACE(("outside of pagetableregion!\n"));
return (uint32 *)get_next_physical_address_alligned(size, 0xffffffc0);
if (address < kPageTableRegionEnd)
sNextPageTableAddress += size;
else {
TRACE(("page table allocation outside of pagetable region!\n"));
address = get_next_physical_address_alligned(size, 0xffffffc0);
}

sNextPageTableAddress += size;
return (uint32 *)address;
uint32 *pageTable = (uint32 *)address;
for (size_t i = 0; i < entryCount; i++)
pageTable[i] = 0;

return pageTable;
}


Expand Down

0 comments on commit a438da7

Please sign in to comment.