home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / config / m68k-native / cacheclearu.s < prev    next >
Encoding:
Text File  |  1997-01-22  |  2.9 KB  |  116 lines

  1. /*
  2.      (C) 1995-96 AROS - The Amiga Replacement OS
  3.      $Id: cacheclearu.s,v 1.8 1997/01/22 02:42:33 ldp Exp $
  4.  
  5.      Desc:
  6.      Lang:
  7. */
  8.  
  9. /*****************************************************************************
  10.  
  11.     NAME
  12.  
  13.      AROS_LH0(void, CacheClearU,
  14.  
  15.     LOCATION
  16.      struct ExecBase *, SysBase, 106, Exec)
  17.  
  18.     FUNCTION
  19.      Flushes the contents of all CPU caches in a simple way.
  20.  
  21.     INPUTS
  22.  
  23.     RESULT
  24.  
  25.     NOTES
  26.  
  27.     EXAMPLE
  28.  
  29.     BUGS
  30.  
  31.     SEE ALSO
  32.  
  33.     INTERNALS
  34.     68000/10: do nothing
  35.     68020/30: clear instruction cache and (030) data cache
  36.     68040/60: push dirty lines to memory and invalidate both caches
  37.  
  38.     HISTORY
  39.  
  40. ******************************************************************************/
  41.  
  42.  
  43. /*
  44.    XDEF AROS_SLIB_ENTRY(CacheClearU,Exec)       ; for 68000/68010
  45.    XDEF AROS_SLIB_ENTRY(CacheClearU_20,Exec)    ; for 68020/68030
  46.    XDEF AROS_SLIB_ENTRY(CacheClearU_40,Exec)    ; for 68040/68060
  47.    XDEF AROS_SLIB_ENTRY(CacheClearU_60,Exec)    ; for 68060 (clears not only
  48.                         ; the i and d caches, but also
  49.                         ; the branch cache)
  50. */
  51.  
  52.     #include "machine.i"
  53.  
  54.     .text
  55.     .balign 16
  56.     .globl    AROS_SLIB_ENTRY(CacheClearU,Exec)
  57.     .type    AROS_SLIB_ENTRY(CacheClearU,Exec),@function
  58. AROS_SLIB_ENTRY(CacheClearU,Exec):
  59.     /* Simple 68000s have no chaches */
  60.     rts
  61.  
  62.     .text
  63.     .balign 16
  64.     .globl    AROS_SLIB_ENTRY(CacheClearU_20,Exec)
  65.     .type    AROS_SLIB_ENTRY(CacheClearU_20,Exec),@function
  66. AROS_SLIB_ENTRY(CacheClearU_20,Exec):
  67.     move.l    a5,a1        /* Save a5 */
  68.     lea.l    cacheclearusup_20(pc),a5
  69.     jmp    Supervisor(a6)    /* No jsr: this saves an rts */
  70.  
  71. cacheclearusup_20:
  72.     or.w    #0x0700,sr    /* Disable interrupts so cacr can not be influenced
  73.                    while we clear the caches */
  74.     movec    cacr,d0
  75.     or.w    #0x0808,d0    /* Set CD and CI bit in cacr */
  76.     movec    d0,cacr
  77.     move.l    a1,a5        /* Restore a5 */
  78.     rte            /* This rte will restore the SR from the stack */
  79.  
  80.     .text
  81.     .balign 16
  82.     .globl    AROS_SLIB_ENTRY(CacheClearU_40,Exec)
  83.     .type    AROS_SLIB_ENTRY(CacheClearU_40,Exec),@function
  84. AROS_SLIB_ENTRY(CacheClearU_40,Exec):
  85.     move.l    a5,a1
  86.     lea.l    cacheclearusup_40(pc),a5
  87.     jmp    Supervisor(a6)
  88.  
  89. cacheclearusup_40:
  90.     cpusha    bc    /* Push dirty cache lines to memory and invalidate both caches */
  91.     cinva    bc    /* 68060 invalidates depending on DPI (Disable CPUSH invalidation)
  92.                bit of CACR. Force an invalidation with CINV. */
  93.     move.l    a1,a5
  94.     rte
  95.  
  96.     .text
  97.     .balign 16
  98.     .globl    AROS_SLIB_ENTRY(CacheClearU_60,Exec)
  99.     .type    AROS_SLIB_ENTRY(CacheClearU_60,Exec),@function
  100. AROS_SLIB_ENTRY(CacheClearU_60,Exec):
  101.     move.l    a5,a1
  102.     lea.l    cacheclearusup_60(pc),a5
  103.     jmp    Supervisor(a6)
  104.  
  105. cacheclearusup_60:
  106.     cpusha    bc    /* Push dirty cache lines to memory and invalidate both caches */
  107.     cinva    bc    /* 68060 invalidates depending on DPI (Disable CPUSH invalidation)
  108.                bit of CACR. Force an invalidation with CINV. */
  109.     or.w    #0x0700,sr
  110.     movec    cacr,d0
  111.     bset.l    #20,d0        /* set CABC Clear All (entries in) Branch Cache bit */
  112.     movec    d0,cacr        /* clear Branch Cache */
  113.     move.l    a1,a5
  114.     rte
  115.  
  116.