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

1.1       root        1: ;
                      2: 
1.1.1.3 ! root        3: ; CPU tricks (mostly having to do with the MMU)
1.1       root        4: 
                      5: ;
                      6: 
1.1.1.3 ! root        7: ;
        !             8: 
        !             9: ; set_mmu(crp,tc): called once, the first time a page table is built, to 
        !            10: 
        !            11: ; switch away from the MMU setup that came from the ROM and into the setup 
        !            12: 
        !            13: ; that we just built.  The CRP is actually on the stack, and it's 8 bytes.
        !            14: 
        !            15: ; The TC is four bytes at sp@(0xc).  "Nulls" is here because we need to
        !            16: 
        !            17: ; shove zeros into a few places.
        !            18: 
        !            19: ;
        !            20: 
        !            21:        DATA
        !            22: 
        !            23: nulltc:        dc.l    0
        !            24: 
        !            25: 
        !            26: 
        !            27:        TEXT
        !            28: 
        !            29:        XDEF    _set_mmu
        !            30: 
        !            31: _set_mmu:
        !            32: 
        !            33:        pmove   (nulltc).l,tc           ; turn off mmu
        !            34: 
        !            35:        dc.l    $f0390800,nulltc        ; pmove nulltc,tt0
        !            36: 
        !            37:        dc.l    $f0390c00,nulltc        ; pmove nulltc,tt1
        !            38: 
        !            39:        pmove   4(sp),crp               ; caution: crp is 8 bytes
        !            40: 
        !            41:        pmove   $c(sp),tc
        !            42: 
        !            43:        rts
        !            44: 
        !            45: ;
        !            46: 
        !            47: ; save_mmu, restr_mmu: save and restore the MMU setup that came from ROM
        !            48: 
        !            49: ;
        !            50: 
        !            51:        DATA
        !            52: 
        !            53: oldcrp:        dc.l    0
        !            54: 
        !            55:        dc.l    0
        !            56: 
        !            57: oldtc: dc.l    0
        !            58: 
        !            59: oldtt0:        dc.l    0
        !            60: 
        !            61: oldtt1:        dc.l    0
        !            62: 
        !            63: 
        !            64: 
1.1       root       65:        TEXT
                     66: 
1.1.1.3 ! root       67:        XDEF    _save_mmu
        !            68: 
        !            69: _save_mmu:
        !            70: 
        !            71:        pmove   tc,oldtc
        !            72: 
        !            73:        dc.l    $f0390a00,oldtt0        ; pmove tt0,oldtt0
        !            74: 
        !            75:        dc.l    $f0390e00,oldtt1        ; pmove tt1,oldtt1
        !            76: 
        !            77:        pmove   crp,oldcrp
        !            78: 
        !            79:        rts
        !            80: 
        !            81: 
        !            82: 
        !            83:        XDEF    _restr_mmu
        !            84: 
        !            85: _restr_mmu:
        !            86: 
        !            87:        pmove   (nulltc).l,tc
        !            88: 
        !            89:        dc.l    $f0390800,oldtt0        ; pmove oldtt0,tt0
        !            90: 
        !            91:        dc.l    $f0390c00,oldtt1        ; pmove oldtt1,tt1
        !            92: 
        !            93:        pmove   oldcrp,crp
        !            94: 
        !            95:        pmove   oldtc,tc
        !            96: 
        !            97:        rts
        !            98: 
