Table of Contents Previous Chapter
The purpose of the Mongoose and BepReg (Back End Registers) classes is to provide low-level access to the R3000 System Coprocessor (Coprocessor 0) Registers, the Mongoose Command/Status Interface (CSI) Registers, and the ACIS-specific Back End Processor Registers. See Section 4.1 , Section 4.2 , and Section 4.3 for descriptions of the R3000 core processor, the Mongoose extensions to the R3000 core, and the Back End Processor hardware, respectively.
The Mongoose class provides the following features:
The BepReg class provides the following additional features:
With the exception of the IntrGuard class (see Section 6.0 ), the Mongoose and BepReg classes are stand-alone classes, and do not rely on any higher level class definitions. The only relationship is that the BepReg and Mongoose class use the IntrGuard class to temporarily disable interrupts when performing atomic operations, such as a read-modify-write of a shared register. The IntrGuard class, then uses the Mongoose class to access the R3000 Status Register needed to perform the interrupt disable and enables.
Access to the Mongoose registers is provided by a global Mongoose class instance, named mongoose
and the BEP register class is accessed via a single global instance bepReg
.
Since the Mongoose CSI registers are packed into adjacent memory locations, and this will not change over the development cycle, the mongoose instance provides a pointer to a structure which directly overlays the CSI block. This provides the lowest level device code direct access to the Mongoose's device control registers.
The Back End Registers are currently NOT packed into adjacent memory addresses, and therefore, this approach is not appropriate. Instead, the Back End Registers module currently provides all of its functions as in-line functions to address of the various BEP registers and atomically manage the control, status and pulse registers.
The R3000 register and bit definitions can be found in the "MIPS Programmer's Handbook, Section A.4 Registers." The Mongoose register and bit definitions can be found in the "Mongoose ASIC Microcontroller Programming Guide, Section 9.0 Command/Status Interface (CSI) Registers." The Back End Processor registers are listed and described in the "DPA Hardware Specification and System Description" in the sections pertaining to the Back End Processors Overall Description and subsequent subsections.
Both the Mongoose
and BepReg
classes provide enumerations which define the various bits in each register they support. The bit-definition names are qualified by the name of the class defining them. This provides in-code documentation as to where to find the actual definition. For example, if the Mongoose
class defines the R3000 status register bit, SR_IEC (Status register Interrupt Enable Current), users of this definition (i.e. all classes other than the Mongoose
class) must refer to the bit by qualifying with the Mongoose
class definition, "Mongoose
::SR_IEC." Rather than list the many definitions in this section, refer to Section 4.3 for a detailed description of these bits; the constants are defined in mongoos.H and bereg.H.
The Mongoose
class provides functions which read the R3000 System Coprocessor registers using the "mfc0" (Move from Coprocessor 0) assembler instruction (NOTE: These functions are implemented using non-portable in-line assembler). This provides the client code with the contents of the following registers:
The R3000 Status Register controls interrupt enables, and masks individual interrupt lines on the R3000 core. This, in conjunction with the Mongoose's Extended Interrupt Mask register, is used to mask and unmask individual interrupt causes, as globally enable and disable interrupts. Client functions modify this register using the setStatusReg() member function.
In general, most low-level client functions want to protect themselves from interrupts while read-modify-writing a shared register. The following C++ code fragment illustrates a safe way of accomplishing this with the Mongoose
class:
unsigned oldStatusRegister; // Saved contents of Status Register // ---- Disable interrupts, saving previous contents ---- oldStatusRegister = mongoose->setStatusReg(Mongoose::SR_DISABLE_INTS); // code to read/modify and write the shared register // ---- Restore original Status Register contents ---- mongoose->setStatusReg (oldStatusRegister);
Since the Mongoose CSI registers are memory-mapped into a contiguous block in memory, the Mongoose
class provides access to these registers in the form of a pointer to a data structure. The registers are accessed by referring to the register by name through the regs register pointer, contained within the global Mongoose
class instance mongoose
. The following code fragment illustrates how a client might set the contents of the DMA destination address register:
mongoose.regs->dmadst = unsigned(dstptr);
The Mongoose Configuration Registers controls several different devices. As such, access to this register's bits must be shared by more than one client device. To make this sharing easier, the Mongoose
class provides functions which atomically set (setCfgBits()) and clear (clrCfgBits()) bits in the register.
This function, setDmaMode(), is a special case of "Use 4:: Set and clear bits in Configuration Register." Since setting the DMA mode value in the Configuration involves both setting and clearing bits, this ability is rolled into a separate function specifically for dealing with the DMA mode value. Typically, the DMA code uses this function to start and stop DMA activity.
Just as for the Configuration Register, the Mongoose Extended Interrupt Mask Register controls several different devices. As such, access to this register's bits must be shared by more than one client device. To make this sharing easier, the Mongoose
class provides functions which atomically set and clear bits in the register, setXmaskBits() and clrXmaskBits() respectively.
NOTE: Currently, the Interrupt Controller class is the only class which manipulates this register. If this is so, this use may disappear.
Extended interrupts on the Mongoose are latched. In order to clear a latch for a particular interrupt, one must write a 1 into the corresponding bit in the Extended Cause Register. The Mongoose
class provides a function which provides this service, clrXcauseBits().
Since the Mongoose Instruction Cache requires special access, and the Mongoose DMA controller only supports certain types of transfers, the Mongoose
class provides functions which test client addresses against the Instruction and Data cache address boundaries (isIcache(), isDcache() isUncached()).
In order to read and write information to and from the Mongoose Instruction cache, one must manipulate the Instruction Cache Address and Data registers. In order to keep block operations to and from I-cache reasonably fast, the Mongoose
class provides block copy functions to and from I-cache (icacheWrite(), icacheRead()).
The BEP's Control Register affects several different devices. As such, access to this register's bits must be shared by more than one client device. To make this sharing easier, the BepReg
class provides functions which atomically set and clear bits in the register (setControl(), clrControl()).
This function is a special case of "Use 10:: Set and clear bits in BEP Control Register." Since setting the LED value in the Control Registers involves both setting and clearing bits, this ability is rolled into a separate function specifically for dealing with the LED value (BepReg::showLeds()).
In order to provide straight-forward access to the BEP's Status Register, the BepReg
class defines a function which reads and returns the current value of the BEP Status Register (getStatus()).
In order to provide straight-forward access to the BEP's Pulse Register, the BepReg
class defines a function which writes a caller-supplied value to the BEP Pulse Register (pulse()).
Since most of the BepReg
class functions require access to physical hardware locations, the BepReg
class also provides functions which return type-safe pointers to all BEP registers. These include the following:
Hierarchy:
Superclasses:
none
Public Interface:
Operations:
clrCfgBits() clrXCauseBits() clrXMaskBits() getBadVaddrReg() getCauseReg() getEpcReg() getStatusReg() getXCauseReg() icacheRead() icacheWrite() isDcache() isIcache() isUncached() setCfgBits() setDmaMode() setStatusReg() setXMaskBits()
Arguments:
unsigned mask
Documentation:
This function clears bits, designated by 1's in the mask argument, in the Configuration Register. Bits designated by 0's in the mask are unaffected.
Arguments:
unsigned xcause
Documentation:
This function writes xcause to the Mongoose Extended Interrupt Cause Register. This has the effect of clearing any extended interrupts corresponding to 1's in the xcause argument. Interrupts corresponding to 0's are not affected.
Arguments:
unsigned mask
Documentation:
This function clears the bits, indicated by 1's in the mask argument, in the Mongoose's Extended Interrupt Mask Register. Bits designated by 0's in the mask are unaffected.
void*
Arguments:
const unsigned* srcaddr
unsigned* dstaddr
unsigned wordcnt
Documentation:
Copy wordcnt 32-bit words from the Mongoose Instruction cache, located at srcaddr into the buffer pointed to by dstaddr.
Arguments:
const unsigned* srcaddr
unsigned* dstaddr
unsigned wordcnt
Documentation:
This function writes wordcnt words from the data address srcaddr to dstaddr within Instruction cache.
Arguments:
const void* addr
Documentation:
This function tests the passed pointer, addr, against the boundaries of the Data Cache.The function returns BoolTrue if the pointer is within D-cache and returns BoolFalse if it is not.
Arguments:
const void* addr
Documentation:
This function tests the passed pointer, addr, against the address boundaries of the Instruction Cache. If the pointer is within I-cache, the function returns BoolTrue, else it returns BoolFalse.
Arguments:
const void* addr
Documentation:
This function tests the passed pointer, addr, against the start of non-cached memory. It returns BoolTrue if the pointer is beyond cache address space, else BoolFalse.
Arguments:
unsigned mask
Documentation:
This function sets bits, designated by 1's in the mask argument, in the Mongoose Configuration Register. Bits designated by 0's in the mask are unaffected.
Arguments:
unsigned mode
Documentation:
This function writes the mode value, specified by mode, into the Mongoose Configuration Register. Only the DMA Mode bits are affected.
Arguments:
unsigned value
Documentation:
This function writes value to the contents of the R3000 Coprocessor 0's Status Register, and returns the old contents of the register.
Arguments:
unsigned mask
Documentation:
This function sets the bits, indicated by 1's in the mask argument, in the Mongooses Extended Interrupt Mask Register. Bits designated by 0's in the mask are unaffected.
Hierarchy:
Superclasses:
none
Public Interface:
Operations:
clrControl() cmdFifoReg() ctlReg() dtcAddrCntReg() dtcEndReg() dtcStartReg() deaCmdReg() deaStatReg() getStatus() pulseReg() pulse() scCntLatTimeReg() scCntRunTimeReg() setControl() showLeds() statReg()
Arguments:
unsigned mask
Documentation:
This function clears bits, designated by 1's in the mask argument, in the BEP Control Register. Bits designated by 0's in the mask are unaffected.
Arguments:
unsigned mask
Documentation:
This function writes mask into the BEP's Pulse Register. This has the effect of pulsing the bits indicated by 1's in the mask argument. Bits designated by 0's in the mask are unaffected.
Arguments:
unsigned mask
Documentation:
This function sets bits, designated by 1's in the mask argument, in the BEP Control Register. Bits designated by 0's in the mask are unaffected.
Arguments:
unsigned value
Documentation:
This function sets the LED bits in the BEP's Control Register to the argument value. The least-significant four bits of value correspond to the four LED bits in the BEP Control Register. All other bits in value are ignored. Only the LED bits in the Control Register are modified by this function.