Subversion Repositories MB01 Project

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 - 1
;;
2
;; Copyright (c) 2016 Marco Granati <mg@unet.bz>
3
;;
4
;; Permission to use, copy, modify, and distribute this software for any
5
;; purpose with or without fee is hereby granted, provided that the above
6
;; copyright notice and this permission notice appear in all copies.
7
;;
8
;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
;;
16
 
17
;; name: sys_fs.inc
18
;; rev.: 2016/02/09
19
;; o.s. 65C816 version v1.0
20
 
21
.LIST on
22
 
23
;---------------------------------------------------------------------------
24
 
25
WKB	.EQU	^FATSOFS	; working bank
26
 
27
HPLMAX	.EQU	32	; Max. subdirectory level
28
 
29
XBSTART	.EQU	$0B40		; first x-mem buffer
30
XBLST	.EQU	$0FFF		; last x-mem buffer
31
XBCNT	.EQU	XBLST+1-XBSTART	; x-mem buffer's count
32
;BS	.EQU	XBCNT*2		; word array size
33
;BCBCNT	.EQU	XBCNT / 16
34
BCBCNT	.EQU	$200
35
BCBXBNK	.EQU	$0C00
36
;XBUFH	.EQU	XMEMBUF
37
 
38
HASHMAX		.EQU	1024
39
HCBSTART	.EQU	$0008
40
HCBBNK		.EQU	4
41
 
42
FAT0X	.EQU	$E0
43
FAT1X	.EQU	$F0
44
DMACNT	.EQU	64
45
 
46
;---------------------------------------------------------------------------
47
; Logical Drive Table (LDT) -- page 0 offset's
48
;---------------------------------------------------------------------------
49
 
50
 STRUCT		LDT
51
ldt_fg1		.DB		; logical volume flag's
52
				; <7>: device ready (fdc drive or ata device)
53
				; <6>: if=1->HD/CF else->FD
54
				; <0>: phisycal device number
55
 
56
ldt_fg2		.DB		; <7>: valid volume (fat volume or cbm disk)
57
				; <6>: if=1->FAT else->CBM (FD only)
58
				; <5>: disk format checked
59
				; <1:0>: disk format (fdc only)
60
 
61
ldt_fp		LP		; fat table buffer long pointer
62
ldt_fbuf	.DB		; fat table: x-mem base bank/dma buffer
63
 
