From 1f57e99720c4bc5e3e27a88ff469cef43c202a43 Mon Sep 17 00:00:00 2001 From: Aleksa Vučković Date: Wed, 29 Jun 2022 01:52:48 +0200 Subject: HigherHalf --- src/c/kernel.c | 2 +- src/c/paging.c | 24 ++++++++++++++++-------- src/c/shell/game.c | 8 ++++---- src/c/vga.c | 3 ++- 4 files changed, 23 insertions(+), 14 deletions(-) (limited to 'src/c') diff --git a/src/c/kernel.c b/src/c/kernel.c index a5dc31a..9692b32 100644 --- a/src/c/kernel.c +++ b/src/c/kernel.c @@ -14,7 +14,7 @@ void kernel_main(void) init_timer(50); init_keyboard(); kheapinit(); - kheapaddblock(0x00200000, 0x00100000, 16); + kheapaddblock(0xC0700000, 0x00100000, 16); terminal_initialize(); prompt(); 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(); } diff --git a/src/c/shell/game.c b/src/c/shell/game.c index ce7793b..9e7323e 100644 --- a/src/c/shell/game.c +++ b/src/c/shell/game.c @@ -56,8 +56,8 @@ void game_keyboard_handler(uint16_t keycode) void game_init(void) { - x=VGA_WIDTH/2; - y=VGA_HEIGHT/2; + x=(uint16_t)VGA_WIDTH/2; + y=(uint16_t)VGA_HEIGHT/2; game_time=0; game_tick=0; duzina=1; @@ -80,7 +80,7 @@ void game_timer_handler() { case 1: if(y>0) y--; - else y=VGA_HEIGHT-1; + else y=(uint16_t)VGA_HEIGHT-1; break; case 2: if(y0) x--; - else x=VGA_WIDTH-1; + else x=(uint16_t)VGA_WIDTH-1; break; case 4: if(x