|
************************************************************************* *** *** VC5409 Bootloader Software : Version 1.02 *** Origin Date : 4/22/99 *** Author(s) : PMJ2 *** ************************************************************************* *** *** This code sets up and executes the VC5409 Bootloader. *** *** Revision History: *** ---------------- *** 1.00 Modified the VC5402 bootloader for use PMJ2 04/22/98 *** on the VC5409. Includes new HPI boot mode, *** and added McBSP2 code. Includes bug fix *** in 8bit parallel mode. Includes bug fix *** in 8-bit I/O mode, Includes the 8bit *** standard serial mode, by changing the *** initialization of RCR11 and XCR11 from *** 040h to 0h. Added a SPI EEPROM bootmode, *** which is selected via the INT3 flag *** (See notes on SPI boot mode below). *** Added code to toggle the BDX2 pin during *** init, to provide a high-to-low transition *** that can be used to drive INT3 for selection *** of the SPI boot mode. *** *** 1.01 Modified SPI boot. PMJ2 09/23/99 *** If the first 8bits are not (08h), *** the boot loader will branch to the parallel boot modes. *** If the second 8bits are not (AAh), the bootloader *** will branch to the McBSP serial boot initialization. *** The DX2 pin now toggles instead of the DX1 pin. *** *** 1.02 Modified Parallel 8-bit. PMJ2 12/06/99 *** Modified I/O 8-bit boot modes. *** In the parallel 8-bit mode, the AG and AH *** are forced to zero for correct evaluation. *** In the 8-bit I/O mode, the XPC *** destination addr is correclty saved. *** The BG and BH are forced to zero *** for correct evaluation. The SPI mode boot *** branches to the parallel boot after failure *** of the first condition (08) and second condition (AA). *** Reset McBSP2 before DX pins toggles. (for debugging) ******************************************************************** *** --------------- Notes on '5409 HPI Boot Mode --------------- *** The new HPI boot mode allows the host to load the on-chip RAM *** after the '5409 is reset. The boot-mode also allows the host *** to specify an entry point at load-time. After completing the *** bootload process, the host must make another HPI access to load *** the entry point to location 07Fh of on-chip RAM. This is how it *** works: after reset, the bootloader initializes address 07Fh to *** zero, then polls this location for a change while the host is *** loading the code. When the bootloader detects a change in the *** contents of address 07Fh, it performs a branch using the contents *** as the destination address. *** This new mode doesn't require the INT2 flag for selection. If the *** INT2 pin is not used to select HPI boot mode, the bootloader *** periodically checks various boot sources, including HPI, until a *** boot condition is detected. Alternatively, the INT2 flag can be *** used to force the bootloader to ignore all boot sources other *** than HPI. If the INT2 flag is to be used, a high to low transition *** is required on the INT2 pin within 30 cycles after the '5409 is *** reset. ************************************************************************* *** --------------- Notes on '5409 SPI Boot Mode --------------- *** The SPI boot mode allows the '5409 to boot from an 8-bit serial *** EEPROM using the SPI protocol. The mode is selected at reset via *** the INT3 external interrupt . Proper selection of the boot mode *** requires a high to low transition on the INT3 pin within 30 CPU *** cycles after the '5409 is reset. *** *** The EEPROM must be connected to McBSP2 as follows: *** McBSP2 EEPROM *** ****** ****** *** BCLKX SCK *** BFSX /CS *** BDX SI *** BDR SO *** XF /HOLD (Optional - disables EEPROM when done) *** *** The boot table used for programming the EEPROM is generated *** using the 8bit serial option of the Hex conversion utility. *** example: *** -bootorg SERIAL *** -memwidth 8 *************************************************************************
.title "bootVC5409" .mmregs .version 548 .def boot .def endboot .def bootend .def dest .def src .def lngth .def hbyte .ref SPI_INIT, SPI_READ, SPI_WRITE .ref SPI_RDSR, SPI_WRSR
************************************* pa0 .set 0H ; port address 0h for i/o boot load
xentry .set 61H ; XPC of entry point entry .set 62H ; entry point hbyte .set 63H ; high byte of 8-bit serial word p8word .set 64H ; concatenator for 8-bit memory load src .set 65H ; source address dest .set 66H ; destination address (dmov from above) xdest .set 67H ; XPC of destination address. lngth .set 68H ; code length temp0 .set 69H ; temporary register0 temp1 .set 6aH ; temporary register1 temp2 .set 6bH ; temporary register2 temp3 .set 6cH ; temporary register3
HPIentry .set 7Fh ; Entry point for HPI boot.
*********************************************** * MMR definition for c54xlp peripherals * *------------- MCBSP0 ----------------------* drr10 .set 21H ; Data Receive Register dxr10 .set 23H ; Data Transmit Register SPSA0 .set 0038H ; Serial Port 0 Sub-bank Address Register SPSD0 .set 0039H ; Serial Port 0 Sub-bank Data Register
*------------- MCBSP1 ----------------------* drr11 .set 41H ; Data Receive Register dxr11 .set 43H ; Data Transmit Register SPSA1 .set 0048H ; Serial Port 1 Sub-bank Address Register SPSD1 .set 0049H ; Serial Port 1 Sub-bank Data Register
*------------- MCBSP2 ---------------------- drr12 .set 31H ; Data Receive Register dxr12 .set 33H ; Data Transmit Register SPSA2 .set 0034H ; Serial Port 2 Sub-bank Address Register SPSD2 .set 0035H ; Serial Port 2 Sub-bank Data Register
*----------- MCBSP CONTROL REGS --------------* SPCR1_SUBADDR .set 0000H ; Serial Port Control Register 1 (subaddress) SPCR2_SUBADDR .set 0001H ; Serial Port 1 Control Register 2 (subaddress) RCR1_SUBADDR .set 0002H ; Receive Control Register 1 (subaddress) RCR2_SUBADDR .set 0003H ; Receive Control Register 2 (subaddress) XCR1_SUBADDR .set 0004H ; Transmit Control Register 1 (subaddress) XCR2_SUBADDR .set 0005H ; Transmit Control Register 2 (subaddress) SRGR1_SUBADDR .set 0006H ; Sample Rate Genarator Register 1 (subaddress) SRGR2_SUBADDR .set 0007H ; Sample Rate Genarator Register 2 (subaddress) PCR_SUBADDR .set 000EH ; Pin Control Register (subaddress)
*-------------- Other contants ---------------* int2msk .set 0004H ; INT2_ bit position on IFR int3msk .set 0100H ; INT3_ bit position in IFR/IMR
********************************************************** * bootloader ********************************************************** .sect "boot" boot ssbx intm ; disable all interrupts stm #0FFFFh,@ifr ; clear IFR flag ld #0, dp orm #02b00h, @st1 ; xf=1, hm=0, intm=1, ovm=1, sxm=1 orm #020h, @pmst ; ovly=1 stm #07fffh, swwsr ; 7 wait states for P_,D_, and I_ spaces stm #0007dh, sp ; Use top part of scratch-pad RAM for stack.
***************************************************************** * RDP, Modified old HPI boot check to support host loading * after reset. Initialize HPI boot entry point to 0. The host * will change the value of this location after loading RAM. ***************************************************************** stm #0, @HPIentry ; Set HPI entry to known value. stm #08h, hpic ; Set HINT pin low. Ok to start ; host load. ***************************************************************** * Toggling the BDX pin on McBSP2. This pin can be used to * drive /INT3 and select the SPI boot mode, without requiring * an external signal. *****************************************************************
stm SPCR2_SUBADDR,SPSA2 stm #0000h,SPSD2 ; DISABLES TRANSMIT. (reset)1.02
stm #PCR_SUBADDR, SPSA2 stm #02000h, SPSD2 ; Set DX low.
stm #PCR_SUBADDR, SPSA2 stm #02020h, SPSD2 ; Set DX high. rpt #5 ; Keep high a while. nop stm #02000h, SPSD2 ; Set DX low.
rpt #5 ; wait several cycles nop ; before checking INT2 bitf @ifr, #int2msk ; Check if INT2_ flag is set nop bc HPI, tc ; If int2 is set then HPI boot.
bitf @ifr, #int3msk ; Else, check if INT3_ flag is set nop bc SPIBOOT, tc ; If int3 is set then SPI boot.
b parallel ; Otherwise, check other boot modes. ***************************************************************** * HPI boot mode selected through int2. ***************************************************************** HPI ; Else, this is an HPI boot, all ; other boot modes are ignored. stm #int2msk, ifr ; Clear INT2_ bit in ifr.
ldm HPIentry, a ; Get HPI entry vector. bc hpiboot, aneq ; If not zero, HPI boot. b $-3 ; else, keep looping.
***************************************************************** * Check Parallel Boot ***************************************************************** parallel stm #0h, @xentry ; initialize the entry point stm #boot, @entry ; portr #0ffffh, @src ; read source address of boot table mvdk @src, ar1 ; ar1 points at source memory (Data) ld *ar1+, a ; load accumulator A with BRW sub #10AAh, a, b ; check 16-bit Boot? bc par16, beq ; a=010AAh and #0ffh, a ; check acc AL = 08 sub #8h, a, b ; check 8-bit Boot? bc chk_data, bneq ; a=08xxh ld *ar1+, a ; 8-bit mode, LSB and #0ffh, a ; check acc AL = AAh sub #0AAh, a ; LSB = 0AAh? bc par08, aeq ; 8-bit Parallel Boot chk_data stm #0FFFFh, ar1 ; check data memory 0xFFFF nop ; prevent pipeline conflict nop ; ld *ar1+, a ; load accumulator A with BRW stlm a, ar1 ; ar1 point at source memory (Data) nop ; prevent posibble pipeline conflic nop ; ld *ar1+, a ; load acculator A with BRW sub #10AAh, a, b ; check 16-bit Boot? bc par16, beq ; a=010AAh stm #0FFFFh, ar1 ; check data memory 0xFFFF & 0xFFFE nop ; prevent possible pipeline conflic nop ; ldu *ar1-, a ; acc A <-- source address and #0FFh, a ; 0 the high byte add *ar1, 8, a ; stlm a, ar1 ; nop ; prvent possible pipeline conflic nop ; ld *ar1+, a ; load accumulator A with BRW and #0ffh, a ; check acc AL = 08h sub #8h, a, b ; check 8-bit Boot? bc ser_ini, bneq ; acc A = 08xxh ld *ar1+, a ; 8-bit mode, LSB and #0ffh, a ; check acc AL = AAh sub #0AAh, a ; LSB = 0AAh? bc par08, aeq ; 8-bit Parallel Boot
ser_ini ******************************************************************************** * * Initialization for 5409 McBSPs * ******************************************************************************** * * 1. McBSP0 is configured for 16-bit, BCLKX input, BFSX input. * ******************************************************************************** * STM SPCR1_SUBADDR,SPSA0 STM #0000h,SPSD0 ; DISABLES RECEIVE. STM SPCR2_SUBADDR,SPSA0 STM #0000h,SPSD0 ; DISABLES TRANSMIT.
STM RCR1_SUBADDR,SPSA0 ; Set the receive word length to 16-bit. STM #0040H,SPSD0 STM RCR2_SUBADDR,SPSA0 ; Set the receive word length to 16-bit. STM #0041H,SPSD0 ; Single Phase, 16-bit, No Compan,1bit *Delay.
STM SRGR1_SUBADDR,SPSA0 STM #0000H,SPSD0 ; Clear the clkdiv and frame width.
STM SRGR2_SUBADDR,SPSA0 STM #0000H,SPSD0 ; Clksm=0 External source.
STM PCR_SUBADDR,SPSA0 STM #0000H,SPSD0 ; BCLKX and FSX configured as inputs STM SPCR1_SUBADDR,SPSA0 STM #0001H,SPSD0 ; ENABLES RECEIVE. ******************************************************************************** * 2. McBSP1 is configured for 16-bit, clk input, fm input. * ******************************************************************************** STM SPCR1_SUBADDR,SPSA1 STM #0000h,SPSD1 ; DISABLES RECEIVE.
STM SPCR2_SUBADDR,SPSA1 STM #0000h,SPSD1 ; DISABLES TRANSMIT.
STM RCR1_SUBADDR,SPSA1 ; Set the receive word length to 16-bit. STM #0040H,SPSD1 STM RCR2_SUBADDR,SPSA1 ; Set the receive word length to 16-bit. STM #0041H,SPSD1 ; Single Phase, 16-bit, No Compan,1bit *Dela.y
STM SRGR1_SUBADDR,SPSA1 STM #0000H,SPSD1 ; Clear the clkdiv and frame width.
STM SRGR2_SUBADDR,SPSA1 STM #0000H,SPSD1 ; Clksm=0 External source.
STM PCR_SUBADDR,SPSA1 STM #0000H,SPSD1 ; BCLKX and FSX configured as inputs STM SPCR1_SUBADDR,SPSA1 STM #0001H,SPSD1 ; ENABLES RECEIVE. ******************************************************************************** * 3. McBSP2 is configured for 8-bit, clk input, fm input. * ******************************************************************************** STM SPCR1_SUBADDR,SPSA2 STM #0000h,SPSD2 ; DISABLES RECEIVE.
STM SPCR2_SUBADDR,SPSA2 STM #0000h,SPSD2 ; DISABLES TRANSMIT.
STM RCR1_SUBADDR,SPSA2 ; Set the receive word length to 8-bit. STM #0000H,SPSD2 STM RCR2_SUBADDR,SPSA2 ; Set the receive word length to 8-bit. STM #0001H,SPSD2 ; Single Phase, 8-bit, No Compan,1bit *Del.ay
STM SRGR1_SUBADDR,SPSA2 STM #0000H,SPSD2 ; Clear the clkdiv and frame width.
STM SRGR2_SUBADDR,SPSA2 STM #0000H,SPSD2 ; Clksm=0 External source.
STM PCR_SUBADDR,SPSA2 STM #0000H,SPSD2 ; BCLKX and FSX configured as inputs STM SPCR1_SUBADDR,SPSA2 STM #0001H,SPSD2 ; ENABLES RECEIVE. ******************************************************************************** rsbx xf ; signal ready-to-receive chk_ser bitf ifr, #400h ; check RINT1 flag cc BSP1, tc ; bitf ifr, #40h ; check RINT2 flag cc BSP2, tc ; bitf ifr, #10h ; check RINT0 flag cc BSP0, tc ; bc pasyini, bio ; check for I/O boot **************RDP*************** * Add HPI entry check here. * ******************************** ldm HPIentry, a ; Get HPI entry vector. bc hpiboot, aneq ; If not zero, HPI boot. b chk_ser ; else, keep looping. ******************************** ***************************************************************** * End-boot, simply branch to source address * ***************************************************************** endboot ldu @entry,a ; branch to the entry point add @xentry,16,a ; hpiboot fbacc a
***************************************************************** * Bootload from 8-bit memory, MS byte first * *****************************************************************
par08 ld *ar1+, 8, a ; read MSB of SWWSR value mvdk *ar1+, ar3 ; read LSB of SWWSR value andm #0ffh, @ar3 ; Mask off upper 8-bits or @ar3, a ; Concatenate stlm a,swwsr ; store A to SWWSR
ld *ar1+, 8, a ; read MSB of BSCR value mvdk *ar1+, ar3 ; read LSB of BSCR value andm #0ffh, @ar3 ; Mask off upper 8-bits or @ar3, a ; Concatenate stlm a,bscr ; store A to BSCR
ld *ar1+, 8, a ; read MSB of XPC of entry addr mvdk *ar1+, ar3 ; read LSB andm #0ffh, @ar3 ; Mask off upper 8-bits or @ar3, a ; Concatenate stl a,@xentry ; stor A to xentry
ld *ar1+, 8, a ; read MSB of entry address mvdk *ar1+, ar3 ; read LSB andm #0ffh, @ar3 ; Mask off upper 8-bits or @ar3, a ; Concatenate stl a,@entry ; stor A to entry
par08_1 ld *ar1+, 8, a ; get MSB of block size (16-bit words) and #0ff00h, a ; Clear grd bits, and upper word. Rev1.01 mvdk *ar1+, ar3 ; read LSB andm #0ffh, @ar3 ; Mask off upper 8-bits or @ar3, a ; Concatenate bcd endboot,aeq ; section size =0 indicate boot end sub #1,a,b ; brc = section size - 1 stlm b, brc ; update block repeat counter register
ld *ar1+, 8, a ; get MSB of XPC of destination mvdk *ar1+, ar3 ; read LSB andm #0ffh, @ar3 ; Mask off upper 8-bits or @ar3, a ; Concatenate stl a,@dest ; @dest <-- XPC
ld *ar1+, 8, a ; get MSB of destinationaddress ************* Bug fix ****************************************************** and #0ff00h,a ;force AG, AH to zero for correct calculation ;of the 23-bit destination address. ;(11/10/99 PMJ2) 1.02 **************************************************************************** mvdk *ar1+, ar3 ; read LSB andm #0ffh, @ar3 ; Mask off upper 8-bits or @ar3, a ; Concatenate add @dest,16,a ; acc A <-- 23-bit destination address
rptb xfr08-1 ld *ar1+, 8, b ; read MSB of data mvdk *ar1+, ar3 ; read LSB of data andm #0ffh, @ar3 ; Mask off upper 8-bits or @ar3, b ; Concatenate
rpt #10 ;insert at least 10 cycles nop ; between read and write
writa BL ; write object data to destination add #1, a ; increment destination address
xfr08 b par08_1
***************************************************************** * Bootload from 16-bit memory * *****************************************************************
par16 ld *ar1+, a ; read desired value of SWWSR stlm a, @swwsr ; store in SWWSR
ld *ar1+, a ; read desired value of BSCR and #0FFFEh,a ; ensure EXIO bit is off stlm a, @bscr ; store in BSCR
ld *ar1+, a ; read XPC of entry point address stl a, @xentry ; and store
ld *ar1+, a ; read low 16-bits of entry point addr stl a, @entry ; and store
par16_1 ld *ar1+,a ; load the size of section to A bcd endboot,aeq ; section size =0 indicate boot end sub #1,a,b ; brc = section size - 1 stlm b, brc ; update BRC ld *ar1+,a ; get the XPC of destination (A22-A16) stl a,@dest ; store XPC at data memory @dest ldu *ar1+,a ; get address of destination in A(15-0) stlm a,ar2 ; store dest address at ar2 add @dest,16,a ; acc A <--- 23-bit destination address
rptb xfr16-1 mvdk *ar1+, ar3 ; read object data
rpt #10 ;insert at least 10 cycles nop ; between read and write
writa @ar3 ; write object data to destination add #1,a ;increment desintation address xfr16 b par16_1
***************************************************************** * Bootload from McBSP serial port * *****************************************************************
ser_in rsbx tc ; clear flag bcd $, ntc ; begin receive data routine BITF *AR6,#0002h ; Bit test on RRDY. Reception of a new word. RET
BSP0 STM SPCR1_SUBADDR,SPSA0 ; Set up to read the value of the STM SPSD0,AR6 ; SPCR10 reg, RRDY. stm #drr10,ar1 ; ar1 <-- drr0 stm #010h, @ifr ; clear BRINT0 flag b SP_in_16 ; check BSP BSP1 STM SPCR1_SUBADDR,SPSA1 ; Set up to read the value of the STM SPSD1,AR6 ; SPCR10 reg, RRDY. stm #drr11,ar1 ; ar1 <-- drr0 stm #0400h, @ifr ; clear BRINT1 flag b SP_in_16 ; check BSP
BSP2 STM SPCR1_SUBADDR,SPSA2 ; Set up to read the value of the STM SPSD2,AR6 ; SPCR10 reg, RRDY. stm #drr12,ar1 ; ar1 <-- drr0 stm #040h, @ifr ; clear BRINT2 flag b SP_in_8 ; check BSP
***************************************************************** * McBSP Bootload in 16-bit mode * *****************************************************************
SP_in_16 ldm *ar1, a ; acc A <-- DRR sub #10AAh, a, b ; acc A = 0x10AA ? bc ser_in_16, beq ; 16-bit serial mode ret
ser_in_16 ;The dummy words are read to maintain ; hex converter compatibility with ; the 548/549
call ser_in ; call SP input sub mvdk *ar1, temp0 ; temp0 <-- drr0 (DUMMY WORD) call ser_in ; call SP input sub mvdk *ar1, temp1 ; temp1 <-- drr0 (DUMMY WORD) call ser_in ; call SP input sub mvdk *ar1, temp2 ; temp2 <-- drr0 (DUMMY WORD) call ser_in ; call SP input sub mvdk *ar1, temp3 ; temp3 <-- drr0 (DUMMY WORD)
call ser_in ; call SP input sub mvdk *ar1, xentry ; xentry <-- drr0 (XPC of entry point)
call ser_in ; call SP input sub mvdk *ar1, entry ; temp0 <-- drr0 (entry point)
SP16_in_1 call ser_in ; call SP input sub ldu *ar1, a ; acc A <-- drr0 (section size) bcd endboot,aeq ; section size =0 indicate boot end sub #1,a,b ; brc = section size - 1 stlm b, brc ; update block repeat counter register call ser_in ; call SP input sub mvdk *ar1, dest ; xentry <-- drr0 (XPC of dest) call ser_in ; call SP input sub ldu *ar1, a ; acc A <-- destination addr add @dest, 16, a ; rptb sfxr16_in-1 call ser_in ; call SP input sub ldu *ar1, b ; acc B <-- drr0 (input dada) writa @BL ; [acc A] <-- acc BL add #1, a ; increment dest add sfxr16_in b SP16_in_1 ; check next section
***************************************************************** * 8-bit mode input clk,frm * ***************************************************************** DBsreadA call ser_in ; call SP input sub ld *ar1, 8, a ; acc A <-- junkbyte.high byte and #0ff00h, a ; acc A <-- high.byte stl a, @hbyte ; save high byte call ser_in ; call SP input sub ldu *ar1, a ; acc A <-- junkbyte.low byte and #0ffh, a ; acc A <-- low byte or @hbyte, a ; acc A <-- high byte.low byte ret
SP_in_8 ldm *ar1, a ; acc A <-- DRR sub #0008h, a ; acc A = 0008 rc aneq call ser_in ; call SP input sub ldm *ar1, a ; acc A <-- DRR sub #0AAh, a ; acc A = 00aa rc aneq ser_08 ;The dummy words are read to maintain ; hex converter compatibility with ; the 548/549
call DBsreadA ; call SP double read byte from DRR stl a, @temp0 ; save DUMMY WORD value in temp0 call DBsreadA ; call SP double read byte from DRR stl a, @temp1 ; save DUMMY WORD value in temp1 call DBsreadA ; call SP double read byte from DRR stl a, @temp2 ; save DUMMY WORD value in temp2 call DBsreadA ; call SP double read byte from DRR stl a, @temp3 ; save DUMMY WORD value in temp3
call DBsreadA ; call SP double read byte from DRR stl a, @xentry ; save XPC entry point
call DBsreadA ; call SP double read byte from DRR stl a, @entry ; save entry point
SP08_1 call DBsreadA ; call SP double read byte from DRR ; read section size bcd endboot,aeq ; section size =0 indicate boot end sub #1,a,b ; brc = section size - 1 stlm b, brc ; update block repeat counter register call DBsreadA ; call SP double read byte from DRR ; read XPC of destination address stl a,@dest ; XPC of destination call DBsreadA ; call SP double read byte from DRR ; read destination address add @dest, 16, a ; rptb sfxr08-1 call ser_in ; call SP input sub ld *ar1, 8, b ; acc B <-- junkbyte.high byte and #0ff00h, b ; acc B <-- high.byte stl b, @hbyte ; save high byte call ser_in ; call SP input sub ldu *ar1, b ; acc B <-- junkbyte.low byte and #0ffh, b ; acc B <-- low byte or @hbyte, b ; acc B <-- high byte.low byte writa @BL ; [acc A] <-- acc BL add #1, a ; increment dest add sfxr08 b SP08_1 ; check next section
************************************************************************* *** SPIBOOT - This routine reads a boot-table from an SPI EEPROM through *** McBSP2. 12/06/99 PMJ2 ************************************************************************* SPIBOOT *** Initialize the McBSP2 for SPI mode. ********************************* stm SPSA2, ar4 ;AR4->SPSA2 stm dxr12-1, ar5 ;AR5->DXR ld #249, a ;Bit-rate divisor (.4Mhz @100MIPs) ssbx XF ;Drive XF high - optional hold feature. call SPI_INIT ;Initialize McBSP. *************************************************** ***** Start reading EEPROM. ***** ***************************************************
stm #0, AR3 ;Init address to read from. call SPI_READ ;Read address 0. xor #08h,a ;Checking for boot-table (08AAh) bc parallel, aneq ;If not 08h, no-go. Branch to parallel. mar *AR3+ ;increment address call SPI_READ ;Read address 1. xor #0AAh,a ;Checking for boot-table (08AAh) bc parallel, aneq ;If not AAh, no-go. Branch to parallel.
*************************************************** ***** If here then booting.************************ ***** The next eight addresses are skipped ***** ***** to maintain hex converter compatibility ***** ***** with the 548/549 serial boot-table ***** *************************************************** stm #0ah, AR3 ;Init address to read from. call SPI_READ ;Read address 0ah. stl a, 8, xentry ;Store xentry high-byte. mar *ar3+ ;increment address call SPI_READ ;Read address 0fh. or xentry, a ;And xentry high-byte and low-byte. stl a, xentry ;Store XPC entry point.
mar *ar3+ ;Increment address. call SPI_READ ;Read address 010h. stl a, 8, entry ;Store entry high-byte. mar *ar3+ ;increment address call SPI_READ ;Read address 011h. or entry, a ;And entry high-byte and low-byte. stl a, entry ;Store PC entry point. mar *ar3+ ;increment address
SPISECT call SPI_READ ;Read address 0ch. stl a, 8, temp0 ;Store size high-byte. mar *ar3+ ;Increment address. call SPI_READ ;Read address 0dh. or temp0, a ;And size high-byte and low-byte. bc SPIEND, aeq ;If size = 0, done. sub #1,a ;Section size - 1. stlm a, brc ;Update block repeat counter register.
mar *ar3+ ;Increment address. call SPI_READ ;Read address 0eh. stl a, 8, xdest ;Store xdest high-byte. mar *ar3+ ;increment address call SPI_READ ;Read address 0fh. or xdest, a ;And xdest high-byte and low-byte. stl a, xdest ;Store XPC entry point.
mar *ar3+ ;Increment address. call SPI_READ ;Read address 010h. stl a, 8, dest ;Store dest high-byte. mar *ar3+ ;increment address call SPI_READ ;Read address 011h. or dest, a ;And dest high-byte and low-byte. stl a, dest ;Store PC dest point. *********This is the loop for reading a section************** rptb SPILOOP-1 mar *ar3+ ;Increment address. call SPI_READ ;Read high-byte. stl a, 8, temp0 ;Store high-byte. mar *ar3+ ;increment address call SPI_READ ;Read address low-byte. or temp0, a ;And high-byte and low-byte. stl a, temp0 ;Temporarily save it. dld xdest, a ;Get destination address. writa temp0 ;[acc A] <-- acc BL add #1, a ;increment dest add dst a, xdest ;Save destination address. SPILOOP mar *ar3+ ;Increment address. b SPISECT ;Read next section. SPIEND rsbx XF ;Drive XF low - optional hold feature. b endboot ;Branch to loaded code.
***************************************************************** * Bootload from parallel I/O port (pa0) *****************************************************************
pasyini call handshake portr pa0, @temp0 ; read BSW 10AAh or 8AAh ld @temp0, a ; check BSW sub #10aah, a, b ; acc A = 10aah ? bcd pasync16, beq ; and #0ffh, a ; check acc AL = 08 sub #8,a ; bc endboot, aneq ; not a boot mode call handshake portr pa0, @temp0 ; read BSW 10AAh or 8AAh ld @temp0, a ; check BSW and #0ffh, a ; check acc AL = 08 sub #0aah, a ; acc A = 0aah ? bc pasync08, aeq ; b endboot
***************************************************************** * Bootload from I/O port (8-bit parallel), MS byte first *****************************************************************
pasync08 call handshake8 stl b, @swwsr ; save swwsr ini-value to SWWSR
call handshake8 stl b, @bscr ; save bscr ini-value to BSCR
call handshake8 stl b, @xentry ; save XPC of entry point
call handshake8 stl b, @entry ; save entry point pasy08_1 ld #0, b ; b=0, Rev1.02 to fix 8bitI/O bug. call handshake8 bc endboot, beq ; if size = 0, branch to endboot sub #1, b ; otherwise, subtract 1 from block size stlm b, brc ; set brc to correct block size
call handshake8 *********************** Bug fix *********************************** stl b, @temp0 ; save XPC of destination addr ld @temp0,16,a ;added to correctly calculate the ;extended address of the section ;PMJ2(11/10/99) 1.02 call handshake8 add b,a ; acc A <-- destination address *******************************************************************
rptb pfxr08-1 call handshake8
ssbx xf ; acknowledge byte as soon as it's read
bc $,bio ;wait until BIO high to write data
writa BL ; write code word to program memory add #1, a ; increment destination address pfxr08 b pasy08_1 ; branch to next section
***************************************************************** * Bootload from I/O port (16-bit parallel) *****************************************************************
pasync16 call handshake portr pa0, @swwsr ; read word from port to SWWSR call handshake portr pa0, @bscr ; read word from port to BSCR call handshake portr pa0, @xentry ; read word from port to XPC of ; entry point call handshake portr pa0, @entry ; read word from port to entry pasy16_1 call handshake portr pa0, @lngth ; read word from port to length ldu @lngth, a ; check size bcd endboot, aeq ; size = 0, end of boot sub #1, a, b ; stlm b, brc call handshake portr pa0, @dest ; read word from port to XPC of ; destination addr call handshake portr pa0, @temp0 ; read from port to temp for ; destiantion addr ldu @temp0, a ; acc A <-- destination address add @dest, 16, a ;
rptb pfxr16-1 call handshake ; check BIO low ? portr pa0, @temp0 ; read word from port to temp ssbx xf ; acknowledge word as soon as it's read
bc $,bio ; wait until BIO high to write data
writa @temp0 ; write word to destination add #1, a ; increment destination address pfxr16 b pasy16_1
* Handshake with BIO signal using XF
handshake ssbx xf ; acknowledge previous data word bc $,bio ; wait till host sends request rsbx xf ; indicate ready to receive new data rc bio ; wait till new data ready b $-1
handshake8 ssbx xf ; acknowledge previous data word bc $,bio ; wait till host sends request rsbx xf ; indicate ready to receive new data bc $,nbio ; wait till new data ready
portr pa0, BL ;read high byte into accumulator A ************* Bug fix ****************************************************** and #0ffh,b ;force BG, BH to zero for correct evaluation ;(11/10/99 PMJ2) **************************************************************************** sftl b,8 ;left shift by 8 bits
ssbx xf ; acknowledge previous data word bc $,bio ; wait till host sends request rsbx xf ; indicate ready to receive new data bc $,nbio ; wait till new data ready
portr pa0, @temp0 andm #0ffh,temp0 ; clear upper byte or @temp0, b ; combine high and low byte ret
bootend .end
|