diff --git a/kernel/arch/x86_64/include/paging.h b/kernel/arch/x86_64/include/paging.h index 601c03f..267279b 100644 --- a/kernel/arch/x86_64/include/paging.h +++ b/kernel/arch/x86_64/include/paging.h @@ -1,12 +1,11 @@ #pragma once #include #include -#include #include typedef phys_t virt_t; struct pagemap_tbl { bool active:1; - bool writable:1; + bool writeable:1; bool unprivileged:1; bool no_write_cache:1; bool no_read_cache:1; @@ -22,7 +21,7 @@ static_assert(sizeof(pagemap_tbl)==8); struct pagemap { bool active:1; - bool writable:1; + bool writeable:1; bool unprivileged:1; bool no_write_cache:1; bool no_read_cache:1; @@ -69,7 +68,6 @@ struct pagetbl { phys_t page:40; uint16_t ignored2:11; bool executable:1; -} }__attribute__((packed)); diff --git a/kernel/arch/x86_64/paging.cpp b/kernel/arch/x86_64/paging.cpp index a7acf48..d6df91d 100644 --- a/kernel/arch/x86_64/paging.cpp +++ b/kernel/arch/x86_64/paging.cpp @@ -6,11 +6,12 @@ extern int kernel_end; paging_context_x86::paging_context_x86(): paging_context() { + phys_t pagedir_addr; *pmm >> pagedir_addr; if(context_enabled) { current_context->mmap(pagedir_addr, (void*)0x800000, protection::RW, false); pagemap *src=(pagemap *)0x400000; - pagemap *dest=(pagedir*)0x600000; + pagemap *dest=(pagemap*)0x600000; for(int i=0;i<256;i++) dest[i]=src[i]; for(int i=256;i<512;i++) @@ -18,7 +19,7 @@ paging_context_x86::paging_context_x86(): paging_context() { dest[0].active=false; phys_t first_pagedir; *pmm >> first_pagedir; - dest[0].pagetable = first_pagedir >> 12; + dest[0].pagedir = first_pagedir >> 12; dest[0].writeable=true; dest[0].unprivileged=false; dest[0].no_write_cache=true; diff --git a/kernel/src/include/base.hpp b/kernel/src/include/base.hpp index b665804..a9dee48 100644 --- a/kernel/src/include/base.hpp +++ b/kernel/src/include/base.hpp @@ -12,7 +12,7 @@ void setMainTTY(TTY *obj); /** * Halts the kernel due to a unresolvable error */ -extern "C" void panic(const char* s); +extern "C" __attribute__((noreturn)) void panic(const char* s); #if !defined(__LITTLE_ENDIAN__) || !defined(__BIG_ENDIAN__) #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ diff --git a/kernel/src/include/pmm.hpp b/kernel/src/include/pmm.hpp index 3a33b46..4bf0730 100644 --- a/kernel/src/include/pmm.hpp +++ b/kernel/src/include/pmm.hpp @@ -7,8 +7,7 @@ typedef uintptr_t phys_t; ///< Type used for physical addresses /** * A single entry in the PMM list */ - -#if BITS == 32 +#ifndef __x86_64__ /** * Physical memory manager. It stores the free memory in a linked list */ @@ -32,7 +31,6 @@ class PMM { }; #else - struct pmm_entry { phys_t next; phys_t last; diff --git a/kernel/src/pmm.cpp b/kernel/src/pmm.cpp index dca798b..362af81 100644 --- a/kernel/src/pmm.cpp +++ b/kernel/src/pmm.cpp @@ -1,6 +1,6 @@ #include -#ifdef BITS == 64 +#ifdef __x86_64__ #include "pmm64.hpp" #else #include "pmm32.hpp" diff --git a/kernel/src/pmm64.hpp b/kernel/src/pmm64.hpp index 20d7d96..33539c9 100644 --- a/kernel/src/pmm64.hpp +++ b/kernel/src/pmm64.hpp @@ -93,6 +93,7 @@ auto PMM::operator,(size_t no_pages) -> phys_t { outlbl: continue; } + panic("Ran out of memory"); } auto PMM::operator()(phys_t pages, size_t no_pages) -> void {