1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00
sortix--sortix/sortix/memorymanagement.h
2011-08-08 15:20:02 +02:00

66 lines
1.9 KiB
C++

/******************************************************************************
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
This file is part of Sortix.
Sortix 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 (at your option) any later
version.
Sortix 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 Sortix. If not, see <http://www.gnu.org/licenses/>.
memorymanagement.h
Handles memory for the x86 architecture.
******************************************************************************/
#ifndef SORTIX_MEMORYMANAGEMENT_H
#define SORTIX_MEMORYMANAGEMENT_H
namespace Sortix
{
namespace Page
{
#ifdef MULTIBOOT_HEADER
void Init(multiboot_info_t* BootInfo);
#endif
addr_t Get();
void Put(addr_t Page);
inline addr_t AlignDown(addr_t page) { return page & ~(0xFFFUL); }
inline addr_t AlignUp(addr_t page) { return AlignDown(page + 0xFFFUL); }
}
namespace VirtualMemory
{
void Init();
void Flush();
addr_t CreateAddressSpace();
addr_t SwitchAddressSpace(addr_t addrspace);
void MapKernel(addr_t where, addr_t physical);
bool MapUser(addr_t where, addr_t physical);
addr_t UnmapKernel(addr_t where);
addr_t UnmapUser(addr_t where);
#ifdef PLATFORM_X86
const addr_t heapLower = 0x80000000UL;
const addr_t heapUpper = 0xFF800000UL;
// Physical pages may be safely temporarily mapped to this address and a
// good dozen of pages onwards. Beware that this is only meant to be temporary.
const addr_t tempaddr = 0xFF800000UL;
#endif
}
}
#endif