54
MicroBlaze Processor Reference Guide
UG081 (v14.7)
Chapter 2:
MicroBlaze Architecture
Privileged Instructions
The following MicroBlaze instructions are privileged:
•
GET
,
GETD,PUT,PUTD
(except when explicitly allowed)
•
WIC
,
WDC
•
MTS
•
MSRCLR
,
MSRSET
(except when only the C bit is affected)
•
BRK
•
RTID
,
RTBD
,
RTED
•
BRKI
(except when jumping to physical address
C_BASE_VECTORS
+ 0x8 or
C_BASE_VECTORS
+ 0x18)
•
SLEEP
Attempted use of these instructions when running in user mode causes a privileged instruction
exception.
When setting the parameter
C_MMU_PRIVILEGED_INSTR
to 1, the instructions GET, GETD,
PUT, and PUTD are not considered privileged, and can be executed when running in user mode. It
is strongly discouraged to do this, unless absolutely necessary for performance reasons, since it
allows application programs to interfere with each other.
There are six ways to leave user mode and virtual mode:
1. Hardware generated reset (including debug reset)
2. Hardware exception
3. Non-maskable break or hardware break
4. Interrupt
5. Executing "
BRALID Re,C_BASE_VECTORS
+
0x8
” to perform a user vector exception
6. Executing the software break instructions “
BRKI
” jumping to physical address
C_BASE_VECTORS
+ 0x8 or
C_BASE_VECTORS
+ 0x18
In all of these cases, except hardware generated reset, the user mode and virtual mode status is saved
in the MSR UMS and VMS bits.
Application (user-mode) programs transfer control to system-service routines (privileged mode
programs) using the
BRALID
or
BRKI
instruction, jumping to physical address
C_BASE_VECTORS
+ 0x8. Executing this instruction causes a system-call exception to occur. The
exception handler determines which system-service routine to call and whether the calling
application has permission to call that service. If permission is granted, the exception handler
performs the actual procedure call to the system-service routine on behalf of the application
program.
The execution environment expected by the system-service routine requires the execution of
prologue instructions to set up that environment. Those instructions usually create the block of
storage that holds procedural information (the activation record), update and initialize pointers, and
save volatile registers (registers the system-service routine uses). Prologue code can be inserted by
the linker when creating an executable module, or it can be included as stub code in either the
system-call interrupt handler or the system-library routines.
Returns from the system-service routine reverse the process described above. Epilog code is
executed to unwind and deallocate the activation record, restore pointers, and restore volatile
registers. The interrupt handler executes a return from exception instruction (RTED) to return to the
application.