forked from tonioni/WinUAE
-
Notifications
You must be signed in to change notification settings - Fork 1
/
filesys.asm
4799 lines (4353 loc) · 83.2 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
; 2011.12.17 built-in CDFS support
; 2015.09.27 KS 1.2 boot hack supported
; 2015.09.28 KS 1.2 boot hack improved, 1.1 and older BCPL-only DOS support.
; 2016.01.14 'Indirect' boot ROM trap support.
; 2018.03.22 Segment tracking
; 2018.07.08 68060 FPU disable
AllocMem = -198
FreeMem = -210
TRAP_DATA_NUM = 4
TRAP_DATA_SEND_NUM = 1
TRAP_DATA = $8000
TRAP_DATA_SLOT_SIZE = 4096
TRAP_DATA_SECOND = 80
TRAP_DATA_TASKWAIT = (TRAP_DATA_SECOND-4)
TRAP_DATA_EXTRA = 144
TRAP_STATUS = $F000
TRAP_STATUS_SLOT_SIZE = 8
TRAP_STATUS_SECOND = 4
TRAP_STATUS_LOCK_WORD = 2
TRAP_STATUS_STATUS2 = 2
TRAP_STATUS_STATUS = 3
TRAP_DATA_DATA = 4
RTAREA_SYSBASE = $7FFC
RTAREA_GFXBASE = $7FF8
RTAREA_INTBASE = $7FF4
RTAREA_INTXY = $7FF0
RTAREA_MOUSEHACK = $7E00
RTAREA_TRAPTASK = $FFF4
RTAREA_EXTERTASK = $FFF8
RTAREA_INTREQ = $FFFC
; don't forget filesys.c! */
PP_MAXSIZE = 4 * 96
PP_FSSIZE = 400
PP_FSPTR = 404
PP_ADDTOFSRES = 408
PP_FSRES = 412
PP_FSRES_CREATED = 416
PP_DEVICEPROC = 420
PP_EXPLIB = 424
PP_FSHDSTART = 428
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
; normal filehandler segment entrypoint
dc.l (rom_end-start)/4 ; 4
our_seglist:
dc.l 0 ; 8 /* NextSeg */
start:
bra.s startjmp
dc.w 13 ; 0 12
startjmp:
bra.w filesys_mainloop ; 1 16
dc.l make_dev-start ; 2 20
dc.l filesys_init-start ; 3 24
dc.l moverom-start ; 4 28
dc.l bootcode-start ; 5 32
dc.l setup_exter-start ; 6 36
dc.l bcplwrapper-start ; 7 40
dc.l afterdos-start ; 8 44
dc.l hwtrap_install-start ; 9 48
dc.l hwtrap_entry-start ; 10 52
dc.l keymaphack-start ; 11 56
dc.l fpu060disable-start ; 12 60
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
fpu060disable:
movec pcr,d0
bset #1,d0
movec d0,pcr
jmp (a5)
; BCPL filehandler segment entry point
; for KS 1.1 and older.
cnop 0,4
dc.l (bcpl_end-bcpl_start)/4+1
our_bcpl_seglist:
dc.l 0
dc.l (bcpl_end-bcpl_start)/4+1
bcpl_start:
; d1 = startup packet
lsl.l #2,d1
move.l d1,d7
bra.w filesys_mainloop_bcpl
cnop 0,4
dc.l 0
dc.l 1
dc.l 4
dc.l 2
bcpl_end:
resident
dc.w $4afc
dc.l 0
dc.l rom_end-resident
dc.b 0,1,0,0
dc.l exter_name-resident
dc.l 0
dc.l start-resident
; KS 1.x does not support RTF_AFTERDOS and KS 2.x RTF_AFTERDOS is broken.
afterdos_hack:
movem.l d0-d2/a0-a2/a6,-(sp)
move.l 4.w,a6
cmp.w #39,20(a6)
bcc.s .rsh
cmp.w #37,20(a6)
bcs.s .rsh
move.w #$FF38,d0
moveq #17,d1
bsr.w getrtbase
jsr (a0)
tst.l d0
beq.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 run_afterdos
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:
; v39 RTF_AFTERDOS
afterdos:
movem.l d2-d7/a2-a6,-(sp)
move.l 4.w,a6
lea gfxlibname(pc),a1
moveq #0,d0
jsr -$0228(a6) ;OpenLibrary
move.l d0,d1
move.w #RTAREA_GFXBASE,d0
bsr.w getrtbase
move.l d1,(a0)
lea intlibname(pc),a1
moveq #0,d0
jsr -$0228(a6) ;OpenLibrary
move.l d0,d1
move.w #RTAREA_INTBASE,d0
bsr.w getrtbase
move.l d1,(a0)
bsr run_afterdos
movem.l (sp)+,d2-d7/a2-a6
moveq #0,d0
rts
run_afterdos
bsr.w clipboard_init
bsr.w consolehook
bsr.w segtrack_init
rts
filesys_init:
movem.l d0-d7/a0-a6,-(sp)
move.l 4.w,a6
move.w #$FFEC,d0 ; filesys base
bsr getrtbase
move.l (a0),a5
moveq #0,d5
moveq #0,d0
cmp.w #33,20(a6) ; 1.1 or older?
bcs.s FSIN_explibok
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
REM ; moved to early hwtrap_install
; create fake configdev
exg a4,a6
move.l a6,d0
beq.s .nocd
btst #4,$110+3(a5)
bne.s .nocd
jsr -$030(a6) ;expansion/AllocConfigDev
tst.l d0
beq.s .nocd
move.l d0,a0
lea start(pc),a1
move.l a1,d0
clr.w d0
move.l d0,32(a0)
move.l #65536,36(a0)
move.w #$0104,16(a0) ;type + product
move.w #2011,16+4(a0) ;manufacturer
moveq #1,d0
move.l d0,22(a0) ;serial
jsr -$01e(a6) ;expansion/AddConfigDev
.nocd
exg a4,a6
EREM
tst.l $10c(a5)
beq.w 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.w $10e(a5),d6
bcc.b FSIN_units_ok
move.l d6,-(sp)
FSIN_nextsub:
move.l $110(a5),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
move.l d1,PP_DEVICEPROC(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,d0
beq.s .noexpclose
move.l a4,a1
jsr -414(a6) ; CloseLibrary
.noexpclose
cmp.w #34,20(a6) ; 1.2 or older?
bcs.w FSIN_tooold
; add MegaChipRAM
moveq #3,d4 ; MEMF_CHIP | MEMF_PUBLIC
cmp.w #36,20(a6)
bcs.s FSIN_ksold
or.w #256,d4 ; MEMF_LOCAL
FSIN_ksold
move.w #$FF80,d0
bsr.w getrtbase
jsr (a0) ; d1 = size, a1 = start address
move.l d0,d5
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
; only if >=4M chip
cmp.l #$400000,d5
bcs.s FSIN_locmem
cmp.l 62(a6),d5
beq.s FSIN_locmem
jsr -$78(a6)
move.l d5,62(a6) ;LocMem
moveq #0,d0
moveq #(82-34)/2-1,d1
lea 34(a6),a0
.FSIN_locmem1
add.w (a0)+,d0
dbf d1,.FSIN_locmem1
not.w d0
move.w d0,82(a6) ;ChkSum
jsr -$7e(a6)
FSIN_locmem
; add >2MB-6MB chip RAM to memory list (if not already done)
lea $210000,a1
; do not add if RAM detected already
jsr -$216(a6) ; TypeOfMem
tst.l d0
bne.s FSIN_chip_done
move.l d4,d1
moveq #-10,d2
move.l #$200000,a0
move.l d5,d0
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
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)
FSIN_tooold
movem.l (sp)+,d0-d7/a0-a6
general_ret:
rts
REM
addextrachip:
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.w FSIN_scannotfound
move.l 20(a0),d1 ; mh_Lower
clr.w d1
tst.l d1
bne.s FSIN_scanchip
move.w 14(a0),d1 ; attributes
bmi.s FSIN_scanchip
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
move.l 24(a0),d1
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:
move.l a0,d2
add.l 4(a0),d2
;Last block goes to end of chip?
cmp.l d2,d1
beq.s FSIN_chipadd1
;It didn't, add new MemChunk
move.l d1,(a0)
move.l d1,a1
clr.l (a1)+
move.l d0,(a1)
bra.s FSIN_scandone
FSIN_chipadd1:
add.l d0,4(a0)
FSIN_scandone:
jsr -$007e(a6) ; Enable
rts
FSIN_scannotfound:
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
lea $210000,a1
; do not add if RAM detected already
jsr -$216(a6) ; TypeOfMem
tst.l d0
bne.s FSIN_chip_done
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
rts
EREM
; d1 = stacksize
; d2 = priority
createproc
movem.l d2-d5/a2/a6,-(sp)
moveq #0,d5
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 d0,d5
move.l a6,a1
move.l 4.w,a6
jsr -$019e(a6); CloseLibrary
.noproc
move.l d5,d0
movem.l (sp)+,d2-d5/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 getrtbaselocal
jsr (a0)
move.l d0,d1
bmi.s .out
bsr.w addfsonthefly
.out moveq #0,d0
rts
trap_task:
move.l 4.w,a6
trap_task_wait
move.l #$100,d0
jsr -$13e(a6) ;Wait
trap_task_check:
moveq #0,d7
; check if we have call lib/func request
move.l #TRAP_STATUS,d0
bsr.w getrtbase
move.l a0,a1
move.l #TRAP_DATA,d0
bsr.w getrtbase
moveq #TRAP_DATA_NUM-1,d6
.nexttrap
tst.b TRAP_STATUS_STATUS(a1)
beq.s .next
cmp.b #$fd,TRAP_STATUS_SECOND+TRAP_STATUS_STATUS(a1)
bne.s .next
addq.l #1,d7
lea TRAP_DATA_SECOND+4(a0),a4
lea TRAP_STATUS_SECOND(a1),a5
movem.l d6/d7/a0/a1/a4/a5/a6,-(sp)
move.w (a5),d4 ;command
movem.l (a4),a0-a2
movem.l (a4),d0-d2
cmp.w #18,d4
bne.s .notcalllib
bsr.w hw_call_lib
bra.s .calldone
.notcalllib
cmp.w #19,d4
bne.s .calldone
bsr.w hw_call_func
.calldone
movem.l (sp)+,d6/d7/a0-a1/a4/a5/a6
move.l d0,(a4)
move.b #2,TRAP_STATUS_STATUS(a5)
.next
add.w #TRAP_DATA_SLOT_SIZE,a0
addq.w #TRAP_STATUS_SLOT_SIZE,a1
dbf d6,.nexttrap
tst.l d7
beq.w trap_task_wait
bra.w trap_task_check
exter_task:
move.l 4.w,a6
exter_task_wait
move.l #$100,d0
jsr -$13e(a6) ;Wait
bsr.s exter_do
bra.s exter_task_wait
exter_done
rts
exter_do
moveq #10,d7
EXTT_loop
move.w #$FF50,d0 ; exter_int_helper
bsr.w getrtbaselocal
move.l d7,d0
jsr (a0)
tst.l d0
beq.s exter_done
moveq #11,d7
cmp.w #1,d0
blt.w EXTT_loop
bgt.b EXTT_signal_reply
jsr -366(a6) ; PutMsg
bra.b EXTT_loop
EXTT_signal_reply:
cmp.w #2,d0
bgt.b EXTT_reply
move.l d1,d0
jsr -$144(a6) ; Signal
bra.b EXTT_loop
EXTT_reply:
cmp.w #3,d0
bgt.b EXTT_cause
jsr -$17a(a6) ; ReplyMsg
bra.b EXTT_loop
EXTT_cause:
cmp.w #4,d0
bgt.b EXTT_notificationhack
jsr -$b4(a6) ; Cause
bra.b EXTT_loop
EXTT_notificationhack:
cmp.w #5,d0
bgt.b EXTT_shellexec
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 EXTT_loop
EXTT_shellexec
cmp.w #6,d0
bgt.s EXTT_shellexec2
bsr.s doshellexecute
bra.w EXTT_loop
EXTT_shellexec2
cmp.w #7,d0
bgt.w EXTT_loop
bsr.s doshellexecute2
bra.w EXTT_loop
doshellexecute
lea shellexecname(pc),a0
lea shellexecproc(pc),a1
moveq #1,d0
move.l #10000,d1
bsr.w createproc
move.l d0,d1
move.w #$FF50,d0 ; exter_int_helper
bsr.w getrtbaselocal
moveq #20,d0
jsr (a0)
rts
doshellexecute2
movem.l d2-d4/a2-a4,-(sp)
sub.l a4,a4
moveq #0,d3
move.w #$FF50,d0 ; exter_int_helper
bsr.w getrtbaselocal
move.l a0,a3
moveq #30,d0
jsr (a3)
; returns requested data size in D0
move.l d0,d2
beq.s .end1
move.l #65536+1,d1
jsr AllocMem(a6)
move.l d0,a4
tst.l d0
beq.s .she1
move.l d2,(a4)
lea shellexecname(pc),a0
lea shellexecproc2(pc),a1
moveq #1,d0
move.l #4096,d1
bsr.w createproc
move.l d0,d3
beq.s .she1
sub.l #92,d3
.she1
moveq #31,d0
move.l a4,a0
; send process struct and data
move.l d3,d1
jsr (a3)
tst.l d3
beq.s .end2
move.l a4,d0
beq.s .end2
move.l d3,a1 ; Task
moveq #0,d0
bset #13,d0 ; SIGBREAK_CTRL_D
jsr -$144(a6) ; Signal
bra.s .end1
.end2
move.l a4,d0
beq.s .end1
move.l a4,a1
move.l (a4),d0
jsr FreeMem(a6)
.end1
movem.l (sp)+,d2-d4/a2-a4
rts
cnop 0,4
dc.l 16
shellexecproc2
dc.l 0
move.l 4.w,a6
lea doslibname(pc),a1
moveq #0,d0
jsr -$228(a6) ; OpenLibrary
move.l d0,d6
moveq #0,d0
bset #13,d0 ; SIGBREAK_CTRL_D
jsr -$013e(a6) ;Wait
move.w #$FF50,d0 ; exter_int_helper
bsr.w getrtbaselocal
moveq #32,d0
; get data
jsr (a0)
move.l d0,a4 ;data
; 0 L size (including this field)
; 4 PT command
; 8 PT params
; 12 PT dir
; 16 PT command + params
; 20 L stack size
; 24 L priority
; 28 L flags
; 32 L id
; 36 L datasize
; 40 PT data
; 44 PT tmpout
; 48 PT out buffer (128)
; 52 PT tmpbinname
move.l d6,a0
cmp.w #36,20(a0)
bcc.s .fstask1
jsr -$0084(a6) ; Forbid
sub.l a1,a1
jsr -$126(a6) ; FindTask
move.l d0,a0
moveq #0,d2
; empty pr_FileSystemTask, find SYS: assign
move.l d6,a1
move.l 34(a1),a1 ;dl_Root
move.l 24(a1),a1 ; rn_Info
add.l a1,a1
add.l a1,a1
move.l 4(a1),a1 ;di_DevInfo
add.l a1,a1
add.l a1,a1
.nextdi
moveq #1,d0
cmp.l 4(a1),d0
bne.s .noassign
move.l 40(a1),a2
add.l a2,a2
add.l a2,a2
move.l (a2),d0
cmp.l #$03535953,d0 ;\03SYS
bne.s .nosys
tst.l 168(a0)
bne.s .noassign
move.l 8(a1),168(a0) ;pr_FileSystemTask
bra.s .noassign
.nosys
swap d0
cmp.w #$0154,d0 ;\01T
bne.s .noassign
moveq #1,d2
.noassign
move.l (a1),d0
lsl.l #2,d0
move.l d0,a1
bne.s .nextdi
.nextdi0
jsr -$008a(a6) ;Permit
moveq #-2,d5
tst.w d2
beq .seproc6
.fstask1
exg d6,a6
move.l sp,a3
lea -8*8(sp),sp
move.l sp,d5
move.l d5,a2
; SYS_Input
move.l #$80000000+32+1,(a2)+
lea nil_name(pc),a0
move.l a0,d1
move.l #1005,d2
jsr -$1e(a6) ;Open
move.l d0,(a2)+
; SYS_Output
move.l #$80000000+32+2,(a2)+
move.l #1006,d2
move.l 44(a4),d1
bne.s .outfile
move.l #1005,d2
lea nil_name(pc),a0
move.l a0,d1
.outfile
jsr -$1e(a6) ;Open
move.l d0,(a2)+
; NP_CurrentDir
moveq #1,d0 ; TAG_IGNORE
move.l d0,(a2)+
moveq #0,d0
move.l d0,(a2)+
move.l 12(a4),a0
tst.b (a0)
beq.s .nodir1
move.l a0,d1
moveq #-2,d2
jsr -$0054(a6) ;Lock
tst.l d0
beq.s .nodir1
subq.l #8,a2
move.l #$80000000+1000+10,(a2)+
move.l d0,(a2)+
.nodir1
; NP_StackSize
move.l 20(a4),d0
beq.s .stk1
move.l #$80000000+1000+11,(a2)+
move.l d0,(a2)+
.stk1
; NP_Priority
move.l #$80000000+1000+13,(a2)+
move.l 24(a4),(a2)+
; NP_WindowPtr
moveq #1,d0 ; TAG_IGNORE
move.l d0,(a2)+
moveq #0,d0
move.l d0,(a2)+
move.l 28(a4),d0
btst #2,d0
beq.s .nowp1
subq.l #8,a2
move.l #$80000000+1000+15,(a2)+
moveq #-1,d0
move.l d0,(a2)+
.nowp1
clr.l (a2)+
clr.l (a2)
move.l d5,a2
tst.l 40(a4)
beq.s .nobin
move.l #1006,d2
move.l 52(a4),d1
jsr -$1e(a6) ;Open
move.l d0,d4
beq.s .nobin
move.l d4,d1
move.l 40(a4),d2
move.l 36(a4),d3
jsr -$30(a6) ;Write
move.l d4,d1
jsr -$24(a6)
.nobin
cmp.w #36,20(a6)
bcc.s .seproc5
sub.l a1,a1
exg d6,a6
jsr -$126(a6) ; FindTask
exg d6,a6
move.l d0,a0
move.l 2*8+4(a2),d0
beq.s .ncur
move.l d0,152(a0) ; pr_CurrentDir
.ncur
move.l 16(a4),d1 ; Command
moveq #0,d2 ; Input
move.l 1*8+4(a2),d3 ; Output
jsr -$de(a6) ; Execute
bra.s .seproc4
.seproc5
move.l 16(a4),d1
move.l a2,d2
jsr -$25e(a6) ; SystemTagList
.seproc4
move.l d0,d5
move.l 0*8+4(a2),d1
beq.s .nof2
jsr -$24(a6) ;Close
.nof2
move.l 1*8+4(a2),d4
beq.s .nof3
tst.l 44(a4)
beq.s .nof21
move.l d4,d1
moveq #0,d2
moveq #-1,d3
jsr -$42(a6) ;Seek
.nof23
move.l d4,d1
move.l 48(a4),d2
move.l #128,d3
jsr -$2a(a6) ;Read
move.l d0,d1
move.w #$FF50,d0 ; exter_int_helper
bsr.w getrtbaselocal
moveq #34,d0
; return output
jsr (a0)
cmp.l d1,d3
beq.s .nof23
moveq #34,d0
moveq #-1,d1
jsr (a0)
.nof21
move.l d4,d1
jsr -$24(a6) ;Close
move.l 44(a4),d1
beq.s .nof22
jsr -$48(a6) ;DeleteFile
.nof22
.nof3
move.l 52(a4),d1
beq.s .nobinf
jsr -$48(a6) ;DeleteFile
.nobinf
cmp.l #-1,d5
bne.s .nof1
move.l 2*8+4(a2),d1
beq.s .nof1
jsr -$5a(a6) ;Unlock
.nof1