using PAGE_ALIGN macro to calc pages
This commit is contained in:
parent
fa07bdee53
commit
9db28ec380
1 changed files with 7 additions and 9 deletions
|
@ -39,6 +39,7 @@
|
|||
* 0x000000000000 - 0x0000000FFFFF: reserved for IO devices (16MB)
|
||||
* 0x000000100000 - 0x00000DEADFFF: Kernel (size depends on the configuration) (221MB)
|
||||
* 0x00000DEAE000 - 0x00003FFFFFFF: Kernel heap
|
||||
* 0xFF4000000000 - 0xFF7FFFFFFFFF: Paging structures for copying a page map (max 512GB)
|
||||
* 0xFF8000000000 - 0xFFFFFFFFFFFF: Paging structures are mapped in this region (max 512GB)
|
||||
*/
|
||||
|
||||
|
@ -298,6 +299,8 @@ size_t map_region(size_t viraddr, size_t phyaddr, uint32_t npages, uint32_t flag
|
|||
}
|
||||
}
|
||||
|
||||
kprintf("map_region: map %u pages from 0x%lx to 0x%lx with flags: 0x%x\n", npages, viraddr, phyaddr, flags); // TODO: remove
|
||||
|
||||
// correct alignment
|
||||
phyaddr &= PAGE_MASK;
|
||||
viraddr &= PAGE_MASK;
|
||||
|
@ -308,7 +311,6 @@ size_t map_region(size_t viraddr, size_t phyaddr, uint32_t npages, uint32_t flag
|
|||
else
|
||||
spinlock_irqsave_lock(&task->page_lock);
|
||||
|
||||
kprintf("map_region: map %u pages from 0x%lx to 0x%lx with flags: 0x%x\n", npages, viraddr, phyaddr, flags);
|
||||
for(i=0; i<npages; i++, viraddr+=PAGE_SIZE, phyaddr+=PAGE_SIZE) {
|
||||
// page table entry
|
||||
size_t* pte = (size_t *) (PAGE_PGT|(viraddr >> 9));
|
||||
|
@ -727,18 +729,14 @@ int arch_paging_init(void)
|
|||
*/
|
||||
if (mb_info && (mb_info->flags & MULTIBOOT_INFO_MODS)) {
|
||||
multiboot_module_t* mmodule = (multiboot_module_t*) ((size_t) mb_info->mods_addr);
|
||||
npages = PAGE_ALIGN(mb_info->mods_count*sizeof(multiboot_module_t)) >> PAGE_SHIFT;
|
||||
|
||||
npages = mb_info->mods_count * sizeof(multiboot_module_t) >> PAGE_SHIFT;
|
||||
if (mb_info->mods_count * sizeof(multiboot_module_t) & (PAGE_SIZE-1))
|
||||
npages++;
|
||||
map_region((size_t) (mb_info->mods_addr), (size_t) (mb_info->mods_addr), npages, MAP_REMAP|MAP_KERNEL_SPACE);
|
||||
map_region((size_t) mmodule, (size_t) mmodule, npages, MAP_REMAP|MAP_KERNEL_SPACE);
|
||||
|
||||
for(i=0; i<mb_info->mods_count; i++, mmodule++) {
|
||||
// map physical address to the same virtual address
|
||||
npages = (mmodule->mod_end - mmodule->mod_start) >> PAGE_SHIFT;
|
||||
if (mmodule->mod_end & (PAGE_SIZE-1))
|
||||
npages++;
|
||||
kprintf("Map module %s at 0x%x (%u pages)\n", (char*) mmodule->cmdline, mmodule->mod_start, npages);
|
||||
npages = PAGE_ALIGN(mmodule->mod_end - mmodule->mod_start) >> PAGE_SHIFT;
|
||||
kprintf("Map module %s at 0x%x (%u pages)\n", (char*)(size_t) mmodule->cmdline, mmodule->mod_start, npages);
|
||||
map_region((size_t) (mmodule->mod_start), (size_t) (mmodule->mod_start), npages, MAP_REMAP|MAP_KERNEL_SPACE);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue