fixed some bugs and made the paging code compile

This commit is contained in:
Morten Delenk 2017-12-09 19:57:18 +00:00
parent 79f6f3bcda
commit a33f99b712
6 changed files with 9 additions and 11 deletions

View file

@ -1,12 +1,11 @@
#pragma once
#include <stdint.h>
#include <pmm.hpp>
#include <regs.h>
#include <paging.hpp>
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));

View file

@ -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;

View file

@ -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__

View file

@ -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;

View file

@ -1,6 +1,6 @@
#include <base.hpp>
#ifdef BITS == 64
#ifdef __x86_64__
#include "pmm64.hpp"
#else
#include "pmm32.hpp"

View file

@ -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 {