IBM SA14-2339-04 Personal Computer User Manual


 
2-32 PPC405 Core User’s Manual
2.9.3 Privileged SPRs
All SPRs are privileged, except for the LR, the CTR, the XER, USPRG0, and read access to SPRG4–
SPRG7. Reading from the time base registers Time Base Lower (TBL) and Time Base Upper (TBU)
is not privileged. These registers are read using the mftb instruction, rather than the mfspr
instruction. TBL and TBU are written (with different addresses) using mtspr, which is privileged for
these registers. Except for moves to and from non-privileged SPRs, attempts to execute mfspr and
mtspr instructions while in user mode result in privileged violation program exceptions.
In a mfspr or mtspr instruction, the 10-bit SPRN field specifies the SPR number of the source or
destination SPR. The SPRN field contains two five-bit subfields, SPRN
0:4
and SPRN
5:9
. The
assembler handles the unusual register number encoding to generate the SPRF field. In the
machine
code
for the mfspr and mtspr instructions, the SPRN subfields are
reversed
(ending up as SPRF
5:9
and SPRF
0:4
) for compatibility with the POWER Architecture.
In the PowerPC Architecture, SPR numbers havinga1inthemost-significant bit of the SPRF field are
privileged.
The following example illustrates how SPR numbers appear in assembler language coding and in
machine coding of the mfspr and mtspr instructions.
In assembler language coding, SRR0 is SPR 26. Note that the assembler handles the unusual
register number encoding to generate the SPRF field.
mfspr r5,26
When the SPR number is considered as a binary number (0b0000011010), the most-significant bit is
0. However, the machine code for the instruction reverses the subfields, resulting in the following
SPRF field: 0b1101000000. The most-significant bit is 1; SRR0 is privileged.
When an SPR number is considered as a hexadecimal number, the second digit of the three-digit
hexadecimal number indicates whether an SPR is privileged. If the second digit is odd (1, 3, 5, 7, 9, B,
D, F), the SPR is privileged.
For example, the SPR number of SRR0 is 26 (0x01A). The second hexadecimal digit is odd; SRR0 is
privileged. In contrast, the LR is SPR 8 (0x008); the second hexadecimal digit is not odd; the LR is
non-privileged.
2.9.4 Privileged DCRs
The mtdcr and mfdcr instructions themselves are privileged, in all cases. All DCRs are privileged.
tlbia
tlbre
tlbsx
tlbsync
tlbwe
wrtee
wrteei
Table 2-9. Privileged Instructions (continued)