|
|
1.1.1.3 ! root 1: SECTION code,code 1.1 root 2: ; This file can be translated with A68k or PhxAss and then linked with BLink 3: ; to produce an Amiga executable. Make sure it does not contain any 4: ; relocations, then run it through the filesys.sh script 1.1.1.2 root 5: ; 6: ; Patrick: It also works with SAS/C asm+slink, but I had to remove 7: ; the .l from jsr.l and jmp.l. 1.1.1.3 ! root 8: ; Toni Wilen: modified SECTION, compiles now with AsmOne and clones(?) ! 9: ; Removed absolute RT_AREA references 1.1 root 10: 11: dc.l 16 12: our_seglist: 13: dc.l 0 ;/* NextSeg */ 14: start: 15: bra filesys_mainloop 16: dc.l make_dev-start 17: dc.l filesys_init-start 18: dc.l exter_server-start 19: dc.l bootcode-start 1.1.1.3 ! root 20: dc.l setup_exter-start 1.1 root 21: 22: bootcode: 23: lea.l doslibname(pc),a1 1.1.1.2 root 24: jsr -96(a6) ; FindResident 1.1 root 25: move.l d0,a0 26: move.l 22(a0),d0 27: move.l d0,a0 28: jsr (a0) 29: rts 30: 31: filesys_init: 32: movem.l d0-d7/a0-a6,-(sp) 33: move.l 4.w,a6 1.1.1.3 ! root 34: move.w #$FFFC,d0 ; filesys base ! 35: bsr getrtbase ! 36: move.l (a0),a5 1.1 root 37: lea.l explibname(pc),a1 ; expansion lib name 38: moveq.l #36,d0 39: moveq.l #0,d5 1.1.1.2 root 40: jsr -552(a6) ; OpenLibrary 1.1 root 41: tst.l d0 42: bne.b FSIN_explibok 43: lea.l explibname(pc),a1 ; expansion lib name 44: moveq.l #0,d0 45: moveq.l #1,d5 1.1.1.2 root 46: jsr -552(a6) ; OpenLibrary 1.1 root 47: FSIN_explibok: 48: move.l d0,a4 49: moveq.l #88,d0 50: moveq.l #1,d1 ; MEMF_PUBLIC 1.1.1.2 root 51: jsr -198(a6) ; AllocMem 1.1 root 52: move.l d0,a3 ; param packet 53: 54: moveq.l #84,d7 ; initialize it 55: FSIN_loop: 56: move.l 0(a5,d7.l),0(a3,d7.l) 57: subq.l #4,d7 58: bcc.b FSIN_loop 59: 60: moveq.l #0,d6 61: FSIN_init_units: 62: cmp.l $10c(a5),d6 63: bcc.b FSIN_units_ok 64: move.l a3,a0 65: movem.l d6/a3,-(sp) 66: move.l #1,d7 1.1.1.2 root 67: bsr.w make_dev 1.1 root 68: movem.l (sp)+,d6/a3 69: addq.l #$1,d6 70: bra.b FSIN_init_units 71: 72: FSIN_units_ok: 73: move.l 4.w,a6 74: move.l a4,a1 1.1.1.2 root 75: jsr -414(a6) ; CloseLibrary 1.1.1.3 ! root 76: move.w #$FF80,d0 ! 77: bsr.w getrtbase ! 78: jsr (a0) 1.1 root 79: moveq.l #3,d1 80: moveq.l #-10,d2 81: move.l #$200000,a0 82: sub.l a0,d0 83: bcs.b FSIN_chip_done 84: beq.b FSIN_chip_done 85: moveq.l #0,d4 86: move.l d4,a1 87: jsr -618(a6) 88: FSIN_chip_done 89: movem.l (sp)+,d0-d7/a0-a6 90: general_ret: 91: rts 92: 1.1.1.2 root 93: exter_data: 94: exter_server: 95: movem.l a2,-(sp) 1.1.1.3 ! root 96: move.w #$FF50,d0 ! 97: bsr.w getrtbase 1.1.1.2 root 98: moveq.l #0,d0 1.1.1.3 ! root 99: jsr (a0) 1.1.1.2 root 100: tst.l d0 101: beq.b exter_server_exit 102: ; This is the hard part - we have to send some messages. 103: move.l 4.w,a6 104: EXTS_loop: 1.1.1.3 ! root 105: move.w #$FF50,d0 ! 106: bsr.w getrtbase 1.1.1.2 root 107: moveq.l #2,d0 1.1.1.3 ! root 108: jsr (a0) 1.1.1.2 root 109: cmp.l #1,d0 110: blt.b EXTS_done 111: bgt.b EXTS_signal_reply 112: jsr -366(a6) ; PutMsg 113: bra.b EXTS_loop 114: EXTS_signal_reply: 115: cmp.l #2,d0 116: bgt.b EXTS_reply 117: move.l d1,d0 118: jsr -$144(a6) ; Signal 119: bra.b EXTS_loop 120: EXTS_reply: 1.1.1.3 ! root 121: cmp.l #3,d0 ! 122: bgt.b EXTS_cause ! 123: jsr -$17a(a6) ; ReplyMsg ! 124: bra.b EXTS_loop ! 125: EXTS_cause: ! 126: cmp.l #4,d0 ! 127: bgt.b EXTS_jump ! 128: jsr -$b4(a6) ; Cause ! 129: bra.b EXTS_loop ! 130: EXTS_jump: ! 131: movem.l a2/a5,-(sp) ! 132: move.l a1,a2 ;CDXL structure ! 133: move.l 20(a2),a1 ! 134: move.l 24(a2),a5 ! 135: move.l a2,-(sp) ! 136: jsr (a5) ; cd.device CD_READXL callback ! 137: move.l (sp)+,d2 ! 138: clr.l 24(a2) ; ugly sync-hack ! 139: movem.l (sp)+,a2/a5 1.1.1.2 root 140: EXTS_done: 1.1.1.3 ! root 141: move.w #$FF50,d0 ! 142: bsr.w getrtbase 1.1.1.2 root 143: moveq.l #4,d0 1.1.1.3 ! root 144: jsr (a0) 1.1.1.2 root 145: moveq.l #1,d0 ; clear Z - it was for us. 146: exter_server_exit: 147: movem.l (sp)+,a2 148: rts 149: 1.1 root 150: setup_exter: 151: moveq.l #26,d0 152: move.l #$10001,d1 153: jsr -198(a6) ; AllocMem 154: move.l d0,a1 155: lea.l exter_name(pc),a0 156: move.l a0,10(a1) 157: lea.l exter_data(pc),a0 158: move.l a0,14(a1) 159: lea.l exter_server(pc),a0 160: move.l a0,18(a1) 1.1.1.3 ! root 161: move.b #200,9(a1) ! 162: move.b #2,8(a1) 1.1 root 163: moveq.l #13,d0 1.1.1.2 root 164: jmp -168(a6) ; AddIntServer 1.1 root 165: 166: make_dev: ; IN: A0 param_packet, D6: unit_no, D7: boot, A4: expansionbase 167: 1.1.1.3 ! root 168: move.l a0,-(sp) ! 169: move.w #$FFFC,d0 ; filesys base ! 170: bsr.w getrtbase ! 171: move.l (a0),a5 ! 172: move.w #$FF28,d0 ; fill in unit-dependent info, return 1 if hardfile. ! 173: bsr.w getrtbase ! 174: move.l a0,a1 ! 175: move.l (sp)+,a0 ! 176: jsr (a1) 1.1 root 177: move.l d0,d3 178: 179: ; Don't init hardfiles if < V36 180: and.l d5,d0 1.1.1.2 root 181: bne.w general_ret 1.1 root 182: 183: move.l a4,a6 1.1.1.2 root 184: jsr -144(a6) ; MakeDosNode() 1.1 root 185: move.l d0,a3 ; devicenode 1.1.1.3 ! root 186: move.w #$FF20,d0 ; record in ui.startup ! 187: bsr.w getrtbase ! 188: jsr (a0) 1.1 root 189: moveq.l #0,d0 190: move.l d0,8(a3) ; dn_Task 191: move.l d0,16(a3) ; dn_Handler 192: move.l d0,32(a3) ; dn_SegList 193: 194: tst.l d3 195: bne.b MKDV_doboot 196: 197: MKDV_is_filesys: 198: move.l #4000,20(a3) ; dn_StackSize 199: lea.l our_seglist(pc),a1 200: move.l a1,d0 201: lsr.l #2,d0 202: move.l d0,32(a3) ; dn_SegList 203: move.l #-1,36(a3) ; dn_GlobalVec 204: 205: MKDV_doboot: 206: tst.l d7 207: beq.b MKDV_noboot 208: 209: move.l 4.w,a6 210: moveq.l #20,d0 211: moveq.l #0,d1 1.1.1.2 root 212: jsr -198(a6) ; AllocMem 1.1 root 213: move.l d0,a1 ; bootnode 214: moveq.l #0,d0 215: move.l d0,(a1) 216: move.l d0,4(a1) 217: move.w d0,14(a1) 218: move.w #$10FF,d0 219: sub.b d6,d0 220: move.w d0,8(a1) 221: move.l $104(a5),10(a1) ; filesys_configdev 222: move.l a3,16(a1) ; devicenode 223: lea.l 74(a4),a0 ; MountList 1.1.1.2 root 224: jmp -270(a6) ; Enqueue() 1.1 root 225: 226: MKDV_noboot: 227: move.l a3,a0 228: moveq.l #0,d1 229: move.l d1,a1 230: moveq.l #-1,d0 231: move.l a4,a6 ; expansion base 1.1.1.2 root 232: jmp -150(a6) ; AddDosNode 1.1 root 233: 234: filesys_mainloop: 235: move.l 4.w,a6 236: moveq.l #0,d0 237: move.l d0,a1 238: jsr -294(a6) ; FindTask 239: move.l d0,a0 240: lea.l $5c(a0),a5 ; pr_MsgPort 241: 242: ; Open DOS library 243: lea.l doslibname(pc),a1 244: moveq.l #0,d0 245: jsr -552(a6) ; OpenLibrary 246: move.l d0,a2 247: 248: ; Allocate some memory. Usage: 249: ; 0: lock chain 250: ; 4: command chain 251: ; 8: second thread's lock chain 252: ; 12: dummy message 253: ; 32: the volume (80+44+1 bytes) 254: move.l #80+44+1+20+12,d0 255: move.l #$10001,d1 ; MEMF_PUBLIC | MEMF_CLEAR 1.1.1.2 root 256: jsr -198(a6) ; AllocMem 1.1 root 257: move.l d0,a3 258: moveq.l #0,d6 259: move.l d6,(a3) 260: move.l d6,4(a3) 261: move.l d6,8(a3) 262: 263: moveq.l #0,d5 ; No commands queued. 264: 265: ; Fetch our startup packet 266: move.l a5,a0 267: jsr -384(a6) ; WaitPort 268: move.l a5,a0 269: jsr -372(a6) ; GetMsg 270: move.l d0,a4 271: move.l 10(a4),d3 ; ln_Name 1.1.1.3 ! root 272: move.w #$FF40,d0 ! 273: bsr.w getrtbase 1.1 root 274: moveq.l #0,d0 1.1.1.3 ! root 275: jsr (a0) 1.1 root 276: bra.b FSML_Reply 277: 278: ; We abuse some of the fields of the message we get. Offset 0 is 279: ; used for chaining unprocessed commands, and offset 1 is used for 280: ; indicating the status of a command. 0 means the command was handed 281: ; off to some UAE thread and did not complete yet, 1 means we didn't 282: ; even hand it over yet because we were afraid that might blow some 283: ; pipe limit, and -1 means the command was handed over and has completed 284: ; processing by now, so it's safe to reply to it. 285: 286: FSML_loop: 287: move.l a5,a0 288: jsr -384(a6) ; WaitPort 289: move.l a5,a0 290: jsr -372(a6) ; GetMsg 291: move.l d0,a4 292: move.l 10(a4),d3 ; ln_Name 293: bne.b FSML_FromDOS 294: 295: ; It's a dummy packet indicating that some queued command finished. 1.1.1.3 ! root 296: move.w #$FF50,d0 ! 297: bsr.w getrtbase 1.1 root 298: moveq.l #1,d0 1.1.1.3 ! root 299: jsr (a0) 1.1 root 300: ; Go through the queue and reply all those that finished. 301: lea.l 4(a3),a2 302: move.l (a2),a0 303: FSML_check_old: 304: move.l a0,d0 305: beq.b FSML_loop 306: move.l (a0),a1 307: move.l d0,a0 308: ; This field may be accessed concurrently by several UAE threads. 309: ; This _should_ be harmless on all reasonable machines. 310: move.l 4(a0),d0 311: bpl.b FSML_check_next 312: movem.l a0/a1,-(a7) 313: move.l 10(a0),a4 314: bsr.b ReplyOne 315: subq.l #1,d5 ; One command less in the queue 316: movem.l (a7)+,a0/a1 317: move.l a1,(a2) 318: move.l a1,a0 319: bra.b FSML_check_old 320: FSML_check_next: 321: move.l a0,a2 322: move.l a1,a0 323: bra.b FSML_check_old 324: 325: FSML_FromDOS: 326: ; Limit the number of outstanding started commands. We can handle an 327: ; unlimited number of unstarted commands. 328: cmp.l #20,d5 329: bcs FSML_DoCommand 330: ; Too many commands queued. 331: moveq.l #1,d0 332: move.l d0,4(a4) 333: bra.b FSML_Enqueue 334: 335: FSML_DoCommand: 336: bsr.b LockCheck ; Make sure there are enough locks for the C code to grab. 1.1.1.3 ! root 337: move.w #$FF30,d0 ! 338: bsr.w getrtbase ! 339: jsr (a0) 1.1 root 340: tst.l d0 341: beq.b FSML_Reply 342: ; The command did not complete yet. Enqueue it and increase number of 343: ; queued commands 344: ; The C code already set 4(a4) to 0 345: addq.l #1,d5 346: FSML_Enqueue: 347: move.l 4(a3),(a4) 348: move.l a4,4(a3) 349: bra.b FSML_loop 350: 351: FSML_Reply: 352: move.l d3,a4 353: bsr.b ReplyOne 1.1.1.3 ! root 354: bra.w FSML_loop 1.1 root 355: 356: ReplyOne: 357: move.l (a4),a1 ; dp_Link 358: move.l 4(a4),a0 ; dp_Port 359: move.l a5,4(a4) 360: jmp -366(a6) ; PutMsg 361: 362: ; ugly code to avoid calling AllocMem / FreeMem from native C code. 363: ; We keep a linked list of 3 locks. In theory, only one should ever 364: ; be used. Before handling every packet, we check that the list has the 365: ; right length. 366: 367: LockCheck: 368: move.l d5,-(a7) 369: moveq.l #-4,d5 ; Keep three locks 370: move.l (a3),a2 371: move.l a2,d7 372: LKCK_Loop: 373: move.l a2,d1 374: beq LKCK_ListEnd 375: addq.l #1,d5 376: beq.b LKCK_TooMany 377: move.l a2,a1 378: move.l (a2),a2 379: bra.b LKCK_Loop 380: LKCK_ListEnd: 381: addq.l #1,d5 382: beq.b LKCK_ret 383: move.l d7,a2 384: moveq.l #24,d0 ; sizeof Lock is 20, 4 for chain 385: moveq.l #1,d1 ; MEMF_PUBLIC 1.1.1.2 root 386: jsr -198(a6) ; AllocMem 1.1 root 387: addq.w #1,d6 388: move.l d0,a2 389: move.l d7,(a2) 390: move.l a2,d7 391: bra.b LKCK_ListEnd 392: LKCK_TooMany: 393: move.l (a2),d0 ; We have too many, but we tolerate that to some extent. 394: beq.b LKCK_ret 395: move.l d0,a0 396: move.l (a0),d0 397: beq.b LKCK_ret 398: move.l d0,a0 399: move.l (a0),d0 400: beq.b LKCK_ret 401: 402: moveq.l #0,d0 ; Now we are sure that we really have too many. Delete some. 403: move.l d0,(a1) 404: LKCK_TooManyLoop: 405: move.l a2,a1 406: move.l (a1),a2 407: moveq.l #24,d0 408: jsr -210(a6) ; FreeMem 409: add.l #$10000,d6 410: move.l a2,d0 411: bne.b LKCK_TooManyLoop 412: LKCK_ret: 413: move.l d7,(a3) 414: move.l (a7)+,d5 415: rts 416: 1.1.1.3 ! root 417: getrtbase: ! 418: lea start-8-4(pc),a0 ! 419: and.l #$FFFF,d0 ! 420: add.l d0,a0 ! 421: rts ! 422: 1.1 root 423: exter_name: dc.b 'UAE filesystem',0 424: doslibname: dc.b 'dos.library',0 425: explibname: dc.b 'expansion.library',0 426: END
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.