64
ldt_root	.DW		; lba of root dir
65
ldt_fat1	.DW		; lba of fat1 table
66
ldt_fat2	.DW		; lba of fat2 table
67
ldt_cls		.DW		; lba of first data cluster
68
ldt_max		.DW		; max usable cluster + 1
69
ldt_csiz	.DB		; cluster size (1,2,4,8,16,32,64)
70
ldt_cshf	.DB		; cluster shift (0,1,2,3,4,5,6)
71
ldt_fsiz	.DB		; fat table size (if 0 -> 256)
72
ldt_rsiz	.DB		; root dir. size (sector's)
73
ldt_rent	.DW		; root dir. max. entries
74
ldt_cent	.DW		; max. entries in dir. cluster
75
ldt_eoc		.DW		; end of cluster chain marker
76
ldt_mcls	.DB		; mask for clust. module: 00,01,03,07,0F,1F,3F
77
ldt_fmt		.DB		; floppy disk format (0,1,2,FF if ata device)
78
ldt_cdlp	.DW		; current working dir list pointer
79
ldt_cdcls	.DW		; current working dir start cluster
80
ldt_free	.DW		; count of free cluster's
81
ldt_nxt		.DW		; next free cluster
82
ldt_cdlvl	.DB		; current working dir level count
83
ldt_pbr		LP		; long pointer to PBR cache buffer
84
 ESTRUCT	LDT
85
 
86
;---------------------------------------------------------------------------
87
; Hierarchical Path List (HPL) -- 16 bit offset's
88
;---------------------------------------------------------------------------
89
 
90
 LSTRUCT	HPL
91
hpl_cls		.DW		; parent cluster
92
hpl_ix		.DW		; entry index in parent cluster
93
hpl_fcb		.DS	11	; fcb name
94
hpl_lst		.DB		; unused
95
 ESTRUCT	HPL
96
 
97
;---------------------------------------------------------------------------
98
; Buffer Control Block (BCB) -- 16 bit offset's
99
;---------------------------------------------------------------------------
100
 
101
 LSTRUCT	BCB
102
bcb_next	.DW		; next logical linked BCB
103
bcb_drv		.DB		; logical drive
104
bcb_sec		.DB		; sector offset
105
bcb_cls		.DW		; cluster
106
bcb_lba		.DW		; sector lba address
107
bcb_lbah	.DW		; lba high
108
bcb_head	.EQU	bcb_lbah	; floppy head
109
bcb_buf		.DW		; x-mem buffer number
110
bcb_trk		.EQU	bcb_buf	; floppy track(low) & sector(hi)
111
bcb_ptr		.DW		; buffer pointer
112
bcb_xbnk	.DW		; buffer pointer hi & x-mem bank
113
bcb_dma		.EQU	bcb_xbnk	; buffer pointer hi & dma buffer
114
 ESTRUCT	BCB
115
 
116
;---------------------------------------------------------------------------
117
; FAT Working Segment
118
;---------------------------------------------------------------------------
119
 
120
_FATS:	.SECTION ref_only, common, offset FATSOFS, range $010000 $01FFFF ;FAT Struct's
121
_FATS_START	.DS	0
122
 
123
; current working directory HPL
124
cwdl0		.DS	(HPLSIZE*HPLMAX)
125
cwdl1		.DS	(HPLSIZE*HPLMAX)
126
cwdl2		.DS	(HPLSIZE*HPLMAX)
127
cwdl3		.DS	(HPLSIZE*HPLMAX)
128
 
129
; current building path HPL
130
cbpl		.DS	(HPLSIZE*HPLMAX)
131
HPL_CLS		.EQU	hpl_cls+cbpl
132
HPL_IX		.EQU	hpl_ix+cbpl
133
HPL_FCB		.EQU	hpl_fcb+cbpl
134
 
135
; BCB list's
136
bcbstart	.DS	(BCBCNT*BCBSIZE)
137
bcbend		.DS	0
138
dmastart	.DS	(DMACNT*BCBSIZE)
139
dmaend		.DS	0
140
dma0s		.DS	(17*BCBSIZE)
141
dma1s		.DS	(17*BCBSIZE)
142
 
143
_FATS_END	.DS	0
144
FATSSIZ		.EQU	(_FATS_END-_FATS_START)
145
.ENDS
146
 
147
;---------------------------------------------------------------------------
148
 
149
; segment for store HCB struct's (Hash Control Block)
150
_HCBS:	.SECTION ref_only, common, offset HCBSST, range HCBSST HCBSEND	;HCB Struct's
151
hcb_next	.DW		; pointer to next HCB
152
hcb_cls		.DW		; cluster number
153
hcb_seq		.DW		; sequence number + logical drive number
154
hcb_cnt		.DW		; number of hashed entries
155
hcb_data	.DS	0	; hash buffer data
156
.ENDS
157
 
158
;---------------------------------------------------------------------------
159
; direct page for LDT var's
160
;---------------------------------------------------------------------------
161
 
162
DPLDT:	.SECTION page0, common, ref_only, offset 0	;LDT D.P.
163
 
164
ldt0		.DS	LDTSIZE
165
ldt1		.DS	LDTSIZE
166
ldt2		.DS	LDTSIZE
167
ldt3		.DS	LDTSIZE
168
 
169
ldtp		.DS	4	; pointer to LDT's in DPLDT page
170
sysbuf		.DS	2	; floppy track 0 cache buffer
171
bpath		.DS	80
172
 
173
bpath1		.DS	0
174
.ENDS
175
 
176
;---------------------------------------------------------------------------
177
; direct page for FAT var's
178
;---------------------------------------------------------------------------
179
 
180
DPFAT:	.SECTION page0, common, ref_only, offset 0	;FAT D.P.
181
 
182
ostos		.DW		; saved top of stack
183
ioerr		.DB		; i/o error
184
ioerr2		.DB		; extended i/o error
185
hcbroot		.DW		; HCB struct's list
186
hcblst		.DW		; the last one HCB
187
hsiz		.DB		; how many sector's an HCB can hold
188
hlog2		.DB		; shift count related to hsiz
189
bcbroot		.DW		; BCB buffer's list
190
bcblst		.DW		; the last one BCB
191
dmaroot		.DW		; dma BCB buffer's list
192
dmalst		.DW		; the last one dma BCB
193
dmabcb		.DW		; BCB list for floppy root, cluster#2,#3&#4
194
fspt		.DB		; sector per track (floppy)
195
pdrive		.DB		; phisycal drive number
196
bplvl		.DB		; subdir level while build path
197
defdrv		.DB		; default drive
198
 
199
; the first block of ldt_ var's is copied from the LDT struct
200
ldtfg1		.DB		; logical volume flag's
201
				; <7>: device ready (fdc drive or ata device)
202
				; <6>: if=1->HD/CF else->FD
203
				; <0>: phisycal device number
204
 
205
ldtfg2		.DB		; <7>: valid volume (fat volume or cbm disk)
206
				; <6>: if=1->FAT else->CBM (FD only)
207
				; <5>: disk format checked
208
				; <1:0>: disk format (fdc only)
209
 
210
ldtfp		LP		; fat table buffer long pointer
211
ldtfbuf		.DB		; fat table: x-mem base bank/dma buffer
212
 
213
ldtroot		.DW		; lba of root dir
214
ldtfat1		.DW		; lba of fat1 table
215
ldtfat2		.DW		; lba of fat2 table
216
ldtcls		.DW		; lba of first data cluster
217
ldtmax		.DW		; max usable cluster + 1
218
ldtcsiz		.DB		; cluster size (1,2,4,8,16,32,64)
219
ldtcshf		.DB		; cluster shift (0,1,2,3,4,5,6)
220
ldtfsiz		.DB		; fat table size (if 0 -> 256)
221
ldtrsiz		.DB		; root dir. size (sector's)
222
ldtrent		.DW		; root dir. max. entries
223
ldtcent		.DW		; max. entries in dir. cluster
224
ldteoc		.DW		; end of cluster chain marker
225
ldtmcls		.DB		; mask for clust. module: 00,01,03,07,0F,1F,3F
226
ldtfmt		.DB		; floppy disk format (0,1,2, FF if ata device)
227
ldtcdlp		.DW		; current working dir list pointer
228
ldtcdcls	.DW		; current working dir start cluster
229
ldtfree		.DW		; count of free cluster's
230
ldtnxt		.DW		; next free cluster
231
ldtcdlvl	.DB		; current working dir level count
232
ldtpbr		LP		; long pointer to PBR cache buffer
233
 
234
chdcls		.DW		; last accessed chained dir. cluster
235
clsofs		.DW		; cluster's offset from start of chain
236
 
237
; not change order of the 2 following var's: will be accessed as 16 bit var
238
entofs		.DB		; entry offset from start of sector
239
secofs		.DB		; sector's offset from start of cluster
240
 
241
dircls		.DW		; directory cluster
242
dcnt		.DW		; directory entry counter
243
lba		.DW		; lba sector address
244
lbah		.DW		; lba is 24 bit's only
245
xbuf		.DW		; x-mem buffer transfer number
246
 
247
fhead		.EQU	lbah	; fd head
248
ftrack		.EQU	xbuf	; fd track
249
fsec		.EQU	xbuf+1	; fd sector
250
 
251
dfcbtyp		.DB		; FCB type to search
252
dfcbatt		.DB		; attribute of found FCB
253
 
254
curdrv		.DB		; current logical drive
255
fcbs		.DS	11	; file control block name
256
 
257
;dcmask		.DW		; mask to start of cluster
258
				; FFF0, FFE0, FFC0, FF80, FF00, FE00
259
 
260
fcbp		.DW		; FCB buffer long pointer
261
		.DW		; low=fcbp+2, high=x-mem bank or dma buffer
262
dmabuf		.EQU	fcbp+3	; dma buffer #
263
xmbank		.EQU	fcbp+3	; x-mem bank #
264
 
265
; temp area
266
hcbseq		.DB
267
hcbdrv		.DB
268
bcbcls		.DW
269
bcbdrv		.DB
270
bcbsec		.DB
271
 
272
thash		.DW
273
hcbrec	.EQU	thash
274
wtmp	.EQU	thash
275
 
276
hlast		.DW
277
hcbcls		.DW
278
hcbx		.DW
279
hcby		.DW
280
tmpp	.EQU	hlast	; temp. long pointer
281
tmpx	.EQU	hcbx
282
wild	.EQU	hcbx+1
283
fsiz	.EQU	hcby
284
fptr	.EQU	hcby+1
285
ldrv	.EQU	hcbx
286
tmpldt	.EQU	hcbx+1
287
 
288
fhash		.DW
289
fcbofs		.DW
290
bcbload		.DB
291
xstart		.DB
292
xend		.DB
293
seccnt		.DB
294
maxseq		.DB
295
dsiz		.DB
296
 
297
haswld		.DB
298
strix		.DB
299
pathp		LP		; long pointer to path string
300
 
301
; TEMP
302
quot		.DW
303
dvsor		.DW
304
troot		.DW
305
tlst		.DW
306
bdmask		.DW
307
bcmask		.DW
308
 
309
.ENDS
310
 
311
.LIST off