1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 1998 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #include <sys/param.h>
  28 #include <sys/errno.h>
  29 #include <sys/asm_linkage.h>
  30 #include <sys/vtrace.h>
  31 #include <sys/machthread.h>
  32 #include <sys/clock.h>
  33 #include <sys/asi.h>
  34 #include <sys/fsr.h>
  35 #include <sys/privregs.h>
  36 #include <sys/pte.h>
  37 #include <sys/mmu.h>
  38 #include <sys/spitregs.h>
  39 
  40 #include "assym.h"
  41 
  42 #define TT_HSM  0x99
  43 
  44 !
  45 ! Move a single cache line of data.  Survive UE and CE on the read
  46 !
  47 ! i0 = src va
  48 ! i1 = dst va
  49 ! i2 = line count
  50 ! i3 = line size
  51 ! i4 = cache of fpu state
  52 !
  53         ENTRY(ac_blkcopy)
  54 
  55         ! TODO: can we safely SAVE here
  56         save    %sp, -SA(MINFRAME + 2*64), %sp
  57 
  58         ! XXX do we need to save the state of the fpu?
  59         rd      %fprs, %i4
  60         btst    (FPRS_DU|FPRS_DL|FPRS_FEF), %i4
  61 
  62         ! always enable FPU
  63         wr      %g0, FPRS_FEF, %fprs
  64 
  65         bz,a    1f
  66          nop
  67 
  68         ! save in-use fpregs on stack
  69         membar  #Sync
  70         add     %fp, STACK_BIAS - 81, %o2
  71         and     %o2, -64, %o2
  72         stda    %d0, [%o2]ASI_BLK_P
  73         membar  #Sync
  74 
  75 1:
  76         brz,pn  %i2, 2f                         ! while (linecount) {
  77          nop
  78         ldda    [%i0]ASI_BLK_P, %d0             ! *dst = *src;
  79         membar  #Sync
  80         stda    %d0, [%i1]ASI_BLK_COMMIT_P
  81         membar  #Sync
  82 
  83         add     %i0, %i3, %i0                   ! dst++, src++;
  84         add     %i1, %i3, %i1
  85 
  86         ba      1b                              ! linecount-- }
  87          dec    %i2
  88 
  89 2:
  90         membar  #Sync
  91 
  92         ! restore fp to the way we got it
  93         btst    (FPRS_DU|FPRS_DL|FPRS_FEF), %i4
  94         bz,a    3f
  95          nop
  96 
  97         ! restore fpregs from stack
  98         add     %fp, STACK_BIAS - 81, %o2
  99         and     %o2, -64, %o2
 100         ldda    [%o2]ASI_BLK_P, %d0
 101         membar  #Sync
 102 
 103 3:
 104         wr      %g0, %i4, %fprs                 ! fpu back to the way it was
 105         ret
 106          restore
 107         SET_SIZE(ac_blkcopy)