Annotation of MiNT/src/gas/intr.s, revision 1.1

1.1     ! root        1: |
        !             2: 
        !             3: | interrupt wrapping routines; these should just save registers and call
        !             4: 
        !             5: | the appropriate C handlers, unless speed is a major problem
        !             6: 
        !             7: |
        !             8: 
        !             9: 
        !            10: 
        !            11: |
        !            12: 
        !            13: | first, utilities for setting processor status level
        !            14: 
        !            15: |
        !            16: 
        !            17:        .globl  _spl7, _spl
        !            18: 
        !            19: _spl7:
        !            20: 
        !            21:        movew   sr, d0
        !            22: 
        !            23:        oriw    #0x0700, sr
        !            24: 
        !            25:        rts
        !            26: 
        !            27: _spl:
        !            28: 
        !            29:        movew   sp@(4), d0
        !            30: 
        !            31:        movew   d0, sr
        !            32: 
        !            33:        rts
        !            34: 
        !            35: 
        !            36: 
        !            37:        .globl  _mint_5ms
        !            38: 
        !            39:        .globl  _mint_timer
        !            40: 
        !            41:        .globl  _mint_vbl
        !            42: 
        !            43:        .globl  _timeout        | C time routine
        !            44: 
        !            45:        .globl  _old_timer      | old GEMDOS time vector
        !            46: 
        !            47:        .globl  _old_vbl        | old GEMDOS vbl vector
        !            48: 
        !            49:        .globl  _old_5ms
        !            50: 
        !            51:        .globl  _build_context
        !            52: 
        !            53:        .globl  _restore_context
        !            54: 
        !            55:        .globl  _proc_clock             | controls process' allocation of CPU time
        !            56: 
        !            57:        .globl  _curproc
        !            58: 
        !            59:        .globl  _in_kernel
        !            60: 
        !            61: 
        !            62: 
        !            63: | AKP: this code is hit once every 5ms; it updates the time fields of curproc.
        !            64: 
        !            65: _mint_5ms:
        !            66: 
        !            67:        movel   a0,sp@-
        !            68: 
        !            69:        movel   _curproc,a0
        !            70: 
        !            71:        addw    #0x364,a0               | $364 is offset to curproc->systime;
        !            72: 
        !            73:        tstw    _in_kernel
        !            74: 
        !            75:        bne     L_5a                    | usrtime is the branch-not-taken case
        !            76: 
        !            77:        addql   #4,a0
        !            78: 
        !            79: L_5a:  addql   #5,a0@
        !            80: 
        !            81:        movel   sp@+,a0
        !            82: 
        !            83:        movel   _old_5ms+8,sp@-
        !            84: 
        !            85:        rts
        !            86: 
        !            87: 
        !            88: 
        !            89: _mint_timer:
        !            90: 
        !            91:        moveml  d0-d2/a0-a2, sp@-       | save C registers
        !            92: 
        !            93:        jsr     _timeout
        !            94: 
        !            95:        moveml  sp@+, d0-d2/a0-a2
        !            96: 
        !            97:        movel   _old_timer+8, sp@-      | jump to GEMDOS time vector
        !            98: 
        !            99:        rts
        !           100: 
        !           101: 
        !           102: 
        !           103: _mint_vbl:
        !           104: 
        !           105:        tstw    0x59e                   | test longframe (AKP)
        !           106: 
        !           107:        beq     L_short1
        !           108: 
        !           109:        clrw    sp@-                    | yes, long frames: push a frame word
        !           110: 
        !           111: L_short1:
        !           112: 
        !           113:        pea     L_comeback              | push fake PC
        !           114: 
        !           115:        movew   sr, sp@-                | push status register
        !           116: 
        !           117:        movel   _old_vbl+8, sp@-        | go service the interrupt
        !           118: 
        !           119:        rts
        !           120: 
        !           121: 
        !           122: 
        !           123: L_comeback:
        !           124: 
        !           125:        tstw    _proc_clock             | has time expired yet?
        !           126: 
        !           127:        beq     L_expired               | yes -- maybe go switch processes
        !           128: 
        !           129: L_out:
        !           130: 
        !           131:        rte                             | no -- just return
        !           132: 
        !           133: 
        !           134: 
        !           135: L_expired:
        !           136: 
        !           137:        btst    #13, sp@                | user mode?
        !           138: 
        !           139:        bne     L_out                   | no -- switching is not possible
        !           140: 
        !           141: L_switch:
        !           142: 
        !           143:        movel   _curproc, sp@-
        !           144: 
        !           145:        addl    #4, sp@                 | to get &curproc->ctxt[SYSCALL]
        !           146: 
        !           147:        jsr     _build_context          | build context
        !           148: 
        !           149:        movel   _curproc, a0
        !           150: 
        !           151:        movel   a0@, sp                 | use curproc->sysstack
        !           152: 
        !           153:        jsr     _enter_kernel           | enter kernel
        !           154: 
        !           155:        jsr     _preempt                | yield processor
        !           156: 
        !           157:        oriw    #0x0700, sr             | spl7()
        !           158: 
        !           159:        jsr     _leave_kernel           | restore vectors
        !           160: 
        !           161:        movel   _curproc, a0
        !           162: 
        !           163:        pea     a0@(4)
        !           164: 
        !           165:        jsr     _restore_context        | back to user
        !           166: 
        !           167: |
        !           168: 
        !           169: | reset routine -- called on a warm boot. Note that TOS sends the
        !           170: 
        !           171: | address to which we should return in register a6. Also note that
        !           172: 
        !           173: | the stack pointer is in an unknown state, so we set up our own
        !           174: 
        !           175: |
        !           176: 
        !           177:        .globl  _reset
        !           178: 
        !           179:        .globl  _tmpstack               | see main.c
        !           180: 
        !           181: 
        !           182: 
        !           183: _reset:
        !           184: 
        !           185:        movew   #0x2700, sr             | avoid interruption here
        !           186: 
        !           187:        movel   sp, _tmpstack           | save A7
        !           188: 
        !           189:        lea     _tmpstack, sp           | set up temporary stack
        !           190: 
        !           191:        lea     sp@(256), sp
        !           192: 
        !           193:        moveml  d0-d2/a0-a2, sp@-       | save C registers
        !           194: 
        !           195:        jsr     _restr_intr             | restore interrupts
        !           196: 
        !           197:        moveml  sp@+, d0-d2/a0-a2       | restore registers
        !           198: 
        !           199:        movel   _tmpstack, sp
        !           200: 
        !           201:        jmp     a6@                     | reset again
        !           202: 
        !           203: 
        !           204: 
        !           205: |
        !           206: 
        !           207: | routine for doing a reboot
        !           208: 
        !           209: |
        !           210: 
        !           211:        .globl  _reboot
        !           212: 
        !           213: _reboot:
        !           214: 
        !           215:        movew   #0x2700, sr             | avoid interrupts
        !           216: 
        !           217:        movel   0x00, sp                | get sp after reboot
        !           218: 
        !           219:        movel   0x04, a6                | get new reboot address
        !           220: 
        !           221:        jmp     _reset
        !           222: 
        !           223: 
        !           224: 
        !           225: |
        !           226: 
        !           227: | routine for mouse packet handling
        !           228: 
        !           229: |
        !           230: 
        !           231:        .globl  _newmvec
        !           232: 
        !           233: _newmvec:
        !           234: 
        !           235:        movel   a0, sp@-
        !           236: 
        !           237:        jsr     _mouse_handler
        !           238: 
        !           239:        movel   sp@+, a0
        !           240: 
        !           241:        rts
        !           242: 
        !           243: 
        !           244: 
        !           245: |
        !           246: 
        !           247: | new ikbd keyboard interrupt vector
        !           248: 
        !           249: | kintr is a global variable that should be non-zero if a keyboard
        !           250: 
        !           251: | event occured
        !           252: 
        !           253: |
        !           254: 
        !           255:        .globl  _new_ikbd
        !           256: 
        !           257: _new_ikbd:
        !           258: 
        !           259:        movew   #1, _kintr
        !           260: 
        !           261:        movel   _old_ikbd+8, sp@-
        !           262: 
        !           263:        rts                     | jump to system interrupt routine
        !           264: 
        !           265: 
        !           266: 
        !           267: |
        !           268: 
        !           269: | simple signal handlers
        !           270: 
        !           271: | global variables referenced:
        !           272: 
        !           273: | in_kernel: (main.c): flag to indicate that we're in the MiNT kernel
        !           274: 
        !           275: | sig_routine: (signal.c): pointer to which signal catching routine to
        !           276: 
        !           277: |          call (e.g. for SIGBUS, or whatever)
        !           278: 
        !           279: |
        !           280: 
        !           281:        .globl  _new_bus, _new_addr, _new_ill, _new_divzero, _new_priv
        !           282: 
        !           283:        .globl  _new_trace
        !           284: 
        !           285:        .globl  _in_kernel, _sig_routine
        !           286: 
        !           287: _new_bus:
        !           288: 
        !           289:        movel   #_sigbus, _sig_routine
        !           290: 
        !           291: Do_sig:
        !           292: 
        !           293:        tstw    _in_kernel              | are we already in the kernel?
        !           294: 
        !           295:        bne     Kernel                  | yes
        !           296: 
        !           297:        movel   _curproc, sp@-
        !           298: 
        !           299:        addl    #4, sp@                 | push offset of save area
        !           300: 
        !           301:        jsr     _build_context
        !           302: 
        !           303:        movel   _curproc, a4
        !           304: 
        !           305:        movel   a4@, sp                 | put us in the system stack
        !           306: 
        !           307:        jsr     _enter_kernel           | set up kernel vectors
        !           308: 
        !           309:        movel   _sig_routine, a1        | get signal handling routine
        !           310: 
        !           311:        jsr     a1@                     | go do it
        !           312: 
        !           313:        oriw    #0x0700, sr             | spl7()
        !           314: 
        !           315:        jsr     _leave_kernel           | leave kernel
        !           316: 
        !           317:        lea     a4@(4), a4              | get context save area address
        !           318: 
        !           319:        movel   a4, sp@-                | push it
        !           320: 
        !           321:        jsr     _restore_context        | restore the context
        !           322: 
        !           323: |
        !           324: 
        !           325: | here's what we do if we already were in the kernel
        !           326: 
        !           327: |
        !           328: 
        !           329: Kernel:
        !           330: 
        !           331:        moveml  d0-d2/a0-a2, sp@-       | save reggies
        !           332: 
        !           333:        movel   _sig_routine, a1        | get handler
        !           334: 
        !           335:        jsr     a1@                     | go do it
        !           336: 
        !           337:        moveml  sp@+, d0-d2/a0-a2
        !           338: 
        !           339:        rte     
        !           340: 
        !           341: _new_addr:
        !           342: 
        !           343:        movel   #_sigaddr, _sig_routine
        !           344: 
        !           345:        bra     Do_sig
        !           346: 
        !           347: _new_ill:
        !           348: 
        !           349:        movel   #_sigill, _sig_routine
        !           350: 
        !           351:        bra     Do_sig
        !           352: 
        !           353: _new_divzero:
        !           354: 
        !           355:        movel   #_sigfpe, _sig_routine
        !           356: 
        !           357:        bra     Do_sig
        !           358: 
        !           359: _new_priv:
        !           360: 
        !           361:        movel   #_sigpriv, _sig_routine
        !           362: 
        !           363:        bra     Do_sig
        !           364: 
        !           365: _new_trace:
        !           366: 
        !           367:        movel   #_sigtrap, _sig_routine
        !           368: 
        !           369:        bra     Do_sig
        !           370: 
        !           371: 
        !           372: 
        !           373: |
        !           374: 
        !           375: | BIOS disk vectors for pseudo-disks like U: and X:; these are present
        !           376: 
        !           377: | just in case some program (foolishly) attempts to access these drives
        !           378: 
        !           379: | directly and gets horribly confused
        !           380: 
        !           381: |
        !           382: 
        !           383:        .globl  _old_getbpb     | old Getbpb vector
        !           384: 
        !           385:        .globl  _old_mediach    | old Mediach vector
        !           386: 
        !           387:        .globl  _old_rwabs      | old Rwabs vector
        !           388: 
        !           389: 
        !           390: 
        !           391:        .globl  _new_getbpb
        !           392: 
        !           393: _new_getbpb:
        !           394: 
        !           395:        movew   sp@(4), d0      | check the drive
        !           396: 
        !           397:        cmpw    #0x10, d0       | drive Q:?
        !           398: 
        !           399:        beq     nobpb           | yes, no BPB available
        !           400: 
        !           401:        cmpw    #0x14, d0       | drive U:?
        !           402: 
        !           403:        beq     nobpb           | yes, no BPB available
        !           404: 
        !           405:        cmpw    #0x15, d0       | drive V:?
        !           406: 
        !           407:        beq     nobpb
        !           408: 
        !           409:        cmpw    #0x17, d0       | drive X:?
        !           410: 
        !           411:        beq     nobpb
        !           412: 
        !           413:        movel   _old_getbpb+8, a0       | not our drive
        !           414: 
        !           415:        jmp     a0@             | call the old vector for it
        !           416: 
        !           417: nobpb:
        !           418: 
        !           419:        moveql  #0, d0          | 0 means "no BPB read"
        !           420: 
        !           421:        rts
        !           422: 
        !           423: 
        !           424: 
        !           425:        .globl  _new_mediach
        !           426: 
        !           427: _new_mediach:
        !           428: 
        !           429:        movew   sp@(4), d0      | check the drive
        !           430: 
        !           431:        cmpw    #0x10, d0       | drive Q:?
        !           432: 
        !           433:        beq     nochng          | yes, no change
        !           434: 
        !           435:        cmpw    #0x14, d0       | drive U:?
        !           436: 
        !           437:        beq     nochng          | yes, no change
        !           438: 
        !           439:        cmpw    #0x15, d0       | drive V:?
        !           440: 
        !           441:        beq     nochng
        !           442: 
        !           443:        cmpw    #0x17, d0       | drive X:?
        !           444: 
        !           445:        beq     nochng
        !           446: 
        !           447:        movel   _old_mediach+8, a0      | not our drive
        !           448: 
        !           449:        jmp     a0@             | call the old vector for it
        !           450: 
        !           451: nochng:
        !           452: 
        !           453:        moveql  #0, d0          | 0 means "definitely no change"
        !           454: 
        !           455:        rts
        !           456: 
        !           457: 
        !           458: 
        !           459:        .globl  _new_rwabs
        !           460: 
        !           461: _new_rwabs:
        !           462: 
        !           463:        movew   sp@(0xe), d0    | check the drive
        !           464: 
        !           465:        cmpw    #0x10, d0       | drive Q:?
        !           466: 
        !           467:        beq     rwdone          | yes, fake a successful I/O operation
        !           468: 
        !           469:        cmpw    #0x14, d0       | drive U:?
        !           470: 
        !           471:        beq     rwdone          | yes, fake it
        !           472: 
        !           473:        cmpw    #0x15, d0       | drive V:?
        !           474: 
        !           475:        beq     rwdone
        !           476: 
        !           477:        cmpw    #0x17, d0       | drive X:?
        !           478: 
        !           479:        beq     rwdone
        !           480: 
        !           481:        movel   _old_rwabs+8, a0 | not our drive
        !           482: 
        !           483:        jmp     a0@             | call the old vector for it
        !           484: 
        !           485: rwdone:
        !           486: 
        !           487:        moveql  #0, d0          | 0 means "successful operation"
        !           488: 
        !           489:        rts
        !           490: 

unix.superglobalmegacorp.com

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