Peripheral Interface: Difference between revisions

no edit summary
(Timing counter sizes)
No edit summary
Line 2:
 
Memory mapped registers are used to configure the Peripheral Interface and initiate DMA reads and writes. The base address for these registers is <code>0x0460 0000</code>, also known as PI_BASE. However, because all memory accesses in the CPU are made using virtual addresses, the following addresses must be offset appropriately. For non-cached reads/writes, add <code>0xA000 0000</code> to the address. As an example, to directly write to the PI_DRAM_ADDR register, use address <code>0xA460 0000</code>.
 
 
== The PI Bus ==
The PI bus is the bus where external devices can be connected, via either the cartridge port on the top of the console, or the expansion port at the bottom of the console. Notice both ports are electrically connected to the same bus, even if the connector is different.
 
The bus address is 32-bit and the values being transferred are 16-bits. So each access (read or write) is made to a 32-bit address with a 16-bit data. The PI (as master device) issues reads and writes to the bus with a wire protocol detailed below. Each device is expected to use an address range (a subset of the whole 32-bit address); the device will receive all reads and writes requests from PI, and is expected to reply / execute those falling within the address range of interest of the device. The PI has no way of knowing if one or more devices are attached to the bus, it does not know which address ranges are used by what device (there is no "address registration / reservation system"), and there are no handling of conflicts.
 
The PI will issue reads or writes as drive by the CPU via two different systems:
 
* DMA: this allows to transfer multiple words. In general, the PI bus protocol allows the PI to write the address once, and then either reads or writes multiple consecutive words, and the DMA will use this mechanism to do quicker transfers. In fact, addresses in the PI bus are virtually split in "pages" of configurable size. The PI is allowed to read/write multiple words within the same page, so during the DMA will issue the address only once for page, and then read/write multiple words as requested. This is done to speed up transfers (as issuing a new address after every word would waste time).
* Direct I/O: part of the 32-bit PI address space is [[Memory map|memory mapped]] to the CPU address space. This means that when the CPU accesses one of these memory mapped addresses, the PI will perform a read or write on the bus. The mapped addresses are only those in the range <code>0x0500_0000 - 0x1FBF_FFFF</code> and <code>0x1FD0_0000 - 0x7FFF_FFFF</code>. Addresses outside of these ranges can only be accessed via DMA. Notice also that direct I/O accesses can only be done as 32-bit words (concatenating two consecutive 16-bit reads), see [[Memory map#Ranges 0x0500'0000 - 0x1FBF'FFFF and 0x1FD0'0000 - 0x7FFF'FFFF (PI external bus)]] for more information.
 
'''NOTE:''' it is easy to get confused with the different kind of addresses. Addresses mentioned here are '''PI bus addresses''', which is a 32-bit namespace by itself. Addresses in the CPU physical memory map are a different namespace. They can be confused because of the memory mapped address, so accessing physical address '''0x0700_0000 in the CPU''' does map exactly to '''PI address 0x0700_0000''', but in general the two namespaces are technically separated. For instance, '''PI address 0x0000_1234''' is a valid PI address on the bus where a device could be attached, but reading from physical address '''0x0000_1234 on the CPU''' accesses RDRAM instead; in fact PI address 0x0000_1234 is not memory mapped, so the only way to access it is via DMA.
 
=== Domains ===
To cope with different peripherals, the PI allows to configure some parameters that affect the bus protocol:
 
* '''PGS (page size).''' This is the size of a virtual page, and defines how often the PI must issue a new address during a DMA transfer. For instance, if the configure page size is 32 16-bit words, assuming an aligned transfer, the PI will issue an address at the start, and then read (or write) 32 consecutive words.
* '''LAT (latency).''' Number of RCP clock cycles to wait between the address and the transfer of the first word
* '''PWD'''
* '''RLS'''
 
The PI stores two set of configurations for these 4 registers, and uses them for different ranges of the address space. These two sets are called "domain 1" and "domain 2". Most of the address space is accessed using the "domain 1" configuration, but a few ranges are accessed as "domain 2". See this table for the mapping:
{| class="wikitable"
|+
!PI address range
!Domain
!Device
|-
|0x0000_0000 - 0x04FF_FFFF
|Domain 1
|No known device exists that operates in this range
|-
|0x0500_0000 - 0x05FF_FFFF
|Domain 2
|64DD registers
|-
|0x0600_0000 - 0x07FF_FFFF
|Domain 1
|64DD ROM
|-
|0x0800_0000 - 0x0FFF_FFFF
|Domain 2
|SRAM
|-
|0x1000_0000 - 0xFFFF_FFFF
|Domain 1
|ROM (though this address range is huge, and ROM only typically occupied a small portion of it)
|}
 
=== Open bus behavior ===
Writes made to addresses with no "receiver" devices cause no harm; the writes are just ignored. As explained above, the PI has absolutely no notion if devices are attached or not (and whether they care about some addresses) so all writes will always be performed as if somebody cared about them.
 
Reads made to addresses with no "receiver" devices cause an open-bus behavior: the 32-bit word returned by PI is the 16-bit lowest part of the address put on the bus, repeated in both halves. For instance, a direct I/O read from PI address <code>0x6666_ABCD</code> will return the value <code>0xABCD_ABCD</code>. When reading unmapped areas via DMA, the rule is the same but the address returned is the address of the page being accessed, and it is repeated for all words read until page change.
 
= Registers =