xref: /illumos-gate/usr/src/uts/sun4v/cpu/niagara_asm.S (revision 5d9d9091f564c198a760790b0bfa72c44e17912b)
1*5d9d9091SRichard Lowe/*
2*5d9d9091SRichard Lowe * CDDL HEADER START
3*5d9d9091SRichard Lowe *
4*5d9d9091SRichard Lowe * The contents of this file are subject to the terms of the
5*5d9d9091SRichard Lowe * Common Development and Distribution License (the "License").
6*5d9d9091SRichard Lowe * You may not use this file except in compliance with the License.
7*5d9d9091SRichard Lowe *
8*5d9d9091SRichard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*5d9d9091SRichard Lowe * or http://www.opensolaris.org/os/licensing.
10*5d9d9091SRichard Lowe * See the License for the specific language governing permissions
11*5d9d9091SRichard Lowe * and limitations under the License.
12*5d9d9091SRichard Lowe *
13*5d9d9091SRichard Lowe * When distributing Covered Code, include this CDDL HEADER in each
14*5d9d9091SRichard Lowe * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*5d9d9091SRichard Lowe * If applicable, add the following below this CDDL HEADER, with the
16*5d9d9091SRichard Lowe * fields enclosed by brackets "[]" replaced with your own identifying
17*5d9d9091SRichard Lowe * information: Portions Copyright [yyyy] [name of copyright owner]
18*5d9d9091SRichard Lowe *
19*5d9d9091SRichard Lowe * CDDL HEADER END
20*5d9d9091SRichard Lowe */
21*5d9d9091SRichard Lowe/*
22*5d9d9091SRichard Lowe * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*5d9d9091SRichard Lowe * Use is subject to license terms.
24*5d9d9091SRichard Lowe */
25*5d9d9091SRichard Lowe
26*5d9d9091SRichard Lowe#include "assym.h"
27*5d9d9091SRichard Lowe
28*5d9d9091SRichard Lowe/*
29*5d9d9091SRichard Lowe * Niagara processor specific assembly routines
30*5d9d9091SRichard Lowe */
31*5d9d9091SRichard Lowe
32*5d9d9091SRichard Lowe#include <sys/asm_linkage.h>
33*5d9d9091SRichard Lowe#include <sys/machasi.h>
34*5d9d9091SRichard Lowe#include <sys/machparam.h>
35*5d9d9091SRichard Lowe#include <sys/hypervisor_api.h>
36*5d9d9091SRichard Lowe#include <sys/niagararegs.h>
37*5d9d9091SRichard Lowe#include <sys/machasi.h>
38*5d9d9091SRichard Lowe#include <sys/niagaraasi.h>
39*5d9d9091SRichard Lowe#include <vm/hat_sfmmu.h>
40*5d9d9091SRichard Lowe
41*5d9d9091SRichard Lowe	/*
42*5d9d9091SRichard Lowe	 * hv_niagara_getperf(uint64_t perfreg, uint64_t *datap)
43*5d9d9091SRichard Lowe	 */
44*5d9d9091SRichard Lowe	ENTRY(hv_niagara_getperf)
45*5d9d9091SRichard Lowe	mov	%o1, %o4			! save datap
46*5d9d9091SRichard Lowe	mov	HV_NIAGARA_GETPERF, %o5
47*5d9d9091SRichard Lowe	ta	FAST_TRAP
48*5d9d9091SRichard Lowe	brz,a	%o0, 1f
49*5d9d9091SRichard Lowe	stx	%o1, [%o4]
50*5d9d9091SRichard Lowe1:
51*5d9d9091SRichard Lowe	retl
52*5d9d9091SRichard Lowe	nop
53*5d9d9091SRichard Lowe	SET_SIZE(hv_niagara_getperf)
54*5d9d9091SRichard Lowe
55*5d9d9091SRichard Lowe	/*
56*5d9d9091SRichard Lowe	 * hv_niagara_setperf(uint64_t perfreg, uint64_t data)
57*5d9d9091SRichard Lowe	 */
58*5d9d9091SRichard Lowe	ENTRY(hv_niagara_setperf)
59*5d9d9091SRichard Lowe	mov	HV_NIAGARA_SETPERF, %o5
60*5d9d9091SRichard Lowe	ta	FAST_TRAP
61*5d9d9091SRichard Lowe	retl
62*5d9d9091SRichard Lowe	nop
63*5d9d9091SRichard Lowe	SET_SIZE(hv_niagara_setperf)
64*5d9d9091SRichard Lowe
65*5d9d9091SRichard Lowe/*
66*5d9d9091SRichard Lowe * Invalidate all of the entries within the TSB, by setting the inv bit
67*5d9d9091SRichard Lowe * in the tte_tag field of each tsbe.
68*5d9d9091SRichard Lowe *
69*5d9d9091SRichard Lowe * We take advantage of the fact that the TSBs are page aligned and a
70*5d9d9091SRichard Lowe * multiple of PAGESIZE to use ASI_BLK_INIT_xxx ASI.
71*5d9d9091SRichard Lowe *
72*5d9d9091SRichard Lowe * See TSB_LOCK_ENTRY and the miss handlers for how this works in practice
73*5d9d9091SRichard Lowe * (in short, we set all bits in the upper word of the tag, and we give the
74*5d9d9091SRichard Lowe * invalid bit precedence over other tag bits in both places).
75*5d9d9091SRichard Lowe */
76*5d9d9091SRichard Lowe	ENTRY(cpu_inv_tsb)
77*5d9d9091SRichard Lowe
78*5d9d9091SRichard Lowe	/*
79*5d9d9091SRichard Lowe	 * The following code assumes that the tsb_base (%o0) is 256 bytes
80*5d9d9091SRichard Lowe	 * aligned and the tsb_bytes count is multiple of 256 bytes.
81*5d9d9091SRichard Lowe	 */
82*5d9d9091SRichard Lowe
83*5d9d9091SRichard Lowe	wr	%g0, ASI_BLK_INIT_ST_QUAD_LDD_P, %asi
84*5d9d9091SRichard Lowe	set	TSBTAG_INVALID, %o2
85*5d9d9091SRichard Lowe	sllx	%o2, 32, %o2		! INV bit in upper 32 bits of the tag
86*5d9d9091SRichard Lowe1:
87*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0x0]%asi
88*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0x40]%asi
89*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0x80]%asi
90*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0xc0]%asi
91*5d9d9091SRichard Lowe
92*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0x10]%asi
93*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0x20]%asi
94*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0x30]%asi
95*5d9d9091SRichard Lowe
96*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0x50]%asi
97*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0x60]%asi
98*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0x70]%asi
99*5d9d9091SRichard Lowe
100*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0x90]%asi
101*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0xa0]%asi
102*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0xb0]%asi
103*5d9d9091SRichard Lowe
104*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0xd0]%asi
105*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0xe0]%asi
106*5d9d9091SRichard Lowe	stxa	%o2, [%o0+0xf0]%asi
107*5d9d9091SRichard Lowe
108*5d9d9091SRichard Lowe	subcc	%o1, 0x100, %o1
109*5d9d9091SRichard Lowe	bgu,pt	%ncc, 1b
110*5d9d9091SRichard Lowe	add	%o0, 0x100, %o0
111*5d9d9091SRichard Lowe
112*5d9d9091SRichard Lowe	membar	#Sync
113*5d9d9091SRichard Lowe	retl
114*5d9d9091SRichard Lowe	nop
115*5d9d9091SRichard Lowe
116*5d9d9091SRichard Lowe	SET_SIZE(cpu_inv_tsb)
117*5d9d9091SRichard Lowe
118*5d9d9091SRichard Lowe	/*
119*5d9d9091SRichard Lowe	 * hv_niagara_mmustat_conf(uint64_t buf, uint64_t *prev_buf)
120*5d9d9091SRichard Lowe	 */
121*5d9d9091SRichard Lowe	ENTRY(hv_niagara_mmustat_conf)
122*5d9d9091SRichard Lowe	mov	%o1, %o4			! save prev_buf
123*5d9d9091SRichard Lowe	mov	HV_NIAGARA_MMUSTAT_CONF, %o5
124*5d9d9091SRichard Lowe	ta	FAST_TRAP
125*5d9d9091SRichard Lowe	retl
126*5d9d9091SRichard Lowe	stx	%o1, [%o4]
127*5d9d9091SRichard Lowe	SET_SIZE(hv_niagara_mmustat_conf)
128*5d9d9091SRichard Lowe
129*5d9d9091SRichard Lowe	/*
130*5d9d9091SRichard Lowe	 * hv_niagara_mmustat_info(uint64_t *buf)
131*5d9d9091SRichard Lowe	 */
132*5d9d9091SRichard Lowe	ENTRY(hv_niagara_mmustat_info)
133*5d9d9091SRichard Lowe	mov	%o0, %o4			! save buf
134*5d9d9091SRichard Lowe	mov	HV_NIAGARA_MMUSTAT_INFO, %o5
135*5d9d9091SRichard Lowe	ta	FAST_TRAP
136*5d9d9091SRichard Lowe	retl
137*5d9d9091SRichard Lowe	stx	%o1, [%o4]
138*5d9d9091SRichard Lowe	SET_SIZE(hv_niagara_mmustat_info)
139*5d9d9091SRichard Lowe
140