# MEMPROT Functions
[MEMPROT]

## Functions
CSL_IDEF_INLINE Uint32 | CSL_MEMPROT_getL2FaultAddress (void)
CSL_IDEF_INLINE void | CSL_MEMPROT_clearL2Fault (void)
CSL_IDEF_INLINE void | CSL_MEMPROT_getL2FaultStatus (CSL_MEMPROT_MPFSR *mpfsr)
CSL_IDEF_INLINE void | CSL_MEMPROT_setL2Attributes (Uint32 index, CSL_MEMPROT_MPPA *mppa)
CSL_IDEF_INLINE void | CSL_MEMPROT_getL2Attributes (Uint32 index, CSL_MEMPROT_MPPA *mppa)
CSL_IDEF_INLINE Uint32 | CSL_MEMPROT_getL1PFaultAddress (void)
CSL_IDEF_INLINE void | CSL_MEMPROT_clearL1PFault (void)
CSL_IDEF_INLINE void | CSL_MEMPROT_getL1PFaultStatus (CSL_MEMPROT_MPFSR *mpfsr)
CSL_IDEF_INLINE void | CSL_MEMPROT_setL1PAttributes (Uint32 index, CSL_MEMPROT_MPPA *mppa)
CSL_IDEF_INLINE void | CSL_MEMPROT_getL1PAttributes (Uint32 index, CSL_MEMPROT_MPPA *mppa)
CSL_IDEF_INLINE Uint32 | CSL_MEMPROT_getL1DFaultAddress (void)
CSL_IDEF_INLINE void | CSL_MEMPROT_clearL1DFault (void)
CSL_IDEF_INLINE void | CSL_MEMPROT_getL1DFaultStatus (CSL_MEMPROT_MPFSR *mpfsr)
CSL_IDEF_INLINE void | CSL_MEMPROT_setL1DKey (Uint32 index, Uint32 l1dkey)
CSL_IDEF_INLINE void | CSL_MEMPROT_resetL1DLock (void)
CSL_IDEF_INLINE void | CSL_MEMPROT_lockL1D (void)
CSL_IDEF_INLINE void | CSL_MEMPROT_unlockL1D (void)
CSL_IDEF_INLINE void | CSL_MEMPROT_getL1DLockStatus (CSL_MEMPROT_MPLKSTAT *mplkstat)
CSL_IDEF_INLINE void | CSL_MEMPROT_setL1DAttributes (Uint32 index, CSL_MEMPROT_MPPA *mppa)
CSL_IDEF_INLINE void | CSL_MEMPROT_getL1DAttributes (Uint32 index, CSL_MEMPROT_MPPA *mppa)

## Function Documentation

CSL_IDEF_INLINE void CSL_MEMPROT_clearL1DFault | ( | void |  | ) |

============================================================================
CSL_MEMPROT_clearL1DFault

Description
This function clears the L1D fault information.

Arguments
None

Return Value
None

Pre Condition
None

Post Condition
CSL_CGEM_L1DMPFCR_MPFCLR register bit field set to one. Previous Fault information is cleared from the Fault Status register.

Writes
CGEM_L1DMPFCR_MPFCLR=1

Affects
CGEM_L1DMPFAR_ADDR=0, CGEM_L1DMPFSR_FID=0, CGEM_L1DMPFSR_LOCAL=0, CGEM_L1DMPFSR_NS=0, CGEM_L1DMPFSR_SR=0, CGEM_L1DMPFSR_SW=0, CGEM_L1DMPFSR_SX=0, CGEM_L1DMPFSR_UR=0, CGEM_L1DMPFSR_UW=0, CGEM_L1DMPFSR_UX=0

Example

            CSL_MEMPROT_clearL1DFault ();

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_clearL1PFault | ( | void |  | ) |

============================================================================
CSL_MEMPROT_clearL1PFault

Description
This function clears the L1P fault information.

Arguments
None

Return Value
None

Pre Condition
None

Post Condition
CSL_CGEM_L1PMPFCR_MPFCLR register bit field set to one. Previous Fault information is cleared from the Fault Status and Address registers.

Writes
CGEM_L1PMPFCR_MPFCLR=1

Affects
CGEM_L1PMPFAR_ADDR=0, CGEM_L1PMPFSR_FID=0, CGEM_L1PMPFSR_LOCAL=0, CGEM_L1PMPFSR_NS=0, CGEM_L1PMPFSR_SR=0, CGEM_L1PMPFSR_SW=0, CGEM_L1PMPFSR_SX=0, CGEM_L1PMPFSR_UR=0, CGEM_L1PMPFSR_UW=0, CGEM_L1PMPFSR_UX=0

