1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00
os-k/include/mm/paging.h

94 lines
3.2 KiB
C
Raw Normal View History

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-12 17:21:12 +01:00
#define USERSPACE 0x80000000
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;
//----------------------------------------------------------------------------//
//
// 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