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