Example

            CSL_MEMPROT_clearL1PFault ();

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_clearL2Fault | ( | void |  | ) |

============================================================================
CSL_MEMPROT_clearL2Fault

Description
This function clears the L2 fault information.

Arguments
None

Return Value
None

Pre Condition
None

Post Condition
CSL_CGEM_L2MPFCR_MPFCLR register bit field set to one. Previous Fault information is cleared from the Fault Status and Address registers.

Writes
CGEM_L2MPFCR_MPFCLR=1

Affects
CGEM_L2MPFAR_ADDR=0, CGEM_L2MPFSR_FID=0, CGEM_L2MPFSR_LOCAL=0, CGEM_L2MPFSR_NS=0, CGEM_L2MPFSR_SR=0, CGEM_L2MPFSR_SW=0, CGEM_L2MPFSR_SX=0, CGEM_L2MPFSR_UR=0, CGEM_L2MPFSR_UW=0, CGEM_L2MPFSR_UX=0

Example

            CSL_MEMPROT_clearL2Fault ();

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_getL1DAttributes | ( | Uint32 | index,
|  | CSL_MEMPROT_MPPA * | mppa |
| ) |  |  |

============================================================================
CSL_MEMPROT_getL1DAttributes

Description
This function gets the L1D attributes from the contents of L1DMPPA register corresponding to the index specified.

Arguments

            index       Index into the set of 32 L1DMPPA registers
            mpaxl       CSL_MEMPROT_MPPA structure that needs to be populated with
                        L1DMPPA register contents.

Return Value
None

Pre Condition
None

Post Condition
None

Reads
CGEM_L1DMPPA_AID5, CGEM_L1DMPPA_AID4, CGEM_L1DMPPA_AID3, CGEM_L1DMPPA_AID2, CGEM_L1DMPPA_AID1, CGEM_L1DMPPA_AID0, CGEM_L1DMPPA_AIDX, CGEM_L1DMPPA_LOCAL, CGEM_L1DMPPA_UW, CGEM_L1DMPPA_UR, CGEM_L1DMPPA_SW, CGEM_L1DMPPA_SR

Example

            Uint32 index = 0;
            CSL_MEMPROT_MPPA mppa;

            CSL_MEMPROT_getL1DAttributes (index, &mppa);

=============================================================================

CSL_IDEF_INLINE Uint32 CSL_MEMPROT_getL1DFaultAddress | ( | void |  | ) |

============================================================================
CSL_MEMPROT_getL1DFaultAddress

Description
This function gets the access address causing the fault.

Arguments
None

Return Value Uint32

Pre Condition
None

Post Condition
None

Reads
CGEM_L1DMPFAR_ADDR

Example

            Uint32 faultAddr;

            faultAddr = CSL_MEMPROT_getL1DFaultAddress ();

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_getL1DFaultStatus | ( | CSL_MEMPROT_MPFSR * | mpfsr | ) |

============================================================================
CSL_MEMPROT_getL1DFaultStatus

Description
This function gets the contents of L1D Fault Status Register L1DMPFSR.

Arguments

            xmpfsr      CSL_MEMPROT_MPFSR structure that needs to be filled in from
                        L1DMPFSR register

Return Value
None

Pre Condition
None

Post Condition
None

Reads
CGEM_L1DMPFSR_FID, CGEM_L1DMPFSR_LOCAL, CGEM_L1DMPFSR_NS, CGEM_L1DMPFSR_SR, CGEM_L1DMPFSR_SW, CGEM_L1DMPFSR_SX, CGEM_L1DMPFSR_UR, CGEM_L1DMPFSR_UW, CGEM_L1DMPFSR_UX

Example

            CSL_MEMPROT_MPFSR mpfsr;

            CSL_MEMPROT_getL1DFaultStatus (&mpfsr);

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_getL1DLockStatus | ( | CSL_MEMPROT_MPLKSTAT * | mplkstat | ) |

============================================================================
CSL_MEMPROT_getL1DLockStatus

Description
This function gets the L1D lock status from the contents of L1DMPLKSTAT register.

Arguments

              mpfsr      	CSL_MEMPROT_MPLKSTAT structure that needs to be filled in from
              			  	L1DMPLKSTAT register

Return Value
None

Pre Condition
None

Post Condition
None

Reads
CGEM_MPLKSTAT_NSL, CGEM_MPLKSTAT_LK

Example

            CSL_MEMPROT_MPLKSTAT mplkstat;

            CSL_MEMPROT_getL1DLockStatus (&mplkstat);

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_getL1PAttributes | ( | Uint32 | index,
|  | CSL_MEMPROT_MPPA * | mppa |
| ) |  |  |

