mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
107 lines
3.5 KiB
C
107 lines
3.5 KiB
C
//----------------------------------------------------------------------------//
|
|
// GNU GPL OS/K //
|
|
// //
|
|
// Desc: Paging memory related functions //
|
|
// //
|
|
// //
|
|
// Copyright © 2018-2020 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)
|
|
#define USERSPACE 0x200000000
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
// 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;
|
|
|
|
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
|
|
};
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
//
|
|
// 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
|