From 4a652d70842dcfb7cfe2666bbafb5c26299dcb82 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Fri, 10 Jan 2020 22:41:25 +0100 Subject: [PATCH 1/8] Working on Paging API --- include/mm/mm.h | 3 +++ kaleid/kernel/ke/cpuid.c | 2 +- kaleid/kernel/mm/paging.c | 49 ++++++++++++++++--------------------- kaleid/kernel/sh/testcmds.c | 27 ++++++++++++++------ 4 files changed, 44 insertions(+), 37 deletions(-) diff --git a/include/mm/mm.h b/include/mm/mm.h index 50657f1..cb6a005 100644 --- a/include/mm/mm.h +++ b/include/mm/mm.h @@ -188,6 +188,9 @@ void MmUnSetPage(void* virtualAddr, ulong flags); void MmMapPage(void* virtualAddr, void* physicalAddr, ulong flags); void MmUnmapPage(void* virtualAddr); +// Allocations +void *MmGetPhyPageBlock(size_t size, bool usermode); + // Page table entry typedef ulong pte_t; diff --git a/kaleid/kernel/ke/cpuid.c b/kaleid/kernel/ke/cpuid.c index 4c5017b..2682ba2 100644 --- a/kaleid/kernel/ke/cpuid.c +++ b/kaleid/kernel/ke/cpuid.c @@ -44,7 +44,7 @@ void KeGetCpuInfos(void) CpuInfo.frequency = KeGetCpuFrequency(); } - DebugLog("\tCPU %s %#d KHz detected with features %#x\n", + DebugLog("\tCPU %s %#d MHz detected with features %#x\n", CpuInfo.vendorStr, (long)(CpuInfo.frequency / 1000.0), CpuInfo.featureFlag diff --git a/kaleid/kernel/mm/paging.c b/kaleid/kernel/mm/paging.c index 5a7e77e..339e565 100644 --- a/kaleid/kernel/mm/paging.c +++ b/kaleid/kernel/mm/paging.c @@ -23,6 +23,7 @@ extern ulong _data_end; ulong MmStackGuards[2] = { 0 }; ulong MmVirtLastAddress = 0; +ulong MmPhysLastAddress = 0; enum { @@ -57,8 +58,8 @@ void MmInitPaging(void) ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize; // Difference between the end of kernel and the begin of userspace - ulong lastKernelAddr = (ulong)(_heap_start + _heap_max); - ulong diffKernUsr = (ulong)USERSPACE - lastKernelAddr - KPAGESIZE; + MmPhysLastAddress = (ulong)(_heap_start + _heap_max); + ulong diffKernUsr = (ulong)USERSPACE - MmPhysLastAddress - KPAGESIZE; // Maximum VIRTUAL address in memory MmVirtLastAddress = phRamSize + diffKernUsr; @@ -132,13 +133,13 @@ void MmInitPaging(void) MmPT[index] = (ulong)curAddrPT | PRESENT; MmPhysicalPageTable[xedni] = (ulong)curAddrPT; MmStackGuards[0] = (ulong)curAddrPT; - DebugLog("\tStack Guard at %p\n", curAddrPT); + //DebugLog("\tStack Guard at %p\n", curAddrPT); } else if ((ulong)curAddrPT == (ulong)BtLoaderInfo.kernelEndAddr) { MmPT[index] = (ulong)curAddrPT | PRESENT; MmPhysicalPageTable[xedni] = (ulong)curAddrPT; MmStackGuards[1] = (ulong)curAddrPT; - DebugLog("\tStack Guard at %p\n", curAddrPT); + //DebugLog("\tStack Guard at %p\n", curAddrPT); } // SECTION .TEXT PROTECTION else if ((ulong)curAddrPT >= (ulong)&_text && (ulong)curAddrPT <= (ulong)&_text_end) { @@ -159,22 +160,22 @@ void MmInitPaging(void) //DebugLog("\tSection .rodata at %p\n", curAddrPT); } // While we're inside the kernel pages - else if ((ulong)curAddrPT <= lastKernelAddr) { + else if ((ulong)curAddrPT <= MmPhysLastAddress) { MmPT[index] = (ulong)curAddrPT | PRESENT | READWRITE; MmPhysicalPageTable[xedni] = (ulong)curAddrPT; - if ((ulong)curAddrPT == lastKernelAddr) { + if ((ulong)curAddrPT == MmPhysLastAddress) { //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 + MmPT[index] = ((ulong)curAddrPT - diffKernUsr); // Not present for instance, unallocated xedni = (((ulong)curAddrPT - diffKernUsr) / ((ulong)KPAGESIZE)); MmPhysicalPageTable[xedni] = (ulong)curAddrPT; if ((ulong)curAddrPT == USERSPACE) { - DebugLog("\tUserspace at %p:%p\n", curAddrPT, curAddrPT - diffKernUsr); + //DebugLog("\tUserspace at %p:%p\n", curAddrPT, curAddrPT - diffKernUsr); } } else { @@ -227,7 +228,7 @@ void *MmTransVirtToPhyAddr(void* virtualAddr) ulong virtAddrPage = (ulong)virtualAddr & ( ~(KPAGESIZE - 1)); pte_t *page = MmGetPageDescriptorFromVirtual(virtualAddr); - if (*page == (*page & ~(KPAGESIZE - 1))) { + if (*page & PRESENT) { return NULL; } @@ -283,31 +284,23 @@ void MmMapPage(void* virtualAddr, void* physicalAddr, ulong flags) // void MmUnmapPage(void* virtualAddr) { - pte_t *page = MmGetPageDescriptorFromVirtual(virtualAddr); - - *page = 0; - - KeFlushTlbSingle(*page); + MmUnsetPage(virtualAddr, PRESENT); // Removing the present flag } // -// Kernel Page allocator +// Find physical unallocated pages // -void *MmKAllocPageBlock(void *start) { - pte_t *startPage = MmGetPageDescriptorFromVirtual(start); +void *MmGetPhyPageBlock(size_t size, bool usermode) { + void *startPage = 0; - //for (ulong curPage = 0; curPage < ) + if (!usermode) { + startPage = MmTransPhyToVirtAddr(0); + } else { + startPage = MmTransVirtToPhyAddr((void*)USERSPACE); + } - return NULL; -} - -// -// User page allocator -// -void *MmUAllocPageBlock(void *start) { - pte_t *startPage = MmGetPageDescriptorFromVirtual(start); - - //for (ulong curPage = 0; curPage < ) + DebugLog("Userspace at %p\n", (void*)USERSPACE); + DebugLog("Userspace physical at %p\n", MmTransVirtToPhyAddr((void*)USERSPACE)); return NULL; } diff --git a/kaleid/kernel/sh/testcmds.c b/kaleid/kernel/sh/testcmds.c index f528b71..8af2fdb 100644 --- a/kaleid/kernel/sh/testcmds.c +++ b/kaleid/kernel/sh/testcmds.c @@ -204,6 +204,20 @@ error_t CmdPageTranslateVirtToPhy(int argc, char **argv, char *cmdline) return EOK; } +error_t CmdPageTranslatePhyToVirt(int argc, char **argv, char *cmdline) +{ + void *address = (void*)strtoul(argv[1], NULL, 16); + + /* if (!(void*)atoul(argv[1])) { */ + /* address = (ulong *)0x80000000; */ + /* } */ + + void *translation = MmTransPhyToVirtAddr(address); + + KernLog("Translation of %p is %p\n", address, translation); + return EOK; +} + enum { PRESENT = 1 << 0, @@ -236,17 +250,13 @@ error_t CmdPageUnmap(int argc, char **argv, char *cmdline) return EOK; } -error_t CmdPageTranslatePhyToVirt(int argc, char **argv, char *cmdline) +error_t CmdPageBlock(int argc, char **argv, char *cmdline) { - void *address = (void*)strtoul(argv[1], NULL, 16); + size_t size = (size_t)atoi(argv[1]); + bool usermode = (bool)atoi(argv[2]); - /* if (!(void*)atoul(argv[1])) { */ - /* address = (ulong *)0x80000000; */ - /* } */ + MmGetPhyPageBlock(size, usermode); - void *translation = MmTransPhyToVirtAddr(address); - - KernLog("Translation of %p is %p\n", address, translation); return EOK; } @@ -316,6 +326,7 @@ static Command_t testcmdtable[] = " virtual address (paging)"}, { "pmap", CmdPageMap, "Map a page to given physical addr" }, { "punmap", CmdPageUnmap, "Unmap a page" }, + { "pblck", CmdPageBlock, "Find a free block of pages" }, { "pf", CmdPF, "Provoke a PF. Usage: pfault
"}, { "shell", CmdShell, "Start a new shell (nested)", }, { "stkov", CmdStackOverflow, "Provoke a stack overflow" }, From ee7315089196755acf610668b804ba77a84035d1 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Fri, 10 Jan 2020 23:56:07 +0100 Subject: [PATCH 2/8] Working on Paging API --- kaleid/kernel/mm/paging.c | 53 ++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/kaleid/kernel/mm/paging.c b/kaleid/kernel/mm/paging.c index 339e565..a049d04 100644 --- a/kaleid/kernel/mm/paging.c +++ b/kaleid/kernel/mm/paging.c @@ -14,6 +14,8 @@ pml4_t MmPageMapLevel4[512] __attribute__((__aligned__(KPAGESIZE))); ulong *MmPhysicalPageTable; +extern MemoryMap_t memoryMap; + extern ulong _text; extern ulong _text_end; extern ulong _rodata; @@ -23,7 +25,7 @@ extern ulong _data_end; ulong MmStackGuards[2] = { 0 }; ulong MmVirtLastAddress = 0; -ulong MmPhysLastAddress = 0; +ulong MmPhysLastKernelAddress = 0; enum { @@ -45,7 +47,6 @@ enum // void MmInitPaging(void) { - extern MemoryMap_t memoryMap; pdpe_t *MmPDP = NULL; pde_t *MmPD = NULL; pte_t *MmPT = NULL; @@ -58,8 +59,8 @@ void MmInitPaging(void) ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize; // Difference between the end of kernel and the begin of userspace - MmPhysLastAddress = (ulong)(_heap_start + _heap_max); - ulong diffKernUsr = (ulong)USERSPACE - MmPhysLastAddress - KPAGESIZE; + MmPhysLastKernelAddress = (ulong)(_heap_start + _heap_max); + ulong diffKernUsr = (ulong)USERSPACE - MmPhysLastKernelAddress - KPAGESIZE; // Maximum VIRTUAL address in memory MmVirtLastAddress = phRamSize + diffKernUsr; @@ -160,11 +161,11 @@ void MmInitPaging(void) //DebugLog("\tSection .rodata at %p\n", curAddrPT); } // While we're inside the kernel pages - else if ((ulong)curAddrPT <= MmPhysLastAddress) { + else if ((ulong)curAddrPT <= MmPhysLastKernelAddress) { MmPT[index] = (ulong)curAddrPT | PRESENT | READWRITE; MmPhysicalPageTable[xedni] = (ulong)curAddrPT; - if ((ulong)curAddrPT == MmPhysLastAddress) { + if ((ulong)curAddrPT == MmPhysLastKernelAddress) { //DebugLog("\tLast page of kernel at %p\n", curAddrPT); } } @@ -284,23 +285,51 @@ void MmMapPage(void* virtualAddr, void* physicalAddr, ulong flags) // void MmUnmapPage(void* virtualAddr) { - MmUnsetPage(virtualAddr, PRESENT); // Removing the present flag + pte_t *page = MmGetPageDescriptorFromVirtual(virtualAddr); + + *page &= (~PRESENT); + + KeFlushTlbSingle(*page); } // // Find physical unallocated pages // void *MmGetPhyPageBlock(size_t size, bool usermode) { - void *startPage = 0; + void *startPhyPage = 0; + void *endPhyPage = 0; + size_t curSize = 0; + + // Maximum PHYSICAL address in memory + ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize; + + ulong curVirtAddr = 0; if (!usermode) { - startPage = MmTransPhyToVirtAddr(0); + startPhyPage = MmTransVirtToPhyAddr((void*)KPAGESIZE + 1); + endPhyPage = (void*)MmPhysLastKernelAddress; } else { - startPage = MmTransVirtToPhyAddr((void*)USERSPACE); + startPhyPage = MmTransVirtToPhyAddr((void*)USERSPACE); + endPhyPage = (void*)(phRamSize & ~(KPAGESIZE - 1)); } - DebugLog("Userspace at %p\n", (void*)USERSPACE); - DebugLog("Userspace physical at %p\n", MmTransVirtToPhyAddr((void*)USERSPACE)); + DebugLog("Start phy at %p\n", startPhyPage); + DebugLog("End phy at %p\n", endPhyPage); + + for (ulong curPhyAddr = (ulong)startPhyPage; + curPhyAddr <= (ulong)endPhyPage; + curPhyAddr += KPAGESIZE) { + curVirtAddr = (ulong)MmTransPhyToVirtAddr((void*)curPhyAddr); + + if (curVirtAddr == 0) { + DebugLog("CurrentAddr %p\n", curVirtAddr); + DebugLog("\t Free !\n"); + curSize += KPAGESIZE; + } + + if (curSize >= size) + break; + } return NULL; } From 40cd623b9722915b77d5f2024e36debcb4880d68 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 11 Jan 2020 00:05:34 +0100 Subject: [PATCH 3/8] Working on Paging API #67 --- kaleid/kernel/mm/paging.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/kaleid/kernel/mm/paging.c b/kaleid/kernel/mm/paging.c index a049d04..116e220 100644 --- a/kaleid/kernel/mm/paging.c +++ b/kaleid/kernel/mm/paging.c @@ -14,8 +14,6 @@ pml4_t MmPageMapLevel4[512] __attribute__((__aligned__(KPAGESIZE))); ulong *MmPhysicalPageTable; -extern MemoryMap_t memoryMap; - extern ulong _text; extern ulong _text_end; extern ulong _rodata; @@ -23,9 +21,11 @@ extern ulong _rodata_end; extern ulong _data; extern ulong _data_end; +extern MemoryMap_t memoryMap; + ulong MmStackGuards[2] = { 0 }; ulong MmVirtLastAddress = 0; -ulong MmPhysLastKernelAddress = 0; +ulong MmPhysLastKernAddress = 0; enum { @@ -59,8 +59,8 @@ void MmInitPaging(void) ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize; // Difference between the end of kernel and the begin of userspace - MmPhysLastKernelAddress = (ulong)(_heap_start + _heap_max); - ulong diffKernUsr = (ulong)USERSPACE - MmPhysLastKernelAddress - KPAGESIZE; + MmPhysLastKernAddress = (ulong)(_heap_start + _heap_max); + ulong diffKernUsr = (ulong)USERSPACE - MmPhysLastKernAddress - KPAGESIZE; // Maximum VIRTUAL address in memory MmVirtLastAddress = phRamSize + diffKernUsr; @@ -161,22 +161,22 @@ void MmInitPaging(void) //DebugLog("\tSection .rodata at %p\n", curAddrPT); } // While we're inside the kernel pages - else if ((ulong)curAddrPT <= MmPhysLastKernelAddress) { + else if ((ulong)curAddrPT <= MmPhysLastKernAddress) { MmPT[index] = (ulong)curAddrPT | PRESENT | READWRITE; MmPhysicalPageTable[xedni] = (ulong)curAddrPT; - if ((ulong)curAddrPT == MmPhysLastKernelAddress) { + if ((ulong)curAddrPT == MmPhysLastKernAddress) { //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); // Not present for instance, unallocated + 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); + DebugLog("\tUserspace at %p:%p\n", curAddrPT, curAddrPT - diffKernUsr); } } else { @@ -229,7 +229,7 @@ void *MmTransVirtToPhyAddr(void* virtualAddr) ulong virtAddrPage = (ulong)virtualAddr & ( ~(KPAGESIZE - 1)); pte_t *page = MmGetPageDescriptorFromVirtual(virtualAddr); - if (*page & PRESENT) { + if (*page == (*page & ~(KPAGESIZE - 1))) { return NULL; } @@ -241,7 +241,7 @@ void *MmTransPhyToVirtAddr(void* physicalAddr) ulong phyAddrPage = (ulong)physicalAddr & ( ~(KPAGESIZE - 1)); return (void*)( MmPhysicalPageTable[(ulong)physicalAddr / ((ulong)KPAGESIZE) - + ((ulong)physicalAddr - phyAddrPage) ] ); + ] + ((ulong)physicalAddr - phyAddrPage)); } // @@ -287,13 +287,13 @@ void MmUnmapPage(void* virtualAddr) { pte_t *page = MmGetPageDescriptorFromVirtual(virtualAddr); - *page &= (~PRESENT); + *page = 0; KeFlushTlbSingle(*page); } // -// Find physical unallocated pages +// Find a free block of pages // void *MmGetPhyPageBlock(size_t size, bool usermode) { void *startPhyPage = 0; @@ -307,7 +307,7 @@ void *MmGetPhyPageBlock(size_t size, bool usermode) { if (!usermode) { startPhyPage = MmTransVirtToPhyAddr((void*)KPAGESIZE + 1); - endPhyPage = (void*)MmPhysLastKernelAddress; + endPhyPage = (void*)MmPhysLastKernAddress; } else { startPhyPage = MmTransVirtToPhyAddr((void*)USERSPACE); endPhyPage = (void*)(phRamSize & ~(KPAGESIZE - 1)); From 3bce4c62084c2f887deb00a6e9aec86bd3804656 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 11 Jan 2020 00:17:42 +0100 Subject: [PATCH 4/8] Working on Paging API #67 --- kaleid/kernel/mm/paging.c | 66 +++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/kaleid/kernel/mm/paging.c b/kaleid/kernel/mm/paging.c index 116e220..fa55202 100644 --- a/kaleid/kernel/mm/paging.c +++ b/kaleid/kernel/mm/paging.c @@ -173,7 +173,7 @@ void MmInitPaging(void) 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; + //MmPhysicalPageTable[xedni] = (ulong)curAddrPT; if ((ulong)curAddrPT == USERSPACE) { DebugLog("\tUserspace at %p:%p\n", curAddrPT, curAddrPT - diffKernUsr); @@ -295,44 +295,48 @@ void MmUnmapPage(void* virtualAddr) // // Find a free block of pages // -void *MmGetPhyPageBlock(size_t size, bool usermode) { - void *startPhyPage = 0; - void *endPhyPage = 0; - size_t curSize = 0; +/* void *MmGetPhyPageBlock(size_t size, bool usermode) { */ +/* void *startPhyPage = 0; */ +/* void *endPhyPage = 0; */ +/* ulong offset = 0; */ +/* size_t curSize = 0; */ - // Maximum PHYSICAL address in memory - ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize; +/* // Maximum PHYSICAL address in memory */ +/* ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize; */ - ulong curVirtAddr = 0; +/* ulong curVirtAddr = 0; */ - if (!usermode) { - startPhyPage = MmTransVirtToPhyAddr((void*)KPAGESIZE + 1); - endPhyPage = (void*)MmPhysLastKernAddress; - } else { - startPhyPage = MmTransVirtToPhyAddr((void*)USERSPACE); - endPhyPage = (void*)(phRamSize & ~(KPAGESIZE - 1)); - } +/* if (!usermode) { */ +/* startPhyPage = MmTransVirtToPhyAddr((void*)KPAGESIZE); */ +/* endPhyPage = (void*)MmPhysLastKernAddress; */ +/* offset = 0; */ +/* } else { */ +/* startPhyPage = MmTransVirtToPhyAddr((void*)USERSPACE); */ +/* endPhyPage = (void*)(phRamSize & ~(KPAGESIZE - 1)); */ +/* offset = (ulong)USERSPACE - MmPhysLastKernAddress - KPAGESIZE; */ +/* } */ - DebugLog("Start phy at %p\n", startPhyPage); - DebugLog("End phy at %p\n", endPhyPage); +/* DebugLog("Start phy at %p\n", startPhyPage); */ +/* DebugLog("End phy at %p\n", endPhyPage); */ - for (ulong curPhyAddr = (ulong)startPhyPage; - curPhyAddr <= (ulong)endPhyPage; - curPhyAddr += KPAGESIZE) { - curVirtAddr = (ulong)MmTransPhyToVirtAddr((void*)curPhyAddr); +/* for (ulong curPhyAddr = (ulong)startPhyPage; */ +/* curPhyAddr <= (ulong)endPhyPage; */ +/* curPhyAddr += KPAGESIZE) { */ +/* curVirtAddr = (ulong)MmTransPhyToVirtAddr((void*)curPhyAddr); */ - if (curVirtAddr == 0) { - DebugLog("CurrentAddr %p\n", curVirtAddr); - DebugLog("\t Free !\n"); - curSize += KPAGESIZE; - } - if (curSize >= size) - break; - } +/* if (curVirtAddr == 0) { */ +/* DebugLog("CurrentAddr %p\n", curPhyAddr); */ +/* DebugLog("\t Free !\n"); */ +/* curSize += KPAGESIZE; */ +/* } */ - return NULL; -} +/* if (curSize >= size) */ +/* break; */ +/* } */ + +/* return NULL; */ +/* } */ //----------- From 7c0fd93ad5265a5715e27e0412523a2eba9cf7f1 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sun, 12 Jan 2020 16:53:23 +0100 Subject: [PATCH 5/8] Header rationalization for mm/ dir --- include/mm/mm.h | 213 ------------------------------------ kaleid/kernel/init/init.c | 4 +- kaleid/kernel/mm/gdt.c | 5 +- kaleid/kernel/mm/heap.c | 2 +- kaleid/kernel/mm/map.c | 2 +- kaleid/kernel/mm/paging.c | 73 +++++------- kaleid/kernel/sh/shcmds.c | 3 +- kaleid/kernel/sh/testcmds.c | 5 +- 8 files changed, 39 insertions(+), 268 deletions(-) delete mode 100644 include/mm/mm.h diff --git a/include/mm/mm.h b/include/mm/mm.h deleted file mode 100644 index cb6a005..0000000 --- a/include/mm/mm.h +++ /dev/null @@ -1,213 +0,0 @@ -//----------------------------------------------------------------------------// -// GNU GPL OS/K // -// // -// Desc: Memory manager 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 . // -//----------------------------------------------------------------------------// - -#ifndef _KERNEL_H -#include -#endif - -#ifndef _MM_MM_H -#define _MM_MM_H - -//----------------------------------------------------------------------------// - -#define MINIMUM_RAM_SIZE 16 // Mio, the minimum RAM size. -#define IOMAP_SIZE (8 * 1024) - -#define AVAILABLE_ZONE 1 // Fully usable RAM zone -#define RESERVED_ZONE 2 // Used by the firmware -#define ACPI_ZONE 3 // Used by ACPI but can be freed -#define NVS_ZONE 4 // Dunno -#define BADRAM_ZONE 5 // Invalid zone because material problem... -#define MAX_ENTRIES 2048 // Max number of memory map entries -#define KPAGESIZE (4 * KB) -#define UPAGESIZE (4 * KB) - -//----------------------------------------------------------------------------// - -// The entry structure of the map -struct MapEntry_t { - void *addr; - size_t length; // in bytes - uint type; // reserved or not -} __attribute__((__packed__)); - -// the map structure -struct MemoryMap_t { - size_t length; - size_t freeRamSize; - size_t nonfreeRamSize; - MapEntry_t entry[MAX_ENTRIES]; -} __attribute__((__packed__)); - -// The gdt entry -struct GdtEntry_t -{ - ushort lowLimit; // lower 16 bits - ushort lowBase; // lower 16 bits - uchar middleBase; // next 8 bits - uchar access; // determine what ring this segment can be used in - uchar flags; - uchar highBase; // last 8 bits -} __attribute__((__packed__)); - -struct TssDescriptor_t -{ - ushort lowLimit; - ushort lowBase; - uchar middleBase; - uchar access; - uchar flags; - uchar highBase; - uint veryHighBase; - uint reserved; -} __attribute__ ((packed)); - -struct Tss_t -{ - uint reserved1; - - // Stack pointers (RSP) for privilege levels 0-2 - ulong rsp0; - ulong rsp1; - ulong rsp2; - ulong reserved2; - - // Interrupt stack table pointers - ulong ist1; - ulong ist2; - ulong ist3; - ulong ist4; - ulong ist5; - ulong ist6; - ulong ist7; - ulong reserved3; - ushort reserved4; - - // Offset to the I/O permission bit map from the 64-bit TSS base - ushort iomap_base; - uchar iomap[IOMAP_SIZE]; - -} __attribute__ ((packed)) __attribute__((aligned(8))); - - - -// The gdt pointer -struct GdtPtr_t -{ - ushort limit; // upper 16 bits - ulong base; // address of the first entry -} __attribute__((__packed__)); - -//----------------------------------------------------------------------------// - -// -// Initializes the memory map structure -// -void MmInitMemoryMap(void); - -// -// Initializes the memory map structure -// -void MmPrintMemoryMap(void); - -// -// Returns the size of the first available memory zone -// from the start address pointer -// -size_t MmGetAvailZoneSize(void *start); - -// -// Returns the first available memory zone from the start address pointer -// -void *MmGetFirstAvailZone(void *start); - -// -// Initializes the descriptor table -// -void MmInitGdt(void); - -// -// Loads the descriptor table -// -extern void MmLoadGdt(GdtPtr_t *gdtPtr, ushort tssOffset); - - -// -// Stores the descriptor table -// -extern void MmStoreGdt(void); - -// -// Paging misc -// -void MmInitPaging(void); - -void MmActivatePageHandler(void); - -// -// Returns the address of the stack guard pages -// -void *MmGetStackGuards(char rank); - -// -// Translate a virtual address into physical address and the opposite -// -void *MmTransVirtToPhyAddr(void*); -void *MmTransPhyToVirtAddr(void* virtualAddr); - -// -// Set flags to a page -// -void MmSetPage(void* virtualAddr, ulong flags); -void MmUnSetPage(void* virtualAddr, ulong flags); - -// -// Map a page -// -void MmMapPage(void* virtualAddr, void* physicalAddr, ulong flags); -void MmUnmapPage(void* virtualAddr); - -// Allocations -void *MmGetPhyPageBlock(size_t size, bool usermode); - -// Page table entry -typedef ulong pte_t; - -// Page directory offset -typedef pte_t* pde_t; - -// Page directory pointer offset -typedef pde_t* pdpe_t; - -// Page directory L4 pointer offset -typedef pdpe_t* pml4_t; - -// paging.asm -void MmLoadPML4(void *); -void MmEnableWriteProtect(void); -void MmDisableWriteProtect(void); - -//----------------------------------------------------------------------------// - -#endif diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 12d3792..3a3144c 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -22,7 +22,9 @@ // along with OS/K. If not, see . // //----------------------------------------------------------------------------// -#include +#include +#include +#include #include #include #include diff --git a/kaleid/kernel/mm/gdt.c b/kaleid/kernel/mm/gdt.c index 8bd426a..6a5c188 100644 --- a/kaleid/kernel/mm/gdt.c +++ b/kaleid/kernel/mm/gdt.c @@ -1,7 +1,7 @@ //----------------------------------------------------------------------------// // GNU GPL OS/K // // // -// Desc: Mapping and checking memory related functions // +// Desc: GDT related functions // // // // // // Copyright © 2018-2019 The OS/K Team // @@ -22,7 +22,8 @@ // along with OS/K. If not, see . // //----------------------------------------------------------------------------// -#include +#include +#include #include GdtPtr_t gdtPtr; diff --git a/kaleid/kernel/mm/heap.c b/kaleid/kernel/mm/heap.c index a968231..b4c0c58 100644 --- a/kaleid/kernel/mm/heap.c +++ b/kaleid/kernel/mm/heap.c @@ -22,7 +22,7 @@ // along with OS/K. If not, see . // //----------------------------------------------------------------------------// -#include +#include #include #include #include diff --git a/kaleid/kernel/mm/map.c b/kaleid/kernel/mm/map.c index f7e164c..64156fe 100644 --- a/kaleid/kernel/mm/map.c +++ b/kaleid/kernel/mm/map.c @@ -22,7 +22,7 @@ // along with OS/K. If not, see . // //----------------------------------------------------------------------------// -#include +#include #include #include #include diff --git a/kaleid/kernel/mm/paging.c b/kaleid/kernel/mm/paging.c index fa55202..86aee49 100644 --- a/kaleid/kernel/mm/paging.c +++ b/kaleid/kernel/mm/paging.c @@ -1,8 +1,33 @@ +//----------------------------------------------------------------------------// +// GNU GPL OS/K // +// // +// Desc: Paging memory 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 . // +//---------------------------------------------------------------------------- + #include #include #include #include -#include +#include +#include #include #include #include @@ -292,52 +317,6 @@ void MmUnmapPage(void* virtualAddr) KeFlushTlbSingle(*page); } -// -// Find a free block of pages -// -/* void *MmGetPhyPageBlock(size_t size, bool usermode) { */ -/* void *startPhyPage = 0; */ -/* void *endPhyPage = 0; */ -/* ulong offset = 0; */ -/* size_t curSize = 0; */ - -/* // Maximum PHYSICAL address in memory */ -/* ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize; */ - -/* ulong curVirtAddr = 0; */ - -/* if (!usermode) { */ -/* startPhyPage = MmTransVirtToPhyAddr((void*)KPAGESIZE); */ -/* endPhyPage = (void*)MmPhysLastKernAddress; */ -/* offset = 0; */ -/* } else { */ -/* startPhyPage = MmTransVirtToPhyAddr((void*)USERSPACE); */ -/* endPhyPage = (void*)(phRamSize & ~(KPAGESIZE - 1)); */ -/* offset = (ulong)USERSPACE - MmPhysLastKernAddress - KPAGESIZE; */ -/* } */ - -/* DebugLog("Start phy at %p\n", startPhyPage); */ -/* DebugLog("End phy at %p\n", endPhyPage); */ - -/* for (ulong curPhyAddr = (ulong)startPhyPage; */ -/* curPhyAddr <= (ulong)endPhyPage; */ -/* curPhyAddr += KPAGESIZE) { */ -/* curVirtAddr = (ulong)MmTransPhyToVirtAddr((void*)curPhyAddr); */ - - -/* if (curVirtAddr == 0) { */ -/* DebugLog("CurrentAddr %p\n", curPhyAddr); */ -/* DebugLog("\t Free !\n"); */ -/* curSize += KPAGESIZE; */ -/* } */ - -/* if (curSize >= size) */ -/* break; */ -/* } */ - -/* return NULL; */ -/* } */ - //----------- // diff --git a/kaleid/kernel/sh/shcmds.c b/kaleid/kernel/sh/shcmds.c index 0507e59..d74d7fd 100644 --- a/kaleid/kernel/sh/shcmds.c +++ b/kaleid/kernel/sh/shcmds.c @@ -23,7 +23,8 @@ //----------------------------------------------------------------------------// #include -#include +#include +#include #include #include #include diff --git a/kaleid/kernel/sh/testcmds.c b/kaleid/kernel/sh/testcmds.c index 8af2fdb..e83667f 100644 --- a/kaleid/kernel/sh/testcmds.c +++ b/kaleid/kernel/sh/testcmds.c @@ -23,7 +23,8 @@ //----------------------------------------------------------------------------// #include -#include +#include +#include #include #include #include @@ -255,7 +256,7 @@ error_t CmdPageBlock(int argc, char **argv, char *cmdline) size_t size = (size_t)atoi(argv[1]); bool usermode = (bool)atoi(argv[2]); - MmGetPhyPageBlock(size, usermode); + //MmGetPhyPageBlock(size, usermode); return EOK; } From 3676254417137f8fa19241d530b1dbb98f65afa2 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sun, 12 Jan 2020 16:53:32 +0100 Subject: [PATCH 6/8] Header rationalization for mm/ dir --- include/mm/gdt.h | 115 ++++++++++++++++++++++++++++++++++++++++++++ include/mm/map.h | 85 ++++++++++++++++++++++++++++++++ include/mm/paging.h | 92 +++++++++++++++++++++++++++++++++++ 3 files changed, 292 insertions(+) create mode 100644 include/mm/gdt.h create mode 100644 include/mm/map.h create mode 100644 include/mm/paging.h diff --git a/include/mm/gdt.h b/include/mm/gdt.h new file mode 100644 index 0000000..289f911 --- /dev/null +++ b/include/mm/gdt.h @@ -0,0 +1,115 @@ +//----------------------------------------------------------------------------// +// GNU GPL OS/K // +// // +// Desc: GDT 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 . // +//----------------------------------------------------------------------------// + +#ifndef _KERNEL_H +#include +#endif + +#ifndef _MM_GDT_H +#define _MM_GDT_H + +//----------------------------------------------------------------------------// + +#define IOMAP_SIZE (8 * 1024) + +//----------------------------------------------------------------------------// + +// The gdt entry +struct GdtEntry_t +{ + ushort lowLimit; // lower 16 bits + ushort lowBase; // lower 16 bits + uchar middleBase; // next 8 bits + uchar access; // determine what ring this segment can be used in + uchar flags; + uchar highBase; // last 8 bits +} __attribute__((__packed__)); + +struct TssDescriptor_t +{ + ushort lowLimit; + ushort lowBase; + uchar middleBase; + uchar access; + uchar flags; + uchar highBase; + uint veryHighBase; + uint reserved; +} __attribute__ ((packed)); + +struct Tss_t +{ + uint reserved1; + + // Stack pointers (RSP) for privilege levels 0-2 + ulong rsp0; + ulong rsp1; + ulong rsp2; + ulong reserved2; + + // Interrupt stack table pointers + ulong ist1; + ulong ist2; + ulong ist3; + ulong ist4; + ulong ist5; + ulong ist6; + ulong ist7; + ulong reserved3; + ushort reserved4; + + // Offset to the I/O permission bit map from the 64-bit TSS base + ushort iomap_base; + uchar iomap[IOMAP_SIZE]; + +} __attribute__ ((packed)) __attribute__((aligned(8))); + +// The gdt pointer +struct GdtPtr_t +{ + ushort limit; // upper 16 bits + ulong base; // address of the first entry +} __attribute__((__packed__)); + +//----------------------------------------------------------------------------// + +// +// Initializes the descriptor table +// +void MmInitGdt(void); + +// +// Loads the descriptor table +// +extern void MmLoadGdt(GdtPtr_t *gdtPtr, ushort tssOffset); + + +// +// Stores the descriptor table +// +extern void MmStoreGdt(void); + +//----------------------------------------------------------------------------// + +#endif diff --git a/include/mm/map.h b/include/mm/map.h new file mode 100644 index 0000000..d7c9ea7 --- /dev/null +++ b/include/mm/map.h @@ -0,0 +1,85 @@ +//----------------------------------------------------------------------------// +// GNU GPL OS/K // +// // +// Desc: Mapping and checking memory 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 . // +//----------------------------------------------------------------------------// + +#ifndef _KERNEL_H +#include +#endif + +#ifndef _MM_MAP_H +#define _MM_MAP_H + +//----------------------------------------------------------------------------// + +#define MINIMUM_RAM_SIZE 16 // Mio, the minimum RAM size. + +#define AVAILABLE_ZONE 1 // Fully usable RAM zone +#define RESERVED_ZONE 2 // Used by the firmware +#define ACPI_ZONE 3 // Used by ACPI but can be freed +#define NVS_ZONE 4 // Dunno +#define BADRAM_ZONE 5 // Invalid zone because material problem... +#define MAX_ENTRIES 2048 // Max number of memory map entries + +//----------------------------------------------------------------------------// + +// The entry structure of the map +struct MapEntry_t { + void *addr; + size_t length; // in bytes + uint type; // reserved or not +} __attribute__((__packed__)); + +// the map structure +struct MemoryMap_t { + size_t length; + size_t freeRamSize; + size_t nonfreeRamSize; + MapEntry_t entry[MAX_ENTRIES]; +} __attribute__((__packed__)); + +//----------------------------------------------------------------------------// + +// +// Initializes the memory map structure +// +void MmInitMemoryMap(void); + +// +// Initializes the memory map structure +// +void MmPrintMemoryMap(void); + +// +// Returns the size of the first available memory zone +// from the start address pointer +// +size_t MmGetAvailZoneSize(void *start); + +// +// Returns the first available memory zone from the start address pointer +// +void *MmGetFirstAvailZone(void *start); + +//----------------------------------------------------------------------------// + +#endif diff --git a/include/mm/paging.h b/include/mm/paging.h new file mode 100644 index 0000000..c25ed08 --- /dev/null +++ b/include/mm/paging.h @@ -0,0 +1,92 @@ +//----------------------------------------------------------------------------// +// GNU GPL OS/K // +// // +// Desc: Paging memory 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 . // +//----------------------------------------------------------------------------// + +#ifndef _KERNEL_H +#include +#endif + +#ifndef _MM_PAGING_H +#define _MM_PAGING_H + +//----------------------------------------------------------------------------// + +#define KPAGESIZE (4 * KB) +#define UPAGESIZE (4 * KB) + +//----------------------------------------------------------------------------// + +// Page table entry +typedef ulong pte_t; + +// Page directory offset +typedef pte_t* pde_t; + +// Page directory pointer offset +typedef pde_t* pdpe_t; + +// Page directory L4 pointer offset +typedef pdpe_t* pml4_t; + +//----------------------------------------------------------------------------// + +// +// Paging activation +// +void MmInitPaging(void); + +void MmActivatePageHandler(void); + +// +// Returns the address of the stack guard pages +// +void *MmGetStackGuards(char rank); + +// +// Translate a virtual address into physical address and the opposite +// +void *MmTransVirtToPhyAddr(void*); +void *MmTransPhyToVirtAddr(void* virtualAddr); + +// +// Set flags to a page +// +void MmSetPage(void* virtualAddr, ulong flags); +void MmUnSetPage(void* virtualAddr, ulong flags); + +// +// Map a page +// +void MmMapPage(void* virtualAddr, void* physicalAddr, ulong flags); +void MmUnmapPage(void* virtualAddr); + +// +// Paging misc +// +void MmLoadPML4(void *); +void MmEnableWriteProtect(void); +void MmDisableWriteProtect(void); + +//----------------------------------------------------------------------------// + +#endif From d056bc2fb64831b74e63858a446197e008081860 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sun, 12 Jan 2020 17:21:12 +0100 Subject: [PATCH 7/8] Working on page allocator #67 --- ProjectTree | 6 ++++-- include/mm/paging.h | 1 + include/mm/palloc.h | 38 +++++++++++++++++++++++++++++++++++++ kaleid/kernel/mm/paging.c | 24 +++++++++++------------ kaleid/kernel/mm/palloc.c | 38 +++++++++++++++++++++++++++++++++++++ kaleid/kernel/sh/testcmds.c | 8 ++++---- 6 files changed, 96 insertions(+), 19 deletions(-) create mode 100644 include/mm/palloc.h create mode 100644 kaleid/kernel/mm/palloc.c diff --git a/ProjectTree b/ProjectTree index 05361f9..1c063cc 100644 --- a/ProjectTree +++ b/ProjectTree @@ -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 diff --git a/include/mm/paging.h b/include/mm/paging.h index c25ed08..d76f0ec 100644 --- a/include/mm/paging.h +++ b/include/mm/paging.h @@ -33,6 +33,7 @@ #define KPAGESIZE (4 * KB) #define UPAGESIZE (4 * KB) +#define USERSPACE 0x80000000 //----------------------------------------------------------------------------// diff --git a/include/mm/palloc.h b/include/mm/palloc.h new file mode 100644 index 0000000..bada93f --- /dev/null +++ b/include/mm/palloc.h @@ -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 . // +//----------------------------------------------------------------------------// + +#ifndef _KERNEL_H +#include +#endif + +#ifndef _MM_PALLOC_H +#define _MM_PALLOC_H + +//----------------------------------------------------------------------------// + + + +//----------------------------------------------------------------------------// + +#endif diff --git a/kaleid/kernel/mm/paging.c b/kaleid/kernel/mm/paging.c index 86aee49..6c3487f 100644 --- a/kaleid/kernel/mm/paging.c +++ b/kaleid/kernel/mm/paging.c @@ -20,20 +20,18 @@ // // // You should have received a copy of the GNU General Public License // // along with OS/K. If not, see . // -//---------------------------------------------------------------------------- +//----------------------------------------------------------------------------// #include #include +#include #include #include #include #include -#include #include #include -#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; } diff --git a/kaleid/kernel/mm/palloc.c b/kaleid/kernel/mm/palloc.c new file mode 100644 index 0000000..22a0fdf --- /dev/null +++ b/kaleid/kernel/mm/palloc.c @@ -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 . // +//----------------------------------------------------------------------------// + +#include +#include +#include +#include +#include +#include + +//--------- + + + + +//--------- + diff --git a/kaleid/kernel/sh/testcmds.c b/kaleid/kernel/sh/testcmds.c index e83667f..271de10 100644 --- a/kaleid/kernel/sh/testcmds.c +++ b/kaleid/kernel/sh/testcmds.c @@ -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"); From 477db646c8dfc5c6561d4e40311d1b4b92bb989a Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sun, 12 Jan 2020 17:29:47 +0100 Subject: [PATCH 8/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 93be98b..6563203 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ make install installdisk=XXX ``` #### Screenshot -![OS/K Started](https://www.os-k.eu/images/screen3.png) +![OS/K Started](https://www.os-k.eu/images/screen6.png)