Add a PAGE_GLOBAL flag for kernel pages

This commit is contained in:
Thomas Lovén 2018-01-04 00:45:01 +01:00
parent 470eb5e9f9
commit 9a479b1132
3 changed files with 7 additions and 6 deletions

View File

@ -9,20 +9,20 @@ BootP4:
.rept ENTRIES_PER_PT - 2 .rept ENTRIES_PER_PT - 2
.quad 0 .quad 0
.endr .endr
.quad offset V2P(BootP3) + (PAGE_PRESENT | PAGE_WRITE) .quad offset V2P(BootP3) + (PAGE_PRESENT | PAGE_WRITE | PAGE_GLOBAL)
BootP3: BootP3:
.quad offset V2P(BootP2) + (PAGE_PRESENT | PAGE_WRITE) .quad offset V2P(BootP2) + (PAGE_PRESENT | PAGE_WRITE | PAGE_GLOBAL)
.rept ENTRIES_PER_PT - 1 .rept ENTRIES_PER_PT - 1
.quad 0 .quad 0
.endr .endr
BootP2: BootP2:
.quad offset V2P(BootP1) + (PAGE_PRESENT | PAGE_WRITE) .quad offset V2P(BootP1) + (PAGE_PRESENT | PAGE_WRITE | PAGE_GLOBAL)
.rept ENTRIES_PER_PT - 1 .rept ENTRIES_PER_PT - 1
.quad 0 .quad 0
.endr .endr
BootP1: BootP1:
.set i, 0 .set i, 0
.rept ENTRIES_PER_PT .rept ENTRIES_PER_PT
.quad (i << 12) + (PAGE_PRESENT | PAGE_WRITE) .quad (i << 12) + (PAGE_PRESENT | PAGE_WRITE | PAGE_GLOBAL)
.set i, (i+1) .set i, (i+1)
.endr .endr

View File

@ -30,8 +30,8 @@ void kmain(uint64_t multiboot_magic, void *multiboot_data)
continue; continue;
if(vmm_get_page(&BootP4, (uintptr_t)P2V(p)) == (uintptr_t)-1) if(vmm_get_page(&BootP4, (uintptr_t)P2V(p)) == (uintptr_t)-1)
{ {
touch_page(&BootP4, (uintptr_t)P2V(p), PAGE_WRITE | PAGE_HUGE); touch_page(&BootP4, (uintptr_t)P2V(p), PAGE_GLOBAL | PAGE_WRITE | PAGE_HUGE);
vmm_set_page(&BootP4, (uintptr_t)P2V(p), p, PAGE_HUGE | PAGE_WRITE | PAGE_PRESENT); vmm_set_page(&BootP4, (uintptr_t)P2V(p), p, PAGE_GLOBAL | PAGE_HUGE | PAGE_WRITE | PAGE_PRESENT);
} }
if(type == 1) if(type == 1)
pmm_free(p); pmm_free(p);

View File

@ -19,6 +19,7 @@
#define PAGE_PRESENT 0x001 #define PAGE_PRESENT 0x001
#define PAGE_WRITE 0x002 #define PAGE_WRITE 0x002
#define PAGE_HUGE 0x080 #define PAGE_HUGE 0x080
#define PAGE_GLOBAL 0x100
#define PAGE_SIZE 0x1000 #define PAGE_SIZE 0x1000
#define ENTRIES_PER_PT 512 #define ENTRIES_PER_PT 512