2020-01-12 16:53:32 +01:00
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
// 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 <https://www.gnu.org/licenses/>. //
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
#ifndef _KERNEL_H
|
|
|
|
#include <kernel.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _MM_PAGING_H
|
|
|
|
#define _MM_PAGING_H
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
#define KPAGESIZE (4 * KB)
|
|
|
|
#define UPAGESIZE (4 * KB)
|
2020-01-18 12:50:36 +01:00
|
|
|
#define USERSPACE 0x200000000
|
2020-01-12 16:53:32 +01:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2020-01-15 16:12:13 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PRESENT = 1 << 0,
|
|
|
|
READWRITE = 1 << 1,
|
|
|
|
USERMODE = 1 << 2,
|
|
|
|
WRITETHR = 1 << 3,
|
|
|
|
CACHEDIS = 1 << 4,
|
|
|
|
ACCESSED = 1 << 5,
|
|
|
|
DIRTY = 1 << 6,
|
|
|
|
HUGE = 1 << 7,
|
|
|
|
NX = 1UL << 63
|
|
|
|
};
|
|
|
|
|
2020-01-12 16:53:32 +01:00
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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
|