/*************************************************************************** LOADER EXAMPLE - TRANSMITTER (PRIMARY PROCESSOR) ***************************************************************************/ /* NOTE: */ /* If you change the program to be booted, you need to change /* the #define size to correspond with the number of lines in the .ldr file */ /* In this case the lsrq.ldr file. */ /* */ /* This file is intended for Rev 0.x */ /* */ /**************************************************************************/ #include "def21060.h" /* CHANGE SIZE ONLY = # of lines in the .ldr file that you include as a variable in this program */ #define size 1584 #define loopsize ((size/3)-256) /* automatically calculates, how many words to send after the */ /* first 256 words */ .SEGMENT/PM irqvects; /* The loader begins with the interrupts up to and including the low */ /* priority timer interrupt. */ NOP;NOP;NOP;NOP; /* Reserved interrupt */ ___lib_RSTI: IDLE; /* Implicit IDLE instruction */ JUMP start (DB); /* Begin loader */ NOP; /* Pad to next interrupt */ NOP; /* Pad to next interrupt */ NOP;NOP;NOP;NOP; /* Reserved interrupt */ /* Vector for status stack/loop stack overflow or PC stack full: */ ___lib_SOVFI: RTI; RTI; RTI; RTI; /* Vector for high priority timer interrupt: */ ___lib_TMZHI: rti; rti;rti;rti; /* Vectors for external interrupts: */ ___lib_VIRPTI: RTI; RTI; RTI; RTI; ___lib_IRQ2I: RTI; RTI; RTI; RTI; ___lib_IRQ1I: RTI; RTI; RTI; RTI; ___lib_IRQ0I: rti; rti;rti;rti; NOP;NOP;NOP;NOP; /* Reserved interrupt */ /* Vectors for Serial port DMA channels: */ ___lib_SPR0I: RTI; RTI; RTI; RTI; ___lib_SPR1I: RTI; RTI; RTI; RTI; ___lib_SPT0I: RTI; RTI; RTI; RTI; ___lib_SPT1I: RTI; RTI; RTI; RTI; /* Vectors for link port DMA channels: */ ___lib_LP2I: RTI; RTI; RTI; RTI; ___lib_LP3I: RTI; RTI; RTI; RTI; /* Vectors for External port DMA channels: */ ___lib_EP0I: RTI; rti; rti; RTI; ___lib_EP1I: RTI; rti; rti; RTI; ___lib_EP2I: RTI; RTI; RTI; RTI; ___lib_EP3I: RTI; RTI; RTI; RTI; /* Vector for Link service request */ ___lib_LSRQ: call lsrqf (db); r4=dm(LSRQ); dm(LSRQ)=r6; /*turn off*/ rti; /* Vector for DAG1 buffer 7 circular buffer overflow */ ___lib_CB7I: RTI; RTI; RTI; RTI; /* Vector for DAG2 buffer 15 circular buffer overflow */ ___lib_CB15I: RTI; RTI; RTI; RTI; /* Vector for lower priority timer interrupt */ ___lib_TMZLI: RTI; RTI; RTI; RTI; .ENDSEG; /* The size of ldata should be changed to match the file that you want to send */ .SEGMENT/pm pm48_2b0; .VAR ldata[size] = "lsrq.ldr"; .ENDSEG; .SEGMENT/pm pm48_1b0; start: ustat1=dm(SYSCON); bit set ustat1 IMDW0X | IMDW1X | IIVT; dm(SYSCON)=ustat1; bit set mode2 FLG0O; /* set FLG0 as an output */ call lload; r2=0x11111111; /* When lbuf4 is empty, disable it */ test: r0=dm(LCOM); btst r0 by 9; if not sz jump test; /* disable lbuf */ r8= 0x0; dm(LCTL)=r8; /* unmask the L4TM */ r5=0x1000; dm(LSRQ)=r5; /* for later masking */ r6=0x0; /* enable LSRQ and interrupts */ bit set imask LSRQI; bit set mode1 IRPTEN; idle; jump (pc,-1); lload: /* r0=0x20000; 1X, 48 bit transfers */ r0 = 0x30000; /* 2X, 48 bit transfers */ dm(LCOM)=r0; r0=0x2c688; /* LBUFx <==> LPORTx */ dm(LAR)=r0; r9=0x90000; /* transmit, lbuf enable */ dm(LCTL)=r9; b0=ldata; l0=0; m0=1; lcntr = 0x100, do link until lce; px1=dm(i0,m0); r0=dm(i0,m0); r1=dm(i0,m0); r0=r0 OR LSHIFT r1 by 16; px2=r0; link: pm(LBUF4)=px; /* Need to split into 2 seperate loops for now. This is because the receiver is going to switch between lbuf4 and lbuf5 between these two loops, and we don't want to lose data. After rev1.0 the receiver should be able to continue using lbuf4 and these two loops combined*/ /* Want to wait and make sure that the receiver has swithed to lbuf5, a set amount of wait time, should be sufficient */ lcntr = 0x100, do waste until lce; nop; nop; waste: nop; /* lcntr should be set to send the rest of the ldr file */ /* (size of file)/3 = number of instructions) */ /* number of instructions - 256 = lcntr for second loop */ /* in this case converted to hex. */ lcntr = loopsize, do link2 until lce; px1=dm(i0,m0); r0=dm(i0,m0); r1=dm(i0,m0); r0=r0 OR LSHIFT r1 by 16; px2=r0; pm(LBUF4)=px; link2: nop; rts; nop; nop; lsrqf: btst r4 by 28; if sz jump no_blink; /* if L4TM, tgl LED and write word out */ bit tgl astat FLG0; dm(LCTL)=r9; /* enable, transmit */ dm(LBUF4)=r2; /* service */ test2: r0=dm(LCOM); btst r0 by 9; if not sz jump test2; dm(LCTL)=r8; /* disable */ no_blink: dm(LSRQ)=r5; /* turn back on */ rts; .ENDSEG;