This module provide an API to
get and to
set the permission attributes of a memory range.
A memory range can be set to user
executable,
user
writable, user
readable,
supervisor
executable, supervisor
writable, or supervisor
readable.
Setting a memory range to only user readable, writable or executable
should be done with caution because BIOS executes in supervisor mode.
Whenever setting the permission attributes of a memory range,
the
local CPU access field must be set, if the
local CPU accesses the memory range. If the local field is not set,
an exception is generated if the CPU tries to access the memory range.
This module is to be used in correlation with the
Exception module.
When this module is in use, external exceptions are enabled by default.
Any memory protection fault which arises generates an exception.
This exception is processed and decoded by the Exception module.
An example of setting Local L2 RAM to be supervisor read-only and
CPU accessible:
UInt32 paMask;
paMask = MemoryProtect_MPPA_LOCAL |
MemoryProtect_MPPA_SR;
MemoryProtect_setPA((Ptr)0x11800000, 0x40000, paMask);
const MemoryProtect_MPPA_LOCAL |
|
Local CPU may access
#define MemoryProtect_MPPA_LOCAL (UInt32)0x00000100
const MemoryProtect_MPPA_SR |
|
Supervisor mode read
#define MemoryProtect_MPPA_SR (UInt32)0x00000020
const MemoryProtect_MPPA_SW |
|
Supervisor mode may write
#define MemoryProtect_MPPA_SW (UInt32)0x00000010
const MemoryProtect_MPPA_SX |
|
Supervisor mode may execute
#define MemoryProtect_MPPA_SX (UInt32)0x00000008
const MemoryProtect_MPPA_UR |
|
User mode may read
#define MemoryProtect_MPPA_UR (UInt32)0x00000004
const MemoryProtect_MPPA_UW |
|
User mode may write
#define MemoryProtect_MPPA_UW (UInt32)0x00000002
const MemoryProtect_MPPA_UX |
|
User mode may execute
#define MemoryProtect_MPPA_UX (UInt32)0x00000001
const MemoryProtect_numXMCRegions |
|
#define MemoryProtect_numXMCRegions (UInt)16
enum MemoryProtect_RegionSize |
|
typedef enum MemoryProtect_RegionSize {
MemoryProtect_RegionSize_4K,
MemoryProtect_RegionSize_8K,
MemoryProtect_RegionSize_16K,
MemoryProtect_RegionSize_32K,
MemoryProtect_RegionSize_64K,
MemoryProtect_RegionSize_128K,
MemoryProtect_RegionSize_256K,
MemoryProtect_RegionSize_512K,
MemoryProtect_RegionSize_1M,
MemoryProtect_RegionSize_2M,
MemoryProtect_RegionSize_4M,
MemoryProtect_RegionSize_8M,
MemoryProtect_RegionSize_16M,
MemoryProtect_RegionSize_32M,
MemoryProtect_RegionSize_64M,
MemoryProtect_RegionSize_128M,
MemoryProtect_RegionSize_256M,
MemoryProtect_RegionSize_512M,
MemoryProtect_RegionSize_1G,
MemoryProtect_RegionSize_2G,
MemoryProtect_RegionSize_4G
} MemoryProtect_RegionSize;
MemoryProtect_getPA() // module-wide |
|
Gets the PA (Permission Attribute) corresponding to addr
Bool MemoryProtect_getPA(Ptr addr, UInt32 *paMask);
ARGUMENTS
addr
address of memory location for which the PA applies
paMask
ptr to location where PA mask for addr is stored
RETURNS
if address doesn't belong to any configured MPC then
FALSE, otherwise TRUE and *paMask contains addr's
MPPA setting
MemoryProtect_setPA() // module-wide |
|
Sets the PA (Permission Attribute) corresponding to addr/size
Bool MemoryProtect_setPA(Ptr addr, SizeT size, UInt32 paMask);
ARGUMENTS
addr
begin address of memory block for which the PA applies
size
size of memory block
paMask
PA mask to assign for the memory block
RETURNS
if address doesn't belong to any configured MPC then
FALSE, otherwise TRUE and PA was written to addr's
MPPA register
DETAILS
The PA is applied to all addresses that are spanned by the
memory block.
MemoryProtect_setXMCRegion() // module-wide |
|
Set XMC region mapping and permission attributes
ARGUMENTS
regionId
XMC region (segment) number
baseAddr
XMC region logical address
size
XMC region size
rAddr35_12
XMC region translated/extended address bits 35:12
paMask
XMC region permission bits
RETURNS
if baseAddr < 0x0C000000 or regionId >= numXMCRegions
then FALSE, othersize TRUE and the region is mapped with
permission attributes paMask.
DETAILS
The C66 CorePac XMC (eXtended Memory Controller) controls access to
L2 SRAM. It contains 16 MPAX registers that define memory translations
and address extensions along with their associated permission
attributes. Regions can overlap one another, with higher numbered
regions taking priority over lower ones. Regions 0 & 1 are
automatically populated by XMC with power up configuratoin values
which map the entire 4GB logical address space to the corresponding
physical address space. These region mappings allow safe fallback
handling for addresses that are not otherwise mapped in higher MPAX
registers.
Addresses < 0x0C000000 do not reach the XMC, so baseAddr should be
greater than or equal to 0x0C000000.
Module-Wide Built-Ins |
|
// Get this module's unique id
Bool MemoryProtect_Module_startupDone();
// Test if this module has completed startup
// The heap from which this module allocates memory
Bool MemoryProtect_Module_hasMask();
// Test whether this module has a diagnostics mask
Bits16 MemoryProtect_Module_getMask();
// Returns the diagnostics mask for this module
Void MemoryProtect_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module