COMMENT * This file is used to generate boot DSP code for the PCI interface board using a DSP56301 as its main processor. This is Revision 1.4 DSP code. * PAGE 132 ; Printronix page width - 132 columns ; Equates to define the X: memory tables VAR_TBL EQU 0 ; Variables and constants table ARG_TBL EQU $30 ; Command arguments and addresses TIM_TBL EQU ARG_TBL+$30 ; Readout timing parameters TIM_LEN EQU $100 ; Length of TIM_TBL = 256 bytes = 64 entries SC_TBL EQU $100 ; Scatter/Gather table BUSY EQU 0 ; =1 if current block is being read or written N_TABLE EQU 255 ; Number of entries in scatter/gather table NRDFIFO EQU 128 ; Number of 512 pixel chunks in FIFO per ; image block ; Various addressing control registers BCR EQU $FFFFFB ; Bus Control Register DCR EQU $FFFFFA ; DRAM Control Register AAR0 EQU $FFFFF9 ; Address Attribute Register, channel 0 AAR1 EQU $FFFFF8 ; Address Attribute Register, channel 1 AAR2 EQU $FFFFF7 ; Address Attribute Register, channel 2 AAR3 EQU $FFFFF6 ; Address Attribute Register, channel 3 PCTL EQU $FFFFFD ; PLL control register IPRP EQU $FFFFFE ; Interrupt Priority register - Peripheral IPRC EQU $FFFFFF ; Interrupt Priority register - Core ; PCI control register DTXS EQU $FFFFCD ; DSP Slave transmit data FIFO DTXM EQU $FFFFCC ; DSP Master transmit data FIFO DRXR EQU $FFFFCB ; DSP Receive data FIFO DPSR EQU $FFFFCA ; DSP PCI Status Register DSR EQU $FFFFC9 ; DSP Status Register DPAR EQU $FFFFC8 ; DSP PCI Address Register DPMC EQU $FFFFC7 ; DSP PCI Master Control Register DPCR EQU $FFFFC6 ; DSP PCI Control Register DCTR EQU $FFFFC5 ; DSP Control Register ; Port E is the Synchronous Communications Interface (SCI) port PCRE EQU $FFFF9F ; Port Control Register PRRE EQU $FFFF9E ; Port Direction Register PDRE EQU $FFFF9D ; Port Data Register ; Various PCI register bit equates STRQ EQU 1 ; Slave transmit data request (DSR) SRRQ EQU 2 ; Slave receive data request (DSR) HACT EQU 23 ; Host active, low true (DSR) MTRQ EQU 1 ; Set whem master transmitter is not full (DPSR) MARQ EQU 4 ; Master address request (DPSR) TRTY EQU 10 ; PCI Target Retry (DPSR) ; The DCTR host flags are written by the DSP and read by PCI host DCTR_RPLY EQU 3 ; Set after reply DCTR_BUF0 EQU 4 ; Set after buffer 0 is written to DCTR_BUF1 EQU 5 ; Set after buffer 1 is written to INTA EQU 6 ; Request PCI interrupt ; The DSR host flags are written by the PCI host and read by the DSP DSR_BUF0 EQU 4 ; PCI host sets this when copying buffer 0 DSR_BUF1 EQU 5 ; PCI host sets this when copying buffer 1 ; DPCR bit definitions CLRT EQU 14 ; Clear transmitter MACE EQU 18 ; Master access counter enable IAE EQU 21 ; Insert Address Enable ; Addresses of ESSI port TX00 EQU $FFFFBC ; Transmit Data Register 0 SSISR0 EQU $FFFFB7 ; Status Register CRB0 EQU $FFFFB6 ; Control Register B CRA0 EQU $FFFFB5 ; Control Register A ; SSI Control Register A Bit Flags TDE EQU 6 ; Set when transmitter data register is empty ; Miscellaneous addresses RDFIFO EQU $FFFFFF ; Read the FIFO for incoming fiber optic data TCSR0 EQU $FFFF8F ; Triper timer control and status register 0 TCSR1 EQU $FFFF8B ; Triper timer control and status register 1 TCSR2 EQU $FFFF87 ; Triper timer control and status register 2 ; Phase Locked Loop initialization PLL_INIT EQU $750012 ; PLL = 33 MHz x 19 / 8 = 78.4 MHz ; Port C is Enhanced Synchronous Serial Port 0 PCRC EQU $FFFFBF ; Port C Control Register PRRC EQU $FFFFBE ; Port C Data direction Register PDRC EQU $FFFFBD ; Port C GPIO Data Register ; Port D is Enhanced Synchronous Serial Port 1 PCRD EQU $FFFFAF ; Port D Control Register PRRD EQU $FFFFAE ; Port D Data direction Register PDRD EQU $FFFFAD ; Port D GPIO Data Register ; Bit number definitions of GPIO pins on Port C ROM_FIFO EQU 2 ; Select ROM or FIFO accesses for AA1 ; Bit number definitions of GPIO pins on Port D EF EQU 0 ; FIFO Empty flag, low true HF EQU 1 ; FIFO half full flag, low true RS EQU 2 ; FIFO reset signal, low true FSYNC EQU 3 ; High during image transmission MODE EQU 4 ; 1 for 32-bit reply data, 0 for 16-bit image WRFIFO EQU 5 ; Low true if FIFO is being written to ; STATUS bit definitions ODD_EVEN EQU 0 ; Block number 0 or 1 in image transfers SCATTERING EQU 1 ; Still Scattering the image if set GATHERING EQU 2 ; Still Gathering the image if set RDI EQU 3 ; Set to start reading an image DOWNLOAD_PCI EQU 4 ; Set to download PCI DSP code ; TIM_STAT = timing board status and configuration word SHUTTER EQU 11 ; Special address for two words for the DSP to bootstrap code from the EEPROM IF @SCP("DOWNLOAD","ROM") ; Boot from ROM on power-on ORG P:0,P:0 DC END_ADR-INIT-2 ; Number of boot words DC INIT ; Starting address ORG P:0,P:2 INIT JMP $0000,X:DPMC ; Subsystem ID MOVEP #>$0000,X:DPAR ; Subsystem Vendor ID ; PCI Personal reset MOVEP X0,X:DCTR ; Personal software reset NOP NOP JSET #HACT,X:DSR,* ; Test for personal reset completion MOVE P:(*+3),X0 ; Trick to write "JMP $000001,X:DPMC BSET #20,X:DCTR ; HI32 mode = 1 => PCI BCLR #21,X:DCTR BCLR #22,X:DCTR NOP BSET #MACE,X:DPCR ; Master access counter enable BSET #IAE,X:DPCR ; Insert PCI address before data NOP ; End of PCI programming ; Set operation mode register OMR to normal expanded MOVEC #$0000,OMR ; Operating Mode Register = Normal Expanded MOVEC #0,SP ; Reset the Stack Pointer SP ; Move the table of constants from P: space to X: space MOVE #CONSTANTS_TBL_START,R1 ; Start of table of constants MOVE #2,R0 ; Leave X:0 for STATUS DO #CONSTANTS_TBL_LENGTH,L_WRITE MOVE P:(R1)+,X0 MOVE X0,X:(R0)+ ; Write the constants to X: L_WRITE ; Program the serial port ESSI0 = Port C for serial transmission to ; the timing board MOVEP #>0,X:PCRC ; Software reset of ESSI0 MOVEP #$000809,X:CRA0 ; Divide 78.4 MHz by 20 to get 3.92 MHz ; DC0-CD4 = 0 for non-network operation ; WL0-WL2 = ALC = 0 for 2-bit data words ; SSC1 = 0 for SC1 not used MOVEP #$010120,X:CRB0 ; SCKD = 1 for internally generated clock ; SHFD = 0 for MSB shifted first ; CKP = 0 for rising clock edge transitions ; TE0 = 1 to enable transmitter #0 ; MOD = 0 for normal, non-networked mode ; FSL1 = 1, FSL0 = 0 for on-demand transmit MOVEP #%101000,X:PCRC ; Control Register (0 for GPIO, 1 for ESSI) ; Set SCK0 = P3, STD0 = P5 to ESSI0 MOVEP #%010111,X:PRRC ; Data Direction Register (0 for In, 1 for Out) MOVEP #%000101,X:PDRC ; Data Register - ROM/FIFO* = 0, SC02 = 0, ; AUX1 = 0, AUX2 = AUX3 = 1 ; Conversion from software bits to schematic labels for Port C and D ; PC0 = SC00 = AUX3 PD0 = SC10 = EF* ; PC1 = SC01 = ROM/FIFO* PD1 = SC11 = HF* ; PC2 = SC02 = AUX2 PD2 = SC12 = RS* ; PC3 = SCK0 = Serial clock PD3 = SCK1 = FSYNC* ; PC4 = SRD0 = AUX1 PD4 = SRD1 = MODE ; PC5 = STD0 = Serial data PD5 = STD1 = WRFIFO* ; Program the serial port ESSI1 = Port D for general purpose I/O (GPIO) MOVEP #%000000,X:PCRD ; Control Register (0 for GPIO, 1 for ESSI) MOVEP #%010100,X:PRRD ; Data Direction Register (0 for In, 1 for Out) MOVEP #%010000,X:PDRD ; Data Register - Pulse RS* low, MODE = 1 REP #10 NOP MOVEP #%010100,X:PDRD ; Program the SCI port to benign values MOVEP #%000,X:PCRE ; Port Control Register = GPIO MOVEP #%110,X:PRRE ; Port Direction Register (0 = Input) MOVEP #%110,X:PDRE ; Port Data Register ; PE0 = RXD ; PE1 = TXD ; PE2 = SCLK ; Program the triple timer to assert TCI0 as an GPIO output = 1 MOVEP #$2800,X:TCSR0 MOVEP #$2800,X:TCSR1 MOVEP #$2800,X:TCSR2 ; Program the AA1 pin to read the FIFO memory for incoming timing board data MOVEP #$FFFC21,X:AAR1 ; Y = $FFF000 to $FFFFFF asserts AA1 low true ; Program the DRAM memory access and addressing MOVEP #$000020,X:BCR ; Bus Control Register MOVEP #$893A05,X:DCR ; DRAM Control Register MOVEP #$000122,X:AAR2 ; Y: $000000 to $7FFFFF asserts AA2 MOVEP #$800122,X:AAR0 ; Y: $800000 to $FFFFFF asserts AA0 MOVEP #$000112,X:AAR3 ; X: $000000 to $7FFFFF asserts AA3 ; Exercise the data lines a little to fill them with electrons MOVE #$20000,R0 MOVE #15000000,X1 MOVE #$FFFFFF,X0 DO X1,INIT_DRAM MOVE X0,Y:(R0)+ INIT_DRAM ; Initialize the fiber optic serial transmitter to zero JCLR #TDE,X:SSISR0,* MOVEP #$000000,X:TX00 ; Clear out the PCI receiver and transmitter FIFOs BSET #CLRT,X:DPCR ; Clear the transmitter JSET #CLRT,X:DPCR,* ; Wait for the clearing to be complete CLR0 JCLR #SRRQ,X:DSR,CLR1 ; Wait for the receiver to be empty MOVEP X:DRXR,X0 ; Read receiver to empty it NOP JMP clear the FIFO CHK_ERR MOVEP #%010000,X:PDRD ; Clear RS* low for 2 milliseconds MOVE #200000,Y0 DO Y0,R_FIFO NOP R_FIFO MOVEP #%010100,X:PDRD ; Data Register - Set RS* high ; Check for the Read Image bit in the STATUS word. This is a way to avoid ; putting the READ_IMAGE routine in an interrupt service routine. GET_RDI JCLR #RDI,X:= $20 JLT 16-bit word address ADD #(ARG_TBL-$10),A ; DSP addr = (PCI addr.-$20)/2 + ARG_TBL NOP ; Pipeline restriction MOVE A1,R0 JCLR #SRRQ,X:DSR,* ; Wait for receiver to be not empty MOVEP X:DRXR,A ; MSW of PCI address ; Get the data number and write it to the argument table JCLR #SRRQ,X:DSR,* ; Wait for receiver to be not empty MOVEP X:DRXR,X0 ; Get least significant word JCLR #SRRQ,X:DSR,* MOVEP X:DRXR,X1 ; Get most significant word MOVE X1,X:(R0)+ ; Store MSW in the argument table MOVE X0,X:(R0) ; Store LSW in the argument table MOVE R0,A CMP #COMMAND_LSW,A ; Is it a command? JEQ A1 MOVE A1,X:(R0) ; Write to the PCI timing table JSR 5000 JGT *+2 BSET #RDI,X:NRDFIFO,X0 ; Number of 512 pixel FIFO chunks MOVE X0,X: DRAM SCATTER3 MOVE X: DRAM SCATTER8 BCLR #BUSY,X:(R2) ; We're done scattering this block BCLR #SCATTERING,X: error MOVE X: X1,X0 JMP error MOVE X: error MOVE X: error MOVE X: A1 JSR 'E',X1 JSR 'D',X1 JSR 'E',X1 JMP 'D',X1 FINISH1 JSR X0 and X1 MOVE A1,B AND #$00FFFF,B MOVE B1,X0 ; Least significant word - X0 MOVE A1,B LSR #16,B NOP MOVE B1,X1 ; Most significant word = X1 RTS ; Subroutine to encode memory type in the address ENC_ADR MOVE X: reset NOP DO #3,L_RESET JCLR #TDE,X:SSISR0,* ; Three data bytes = anything MOVEP A1,X:TX00 NOP L_RESET JCLR #TDE,X:SSISR0,* ; Zeroes to bring TX00 low MOVEP #$000000,X:TX00 ; Now wait around for the 'SYR' reply from system reset and the 'DON' ; reply from the Load Application command JSR 'S',X1 JSR ARG_TBL WARN 'The parameter table is too big!' ENDIF ORG X:ARG_TBL,P: ; Table that contains the command arguments PCI address COMMAND_MSW DC 0 ; Manual command $20 COMMAND_LSW DC 0 ; Most significant word NUM_ARG DC 0 ; Number of command arguments $24 COM_DEST DC 0 ; Command destination ARG1_MSW DC 0 ; First command argument $28 ARG1_LSW DC 0 ARG2_MSW DC 0 ; Second command argument $2C ARG2_LSW DC 0 ARG3_MSW DC 0 ; Third command argument $30 ARG3_LSW DC 0 ARG4_MSW DC 0 ; Fourth command argument $34 ARG4_LSW DC 0 ARG5_MSW DC 0 ; Fifth command argument $38 ARG5_LSW DC 0 DC 0 ; Reserved $3C DC 0 ADR_BLOCK_0_B1 DC 0 ; Block #1 address $40 ADR_BLOCK_0_B0 DC 0 ADR_BLOCK_1_B1 DC 0 ; Block #2 address $44 ADR_BLOCK_1_B0 DC 0 ; $48 - $7C are available ; Check that the argument table is not too big IF @CVS(N,*)>TIM_TBL WARN 'The argument table is too big!' ENDIF ORG X:TIM_TBL,P: ; Timing board table - 64 locations maximum = $100 bytes PCI address EXPTIME DC 0 ; Exposure time in millisec $80 TIM_STAT DC 0 ; Controller options $84 CAM_STATUS DC 0 ; Dummy in timing code $88 NCOLS DC 0 ; Number of columns in image $8C NROWS DC 0 ; Number of rows in image $90 NCBIN DC 0 ; Number of columns binned $94 NRBIN DC 0 ; Number of rows binned $98 UNUSED0 DC 0 UNUSED1 DC 0 UNUSED2 DC 0 UNUSED3 DC 0 UNUSED4 DC 0 UNUSED5 DC 0 UNUSED6 DC 0 ; Check that the timing table is not too big IF @CVS(N,*)>TIM_TBL+TIM_LEN/4 WARN 'The timing table is too big!' ENDIF ; ********************************************************************** ; SCATTER / GATHER - Block addressing table ; bit #: 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ; ---------- Block Number 23 to 2 ----------------------- Busy ; The table has 254 entries to manage the 16 Mpixel image memory in blocks ; that are each 65k pixels in size. Each entry of the table occupies one ; 24-bit DSP memory word. ; Busy : Set if the block is currently being read from or written to ; Block number - 23-bit block number in image of image data written ; ; If Busy = 1 then the block is currently being written to or read from ; and must not be accessed except by its owner. ; If block number = Busy = 0 then the block is available for writing ; FIFO data into it. ; If block number .NE. 0 then it contains FIFO data and should be written ; to the host in order of block numbers. ; ; ********************************************************************** ORG X:SC_TBL,P: X_TABLE DC 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; $80 locations for SG Table DUP 7 DC 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ENDM ; ********************************************************************** ; End of program END