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

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

unix.superglobalmegacorp.com

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