Annotation of MiNT/src/intr.spp, revision 1.1.1.3

1.1.1.2   root        1: ; Copyright 1992 Eric R. Smith
                      2: 
                      3: ; All rights reserved.
                      4: 
                      5: 
                      6: 
1.1       root        7: %include "magic.i"
                      8: 
                      9: ;
                     10: 
                     11: ; interrupt wrapping routines; these should just save registers and call
                     12: 
                     13: ; the appropriate C handlers, unless speed is a major problem
                     14: 
                     15: ;
                     16: 
                     17:        TEXT
                     18: 
                     19: ;
                     20: 
                     21: ; first, utilities for setting processor status level
                     22: 
                     23: ;
                     24: 
                     25:        XDEF    _spl7,_spl
                     26: 
                     27: _spl7:
                     28: 
                     29:        move.w  sr,d0
                     30: 
                     31:        ori.w   #$0700,sr
                     32: 
                     33:        rts
                     34: 
                     35: _spl:
                     36: 
1.1.1.3 ! root       37:        move.w  4(sp),sr
1.1       root       38: 
                     39:        rts
                     40: 
                     41: 
                     42: 
                     43:        XDEF    _mint_5ms
                     44: 
                     45:        XDEF    _mint_timer
                     46: 
                     47:        XDEF    _mint_vbl
                     48: 
                     49:        XREF    _timeout        ; C time routine
                     50: 
                     51:        XREF    _old_timer      ; old GEMDOS time vector
                     52: 
                     53:        XREF    _old_vbl        ; old GEMDOS vbl vector
                     54: 
                     55:        XREF    _old_5ms
                     56: 
                     57:        XREF    _build_context
                     58: 
                     59:        XREF    _restore_context
                     60: 
                     61:        XREF    _proc_clock             ; controls process' allocation of CPU time
                     62: 
                     63:        XREF    _curproc
                     64: 
                     65:        XREF    _enter_kernel
                     66: 
                     67:        XREF    _leave_kernel
                     68: 
                     69:        XREF    _preempt
                     70: 
                     71:        XREF    _in_kernel
                     72: 
                     73: 
                     74: 
                     75: ; AKP: this code is hit once every 5ms; it updates the time fields of curproc.
                     76: 
                     77: _mint_5ms:
                     78: 
                     79:        move.l  a0,-(sp)
                     80: 
                     81:        move.l  _curproc,a0
                     82: 
                     83:        tst.w   _in_kernel
                     84: 
                     85:        bne.s   L_systime
                     86: 
                     87:        lea     P_USRTIME(a0),a0        ; get offset to curproc->usrtime
                     88: 
                     89:        addq.l  #5,(a0)                 ; update the time
                     90: 
                     91:        move.l  (sp)+,a0
                     92: 
                     93:        move.l  _old_5ms+8,-(sp)        ; branch to old vector
                     94: 
                     95:        rts
                     96: 
                     97: L_systime:
                     98: 
                     99:        lea     P_SYSTIME(a0),a0        ; get offset to curproc->systime
                    100: 
                    101:        addq.l  #5,(a0)
                    102: 
                    103:        move.l  (sp)+,a0
                    104: 
                    105:        move.l  _old_5ms+8,-(sp)
                    106: 
                    107:        rts
                    108: 
                    109: 
                    110: 
                    111: _mint_timer:
                    112: 
                    113:        movem.l d0-d2/a0-a2,-(sp)       ; save C registers
                    114: 
                    115:        jsr     _timeout
                    116: 
                    117:        movem.l (sp)+,d0-d2/a0-a2
                    118: 
                    119:        move.l  _old_timer+8,-(sp)      ; jump to GEMDOS time vector
                    120: 
                    121:        rts
                    122: 
                    123: 
                    124: 
                    125: _mint_vbl:
                    126: 
1.1.1.2   root      127: %ifndef ONLY030
                    128: 
1.1       root      129:        tst.w   ($59e).w                ; test longframe (AKP)
                    130: 
                    131:        beq.s   L_short1
                    132: 
1.1.1.2   root      133: %endif
                    134: 
