/*************************************************************************** LOADER EXAMPLE - TRANSMITTER (PRIMARY PROCESSOR) ***************************************************************************/ /* NOTE: */ /* 1 thing needs to be changed each time you change the file */ /* that you want to load. The #define size should be changed to match */ /* the number of lines in the *.ldr file that you are sending over the links. */ /* In this case lsrq.ldr. */ /* */ /* This file is intended for Rev 1.0 and later ONLY */ /* */ /**************************************************************************/ #include "def21060.h" /* CHANGE SIZE ONLY = # of lines in the .ldr file that you include as a variable in this program */ #define size 1542 #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); /* --------------------------------------link boot routine here---------------------------------------------------------------*/ lload: r0 = 0x0; /* 1x; 0x10000 = 2x for lbuf4 */ dm(LCOM)=r0; r0=0x2c688; /* LBUFx <==> LPORTx */ dm(LAR)=r0; r9=0x10090000; /* transmit, lbuf enable */ dm(LCTL)=r9; b0=ldata; l0=0; m0=1; /* --------------------------PART 1 ---------------------------------------------------*/ /* Send first 256 words (link boot routine) */ 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; nop; /*--------------------------PART 2 -----------------------------------------------------*/ /* Wait until the chip is ready for the rest of the program */ /* (wait for booting chip to try to read more data, you don't */ /* want to send data right away because it will be flushed */ /* when the booting chip finishes booting its first 256 words */ /* and begins running its loader routine) */ r0=0x0; r9=0x10090000; /* transmit, lbuf enable */ not_empty: r1=dm(LCOM); /* wait until lbuf4 is empty */ btst r1 by 9; if not sz jump not_empty; bit clr imask LSRQI; /* disable LSRQ interrupts */ dm(LCTL)=r0; /* disable lbuf */ r5=0x1000; dm(LSRQ)=r5; /* unmask L4TM */ poll: r4=dm(LSRQ); /* read LSRQ register */ btst r4 by 28; /* see if there is a transmit request */ if sz jump poll; /* if not keep polling */ dm(LSRQ)=r0; /* mask L4TM */ dm(LCTL)=r9; /* enable LCTL again */ /*--------------------------PART 3 -----------------------------------------------------*/ /* Send rest of the program */ 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; link2: pm(LBUF4)=px; nop; rts; /* return to main program */ nop; nop; /* ------------------------------------------------------end of link boot routine ---------------------------------------------------------------*/ 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;