xref: /titanic_51/usr/src/uts/sun4/ml/subr_asm.s (revision ae115bc77f6fcde83175c75b4206dc2e50747966)
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
57bafd143Sjb145095 * Common Development and Distribution License (the "License").
67bafd143Sjb145095 * 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*ae115bc7Smrj * Copyright 2007 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/*
297c478bd9Sstevel@tonic-gate * General machine architecture & implementation specific
307c478bd9Sstevel@tonic-gate * assembly language routines.
317c478bd9Sstevel@tonic-gate */
327c478bd9Sstevel@tonic-gate#if defined(lint)
337c478bd9Sstevel@tonic-gate#include <sys/types.h>
347c478bd9Sstevel@tonic-gate#include <sys/machsystm.h>
357c478bd9Sstevel@tonic-gate#include <sys/t_lock.h>
367c478bd9Sstevel@tonic-gate#else	/* lint */
377c478bd9Sstevel@tonic-gate#include "assym.h"
387c478bd9Sstevel@tonic-gate#endif	/* lint */
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h>
417c478bd9Sstevel@tonic-gate#include <sys/async.h>
427c478bd9Sstevel@tonic-gate#include <sys/machthread.h>
437bafd143Sjb145095#include <sys/vis.h>
447bafd143Sjb145095#include <sys/machsig.h>
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate#if defined(lint)
477c478bd9Sstevel@tonic-gatecaddr_t
487c478bd9Sstevel@tonic-gateset_trap_table(void)
497c478bd9Sstevel@tonic-gate{
507c478bd9Sstevel@tonic-gate	return ((caddr_t)0);
517c478bd9Sstevel@tonic-gate}
527c478bd9Sstevel@tonic-gate#else /* lint */
537c478bd9Sstevel@tonic-gate
547c478bd9Sstevel@tonic-gate	ENTRY(set_trap_table)
557c478bd9Sstevel@tonic-gate	set	trap_table, %o1
567c478bd9Sstevel@tonic-gate	rdpr	%tba, %o0
577c478bd9Sstevel@tonic-gate	wrpr	%o1, %tba
587c478bd9Sstevel@tonic-gate	retl
597c478bd9Sstevel@tonic-gate	wrpr	%g0, WSTATE_KERN, %wstate
607c478bd9Sstevel@tonic-gate	SET_SIZE(set_trap_table)
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gate#endif /* lint */
637c478bd9Sstevel@tonic-gate
647c478bd9Sstevel@tonic-gate#if defined(lint)
657c478bd9Sstevel@tonic-gate
667c478bd9Sstevel@tonic-gate/*ARGSUSED*/
677c478bd9Sstevel@tonic-gatevoid
687c478bd9Sstevel@tonic-gatestphys(uint64_t physaddr, int value)
697c478bd9Sstevel@tonic-gate{}
707c478bd9Sstevel@tonic-gate
717c478bd9Sstevel@tonic-gate/*ARGSUSED*/
727c478bd9Sstevel@tonic-gateint
737c478bd9Sstevel@tonic-gateldphys(uint64_t physaddr)
747c478bd9Sstevel@tonic-gate{ return (0); }
757c478bd9Sstevel@tonic-gate
767c478bd9Sstevel@tonic-gate/*ARGSUSED*/
777c478bd9Sstevel@tonic-gatevoid
787c478bd9Sstevel@tonic-gatestdphys(uint64_t physaddr, uint64_t value)
797c478bd9Sstevel@tonic-gate{}
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gate/*ARGSUSED*/
827c478bd9Sstevel@tonic-gateuint64_t
837c478bd9Sstevel@tonic-gatelddphys(uint64_t physaddr)
847c478bd9Sstevel@tonic-gate{ return (0x0ull); }
857c478bd9Sstevel@tonic-gate
867c478bd9Sstevel@tonic-gate/* ARGSUSED */
877c478bd9Sstevel@tonic-gatevoid
887c478bd9Sstevel@tonic-gatestphysio(u_longlong_t physaddr, uint_t value)
897c478bd9Sstevel@tonic-gate{}
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gate/* ARGSUSED */
927c478bd9Sstevel@tonic-gateuint_t
937c478bd9Sstevel@tonic-gateldphysio(u_longlong_t physaddr)
947c478bd9Sstevel@tonic-gate{ return(0); }
957c478bd9Sstevel@tonic-gate
967c478bd9Sstevel@tonic-gate/* ARGSUSED */
977c478bd9Sstevel@tonic-gatevoid
987c478bd9Sstevel@tonic-gatesthphysio(u_longlong_t physaddr, ushort_t value)
997c478bd9Sstevel@tonic-gate{}
1007c478bd9Sstevel@tonic-gate
1017c478bd9Sstevel@tonic-gate/* ARGSUSED */
1027c478bd9Sstevel@tonic-gateushort_t
1037c478bd9Sstevel@tonic-gateldhphysio(u_longlong_t physaddr)
1047c478bd9Sstevel@tonic-gate{ return(0); }
1057c478bd9Sstevel@tonic-gate
1067c478bd9Sstevel@tonic-gate/* ARGSUSED */
1077c478bd9Sstevel@tonic-gatevoid
1087c478bd9Sstevel@tonic-gatestbphysio(u_longlong_t physaddr, uchar_t value)
1097c478bd9Sstevel@tonic-gate{}
1107c478bd9Sstevel@tonic-gate
1117c478bd9Sstevel@tonic-gate/* ARGSUSED */
1127c478bd9Sstevel@tonic-gateuchar_t
1137c478bd9Sstevel@tonic-gateldbphysio(u_longlong_t physaddr)
1147c478bd9Sstevel@tonic-gate{ return(0); }
1157c478bd9Sstevel@tonic-gate
1167c478bd9Sstevel@tonic-gate/*ARGSUSED*/
1177c478bd9Sstevel@tonic-gatevoid
1187c478bd9Sstevel@tonic-gatestdphysio(u_longlong_t physaddr, u_longlong_t value)
1197c478bd9Sstevel@tonic-gate{}
1207c478bd9Sstevel@tonic-gate
1217c478bd9Sstevel@tonic-gate/*ARGSUSED*/
1227c478bd9Sstevel@tonic-gateu_longlong_t
1237c478bd9Sstevel@tonic-gatelddphysio(u_longlong_t physaddr)
1247c478bd9Sstevel@tonic-gate{ return (0ull); }
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gate#else
1277c478bd9Sstevel@tonic-gate
1287c478bd9Sstevel@tonic-gate	! Store long word value at physical address
1297c478bd9Sstevel@tonic-gate	!
1307c478bd9Sstevel@tonic-gate	! void  stdphys(uint64_t physaddr, uint64_t value)
1317c478bd9Sstevel@tonic-gate	!
1327c478bd9Sstevel@tonic-gate	ENTRY(stdphys)
1337c478bd9Sstevel@tonic-gate	/*
1347c478bd9Sstevel@tonic-gate	 * disable interrupts, clear Address Mask to access 64 bit physaddr
1357c478bd9Sstevel@tonic-gate	 */
1367c478bd9Sstevel@tonic-gate	rdpr	%pstate, %o4
1377c478bd9Sstevel@tonic-gate	andn	%o4, PSTATE_IE | PSTATE_AM, %o5
1387c478bd9Sstevel@tonic-gate	wrpr	%o5, 0, %pstate
1397c478bd9Sstevel@tonic-gate	stxa	%o1, [%o0]ASI_MEM
1407c478bd9Sstevel@tonic-gate	retl
1417c478bd9Sstevel@tonic-gate	wrpr	%g0, %o4, %pstate	! restore earlier pstate register value
1427c478bd9Sstevel@tonic-gate	SET_SIZE(stdphys)
1437c478bd9Sstevel@tonic-gate
1447c478bd9Sstevel@tonic-gate
1457c478bd9Sstevel@tonic-gate	! Store long word value at physical i/o address
1467c478bd9Sstevel@tonic-gate	!
1477c478bd9Sstevel@tonic-gate	! void  stdphysio(u_longlong_t physaddr, u_longlong_t value)
1487c478bd9Sstevel@tonic-gate	!
1497c478bd9Sstevel@tonic-gate	ENTRY(stdphysio)
1507c478bd9Sstevel@tonic-gate	/*
1517c478bd9Sstevel@tonic-gate	 * disable interrupts, clear Address Mask to access 64 bit physaddr
1527c478bd9Sstevel@tonic-gate	 */
1537c478bd9Sstevel@tonic-gate	rdpr	%pstate, %o4
1547c478bd9Sstevel@tonic-gate	andn	%o4, PSTATE_IE | PSTATE_AM, %o5
1557c478bd9Sstevel@tonic-gate	wrpr	%o5, 0, %pstate		! clear IE, AM bits
1567c478bd9Sstevel@tonic-gate	stxa	%o1, [%o0]ASI_IO
1577c478bd9Sstevel@tonic-gate	retl
1587c478bd9Sstevel@tonic-gate	wrpr	%g0, %o4, %pstate	! restore earlier pstate register value
1597c478bd9Sstevel@tonic-gate	SET_SIZE(stdphysio)
1607c478bd9Sstevel@tonic-gate
1617c478bd9Sstevel@tonic-gate
1627c478bd9Sstevel@tonic-gate	!
1637c478bd9Sstevel@tonic-gate	! Load long word value at physical address
1647c478bd9Sstevel@tonic-gate	!
1657c478bd9Sstevel@tonic-gate	! uint64_t lddphys(uint64_t physaddr)
1667c478bd9Sstevel@tonic-gate	!
1677c478bd9Sstevel@tonic-gate	ENTRY(lddphys)
1687c478bd9Sstevel@tonic-gate	rdpr	%pstate, %o4
1697c478bd9Sstevel@tonic-gate	andn	%o4, PSTATE_IE | PSTATE_AM, %o5
1707c478bd9Sstevel@tonic-gate	wrpr	%o5, 0, %pstate
1717c478bd9Sstevel@tonic-gate	ldxa	[%o0]ASI_MEM, %o0
1727c478bd9Sstevel@tonic-gate	retl
1737c478bd9Sstevel@tonic-gate	wrpr	%g0, %o4, %pstate	! restore earlier pstate register value
1747c478bd9Sstevel@tonic-gate	SET_SIZE(lddphys)
1757c478bd9Sstevel@tonic-gate
1767c478bd9Sstevel@tonic-gate	!
1777c478bd9Sstevel@tonic-gate	! Load long word value at physical i/o address
1787c478bd9Sstevel@tonic-gate	!
1797c478bd9Sstevel@tonic-gate	! unsigned long long lddphysio(u_longlong_t physaddr)
1807c478bd9Sstevel@tonic-gate	!
1817c478bd9Sstevel@tonic-gate	ENTRY(lddphysio)
1827c478bd9Sstevel@tonic-gate	rdpr	%pstate, %o4
1837c478bd9Sstevel@tonic-gate	andn	%o4, PSTATE_IE | PSTATE_AM, %o5
1847c478bd9Sstevel@tonic-gate	wrpr	%o5, 0, %pstate	! clear IE, AM bits
1857c478bd9Sstevel@tonic-gate	ldxa	[%o0]ASI_IO, %o0
1867c478bd9Sstevel@tonic-gate	retl
1877c478bd9Sstevel@tonic-gate	wrpr	%g0, %o4, %pstate	! restore earlier pstate register value
1887c478bd9Sstevel@tonic-gate	SET_SIZE(lddphysio)
1897c478bd9Sstevel@tonic-gate
1907c478bd9Sstevel@tonic-gate	!
1917c478bd9Sstevel@tonic-gate	! Store value at physical address
1927c478bd9Sstevel@tonic-gate	!
1937c478bd9Sstevel@tonic-gate	! void  stphys(uint64_t physaddr, int value)
1947c478bd9Sstevel@tonic-gate	!
1957c478bd9Sstevel@tonic-gate	ENTRY(stphys)
1967c478bd9Sstevel@tonic-gate	rdpr	%pstate, %o4
1977c478bd9Sstevel@tonic-gate	andn	%o4, PSTATE_IE | PSTATE_AM, %o5
1987c478bd9Sstevel@tonic-gate	wrpr	%o5, 0, %pstate
1997c478bd9Sstevel@tonic-gate	sta	%o1, [%o0]ASI_MEM
2007c478bd9Sstevel@tonic-gate	retl
2017c478bd9Sstevel@tonic-gate	wrpr	%g0, %o4, %pstate	! restore earlier pstate register value
2027c478bd9Sstevel@tonic-gate	SET_SIZE(stphys)
2037c478bd9Sstevel@tonic-gate
2047c478bd9Sstevel@tonic-gate
2057c478bd9Sstevel@tonic-gate	!
2067c478bd9Sstevel@tonic-gate	! load value at physical address
2077c478bd9Sstevel@tonic-gate	!
2087c478bd9Sstevel@tonic-gate	! int   ldphys(uint64_t physaddr)
2097c478bd9Sstevel@tonic-gate	!
2107c478bd9Sstevel@tonic-gate	ENTRY(ldphys)
2117c478bd9Sstevel@tonic-gate	rdpr	%pstate, %o4
2127c478bd9Sstevel@tonic-gate	andn	%o4, PSTATE_IE | PSTATE_AM, %o5
2137c478bd9Sstevel@tonic-gate	wrpr	%o5, 0, %pstate
2147c478bd9Sstevel@tonic-gate	lda	[%o0]ASI_MEM, %o0
2157c478bd9Sstevel@tonic-gate	srl	%o0, 0, %o0	! clear upper 32 bits
2167c478bd9Sstevel@tonic-gate	retl
2177c478bd9Sstevel@tonic-gate	wrpr	%g0, %o4, %pstate	! restore earlier pstate register value
2187c478bd9Sstevel@tonic-gate	SET_SIZE(ldphys)
2197c478bd9Sstevel@tonic-gate
2207c478bd9Sstevel@tonic-gate	!
2217c478bd9Sstevel@tonic-gate	! Store value into physical address in I/O space
2227c478bd9Sstevel@tonic-gate	!
2237c478bd9Sstevel@tonic-gate	! void stphysio(u_longlong_t physaddr, uint_t value)
2247c478bd9Sstevel@tonic-gate	!
2257c478bd9Sstevel@tonic-gate	ENTRY_NP(stphysio)
2267c478bd9Sstevel@tonic-gate	rdpr	%pstate, %o4		/* read PSTATE reg */
2277c478bd9Sstevel@tonic-gate	andn	%o4, PSTATE_IE | PSTATE_AM, %o5
2287c478bd9Sstevel@tonic-gate	wrpr	%o5, 0, %pstate
2297c478bd9Sstevel@tonic-gate	stwa	%o1, [%o0]ASI_IO	/* store value via bypass ASI */
2307c478bd9Sstevel@tonic-gate	retl
2317c478bd9Sstevel@tonic-gate	wrpr	%g0, %o4, %pstate	/* restore the PSTATE */
2327c478bd9Sstevel@tonic-gate	SET_SIZE(stphysio)
2337c478bd9Sstevel@tonic-gate
2347c478bd9Sstevel@tonic-gate	!
2357c478bd9Sstevel@tonic-gate	! Store value into physical address in I/O space
2367c478bd9Sstevel@tonic-gate	!
2377c478bd9Sstevel@tonic-gate	! void sthphysio(u_longlong_t physaddr, ushort_t value)
2387c478bd9Sstevel@tonic-gate	!
2397c478bd9Sstevel@tonic-gate	ENTRY_NP(sthphysio)
2407c478bd9Sstevel@tonic-gate	rdpr	%pstate, %o4		/* read PSTATE reg */
2417c478bd9Sstevel@tonic-gate	andn	%o4, PSTATE_IE | PSTATE_AM, %o5
2427c478bd9Sstevel@tonic-gate	wrpr	%o5, 0, %pstate
2437c478bd9Sstevel@tonic-gate	stha	%o1, [%o0]ASI_IO	/* store value via bypass ASI */
2447c478bd9Sstevel@tonic-gate	retl
2457c478bd9Sstevel@tonic-gate	wrpr	%g0, %o4, %pstate		/* restore the PSTATE */
2467c478bd9Sstevel@tonic-gate	SET_SIZE(sthphysio)
2477c478bd9Sstevel@tonic-gate
2487c478bd9Sstevel@tonic-gate	!
2497c478bd9Sstevel@tonic-gate	! Store value into one byte physical address in I/O space
2507c478bd9Sstevel@tonic-gate	!
2517c478bd9Sstevel@tonic-gate	! void stbphysio(u_longlong_t physaddr, uchar_t value)
2527c478bd9Sstevel@tonic-gate	!
2537c478bd9Sstevel@tonic-gate	ENTRY_NP(stbphysio)
2547c478bd9Sstevel@tonic-gate	rdpr	%pstate, %o4		/* read PSTATE reg */
2557c478bd9Sstevel@tonic-gate	andn	%o4, PSTATE_IE | PSTATE_AM, %o5
2567c478bd9Sstevel@tonic-gate	wrpr	%o5, 0, %pstate
2577c478bd9Sstevel@tonic-gate	stba	%o1, [%o0]ASI_IO	/* store byte via bypass ASI */
2587c478bd9Sstevel@tonic-gate	retl
2597c478bd9Sstevel@tonic-gate	wrpr	%g0, %o4, %pstate	/* restore the PSTATE */
2607c478bd9Sstevel@tonic-gate	SET_SIZE(stbphysio)
2617c478bd9Sstevel@tonic-gate
2627c478bd9Sstevel@tonic-gate	!
2637c478bd9Sstevel@tonic-gate	! load value at physical address in I/O space
2647c478bd9Sstevel@tonic-gate	!
2657c478bd9Sstevel@tonic-gate	! uint_t   ldphysio(u_longlong_t physaddr)
2667c478bd9Sstevel@tonic-gate	!
2677c478bd9Sstevel@tonic-gate	ENTRY_NP(ldphysio)
2687c478bd9Sstevel@tonic-gate	rdpr	%pstate, %o4		/* read PSTATE reg */
2697c478bd9Sstevel@tonic-gate	andn	%o4, PSTATE_IE | PSTATE_AM, %o5
2707c478bd9Sstevel@tonic-gate	wrpr	%o5, 0, %pstate
2717c478bd9Sstevel@tonic-gate	lduwa	[%o0]ASI_IO, %o0	/* load value via bypass ASI */
2727c478bd9Sstevel@tonic-gate	retl
2737c478bd9Sstevel@tonic-gate	wrpr	%g0, %o4, %pstate	/* restore pstate */
2747c478bd9Sstevel@tonic-gate	SET_SIZE(ldphysio)
2757c478bd9Sstevel@tonic-gate
2767c478bd9Sstevel@tonic-gate	!
2777c478bd9Sstevel@tonic-gate	! load value at physical address in I/O space
2787c478bd9Sstevel@tonic-gate	!
2797c478bd9Sstevel@tonic-gate	! ushort_t   ldhphysio(u_longlong_t physaddr)
2807c478bd9Sstevel@tonic-gate	!
2817c478bd9Sstevel@tonic-gate	ENTRY_NP(ldhphysio)
2827c478bd9Sstevel@tonic-gate	rdpr	%pstate, %o4		/* read PSTATE reg */
2837c478bd9Sstevel@tonic-gate	andn	%o4, PSTATE_IE | PSTATE_AM, %o5
2847c478bd9Sstevel@tonic-gate	wrpr	%o5, 0, %pstate
2857c478bd9Sstevel@tonic-gate	lduha	[%o0]ASI_IO, %o0	/* load value via bypass ASI */
2867c478bd9Sstevel@tonic-gate	retl
2877c478bd9Sstevel@tonic-gate	wrpr	%g0, %o4, %pstate	/* restore pstate */
2887c478bd9Sstevel@tonic-gate	SET_SIZE(ldhphysio)
2897c478bd9Sstevel@tonic-gate
2907c478bd9Sstevel@tonic-gate	!
2917c478bd9Sstevel@tonic-gate	! load byte value at physical address in I/O space
2927c478bd9Sstevel@tonic-gate	!
2937c478bd9Sstevel@tonic-gate	! uchar_t   ldbphysio(u_longlong_t physaddr)
2947c478bd9Sstevel@tonic-gate	!
2957c478bd9Sstevel@tonic-gate	ENTRY_NP(ldbphysio)
2967c478bd9Sstevel@tonic-gate	rdpr	%pstate, %o4		/* read PSTATE reg */
2977c478bd9Sstevel@tonic-gate	andn	%o4, PSTATE_IE | PSTATE_AM, %o5
2987c478bd9Sstevel@tonic-gate	wrpr	%o5, 0, %pstate
2997c478bd9Sstevel@tonic-gate	lduba	[%o0]ASI_IO, %o0	/* load value via bypass ASI */
3007c478bd9Sstevel@tonic-gate	retl
3017c478bd9Sstevel@tonic-gate	wrpr	%g0, %o4, %pstate	/* restore pstate */
3027c478bd9Sstevel@tonic-gate	SET_SIZE(ldbphysio)
3037c478bd9Sstevel@tonic-gate#endif  /* lint */
3047c478bd9Sstevel@tonic-gate
3057c478bd9Sstevel@tonic-gate/*
3067c478bd9Sstevel@tonic-gate * save_gsr(kfpu_t *fp)
3077c478bd9Sstevel@tonic-gate * Store the graphics status register
3087c478bd9Sstevel@tonic-gate */
3097c478bd9Sstevel@tonic-gate
3107c478bd9Sstevel@tonic-gate#if defined(lint) || defined(__lint)
3117c478bd9Sstevel@tonic-gate
3127c478bd9Sstevel@tonic-gate/* ARGSUSED */
3137c478bd9Sstevel@tonic-gatevoid
3147c478bd9Sstevel@tonic-gatesave_gsr(kfpu_t *fp)
3157c478bd9Sstevel@tonic-gate{}
3167c478bd9Sstevel@tonic-gate
3177c478bd9Sstevel@tonic-gate#else	/* lint */
3187c478bd9Sstevel@tonic-gate
3197c478bd9Sstevel@tonic-gate	ENTRY_NP(save_gsr)
3207c478bd9Sstevel@tonic-gate	rd	%gsr, %g2			! save gsr
3217c478bd9Sstevel@tonic-gate	retl
3227c478bd9Sstevel@tonic-gate	stx	%g2, [%o0 + FPU_GSR]
3237c478bd9Sstevel@tonic-gate	SET_SIZE(save_gsr)
3247c478bd9Sstevel@tonic-gate
3257c478bd9Sstevel@tonic-gate#endif	/* lint */
3267c478bd9Sstevel@tonic-gate
3277c478bd9Sstevel@tonic-gate#if defined(lint) || defined(__lint)
3287c478bd9Sstevel@tonic-gate
3297c478bd9Sstevel@tonic-gate/* ARGSUSED */
3307c478bd9Sstevel@tonic-gatevoid
3317c478bd9Sstevel@tonic-gaterestore_gsr(kfpu_t *fp)
3327c478bd9Sstevel@tonic-gate{}
3337c478bd9Sstevel@tonic-gate
3347c478bd9Sstevel@tonic-gate#else	/* lint */
3357c478bd9Sstevel@tonic-gate
3367c478bd9Sstevel@tonic-gate	ENTRY_NP(restore_gsr)
3377c478bd9Sstevel@tonic-gate	ldx	[%o0 + FPU_GSR], %g2
3387c478bd9Sstevel@tonic-gate	wr	%g2, %g0, %gsr
3397c478bd9Sstevel@tonic-gate	retl
3407c478bd9Sstevel@tonic-gate	nop
3417c478bd9Sstevel@tonic-gate	SET_SIZE(restore_gsr)
3427c478bd9Sstevel@tonic-gate
3437c478bd9Sstevel@tonic-gate#endif	/* lint */
3447c478bd9Sstevel@tonic-gate
3457c478bd9Sstevel@tonic-gate/*
3467c478bd9Sstevel@tonic-gate * uint64_t
3475892374fSdf157793 * _fp_read_pgsr()
3487c478bd9Sstevel@tonic-gate * Get the graphics status register info from fp and return it
3497c478bd9Sstevel@tonic-gate */
3507c478bd9Sstevel@tonic-gate
3517c478bd9Sstevel@tonic-gate#if defined(lint) || defined(__lint)
3527c478bd9Sstevel@tonic-gate
3537c478bd9Sstevel@tonic-gate/* ARGSUSED */
3547c478bd9Sstevel@tonic-gateuint64_t
3555892374fSdf157793_fp_read_pgsr(kfpu_t *fp)
3567c478bd9Sstevel@tonic-gate{ return 0; }
3577c478bd9Sstevel@tonic-gate
3587c478bd9Sstevel@tonic-gate#else	/* lint */
3597c478bd9Sstevel@tonic-gate
3605892374fSdf157793	ENTRY_NP(_fp_read_pgsr)
3617c478bd9Sstevel@tonic-gate	retl
3627c478bd9Sstevel@tonic-gate	rd	%gsr, %o0
3635892374fSdf157793	SET_SIZE(_fp_read_pgsr)
3647c478bd9Sstevel@tonic-gate
3657c478bd9Sstevel@tonic-gate#endif	/* lint */
3667c478bd9Sstevel@tonic-gate
3677c478bd9Sstevel@tonic-gate
3687c478bd9Sstevel@tonic-gate/*
3697c478bd9Sstevel@tonic-gate * uint64_t
3707c478bd9Sstevel@tonic-gate * get_gsr(kfpu_t *fp)
3717c478bd9Sstevel@tonic-gate * Get the graphics status register info from fp and return it
3727c478bd9Sstevel@tonic-gate */
3737c478bd9Sstevel@tonic-gate
3747c478bd9Sstevel@tonic-gate#if defined(lint) || defined(__lint)
3757c478bd9Sstevel@tonic-gate
3767c478bd9Sstevel@tonic-gate/* ARGSUSED */
3777c478bd9Sstevel@tonic-gateuint64_t
3787c478bd9Sstevel@tonic-gateget_gsr(kfpu_t *fp)
3797c478bd9Sstevel@tonic-gate{ return 0; }
3807c478bd9Sstevel@tonic-gate
3817c478bd9Sstevel@tonic-gate#else	/* lint */
3827c478bd9Sstevel@tonic-gate
3837c478bd9Sstevel@tonic-gate	ENTRY_NP(get_gsr)
3847c478bd9Sstevel@tonic-gate	retl
3857c478bd9Sstevel@tonic-gate	ldx	[%o0 + FPU_GSR], %o0
3867c478bd9Sstevel@tonic-gate	SET_SIZE(get_gsr)
3877c478bd9Sstevel@tonic-gate
3887c478bd9Sstevel@tonic-gate#endif
3897c478bd9Sstevel@tonic-gate
3907c478bd9Sstevel@tonic-gate/*
3915892374fSdf157793 * _fp_write_pgsr(uint64_t *buf, kfpu_t *fp)
3927c478bd9Sstevel@tonic-gate * Set the graphics status register info to fp from buf
3937c478bd9Sstevel@tonic-gate */
3947c478bd9Sstevel@tonic-gate
3957c478bd9Sstevel@tonic-gate#if defined(lint) || defined(__lint)
3967c478bd9Sstevel@tonic-gate
3977c478bd9Sstevel@tonic-gate/* ARGSUSED */
3987c478bd9Sstevel@tonic-gatevoid
3995892374fSdf157793_fp_write_pgsr(uint64_t buf, kfpu_t *fp)
4007c478bd9Sstevel@tonic-gate{}
4017c478bd9Sstevel@tonic-gate
4027c478bd9Sstevel@tonic-gate#else	/* lint */
4037c478bd9Sstevel@tonic-gate
4045892374fSdf157793	ENTRY_NP(_fp_write_pgsr)
4057c478bd9Sstevel@tonic-gate	retl
4067c478bd9Sstevel@tonic-gate	mov	%o0, %gsr
4075892374fSdf157793	SET_SIZE(_fp_write_pgsr)
4087c478bd9Sstevel@tonic-gate
4097c478bd9Sstevel@tonic-gate#endif	/* lint */
4107c478bd9Sstevel@tonic-gate
4117c478bd9Sstevel@tonic-gate/*
4127c478bd9Sstevel@tonic-gate * set_gsr(uint64_t buf, kfpu_t *fp)
4137c478bd9Sstevel@tonic-gate * Set the graphics status register info to fp from buf
4147c478bd9Sstevel@tonic-gate */
4157c478bd9Sstevel@tonic-gate
4167c478bd9Sstevel@tonic-gate#if defined(lint) || defined(__lint)
4177c478bd9Sstevel@tonic-gate
4187c478bd9Sstevel@tonic-gate/* ARGSUSED */
4197c478bd9Sstevel@tonic-gatevoid
4207c478bd9Sstevel@tonic-gateset_gsr(uint64_t buf, kfpu_t *fp)
4217c478bd9Sstevel@tonic-gate{}
4227c478bd9Sstevel@tonic-gate
4237c478bd9Sstevel@tonic-gate#else	/* lint */
4247c478bd9Sstevel@tonic-gate
4257c478bd9Sstevel@tonic-gate	ENTRY_NP(set_gsr)
4267c478bd9Sstevel@tonic-gate	retl
4277c478bd9Sstevel@tonic-gate	stx	%o0, [%o1 + FPU_GSR]
4287c478bd9Sstevel@tonic-gate	SET_SIZE(set_gsr)
4297c478bd9Sstevel@tonic-gate
4307c478bd9Sstevel@tonic-gate#endif	/* lint */
4317c478bd9Sstevel@tonic-gate
4327c478bd9Sstevel@tonic-gate#if defined(lint) || defined(__lint)
4337c478bd9Sstevel@tonic-gatevoid
4347c478bd9Sstevel@tonic-gatekdi_cpu_index(void)
4357c478bd9Sstevel@tonic-gate{
4367c478bd9Sstevel@tonic-gate}
4377c478bd9Sstevel@tonic-gate
4387c478bd9Sstevel@tonic-gate#else	/* lint */
4397c478bd9Sstevel@tonic-gate
4407c478bd9Sstevel@tonic-gate	ENTRY_NP(kdi_cpu_index)
4417c478bd9Sstevel@tonic-gate	CPU_INDEX(%g1, %g2)
4427c478bd9Sstevel@tonic-gate	jmp	%g7
4437c478bd9Sstevel@tonic-gate	nop
4447c478bd9Sstevel@tonic-gate	SET_SIZE(kdi_cpu_index)
4457c478bd9Sstevel@tonic-gate
4467c478bd9Sstevel@tonic-gate#endif	/* lint */
4477bafd143Sjb145095
448*ae115bc7Smrj#if defined(lint) || defined(__lint)
449*ae115bc7Smrjvoid
450*ae115bc7Smrjkmdb_enter(void)
451*ae115bc7Smrj{
452*ae115bc7Smrj}
453*ae115bc7Smrj
454*ae115bc7Smrj#else	/* lint */
455*ae115bc7Smrj
456*ae115bc7Smrj	ENTRY_NP(kmdb_enter)
457*ae115bc7Smrj	t	ST_KMDB_TRAP
458*ae115bc7Smrj	retl
459*ae115bc7Smrj	nop
460*ae115bc7Smrj	SET_SIZE(kmdb_enter)
461*ae115bc7Smrj
462*ae115bc7Smrj#endif	/* lint */
463*ae115bc7Smrj
4647bafd143Sjb145095/*
4657bafd143Sjb145095 * The Spitfire floating point code has been changed not to use install/
4667bafd143Sjb145095 * save/restore/fork/freectx() because of the special memcpy library
4677bafd143Sjb145095 * routines, which will lose too much performance if they have to go
4687bafd143Sjb145095 * through the fp_disabled trap (which used to call installctx()). So
4697bafd143Sjb145095 * now fp_save/fp_restore are called from resume, and they don't care
4707bafd143Sjb145095 * whether floating point was enabled from the user program via the
4717bafd143Sjb145095 * fp_enabled trap or from the memcpy library, which just turns on floating
4727bafd143Sjb145095 * point in the fprs register itself. The new routine lwp_freeregs is
4737bafd143Sjb145095 * called everywhere freectx is called, and code was added to the sun4u-
4747bafd143Sjb145095 * specific version of lwp_forkregs (which is called everywhere forkctx
4757bafd143Sjb145095 * is called) to handle forking the floating point registers.
4767bafd143Sjb145095 *
4777bafd143Sjb145095 * Note that for the fprs dirty upper/lower bits are not used for now,
4787bafd143Sjb145095 * because the #instructions to determine if we need to use them is probably
4797bafd143Sjb145095 * greater than the #insructions just using them. This is a possible future
4807bafd143Sjb145095 * optimization, only do it with very careful benchmarking!
4817bafd143Sjb145095 *
4827bafd143Sjb145095 * The fp_fksave and and fp_load were split into two routines for the
4837bafd143Sjb145095 * sake of efficiency between the getfpregs/xregs_getfpregs and
4847bafd143Sjb145095 * setfpregs/xregs_setfpregs. But note that for saving and restoring
4857bafd143Sjb145095 * context, both *must* happen. For prmachdep, aka access from [k]adb,
4867bafd143Sjb145095 * it's OK if only one part happens.
4877bafd143Sjb145095 */
4887bafd143Sjb145095
4897bafd143Sjb145095/*
4907bafd143Sjb145095 * fp_save(kfpu_t *fp)
4917bafd143Sjb145095 * fp_fksave(kfpu_t *fp)
4927bafd143Sjb145095 * Store the floating point registers.
4937bafd143Sjb145095 */
4947bafd143Sjb145095
4957bafd143Sjb145095#if defined(lint) || defined(__lint)
4967bafd143Sjb145095
4977bafd143Sjb145095/* ARGSUSED */
4987bafd143Sjb145095void
4997bafd143Sjb145095fp_save(kfpu_t *fp)
5007bafd143Sjb145095{}
5017bafd143Sjb145095
5027bafd143Sjb145095/* ARGSUSED */
5037bafd143Sjb145095void
5047bafd143Sjb145095fp_fksave(kfpu_t *fp)
5057bafd143Sjb145095{}
5067bafd143Sjb145095
5077bafd143Sjb145095#else	/* lint */
5087bafd143Sjb145095
5097bafd143Sjb145095	ENTRY_NP(fp_save)
5107bafd143Sjb145095	ALTENTRY(fp_fksave)
5117bafd143Sjb145095	BSTORE_FPREGS(%o0, %o1)			! store V9 regs
5127bafd143Sjb145095	retl
5137bafd143Sjb145095	stx	%fsr, [%o0 + FPU_FSR]		! store fsr
5147bafd143Sjb145095	SET_SIZE(fp_fksave)
5157bafd143Sjb145095	SET_SIZE(fp_save)
5167bafd143Sjb145095
5177bafd143Sjb145095#endif	/* lint */
5187bafd143Sjb145095
5197bafd143Sjb145095/*
5207bafd143Sjb145095 * fp_v8_fksave(kfpu_t *fp)
5217bafd143Sjb145095 *
5227bafd143Sjb145095 * This is like the above routine but only saves the lower half.
5237bafd143Sjb145095 */
5247bafd143Sjb145095
5257bafd143Sjb145095#if defined(lint) || defined(__lint)
5267bafd143Sjb145095
5277bafd143Sjb145095/* ARGSUSED */
5287bafd143Sjb145095void
5297bafd143Sjb145095fp_v8_fksave(kfpu_t *fp)
5307bafd143Sjb145095{}
5317bafd143Sjb145095
5327bafd143Sjb145095#else	/* lint */
5337bafd143Sjb145095
5347bafd143Sjb145095	ENTRY_NP(fp_v8_fksave)
5357bafd143Sjb145095	BSTORE_V8_FPREGS(%o0, %o1)		! store V8 regs
5367bafd143Sjb145095	retl
5377bafd143Sjb145095	stx	%fsr, [%o0 + FPU_FSR]		! store fsr
5387bafd143Sjb145095	SET_SIZE(fp_v8_fksave)
5397bafd143Sjb145095
5407bafd143Sjb145095#endif	/* lint */
5417bafd143Sjb145095
5427bafd143Sjb145095/*
5437bafd143Sjb145095 * fp_v8p_fksave(kfpu_t *fp)
5447bafd143Sjb145095 *
5457bafd143Sjb145095 * This is like the above routine but only saves the upper half.
5467bafd143Sjb145095 */
5477bafd143Sjb145095
5487bafd143Sjb145095#if defined(lint) || defined(__lint)
5497bafd143Sjb145095
5507bafd143Sjb145095/* ARGSUSED */
5517bafd143Sjb145095void
5527bafd143Sjb145095fp_v8p_fksave(kfpu_t *fp)
5537bafd143Sjb145095{}
5547bafd143Sjb145095
5557bafd143Sjb145095#else	/* lint */
5567bafd143Sjb145095
5577bafd143Sjb145095	ENTRY_NP(fp_v8p_fksave)
5587bafd143Sjb145095	BSTORE_V8P_FPREGS(%o0, %o1)		! store V9 extra regs
5597bafd143Sjb145095	retl
5607bafd143Sjb145095	stx	%fsr, [%o0 + FPU_FSR]		! store fsr
5617bafd143Sjb145095	SET_SIZE(fp_v8p_fksave)
5627bafd143Sjb145095
5637bafd143Sjb145095#endif	/* lint */
5647bafd143Sjb145095
5657bafd143Sjb145095/*
5667bafd143Sjb145095 * fp_restore(kfpu_t *fp)
5677bafd143Sjb145095 */
5687bafd143Sjb145095
5697bafd143Sjb145095#if defined(lint) || defined(__lint)
5707bafd143Sjb145095
5717bafd143Sjb145095/* ARGSUSED */
5727bafd143Sjb145095void
5737bafd143Sjb145095fp_restore(kfpu_t *fp)
5747bafd143Sjb145095{}
5757bafd143Sjb145095
5767bafd143Sjb145095#else	/* lint */
5777bafd143Sjb145095
5787bafd143Sjb145095	ENTRY_NP(fp_restore)
5797bafd143Sjb145095	BLOAD_FPREGS(%o0, %o1)			! load V9 regs
5807bafd143Sjb145095	retl
5817bafd143Sjb145095	ldx	[%o0 + FPU_FSR], %fsr		! restore fsr
5827bafd143Sjb145095	SET_SIZE(fp_restore)
5837bafd143Sjb145095
5847bafd143Sjb145095#endif	/* lint */
5857bafd143Sjb145095
5867bafd143Sjb145095/*
5877bafd143Sjb145095 * fp_v8_load(kfpu_t *fp)
5887bafd143Sjb145095 */
5897bafd143Sjb145095
5907bafd143Sjb145095#if defined(lint) || defined(__lint)
5917bafd143Sjb145095
5927bafd143Sjb145095/* ARGSUSED */
5937bafd143Sjb145095void
5947bafd143Sjb145095fp_v8_load(kfpu_t *fp)
5957bafd143Sjb145095{}
5967bafd143Sjb145095
5977bafd143Sjb145095#else	/* lint */
5987bafd143Sjb145095
5997bafd143Sjb145095	ENTRY_NP(fp_v8_load)
6007bafd143Sjb145095	BLOAD_V8_FPREGS(%o0, %o1)		! load V8 regs
6017bafd143Sjb145095	retl
6027bafd143Sjb145095	ldx	[%o0 + FPU_FSR], %fsr		! restore fsr
6037bafd143Sjb145095	SET_SIZE(fp_v8_load)
6047bafd143Sjb145095
6057bafd143Sjb145095#endif	/* lint */
6067bafd143Sjb145095
6077bafd143Sjb145095/*
6087bafd143Sjb145095 * fp_v8p_load(kfpu_t *fp)
6097bafd143Sjb145095 */
6107bafd143Sjb145095
6117bafd143Sjb145095#if defined(lint) || defined(__lint)
6127bafd143Sjb145095
6137bafd143Sjb145095/* ARGSUSED */
6147bafd143Sjb145095void
6157bafd143Sjb145095fp_v8p_load(kfpu_t *fp)
6167bafd143Sjb145095{}
6177bafd143Sjb145095
6187bafd143Sjb145095#else	/* lint */
6197bafd143Sjb145095
6207bafd143Sjb145095	ENTRY_NP(fp_v8p_load)
6217bafd143Sjb145095	BLOAD_V8P_FPREGS(%o0, %o1)		! load V9 extra regs
6227bafd143Sjb145095	retl
6237bafd143Sjb145095	ldx	[%o0 + FPU_FSR], %fsr		! restore fsr
6247bafd143Sjb145095	SET_SIZE(fp_v8p_load)
6257bafd143Sjb145095
6267bafd143Sjb145095#endif	/* lint */
627