forked from tonioni/WinUAE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilesys.asm
2479 lines (2284 loc) · 45.9 KB
/
filesys.asm
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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
SECTION code,code
; This file can be translated with A68k or PhxAss and then linked with BLink
; to produce an Amiga executable. Make sure it does not contain any
; relocations, then run it through the filesys.sh script
;
; Patrick: It also works with SAS/C asm+slink, but I had to remove
; the .l from jsr.l and jmp.l.
; Toni Wilen: modified SECTION, compiles now with AsmOne and clones(?)
; Removed absolute RT_AREA references
; 2002.08.06 RDB automount/autoboot support (Toni Wilen)
; 2002.09.11 KS1.3 RDB support (TW)
; 200?.??.?? Picasso96 vblank hack (TW)
; 2006.03.04 Mousehack code integrated (TW)
; 2006.18.07 FileSystem.resource find routine access fault fixed (TW)
; 2007.03.30 mousehack do not start multiple times anymore (TW)
; 2007.06.15 uninitialized variable in memory type selection fixed (stupid me) (TW)
; 2007.08.09 started implementing removable drive support (TW)
; 2007.09.01 ACTION_EXAMINE_ALL (TW)
; 2007.09.05 full filesystem device mounting on the fly (TW)
; 2008.01.09 ACTION_EXAMINE_ALL does not anymore return eac_Entries = 0 with continue (fixes some broken programs)
; 2008.12.11 mousehack -> tablet driver
; 2008.12.25 mousehack cursor sync
; 2009.01.20 clipboard sharing
; 2009.12.27 console hook
; 2010.05.27 Z3Chip
AllocMem = -198
FreeMem = -210
; don't forget filesys.c! */
PP_MAXSIZE = 4 * 96
PP_FSSIZE = 400
PP_FSPTR = 404
PP_FSRES = 408
PP_EXPLIB = 412
PP_FSHDSTART = 416
PP_TOTAL = (PP_FSHDSTART+140)
NOTIFY_CLASS = $40000000
NOTIFY_CODE = $1234
NRF_SEND_MESSAGE = 1
NRF_SEND_SIGNAL = 2
NRF_WAIT_REPLY = 8
NRF_NOTIFY_INITIAL = 16
NRF_MAGIC = $80000000
dc.l 16 ; 4
our_seglist:
dc.l 0 ; 8 /* NextSeg */
start:
dc.l 9 ;0 12
bra.w filesys_mainloop ;1 16
dc.l make_dev-start ;2 20
dc.l filesys_init-start ;3 24
dc.l exter_server-start ;4 28
dc.l bootcode-start ;5 32
dc.l setup_exter-start ;6 36
dc.l mh_e-start ;7 40
dc.l clipboard_init-start ;8 44
;52
bootcode:
lea.l doslibname(pc),a1
jsr -96(a6) ; FindResident
move.l d0,a0
move.l 22(a0),d0
move.l d0,a0
jsr (a0)
rts
residenthack
movem.l d0-d2/a0-a2/a6,-(sp)
move.l 4.w,a6
cmp.w #37,20(a6)
bcs.s .rsh
moveq #residentcodeend-residentcodestart,d0
move.l d0,d2
moveq #1,d1
jsr AllocMem(a6)
tst.l d0
beq.s .rsh
move.l d0,a2
move.l a2,a0
lea residentcodestart(pc),a1
.cp1
move.l (a1)+,(a0)+
subq.l #4,d2
bne.s .cp1
jsr -$0078(a6) ;Disable
move.l a6,a1
move.w #-$48,a0 ;InitCode
move.l a2,d0
jsr -$01a4(a6) ;SetFunction
move.l d0,residentcodejump2-residentcodestart+2(a2)
lea myafterdos(pc),a0
move.l a0,residentcodejump1-residentcodestart+2(a2)
jsr -$27C(a6) ;CacheClearU
jsr -$007e(a6) ;Enable
.rsh
movem.l (sp)+,d0-d2/a0-a2/a6
rts
myafterdos
move.l (sp),a0
move.l 2(a0),a0
move.l a0,-(sp)
jsr (a0) ;jump to original InitCode
move.l (sp)+,a0
addq.l #4,sp ;remove return address
movem.l d0-d7/a1-a6,-(sp)
move.l a6,a1
move.l a0,d0
move.w #-$48,a0 ;InitCode
jsr -$01a4(a6) ;SetFunction (restore original)
bsr.w clipboard_init
bsr.w consolehook
movem.l (sp)+,d0-d7/a1-a6
rts ;return directly to caller
cnop 0,4
residentcodestart:
btst #2,d0 ;RTF_AFTERDOS?
beq.s resjump
residentcodejump1
jsr $f00000
resjump
residentcodejump2
jmp $f00000
cnop 0,4
residentcodeend:
filesys_init:
movem.l d0-d7/a0-a6,-(sp)
move.l 4.w,a6
move.w #$FFFC,d0 ; filesys base
bsr getrtbase
move.l (a0),a5
lea.l explibname(pc),a1 ; expansion lib name
moveq #36,d0
moveq #1,d5
jsr -552(a6) ; OpenLibrary
tst.l d0
bne.b FSIN_explibok
lea.l explibname(pc),a1 ; expansion lib name
moveq #0,d0
moveq #0,d5
jsr -552(a6) ; OpenLibrary
FSIN_explibok:
move.l d0,a4
tst.l $10c(a5)
beq.s FSIN_none
move.l #PP_TOTAL,d0
move.l #$10001,d1
jsr AllocMem(a6)
move.l d0,a3 ; param packet
move.l a4,PP_EXPLIB(a3)
moveq #0,d6
FSIN_init_units:
cmp.l $10c(a5),d6
bcc.b FSIN_units_ok
move.l d6,-(sp)
FSIN_nextsub:
moveq #1,d7
tst.w d5
beq.s .oldks
bset #2,d7
.oldks move.l a3,-(sp)
move.l a3,a0
bsr.w make_dev
move.l (sp)+,a3
cmp.l #-2,d0
beq.s FSIN_nomoresub
swap d6
addq.w #1,d6
swap d6
bra.s FSIN_nextsub
FSIN_nomoresub:
move.l (sp)+,d6
addq.w #1,d6
bra.b FSIN_init_units
FSIN_units_ok:
move.l 4.w,a6
move.l a3,a1
move.l #PP_TOTAL,d0
jsr FreeMem(a6)
FSIN_none:
move.l 4.w,a6
move.l a4,a1
jsr -414(a6) ; CloseLibrary
; move.w #$FF80,d0
; bsr.w getrtbase
; jsr (a0)
; jsr -$0078(a6) ; Disable
; lea 322(a6),a0 ; MemHeader
;FSIN_scanchip:
; move.l (a0),a0 ; first MemList
; tst.l (a0)
; beq.s FSIN_scandone
; move.w 14(a0),d1 ; attributes
; and #2,d1 ; MEMF_CHIP?
; beq.s FSIN_scanchip
; sub.l 24(a0),d0 ; did KS detect all chip?
; bmi.s FSIN_scandone
; beq.s FSIN_scandone
; ; add the missing piece
; add.l d0,24(a0) ; mh_Upper
; add.l d0,28(a0) ; mh_Free
; add.l d0,62(a6) ; MaxLocMem
; ; we still need to update last node's free space
; move.l 16(a0),a0 ; mh_First
;FSIN_chiploop2
; tst.l (a0)
; beq.s FSIN_chiploop
; move.l (a0),a0
; bra.s FSIN_chiploop2
;FSIN_chiploop:
; add.l d0,4(a0)
;FSIN_scandone:
; jsr -$007e(a6) ; Enable
filesys_dev_storeinfo
moveq #3,d4 ; MEMF_CHIP | MEMF_PUBLIC
cmp.w #36,20(a6)
bcs.s FSIN_ksold
or.w #256,d4 ; MEMF_LOCAL
FSIN_ksold
; add >2MB-6MB chip RAM to memory list
move.w #$FF80,d0
bsr.w getrtbase
jsr (a0)
move.l d4,d1
moveq #-10,d2
move.l #$200000,a0
sub.l a0,d0
bcs.b FSIN_chip_done
beq.b FSIN_chip_done
sub.l a1,a1
jsr -618(a6) ; AddMemList
FSIN_chip_done
; add MegaChipRAM
move.w #$FF80,d0
bsr.w getrtbase
jsr (a0) ; d1 = size, a1 = start address
move.l a1,a0
move.l d1,d0
beq.s FSIN_fchip_done
move.l d4,d1
moveq #-5,d2
lea fchipname(pc),a1
jsr -618(a6) ; AddMemList
FSIN_fchip_done
lea fstaskname(pc),a0
lea fsmounttask(pc),a1
moveq #10,d0
bsr createtask
move.l d0,a1
moveq #1,d1
move.w #$FF48,d0 ; store task pointer
bsr.w getrtbase
jsr (a0)
movem.l (sp)+,d0-d7/a0-a6
general_ret:
rts
createproc
movem.l d2-d4/a2/a6,-(sp)
move.l 4.w,a6
move.l d0,d2
move.l d1,d4
move.l a1,d3
move.l a0,a2
lea doslibname(pc),a1
moveq #0,d0
jsr -$0228(a6) ; OpenLibrary
tst.l d0
beq.s .noproc
move.l d0,a6
move.l a2,d1
lsr.l #2,d3
jsr -$08a(a6) ; CreateProc
move.l a6,a1
move.l 4.w,a6
jsr -$019e(a6); CloseLibrary
.noproc
movem.l (sp)+,d2-d4/a2/a6
rts
; this is getting ridiculous but I don't see any other solutions..
fsmounttask
.fsm1 move.l 4.w,a6
moveq #0,d0
bset #13,d0 ; SIGBREAK_CTRL_D
jsr -$013e(a6) ;Wait
lea fsprocname(pc),a0
lea mountproc(pc),a1
moveq #15,d0
move.l #8000,d1
bsr.w createproc
bra.s .fsm1
; dummy process here because can't mount devices with ADNF_STARTPROC from task..
; (AddDosNode() internally calls GetDeviceProc() which accesses ExecBase->ThisTask->pr_GlobVec)
cnop 0,4
dc.l 16
mountproc
dc.l 0
moveq #2,d1
move.w #$FF48,d0 ; get new unit number
bsr.w getrtbase
jsr (a0)
move.l d0,d1
bmi.s .out
bsr.w addfsonthefly
.out moveq #0,d0
rts
exter_data:
exter_server:
movem.l a2,-(sp)
move.w #$FF50,d0 ; exter_int_helper
bsr.w getrtbase
moveq.l #0,d0
jsr (a0)
tst.l d0
beq.w exter_server_exit
; This is the hard part - we have to send some messages.
move.l 4.w,a6
EXTS_loop:
move.w #$FF50,d0 ; exter_int_helper
bsr.w getrtbase
moveq.l #2,d0
jsr (a0)
cmp.w #1,d0
blt.w EXTS_done
bgt.b EXTS_signal_reply
jsr -366(a6) ; PutMsg
bra.b EXTS_loop
EXTS_signal_reply:
cmp.w #2,d0
bgt.b EXTS_reply
move.l d1,d0
jsr -$144(a6) ; Signal
bra.b EXTS_loop
EXTS_reply:
cmp.w #3,d0
bgt.b EXTS_cause
jsr -$17a(a6) ; ReplyMsg
bra.b EXTS_loop
EXTS_cause:
cmp.w #4,d0
bgt.b EXTS_notificationhack
jsr -$b4(a6) ; Cause
bra.b EXTS_loop
EXTS_notificationhack:
cmp.w #5,d0
bgt.b EXTS_done
movem.l a0-a1,-(sp)
moveq #38,d0
move.l #65536+1,d1
jsr AllocMem(a6)
movem.l (sp)+,a0-a1
move.l d0,a2
move.b #8,8(a2)
move.l a0,14(a2)
move.w #38,18(a2)
move.l #NOTIFY_CLASS,20(a2)
move.w #NOTIFY_CODE,24(a2)
move.l a1,26(a2)
move.l 16(a1),a0
move.l a2,a1
jsr -366(a6) ; PutMsg
bra.w EXTS_loop
EXTS_done:
move.w #$FF50,d0 ;exter_int_helper
bsr.w getrtbase
moveq.l #4,d0
jsr (a0)
moveq.l #1,d0 ; clear Z - it was for us.
exter_server_exit:
movem.l (sp)+,a2
rts
setup_exter:
movem.l d0-d1/a0-a1,-(sp)
bsr.w residenthack
moveq.l #26,d0
move.l #$10001,d1
jsr AllocMem(a6)
move.l d0,a1
lea.l exter_name(pc),a0
move.l a0,10(a1)
lea.l exter_data(pc),a0
move.l a0,14(a1)
lea.l exter_server(pc),a0
move.l a0,18(a1)
move.w #$0214,8(a1)
moveq.l #3,d0
jsr -168(a6) ; AddIntServer
move.w mh_e(pc),d0
beq.s .nomh
bsr.w mousehack_init
.nomh
movem.l (sp)+,d0-d1/a0-a1
rts
addfs: ; a0 = first hunk, a1 = parmpacket
movem.l d0-d1/a0-a3/a6,-(sp)
move.l 4.w,a6
move.l a0,a2
move.l a1,a3
move.l #62+128,d0 ; sizeof(FileSysEntry) + patchflags;
move.l #$10001,d1
jsr -198(a6)
move.l d0,a0
moveq #0,d0
lea PP_FSHDSTART(a3),a1
af1 move.b 0(a1,d0.w),14(a0,d0.w)
addq.w #1,d0
cmp.w #140,d0
bne.s af1
move.l a2,d0
lsr.l #2,d0
move.l d0,54(a0) ;seglist
move.l a0,a1
lea exter_name(pc),a0
move.l a0,10(a1) ; name
move.l PP_FSRES(a3),a0 ; FileSystem.resource
lea 18(a0),a0 ; fsr_FileSysEntries
jsr -$f0(a6) ;AddHead
movem.l (sp)+,d0-d1/a0-a3/a6
rts
relocate: ;a0=pointer to executable, returns first segment in A0
movem.l d1-d7/a1-a6,-(sp)
move.l 4.w,a6
move.l a0,a2
cmp.l #$3f3,(a2)+
bne.w ree
addq.l #8,a2 ; skip name end and skip total hunks + 1
move.l 4(a2),d7 ; last hunk
sub.l (a2),d7 ; first hunk
addq.l #8,a2 ; skip hunk to load first and hunk to load last
addq.l #1,d7
move.l a2,a3
move.l d7,d0
add.l d0,d0
add.l d0,d0
add.l d0,a3
move.l a2,a4
; allocate hunks
sub.l a5,a5 ;prev segment
moveq #0,d6
r15 move.l (a2),d2 ; hunk size (header)
moveq #1,d1
btst #30,d2 ; chip mem?
beq.s r2
bset #1,d1
r2 bset #16,d1
lsl.l #2,d2
move.l d2,d0
bne.s r17
clr.l (a2)+ ; empty hunk
bra.s r18
r17 addq.l #8,d0 ; size + pointer to next hunk + hunk size
jsr AllocMem(a6)
tst.l d0
beq.w ree
move.l d0,a0
move.l d2,(a0)+ ; store size
move.l a0,(a2)+ ; store new pointer
move.l a5,d1
beq.s r10
move.l a0,d0
lsr.l #2,d0
move.l d0,(a5)
r10 move.l a0,a5
r18 addq.l #1,d6
cmp.l d6,d7
bne.s r15
moveq #0,d6
r3 move.l d6,d1
add.l d1,d1
add.l d1,d1
move.l 0(a4,d1.l),a0
addq.l #4,a0
move.l (a3)+,d3 ; hunk type
move.l (a3)+,d4 ; hunk size
lsl.l #2,d4
cmp.l #$3e9,d3 ;code
beq.s r4
cmp.l #$3ea,d3 ;data
bne.s r5
r4
; code and data
move.l d4,d0
r6 tst.l d0
beq.s r7
move.b (a3)+,(a0)+
subq.l #1,d0
bra.s r6
r5
cmp.l #$3eb,d3 ;bss
bne.s ree
r7 ; scan for reloc32 or hunk_end
move.l (a3)+,d3
cmp.l #$3ec,d3 ;reloc32
bne.s r13
; relocate
move.l d6,d1
add.l d1,d1
add.l d1,d1
move.l 0(a4,d1.l),a0 ; current hunk
addq.l #4,a0
r11 move.l (a3)+,d0 ;number of relocs
beq.s r7
move.l (a3)+,d1 ;hunk
add.l d1,d1
add.l d1,d1
move.l 0(a4,d1.l),d3 ;hunk start address
addq.l #4,d3
r9 move.l (a3)+,d2 ;offset
add.l d3,0(a0,d2.l)
subq.l #1,d0
bne.s r9
bra.s r11
r13
cmp.l #$3f2,d3 ;end
bne.s ree
addq.l #1,d6
cmp.l d6,d7
bne.w r3
moveq #1,d7
move.l (a4),a0
r0 move.l d7,d0
movem.l (sp)+,d1-d7/a1-a6
rts
ree moveq #0,d7
bra.s r0
fsres
movem.l d1/a0-a2/a6,-(sp)
move.l 4.w,a6
lea $150(a6),a0 ;ResourceList
move.l (a0),a0 ;lh_Head
fsres3
tst.l (a0) ;end of list?
beq.s fsres1
move.l 10(a0),a1 ;name
lea fsresname(pc),a2
fsres5
move.b (a1)+,d0
move.b (a2)+,d1
cmp.b d1,d0
bne.s fsres2
tst.b d0
beq.s fsres4
bra.s fsres5
fsres2
move.l (a0),a0
bra.s fsres3
; FileSystem.resource does not exist -> create it
fsres1
moveq #32,d0 ; sizeof(FileSysResource)
move.l #$10001,d1
jsr AllocMem(a6)
move.l d0,a2
move.b #8,8(a2) ; NT_RESOURCE
lea fsresname(pc),a0
move.l a0,10(a2) ; node name
lea exter_name(pc),a0
move.l a0,14(a2) ; fsr_Creator
lea 18(a2),a0
move.l a0,(a0) ; NewList() fsr_FileSysEntries
addq.l #4,(a0)
move.l a0,8(a0)
lea $150(a6),a0 ; ResourceList
move.l a2,a1
jsr -$f6(a6) ; AddTail
move.l a2,a0
fsres4
move.l a0,d0
movem.l (sp)+,d1/a0-a2/a6
rts
addvolumenode
movem.l d7/a6,-(sp)
move.l d0,d7
tst.b 32+44(a3)
beq.s .end ;empty volume string = empty drive
move.l 160(a3),a6
cmp.w #37, 20(a6)
bcs.s .prev37
moveq #(1<<1)+(1<<3)+(1<<2),d1 ;LDF_WRITE | LDF_VOLUMES | LDF_DEVICES
jsr -$29A(a6) ;AttemptLockDosList
and.l #~1,d0
beq.s .end
btst #0,d7
beq.s .nvol
lea 32(a3),a0
move.l a0,d1
jsr -$2A6(a6) ;AddDosEntry (Volume)
.nvol btst #1,d7
beq.s .ndev
tst.b 158(a3)
bne.s .ndev
st 158(a3)
move.l 180(a3),d1
jsr -$2A6(a6) ;AddDosEntry (Device)
.ndev moveq #(1<<1)+(1<<3)+(1<<2),d1 ;LDF_WRITE | LDF_VOLUMES | LDF_DEVICES
jsr -$294(a6) ;UnLockDosList
bra.s .end
.prev37 move.l 4.w,a6
jsr -$0084(a6) ; Forbid
btst #0,d7
beq.s .nvol13
lea 32(a3),a0
bsr.w adddosentry13
.nvol13 btst #1,d7
beq.s .ndev13
tst.b 158(a3)
bne.s .ndev13
st 158(a3)
move.l 180(a3),a0
bsr.w adddosentry13
.ndev13 jsr -$008a(a6) ;Permit
.end movem.l (sp)+,d7/a6
rts
remvolumenode
movem.l d7/a2/a6,-(sp)
move.l d0,d7
move.l 160(a3),a6
cmp.w #37,20(a6)
bcs.s .prev37
moveq #(1<<1)+(1<<3)+(1<<2),d1 ;LDF_WRITE | LDF_VOLUMES | LDF_DEVICES
jsr -$29A(a6) ;AttemptLockDosList
and.l #~1,d0
beq.s .end
btst #0,d7
beq.s .nvol
lea 32(a3),a0
move.l a0,d1
jsr -$2A0(a6) ;RemDosEntry (Volume)
.nvol btst #1,d7
beq.s .ndev
tst.b 158(a3)
beq.s .ndev
clr.b 158(a3)
move.l 180(a3),d1
jsr -$2A0(a6) ;RemDosEntry (Device)
.ndev moveq #(1<<1)+(1<<3)+(1<<2),d1 ;LDF_WRITE | LDF_VOLUMES | LDF_DEVICES
jsr -$294(a6) ;UnLockDosList
bra.s .end
.prev37 move.l 4.w,a6
jsr -$0084(a6) ; Forbid
btst #0,d7
beq.s .nvol13
lea 32(a3),a0
bsr.w remdosentry13
.nvol13 btst #1,d7
beq.s .ndev13
tst.b 158(a3)
beq.s .ndev13
clr.b 158(a3)
move.l 180(a3),a0
bsr.w remdosentry13
.ndev13 jsr -$008a(a6) ;Permit
.end movem.l (sp)+,d7/a2/a6
rts
adddosentry13:
move.l a0,a1
move.l 160(a3),a0
move.l 34(a0),a0 ; RootNode
move.l 24(a0),a0 ; DosInfo
add.l a0,a0
add.l a0,a0
move.l 4(a0),(a1) ; myentry->dl_Next = di_DevInfo
move.l a1,d0
lsr.l #2,d0
move.l d0,4(a0) ; di_DevInfo = myentry
rts
remdosentry13:
move.l a0,a2
move.l 160(a3),a0
move.l 34(a0),a0 ; RootNode
move.l 24(a0),a0 ; DosInfo
add.l a0,a0
add.l a0,a0
move.l 4(a0),a1 ; DosInfo->di_DevInfo
add.l a1,a1
add.l a1,a1
cmp.l a2,a1
bne.s .pr2
; was first entry
move.l (a2),4(a0) ; di_DevInfo = myentry->dl_Next
bra.s .pr1
.pr2 move.l a1,d0
beq.s .pr3
move.l (a1),d0 ; prevEntry->dl_Next
add.l d0,d0
add.l d0,d0
cmp.l d0,a2 ; next is our entry?
beq.s .pr3
move.l d0,a1
bra.s .pr2
.pr3 move.l a1,d0
beq.s .pr1
move.l (a2),(a1) ; prevEntry->dl_Next = myentry->dl_Next
.pr1 rts
diskinsertremove:
movem.l d2/a2/a6,-(sp)
moveq #22,d2
sub.l d2,sp
move.l sp,a2
move.w d2,d1
.l1 clr.b -1(a2,d1.w)
subq.w #1,d1
bne.s .l1
move.l 4.w,a6
moveq #15,d1 ;IECLASS_DISKREMOVED
tst.l d0
beq.s .l2
moveq #16,d1 ;IECLASS_DISKINSERTED
.l2 move.b d1,4(a2) ;ie_Class
move.w #$0800,8(a2); ie_Qualifier=IEQUALIFIER_MULTIBROADCAST
move.l 164(a3),a1
move.w #11,28(a1) ;IND_WRITEEVENT
move.l #22,36(a1) ;sizeof(struct InputEvent)
move.l a2,40(a1)
move.b #1,30(a1) ;IOF_QUICK
move.l 168(a3),a1
move.w #10,28(a1) ;TR_GETSYSTIME
move.b #1,30(a1) ;IOF_QUICK
jsr -$01c8(a6) ;DoIO
move.l 168(a3),a1
move.l 32(a1),14(a2)
move.l 36(a1),18(a2)
move.l 164(a3),a1
jsr -$01c8(a6) ;DoIO
add.l d2,sp
movem.l (sp)+,d2/a2/a6
rts
dodiskchange
tst.b d0
beq.s .eject
tst.b 32+44(a3)
bne.s .end
moveq #0,d0
.dc2
tst.b 32+45(a3,d0.w)
beq.s .dc1
addq.b #1,d0
bra.s .dc2
.dc1
move.b d0,32+44(a3)
beq.s .end
move.l d1,d0
bsr.w addvolumenode
moveq #1,d0
bsr.w diskinsertremove
bra.s .end
.eject
tst.b 32+44(a3)
beq.s .end
clr.b 32+44(a3)
move.l d1,d0
bsr.w remvolumenode
moveq #0,d0
bsr.w diskinsertremove
.end
rts
action_inhibit
tst.l 20(a4) ;dp_Arg1
beq.s .add
moveq #0,d0
moveq #1,d1
bsr dodiskchange
rts
.add
moveq #1,d0
moveq #3,d1
bsr dodiskchange
rts
diskchange
move.b 172(a3),d0
bmi.s .nodisk
moveq #1,d0
moveq #3,d1
bsr dodiskchange
rts
.nodisk
moveq #1,d1
cmp.b #-2,d0 ;remove device node?
bne.s .nod1
moveq #3,d1
.nod1 moveq #0,d0
bsr dodiskchange
rts
; exall is complex, need to emulate eac_MatchString and/or eac_MatchFunc
action_exall
move.l 36(a4),a0 ; dp_Arg5, struct ExAllControl
tst.l (a0)
beq.s .ex0
tst.l 8(a0) ; eac_MatchString
bne.s .ex1
tst.l 12(a0) ; eac_MatchFunc
bne.s .ex1
.ex0 moveq #1,d0 ; no need to get more entries
rts ;nothing to do here
.ex1: movem.l d2-d7/a2-a6,-(sp)
move.l a0,a5
move.l 24(a4),a2 ;dp_Arg2, ExAllData
move.l (a5),d7 ; eac_Entries
moveq #0,d5 ; previous entry
.ex4 tst.l d7
beq.s .ex3
move.l a2,d0
beq.s .ex3
moveq #0,d6
move.l 8(a5),d1 ; MatchString
beq.s .ex5
move.l 4(a2),d2 ; dir/file name
move.l 160(a3),a6 ; dosbase
jsr -$03cc(a6) ; MatchPatternNoCase
tst.l d0
bne.s .ex5
st d6
.ex5 move.l 12(a5),d1 ; MatchFunc
beq.s .ex6
move.l d1,a0
move.l a2,a1
move.l a2,-(sp)
lea 32(a4),a2 ; dp_Arg4, Type
pea .pop(pc)
move.l 8(a0),-(sp)
rts
.pop move.l (sp)+,a2
tst.l d0
bne.s .ex6
st d6
.ex6 tst.b d6
beq.s .ex7
; need to delete current entry.. this is not really the proper way..
move.l 4(a2),d0 ; pointer to filename (which is first address after structure)
sub.l a2,d0 ; copy this much data
tst.l (a2) ; delete last? (eac_Next)
bne.s .ex10
; need to clear previous eac_Next
move.l d5,d0
beq.s .ex8
move.l d0,a0
clr.l (a0)
bra.s .ex8
.ex10 move.l (a2),a0
move.l a2,a1
.ex9 move.l (a0)+,(a1)+
subq.l #4,d0
bpl.s .ex9
.ex8 subq.l #1,(a5) ; eac_Entries
subq.l #1,d7
bra.s .ex4
.ex7 move.l a2,d5
move.l (a2),a2 ; eac_Next
subq.l #1,d7
bra.s .ex4
.ex3 movem.l (sp)+,d2-d7/a2-a6
move.l 36(a4),a0 ; dp_Arg5, struct ExAllControl
tst.l (a0) ; eac_Entries == 0 -> get more
rts
make_dev: ; IN: A0 param_packet, D6: unit_no, D7: b0=autoboot,b1=onthefly,b2=v36+
; A4: expansionbase
bsr.w fsres
move.l d0,PP_FSRES(a0) ; pointer to FileSystem.resource
move.l a0,-(sp)
move.w #$FFFC,d0 ; filesys base
bsr.w getrtbase
move.l (a0),a5
move.w #$FF28,d0 ; fill in unit-dependent info (filesys_dev_storeinfo)
bsr.w getrtbase
move.l a0,a1
move.l (sp)+,a0
clr.l PP_FSSIZE(a0) ; filesystem size
clr.l PP_FSPTR(a0) ; filesystem memory
jsr (a1)
; ret:0=virtual,1=hardfile,2=rdbhardfile,-1=hardfile-donotmount,-2=no more subunits
move.l d0,d3
cmp.w #-2,d3
beq.w general_ret
;cmp.w #1,d3
;bne.s mountalways
; KS < V36: init regular hardfiles only if filesystem is loaded
;btst #2,d7
;bne.s mountalways ; >= 36
;btst #1,d7
;bne.w mountalways
mountalways
; allocate memory for loaded filesystem
move.l PP_FSSIZE(a0),d0
beq.s nordbfs1
bmi.s nordbfs1
move.l a0,-(sp)
moveq #1,d1
move.l 4.w,a6
jsr AllocMem(a6)
move.l (sp)+,a0
move.l d0,PP_FSPTR(a0)
nordbfs1:
tst.l d3
bpl.s do_mount
; do not mount but we might need to load possible custom filesystem(s)
move.l a0,a1
move.w #$FF20,d0 ; record in ui.startup (filesys_dev_remember)
bsr.w getrtbase
jsr (a0)
bra.s dont_mount
do_mount:
move.l a4,a6
move.l a0,-(sp)
jsr -144(a6) ; MakeDosNode()
move.l (sp)+,a0 ; parmpacket
move.l a0,a1
move.l d0,a3 ; devicenode
move.w #$FF20,d0 ; record in ui.startup (filesys_dev_remember)
bsr.w getrtbase
jsr (a0)
moveq #0,d0
move.l d0,8(a3) ; dn_Task
move.l d0,16(a3) ; dn_Handler
move.l d0,32(a3) ; dn_SegList
dont_mount:
tst.l PP_FSPTR(a1) ; filesystem?
beq.s nordbfs2
move.l PP_FSPTR(a1),a0
bsr.w relocate
movem.l d0/a0-a1,-(sp)
move.l PP_FSSIZE(a1),d0
move.l PP_FSPTR(a1),a1
move.l 4.w,a6
jsr FreeMem(a6)
movem.l (sp)+,d0/a0-a1
tst.l d0
beq.s nordbfs2
bsr.w addfs
nordbfs2:
tst.l d3
bmi.w general_ret
move.w #$FF18,d0 ; update dn_SegList if needed (filesys_dev_bootfilesys)
bsr.w getrtbase
jsr (a0)
move.l d3,d0
move.b 79(a1),d3 ; bootpri
tst.l d0
bne.b MKDV_doboot
MKDV_is_filesys:
move.l #6000,20(a3) ; dn_StackSize
lea.l our_seglist(pc),a0
move.l a0,d0
lsr.l #2,d0