aboutsummaryrefslogtreecommitdiff
path: root/src/c/paging.c
diff options
context:
space:
mode:
authorAleksa Vučković <aleksav013@gmail.com>2022-06-29 01:52:48 +0200
committerAleksa Vučković <aleksav013@gmail.com>2022-06-29 16:44:25 +0200
commit1f57e99720c4bc5e3e27a88ff469cef43c202a43 (patch)
tree8161bd72d272009a520dd173eac3658a48a9f096 /src/c/paging.c
parent58240b0509d11b09ce2994b88308650e7cfb93bd (diff)
HigherHalf
Diffstat (limited to 'src/c/paging.c')
-rw-r--r--src/c/paging.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/c/paging.c b/src/c/paging.c
index 4aba4af..0a4c01f 100644
--- a/src/c/paging.c
+++ b/src/c/paging.c
@@ -3,6 +3,7 @@
extern void loadPageDirectory(uint32_t*);
extern void enablePaging(void);
+extern void flushPaging(void);
uint32_t page_directory[1024] __attribute__((aligned(4096)));
@@ -23,11 +24,6 @@ uint32_t page_table[1024][1024] __attribute__((aligned(4096)));
void set_pt(size_t num,uint32_t address)
{
- // holds the physical address where we want to start mapping these pages
- // to.
- // in this case, we want to map these pages to the very beginning of
- // memory.
-
//we will fill all 1024 entries in the table, mapping 4 megabytes
for(size_t i=0;i<1024;i++)
{
@@ -37,14 +33,26 @@ void set_pt(size_t num,uint32_t address)
// attributes: supervisor level, read/write, present.
}
- page_directory[num] = ((uint32_t)page_table[num]) | 3;
+ page_directory[num] = ((uint32_t)page_table[num] - 0xC0000000) | 3;
// attributes: supervisor level, read/write, present
}
+void empty_pt(size_t num)
+{
+ for(size_t i=0;i<1024;i++)
+ {
+ page_table[num][i] = 0;
+ }
+
+ page_directory[num] = 0x00000002;
+}
+
void set_paging(void)
{
set_pd();
- for(size_t i=0;i<1024;i++) set_pt(i,0x00400000 * i); // all 4GB mapped
+ set_pt(768,0x00000000); // maps 0x00000000 to 0xC0000000
+ set_pt(769,0x00400000); // maps 0x00400000 to 0xC0400000
+ set_pt(832,0x000B8000); // maps 0x000B8000 to 0xD0000000
loadPageDirectory(page_directory);
- enablePaging();
+ flushPaging();
}