annotate level1/modules/rbsuper.asm @ 2910:87f2133301b0

Remove execute permissions from files that should not have it
author Tormod Volden <debian.tormod@gmail.com>
date Sat, 11 Jan 2014 21:52:42 +0100
parents ebf319736e9c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2590
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
1 ********************************************************************
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
2 * rbsuper - RBF Super Caching Device Driver
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
3 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
4 * $Id$
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
5 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
6 * (C) 2004 Boisy G. Pitre - Licensed to Cloud-9
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
7 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
8 * RBSuper is the framework for a new type of RBF device driver -- one
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
9 * that fetches native-size, or PHYSICAL sectors. A physical sector is
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
10 * a sector that is sized to its device. For example, all IDE drives and
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
11 * pretty much all SCSI drives have 512 byte sectors; CD-ROMs have 2048
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
12 * byte sectors.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
13 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
14 * As a high-level driver, this module is responsible for managing
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
15 * the cache, verifying writes, etc.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
16 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
17 * The actual reading and writing of sectors is performed by the
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
18 * low-level driver, which can be designed for any device.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
19 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
20 * Conditionals:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
21 * H6309 - if set, assembles for 6309
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
22 * USECS - if set, uses critical section code (slows down driver)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
23 * HDBDOS - if set, adds code to handle HDB-DOS partitions
2733
ebf319736e9c Adjusted disk format for dw .dsk's, took a blank line out of regdmp to compact its display
gheskett
parents: 2590
diff changeset
24 * And somewhere this flag has been lost GH 2012/11/13
ebf319736e9c Adjusted disk format for dw .dsk's, took a blank line out of regdmp to compact its display
gheskett
parents: 2590
diff changeset
25 * Only found when I trashed my systems vdisks
ebf319736e9c Adjusted disk format for dw .dsk's, took a blank line out of regdmp to compact its display
gheskett
parents: 2590
diff changeset
26 HDBDOS set 1
2590
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
27 * Edt/Rev YYYY/MM/DD Modified by
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
28 * Comment
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
29 * ------------------------------------------------------------------
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
30 * 2004/04/10 Boisy G. Pitre
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
31 * Created due to Mark's constant harping about a NitrOS-9 driver for
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
32 * the SuperIDE Interface. Here ya go, Marlette.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
33 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
34 * 2005/12/12 Boisy G. Pitre
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
35 * The SS.VarSect call has been moved from the low level driver to rbsuper
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
36 * for efficiency. Also it no longer calls SS.DSize every time it is called.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
37 * Instead, it only calls it the first time, then caches the sector size value
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
38 * and returns that value on subsequent calls.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
39 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
40 * 2005/12/13 Boisy G. Pitre
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
41 * Employed a trick to "shift" the idea of where the driver's static
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
42 * data starts at the start of each entry point. This saves about 200
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
43 * bytes of memory.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
44 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
45 * 1 2006/08/20 Boisy G. Pitre
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
46 * Fixed bug where linking to a non-existent module in Init would cause a crash
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
47 * because IOMan calls the Term routine when Init returns an error. Added a simple
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
48 * one line test in Term to see if a value was non-zero which would indicate if Init
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
49 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
50 * 2 2008/02/05 Boisy G. Pitre
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
51 * Fixed bug where DNS HDB flag was being pulled from PD.TYP byte instead of PD.DNS.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
52 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
53 * 3 2011/12/22 Boisy G. Pitre
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
54 * Made a "fast path" for 256 byte sector devices to read/write directly into PD.BUF
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
55 * instead of using the cache, for performance reasons.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
56 * Conditionalized critical section code since it may not be needed, and affects performance.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
57
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
58 NAM rbsuper
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
59 TTL RBF Super Caching Device Driver
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
60
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
61 IFP1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
62 USE defsfile
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
63 USE rbsuper.d
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
64 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
65
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
66 tylg SET Drivr+Objct
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
67 atrv SET ReEnt+rev
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
68 rev SET 0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
69 edition SET 2
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
70
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
71 MOD eom,name,tylg,atrv,start,V.RBSuper
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
72
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
73 FCB DIR.+SHARE.+PEXEC.+PREAD.+PWRIT.+EXEC.+UPDAT.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
74
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
75 name FCS /RBSuper/
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
76 FCB edition
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
77
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
78 start lbra Init
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
79 bra Read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
80 nop
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
81 lbra Write
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
82 lbra GetStat
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
83 lbra SetStat
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
84
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
85 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
86 * Term
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
87 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
88 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
89 * U = address of device memory area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
90 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
91 * Exit:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
92 * CC = carry set on error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
93 * B = error code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
94 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
95 Term leau UOFFSET,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
96 * Free memory allocated for cache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
97 lda V.CchSize,u get cache size into A
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
98 * Note, the next line fixes a bug where the system would crash when F$Link in Init failed.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
99 * If it fails, V.CchSize will never get set, and since it is set to 0 initally, we assume
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
100 * that init failed if V.CchSize is 0 and thus we simply return.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
101 beq ret@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
102 tfr u,x move statics ptr into X for safety
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
103 ldu V.CchAddr,u and load U with cache address
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
104 beq nofree@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
105 os9 F$SRtMem return cache memory to system
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
106 nofree@ tfr x,u and restore statics ptr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
107 * Call low-level driver term
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
108 ldx V.LLTerm,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
109 lbsr LLCall
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
110 * Unlink low-level driver
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
111 IFGT Level-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
112 ldx D.Proc get curr proc ptr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
113 ldd D.SysPrc get system process desc ptr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
114 std D.Proc and make current proc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
115 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
116 ldu V.LLAddr,u get the address of the low-level module
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
117 os9 F$Unlink unlink it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
118 IFGT Level-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
119 stx D.Proc restore
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
120 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
121 ret@ rts return
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
122
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
123 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
124 * Read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
125 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
126 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
127 * B = MSB of the disk's LSN
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
128 * X = LSB of the disk's LSN
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
129 * Y = address of path descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
130 * U = address of device memory area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
131 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
132 * Exit:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
133 * CC = carry set on error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
134 * B = error code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
135 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
136 Read leau UOFFSET,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
137 cmpx #$0000 LSN 0?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
138 bne ReadSect branch if not
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
139 tstb LSN 0?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
140 bne ReadSect branch if not
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
141 bsr ReadSect else read LSN0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
142 bcs bye if error, return
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
143 * Code to deal with copying LSN0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
144 leax DRVBEG-UOFFSET,u point X to start of drive table
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
145 ldb PD.DRV,y get drive number
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
146 lsn@ beq CopyLSN0 branch if zero
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
147 leax DRVMEM,x else increase X by drive table size
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
148 decb decrement drive number
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
149 bra lsn@ branch to loop
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
150
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
151 * X = drive table pointer for PD.DRV
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
152 * Copy DD.SIZ bytes (LSN0) from buffer to drive table
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
153 CopyLSN0 EQU *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
154 ldu PD.BUF,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
155 IFNE H6309
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
156 ldw #DD.SIZ
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
157 tfm u+,x+
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
158 ELSE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
159 ldb #DD.SIZ
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
160 CpyLSNLp pulu a one cycle less than lda ,u+
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
161 sta ,x+
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
162 decb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
163 bne CpyLSNLp
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
164 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
165 rret rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
166
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
167 IFNE HDBDOS
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
168 * For HDB-DOS, we must add in drive number
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
169 * First, multiply drive number in descriptor by $276 (630 sectors),
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
170 * then, add the product to the PSect
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
171 ComputeHDB
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
172 IFNE H6309
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
173 clra
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
174 ldb V.HDBDrive,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
175 muld #$0276
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
176 addw V.PhysSect+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
177 stw V.PhysSect+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
178 adcb V.PhysSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
179 stb V.PhysSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
180 ELSE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
181 leas -4,s make a stack to store product of $276 * DriveNum
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
182 lda V.HDBDrive,u get drive number
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
183 ldb #$76
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
184 mul
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
185 std 2,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
186 lda V.HDBDrive,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
187 ldb #$02
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
188 mul
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
189 std ,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
190 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
191 lda 1,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
192 addd 2,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
193 std 2,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
194 bcc f@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
195 inc ,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
196 f@ lda ,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
197 sta 1,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
198 ldd 2,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
199 addd V.PhysSect+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
200 std V.PhysSect+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
201 lda 1,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
202 adca V.PhysSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
203 sta V.PhysSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
204 leas 4,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
205 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
206 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
207 bye rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
208
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
209 * 256 byte sector device: setup for low level driver to put 256 byte sector directly into PD.BUF
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
210 Read256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
211 lbsr Log2Phys
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
212 * We may not have to do this (and disturb the cache as a result)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
213 * lda PD.DRV,y get current drive number
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
214 * sta V.LastDrv,u and make this the current drive
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
215 lda #1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
216 sta V.SectCnt,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
217 ldx PD.BUF,y put address of PD.BUF directly into cache spot
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
218 stx V.CchPSpot,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
219 * Call low-level driver read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
220 ldx V.LLRead,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
221 lbra LLCall
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
222
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
223 * Read Sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
224 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
225 * The sector will be read from either the cache or the controller.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
226 * A cache "hit" is verified by two methods:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
227 * 1. Comparing the drive number of the drive for the current path to
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
228 * the drive number of the last path -- if they match, we *MAY*
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
229 * have a cache hit. If not, we fill the cache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
230 * 2. If #1 matches, then we know the current drive and the last drive
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
231 * are the same. We then check the logical sector to see if it is
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
232 * in the cache.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
233 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
234 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
235 * Y = address of path descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
236 * U = address of device memory area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
237 * B = Sector bits 23-16
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
238 * X = Sector bits 15-0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
239 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
240 ReadSect bsr PreXfr to pre-transfer stuff
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
241 bcs bye branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
242 IFNE HDBDOS
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
243 tst V.HDBPart,u HDB-DOS partition?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
244 beq NotHDB
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
245 * This is the HDB-DOS partition "read" code path.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
246 * As an HDB-DOS partition, we are interested ONLY in reading the first 256 bytes
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
247 * regardless of the size of the cache.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
248 lda V.SectSize,u get sector size (0=256,1=512,2=1024,etc)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
249 leax SCTTBL,pcr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
250 lda a,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
251 sta V.Log2Phys,u set logical sectors per phys
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
252 lda #$01 get sector count
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
253 sta V.SectCnt,u and store it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
254 sta V.CchDirty,u the cache will ALWAYS be dirty in HDB-DOS mode
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
255 lda V.LogSect,u get logical sector stored earlier
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
256 sta V.PhysSect,u save off logical sector as physical one
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
257 ldd V.LogSect+1,u get logical sector stored earlier
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
258 std V.PhysSect+1,u save off logical sector as physical sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
259 lbsr AddSectorOffset add in partition offset and HDB-DOS drive
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
260 bsr ComputeHDB and compute HDB-DOS offset
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
261 * Set up the pointer to the buffer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
262 ldx V.CchAddr,u get address of cache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
263 stx V.CchPSpot,u save in current sector pointer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
264 * Call low-level driver
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
265 ldx V.LLRead,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
266 lbsr LLCall
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
267 bcs bye
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
268 ldx V.CchAddr,u get cache pointer which holds HDB-DOS sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
269 bra CopyXToPDBUF
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
270 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
271 NotHDB
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
272 * New: Dec 20, 2011
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
273 * Fast path opportunity: if sector size is 256 bytes, call LLRead right into PD.BUF
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
274 tst V.SectSize,u (0=256 byte sector device)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
275 beq Read256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
276 bsr ValidateCache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
277 bcs ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
278 * Copy appropriate 256 byte sector from V.CchAddr to PD.BUF,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
279 lda V.CchSize,u get hi byte of cache size
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
280 deca
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
281 anda V.LogSect+2,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
282 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
283 ldx V.CchAddr,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
284 leax d,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
285 CopyXToPDBUF pshs y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
286 ldy PD.BUF,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
287 IFNE H6309
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
288 ldw #256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
289 tfm x+,y+
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
290 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
291 puls y,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
292 ELSE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
293 clr ,-s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
294 next@ ldd ,x++
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
295 std ,y++
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
296 inc ,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
297 bpl next@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
298 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
299 puls a,y,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
300 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
301 ex@ rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
302
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
303 * ValidateCache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
304 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
305 * Check if the cache is coherent (i.e. contains requested sector).
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
306 * If the cache is NOT coherent, it calls 'FillCache' to fill it.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
307 ValidateCache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
308 * We must determine if the currently requested sector is already in cache.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
309 * First, is this drive the same as the last drive that accessed the cache?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
310 * If not, then we need to fill the cache with sectors from the current drive.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
311 tst V.CchDirty,u has cache been initialized?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
312 bne nomatch branch if not
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
313 lda PD.DRV,y get current drive
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
314 cmpa V.LastDrv,u save as last drive to access cache?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
315 bne nomatch if not, fill cache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
316 * Same drive as last access... is this sector in cache?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
317 ldb V.LogSect,u save off logical sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
318 cmpb V.CchBase,u compare bits 23-16
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
319 bne nomatch branch if not the same
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
320 lda V.LogSect+1,u save off logical sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
321 ldb V.CchSize,u get hi byte of cache size
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
322 decb decrement (e.g. 8=7,4=3,2=1,1=0)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
323 comb invert (e.g. 7=$F8,3=$FC,1=$FE,0=$FF)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
324 andb V.LogSect+2,u mask out cached sectors
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
325 cmpd V.CchBase+1,u same as what's in cache?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
326 beq exok@ YES, WE HAVE A CACHE HIT!!!
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
327 nomatch bra FillCache no, we must fil the cache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
328 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
329 * PreXfr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
330 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
331 * Called at read/write to gather info from path descriptor and
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
332 * device descriptor.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
333 PreXfr stb V.LogSect,u save off logical sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
334 stx V.LogSect+1,u save off logical sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
335 lda PD.STP,y get possible HDB-DOS drive number
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
336 sta V.HDBDrive,u save off in our statics
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
337 lda PD.TYP,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
338 anda #TYPH.SSM lob off all but sector size bits
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
339 * SmartCache - check if our current cache can accommodate this sector size
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
340 cmpa V.SectSize,u do we need to expand?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
341 bls no@ branch if not
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
342 * Yes, we need to free our current cache mem and alloc more
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
343 pshs a,u save regs
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
344 ldd V.CchSize,u get current cache size
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
345 ldu V.CchAddr,u and cache pointer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
346 beq nofree@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
347 os9 F$SRtMem return that memory
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
348 nofree@ puls a,u restore regs
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
349 lbsr ExpandCache go expand cache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
350 bcs ex@ and branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
351 sta V.SectSize,u save new sector size
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
352 no@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
353 lda PD.DNS,y get DNS byte
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
354 anda #DNS.HDB isolate HDB-DOS flag
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
355 sta V.HDBPart,u and save state
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
356 exok@ clrb clear carry
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
357 rts return
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
358 ex@ clr V.SectSize,u clear sector size to force realloc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
359 orcc #Carry set carry (indicates error)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
360 rts return
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
361
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
362 * FillCache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
363 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
364 * Fill the cache with sectors from the device.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
365 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
366 * Destroys: A, B, X
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
367 FillCache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
368 lda V.LogSect,u get logical sector bits 23-16
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
369 sta V.CchBase,u save as cached base
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
370 lda V.LogSect+1,u save off logical sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
371 ldb V.CchSize,u get hi byte of cache size (1, 2, 4 or 8)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
372 decb decrement (e.g. 8=7,4=3,2=1,1=0)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
373 comb invert (e.g. 7=$F8,3=$FC,1=$FE,0=$FF)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
374 andb V.LogSect+2,u mask out cached sectors
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
375 std V.CchBase+1,u save as cached base
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
376 lbsr Log2Phys convert logical sectors to physical
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
377 lda PD.DRV,y get current drive number
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
378 sta V.LastDrv,u and make this the currently cached drive
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
379 * Set up the transfer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
380 ldb V.CchSize,u get upper 8 bits of cache size
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
381 lda V.SectSize,u get sector size (0=256,1=512,2=1024,etc)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
382 leax SCTTBL,pcr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
383 lda a,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
384 sta V.Log2Phys,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
385 lda V.SectSize,u get sector size (0=256,1=512,2=1024,etc)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
386 beq ok@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
387 lsr@ lsrb divide by 2
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
388 deca decrement
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
389 bne lsr@ else divide again
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
390 ok@ stb V.SectCnt,u save sector count
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
391 decb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
392 comb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
393 andb V.PhysSect+2,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
394 stb V.PhysSect+2,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
395 * Set up the pointer to the buffer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
396 ldx V.CchAddr,u get pointer to big buffer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
397 stx V.CchPSpot,u save in current sector pointer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
398 * Call low-level driver read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
399 ldx V.LLRead,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
400 bsr LLCall
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
401 bcs ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
402 clr V.CchDirty,u cache is no longer dirty
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
403 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
404 rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
405 ex@ stb V.CchDirty,u store error code as dirty flag
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
406 rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
407
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
408
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
409 SCTTBL FCB 256/256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
410 FCB 512/256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
411 FCB 1024/256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
412 FCB 2048/256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
413
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
414 * GetStat/SetStat
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
415 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
416 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
417 * R$B = function code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
418 * Y = address of path descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
419 * U = address of device memory area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
420 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
421 * Exit:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
422 * CC = carry set on error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
423 * B = error code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
424 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
425 SetStat leau UOFFSET,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
426 ldx V.LLStSt,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
427 bra LLCall
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
428
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
429 SSVarSect ldb PD.DRV,y get drive number
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
430 leax V.SSCache,u point to sector size cache table
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
431 abx
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
432 lda ,x get sector size
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
433 bne go2@ if not zero, use that value
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
434 pshs x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
435 ldx PD.RGS,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
436 pshs x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
437 leas -R$Size,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
438 sts PD.RGS,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
439 lda #SS.DSize
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
440 sta R$B,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
441 bsr gs2 make a call to low level driver's SS.DSize
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
442 * Be sure that no instructions from here to the bcs modify carry
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
443 lda R$A,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
444 leas R$Size,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
445 puls x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
446 stx PD.RGS,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
447 puls x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
448 bcs ex@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
449 cmpa #8 2048 byte sector?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
450 beq go@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
451 lsra else shift right
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
452 FCB $8C skip next two bytes (cmpx...)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
453 go@ lda #3
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
454 sta ,x save newly acquired value off into cached size table
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
455 go2@ pshs a
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
456 lda PD.TYP,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
457 anda #^TYPH.SSM
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
458 ora ,s+
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
459 * Boisy's Notes 3/27/06:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
460 * Notice that we save the true sector size of the device in the PD.TYP byte of
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
461 * the path descriptor EACH TIME SS.VarSect is called. This is important,
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
462 * because it alleviates the user from having to set this value in the device
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
463 * descriptor in a situation where the device being accessed has a larger sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
464 * size than what is in the device descriptor.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
465 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
466 * Note that the value in the device descriptor IS used to initially determine
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
467 * the size of the cache at INIT time since we haven't even talked to the
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
468 * controller at that time yet to query it for its size.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
469 * sta PD.TYP,y and in path descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
470 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
471 ex@ rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
472
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
473
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
474 GetStat leau UOFFSET,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
475 ldx PD.RGS,y get registers
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
476 ldb R$B,x get caller's B
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
477 cmpb #SS.VarSect
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
478 beq SSVarSect
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
479
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
480 gs2 ldx V.LLGtSt,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
481
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
482 * Entry: Y = path desc ptr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
483 * U = statics ptr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
484 * X = address of routine to call
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
485 LLCall
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
486 IFEQ USECS-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
487 pshs a preserve A for duration of csacq_wait
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
488 lda #255 wait the maximum number of counts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
489 bsr csacq_wait acquire the critical section
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
490 tsta test A for zero
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
491 puls a restore A
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
492 beq cserr return if A was zero (semaphore wasn't acquired)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
493 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
494 pshs u,y save U and Y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
495 jsr ,x call low level routine
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
496 puls y,u restore U and Y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
497
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
498 IFEQ USECS-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
499 * Critical Section Release - clear the critial section to zero, allowing others to use it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
500 csrel pshs cc preserve CC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
501 clr V.LLSema,u clear critical section
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
502 puls cc,pc restore CC and return
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
503 cserr comb set the carry
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
504 ldb #111 and load B with error indicating a semaphore timeout
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
505 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
506 rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
507
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
508 IFEQ USECS-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
509 * Critical Section Acquire With Wait
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
510 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
511 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
512 * A = number of times to check before giving up
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
513 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
514 * Exit:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
515 * A = status (>0 = Critical section acquired, 0 = Critical section not acquired)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
516 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
517 csacq_wait pshs cc save CC on stack
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
518 orcc #IntMasks mask interrupts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
519 tst V.LLSema,u does someone already have the critical section?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
520 bne w@ if so, then branch
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
521 inc V.LLSema,u else claim critical section (0->1)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
522 e@ puls cc,pc restore CC and return
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
523 w@ deca decrement our timeout counter
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
524 beq e@ if zero, we've timed out, return
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
525 puls cc give interrupts a chance to breathe
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
526 IFGT Level-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
527 * Give up timeslice unless this is the system
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
528 pshs x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
529 ldx D.Proc get proc descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
530 cmpx D.SysPrc system?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
531 beq wd@ yep, system cannot sleep
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
532 * ldx D.AProcQ get active proc queue
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
533 * beq wd@ if empty, return
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
534 ldx #$0001
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
535 os9 F$Sleep give up timeslice
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
536 wd@ puls x return to caller
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
537 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
538 bra csacq_wait and try again
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
539 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
540
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
541
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
542 * Log2Phys - Convert logical sector to physical sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
543 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
544 * Stores V.PhysSect,u from V.LogSect,u based on V.SectSize,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
545 * Also adds IT.SOFF1-IT.SOFF3 to V.PhysSect,u for partitioning.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
546 * Results are placed in V.PhysSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
547 Log2Phys lda V.LogSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
548 sta V.PhysSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
549 ldd V.LogSect+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
550 std V.PhysSect+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
551 lda V.SectSize,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
552 beq AddSectorOffset
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
553 DivBy2 lsr V.PhysSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
554 ror V.PhysSect+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
555 ror V.PhysSect+2,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
556 deca
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
557 bne DivBy2
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
558 * This routine adds the 3 byte sector offset in the
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
559 * device descriptor to the physical sector.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
560 AddSectorOffset
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
561 ldx PD.DEV,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
562 ldx V$DESC,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
563 ldd IT.SOFF2,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
564 addd V.PhysSect+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
565 std V.PhysSect+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
566 lda IT.SOFF1,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
567 adca V.PhysSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
568 sta V.PhysSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
569 logex rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
570
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
571
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
572 * 256 byte sector device: setup for low level driver to put 256 byte sector directly into PD.BUF
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
573 Write256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
574 bsr Log2Phys
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
575 * We may not have to do this (and disturb the cache as a result)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
576 * lda PD.DRV,y get current drive number
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
577 * sta V.LastDrv,u and make this the current drive
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
578 lda #1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
579 sta V.SectCnt,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
580 ldx PD.BUF,y put address of PD.BUF directly into cache spot
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
581 stx V.CchPSpot,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
582 * Call low-level driver read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
583 ldx V.LLWrite,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
584 bra LLCall
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
585
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
586 * Write
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
587 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
588 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
589 * B = MSB of the disk's LSN
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
590 * X = LSB of the disk's LSN
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
591 * Y = address of path descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
592 * U = address of device memory area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
593 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
594 * Exit:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
595 * CC = carry set on error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
596 * B = error code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
597 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
598 Write leau UOFFSET,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
599 lbsr PreXfr to pre-transfer stuff
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
600 bcs logex branch if error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
601 IFNE HDBDOS
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
602 lda V.HDBPart,u HDB-DOS partition?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
603 beq h@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
604 * HDB-DOS partition code path
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
605 sta V.CchDirty,u cache is dirty
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
606 lda V.SectSize,u get sector size (0=256,1=512,2=1024,3=2048)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
607 leax SCTTBL,pcr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
608 lda a,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
609 sta V.Log2Phys,u set logical sectors per phys
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
610 lda V.LogSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
611 sta V.PhysSect,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
612 ldd V.LogSect+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
613 std V.PhysSect+1,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
614 bsr AddSectorOffset add in partition offset and HDB-DOS drive
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
615 lbsr ComputeHDB and compute HDB-DOS offset
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
616 ldx PD.BUF,y get path desc buffer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
617 stx V.CchPSpot,u we write directly from PD.BUF
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
618 bra writeit
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
619 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
620 * New: Dec 20, 2011
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
621 * Fast path opportunity: if sector size is 256 bytes, call LLRead right into PD.BUF
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
622 h@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
623 tst V.SectSize,u (0=256 byte sector device)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
624 beq Write256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
625 lbsr ValidateCache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
626 bcs logex
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
627 * Copy appropriate 256 byte sector from PD.BUF,y to V.CchAddr,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
628 * Determine where in the cache we copy this 256 byte sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
629 bsr Log2Phys compute physical sector from logical sector
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
630 lda V.CchSize,u get hi byte of cache size
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
631 deca
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
632 anda V.LogSect+2,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
633 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
634 ldx V.CchAddr,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
635 leax d,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
636 stx V.CchLSpot,u save for possible verify later
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
637 pshs y save path desc for now
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
638 ldy PD.BUF,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
639 IFNE H6309
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
640 ldw #256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
641 tfm y+,x+
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
642 puls y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
643 ELSE
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
644 clr ,-s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
645 loop@ ldd ,y++
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
646 std ,x++
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
647 inc ,s
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
648 bpl loop@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
649 puls a,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
650 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
651 * Now that sector is copied, determine where in cache we start
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
652 lda V.LogSect+2,u get logical sector bits 7-0
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
653 leax MASKTBL,pcr point to base of cache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
654 ldb V.SectSize,u get sector size in B
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
655 anda b,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
656 pshs a
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
657 lda V.CchSize,u get upper 8 bits of cache size
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
658 deca
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
659 anda ,s+
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
660 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
661 ldx V.CchAddr,u point to base of cache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
662 leax d,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
663 stx V.CchPSpot,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
664 * Call low-level driver write routine
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
665 writeit lda #$01
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
666 sta V.SectCnt,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
667 ldx V.LLWrite,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
668 lbsr LLCall
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
669 * If verify flag is on, read back and compare
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
670 tst PD.VFY,y verify flag set?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
671 bne ex@ if so, we don't verify -- just exit
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
672 * Read back physical sector into cache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
673 tst V.HDBPart,u HDB-DOS partition?
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
674 beq o@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
675 * If in HDB-DOS mode, we simply place the base address of the cache into
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
676 * V.CchPSpot... and V.CchLSpot for later verify
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
677 ldx V.CchAddr,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
678 stx V.CchPSpot,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
679 stx V.CchLSpot,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
680 o@ lda #$01
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
681 sta V.SectCnt,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
682 ldx V.LLRead,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
683 lbsr LLCall
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
684 * Now compare PD.BUF to sector in cache just re-read
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
685 ldx V.CchLSpot,u get spot in cache where 256 byte sector is.
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
686 ldy PD.BUF,y get pointer to buffer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
687 clra
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
688 a@ ldb ,x+ get byte in cache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
689 cmpb ,y+ compare against byte in PD.BUF
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
690 bne err@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
691 deca
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
692 bne a@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
693 ex@ clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
694 rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
695 err@ comb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
696 ldb #E$Write
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
697 stb V.CchDirty,u make cache dirty due to error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
698 rts
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
699
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
700 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
701 * Init
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
702 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
703 * Entry:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
704 * Y = address of device descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
705 * U = address of device memory area
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
706 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
707 * Exit:
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
708 * CC = carry set on error
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
709 * B = error code
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
710 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
711 Init pshs y save device descriptor ptr on stack
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
712 ldb #DrvCount get maximum drives supported
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
713 stb V.NDRV,u save in our device memory
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
714 leax DRVBEG,u point X to the drive tables
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
715 lda #$FF
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
716 * Invalidate V.NDRV drive tables
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
717 drvx sta DD.TOT,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
718 sta DD.TOT+1,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
719 sta DD.TOT+2,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
720 leax DRVMEM,x point to next drive table
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
721 decb decrement counter
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
722 bne drvx if not zero, continue
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
723 * Link to low-level driver
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
724 ldd IT.LLDRV,y point to name in descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
725 leax d,y point to name in descriptor
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
726 pshs u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
727 IFGT Level-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
728 ldd D.Proc get curr proc ptr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
729 pshs d save on stack
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
730 ldd D.SysPrc get system process desc ptr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
731 std D.Proc and make current proc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
732 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
733 lda #Sbrtn+Objct
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
734 os9 F$Link link to it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
735 IFGT Level-1
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
736 puls x get curr proc ptr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
737 stx D.Proc restore
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
738 ENDC
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
739 tfr u,x transfer module address to X
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
740 puls u restore U
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
741 leau UOFFSET,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
742 bcs ret@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
743 stx V.LLAddr,u else save module address
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
744 * setup entry points to low-level module
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
745 leax V.LLInit,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
746 lda #6 number of entry points
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
747 l@ sty ,x++
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
748 leay 3,y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
749 deca
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
750 bne l@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
751 * Call low-level driver init
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
752 ldy ,s grab path desc ptr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
753 ldx V.LLInit,u
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
754 lbsr LLCall
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
755 bcc r@
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
756 ret@ puls y,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
757 * Allocate cache memory
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
758 r@ lda IT.TYP,y get type byte
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
759 anda #TYPH.SSM mask out all but sector size
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
760 * Added Dec 20, 2011: save off to V.SectSize (never got initialized until now!)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
761 sta V.SectSize,u clear out V.SectSize
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
762 puls y
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
763 * Fall through to ExpandCache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
764
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
765 * Entry: A = cache size to expand to (1 = 512, 2 = 1024, 3 = 2048)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
766 * Exit: D is destroyed
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
767 * Note: any previously allocated cache memory must have been
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
768 * freed before this call!
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
769 *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
770 ExpandCache
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
771 pshs a,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
772 leax CCHTBL,pcr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
773 lda a,x get 1, 2, 4 or 8
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
774 sta V.CchDirty,u make cache dirty since we will expand it
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
775 clrb
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
776 std V.CchSize,u save cache size (256, 512, 1024 or 2048)
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
777 tfr u,x
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
778 os9 F$SRqMem allocate cache memory
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
779 stu V.CchAddr,x save cache ptr
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
780 tfr x,u restore mem pointer
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
781 ex@ puls a,x,pc
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
782
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
783
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
784 CCHTBL FCB 256/256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
785 FCB 512/256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
786 FCB 1024/256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
787 FCB 2048/256
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
788
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
789 MASKTBL FCB $07,$06,$04,$00
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
790
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
791 EMOD
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
792 eom EQU *
17d43fd29ee2 Integration of SuperDriver
boisy
parents:
diff changeset
793 END