Example in assembly of a read from system memory:
mc_config_read:
; Configure the MC for a read from memory...
; do not keep ownership (release ownership when
; this single read is done)
rwq REG_STATE(iop_sw_spu, rw_mc_ctrl, keep_owner, no) | \
REG_STATE(iop_sw_spu, rw_mc_ctrl, cmd, rd) | \
; read 4 bytes
REG_FIELD(iop_sw_spu, rw_mc_ctrl, size, 0x4) | \
REG_STATE(iop_sw_spu, rw_mc_ctrl, wr_spu0_mem, no) | \
REG_STATE(iop_sw_spu, rw_mc_ctrl, wr_spu1_mem, no), \
REG_ADDR(iop_sw_spu, iop_sw_spu0, rw_mc_ctrl)
; Read the r_mc_stat MC register
rr REG_ADDR(iop_sw_spu, iop_sw_spu0, r_mc_stat), r15
nop ; Wait one cycle for the update of the r15 register
; Check for ownership...
bbc r15, REG_BIT(iop_sw_spu, r_mc_stat, owned_by_spu0), mc_config
nop ; Delay slot
; Ownership granted, put the system memory address in rw_mc_addr
rw r2, REG_ADDR(iop_sw_spu, iop_sw_spu0, rw_mc_addr)
; Wait for busy bit to go low
mc_config_read_wait:
; Read the r_mc_stat MC register
rr REG_ADDR(iop_sw_spu, iop_sw_spu0, r_mc_stat), r15
nop ; Wait one cycle for the update of the r15 register
; Check busy bit of MC...
bbs r15_misc, REG_BIT(iop_sw_spu, r_mc_stat, busy_spu0), mc_config_read
nop ; Delay slot
; Busy bit is low, read data from external memory
rr REG_ADDR(iop_sw_spu, iop_sw_spu0, rs_mc_data), r1
Example in assembly of a write to system memory:
mc_config_write:
; Configure the MC for a write from memory...
; do not keep ownership (release ownership when
; this single write is done)
rwq REG_STATE(iop_sw_spu, rw_mc_ctrl, keep_owner, no) | \
REG_STATE(iop_sw_spu, rw_mc_ctrl, cmd, wr) | \
; write 4 bytes
REG_FIELD(iop_sw_spu, rw_mc_ctrl, size, 0x4) | \
REG_STATE(iop_sw_spu, rw_mc_ctrl, wr_spu0_mem, no) | \
REG_STATE(iop_sw_spu, rw_mc_ctrl, wr_spu1_mem, no), \
REG_ADDR(iop_sw_spu, iop_sw_spu0, rw_mc_ctrl)
; Read the r_mc_stat MC register
rr REG_ADDR(iop_sw_spu, iop_sw_spu0, r_mc_stat), r15
nop ; Wait one cycle for the update of the r15 register
; Check for ownership...
bbc r15, REG_BIT(iop_sw_spu, r_mc_stat, owned_by_spu0), mc_config_write
nop ; Delay slot
; Ownership granted, put the data in rw_mc_data
rw r1, REG_ADDR(iop_sw_spu, iop_sw_spu0, rw_mc_data)
; Put the system memory address in rw_mc_addr
rw r2, REG_ADDR(iop_sw_spu, iop_sw_spu0, rw_mc_addr)