1.1       root       99: ;
                    100: 
                    101: ; Cache tricks
                    102: 
                    103: ;
                    104: 
                    105:        XDEF    _cpush
                    106: 
                    107:        XREF    _mcpu           ; in main.c
                    108: 
                    109: ;
                    110: 
                    111: ; cpush(void *base, long length):
                    112: 
                    113: ; flush both caches from base over a distance of length. If length is -1
                    114: 
                    115: ; then the entire cache is flushed
                    116: 
                    117: ;
                    118: 
                    119: _cpush:
                    120: 
                    121:        movem.l 4(a7),d0/a0     ; get parameters
                    122: 
                    123:        exg     a0,d0           ; and in the right order
                    124: 
                    125:        move.l  _mcpu,d1        ; start checking the CPU type
                    126: 
                    127:        cmp.l   #20,d1
                    128: 
                    129:        bcs.s   noc
                    130: 
                    131:        cmp.l   #40,d1
                    132: 
                    133:        bne.s   is030
                    134: 
                    135:        
                    136: 
                    137:        addq.l  #1,d0           ; if was -1
                    138: 
                    139:        beq.s   abc040          ; then flush everything
                    140: 
                    141:        add.l   #14,d0          ; round up to line boundary
                    142: 
                    143:        lsr.l   #4,d0           ; convert to number of lines
                    144: 
                    145:        cmp.l   #256,d0
                    146: 
                    147:        bcs.s   fls040          ; not too many lines, so dump only some
                    148: 
                    149: 
                    150: 
                    151: abc040:        dc.w    $F4F8           ; this is "cpusha bc" if your asm knows '040
                    152: 
                    153:        bra.s   noc
                    154: 
                    155:        
                    156: 
                    157: ; run through d0+1 times (since a0 may not be on a line boundary)
                    158: 
                    159: fls040:        moveq   #16,d1
                    160: 
                    161: do040: dc.w    $F4E8           ; this is "cpushl bc,(a0)" for the '040
                    162: 
                    163:        add.w   d1,a0
                    164: 
                    165:        dbf     d0,do040
                    166: 
                    167:        bra.s   noc
                    168: 
                    169: 
                    170: 
                    171: is030:
                    172: 
                    173:        movec   cacr,d1
                    174: 
                    175:        move.l  d1,-(a7)
                    176: 
                    177:        addq.l  #1,d0           ; if was -1
                    178: 
                    179:        beq.s   abc030          ; then flush everything
                    180: 
                    181:        addq.l  #2,d0           ; round up to long boundary
                    182: 
                    183:        lsr.l   #2,d0           ; convert to number of longs
                    184: 
                    185:        cmp.l   #64,d0
                    186: 
                    187:        bcs.s   fls030          ; dump selectively
                    188: 
                    189:        
                    190: 
                    191: abc030:        or.w    #$808,d1
                    192: 
                    193:        movec   d1,cacr
                    194: 
                    195:        bra.s   rescacr
                    196: 
                    197: 
                    198: 
                    199: fls030:        or.w    #$404,d1        ; clear DC/IC entries
                    200: 
                    201: ; run through d0+1 times (since a0 may not be on a long boundary)
                    202: 
                    203: do030: movec   a0,caar
                    204: 
                    205:        movec   d1,cacr
                    206: 
                    207:        addq.w  #4,a0
                    208: 
                    209:        dbf     d0,do030
                    210: 
                    211: rescacr:
                    212: 
                    213:        move.l  (a7)+,d0
                    214: 
                    215:        movec   d0,cacr
                    216: 
                    217: noc:   rts
                    218: 
                    219: 
                    220: 
1.1.1.2   root      221: ;
                    222: 
                    223: ; Set the stack pointer to a new value
                    224: 
                    225: ; Called when we're starting GEM from the exec_os vector
                    226: 
                    227: 
                    228: 
                    229:        XDEF    _setstack
                    230: 
                    231: _setstack:
                    232: 
                    233:        move.l  (sp)+,a0        ; pop return address
                    234: 
                    235:        move.l  (sp)+,sp        ; set stack pointer
                    236: 
                    237:        jmp     (a0)            ; return
                    238: 
                    239: 
                    240: 
1.1.1.3 ! root      241: ;
        !           242: 
        !           243: ; PMMU stuff
        !           244: 
        !           245: ;
        !           246: 
        !           247:        XDEF    _flush_pmmu
        !           248: 
        !           249: _flush_pmmu:
        !           250: 
        !           251:        pflusha
        !           252: 
        !           253:        rts
        !           254: 
1.1       root      255:        END
                    256: 

unix.superglobalmegacorp.com

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