This module allows the ARM processor to map a 64-bit virtual address
to a 48-bit physical address and enable/disable the MMU. It does this
through translation tables in memory.
...
Void Mmu_initFuncDefault()
{
Bool ret;
Mmu_MapAttrs attrs;
Mmu_initMapAttrs(&attrs);
// MAIR0 has a default memory type that is non-gathering and
// non-reordering with no early write acknowledegement property.
// In other words, strongly ordered memory type.
attrs.attrIndx = Mmu_AttrIndx_MAIR0;
// Map GICv3 registers
ret = Mmu_map(0x01800000, 0x01800000, 0x00100000, &attrs);
if (!ret) {
goto fail;
}
// Map DMTimer registers
ret = Mmu_map(0x02400000, 0x02400000, 0x000c0000, &attrs);
if (!ret) {
goto fail;
}
// Map UART registers
ret = Mmu_map(0x02800000, 0x02800000, 0x00001000, &attrs);
if (!ret) {
goto fail;
}
// Map System Timer registers
ret = Mmu_map(0x2A430000, 0x2A430000, 0x00001000, &attrs);
if (!ret) {
goto fail;
}
// MAIR7 has a default attribute type of Inner and Outer
// write-back cacheable
attrs.attrIndx = Mmu_AttrIndx_MAIR7;
//Map MSMC SRAM
ret = Mmu_map(0x70000000, 0x70000000, 0x00200000, &attrs);
if (!ret) {
goto fail;
}
return;
fail:
System_printf("Mmu config failed.\n");
while (1);
}
const Mmu_PA_MAX_WIDTH |
|
#define Mmu_PA_MAX_WIDTH (UInt8)48
const Mmu_PA_SIZE_ENCODING |
|
#define Mmu_PA_SIZE_ENCODING (UInt8)0x5
enum Mmu_AccessPerm |
|
Access Permissions
typedef enum Mmu_AccessPerm {
Mmu_AccessPerm_PRIV_RW_USER_NONE,
Mmu_AccessPerm_PRIV_RW_USER_RW,
Mmu_AccessPerm_PRIV_RO_USER_NONE,
Mmu_AccessPerm_PRIV_RO_USER_RO
} Mmu_AccessPerm;
enum Mmu_AttrIndx |
|
Memory attribute register (MAIR) index
typedef enum Mmu_AttrIndx {
Mmu_AttrIndx_MAIR0,
Mmu_AttrIndx_MAIR1,
Mmu_AttrIndx_MAIR2,
Mmu_AttrIndx_MAIR3,
Mmu_AttrIndx_MAIR4,
Mmu_AttrIndx_MAIR5,
Mmu_AttrIndx_MAIR6,
Mmu_AttrIndx_MAIR7
} Mmu_AttrIndx;
DETAILS
SYS/BIOS defines default values for MAIR register. See
MAIR0,
MAIR1,
MAIR2,
MAIR3,
MAIR4,
MAIR5,
MAIR6 &
MAIR7 for more info on the
memory type defined by each MAIR register.
enum Mmu_GranuleSize |
|
Memory translation granuleSize granule size
typedef enum Mmu_GranuleSize {
Mmu_GranuleSize_4KB,
Mmu_GranuleSize_16KB,
Mmu_GranuleSize_64KB
} Mmu_GranuleSize;
enum Mmu_Shareable |
|
Shareability attribute
typedef enum Mmu_Shareable {
Mmu_Shareable_NONE,
Mmu_Shareable_OUTER,
Mmu_Shareable_INNER
} Mmu_Shareable;
typedef Mmu_InitFuncPtr |
|
Mmu init function type definition
typedef Void (*Mmu_InitFuncPtr)(Void);
struct Mmu_MapAttrs |
|
Structure containing attributes for memory map entry
typedef struct Mmu_MapAttrs {
// privileged & user access permissions
Bool privExecute;
// privileged execute permission
Bool userExecute;
// user execute permission
// shareability field value 0-3
// stage 1 memory attributes index field
for the indicated MAIRn reg value 0-7
Bool global;
// global mmu entry ? (used by kernel
when memory protection extensions are
enabled)
} Mmu_MapAttrs;
config Mmu_A_nullPointer // module-wide |
|
Assert raised when a pointer is null
config Mmu_A_paddrOutOfRange // module-wide |
|
Assert raised when physical address passed is out of range
extern const Assert_Id Mmu_A_paddrOutOfRange;
config Mmu_A_unalignedPaddr // module-wide |
|
Assert raised if unaligned physical address passed to Mmu_map()
config Mmu_A_unalignedSize // module-wide |
|
Assert raised if unaligned size passed to Mmu_map()
config Mmu_A_unalignedVaddr // module-wide |
|
Assert raised if unaligned virtual address passed to Mmu_map()
config Mmu_A_vaddrOutOfRange // module-wide |
|
Assert raised when virtual address passed is out of range
extern const Assert_Id Mmu_A_vaddrOutOfRange;
config Mmu_MAIR0 // module-wide |
|
Memory attribute 0
extern const UInt8 Mmu_MAIR0;
DETAILS
Default is memory with non-gathering, non-reordering and no early write
acknowledegement property.
config Mmu_MAIR1 // module-wide |
|
Memory attribute 1
extern const UInt8 Mmu_MAIR1;
DETAILS
Default is memory with non-gathering, non-reordering and early write
acknowledegement property.
config Mmu_MAIR2 // module-wide |
|
Memory attribute 2
extern const UInt8 Mmu_MAIR2;
DETAILS
Default is memory with non-gathering, reordering and early write
acknowledegement property.
config Mmu_MAIR3 // module-wide |
|
Memory attribute 3
extern const UInt8 Mmu_MAIR3;
DETAILS
Default is memory with gathering, reordering and early write
acknowledegement property.
config Mmu_MAIR4 // module-wide |
|
Memory attribute 4
extern const UInt8 Mmu_MAIR4;
DETAILS
Default is normal inner & outer non-cacheable memory.
config Mmu_MAIR5 // module-wide |
|
Memory attribute 5
extern const UInt8 Mmu_MAIR5;
DETAILS
Default is normal outer non-cacheable, inner write-back cacheable
non-transient memory.
config Mmu_MAIR6 // module-wide |
|
Memory attribute 6
extern const UInt8 Mmu_MAIR6;
DETAILS
Default is normal outer & inner write-through cacheable non-transient
memory.
config Mmu_MAIR7 // module-wide |
|
Memory attribute 7
extern const UInt8 Mmu_MAIR7;
DETAILS
Default is normal outer and inner write-back cacheable non-transient
memory.
config Mmu_defaultMapAttrs // module-wide |
|
default descriptor attributes structure
config Mmu_enableMMU // module-wide |
|
Configuration parameter to enable MMU
extern const Bool Mmu_enableMMU;
config Mmu_granuleSize // module-wide |
|
Memory translation granule size. Default is 4KB
DETAILS
The granule size determines the smallest page size that can be
mapped with the MMU.
config Mmu_initFunc // module-wide |
|
MMU init function pointer
DETAILS
This config param is initialized to point to an init function that
will perform MMU configuration using the
map runtime APIs
provided by this module. The init function is called before
C initialization i.e. before the data section is initialized.
Therefore, care must be taken to not rely on any initialized
data variables.
By default, the
Mmu_initFuncDefault function
designed for use with AM65x devices is used if the application doesn't
provide its own implementation.
config Mmu_tableArrayLen // module-wide |
|
Length of array of MMU tables
extern const UInt Mmu_tableArrayLen;
DETAILS
MMU module allocates memory for MMU table from a table array.
This config param controls number of MMU tables supported.
Each table in the array is the size of the MMU table and aligned
to the table's size.
NOTE
MMU table size is same as translation granule size (see
granuleSize)
Mmu_enable() // module-wide |
|
Enables the MMU
DETAILS
If the MMU is already enabled, then simply return.
Otherwise this function does the following:
- If the L1 program cache is enabled, invalidate all of L1
program cache.
This function enables the MMU on the core it is called from.
NOTE
This function does not change the L1 data/program cache settings.
Mmu_initFuncDefault() // module-wide |
|
default Mmu.initFunc implementation
Void Mmu_initFuncDefault();
DETAILS
provides Mmu regions for the AM65x's GIC, DMTimer, UART, SYSTIMER,
and MSMC memory.
Mmu_initMapAttrs() // module-wide |
|
Initializes the map attribute structure
ARGUMENTS
attrs
Pointer to map attribute struct
Mmu_isEnabled() // module-wide |
|
Determines if the MMU is enabled
Mmu_map() // module-wide |
|
Add a mapping to MMU table
Bool Mmu_map(
UInt64 vaddr,
UInt64 paddr,
SizeT size,
Mmu_MapAttrs *
attrs);
ARGUMENTS
attrs
Memory region attributes
RETURNS
Status (True-success, False-failed)
DETAILS
This API adds a mapping for the given virtual and physical
address to the MMU table and sets the memory attributes
as per the attributes passed to the function.
This API internally disables interrupts before updating the
MMU table. The interrupts may be disabled for a long period
of time. It is therefore recommended to either call this
API in the Mmu.initFunc or in main().
The smallest mapping size (page size) supported is determined
by the
granuleSize. The largess mapping size supported
is 2^
PA_MAX_WIDTH-1.
Mmu_setMAIR() // module-wide |
|
Sets the memory attribute encoding in the MAIRn register
Void Mmu_setMAIR(UInt8 attrIndx, UInt8 attr);
ARGUMENTS
attrIndx
Memory attribute index
attr
Memory attribute encoding
DETAILS
MAIR provides the memory attribute encodings to the possible
attrIndx values in a long-descriptor format
translation table entry for stage 1 translations.
attrIndx[2:0] selects the ATTRn bit-field in
the MAIR register.
Memory Attribute Indirection Register (MAIR) bit assignments:
--------------------------------------------------------------
|63 | 56|55 | 48|47 | 40|39 | 32|
--------------------------------------------------------------
MAIR | ATTR7 | ATTR6 | ATTR5 | ATTR4 |
--------------------------------------------------------------
|31 | 24|23 | 16|15 | 8|7 | 0|
--------------------------------------------------------------
MAIR | ATTR3 | ATTR2 | ATTR1 | ATTR0 |
--------------------------------------------------------------
SYS/BIOS has 8 MAIR config params (MAIR0, MAIR2, ...) that are
initialized to default value. In order to have a custom memory
attribute, a user can either change the MAIRn config param in
the application's cfg script or call this runtime API.
For more details on MAIR encodings please refer
v8A ARM Architecture Reference Manual
NOTE
This function only invalidates the TLB and does not flush the cache.
If the cacheability attribute of a region of memory is changed by
modifying the MAIR entry for the region, the application needs to
flush and invalidate the region of memory from the cache.
Mmu_tlbInvAll() // module-wide |
|
Invalidate entire TLB (both data and instruction)
Module-Wide Built-Ins |
|
// Get this module's unique id
Bool Mmu_Module_startupDone();
// Test if this module has completed startup
// The heap from which this module allocates memory
Bool Mmu_Module_hasMask();
// Test whether this module has a diagnostics mask
Bits16 Mmu_Module_getMask();
// Returns the diagnostics mask for this module
Void Mmu_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
const Mmu.PA_MAX_WIDTH |
|
const Mmu.PA_MAX_WIDTH = 48;
C SYNOPSIS
const Mmu.PA_SIZE_ENCODING |
|
const Mmu.PA_SIZE_ENCODING = 0x5;
C SYNOPSIS
enum Mmu.AccessPerm |
|
Access Permissions
values of type Mmu.AccessPerm
const Mmu.AccessPerm_PRIV_RW_USER_NONE;
const Mmu.AccessPerm_PRIV_RW_USER_RW;
const Mmu.AccessPerm_PRIV_RO_USER_NONE;
const Mmu.AccessPerm_PRIV_RO_USER_RO;
C SYNOPSIS
enum Mmu.AttrIndx |
|
Memory attribute register (MAIR) index
values of type Mmu.AttrIndx
const Mmu.AttrIndx_MAIR0;
const Mmu.AttrIndx_MAIR1;
const Mmu.AttrIndx_MAIR2;
const Mmu.AttrIndx_MAIR3;
const Mmu.AttrIndx_MAIR4;
const Mmu.AttrIndx_MAIR5;
const Mmu.AttrIndx_MAIR6;
const Mmu.AttrIndx_MAIR7;
DETAILS
SYS/BIOS defines default values for MAIR register. See
MAIR0,
MAIR1,
MAIR2,
MAIR3,
MAIR4,
MAIR5,
MAIR6 &
MAIR7 for more info on the
memory type defined by each MAIR register.
C SYNOPSIS
enum Mmu.GranuleSize |
|
Memory translation granuleSize granule size
values of type Mmu.GranuleSize
const Mmu.GranuleSize_4KB;
const Mmu.GranuleSize_16KB;
const Mmu.GranuleSize_64KB;
C SYNOPSIS
enum Mmu.Shareable |
|
Shareability attribute
values of type Mmu.Shareable
const Mmu.Shareable_NONE;
const Mmu.Shareable_OUTER;
const Mmu.Shareable_INNER;
C SYNOPSIS
struct Mmu.MapAttrs |
|
Structure containing attributes for memory map entry
var obj = new Mmu.MapAttrs;
// privileged & user access permissions
obj.privExecute = Bool ...
// privileged execute permission
obj.userExecute = Bool ...
// user execute permission
// shareability field value 0-3
// stage 1 memory attributes index field
for the indicated MAIRn reg value 0-7
obj.global = Bool ...
// global mmu entry ? (used by kernel
when memory protection extensions are
enabled)
C SYNOPSIS
config Mmu.A_nullPointer // module-wide |
|
Assert raised when a pointer is null
msg: "A_nullPointer: Pointer is null"
};
C SYNOPSIS
config Mmu.A_paddrOutOfRange // module-wide |
|
Assert raised when physical address passed is out of range
msg: "A_paddrOutOfRange: Physical address is out of range"
};
C SYNOPSIS
config Mmu.A_unalignedPaddr // module-wide |
|
Assert raised if unaligned physical address passed to Mmu_map()
msg: "A_unalignedPaddr: Physical address not page aligned"
};
C SYNOPSIS
config Mmu.A_unalignedSize // module-wide |
|
Assert raised if unaligned size passed to Mmu_map()
msg: "A_unalignedSize: Mmu mapping size not page aligned"
};
C SYNOPSIS
config Mmu.A_unalignedVaddr // module-wide |
|
Assert raised if unaligned virtual address passed to Mmu_map()
msg: "A_unalignedVaddr: Virtual address not page aligned"
};
C SYNOPSIS
config Mmu.A_vaddrOutOfRange // module-wide |
|
Assert raised when virtual address passed is out of range
msg: "A_vaddrOutOfRange: Virtual address is out of range"
};
C SYNOPSIS
config Mmu.MAIR0 // module-wide |
|
Memory attribute 0
DETAILS
Default is memory with non-gathering, non-reordering and no early write
acknowledegement property.
C SYNOPSIS
config Mmu.MAIR1 // module-wide |
|
Memory attribute 1
DETAILS
Default is memory with non-gathering, non-reordering and early write
acknowledegement property.
C SYNOPSIS
config Mmu.MAIR2 // module-wide |
|
Memory attribute 2
DETAILS
Default is memory with non-gathering, reordering and early write
acknowledegement property.
C SYNOPSIS
config Mmu.MAIR3 // module-wide |
|
Memory attribute 3
DETAILS
Default is memory with gathering, reordering and early write
acknowledegement property.
C SYNOPSIS
config Mmu.MAIR4 // module-wide |
|
Memory attribute 4
DETAILS
Default is normal inner & outer non-cacheable memory.
C SYNOPSIS
config Mmu.MAIR5 // module-wide |
|
Memory attribute 5
DETAILS
Default is normal outer non-cacheable, inner write-back cacheable
non-transient memory.
C SYNOPSIS
config Mmu.MAIR6 // module-wide |
|
Memory attribute 6
DETAILS
Default is normal outer & inner write-through cacheable non-transient
memory.
C SYNOPSIS
config Mmu.MAIR7 // module-wide |
|
Memory attribute 7
DETAILS
Default is normal outer and inner write-back cacheable non-transient
memory.
C SYNOPSIS
config Mmu.defaultMapAttrs // module-wide |
|
default descriptor attributes structure
privExecute: true,
userExecute: false,
global: true
};
C SYNOPSIS
config Mmu.enableMMU // module-wide |
|
Configuration parameter to enable MMU
Mmu.enableMMU = Bool true;
C SYNOPSIS
config Mmu.granuleSize // module-wide |
|
Memory translation granule size. Default is 4KB
DETAILS
The granule size determines the smallest page size that can be
mapped with the MMU.
C SYNOPSIS
config Mmu.initFunc // module-wide |
|
MMU init function pointer
DETAILS
This config param is initialized to point to an init function that
will perform MMU configuration using the
map runtime APIs
provided by this module. The init function is called before
C initialization i.e. before the data section is initialized.
Therefore, care must be taken to not rely on any initialized
data variables.
By default, the
Mmu_initFuncDefault function
designed for use with AM65x devices is used if the application doesn't
provide its own implementation.
C SYNOPSIS
config Mmu.tableArrayLen // module-wide |
|
Length of array of MMU tables
Mmu.tableArrayLen = UInt 16;
DETAILS
MMU module allocates memory for MMU table from a table array.
This config param controls number of MMU tables supported.
Each table in the array is the size of the MMU table and aligned
to the table's size.
NOTE
MMU table size is same as translation granule size (see
granuleSize)
C SYNOPSIS
metaonly config Mmu.common$ // module-wide |
|
Common module configuration parameters
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.
metaonly config Mmu.tableArraySection // module-wide |
|
Contains a table array and some state variables.
This section is uninitialized
Mmu.tableArraySection = String ".data.ti_sysbios_family_arm_v8a_Mmu_tableArray";
DETAILS
Note: Memory containing the table array must be marked as inner &
and outer shareable, and inner and outer write-back write-allocate
cacheable.