mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Working on page allocator #67
This commit is contained in:
parent
3676254417
commit
d056bc2fb6
@ -70,9 +70,11 @@
|
||||
│ │ ├── buf.h
|
||||
│ │ └── list.h
|
||||
│ ├── mm
|
||||
│ │ ├── gdt.h
|
||||
│ │ ├── heap.h
|
||||
│ │ ├── malloc.h
|
||||
│ │ └── mm.h
|
||||
│ │ ├── map.h
|
||||
│ │ └── paging.h
|
||||
│ ├── po
|
||||
│ │ └── shtdwn.h
|
||||
│ ├── sh
|
||||
@ -155,4 +157,4 @@
|
||||
├── ProjectTree
|
||||
└── README.md
|
||||
|
||||
28 directories, 102 files
|
||||
28 directories, 104 files
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#define KPAGESIZE (4 * KB)
|
||||
#define UPAGESIZE (4 * KB)
|
||||
#define USERSPACE 0x80000000
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
|
38
include/mm/palloc.h
Normal file
38
include/mm/palloc.h
Normal file
@ -0,0 +1,38 @@
|
||||
//----------------------------------------------------------------------------//
|
||||
// GNU GPL OS/K //
|
||||
// //
|
||||
// Desc: Page allocator related functions //
|
||||
// //
|
||||
// //
|
||||
// Copyright © 2018-2019 The OS/K Team //
|
||||
// //
|
||||
// This file is part of OS/K. //
|
||||
// //
|
||||
// OS/K is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation, either version 3 of the License, or //
|
||||
// any later version. //
|
||||
// //
|
||||
// OS/K is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY//without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#ifndef _KERNEL_H
|
||||
#include <kernel.h>
|
||||
#endif
|
||||
|
||||
#ifndef _MM_PALLOC_H
|
||||
#define _MM_PALLOC_H
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#endif
|
@ -20,20 +20,18 @@
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <kernel.h>
|
||||
#include <init/boot.h>
|
||||
#include <ke/idt.h>
|
||||
#include <ex/malloc.h>
|
||||
#include <mm/heap.h>
|
||||
#include <mm/paging.h>
|
||||
#include <mm/map.h>
|
||||
#include <ke/idt.h>
|
||||
#include <lib/buf.h>
|
||||
#include <io/vga.h>
|
||||
|
||||
#define USERSPACE 0x80000000
|
||||
|
||||
//-----------
|
||||
|
||||
pml4_t MmPageMapLevel4[512] __attribute__((__aligned__(KPAGESIZE)));
|
||||
@ -194,16 +192,16 @@ void MmInitPaging(void)
|
||||
//DebugLog("\tLast page of kernel at %p\n", curAddrPT);
|
||||
}
|
||||
}
|
||||
// While we're inside the userspace pages
|
||||
else if ((ulong)curAddrPT >= USERSPACE) {
|
||||
MmPT[index] = ((ulong)curAddrPT - diffKernUsr) | PRESENT; // Not present for instance
|
||||
xedni = (((ulong)curAddrPT - diffKernUsr) / ((ulong)KPAGESIZE));
|
||||
//MmPhysicalPageTable[xedni] = (ulong)curAddrPT;
|
||||
/* // While we're inside the userspace pages */
|
||||
/* else if ((ulong)curAddrPT >= USERSPACE) { */
|
||||
/* MmPT[index] = ((ulong)curAddrPT - diffKernUsr) | PRESENT; // Not present for instance */
|
||||
/* xedni = (((ulong)curAddrPT - diffKernUsr) / ((ulong)KPAGESIZE)); */
|
||||
/* //MmPhysicalPageTable[xedni] = (ulong)curAddrPT; */
|
||||
|
||||
if ((ulong)curAddrPT == USERSPACE) {
|
||||
DebugLog("\tUserspace at %p:%p\n", curAddrPT, curAddrPT - diffKernUsr);
|
||||
}
|
||||
}
|
||||
/* if ((ulong)curAddrPT == USERSPACE) { */
|
||||
/* DebugLog("\tUserspace at %p:%p\n", curAddrPT, curAddrPT - diffKernUsr); */
|
||||
/* } */
|
||||
/* } */
|
||||
else {
|
||||
MmPT[index] = 0;
|
||||
}
|
||||
|
38
kaleid/kernel/mm/palloc.c
Normal file
38
kaleid/kernel/mm/palloc.c
Normal file
@ -0,0 +1,38 @@
|
||||
//----------------------------------------------------------------------------//
|
||||
// GNU GPL OS/K //
|
||||
// //
|
||||
// Desc: Page allocator related functions //
|
||||
// //
|
||||
// //
|
||||
// Copyright © 2018-2019 The OS/K Team //
|
||||
// //
|
||||
// This file is part of OS/K. //
|
||||
// //
|
||||
// OS/K is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation, either version 3 of the License, or //
|
||||
// any later version. //
|
||||
// //
|
||||
// OS/K is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY//without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <kernel.h>
|
||||
#include <init/boot.h>
|
||||
#include <ex/malloc.h>
|
||||
#include <mm/paging.h>
|
||||
#include <mm/palloc.h>
|
||||
#include <io/vga.h>
|
||||
|
||||
//---------
|
||||
|
||||
|
||||
|
||||
|
||||
//---------
|
||||
|
@ -263,13 +263,13 @@ error_t CmdPageBlock(int argc, char **argv, char *cmdline)
|
||||
|
||||
error_t CmdPF(int argc, char **argv, char *cmdline)
|
||||
{
|
||||
ulong *address = (ulong*)(ulong)strtoul(argv[1], NULL, 16);
|
||||
register ulong *address = (ulong*)(ulong)strtoul(argv[1], NULL, 16);
|
||||
|
||||
KernLog("Provoking Page Fault at %#x\n", address);
|
||||
KernLog("Test provoking a fault at %p\n", address);
|
||||
|
||||
KernLog("It contained %#x\n", *address);
|
||||
KernLog("It contained %p\n", *address);
|
||||
*address = 1;
|
||||
KernLog("Now it contains %#x\n", *address);
|
||||
KernLog("Now it contains %p\n", *address);
|
||||
|
||||
KernLog("No page fault : address was valid/present\n");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user