/* bounce.uc * Recv packet on MAC1 port 0 then transmit packet using MAC 1 port 0 */ br!=ctx[0,killit#] .xfer_order $$x0,$$x1,$$x2,$$x3,$$x4,$$x5,$$x6,$$x7 .xfer_order $x0,$x1,$x2,$x3 immed_w0[ledaddr,0x2000] immed_w1[ledaddr,0x74] immed[$x2,0xff] sram[write,$x2,ledaddr,0,1],ctx_swap #include "../init.h" loop#: /* receive loop */ waitloop#: csr[read,$x0,rcv_rdy_cnt] alu_shf[$x2,--,B,$x0,>>24] sram[write,$x2,ledaddr,0,1],ctx_swap alu_shf[--,1,AND,$x0,>>24] /* check fast port ready #1 */ br=0[waitloop#] immed[$x2,0xa0] sram[write,$x2,ledaddr,0,1],ctx_swap notready#: br_inp_state[rec_req_avail,okready#] br[notready#] okready#: immed[$x2,0xa1] sram[write,$x2,ledaddr,0,1],ctx_swap immed_w0[gpr0,0x8] /* mac 1: port 0, signal thread 0 */ immed_w1[gpr0,0x1] /* fast port mode, sequence 1, fifo #1=0, fifo #2=1 */ alu[$x1,--,B,gpr0] csr[write,$x1,rcv_req],ctx_swap ; write to RCV_REQ and block until done ctx_arb[start_receive] ; wait for receive signal from IX Bus csr[read,$x1,rcv_cntl] ; read RCV_CNTL to clear RCV_CNTL FIFO immed[$x2,0xa2] sram[write,$x2,ledaddr,0,1],ctx_swap ; ok, data is in RFIFO, let's get it out and put it in SDRAM immed[gpr0,0,0] ; we'll use this as the dest addr ie put data at ;base of SDRAM ; indirect value for sdram instruction: read the number of quadwords ; from RCV_CNTL immed[gpr1,7,0] ; read 8 - 1 quadwords alu_shf[--,--,B,gpr1,<<16] ; read into sdram, note that the 8 on the end is simply ignored; ; it's replaced by the indirect value sdram[r_fifo_rd,--,0,gpr0,8],indirect_ref,ctx_swap /* transmit */ /* fill tfifo */ /* decide which element to place data in */ csr[read,$x0,xmit_ptr],ctx_swap /* $x0 is now element number */ alu[$x0,0xf,AND,$x0] /* clear reserved area */ /* form indirect reference for sdram, put it in gpr0 */ alu_shf[gpr0,--,B,0x7,<<16] alu_shf[gpr0,gpr0,OR,$x0,<<4] /* gpr0 is the indirect ref for sdram */ /* for indirect reference for fast_wr, put it in gpr1 */ alu_shf[gpr1,--,B,$x0,<<5] alu_shf[gpr1,gpr1,OR,0x1,<<15] /* make gpr2 the addr of the control element then write control data */ immed[gpr2,128] alu_shf[gpr2,gpr2,+,$x0,<<1] /* add 2*element number */ immed[$x0,0xff08] /* control data: 8 qw/8 bytes in last qw & EOP/SOP */ immed[$x1,0] immed[$x2,0] immed[$x3,0] t_fifo_wr[$x0,gpr2,0,2],ctx_swap /* write control data */ /* actually copy data */ alu[--,--,B,gpr0] sdram[t_fifo_wr,--,0, addr,8],indirect_ref,ctx_swap immed[$x2,0xb0] sram[write,$x2,ledaddr,0,1],ctx_swap /* wait for ready to transmit */ //rdywait#: // csr[read,$x0,xmit_rdy_lo],ctx_swap // alu[--,$x0,AND,0x1] //br!=0[rdywait#] immed[$x2,0xbb] sram[write,$x2,ledaddr,0,1],ctx_swap /* send it */ alu[--,--,B,gpr1] /* the tfifo element to use */ fast_wr[0,xmit_validate],indirect_ref br[loop#] killit#: ctx_arb[kill]