Chapter 5
Programming the MIPS32® 74K™ Core Family, Revision 02.14
67
Kernel-mode (OS) programming and Release 2 of the
MIPS32® Architecture
tells you how to write OS code which is portable across all compliant CPUs. Most OS code should be
CPU-independent, and we won’t tell you how to write it here. But release 2 of the MIPS32 Specification
introduced a few new optional features which are not yet well known, so are worth describing here:
•
A better way of managing software-visible pipeline and hardware delays associated with CP0 programming in
Section 5.1, "Hazard barrier instructions"
.
•
New interrupt facilities described in
Section 5.2, "MIPS32® Architecture Release 2 - enhanced interrupt
;
•
That led on to
Section 5.3.1 “Summary of exception entry points”
: where do exceptions go, and what options are
available?
•
The ability to use one or more extra sets of registers (“shadow sets”) to reduce context-saving overhead in inter-
rupt handlers, in
Section 5.4, "Shadow registers"
•
How to get at any power-saving features, in
•
How to control user-privilege access to “hardware registers”, in
Section 5.6 “The HWREna register - Control
5.1 Hazard barrier instructions
When privileged “CP0” instructions change the machine state, you can get unexpected behavior if an effect is
deferred out of its normal instruction sequence. But that can happen because the relevant control register only gets
written some way down the pipeline, or because the changes it makes are sensed by other instructions early in their
pipeline sequence: this is called a CP0 hazard.
Your 74K family core offers you the option of removing many CP0 hazards by setting the
Config7[IHB]
option bit as
described in the notes to
. But you might be better off sticking to the rules described in
code will run on any compliant CPU: it may be best to see this feature as the way to rescue legacy code.
It’s possible to get hazards in user mode code too, and many of the instructions described here are not solely for ker-
nel-privilege code. But they’re most often met around CP0 read/writes, so they found their way to this chapter.
Traditionally, MIPS CPUs left the kernel/low-level software engineer with the job of designing sequences which are
guaranteed to run correctly, usually by padding the dangerous operation with enough
nop
or
ssnop
instructions.
From Release 2 of the MIPS32 specification this is replaced by explicit hazard barrier instructions. If you execute a
hazard barrier between the instruction which makes the change (the “producer”) and the instruction which is sensitive
to it (the “consumer”), you are guaranteed that the change will be seen as complete. Hazards can appear when the pro-
Summary of Contents for MIPS32 74K Series
Page 1: ...Document Number MD00541 Revision 02 14 March 30 2011 Programming the MIPS32 74K Core Family...
Page 10: ...Programming the MIPS32 74K Core Family Revision 02 14 10...
Page 54: ...3 8 The TLB and translation Programming the MIPS32 74K Core Family Revision 02 14 54...
Page 83: ......
Page 101: ...The MIPS32 DSP ASE 101 Programming the MIPS32 74K Core Family Revision 02 14...
Page 134: ...8 4 Performance counters Programming the MIPS32 74K Core Family Revision 02 14 134...