============================================================================
CSL_MEMPROT_getL1PAttributes

Description
This function gets the L1P attributes by reading the contents of L1PMPPA register corresponding to the index specified.

Arguments

            index       Index into the set of 32 L1PMPPA registers
            mpaxl       CSL_MEMPROT_MPPA structure that needs to be populated with
                        L1PMPPA register contents.

Return Value
None

Pre Condition
None

Post Condition
None

Reads
CGEM_L1PMPPA_AID5, CGEM_L1PMPPA_AID4, CGEM_L1PMPPA_AID3, CGEM_L1PMPPA_AID2, CGEM_L1PMPPA_AID1, CGEM_L1PMPPA_AID0, CGEM_L1PMPPA_AIDX, CGEM_L1PMPPA_LOCAL, CGEM_L1PMPPA_UX, CGEM_L1PMPPA_UW, CGEM_L1PMPPA_UR, CGEM_L1PMPPA_SX, CGEM_L1PMPPA_SW, CGEM_L1PMPPA_SR

Example

            Uint32 index = 0;
            CSL_MEMPROT_MPPA mppa;

            CSL_MEMPROT_getL1PAttributes (index, &mppa);

=============================================================================

CSL_IDEF_INLINE Uint32 CSL_MEMPROT_getL1PFaultAddress | ( | void |  | ) |

============================================================================
CSL_MEMPROT_getL1PFaultAddress

Description
This function gets the access address causing the fault.

Arguments
None

Return Value Uint32

Pre Condition
None

Post Condition
None

Reads
CGEM_L1PMPFAR_ADDR

Example

            Uint32 faultAddr;

            faultAddr = CSL_MEMPROT_getL1PFaultAddress ();

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_getL1PFaultStatus | ( | CSL_MEMPROT_MPFSR * | mpfsr | ) |

============================================================================
CSL_MEMPROT_getL1PFaultStatus

Description
This function gets the contents of L1P Fault Status Register L1PMPFSR.

Arguments

            xmpfsr      CSL_MEMPROT_MPFSR structure that needs to be filled in from
                        L1PMPFSR register

Return Value
None

Pre Condition
None

Post Condition
None

Reads
CGEM_L1PMPFSR_FID, CGEM_L1PMPFSR_LOCAL, CGEM_L1PMPFSR_NS, CGEM_L1PMPFSR_SR, CGEM_L1PMPFSR_SW, CGEM_L1PMPFSR_SX, CGEM_L1PMPFSR_UR, CGEM_L1PMPFSR_UW, CGEM_L1PMPFSR_UX

Example

            CSL_MEMPROT_MPFSR mpfsr;

            CSL_MEMPROT_getL1PFaultStatus (&mpfsr);

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_getL2Attributes | ( | Uint32 | index,
|  | CSL_MEMPROT_MPPA * | mppa |
| ) |  |  |

============================================================================
CSL_MEMPROT_getL2Attributes

Description
This function gets the L2 memory protection attributes by reading the contents of L2MPPA register corresponding to the index specified.

Arguments

            index       Index into the set of 32 MPPA registers
            mpaxl       CSL_MEMPROT_MPPA structure that needs to be populated with
                        L2MPPA register contents.

Return Value
None

Pre Condition
None

Post Condition
None

Reads
CGEM_L2MPPA_AID5, CGEM_L2MPPA_AID4, CGEM_L2MPPA_AID3, CGEM_L2MPPA_AID2, CGEM_L2MPPA_AID1, CGEM_L2MPPA_AID0, CGEM_L2MPPA_AIDX, CGEM_L2MPPA_LOCAL, CGEM_L2MPPA_UX, CGEM_L2MPPA_UW, CGEM_L2MPPA_UR, CGEM_L2MPPA_SX, CGEM_L2MPPA_SW, CGEM_L2MPPA_SR

Example

            Uint32 index = 0;
            CSL_MEMPROT_MPPA mppa;

            CSL_MEMPROT_getL2Attributes (index, &mppa);

=============================================================================

CSL_IDEF_INLINE Uint32 CSL_MEMPROT_getL2FaultAddress | ( | void |  | ) |

============================================================================
CSL_MEMPROT_getL2FaultAddress

Description
This function gets the access address causing the fault.

Arguments
None

Return Value Uint32

Pre Condition
None

Post Condition
None

Reads
CGEM_L2MPFAR_ADDR

Example

            Uint32 faultAddr;

            faultAddr = CSL_MEMPROT_getL2FaultAddress ();

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_getL2FaultStatus | ( | CSL_MEMPROT_MPFSR * | mpfsr | ) |