1.1       root      135:        clr.w   -(sp)                   ; yes, long frames: push a frame word
                    136: 
                    137: L_short1:
                    138: 
                    139:        pea     L_comeback              ; push fake PC
                    140: 
                    141:        move.w  sr,-(sp)                ; push status register
                    142: 
                    143:        move.l  _old_vbl+8,-(sp)        ; go service the interrupt
                    144: 
                    145:        rts
                    146: 
                    147: 
                    148: 
                    149: L_comeback:
                    150: 
                    151:        tst.w   _proc_clock             ; has time expired yet?
                    152: 
                    153:        beq.s   L_expired               ; yes -- maybe go switch processes
                    154: 
                    155: L_out:
                    156: 
                    157:        rte                             ; no -- just return
                    158: 
                    159: 
                    160: 
                    161: L_expired:
                    162: 
                    163:        btst    #5,(sp)                 ; user mode?
                    164: 
                    165:        bne.s   L_out                   ; no -- switching is not possible
                    166: 
                    167:        tst.w   ($43e).w                ; test floppy disk lock variable
                    168: 
                    169:        bne.s   L_out                   ; if locked, can't switch
                    170: 
                    171:        tst.w   _in_kernel              ; are we doing a kernel operation?
                    172: 
                    173:        bne.s   L_out
                    174: 
                    175: L_switch:
                    176: 
                    177:        clr.w   -(sp)                   ; no frame format needed
                    178: 
                    179:        move.l  _curproc,-(sp)
                    180: 
1.1.1.2   root      181:        addq.l  #P_CTXT0,(sp)                   ; to get &curproc->ctxt[SYSCALL]
1.1       root      182: 
                    183:        jsr     _build_context          ; build context
                    184: 
                    185:        move.l  _curproc,a0
                    186: 
                    187:        move.l  (a0),sp                 ; use curproc->sysstack
                    188: 
                    189:        jsr     _enter_kernel           ; enter kernel
                    190: 
                    191:        jsr     _preempt                ; yield processor
                    192: 
                    193:        ori.w   #$700,sr                ; spl7()
                    194: 
                    195:        jsr     _leave_kernel           ; restore vectors
                    196: 
                    197:        move.l  _curproc,a0
                    198: 
                    199:        pea     4(a0)
                    200: 
                    201:        jsr     _restore_context        ; back to user
                    202: 
                    203: 
                    204: 
                    205: ;
                    206: 
                    207: ; reset routine -- called on a warm boot. Note that TOS sends the
                    208: 
                    209: ; address to which we should return in register a6. Also note that
                    210: 
                    211: ; the stack pointer is in an unknown state, so we set up our own
                    212: 
                    213: ;
                    214: 
                    215:        XDEF    _reset
                    216: 
1.1.1.2   root      217:        XREF    _init_tail              ; see main.c
1.1       root      218: 
                    219:        XREF    _restr_intr
                    220: 
                    221: 
                    222: 
                    223: _reset:
                    224: 
                    225:        move.w  #$2700,sr               ; avoid interruption here
                    226: 
1.1.1.2   root      227:        move.l  sp,_init_tail           ; save A7
1.1       root      228: 
1.1.1.2   root      229:        lea     _init_tail,sp           ; set up temporary stack
1.1       root      230: 
                    231:        lea     256(sp),sp
                    232: 
                    233:        movem.l d0-d2/a0-a2,-(sp)       ; save C registers
                    234: 
                    235:        jsr     _restr_intr             ; restore interrupts
                    236: 
                    237:        movem.l (sp)+,d0-d2/a0-a2       ; restore registers
                    238: 
