Map all free memory pages and add to page stack
This commit is contained in:
parent
cf1b631461
commit
5dc4e27392
@ -6,6 +6,7 @@ KERNEL_START = 0x10000;
|
|||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = KERNEL_START + KERNEL_OFFSET;
|
. = KERNEL_START + KERNEL_OFFSET;
|
||||||
|
kernel_start = .;
|
||||||
.text : AT(ADDR(.text) - KERNEL_OFFSET)
|
.text : AT(ADDR(.text) - KERNEL_OFFSET)
|
||||||
{
|
{
|
||||||
*(.multiboot)
|
*(.multiboot)
|
||||||
@ -24,4 +25,5 @@ SECTIONS
|
|||||||
*(.COMMON)
|
*(.COMMON)
|
||||||
*(.bss)
|
*(.bss)
|
||||||
}
|
}
|
||||||
|
kernel_end = .;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,22 @@ void kmain(uint64_t multiboot_magic, void *multiboot_data)
|
|||||||
uintptr_t start, end;
|
uintptr_t start, end;
|
||||||
uint32_t type, i=0;
|
uint32_t type, i=0;
|
||||||
while(!multiboot_get_memory_area(i++, &start, &end, &type))
|
while(!multiboot_get_memory_area(i++, &start, &end, &type))
|
||||||
|
{
|
||||||
|
if(type != 1)
|
||||||
|
continue;
|
||||||
debug_printf("Mem %d 0x%x-0x%x\n", type, start, end);
|
debug_printf("Mem %d 0x%x-0x%x\n", type, start, end);
|
||||||
|
for(uintptr_t p = start; p < end; p += PAGE_SIZE)
|
||||||
|
{
|
||||||
|
if(p >= V2P(&kernel_start) && p < V2P(&kernel_end))
|
||||||
|
continue;
|
||||||
|
if(!(p & 0x1FFFFF))
|
||||||
|
{
|
||||||
|
touch_page(&BootP4, (uintptr_t)P2V(p), PAGE_HUGE);
|
||||||
|
vmm_set_page(&BootP4, (uintptr_t)P2V(p), p, PAGE_HUGE | PAGE_WRITE | PAGE_PRESENT);
|
||||||
|
}
|
||||||
|
pmm_free(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
debug_ok("Boot \"Complete\"\n");
|
debug_ok("Boot \"Complete\"\n");
|
||||||
|
|
||||||
|
@ -38,4 +38,7 @@ uintptr_t vmm_get_page(void *P4, uintptr_t addr);
|
|||||||
int vmm_set_page(void *P4, uintptr_t addr, uintptr_t page, uint16_t flags);
|
int vmm_set_page(void *P4, uintptr_t addr, uintptr_t page, uint16_t flags);
|
||||||
int touch_page(void *P4, uintptr_t addr, uint16_t flags);
|
int touch_page(void *P4, uintptr_t addr, uint16_t flags);
|
||||||
void free_page(void *P4, uintptr_t addr, int free);
|
void free_page(void *P4, uintptr_t addr, int free);
|
||||||
|
|
||||||
|
extern union PTE BootP4;
|
||||||
|
extern int kernel_start, kernel_end;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user