============================================================================
CSL_MEMPROT_getL2FaultStatus

Description
This function gets the contents of L2 Fault Status Register L2MPFSR.

Arguments

            xmpfsr      CSL_MEMPROT_MPFSR structure that needs to be filled in from
                        L2MPFSR register

Return Value
None

Pre Condition
None

Post Condition
None

Reads
CGEM_L2MPFSR_FID, CGEM_L2MPFSR_LOCAL, CGEM_L2MPFSR_NS, CGEM_L2MPFSR_SR, CGEM_L2MPFSR_SW, CGEM_L2MPFSR_SX, CGEM_L2MPFSR_UR, CGEM_L2MPFSR_UW, CGEM_L2MPFSR_UX

Example

            CSL_MEMPROT_MPFSR mpfsr;

            CSL_MEMPROT_getL2FaultStatus (&mpfsr);

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_lockL1D | ( | void |  | ) |

============================================================================
CSL_MEMPROT_lockL1D

Description
This function locks the L1D by issuing a LOCK command using the L1DMPLKCMD register.

Arguments None

Return Value
None

Pre Condition
CSL_MEMPROT_resetL1DLock() must be called to reset locks before calling this API. Also, if a new key value needs to be configured it must be done too using CSL_MEMPROT_setL1DKey() API before doing the lock operation.

Post Condition
LOCK bit set in the L1DMPLKCMD register.

Writes
CGEM_MPLKCMD_LOCK=1

Affects
CGEM_MPLKSTAT_LK=1

Example

            Uint32 index = 0;
            Uint32 value = 0x32;

            CSL_MEMPROT_resetL1DLock ();
            ...
            CSL_MEMPROT_setL1DKey (index, value);
            ...
            CSL_MEMPROT_lockL1D ();

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_resetL1DLock | ( | void |  | ) |

============================================================================
CSL_MEMPROT_resetL1DLock

Description
This function resets the L1D Lock by issuing the KEYR command to MPLKCMD register.

Arguments None

Return Value
None

Pre Condition
None

Post Condition
KEYR bit in MPLKCMD register is set and lock reset sequence is set in motion.

Writes
CGEM_MPLKCMD_KEYR=1

Example

            CSL_MEMPROT_resetL1DLock ();

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_setL1DAttributes | ( | Uint32 | index,
|  | CSL_MEMPROT_MPPA * | mppa |
| ) |  |  |

============================================================================
CSL_MEMPROT_setL1DAttributes

Description
This function sets the contents of L1DMPPA register corresponding to the index specified.

Arguments

            index       Index into the set of 32 registers (0-31)
            mppa        CSL_MEMPROT_MPPA structure that needs to be set into the
                        register

Return Value
None

Pre Condition
None

Post Condition
L1DMPPA register corresponding to index specified is configured with the attributes passed.

Writes
CGEM_L1DMPPA_AID5, CGEM_L1DMPPA_AID4, CGEM_L1DMPPA_AID3, CGEM_L1DMPPA_AID2, CGEM_L1DMPPA_AID1, CGEM_L1DMPPA_AID0, CGEM_L1DMPPA_AIDX, CGEM_L1DMPPA_LOCAL, CGEM_L1DMPPA_UW, CGEM_L1DMPPA_UR, CGEM_L1DMPPA_SW, CGEM_L1DMPPA_SR

Example

            Uint32 index = 0;
            CSL_MEMPROT_MPPA mppa;

            mppa->aid5 = 1;
            mppa->aid4 = 1;
            mppa->aid3 = 1;
            mppa->aid2 = 1;
            mppa->aid1 = 1;
            mppa->aid0 = 1;
            mppa->aidx = 1;
            mppa->local = 1;
            mppa->uw = 1;
            mppa->ur = 1;
            mppa->sw = 1;
            mppa->sr = 1;

            CSL_MEMPROT_setL1DAttributes (index, &mppa);

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_setL1DKey | ( | Uint32 | index,
|  | Uint32 | l1dkey |
| ) |  |  |

============================================================================
CSL_MEMPROT_setL1DKey

Description
This function configures the MPLK register corresponding to the index specified with the key value passed to this API.

Arguments

            index       Index into the set of 4 MPLK registers
            l1dkey      32 Lock bits to be put into the MPLK register.

Return Value
None

Pre Condition
CSL_MEMPROT_resetL1DLock() must be set to reset locks before calling this API.

Post Condition
L1DMPLK register corresponding to index specified is configured with the key value passed in l1dkey argument.

Writes
CGEM_MPLK_MPLK

