3033
|
1 ********************************************************************
|
|
2 * Boot - CoCo SDC Boot module
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Edt/Rev YYYY/MM/DD Modified by
|
|
7 * Comment
|
|
8 * ------------------------------------------------------------------
|
|
9 * 2014/12/22 Darren Atkinson
|
|
10 * Created.
|
|
11
|
|
12 nam Boot
|
|
13 ttl SDC Boot module
|
|
14
|
|
15 IFP1
|
|
16 use defsfile
|
|
17 ENDC
|
|
18
|
|
19 * Default Boot is from drive 0
|
|
20 BootDr set 0
|
|
21
|
|
22 * Alternate Boot is from drive 1
|
|
23 IFEQ DNum-1
|
|
24 BootDr set 1
|
|
25 ENDC
|
|
26
|
|
27 * Common booter-required defines
|
|
28 LSN24BIT equ 1
|
|
29 FLOPPY equ 0
|
|
30
|
|
31 * DPort offsets
|
|
32 CONTROL equ 0 write-only
|
|
33 CMDREG equ 8+0 write-only
|
|
34 STATREG equ CMDREG read-only
|
|
35 LSNREG equ 8+1
|
|
36 DATAREG equ 8+2
|
|
37
|
|
38 * NOTE: these are U-stack offsets, not DP
|
|
39 seglist rmb 2 pointer to segment list
|
|
40 blockloc rmb 2 pointer to memory requested
|
|
41 blockimg rmb 2 duplicate of the above
|
|
42 bootsize rmb 2 size in bytes
|
|
43 LSN0Ptr rmb 2 In memory LSN0 pointer
|
|
44 size equ .
|
|
45
|
|
46
|
|
47 tylg set Systm+Objct
|
|
48 atrv set ReEnt+rev
|
|
49 rev set $00
|
|
50 edition set 1
|
|
51
|
|
52 mod eom,name,tylg,atrv,start,size
|
|
53
|
|
54 name fcs /Boot/
|
|
55 fcb edition
|
|
56
|
|
57
|
|
58 *--------------------------------------------------------------------------
|
|
59 * HWInit - Initialize the device
|
|
60 *
|
|
61 * Entry:
|
|
62 * Y = hardware address
|
|
63 *
|
|
64 * Exit:
|
|
65 * Carry Clear = OK, Set = Error
|
|
66 * B = error (Carry Set)
|
|
67 *
|
|
68 HWInit orcc #$50 mask interrupts
|
|
69 lda #$D0 stop any emulated FDC command
|
|
70 sta CMDREG,y
|
|
71 pshs d,x,y,u delay
|
|
72 puls d,x,y,u
|
|
73 lda STATREG,y clear INTRQ
|
|
74
|
|
75 *** Fall Thru ***
|
|
76
|
|
77 *--------------------------------------------------------------------------
|
|
78 * HWTerm - Terminate the device
|
|
79 *
|
|
80 * Entry:
|
|
81 * Y = hardware address
|
|
82 *
|
|
83 * Exit:
|
|
84 * Carry Clear = OK, Set = Error
|
|
85 * B = error (Carry Set)
|
|
86 *
|
|
87 HWTerm clrb no error
|
|
88 stb CONTROL,y disable command mode
|
|
89 rts
|
|
90
|
|
91
|
|
92 ***************************************************************************
|
|
93 use boot_common.asm
|
|
94 ***************************************************************************
|
|
95
|
|
96 *
|
|
97 * HWRead - Read a 256 byte sector from the device
|
|
98 *
|
|
99 * Entry:
|
|
100 * Y = hardware address
|
|
101 * B = bits 23-16 of LSN
|
|
102 * X = bits 15-0 of LSN
|
|
103 * blockloc,u = where to load the 256 byte sector
|
|
104 *
|
|
105 * Exit:
|
|
106 * X = ptr to data (i.e. ptr in blockloc,u)
|
|
107 *
|
|
108 HWRead lda #$43 start command mode
|
|
109 sta CONTROL,y
|
|
110 stb LSNREG,y put LSN into registers
|
|
111 stx LSNREG+1,y
|
|
112 clra A=0 for use at rdExit
|
|
113 bsr waitSDC wait for BUSY to be cleared
|
|
114 bcs rdExit exit on error or timeout
|
|
115 ldb WhichDrv,pcr get drive number
|
|
116 andb #1 limit to 0 or 1
|
|
117 orb #$80 combine with Read Sector command
|
|
118 stb CMDREG,y send command to controller
|
|
119 bsr waitSDC wait for data READY
|
|
120 bcs rdExit exit on error or timeout
|
|
121 ldx blockloc,u get address of buffer to fill
|
|
122 pshs u,x preserve U and X
|
|
123 ldb #256/2 1/2 sector size
|
|
124 rdLoop ldu DATAREG,y read word data from controller
|
|
125 stu ,x++ store to buffer
|
|
126 decb decrement word counter
|
|
127 bne rdLoop loop until done
|
|
128 puls x,u restore X and U
|
|
129 rdExit sta CONTROL,y end command mode
|
|
130 rts
|
|
131
|
|
132
|
|
133 *--------------------------------------------------------------------------
|
|
134 * Wait for controller status to indicate either "Not Busy" or "Ready".
|
|
135 * Will time out if neither condition satisfied within a suitable period.
|
|
136 *
|
|
137 * Exit:
|
|
138 * CC.C set on error or time out
|
|
139 *
|
|
140 waitSDC ldx #0 setup timeout counter
|
|
141 waitLp bsr waitRet extra cycles for timeout
|
|
142 comb set carry for timeout/FAILED
|
|
143 leax ,-x decrement timeout counter
|
|
144 beq waitRet return if timed out
|
|
145 ldb STATREG,y read status
|
|
146 bmi waitRet return if FAILED
|
|
147 lsrb BUSY --> Carry
|
|
148 bcc waitRet return if not busy
|
|
149 rolb clear carry
|
|
150 bitb #2 test READY
|
|
151 beq waitLp loop if not ready for transfer
|
|
152 waitRet rts return
|
|
153
|
|
154
|
|
155 *--------------------------------------------------------------------------
|
|
156
|
|
157 IFGT Level-1
|
|
158 * Filler to get $1D0
|
|
159 Filler fill $39,$1D0-3-2-1-*
|
|
160 ENDC
|
|
161
|
|
162 Address fdb DPort
|
|
163 WhichDrv fcb BootDr
|
|
164
|
|
165 emod
|
|
166 eom equ *
|
|
167 end
|