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

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

unix.superglobalmegacorp.com

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