remove "unsecure" usage of get_page in page_init
This commit is contained in:
parent
a929feb257
commit
c2935e2f66
2 changed files with 14 additions and 16 deletions
|
@ -58,6 +58,8 @@ extern const void kernel_end;
|
|||
|
||||
// boot task's page directory and page directory lock
|
||||
static page_dir_t boot_pgd = {{[0 ... PGT_ENTRIES-1] = 0}};
|
||||
static page_table_t pgt_container = {{[0 ... PGT_ENTRIES-1] = 0}};
|
||||
static page_table_t boot_pgt[KERNEL_SPACE/(1024*PAGE_SIZE)];
|
||||
static spinlock_t kslock = SPINLOCK_INIT;
|
||||
static int paging_enabled = 0;
|
||||
|
||||
|
@ -570,7 +572,7 @@ int vm_free(size_t viraddr, uint32_t npages)
|
|||
index1 = viraddr >> 22;
|
||||
index2 = (viraddr >> 12) & 0x3FF;
|
||||
|
||||
pgt = (page_table_t*) ((KERNEL_SPACE - 1024*PAGE_SIZE + index1*PAGE_SIZE) & PAGE_MASK);
|
||||
pgt = (page_table_t*) ((KERNEL_SPACE - 1024*PAGE_SIZE + index1*PAGE_SIZE) & PAGE_MASK);
|
||||
if (!pgt)
|
||||
continue;
|
||||
pgt->entries[index2] = 0;
|
||||
|
@ -689,12 +691,7 @@ int arch_paging_init(void)
|
|||
irq_install_handler(14, pagefault_handler);
|
||||
|
||||
// Create a page table to reference to the other page tables
|
||||
pgt = (page_table_t*) get_page();
|
||||
if (!pgt) {
|
||||
kputs("arch_paging_init: Not enough memory!\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(pgt, 0, PAGE_SIZE);
|
||||
pgt = &pgt_container;
|
||||
|
||||
// map this table at the end of the kernel space
|
||||
viraddr = KERNEL_SPACE - PAGE_SIZE;
|
||||
|
@ -707,14 +704,9 @@ int arch_paging_init(void)
|
|||
|
||||
// create the other PGTs for the kernel space
|
||||
for(i=0; i<KERNEL_SPACE/(1024*PAGE_SIZE)-1; i++) {
|
||||
size_t phyaddr = get_page();
|
||||
size_t phyaddr = boot_pgt+i;
|
||||
|
||||
if (!phyaddr) {
|
||||
kputs("arch_paging_init: Not enough memory!\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memset((void*) phyaddr, 0, PAGE_SIZE);
|
||||
memset((void*) phyaddr, 0x00, sizeof(page_table_t));
|
||||
per_core(current_task)->pgd->entries[i] = (phyaddr & PAGE_MASK)|KERN_TABLE;
|
||||
pgt->entries[i] = (phyaddr & PAGE_MASK)|KERN_PAGE;
|
||||
}
|
||||
|
@ -778,7 +770,7 @@ int arch_paging_init(void)
|
|||
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 & PAGE_MASK, (size_t) mb_info->mods_addr & PAGE_MASK, npages, MAP_KERNEL_SPACE);
|
||||
map_region((size_t) mb_info->mods_addr, (size_t) mb_info->mods_addr, npages, MAP_KERNEL_SPACE);
|
||||
|
||||
for(i=0; i<mb_info->mods_count; i++, mmodule++) {
|
||||
// map physical address to the same virtual address
|
||||
|
@ -786,7 +778,7 @@ int arch_paging_init(void)
|
|||
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);
|
||||
map_region((size_t) mmodule->mod_start & PAGE_MASK, (size_t) mmodule->mod_start & PAGE_MASK, npages, MAP_KERNEL_SPACE);
|
||||
map_region((size_t) mmodule->mod_start, (size_t) mmodule->mod_start, npages, MAP_KERNEL_SPACE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
#include <metalsvm/errno.h>
|
||||
#include <metalsvm/init.h>
|
||||
#include <metalsvm/fs.h>
|
||||
#ifdef CONFIG_MULTIBOOT
|
||||
#include <asm/multiboot.h>
|
||||
#endif
|
||||
#ifdef CONFIG_LWIP
|
||||
#include <lwip/init.h>
|
||||
#include <lwip/sys.h>
|
||||
|
@ -66,6 +69,9 @@ int lowlevel_init(void)
|
|||
koutput_init();
|
||||
|
||||
//kprintf("Now, the BSS section (0x%x - 0x%x) is initialized.\n", (size_t) &bss_start, (size_t) &bss_end);
|
||||
#ifdef CONFIG_MULTIBOOT
|
||||
//kprintf("Start kernel with command line \"%s\"\n", mb_info->cmdline);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue