1/* 2 * Copyright 2014, General Dynamics C4 Systems 3 * 4 * SPDX-License-Identifier: GPL-2.0-only 5 */ 6#pragma once 7 8/* Each architecture defines a set of constants in #defines. These 9 * constants describe the memory regions of the kernel's portion of the 10 * address space including the physical memory window, the kernel ELF 11 * region, and the device region. 12 * 13 * - USER_TOP: The first address after the end of user memory 14 * 15 * - PADDR_BASE: The first physical address mapped in the kernel's 16 * physical memory window. 17 * - PPTR_BASE: The first virtual address of the kernel's physical 18 * memory window. 19 * - PPTR_TOP: The first virtual address after the end of the kernel's 20 * physical memory window. 21 * 22 * - KERNEL_ELF_PADDR_BASE: The first physical address used to map the 23 * initial kernel image. The kernel ELF is mapped contiguously 24 * starting at this address. 25 * - KERNEL_ELF_BASE: The first virtual address used to map the initial 26 * kernel image. 27 * 28 * - KDEV_BASE: The first virtual address used to map devices. 29 */ 30 31/* The offset from a physical address to a virtual address in the 32 * physical memory window. */ 33#define PPTR_BASE_OFFSET (PPTR_BASE - PADDR_BASE) 34 35/* The last address in the physical memory region mapped into the 36 * physical memory window */ 37#define PADDR_TOP (PPTR_TOP - PPTR_BASE_OFFSET) 38 39/* The kernel base offset is a way to translate the kernel image segment 40 * from virtual to physical. This translation must be a single offset 41 * for for the entire segment (i.e. the kernel image must be contiguous 42 * both virtually and physically) */ 43#define KERNEL_ELF_BASE_OFFSET (KERNEL_ELF_BASE - KERNEL_ELF_PADDR_BASE) 44 45#ifndef __ASSEMBLER__ 46 47/* This symbol is generated by the linker and marks the last valid 48 * address in the kernel's virtual region */ 49extern char ki_end[]; 50#define KERNEL_ELF_TOP ((paddr_t)(&ki_end)) 51#define KERNEL_ELF_PADDR_TOP (KERNEL_ELF_TOP - KERNEL_ELF_BASE_OFFSET) 52 53#endif /* __ASSEMBLER__ */ 54 55#include <mode/hardware.h> 56