Skip to content

Commit 927ce50

Browse files
author
Yuma Arakawa
committed
mem: グローバルページ機能を有効化
1 parent c4d76ea commit 927ce50

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernel/memory.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <memory.h>
22

3+
#define CR4_BIT_PGE (1U << 7)
4+
35
void mem_init(void)
46
{
57
struct page_directory_entry {
@@ -24,6 +26,12 @@ void mem_init(void)
2426
} *pte;
2527
unsigned int paging_base_addr;
2628
unsigned int i;
29+
unsigned int cr4;
30+
31+
/* Enable PGE(Page Global Enable) flag of CR4*/
32+
__asm__("movl %%cr4, %0":"=r"(cr4):);
33+
cr4 |= CR4_BIT_PGE;
34+
__asm__("movl %0, %%cr4"::"r"(cr4));
2735

2836
/* Initialize kernel page directory */
2937
pde = (struct page_directory_entry *)0x0008f000;

0 commit comments

Comments
 (0)