PI Registers Detailed

From en64 wiki
Jump to: navigation, search

Taken from Lac's hw-dox.

initialize pif

(you should do this before you do anything!)

    1. Simply write 0x8 to PIF_RAM_START+0x3c

PI DMA transfer

    1. Wait for previous dma transfer to finish (see next explanation)
    2. Write the physical dram address of the dma transfer to PI_DRAM_ADDR_REG
       NOTE: To convert from a virtual address to physical, simply AND the address with 0x1fffffff.
    3. Write the physical cart address to PI_CART_ADDR_REG.
    4. Write the length-1 of the dma transfer to PI_WR_LEN_REG
       this is from cart->rdram change this to RD   ^  for the other way
       also note you must write a 0x2 to PI_STATUS_REG in order to write to
       the cart space (0xb0000000) 
    NOTE: The cart addr must be 2 byte aligned, and the rdram addres must 8-byte aligned. Once again make sure you write back the cache lines and
    invalidate the cache lines if needed, or you will run into trouble.

PI DMA wait

    1. Read PI_STATUS_REG then AND it with 0x3, if its true... then wait until it is not true.

    NOTE: Look at RCP.H for more information on the PI_STATUS_REG and the PI in general.

reading and writing the new sram chip (DS1)

  Sram is mapped at 0xa8000000.
The trick is that you cannot write to it directly, you must us the PI. Actually it is possible to write to it directly, but I dont know how because it
needs to be timed carefully. Its a little tricky which requires writing some values into some PI regs to initialize the PI correctly for the type of
transfer protocol the sram needs for successful data transfer.

Initialize the PI for sram

      1. write 0x05 to the PI_BSD_DOM2_LAT_REG.
      2. write 0x0c to the PI_BSD_DOM2_PWD_REG.
      3. write 0x0d to the PI_BSD_DOM2_PGS_REG.
      4. write 0x02 to the PI_BSD_DOM2_RLS_REG.

Now you should be able to use the PI to transfer between rdram and sram.(refer to the dox above concerning PI, but replace the ROM address with sram address 0xa8000000).