module ti.sysbios.family.c64p.MemoryProtect

MemoryProtect Module

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. [ more ... ]
C synopsis target-domain sourced in ti/sysbios/family/c64p/MemoryProtect.xdc
DETAILS
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);

Calling Context

Function Hwi Swi Task Main Startup
getPA Y Y Y Y Y
setPA Y Y Y Y Y
Definitions:
  • Hwi: API is callable from a Hwi thread.
  • Swi: API is callable from a Swi thread.
  • Task: API is callable from a Task thread.
  • Main: API is callable during any of these phases:
    • In your module startup after this module is started (e.g. Mod_Module_startupDone() returns TRUE).
    • During xdc.runtime.Startup.lastFxns.
    • During main().
    • During BIOS.startupFxns.
  • Startup: API is callable during any of these phases:
    • During xdc.runtime.Startup.firstFxns.
    • In your module startup before this module is started (e.g. Mod_Module_startupDone() returns FALSE).
 
const MemoryProtect_MPPA_LOCAL

Local CPU may access

C synopsis target-domain
#define MemoryProtect_MPPA_LOCAL (UInt32)0x00000100
 
 
const MemoryProtect_MPPA_SR

Supervisor mode read

C synopsis target-domain
#define MemoryProtect_MPPA_SR (UInt32)0x00000020
 
 
const MemoryProtect_MPPA_SW

Supervisor mode may write

C synopsis target-domain
#define MemoryProtect_MPPA_SW (UInt32)0x00000010
 
 
const MemoryProtect_MPPA_SX

Supervisor mode may execute

C synopsis target-domain
#define MemoryProtect_MPPA_SX (UInt32)0x00000008
 
 
const MemoryProtect_MPPA_UR

User mode may read

C synopsis target-domain
#define MemoryProtect_MPPA_UR (UInt32)0x00000004
 
 
const MemoryProtect_MPPA_UW

User mode may write

C synopsis target-domain
#define MemoryProtect_MPPA_UW (UInt32)0x00000002
 
 
const MemoryProtect_MPPA_UX

User mode may execute

C synopsis target-domain
#define MemoryProtect_MPPA_UX (UInt32)0x00000001
 
 
MemoryProtect_getPA()  // module-wide

Gets the PA (Permission Attribute) corresponding to addr

C synopsis target-domain
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

C synopsis target-domain
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.
Module-Wide Built-Ins

C synopsis target-domain
Types_ModuleId MemoryProtect_Module_id();
// Get this module's unique id
 
Bool MemoryProtect_Module_startupDone();
// Test if this module has completed startup
 
IHeap_Handle MemoryProtect_Module_heap();
// 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
 
Configuration settings sourced in ti/sysbios/family/c64p/MemoryProtect.xdc
var MemoryProtect = xdc.useModule('ti.sysbios.family.c64p.MemoryProtect');
module-wide constants & types
    const MemoryProtect.MPPA_SR// Supervisor mode read = 0x00000020;
    const MemoryProtect.MPPA_UR// User mode may read = 0x00000004;
    const MemoryProtect.MPPA_UW// User mode may write = 0x00000002;
module-wide config parameters
 
 
const MemoryProtect.MPPA_LOCAL

Local CPU may access

Configuration settings
const MemoryProtect.MPPA_LOCAL = 0x00000100;
 
C SYNOPSIS
 
const MemoryProtect.MPPA_SR

Supervisor mode read

Configuration settings
const MemoryProtect.MPPA_SR = 0x00000020;
 
C SYNOPSIS
 
const MemoryProtect.MPPA_SW

Supervisor mode may write

Configuration settings
const MemoryProtect.MPPA_SW = 0x00000010;
 
C SYNOPSIS
 
const MemoryProtect.MPPA_SX

Supervisor mode may execute

Configuration settings
const MemoryProtect.MPPA_SX = 0x00000008;
 
C SYNOPSIS
 
const MemoryProtect.MPPA_UR

User mode may read

Configuration settings
const MemoryProtect.MPPA_UR = 0x00000004;
 
C SYNOPSIS
 
const MemoryProtect.MPPA_UW

User mode may write

Configuration settings
const MemoryProtect.MPPA_UW = 0x00000002;
 
C SYNOPSIS
 
const MemoryProtect.MPPA_UX

User mode may execute

Configuration settings
const MemoryProtect.MPPA_UX = 0x00000001;
 
C SYNOPSIS
 
metaonly config MemoryProtect.common$  // module-wide

Common module configuration parameters

Configuration settings
MemoryProtect.common$ = Types.Common$ undefined;
 
DETAILS
All modules have this configuration parameter. Its name contains the '$' character to ensure it does not conflict with configuration parameters declared by the module. This allows new configuration parameters to be added in the future without any chance of breaking existing modules.
generated on Fri, 10 Jun 2016 23:28:59 GMT