/*
 * Copyright (c) 2011, 2014 Jonas 'Sortie' Termansen.
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 *
 * x64/memorymanagement.h
 * Handles memory for the x64 architecture.
 */

#ifndef SORTIX_X64_MEMORYMANAGEMENT_H
#define SORTIX_X64_MEMORYMANAGEMENT_H

namespace Sortix {
namespace Memory {

const size_t TOPPMLLEVEL = 4;
const size_t ENTRIES = 4096UL / sizeof(addr_t);
const size_t TRANSBITS = 9;

PML* const PMLS[TOPPMLLEVEL + 1] =
{
	(PML*) 0x0,
	(PML*) 0xFFFFFF8000000000UL,
	(PML*) 0xFFFFFF7FC0000000UL,
	(PML*) 0XFFFFFF7FBFE00000UL,
	(PML*) 0xFFFFFF7FBFDFF000UL,
};

PML* const FORKPML = (PML*) 0xFFFFFF0000000000UL;

} // namespace Memory
} // namespace Sortix

namespace Sortix {
namespace Page {

addr_t* const STACK = (addr_t*) 0xFFFFFE8000000000UL;
const size_t MAXSTACKSIZE = (512UL*1024UL*1024UL*1024UL);
const size_t MAXSTACKLENGTH = MAXSTACKSIZE / sizeof(addr_t);

} // namespace Page
} // namespace Sortix

#endif
