xref: /titanic_50/usr/src/uts/sun4v/cpu/niagara_asm.s (revision c56c1e58d46678af913f4c68f2ef9dcacb5f282f)
17c478bd9Sstevel@tonic-gate/*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*c56c1e58Sgirish * Common Development and Distribution License (the "License").
6*c56c1e58Sgirish * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate/*
22*c56c1e58Sgirish * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate#if !defined(lint)
297c478bd9Sstevel@tonic-gate#include "assym.h"
307c478bd9Sstevel@tonic-gate#endif
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate/*
337c478bd9Sstevel@tonic-gate * Niagara processor specific assembly routines
347c478bd9Sstevel@tonic-gate */
357c478bd9Sstevel@tonic-gate
367c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h>
377c478bd9Sstevel@tonic-gate#include <sys/machasi.h>
387c478bd9Sstevel@tonic-gate#include <sys/machparam.h>
397c478bd9Sstevel@tonic-gate#include <sys/hypervisor_api.h>
407c478bd9Sstevel@tonic-gate#include <sys/niagararegs.h>
417c478bd9Sstevel@tonic-gate#include <sys/machasi.h>
427c478bd9Sstevel@tonic-gate#include <sys/niagaraasi.h>
437c478bd9Sstevel@tonic-gate#include <vm/hat_sfmmu.h>
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gate#if defined(lint)
467c478bd9Sstevel@tonic-gate/*ARGSUSED*/
477c478bd9Sstevel@tonic-gateuint64_t
487c478bd9Sstevel@tonic-gatehv_niagara_getperf(uint64_t perfreg, uint64_t *datap)
497c478bd9Sstevel@tonic-gate{ return (0); }
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate/*ARGSUSED*/
527c478bd9Sstevel@tonic-gateuint64_t
537c478bd9Sstevel@tonic-gatehv_niagara_setperf(uint64_t perfreg, uint64_t data)
547c478bd9Sstevel@tonic-gate{ return (0); }
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gate#else   /* lint */
577c478bd9Sstevel@tonic-gate
587c478bd9Sstevel@tonic-gate	/*
597c478bd9Sstevel@tonic-gate	 * hv_niagara_getperf(uint64_t perfreg, uint64_t *datap)
607c478bd9Sstevel@tonic-gate	 */
617c478bd9Sstevel@tonic-gate	ENTRY(hv_niagara_getperf)
627c478bd9Sstevel@tonic-gate	mov	%o1, %o4			! save datap
637c478bd9Sstevel@tonic-gate	mov	HV_NIAGARA_GETPERF, %o5
647c478bd9Sstevel@tonic-gate	ta	FAST_TRAP
657c478bd9Sstevel@tonic-gate	brz,a	%o0, 1f
667c478bd9Sstevel@tonic-gate	stx	%o1, [%o4]
677c478bd9Sstevel@tonic-gate1:
687c478bd9Sstevel@tonic-gate	retl
697c478bd9Sstevel@tonic-gate	nop
707c478bd9Sstevel@tonic-gate	SET_SIZE(hv_niagara_getperf)
717c478bd9Sstevel@tonic-gate
727c478bd9Sstevel@tonic-gate	/*
737c478bd9Sstevel@tonic-gate	 * hv_niagara_setperf(uint64_t perfreg, uint64_t data)
747c478bd9Sstevel@tonic-gate	 */
757c478bd9Sstevel@tonic-gate	ENTRY(hv_niagara_setperf)
767c478bd9Sstevel@tonic-gate	mov	HV_NIAGARA_SETPERF, %o5
777c478bd9Sstevel@tonic-gate	ta	FAST_TRAP
787c478bd9Sstevel@tonic-gate	retl
797c478bd9Sstevel@tonic-gate	nop
807c478bd9Sstevel@tonic-gate	SET_SIZE(hv_niagara_setperf)
817c478bd9Sstevel@tonic-gate
827c478bd9Sstevel@tonic-gate#endif /* !lint */
837c478bd9Sstevel@tonic-gate
847c478bd9Sstevel@tonic-gate#if defined (lint)
857c478bd9Sstevel@tonic-gate/*
867c478bd9Sstevel@tonic-gate * Invalidate all of the entries within the TSB, by setting the inv bit
877c478bd9Sstevel@tonic-gate * in the tte_tag field of each tsbe.
887c478bd9Sstevel@tonic-gate *
897c478bd9Sstevel@tonic-gate * We take advantage of the fact that the TSBs are page aligned and a
907c478bd9Sstevel@tonic-gate * multiple of PAGESIZE to use ASI_BLK_INIT_xxx ASI.
917c478bd9Sstevel@tonic-gate *
927c478bd9Sstevel@tonic-gate * See TSB_LOCK_ENTRY and the miss handlers for how this works in practice
937c478bd9Sstevel@tonic-gate * (in short, we set all bits in the upper word of the tag, and we give the
947c478bd9Sstevel@tonic-gate * invalid bit precedence over other tag bits in both places).
957c478bd9Sstevel@tonic-gate */
967c478bd9Sstevel@tonic-gate/*ARGSUSED*/
977c478bd9Sstevel@tonic-gatevoid
987c478bd9Sstevel@tonic-gatecpu_inv_tsb(caddr_t tsb_base, uint_t tsb_bytes)
997c478bd9Sstevel@tonic-gate{}
1007c478bd9Sstevel@tonic-gate
1017c478bd9Sstevel@tonic-gate#else /* lint */
1027c478bd9Sstevel@tonic-gate
1037c478bd9Sstevel@tonic-gate	ENTRY(cpu_inv_tsb)
1047c478bd9Sstevel@tonic-gate
1057c478bd9Sstevel@tonic-gate	/*
1067c478bd9Sstevel@tonic-gate	 * The following code assumes that the tsb_base (%o0) is 256 bytes
1077c478bd9Sstevel@tonic-gate	 * aligned and the tsb_bytes count is multiple of 256 bytes.
1087c478bd9Sstevel@tonic-gate	 */
1097c478bd9Sstevel@tonic-gate
1107c478bd9Sstevel@tonic-gate	wr	%g0, ASI_BLK_INIT_ST_QUAD_LDD_P, %asi
1117c478bd9Sstevel@tonic-gate	set	TSBTAG_INVALID, %o2
1127c478bd9Sstevel@tonic-gate	sllx	%o2, 32, %o2		! INV bit in upper 32 bits of the tag
1137c478bd9Sstevel@tonic-gate1:
1147c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0x0]%asi
1157c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0x40]%asi
1167c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0x80]%asi
1177c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0xc0]%asi
1187c478bd9Sstevel@tonic-gate
1197c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0x10]%asi
1207c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0x20]%asi
1217c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0x30]%asi
1227c478bd9Sstevel@tonic-gate
1237c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0x50]%asi
1247c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0x60]%asi
1257c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0x70]%asi
1267c478bd9Sstevel@tonic-gate
1277c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0x90]%asi
1287c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0xa0]%asi
1297c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0xb0]%asi
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0xd0]%asi
1327c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0xe0]%asi
1337c478bd9Sstevel@tonic-gate	stxa	%o2, [%o0+0xf0]%asi
1347c478bd9Sstevel@tonic-gate
1357c478bd9Sstevel@tonic-gate	subcc	%o1, 0x100, %o1
1367c478bd9Sstevel@tonic-gate	bgu,pt	%ncc, 1b
1377c478bd9Sstevel@tonic-gate	add	%o0, 0x100, %o0
1387c478bd9Sstevel@tonic-gate
1397c478bd9Sstevel@tonic-gate	membar	#Sync
1407c478bd9Sstevel@tonic-gate	retl
1417c478bd9Sstevel@tonic-gate	nop
1427c478bd9Sstevel@tonic-gate
1437c478bd9Sstevel@tonic-gate	SET_SIZE(cpu_inv_tsb)
1447c478bd9Sstevel@tonic-gate#endif /* lint */
1457c478bd9Sstevel@tonic-gate
146ce0352ebSgirish#if defined(lint)
147ce0352ebSgirish/*ARGSUSED*/
148ce0352ebSgirishuint64_t
149ce0352ebSgirishhv_niagara_mmustat_conf(uint64_t buf, uint64_t *prev_buf)
150ce0352ebSgirish{ return (0); }
151ce0352ebSgirish
152ce0352ebSgirish/*ARGSUSED*/
153ce0352ebSgirishuint64_t
154ce0352ebSgirishhv_niagara_mmustat_info(uint64_t *buf)
155ce0352ebSgirish{ return (0); }
156ce0352ebSgirish
157ce0352ebSgirish#else   /* lint */
158ce0352ebSgirish
159ce0352ebSgirish	/*
160ce0352ebSgirish	 * hv_niagara_mmustat_conf(uint64_t buf, uint64_t *prev_buf)
161ce0352ebSgirish	 */
162ce0352ebSgirish	ENTRY(hv_niagara_mmustat_conf)
163ce0352ebSgirish	mov	%o1, %o4			! save prev_buf
164ce0352ebSgirish	mov	HV_NIAGARA_MMUSTAT_CONF, %o5
165ce0352ebSgirish	ta	FAST_TRAP
166ce0352ebSgirish	retl
167ce0352ebSgirish	stx	%o1, [%o4]
168ce0352ebSgirish	SET_SIZE(hv_niagara_mmustat_conf)
169ce0352ebSgirish
170ce0352ebSgirish	/*
171ce0352ebSgirish	 * hv_niagara_mmustat_info(uint64_t *buf)
172ce0352ebSgirish	 */
173ce0352ebSgirish	ENTRY(hv_niagara_mmustat_info)
174ce0352ebSgirish	mov	%o0, %o4			! save buf
175ce0352ebSgirish	mov	HV_NIAGARA_MMUSTAT_INFO, %o5
176ce0352ebSgirish	ta	FAST_TRAP
177ce0352ebSgirish	retl
178ce0352ebSgirish	stx	%o1, [%o4]
179ce0352ebSgirish	SET_SIZE(hv_niagara_mmustat_info)
180ce0352ebSgirish
181ce0352ebSgirish#endif /* !lint */
182