/* allocate a new page table if not present */
if(!(pd->pt_entries[pde] & PAGE_ATTR_PRESENT)) {
- pd->pt_entries[pde] = (u32_t)pg_frame_alloc_end();
+ /*
+ * Allocate a large page if we're at a large page boundary
+ * and we're supposed to allocate at least the size of a large page
+ */
+ if(size >= PAGE_SIZE_LARGE && ALIGNED(vaddr, PAGE_SIZE_LARGE)) {
+ pd->pt_entries[pde] = vaddr | PAGE_ATTR_SIZE | PAGE_ATTR_PRESENT | flags;
- if(!pd->pt_entries[pde]) {
- ret_val = -ENOMEM;
- break;
+ paddr += PAGE_SIZE_LARGE;
+ vaddr += PAGE_SIZE_LARGE;
+ size -= PAGE_SIZE_LARGE;
+
+ /* skip the rest of the loop, which would attempt to populate the page table */
+ continue;
} else {
- /* wipe the page table before using it */
- memset((void*)pd->pt_entries[pde], 0, PAGE_SIZE);
- }
+ pd->pt_entries[pde] = (u32_t)pg_frame_alloc_end();
+
+ if(!pd->pt_entries[pde]) {
+ ret_val = -ENOMEM;
+ break;
+ } else {
+ /* wipe the page table before using it */
+ memset((void*)pd->pt_entries[pde], 0, PAGE_SIZE);
+ }
- pd->pt_entries[pde] |= PAGE_ATTR_PRESENT | flags;
+ pd->pt_entries[pde] |= PAGE_ATTR_PRESENT | flags;
+ }
}
pt = (page_table_t*)(pd->pt_entries[pde] & 0xfffff000);