home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mint104s.zoo / mint.src / cpu.spp < prev    next >
Text File  |  1993-03-08  |  2KB  |  77 lines

  1. ;
  2. ; CPU tricks (we should probably have spl7(), spl() & reboot() in here)
  3. ;
  4.     TEXT
  5. ;
  6. ; Cache tricks
  7. ;
  8.     XDEF    _cpush
  9.     XREF    _mcpu        ; in main.c
  10. ;
  11. ; cpush(void *base, long length):
  12. ; flush both caches from base over a distance of length. If length is -1
  13. ; then the entire cache is flushed
  14. ;
  15. _cpush:
  16.     movem.l    4(a7),d0/a0    ; get parameters
  17.     exg    a0,d0        ; and in the right order
  18.     move.l    _mcpu,d1    ; start checking the CPU type
  19.     cmp.l    #20,d1
  20.     bcs.s    noc
  21.     cmp.l    #40,d1
  22.     bne.s    is030
  23.     
  24.     addq.l    #1,d0        ; if was -1
  25.     beq.s    abc040        ; then flush everything
  26.     add.l    #14,d0        ; round up to line boundary
  27.     lsr.l    #4,d0        ; convert to number of lines
  28.     cmp.l    #256,d0
  29.     bcs.s    fls040        ; not too many lines, so dump only some
  30.  
  31. abc040:    dc.w    $F4F8        ; this is "cpusha bc" if your asm knows '040
  32.     bra.s    noc
  33.     
  34. ; run through d0+1 times (since a0 may not be on a line boundary)
  35. fls040:    moveq    #16,d1
  36. do040:    dc.w    $F4E8        ; this is "cpushl bc,(a0)" for the '040
  37.     add.w    d1,a0
  38.     dbf    d0,do040
  39.     bra.s    noc
  40.  
  41. is030:
  42.     movec    cacr,d1
  43.     move.l    d1,-(a7)
  44.     addq.l    #1,d0        ; if was -1
  45.     beq.s    abc030        ; then flush everything
  46.     addq.l    #2,d0        ; round up to long boundary
  47.     lsr.l    #2,d0        ; convert to number of longs
  48.     cmp.l    #64,d0
  49.     bcs.s    fls030        ; dump selectively
  50.     
  51. abc030:    or.w    #$808,d1
  52.     movec    d1,cacr
  53.     bra.s    rescacr
  54.  
  55. fls030:    or.w    #$404,d1    ; clear DC/IC entries
  56. ; run through d0+1 times (since a0 may not be on a long boundary)
  57. do030:    movec    a0,caar
  58.     movec    d1,cacr
  59.     addq.w    #4,a0
  60.     dbf    d0,do030
  61. rescacr:
  62.     move.l    (a7)+,d0
  63.     movec    d0,cacr
  64. noc:    rts
  65.  
  66. ;
  67. ; Set the stack pointer to a new value
  68. ; Called when we're starting GEM from the exec_os vector
  69.  
  70.     XDEF    _setstack
  71. _setstack:
  72.     move.l    (sp)+,a0    ; pop return address
  73.     move.l    (sp)+,sp    ; set stack pointer
  74.     jmp    (a0)        ; return
  75.  
  76.     END
  77.