45
|
1 ********************************************************************
|
|
2 * Boot - Glenside IDE Boot module
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Ed. Comments Who YY/MM/DD
|
|
7 * ------------------------------------------------------------------
|
|
8 * 1 Created BGP 99/05/11
|
|
9
|
|
10 nam Boot
|
|
11 ttl Glenside IDE Boot module
|
|
12
|
|
13 ifp1
|
|
14 use defsfile
|
|
15 endc
|
|
16
|
|
17 tylg set Systm+Objct
|
|
18 atrv set ReEnt+rev
|
|
19 rev set 0
|
|
20 edition set 1
|
|
21
|
|
22 mod eom,name,tylg,atrv,start,size
|
|
23
|
|
24 blockloc rmb 2 pointer to memory requested
|
|
25 blockimg rmb 2 duplicate of the above
|
|
26 bootloc rmb 3 sector pointer; not byte pointer
|
|
27 bootsize rmb 2 size in bytes
|
|
28 size equ .
|
|
29
|
|
30 name fcs /Boot/
|
|
31 fcb edition
|
|
32
|
|
33 hwport fdb $FF70
|
|
34
|
|
35 start clra
|
|
36 ldb #size
|
|
37 clean pshs a
|
|
38 decb
|
|
39 bne clean
|
|
40 tfr s,u get pointer to data area
|
|
41 pshs u save pointer to data area
|
|
42
|
|
43 lda #$D0 forced interrupt; kill floppy activity
|
|
44 sta $FF48 command register
|
|
45 clrb
|
|
46 pause decb
|
|
47 bne pause
|
|
48 lda $FF48 clear controller
|
|
49 clr $FF40 make sure motors are turned off
|
|
50 sta $FFD9 fast clock
|
|
51 lbsr Init
|
|
52
|
|
53 * Request memory for LSN0
|
|
54 ldd #1
|
|
55 os9 F$SRqMem request one page of RAM
|
|
56 bcs error
|
|
57 bsr getpntr
|
|
58
|
|
59 * Get LSN0 into memory
|
|
60 clrb MSB sector
|
|
61 ldx #0 LSW sector
|
|
62 bsr mread
|
|
63 bcs error
|
|
64 ldd bootsize,u
|
|
65 beq error
|
|
66 pshs d
|
|
67
|
|
68 * Return memory
|
|
69 ldd #$100
|
|
70 ldu blockloc,u
|
|
71 os9 F$SRtMem
|
|
72 puls d
|
|
73 os9 F$BtMem
|
|
74 bcs error
|
|
75 bsr getpntr
|
|
76 std blockimg,u
|
|
77
|
|
78 * Get os9boot into memory
|
|
79 ldd bootsize,u
|
|
80 leas -2,s same as a PSHS D
|
|
81 getboot std ,s
|
|
82 ldb bootloc,u MSB sector location
|
|
83 ldx bootloc+1,u LSW sector location
|
|
84 bsr mread
|
|
85 ldd bootloc+1,u update sector location by one to 24bit word
|
|
86 addd #1
|
|
87 std bootloc+1,u
|
|
88 ldb bootloc,u
|
|
89 adcb #0
|
|
90 stb bootloc,u
|
|
91 inc blockloc,u update memory pointer for upload
|
|
92 ldd ,s update size of file left to read
|
|
93 subd #$100 file read one sector at a time
|
|
94 bhi getboot
|
|
95
|
|
96 leas 4+size,s reset the stack same as PULS U,D
|
|
97 ldd bootsize,u
|
|
98 ldx blockimg,u pointer to start of os9boot in memory
|
|
99 andcc #^Carry clear carry
|
|
100 rts back to os9p1
|
|
101
|
|
102 error leas 2+size,s
|
|
103 ldb #E$NotRdy drive not ready
|
|
104 rts
|
|
105
|
|
106 getpntr tfr u,d save pointer to requested memory
|
|
107 ldu 2,s recover pointer to data stack
|
|
108 std blockloc,u
|
|
109 rts
|
|
110
|
|
111 mread tstb
|
|
112 bne read10
|
|
113 cmpx #0
|
|
114 bne read10
|
|
115 bsr read10
|
|
116 bcc readlsn0
|
|
117 rts
|
|
118
|
|
119 readlsn0 pshs a,x,y
|
|
120 ldy blockloc,u
|
|
121 lda DD.Bt,y os9boot pointer
|
|
122 ldx DD.Bt+1,y LSW of 24 bit address
|
|
123 sta bootloc,u
|
|
124 stx bootloc+1,u
|
|
125 ldx DD.BSZ,y os9boot size in bytes
|
|
126 stx bootsize,u
|
|
127 clrb
|
|
128 puls a,x,y,pc
|
|
129
|
|
130 * Initialize IDE interface
|
|
131 Init ldx #$1500
|
|
132 ldy hwport,pc
|
|
133 RdyIni1 tst 7,y Wait for drive ready
|
|
134 bpl GoInit
|
|
135 leax -1,x
|
|
136 bne RdyIni1
|
|
137 lbeq ENotRdy Timed out ... give up on drive
|
|
138
|
|
139 GoInit ldd #$AF20 Drive is ready -- initialize
|
|
140 * For IDE command $91, DrvHd reg = 101xhhhh binary
|
|
141 sta 6,y $10 heads (x=0-master/1-slave; hhhh=#heads)
|
|
142 stb 2,y $20 sectors/track
|
|
143 lda #$91
|
|
144 sta 7,y Give drive the Init Drive Parameters IDE command
|
|
145 RdyIni2 tst 7,y
|
|
146 bmi RdyIni2 Wait *forever* until drive is ready
|
|
147 clrb
|
|
148 rts
|
|
149 ENotRdy comb
|
|
150 ldb #E$NotRdy
|
|
151 rts
|
|
152
|
|
153 *
|
|
154 * READ
|
|
155 *
|
|
156 * B = MSB of OS-9 disk LSN
|
|
157 * X = LSB of OS-9 disk LSN
|
|
158 *
|
|
159 read10 lbsr SetIDE
|
|
160 bcs Ret
|
|
161 ldx blockloc,u
|
|
162 lda #$20
|
|
163 pshs a
|
|
164 ldy hwport,pc
|
|
165 ReadLp lda ,y
|
|
166 ldb ,y
|
|
167 std ,x++
|
|
168 lda ,y
|
|
169 ldb ,y
|
|
170 std ,x++
|
|
171 lda ,y
|
|
172 ldb ,y
|
|
173 std ,x++
|
|
174 lda ,y
|
|
175 ldb ,y
|
|
176 std ,x++
|
|
177 dec ,s
|
|
178 bne ReadLp
|
|
179 puls a
|
|
180
|
|
181 *
|
|
182 * After read or write, check drive status
|
|
183 * Return value = CC, true=error, false=OK
|
|
184 *
|
|
185 WaitOK lda #$80 Is DRQ still true? Just one check necessary
|
|
186 ldy hwport,pc
|
|
187 bita 7,y If it is, sector isn't fully transferred
|
|
188 bne WaitOK
|
|
189 lda #$01 Wait *forever* for drive ready
|
|
190 bita 7,y
|
|
191 bne CmdErr
|
|
192 Ret clrb Nope -- clear CC
|
|
193 rts
|
|
194 CmdErr comb Yep -- set CC
|
|
195 rts
|
|
196
|
|
197 *
|
|
198 * Setup IDE read or write operation
|
|
199 * trashes D and X
|
|
200 *
|
|
201 SetIDE pshs b,x
|
|
202 ldx #$A000
|
|
203 CmdLp1 ldy hwport,pc
|
|
204 tst 7,y
|
|
205 bpl SetRdy Should go to ChkDRDY ?????
|
|
206 leax -1,x
|
|
207 bne CmdLp1
|
|
208 puls b,x
|
|
209 bra ENotRdy
|
|
210
|
|
211 SetRdy lda 2,s Sector first
|
|
212 anda #$1F
|
|
213 adda #$01
|
|
214 sta 3,y Store calculated sector number
|
|
215 ldd 1,s
|
|
216 rolb
|
|
217 rola
|
|
218 rolb
|
|
219 rola
|
|
220 rolb
|
|
221 rola
|
|
222 anda #$0F
|
|
223 ora #$A0
|
|
224 sta 6,y Store calculated drive number
|
|
225 ldd ,s Last, the cylinder number (2-bytes)
|
|
226 rora
|
|
227 rorb
|
|
228 anda #$7F
|
|
229 sta 5,y Store calculated CylHi
|
|
230 stb 4,y Store calculated CylLo
|
|
231 lda #$01
|
|
232 sta 2,y Sector count = 1
|
|
233 ldb #$20
|
|
234 stb 7,y Lastly, push the command to the drive
|
|
235 ldb #$40
|
|
236 lda #$08 Wait for Drive ready
|
|
237 CmdLp2 bita 7,y
|
|
238 bne CmdDone
|
|
239 decb
|
|
240 bne CmdLp2
|
|
241 ldx #$0001 If we time out, sleep 1 tick, then loop *forever*
|
|
242 os9 F$Sleep
|
|
243 CmdLp3 bita 7,y
|
|
244 beq CmdLp3
|
|
245 CmdDone puls b,x
|
|
246 clrb All right, drive ready -- return
|
|
247 rts
|
|
248
|
|
249 * Fillers to get to $1D0
|
|
250 fcc /9999999999/
|
|
251 fcc /9999999999/
|
|
252 fcc /9999999999/
|
|
253 fcc /9999999999/
|
|
254 fcc /9999999999/
|
|
255 fcc /9999999999/
|
|
256 fcc /9999999999/
|
|
257 fcc /999999999/
|
|
258
|
|
259 emod
|
|
260
|
|
261 eom equ *
|