Each architecture now only needs to describe the bounds of the three memory regions: the 1:1 mapped physical memory region, the kernel ELF region (which may or may not overlap the physical memory region) and the device / kernel page table region. The physical base address of the 1:1 mapped physcial memory region and the kernel ELF region must also be specified. The top of user addressable memory (where in the same virtual address space as the kernel) is defined by USER_TOP. The physic memory virtual mapping is described by PPTR_BASE and PPTR_TOP. The base physical memory address is PADDR_BASE and is the physical address used to map PPTR_BASE. Don't use kernelBase when referring to the base of the 1:1 mapped physical memory window. The kernel ELF virtual address region is described by KERNEL_ELF_BASE and extends until the virtual address of the symbol `ki_end` which is created by the linker. KERNEL_ELF_PADDR_BASE is the base address of the physical memory region used to map the kernel and is the address to which KERNEL_ELF_BASE maps. KERNEL_ELF_BASE and KERNEL_ELF_PADDR_BASE do not need to be aligned to a page size boundary as they are approriately truncated during boot by the `map_kernel_window` function. KDEV_BASE describes the base virtual address of the kernel device region and the region is assumed to extend to the end of virtual memory. Note: The offset between PPTR_BASE and PADDR_BASE is used to translate the virtual address of all untyped objects to physical addresses. This includes device untyped objects or frame objects where the virtual address does not fall within the 1:1 mapped physical memory region. Signed-off-by: Curtis Millar <curtis.millar@data61.csiro.au>
46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
/*
|
|
* Copyright 2014, General Dynamics C4 Systems
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-only
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <plat/machine.h>
|
|
#include <machine/registerset.h>
|
|
#include <hardware.h>
|
|
|
|
/* When translating a physical address into an address accessible to the
|
|
* kernel via virtual addressing we always use the mapping of the memory
|
|
* into the physical memory window, even if the mapping originally
|
|
* referred to a kernel virtual address. */
|
|
static inline void *CONST ptrFromPAddr(paddr_t paddr)
|
|
{
|
|
return (void *)(paddr + PPTR_BASE_OFFSET);
|
|
}
|
|
|
|
/* When obtaining a physical address from a reference to any object in
|
|
* the physical mapping window, this function must be used. */
|
|
static inline paddr_t CONST addrFromPPtr(void *pptr)
|
|
{
|
|
return (paddr_t)pptr - PPTR_BASE_OFFSET;
|
|
}
|
|
|
|
static inline region_t CONST paddr_to_pptr_reg(p_region_t p_reg)
|
|
{
|
|
return (region_t) {
|
|
p_reg.start + PPTR_BASE_OFFSET, p_reg.end + PPTR_BASE_OFFSET
|
|
};
|
|
}
|
|
|
|
static inline p_region_t CONST pptr_to_paddr_reg(region_t reg)
|
|
{
|
|
return (p_region_t) {
|
|
reg.start - PPTR_BASE_OFFSET, reg.end - PPTR_BASE_OFFSET
|
|
};
|
|
}
|
|
|
|
#define paddr_to_pptr ptrFromPAddr
|
|
#define pptr_to_paddr(x) addrFromPPtr(x)
|
|
|
|
#include <mode/machine.h>
|