diff options
author | Marvin Borner | 2020-05-14 21:45:51 +0200 |
---|---|---|
committer | Marvin Borner | 2020-05-14 21:45:51 +0200 |
commit | 977aaa6e42d12d1237611673453ab9a9fbd46175 (patch) | |
tree | aa1a2fe6cf622fa2ec1e6963a70b0456daceb2b5 /src/kernel | |
parent | ddcc46555c8b85754fc7e0ed026e836d9197a859 (diff) |
Fixed kernel end variable
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/boot.asm | 6 | ||||
-rw-r--r-- | src/kernel/linker.ld | 5 | ||||
-rw-r--r-- | src/kernel/memory/paging.c | 14 |
3 files changed, 15 insertions, 10 deletions
diff --git a/src/kernel/boot.asm b/src/kernel/boot.asm index 11f8a45..444b73a 100644 --- a/src/kernel/boot.asm +++ b/src/kernel/boot.asm @@ -43,4 +43,8 @@ section .text push eax cli call kernel_main - jmp $
\ No newline at end of file + jmp $ + +section .end + global KERNEL_END + KERNEL_END:
\ No newline at end of file diff --git a/src/kernel/linker.ld b/src/kernel/linker.ld index 00ffb20..f134ccb 100644 --- a/src/kernel/linker.ld +++ b/src/kernel/linker.ld @@ -27,5 +27,8 @@ SECTIONS *(.bss) } - end = .; _end = .; __end = .; + .end BLOCK(4K) : ALIGN(4K) + { + *(.end) + } }
\ No newline at end of file diff --git a/src/kernel/memory/paging.c b/src/kernel/memory/paging.c index fb93dc4..05e37bd 100644 --- a/src/kernel/memory/paging.c +++ b/src/kernel/memory/paging.c @@ -6,9 +6,8 @@ int paging_enabled = 0; -u32 root_dir[1024][1024] __attribute__((aligned(4096))); struct page_directory *paging_directory; // Current -struct page_directory *paging_kernel_directory = (struct page_directory *)root_dir; +struct page_directory *paging_kernel_directory = 0x9d000; void paging_init(struct page_directory *dir, int user) { @@ -33,16 +32,16 @@ struct page_directory *paging_make_directory(int user) return dir; } -extern u32 end; +extern void KERNEL_END(); void paging_install(u32 multiboot_address) { - // Kernel paging paging_switch_directory(paging_kernel_directory); paging_init(paging_directory, 0); if (!memory_init(multiboot_address)) - paging_set_present(0, memory_get_all() >> 3); // /4 - paging_set_used(0, ((u32)end >> 12) + 1); // /4096 + paging_set_present(0, memory_get_all() >> 3); + + paging_set_used(0, ((u32)KERNEL_END >> 12) + 1); // /4096 log("Enabling"); paging_enable(); @@ -60,7 +59,6 @@ void paging_disable() void paging_enable() { - asm("mov %0, %%cr3" ::"r"(paging_directory)); u32 cr0; asm("mov %%cr0, %0" : "=r"(cr0)); cr0 |= 0x80000000; @@ -71,7 +69,7 @@ void paging_enable() void paging_switch_directory(struct page_directory *dir) { paging_directory = dir; - asm("mov %0, %%cr3" ::"r"(paging_directory)); + asm("mov %0, %%cr3" ::"r"(dir)); } void invlpg(u32 addr) |