Specifications
• If the processor is currently running in the normal register set, insert the new register set number in
estatus.CRS, and execute eret.
• If the processor is currently running in a shadow register set, insert the new register set number in
sstatus.CRS, and execute eret.
Before executing eret to change the register set, system software must set individual external interrupt
masks correctly to ensure that registers in the shadow register set cannot be corrupted. If an interrupt is
assigned to the register set, system software must ensure that one of the following conditions is true:
• The ISR is written to preserve register contents.
• The individual interrupt is disabled. The method for disabling an individual external interrupt is
specific to the EIC implementation.
Stacks and Shadow Register Sets
Depending on system requirements, the system software can create a dedicated stack for each register set,
or share a stack among several register sets. If a stack is shared, the system software must copy the stack
pointer each time the register set changes. Use the rdprs instruction to copy the stack register between the
current register set and another register set.
Initialization with Shadow Register Sets
At initialization, system software must carry out the following tasks to ensure correct software functioning
with shadow register sets:
• After the gp register is initialized in the normal register set, copy it to all shadow register sets, to ensure
that all code can correctly address the small data sections.
• Copy the zero register from the normal register set to all shadow register sets, using the wrprs instruc‐
tion.
Working with the MPU
This section provides a basic overview of MPU initialization and the MPU region read and write
operations.
MPU Region Read and Write Operations
MPU region read and write operations are operations that access MPU region attributes through the
mpubase and mpuacc control registers. The mpubase.BASE, mpuacc.MASK, mpuacc.LIMIT, mpuacc.C, and
mpuacc.PERM fields comprise the MPU region attributes.
MPU region read operations retrieve the current values for the attributes of a region. Each MPU region
read operation consists of the following actions:
• Execute a wrctl instruction to the mpubase register with the mpubase.INDEX and mpubase.D fields set
to identify the MPU region.
• Execute a wrctl instruction to the mpuacc register with the mpuacc.RD field set to one and the
mpuacc.WR field cleared to zero. This action loads the mpubase and mpuacc register values.
• Execute a rdctl instruction to the mpubase register to read the loaded the mpubase register value.
• Execute a rdctl instruction to the mpuacc register to read the loaded the mpuacc register value.
The MPU region read operation retrieves mpubase.BASE, mpuacc.MASK or mpuacc.LIMIT, mpuacc.C, and
mpuacc.PERM values for the MPU region.
Note:
Values for the mpubase register are not actually retrieved until the wrctl instruction to the mpuacc
register is performed.
3-32
Stacks and Shadow Register Sets
NII51003
2015.04.02
Altera Corporation
Programming Model
Send Feedback