1.1.1.2   root      239:        move.l  _init_tail,sp
1.1       root      240: 
                    241:        jmp     (a6)                    ; reset again
                    242: 
                    243: 
                    244: 
                    245: ;
                    246: 
                    247: ; routine for doing a reboot
                    248: 
                    249: ;
                    250: 
                    251:        XDEF    _reboot
                    252: 
                    253: _reboot:
                    254: 
                    255:        move.w  #$2700,sr               ; avoid interrupts
                    256: 
                    257:        move.l  (0).w,sp                ; get sp after reboot
                    258: 
                    259:        move.l  (4).w,a6                ; get new reboot address
                    260: 
                    261:        jmp     _reset
                    262: 
                    263: 
                    264: 
                    265: ;
                    266: 
                    267: ; routine for mouse packet handling
                    268: 
                    269: ;
                    270: 
                    271:        XDEF    _newmvec
                    272: 
                    273:        XDEF    _newjvec
                    274: 
                    275:        XREF    _mouse_handler
                    276: 
                    277: ; Experimental three button mouse support (by [email protected],
                    278: 
                    279: ; August 4, 1992
                    280: 
                    281: ;
                    282: 
                    283: ; Should work with the mice shipped with Atari's ASV or
                    284: 
                    285: ; compatible ones (like Golden Image GI-6000). Might not work
                    286: 
                    287: ; on ST/STE systems with older IKBD's or keyboards. The middle mouse
                    288: 
                    289: ; button is wired to one of the joystick directions on joystick one.
                    290: 
                    291: ;
                    292: 
                    293: ; _newmvec is the same as before with two exceptions:
                    294: 
                    295: ; 1. the first byte of the packet is saved for the joystick handler
                    296: 
                    297: ; 2. the bit for the middle mouse button is ored in
                    298: 
                    299: ;
                    300: 
                    301: ; _newjvec hooks into the joystick vector and chains to the normal
                    302: 
                    303: ; handler. The middle mouse button state is saved in a special
                    304: 
                    305: ; register for _newmvec, and a 'fake' mouse packet is set up
                    306: 
                    307: ; (by merging the last mouse packet header, or-ing in the
                    308: 
                    309: ; middle button state and using 0/0 for the x/y increment).
                    310: 
                    311: ;
                    312: 
                    313: ; the faked_packet and third_button variables are declared at the
                    314: 
                    315: ; end of this file
                    316: 
                    317: 
                    318: 
                    319: _newmvec:
                    320: 
                    321:        move.l  a0,-(sp)
                    322: 
                    323:        move.b  (a0),d0
                    324: 
                    325:        move.b  d0,faked_packet
                    326: 
                    327:        or.b    third_button,d0
                    328: 
                    329:        move.b  d0,(a0)
                    330: 
                    331:        jsr     _mouse_handler
                    332: 
                    333:        move.l  (sp)+,a0
                    334: 
                    335:        rts
                    336: 
                    337: ;
                    338: 
                    339: ; routine for joystick packet handling (used for three button mice)
                    340: 
                    341: ;
                    342: 
                    343:        XDEF    _newjvec
                    344: 
                    345:        XREF    _oldjvec
                    346: 
                    347: 
                    348: 
                    349: _newjvec:
                    350: 
                    351:        move.l  a0,-(sp)        ; save a0 on the stack
                    352: 
                    353:        move.b  2(a0),d0        ; joystick direction
                    354: 
                    355:        and.b   #1,d0           ; middle mouse button in lowest bit
                    356: 
                    357:        add.b   d0,d0           ; times 4
                    358: 
                    359:        add.b   d0,d0
                    360: 
                    361:        move.b  d0,third_button ; save it for use in newmvec
                    362: 
                    363: 
                    364: 
                    365:        lea     faked_packet,a0 ; 'our' faked mouse event
                    366: 
                    367:        move.b  (a0),d0
                    368: 
                    369:        and.b   #$3,d0          ; unmask our mouse button
                    370: 
                    371:        or.b    #$F8,d0         ; or in correct header
                    372: 
                    373:        or.b    third_button,d0 ; or in the current status
                    374: 
                    375:        move.b  d0,(a0)         ; write it back
                    376: 
                    377: 
                    378: 
                    379:        move.l  a0,-(sp)        ; pass pointer to fake packet
                    380: 
                    381:        jsr     _mouse_handler  ; to \dev\mouse handler
                    382: 
                    383:        addq.l  #4,sp           ; pop parameter
                    384: 
                    385:        move.l  (sp)+,a0        ; restore original a0 value
                    386: 
                    387:        move.l  _oldjvec,-(sp)  ; jump to original joystick handler
                    388: 
                    389:        rts
                    390: 
                    391: ;
                    392: 
                    393: ; new ikbd keyboard interrupt vector
                    394: 
                    395: ; kintr is a global variable that should be non-zero if a keyboard
                    396: 
                    397: ; event occured
                    398: 
                    399: ;
                    400: 
                    401:        XDEF    _new_ikbd
                    402: 
                    403:        XREF    _old_ikbd
                    404: 
                    405:        XREF    _kintr
                    406: 
                    407: 
                    408: 
                    409: _new_ikbd:
                    410: 
                    411:        move.w  #1,_kintr
                    412: 
                    413:        move.l  _old_ikbd+8,-(sp)
                    414: 
                    415:        rts                     ; jump to system interrupt routine
                    416: 
                    417: 
                    418: 
                    419: ;
                    420: 
                    421: ; simple signal handlers
                    422: 
                    423: ; global variables referenced:
                    424: 
                    425: ; in_kernel: (main.c): flag to indicate that we're in the MiNT kernel
                    426: 
                    427: ; sig_routine: (signal.c): pointer to which signal catching routine to
                    428: 
                    429: ;          call (e.g. for SIGBUS, or whatever)
                    430: 
                    431: ;
                    432: 
                    433:        XDEF    _new_bus,_new_addr,_new_ill,_new_divzero,_new_priv,_new_linef
                    434: 
                    435:        XDEF    _new_trace,_new_chk,_new_trapv,_new_fpcp,_new_mmu,_new_pmmuacc
                    436: 
                    437:        XDEF    _new_uninit,_new_spurious,_new_format,_new_cpv
                    438: 
                    439:        XREF    _in_kernel,_sig_routine
                    440: 
                    441:        XREF    _sigbus,_sigaddr,_sigill,_sigfpe,_sigpriv,_sigtrap
                    442: 
                    443:        XREF    _haltformat,_haltcpv
                    444: 
                    445:        XREF    _sig_exc
                    446: 
1.1.1.3 ! root      447:        XREF    _mcpu
        !           448: 
1.1       root      449:        
                    450: 
1.1.1.2   root      451: ;
                    452: 
                    453: ; New bus error handler for memory protection: get the ssp and
                    454: 
                    455: ; put it in the proc structure before calling
                    456: 
                    457: ; _sigbus.  When the bus error happens in the kernel we don't save
                    458: 
                    459: ; any contexts.
                    460: 
                    461: ; We don't want to mess up any registers here because we might bring the
                    462: 
                    463: ; page in and RTE.
                    464: 
                    465: ;
                    466: 
                    467: 
                    468: 
1.1       root      469: _new_bus:
                    470: 
1.1.1.3 ! root      471: %ifndef ONLY030
        !           472: 
1.1       root      473:        move.w  #$8,_sig_exc
                    474: 
1.1.1.3 ! root      475:        cmp.l   #30,_mcpu
        !           476: 
        !           477:        bne.s   noMMU
        !           478: 
        !           479: %endif
        !           480: 
1.1.1.2   root      481:        move.l  #_mmu_sigbus,_sig_routine
1.1       root      482: 
1.1.1.3 ! root      483: %ifndef ONLY030
        !           484: 
        !           485:        bra.s   Do_sig
        !           486: 
        !           487: noMMU:
        !           488: 
        !           489:        move.l  #_nommu_sigbus,_sig_routine
        !           490: 
        !           491: %endif
        !           492: 
1.1       root      493: Do_sig:
                    494: 
1.1.1.2   root      495:        move.l  a0,-(sp)                ; save a0
                    496: 
                    497:        move.l  _curproc,a0
                    498: 
                    499:        move.l  sp,P_EXCSSP(a0)
                    500: 
                    501:        addq.l  #4,P_EXCSSP(a0)
                    502: 
                    503:        move.l  6(sp),P_EXCPC(a0)
                    504: 
                    505:        move.l  (sp)+,a0
                    506: 
                    507: 
                    508: 
1.1       root      509:        tst.w   _in_kernel              ; are we already in the kernel?
                    510: 
                    511:        bne.s   Kernel                  ; yes
                    512: 
                    513:        move.w  _sig_exc,-(sp)
                    514: 
                    515:        move.l  _curproc,-(sp)
                    516: 
                    517:        addq.l  #4,(sp)                 ; push offset of save area
                    518: 
                    519:        jsr     _build_context
                    520: 
                    521:        move.l  _curproc,a4
                    522: 
                    523:        move.l  (a4),sp                 ; put us in the system stack
                    524: 
                    525:        jsr     _enter_kernel           ; set up kernel vectors
                    526: 
                    527:        move.l  _sig_routine,a1         ; get signal handling routine
                    528: 
                    529:        jsr     (a1)                    ; go do it
                    530: 
                    531:        ori.w   #$0700,sr               ; spl7()
                    532: 
                    533:        jsr     _leave_kernel           ; leave kernel
                    534: 
                    535:        addq.w  #4,a4                   ; get context save area address
                    536: 
                    537:        move.l  a4,-(sp)                ; push it
                    538: 
                    539:        jsr     _restore_context        ; restore the context
                    540: 
                    541: ;
                    542: 
                    543: ; here's what we do if we already were in the kernel
                    544: 
                    545: ;
                    546: 
                    547: Kernel:
                    548: 
                    549:        movem.l d0-d2/a0-a2,-(sp)       ; save reggies
                    550: 
                    551:        move.l  _sig_routine,a1         ; get handler
                    552: 
                    553:        jsr     (a1)                    ; go do it
                    554: 
                    555:        movem.l (sp)+,d0-d2/a0-a2
                    556: 
                    557:        rte
                    558: 
1.1.1.2   root      559: 
                    560: 
                    561: ;
                    562: 
                    563: ; _mmu_sigbus: a pre-handler for _sigbus.  Check the reason for the bus
                    564: 
                    565: ; error and report if it was a real access fault.
                    566: 
                    567: ;
                    568: 
                    569: _mmu_sigbus:
                    570: 
                    571:        move.l  a2,-(sp)
                    572: 
                    573:        move.l  _curproc,a0
                    574: 
                    575:        move.l  P_EXCSSP(a0),a1         ; a1 is now exception_ssp
                    576: 
                    577:        move.w  $A(a1),d0               ; d0 is SSR
                    578: 
                    579:        move.l  $10(a1),a1              ; a1 is the access address
                    580: 
                    581:        move.l  a1,P_EXCADDR(a0)        ; save the access address
                    582: 
                    583: 
                    584: 
                    585:        ptestr  d0,(a1),#7,a2           ; a2 is the table address
                    586: 
                    587:        move.l  a2,P_EXCTBL(a0)         ; save table address in curproc
                    588: 
                    589:        pmove   mmusr,P_EXCMMUSR(a0)    ; save resulting mmusr in curproc
                    590: 
                    591:        move.l  (sp)+,a2
                    592: 
                    593:        jmp     _sigbus         ; chain to bus-error handler
                    594: 
1.1.1.3 ! root      595: %ifndef ONLY030
        !           596: 
        !           597: ;
        !           598: 
        !           599: ; _nommu_sigbus: handler for bus errors on machines without MMU
        !           600: 
        !           601: 
        !           602: 
        !           603: _nommu_sigbus:
        !           604: 
        !           605:        move.l  _curproc,a0
        !           606: 
        !           607:        move.l  P_EXCSSP(a0),a1
        !           608: 
        !           609:        lea     $10(a1),a1              ; point to access address
        !           610: 
        !           611:        tst.w   ($59e).w                ; test longframe
        !           612: 
        !           613:        beq.s   NOMMU1
        !           614: 
        !           615:        addq.w  #8,a1                   ; on 68000, address is 8 bytes further
        !           616: 
        !           617: NOMMU1:
        !           618: 
        !           619:        move.l  (a1),P_EXCADDR(a0)      ; save the access address
        !           620: 
        !           621:        jmp     _sigbus
        !           622: 
        !           623: %endif
        !           624: 
1.1.1.2   root      625: 
                    626: 
1.1       root      627: _new_addr:
                    628: 
1.1.1.3 ! root      629: %ifndef ONLY030
        !           630: 
1.1       root      631:        move.w  #$c,_sig_exc
                    632: 
1.1.1.3 ! root      633: %endif
        !           634: 
1.1       root      635:        move.l  #_sigaddr,_sig_routine
                    636: 
1.1.1.2   root      637:        bra     Do_sig
1.1       root      638: 
                    639: _new_ill:
                    640: 
1.1.1.3 ! root      641: %ifndef ONLY030
        !           642: 
1.1       root      643:        move.w  #$10,_sig_exc
                    644: 
1.1.1.3 ! root      645: %endif
        !           646: 
1.1       root      647:        move.l  #_sigill,_sig_routine
                    648: 
1.1.1.2   root      649:        bra     Do_sig
1.1       root      650: 
                    651: _new_divzero:
                    652: 
1.1.1.3 ! root      653: %ifndef ONLY030
        !           654: 
1.1       root      655:        move.w  #$14,_sig_exc
                    656: 
1.1.1.3 ! root      657: %endif
        !           658: 
1.1       root      659:        move.l  #_sigfpe,_sig_routine
                    660: 
                    661:        bra     Do_sig
                    662: 
                    663: _new_linef:
                    664: 
1.1.1.3 ! root      665: %ifndef ONLY030
        !           666: 
1.1       root      667:        move.w  #$2c,_sig_exc
                    668: 
1.1.1.3 ! root      669: %endif
        !           670: 
1.1       root      671:        move.l  #_sigill,_sig_routine
                    672: 
                    673:        bra     Do_sig
                    674: 
                    675: _new_chk:
                    676: 
1.1.1.3 ! root      677: %ifndef ONLY030
        !           678: 
1.1       root      679:        move.w  #$18,_sig_exc
                    680: 
1.1.1.3 ! root      681: %endif
        !           682: 
1.1       root      683:        move.l  #_sigfpe,_sig_routine
                    684: 
                    685:        bra     Do_sig
                    686: 
                    687: _new_trapv:
                    688: 
1.1.1.3 ! root      689: %ifndef ONLY030
        !           690: 
1.1       root      691:        move.w  #$1c,_sig_exc
                    692: 
1.1.1.3 ! root      693: %endif
        !           694: 
1.1       root      695:        move.l  #_sigfpe,_sig_routine
                    696: 
                    697:        bra     Do_sig
                    698: 
                    699: _new_fpcp:
                    700: 
                    701: ; don't set _sig_exc - only needed for 68000 vectors
                    702: 
                    703:        move.l  #_sigfpe,_sig_routine
                    704: 
                    705:        bra     Do_sig
                    706: 
                    707: _new_mmu:
                    708: 
                    709: ; don't set _sig_exc - only needed for 68000 vectors
                    710: 
                    711:        move.l  #_sigill,_sig_routine
                    712: 
                    713:        bra     Do_sig
                    714: 
                    715: _new_pmmuacc:
                    716: 
                    717: ; don't set _sig_exc - only needed for 68000 vectors
                    718: 
                    719:        move.l  #_sigbus,_sig_routine
                    720: 
                    721:        bra     Do_sig
                    722: 
                    723: _new_uninit:
                    724: 
1.1.1.3 ! root      725: %ifndef ONLY030
        !           726: 
1.1       root      727:        move.w  #$3c,_sig_exc
                    728: 
1.1.1.3 ! root      729: %endif
        !           730: 
1.1       root      731:        move.l  #_sigbus,_sig_routine
                    732: 
                    733:        bra     Do_sig
                    734: 
                    735: _new_spurious:
                    736: 
1.1.1.3 ! root      737: %ifndef ONLY030
        !           738: 
1.1       root      739:        move.w  #$60,_sig_exc
                    740: 
1.1.1.3 ! root      741: %endif
        !           742: 
1.1       root      743:        move.l  #_sigbus,_sig_routine
                    744: 
                    745:        bra     Do_sig
                    746: 
                    747: _new_format:
                    748: 
                    749:        move.l  #_haltformat,_sig_routine
                    750: 
                    751:        bra     Do_sig
                    752: 
                    753: _new_cpv:
                    754: 
                    755:        move.l  #_haltcpv,_sig_routine
                    756: 
                    757:        bra     Do_sig
                    758: 
                    759: 
                    760: 
                    761:        XREF    _old_priv               ; old privilege violation vector
                    762: 
                    763: _new_priv:
                    764: 
1.1.1.3 ! root      765: %ifndef ONLY030
        !           766: 
1.1       root      767:        move.w  #$20,_sig_exc
                    768: 
1.1.1.3 ! root      769: %endif
        !           770: 
1.1       root      771:        move.l  #_sigpriv,_sig_routine
                    772: 
1.1.1.3 ! root      773: %ifndef ONLY030
1.1.1.2   root      774: 
1.1       root      775:        tst.w   ($59e).w                ; 68000s always get SIGPRIV
                    776: 
                    777:        beq     Do_sig
                    778: 
1.1.1.2   root      779: %endif
                    780: 
1.1       root      781:        movem.l d0/a0,-(a7)
                    782: 
                    783:        move.l  10(a7),a0               ; fetch exception address
                    784: 
                    785:        move.w  (a0),d0
                    786: 
                    787:        and.w   #$ffc0,d0               ; partially decode move sr,...
                    788: 
                    789:        cmp.w   #$40c0,d0               ; and test it
                    790: 
                    791:        movem.l (a7)+,d0/a0             ; preserves the flags
                    792: 
                    793:        bne     Do_sig                  ; doesn't look like sr,...
                    794: 
                    795:        move.l  _old_priv+8,-(sp)       ; let our parent handle it
                    796: 
                    797:        rts
                    798: 
                    799: 
                    800: 
                    801: ; XBRA vectors from main.c
                    802: 
                    803:        XREF    _old_dos,_old_bios,_old_xbios
                    804: 
                    805:        XREF    _old_divzero,_old_chk,_old_trapv
                    806: 
                    807: 
                    808: 
                    809: _new_trace:
                    810: 
                    811:        btst    #5,(a7)                 ; only check when called from supervisor mode
                    812: 
                    813:        beq.s   S_1
                    814: 
                    815:        cmp.l   #_old_dos+12,2(a7)      ; lets not trace the kernel !
                    816: 
                    817:        beq.s   S_2
                    818: 
                    819:        cmp.l   #_old_xbios+12,2(a7)
                    820: 
                    821:        beq.s   S_2
                    822: 
                    823:        cmp.l   #_old_bios+12,2(a7)
                    824: 
                    825:        beq.s   S_2
                    826: 
                    827:        cmp.l   #_old_divzero+12,2(a7)
                    828: 
                    829:        beq.s   S_2
                    830: 
                    831:        cmp.l   #_old_trapv+12,2(a7)
                    832: 
                    833:        beq.s   S_2
                    834: 
                    835:        cmp.l   #_old_chk+12,2(a7)
                    836: 
                    837:        beq.s   S_2
                    838: 
                    839: ; add any other non-traceable entities here...
                    840: 
                    841: 
                    842: 
                    843: S_1:   move.w  #$24,_sig_exc
                    844: 
                    845:        move.l  #_sigtrap,_sig_routine
                    846: 
                    847:        bra     Do_sig
                    848: 
                    849: 
                    850: 
                    851: S_2:   and.w   #$3fff,(a7)             ; clear both trace bits
                    852: 
                    853:        rte                             ; and re-start the handler
                    854: 
                    855: 
                    856: 
                    857: ;
                    858: 
                    859: ; BIOS disk vectors for pseudo-disks like U: and X:; these are present
                    860: 
                    861: ; just in case some program (foolishly) attempts to access these drives
                    862: 
                    863: ; directly and gets horribly confused
                    864: 
                    865: ;
                    866: 
                    867:        XREF    _old_getbpb     ; old Getbpb vector
                    868: 
                    869:        XREF    _old_mediach    ; old Mediach vector
                    870: 
                    871:        XREF    _old_rwabs      ; old Rwabs vector
                    872: 
                    873:        XREF    _aliasdrv       ; array of drive aliases
                    874: 
                    875:        XDEF    _new_getbpb
                    876: 
                    877:        XDEF    _new_mediach
                    878: 
                    879:        XDEF    _new_rwabs
                    880: 
                    881: 
                    882: 
                    883: _new_getbpb:
                    884: 
                    885:        move.w  4(sp),d0        ; check the drive
                    886: 
1.1.1.2   root      887:        cmp.w   #$1f,d0         ; legal drive?
                    888: 
                    889:        bhi.s   noalias0        ; no
                    890: 
1.1       root      891:        move.w  d0,d1           ; get index
                    892: 
                    893:        add.w   d0,d1           ; convert to index
                    894: 
                    895:        lea     _aliasdrv,a0
                    896: 
                    897:        move.w  0(a0,d1.w),d1   ; alias drive?
                    898: 
                    899:        beq.s   noalias0
                    900: 
                    901:        move.w  d1,d0
                    902: 
                    903:        subq.w  #1,d0           ; adjust for aliasdrv base of '@'
                    904: 
                    905:        cmp.w   #$1f,d0         ; is this a legal drive?
                    906: 
                    907:        bhi.s   nobpb           ; no -- ignore it
                    908: 
1.1.1.2   root      909: noalias0:
                    910: 
1.1       root      911:        cmp.w   #$14,d0         ; drive U:?
                    912: 
                    913:        beq.s   nobpb           ; yes, no BPB available
                    914: 
                    915:        move.l  _old_getbpb+8,a0        ; not our drive
                    916: 
                    917:        jmp     (a0)            ; call the old vector for it
                    918: 
                    919: nobpb:
                    920: 
                    921:        moveq.l #0,d0           ; 0 means "no BPB read"
                    922: 
                    923:        rts
                    924: 
                    925: 
                    926: 
                    927: _new_mediach:
                    928: 
                    929:        move.w  4(sp),d0        ; check the drive
                    930: 
1.1.1.2   root      931:        cmp.w   #$1f,d0         ; legal drive?
                    932: 
                    933:        bhi.s   noalias1        ; no
                    934: 
1.1       root      935:        move.w  d0,d1           ; get index
                    936: 
                    937:        add.w   d0,d1           ; convert to index
                    938: 
                    939:        lea     _aliasdrv,a0
                    940: 
                    941:        move.w  0(a0,d1.w),d1   ; alias drive?
                    942: 
                    943:        beq.s   noalias1
                    944: 
                    945:        move.w  d1,d0
                    946: 
                    947:        subq.w  #1,d0           ; adjust for aliasdrv base
                    948: 
                    949:        cmp.w   #$1f,d0         ; legal drive?
                    950: 
                    951:        bhi.s   nobpb           ; no -- ignore it
                    952: 
1.1.1.2   root      953: noalias1:
                    954: 
1.1       root      955:        cmp.w   #$14,d0         ; drive U:?
                    956: 
                    957:        beq.s   nochng          ; yes, no change
                    958: 
                    959:        move.l  _old_mediach+8,a0       ; not our drive
                    960: 
                    961:        jmp     (a0)            ; call the old vector for it
                    962: 
                    963: nochng:
                    964: 
                    965:        moveq.l #0,d0           ; 0 means "definitely no change"
                    966: 
                    967:        rts
                    968: 
                    969: 
                    970: 
                    971: _new_rwabs:
                    972: 
                    973:        move.w  $e(sp),d0       ; check the drive
                    974: 
1.1.1.2   root      975:        cmp.w   #$1f,d0         ; legal drive?
                    976: 
                    977:        bhi.s   noalias2        ; no
                    978: 
1.1       root      979:        move.w  d0,d1           ; get index
                    980: 
                    981:        add.w   d0,d1           ; convert to index
                    982: 
                    983:        lea     _aliasdrv,a0
                    984: 
                    985:        move.w  0(a0,d1.w),d1   ; alias drive?
                    986: 
                    987:        beq.s   noalias2
                    988: 
                    989:        move.w  d1,d0
                    990: 
                    991:        subq.w  #1,d0           ; adjust for aliasdrv base
                    992: 
                    993:        cmp.w   #$1f,d0         ; legal drive?
                    994: 
                    995:        bhi.s   nobpb           ; no -- ignore it
                    996: 
1.1.1.2   root      997: noalias2:
                    998: 
1.1       root      999:        cmp.w   #$14,d0         ; drive U:?
                   1000: 
                   1001:        beq.s   rwdone          ; yes, fake it
                   1002: 
                   1003:        move.l  _old_rwabs+8,a0 ; not our drive
                   1004: 
                   1005:        jmp     (a0)            ; call the old vector for it
                   1006: 
                   1007: rwdone:
                   1008: 
                   1009:        moveq.l #0,d0           ; 0 means "successful operation"
                   1010: 
                   1011:        rts
                   1012: 
                   1013: 
                   1014: 
                   1015:        DATA
                   1016: 
                   1017: ; buffer for faked mouse packet (actually only 3 bytes)
                   1018: 
                   1019: 
                   1020: 
                   1021: faked_packet:
                   1022: 
                   1023:        dc.l    0
                   1024: 
                   1025: 
                   1026: 
                   1027: ; here we store the additional button state
                   1028: 
                   1029: third_button:
                   1030: 
                   1031:        dc.w    0
                   1032: 
                   1033: 
                   1034: 
                   1035:        END
                   1036: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.