-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopen.aii
286 lines (217 loc) · 3.58 KB
/
open.aii
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
include 'gsos.equ'
include 'minix.equ'
include 'records.equ'
include 'fst.equ'
include 'fst.macros'
include 'M16.Debug'
import do_ignore
import do_refnum
import do_file_type
import do_aux_type
import do_storage_type
import do_option_list
import do_eof
import do_blocks
import do_r_eof
import do_r_blocks
import do_create_date_time
import do_mod_date_time
entry do_fcr_access
entry check_resource
entry check_access
entry build_fcr
import path_to_inode
import load_inode
import disk_inode:v1_inode
import disk_super:v1_super
open procname export
with fst_parms
with dev_parms
with dp
; find the inode...
jsr path_to_inode
bcs exit
jsr load_inode
bcs exit
; sanity check the parameters.
jsr check_resource
bcs exit
jsr check_access
bcs exit
; now create the fcr.
jsr build_fcr
bcs exit
; output fields...
lda <call_class
beq class0
class1
lda [param_blk_ptr] ; pcount
dec a
asl a ; x 2
asl a ; x 4
tax
dispatch open_dcb_1
lda tool_error
cmp #1
rtl
class0
ldx #open_dcb_0_size-4
dispatch open_dcb_0
lda tool_error
cmp #1
rtl
exit
rtl
open_dcb_0
dc.w 0, do_refnum
; all remaining fields are read-only.
open_dcb_0_size equ *-open_dcb_0
open_dcb_1
;dc.w 0, do_ignore ; pCount
dc.w $02, do_refnum ; refNum
dc.w $04, do_ignore ; path
dc.w $08, do_ignore ; request access
dc.w $0a, do_ignore ; resource resourceNumber
dc.w $0c, do_fcr_access ; actual access
dc.w $0e, do_file_type
dc.w $10, do_aux_type
dc.w $14, do_storage_type
dc.w $16, do_create_date_time
dc.w $1e, do_mod_date_time
dc.w $26, do_option_list
dc.w $2a, do_eof
dc.w $2e, do_blocks
dc.w $32, do_r_eof
dc.w $36, do_r_blocks
endp
build_fcr proc
with dp
import target:GSString32
; use vcr.vname. this is only needed for device-relative paths, anyhow.
; can vcr be invalidated? copy vcr.vname to target, just in case.
ldy #vcr.vname.length
lda [my_vcr],y
sta target.length
ldx #0
ldy #vcr.vname.text
vcr_vname
@loop
lda [my_vcr],y
sta target.text,x
iny
iny
inx
inx
cpx target.length
bcc @loop
; build filename string...
lda #fcr.__sizeof
ldx #target
ldy #^target
jsl alloc_fcr
bcc @ok
lda #out_of_mem
rts
@ok
jsl deref
stx my_fcr
sty my_fcr+2
ldy #vcr.open_count
lda [my_vcr],y
inc a
sta [my_vcr],y
lda #read_access
ldy #fcr.access
sta [my_fcr],y
lda #fst_id
ldy #fcr.fst_id
sta [my_fcr],y
ldy #vcr.id
lda [my_vcr],y
ldy #fcr.vcr_id
sta [my_fcr],y
lda inode
ldy #fcr.inode
sta [my_fcr],y
lda #0
ldy #fcr.dirty
sta [my_fcr],y
ldy #fcr.mark
sta [my_fcr],y
iny
iny
sta [my_fcr],y
; memory is 0-filled.
; copy the disk inode
ldx #v1_inode.__sizeof - 2
ldy #fcr.disk_inode.__end - 2
fcr_inode
@loop
lda disk_inode,x
sta [my_fcr],y
dey
dey
dex
dex
bpl @loop
clc
rts
endp
check_resource procname
; verify the resourceNumber is ok
; sets a/carry on error.
with fst_parms, dp
lda <call_class
beq done
lda [<param_blk_ptr] ; pcount
cmp #4
blt done
ldy #OpenRecGS.resourceNumber
lda [<param_blk_ptr],y
beq done
cmp #1
bne param_range
lda #res_not_found
sec
rts
param_range
lda #parm_range_err
sec
rts
done
clc
rts
endp
do_fcr_access procname
with fst_parms, dp
phy
ldy #fcr.access
lda [my_fcr],y
ply
sta [param_blk_ptr],y
rts
endp
check_access procname
with fst_parms, dp
; todo ....
; for now, read-only.
; class 0 ok
; class 1 w/ pcount < 4 ok
lda call_class
beq done
lda [param_blk_ptr]
cmp #4
bcc done
ldy #OpenRecGS.requestAccess
lda [param_blk_ptr],y
; 0 or 1 are acceptable.
cmp #2
bcc done
lda #invalid_access
sec
rts
done
clc
rts
endp
end