Hello user process
This commit is contained in:
@ -5,6 +5,8 @@
|
||||
#include "bootinfo/bootinfo.h"
|
||||
#include "pmm/pmm.h"
|
||||
#include "paging.h"
|
||||
#include "proc/proc.h"
|
||||
#include "kprintf.h"
|
||||
|
||||
PgTable *KERNEL_CR3 = NULL;
|
||||
|
||||
@ -73,7 +75,7 @@ void hal_vmm_map_range(PgTable *cr3, void *virtstart, void *physstart, size_t si
|
||||
}
|
||||
}
|
||||
|
||||
void hal_vmm_unmap_range(PgTable *cr3, void *virtstart, void *physstart, size_t size, uint32_t flags) {
|
||||
void hal_vmm_unmap_range(PgTable *cr3, void *virtstart, void *physstart, size_t size) {
|
||||
if (size % HAL_PAGE_SIZE != 0 || (uint64_t)virtstart % HAL_PAGE_SIZE != 0 || (uint64_t)physstart % HAL_PG_PRESENT != 0) {
|
||||
return;
|
||||
}
|
||||
@ -96,6 +98,21 @@ void hal_vmm_switch_pd(PgTable *cr3) {
|
||||
hal_loadpd(cr3);
|
||||
}
|
||||
|
||||
PgTable *hal_vmm_userproc_pml4(Proc *proc) {
|
||||
uint8_t *cr3 = pmm_alloc(1);
|
||||
PgTable *pml4 = (PgTable *)VIRT(cr3);
|
||||
hal_memset(pml4, 0, HAL_PAGE_SIZE);
|
||||
|
||||
PgTable *kcr3 = VIRT(KERNEL_CR3);
|
||||
|
||||
for (size_t i = 256; i < 512; i++) {
|
||||
pml4->ents[i] = kcr3->ents[i];
|
||||
}
|
||||
|
||||
return (PgTable *)cr3;
|
||||
}
|
||||
|
||||
void hal_vmm_init(void) {
|
||||
KERNEL_CR3 = hal_vmm_current_cr3();
|
||||
kprintf("KERNEL_CR3 = %p\n", KERNEL_CR3);
|
||||
}
|
||||
|
Reference in New Issue
Block a user