Example

            Uint32 index = 0;
            Uint32 value = 0x32;

            CSL_MEMPROT_resetL1DLock ();
            ...
            CSL_MEMPROT_setL1DKey (index, value);
            ...
            CSL_MEMPROT_lockL1D ();

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_setL1PAttributes | ( | Uint32 | index,
|  | CSL_MEMPROT_MPPA * | mppa |
| ) |  |  |

============================================================================
CSL_MEMPROT_setL1PAttributes

Description
This function sets the L1P attributes, by configuring the contents of L1PMPPA register corresponding to the index specified.

Arguments

            index       Index into the set of 32 L1PMPPA registers (0-31)
            mppa        CSL_MEMPROT_MPPA structure that needs to be set into the
                        register

Return Value
None

Pre Condition
None

Post Condition
L1PMPPA register configured with the value passed.

Writes
CGEM_L1PMPPA_AID5, CGEM_L1PMPPA_AID4, CGEM_L1PMPPA_AID3, CGEM_L1PMPPA_AID2, CGEM_L1PMPPA_AID1, CGEM_L1PMPPA_AID0, CGEM_L1PMPPA_AIDX, CGEM_L1PMPPA_LOCAL, CGEM_L1PMPPA_UX, CGEM_L1PMPPA_UW, CGEM_L1PMPPA_UR, CGEM_L1PMPPA_SX, CGEM_L1PMPPA_SW, CGEM_L1PMPPA_SR

Example

            Uint32 index = 0;
            CSL_MEMPROT_MPPA mppa;

            mppa->aid5 = 1;
            mppa->aid4 = 1;
            mppa->aid3 = 1;
            mppa->aid2 = 1;
            mppa->aid1 = 1;
            mppa->aid0 = 1;
            mppa->aidx = 1;
            mppa->local = 1;
            mppa->ux = 1;
            mppa->uw = 1;
            mppa->ur = 1;
            mppa->sx = 1;
            mppa->sw = 1;
            mppa->sr = 1;

            CSL_MEMPROT_setL1PAttributes (index, &mppa);

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_setL2Attributes | ( | Uint32 | index,
|  | CSL_MEMPROT_MPPA * | mppa |
| ) |  |  |

============================================================================
CSL_MEMPROT_setL2Attributes

Description
This function sets the contents of L2MPPA register corresponding to the index specified.

Arguments

            index       Index into the set of 32 registers (0-31)
            mppa        CSL_MEMPROT_MPPA structure that needs to be set into the
                        register

Return Value
None

Pre Condition
None

Post Condition
L2MPPA register corresponding to index specified is configured with the attributes passed in mppa argument.

Writes
CGEM_L2MPPA_AID5, CGEM_L2MPPA_AID4, CGEM_L2MPPA_AID3, CGEM_L2MPPA_AID2, CGEM_L2MPPA_AID1, CGEM_L2MPPA_AID0, CGEM_L2MPPA_AIDX, CGEM_L2MPPA_LOCAL, CGEM_L2MPPA_UX, CGEM_L2MPPA_UW, CGEM_L2MPPA_UR, CGEM_L2MPPA_SX, CGEM_L2MPPA_SW, CGEM_L2MPPA_SR

Example

            Uint32 index = 0;
            CSL_MEMPROT_MPPA mppa;

            mppa->aid5 = 1;
            mppa->aid4 = 1;
            mppa->aid3 = 1;
            mppa->aid2 = 1;
            mppa->aid1 = 1;
            mppa->aid0 = 1;
            mppa->aidx = 1;
            mppa->local = 1;
            mppa->ux = 1;
            mppa->uw = 1;
            mppa->ur = 1;
            mppa->sx = 1;
            mppa->sw = 1;
            mppa->sr = 1;

            CSL_MEMPROT_setL2Attributes (index, &mppa);

=============================================================================

CSL_IDEF_INLINE void CSL_MEMPROT_unlockL1D | ( | void |  | ) |

============================================================================
CSL_MEMPROT_unlockL1D

Description
This function unlocks L1D by issuing an UNLOCK command using the L1DMPLKCMD register.

Arguments None

Return Value
None

Pre Condition
CSL_MEMPROT_resetL1DLock() must be called to reset locks before calling this API. Also, a valid key must be configured using CSL_MEMPROT_setL1DKey() API before calling this API.

Post Condition
UNLOCK bit set in the L1DMPLKCMD register.

Writes
CGEM_MPLKCMD_UNLOCK=1

Affects
CGEM_MPLKSTAT_LK=0

Example

            CSL_MEMPROT_resetL1DLock ();
            ...
            CSL_MEMPROT_unlockL1D ();

=============================================================================

Copyright 2012, Texas Instruments Incorporated