1187
|
1 ********************************************************************
|
|
2 * Boot - IDE Boot Module (LBA Mode)
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Ed. Comments Who YY/MM/DD
|
|
7 * ------------------------------------------------------------------
|
|
8 * ? Disassembled AD 94/06/25
|
|
9 * 6 Redone for IDE PTB 99/08/17
|
|
10 * 7 Added use of LSN bits 23-16 BGP 02/06/27
|
|
11
|
|
12 nam Boot
|
|
13 ttl IDE Boot Module (LBA Mode)
|
|
14
|
|
15 ifp1
|
|
16 use defsfile
|
|
17 use rbfdefs
|
|
18 endc
|
|
19
|
|
20 tylg set Systm+Objct
|
|
21 atrv set ReEnt+rev
|
|
22 rev set 2
|
|
23 edition set 7
|
|
24
|
|
25 * Disassembled 94/06/25 11:37:47 by Alan DeKok
|
|
26 * ReDone by Paul T. Barton 99/08/17, for IDE
|
|
27 *
|
|
28 Port equ $FF70 still leaves room for SSPak & SSP & MPI
|
|
29 RData equ 0 data 0..7
|
|
30 WData equ 0 data 0..7
|
|
31 ErrReg equ 1 Has the errors
|
|
32 SecCnt equ 2 always =1
|
|
33 SecNum equ 3
|
|
34 CylLow equ 4
|
|
35 CylHigh equ 5
|
|
36 DevHead equ 6 0,1,0,DEV,0,0,0,0
|
|
37 Status equ 7 Results of read/write
|
|
38 CmdIde equ 7 Commands
|
|
39 Latch equ 8 Latch
|
|
40
|
|
41 ReadCmd equ $20
|
|
42 Diagnos equ $90
|
|
43
|
|
44 BusyBit equ %10000000 BUSY=1
|
|
45 DrdyBit equ %01000000 drive ready=1
|
|
46 DscBit equ %00010000 seek finished=1
|
|
47 DrqBit equ %00001000 data requested=1
|
|
48 ErrBit equ %00000001 error_reg has it
|
|
49 RdyTrk equ %01010000 ready & over track
|
|
50 RdyDrq equ %01011000 ready w/ data
|
|
51 Master equ %11100000 LBA MODE
|
|
52 Slave equ %11110000 LBA MODE
|
|
53
|
|
54
|
|
55 WhchDriv equ Master Drive to use (Master or Slave)
|
|
56
|
|
57 mod eom,name,tylg,atrv,start,size
|
|
58
|
|
59 * on-stack buffer to use
|
|
60 org 0
|
|
61 btmem rmb 2
|
|
62 btsiz rmb 2
|
|
63 btloc rmb 3
|
|
64 size equ .
|
|
65
|
|
66 name fcs /Boot/
|
|
67 fcb edition
|
|
68
|
|
69 start
|
|
70 orcc #IntMasks ensure IRQ's are off.
|
|
71 leas -size,s
|
|
72
|
|
73 clr >$FF40 stop the disk
|
|
74 lbsr Init
|
|
75
|
|
76 ldd #$0001 request one byte (will round up to 1 page)
|
|
77 os9 F$SRqMem request the memory
|
|
78 bcs L00B0 exit on error
|
|
79
|
|
80 * U is implicitely the buffer address to use
|
|
81
|
|
82 clrb
|
|
83 ldx #$0000 X=0: got to sector #$0000
|
|
84 bsr GetSect load in LSN0, U = buffer start
|
|
85 bcs L00B0
|
|
86
|
|
87 IFNE NitrOS9
|
|
88 lda #'0 --- loaded in LSN0
|
|
89 jsr <D.BtBug ---
|
|
90 ENDC
|
|
91
|
|
92 ldd <DD.BSZ,u size of the bootstrap file
|
|
93 std btsiz,s save it on the stack (0,s is junk)
|
|
94 lda <DD.BT,u get starting sector bits 23-16
|
|
95 ldx <DD.BT+1,u get starting sector of the bootstrap file
|
|
96 sta btloc,s
|
|
97 stx btloc+1,s
|
|
98
|
|
99 ldd #256 one page of memory
|
|
100 os9 F$SRtMem return the copy of LSN0 to free memory
|
|
101
|
|
102 ldd btsiz,s get size of boot memory to request
|
|
103 IFEQ Level-2
|
|
104 os9 F$BtMem ask for the boot memory
|
|
105 ELSE
|
|
106 os9 F$SRqMem ask for the boot memory
|
|
107 ENDC
|
|
108 bcs L00AE no memory: exit with error
|
|
109
|
|
110 std btsiz,s
|
|
111 stu btmem,s save start address of memory allocated
|
|
112 ldd btsiz,s and the size of the boot memory
|
|
113 beq L00B0 if no memory allocated, exit
|
|
114 pshs d save off temp size
|
|
115 SectLp
|
|
116 ldb btloc+2,s
|
|
117 bsr GetSect read one sector
|
|
118 bcs L00AE if there's an error, exit
|
|
119
|
|
120 IFNE NitrOS9
|
|
121 lda #'. dump out a period for boot debugging
|
|
122 jsr <D.BtBug do the debug stuff
|
|
123 ENDC
|
|
124
|
|
125 leau 256,u
|
|
126 leax 1,x go to the next sector
|
|
127 bne Sect2
|
|
128 incb
|
|
129 stb btloc+2,s
|
|
130 Sect2
|
|
131 ldd ,s
|
|
132 subd #256 take out one sector, need value in B, too.
|
|
133 std ,s
|
|
134 bhi SectLp loop until all sectors are read
|
|
135
|
|
136 L00A7 clrb clear carry
|
|
137 ldd btsiz+2,s
|
|
138
|
|
139 L00AE leas $02,s kill D off of the stack
|
|
140 ldx btmem,s
|
|
141 L00B0 leas size,s remove the on-stack buffer
|
|
142 L00BA rts
|
|
143
|
|
144 Address fdb Port
|
|
145
|
|
146 * GetSect: read a sector off of the disk
|
|
147 * Entry: B,X = sector number to read
|
|
148 * Memory: U = where to put it
|
|
149
|
|
150 GetSect
|
|
151 pshs b,x,y
|
|
152 ldy <Address,pcr grab the device address
|
|
153 bsr ChkBusy
|
|
154
|
|
155 RdyHuh1
|
|
156 lda Status,y is IDE ready for commands?
|
|
157 anda #DrdyBit ready ?
|
|
158 beq RdyHuh1 loop until Drdy =1
|
|
159
|
|
160 lda #WhchDriv
|
|
161 sta DevHead,y 0L0d/0hhh device=LBA
|
|
162 lda #$01 only one at a time
|
|
163 sta SecCnt,y only one at a time
|
|
164 stb CylHigh,y bits 23-16
|
|
165 tfr x,d sector number to read
|
|
166 sta CylLow,y hi-byte
|
|
167 stb SecNum,y
|
|
168 leax ,u where to put the sector
|
|
169 lda #ReadCmd read one sector
|
|
170 sta CmdIde,y finish process
|
|
171
|
|
172 Blk2
|
|
173 lda Status,y is IDE ready to send?
|
|
174 anda #DrqBit DRQ, data request
|
|
175 beq Blk2 loop while DRQ =0
|
|
176
|
|
177 clr ,-s
|
|
178 BlkLp
|
|
179 lda RData,y A <- IDE
|
|
180 ldb Latch,y
|
|
181 std ,x++ into RAM
|
|
182 inc ,s
|
|
183 bpl BlkLp go get the rest
|
|
184 puls b
|
|
185
|
|
186 lda Status,y check for error-bit
|
|
187 clrb
|
|
188 puls b,x,y,pc
|
|
189 * ------------------------------------------
|
|
190
|
|
191 ChkBusy
|
|
192 lda Status,y
|
|
193 anda #BusyBit 1xxx-xxxx
|
|
194 bne ChkBusy if =1 then loop
|
|
195 rts exit when BUSY =0
|
|
196
|
|
197 Init
|
|
198 pshs d,y
|
|
199 ldy <Address,pcr
|
|
200 bsr ChkBusy could be spinning up...
|
|
201 lda #Diagnos hits all drives
|
|
202 sta CmdIde,y ./
|
|
203 bsr ChkBusy wait 'til both done
|
|
204 clrb no errors
|
|
205 puls d,y,pc
|
|
206
|
|
207 IFEQ Level-2
|
|
208 Pad fill $39,$1D0-3-*
|
|
209 ENDC
|
|
210
|
|
211
|
|
212 emod
|
|
213 eom equ *
|
|
214 end
|