Added key systems to kernel state

This commit is contained in:
2020-08-02 15:03:35 -05:00
parent 0b32783a2c
commit 50816a3b6d
5 changed files with 44 additions and 14 deletions

View File

@@ -1,7 +1,8 @@
ENTRY(_start)
SECTIONS
{
. = 0xFF900000;
VIRTUAL_BASE = .;
PHYSICAL_BASE = 0x100000;
@@ -33,4 +34,10 @@ SECTIONS
LOAD_END = ADDR(.data) + SIZEOF(.data) - (VIRTUAL_BASE - PHYSICAL_BASE);
BSS_END = ADDR(.bss) + SIZEOF(.bss) - (VIRTUAL_BASE - PHYSICAL_BASE);
IMAGE_SIZE = ((BSS_END - LOAD_START) + (4096 - ((BSS_END - LOAD_START) % 4096))) / 4096;
_pageMapLocation = 0xFF800000;
_heapLocation = 0xFFB00000;
_heapSize = 0x100000;
_kernelStart = VIRTUAL_BASE;
_kernelEnd = VIRTUAL_BASE + (4096 * IMAGE_SIZE);
}

View File

@@ -1,4 +1,5 @@
#include "../mmap.hpp"
#include "../kernelstate.hpp"
class PageTableEntry {
public:
@@ -149,7 +150,7 @@ private:
uint32_t physicalAddress : 20;
};
int kernel::mmap(PageAllocator& allocator, void* start, size_t length, int flags)
int kernel::mmap(void* start, size_t length, int flags)
{
if((size_t) start % 4096 != 0)
return -1;
@@ -161,7 +162,7 @@ int kernel::mmap(PageAllocator& allocator, void* start, size_t length, int flags
size_t directoryIndex = tableIndex / 1024;
if(!pageDirectory[directoryIndex].getPresent())
{
physaddr_t newPT = allocator.allocate(4096);
physaddr_t newPT = State::pageAllocator.allocate(4096);
if(newPT == 0)
return -1;
pageDirectory[directoryIndex] = newPT;
@@ -171,7 +172,7 @@ int kernel::mmap(PageAllocator& allocator, void* start, size_t length, int flags
}
if(!pageTables[tableIndex].getPresent())
{
physaddr_t page = allocator.allocate(4096);
physaddr_t page = State::pageAllocator.allocate(4096);
pageTables[tableIndex] = page;
pageTables[tableIndex].setPresent(true);
pageTables[tableIndex].setUsermode(false);
@@ -184,7 +185,7 @@ int kernel::mmap(PageAllocator& allocator, void* start, size_t length, int flags
return 0;
}
int kernel::munmap(PageAllocator& allocator, void* start, size_t length)
int kernel::munmap(void* start, size_t length)
{
if((size_t) start % 4096 != 0)
return -1;