-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.aii
384 lines (298 loc) · 6.73 KB
/
main.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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
string asis
include 'gsos.equ'
include 'minix.equ'
include 'records.equ'
include 'fst.equ'
include 'fst.macros'
include 'M16.Debug'
entry app_entry
entry sys_entry
entry sys_startup
entry sys_shutdown
entry rtl_invalid_fst_op
entry rtl_bad_system_call
entry rtl_no_error
entry rtl_invalid_pcount
import judge_name
import create
import destroy
import change_path
import set_file_info
import get_file_info
import volume
import open
import read
import write
import flush
import close
import get_mark
import set_mark
import get_eof
import set_eof
import get_dir_entry
import get_dev_num
import format
import erase_disk
import disk_inode:v1_inode
import disk_super:v1_super
import debug
header proc
;
; FST attributes
; case-insensitive = $8000 [dispatcher should upper case]
; character device = $4000
; format = $2000
; clear high bits = $1000
; read-only = $0800
; Upper-case pathnames
; |Character-based FST
; ||Format capable
; |||Strip high bits from pathname characters
; ||||Read-Only FST
; |||||Reserved
; ||||||||||||||Format type
; |||||||||||||||| (00 = Universal)
; |||||||||||||||| (01 = Apple-generic)
; |||||||||||||||| (10 = Non-Apple)
; |||||||||||||||| (11 = Apple-][ specific)
fst_attr equ %0010100000000010 ;attributes
;(Format, ReadOnly, Non-Apple)
dc.b 'FST '
dc.l app_entry
dc.l sys_entry
dc.w fst_id
dc.w fst_attr ; $2002 ; flags -- format, block device, non-apple format
dc.w $8001 ; version 0.1, prototype.
dc.w 1024 ; block size
dc.l $00010000 ; max blocks/volume
dc.l $00000006 ; min blocks/volume
dc.l $10081c00 ; max file size
dc.l 0 ; reserved
str.b 'Minix' ; FST Name
str.b 'Minix FST' ; FST Comment
dc.w 0
; credits
str.b $0d,'Minix FST by Kelvin W Sherlock, 2014/2025',$0d
endp
data record
export global_buffer
global_buffer ds.l 1
endr
sys_entry procname
phk
plb
rep #$30
cpx #max_sys_call+1
bge rtl_no_error
jmp (@sys_table,x)
@sys_table
dc.w rtl_no_error
dc.w sys_startup
dc.w sys_shutdown
dc.w rtl_no_error ; remove vcr
dc.w rtl_no_error ; deferred flush
max_sys_call equ *-@sys_table-2
endp
rtl_no_error proc
lda #0
clc
rtl
endp
rtl_invalid_fst_op proc
lda #invalid_fst_op
sec
rtl
endp
rtl_bad_system_call proc
lda #bad_system_call
sec
rtl
endp
rtl_invalid_pcount proc
lda #invalid_pcount
sec
rtl
endp
sys_startup procname
jsl get_sys_gbuf
stx global_buffer
sty global_buffer+2
lda #0
clc
rtl
endp
sys_shutdown procname
lda #0
clc
rtl
endp
; x = call number * 2
; y = class number * 2
app_entry procname
with dp
with fst_parms
;import min_pcount
import max_pcount
phk
plb
rep #$30
;brk $42
sty <call_class
; debug saves all registers.
IF DEBUG_S16 THEN
jsr debug
ENDIF
; check the class 0 or 1 only.
cpy #2+1
bge @bad_system_call
cpx #max_app_call+1 ; 66+1
bge @bad_system_call
; class 1 -- check the pcount maximum.
cpy #2
bne @ok
lda [param_blk_ptr]
; gs/os already checks the minimum and verifies non-null names, etc.
;cmp min_pcount,x
;blt @invalid_pcount
cmp max_pcount,x
bge @invalid_pcount
@ok
; init stuff
lda global_buffer
sta io_buffer
sta dev_parms.dev_buff
lda global_buffer+2
sta io_buffer+2
sta dev_parms.dev_buff+2
;
; minix uses 1024 byte blocks... however, appledisk3.5 can only read 256, 512, or 524 byte blocks.
;
lda #512
sta dev_parms.dev_blk_size
stz dev_parms.dev_blk_size+2
stz dev_parms.dev_num
stz dev_parms.dev_callnum
stz dev_parms.dev_req_cnt
stz dev_parms.dev_req_cnt+2
stz dev_parms.dev_blk_num
stz dev_parms.dev_blk_num+2
stz my_fcr
stz my_fcr+2
stz my_vcr
stz my_vcr+2
lda #fst_id
sta dev_parms.dev_fst_num
stz <tool_error
;stz <device
; fake an rtl address for sys_exit
; otherwise, would need to jml sys_exit from functions.
pea |(sys_exit-1)>>8
phb
lda #<sys_exit-1
sta 1,s
; call it...
jmp (@app_table,x)
@bad_system_call
lda #bad_system_call
sec
jml sys_exit
@invalid_pcount
lda #invalid_pcount
sec
jml sys_exit
@app_table
dc.w rtl_bad_system_call ;
dc.w create ; ($01) Create
dc.w destroy ; ($02) Destroy
dc.w rtl_bad_system_call ; ($03) OS Shutdown
dc.w change_path ; ($04) Change Path
dc.w set_file_info ; ($05) Set File Info
dc.w get_file_info ; ($06) Get File Info
dc.w judge_name ; ($07) Judge Name
dc.w volume ; ($08) Volume
dc.w rtl_bad_system_call ; ($09) Set Prefix
dc.w rtl_bad_system_call ; ($0A) Get Prefix
dc.w rtl_invalid_fst_op ; ($0B) Clear Backup Bit
dc.w rtl_bad_system_call ; ($0C) Set Sys Prefs
dc.w rtl_no_error ; ($0D) Null
dc.w rtl_bad_system_call ; ($0E) Expand Path
dc.w rtl_bad_system_call ; ($0F) Get Sys Prefs
dc.w open ; ($10) Open
dc.w rtl_bad_system_call ; ($11) NewLine
dc.w read ; ($12) Read
dc.w write ; ($13) Write
dc.w close ; ($14) Close
dc.w flush ; ($15) Flush
dc.w set_mark ; ($16) Set Mark
dc.w get_mark ; ($17) Get Mark
dc.w set_eof ; ($18) Set EOF
dc.w get_eof ; ($19) Get EOF
dc.w rtl_bad_system_call ; ($1A) Set Level
dc.w rtl_bad_system_call ; ($1B) Get Level
dc.w get_dir_entry ; ($1C) Get Dir Entry
dc.w rtl_bad_system_call ; ($1D) Begin Session
dc.w rtl_bad_system_call ; ($1E) End Session
dc.w rtl_bad_system_call ; ($1F) Session Status
dc.w get_dev_num ; ($20) Get Dev Num
dc.w rtl_bad_system_call ; ($21) Get Last Dev
dc.w rtl_bad_system_call ; ($22) Read Block
dc.w rtl_bad_system_call ; ($23) Write Block
dc.w format ; ($24) Format
dc.w erase_disk ; ($25) Erase Disk
dc.w rtl_bad_system_call ; ($26) Reset Cache
dc.w rtl_bad_system_call ; ($27) Get Name
dc.w rtl_bad_system_call ; ($28) Get Boot Vol
dc.w rtl_bad_system_call ; ($29) Quit
dc.w rtl_bad_system_call ; ($2A) Get Version
dc.w rtl_bad_system_call ; ($2B) Get FST Info
dc.w rtl_bad_system_call ; ($2C) D_INFO
dc.w rtl_bad_system_call ; ($2D) D_STATUS
dc.w rtl_bad_system_call ; ($2E) D_CONTROL
dc.w rtl_bad_system_call ; ($2F) D_READ
dc.w rtl_bad_system_call ; ($30) D_WRITE
dc.w rtl_bad_system_call ; ($31) Alloc Interrupt
dc.w rtl_bad_system_call ; ($32) Dealloc Interrupt
dc.w rtl_invalid_fst_op ; ($33) FST Specific
max_app_call equ *-@app_table-2
endp
init_fcr proc export
; deref the fcr and copy over inode, disk_inode
with fst_parms, dp
ldx fcr_ptr
ldy fcr_ptr+2
jsl deref
stx my_fcr
sty my_fcr+2
ldy #fcr.inode
lda [my_fcr],y
sta inode
;ldy #fcr.disk_inode + v1_inode.sizeof - 2
ldy #fcr.disk_inode.__end-2
ldx #v1_inode.__sizeof-2
@loop
lda [my_fcr],y
sta disk_inode,x
dey
dey
dex
dex
bpl @loop
clc
rts
endp
init_vcr proc export
; deref the vcr
with fst_parms, dp
ldx vcr_ptr
ldy vcr_ptr+2
jsl deref
stx my_vcr
sty my_vcr+2
ldy #vcr.device
lda [my_vcr],y
;sta device ; should probably just store in the dev_num.
sta dev_parms.dev_num
clc
rts
endp
end