xref: /onnv-gate/usr/src/uts/sun4u/opl/ml/drmach_asm.s (revision 11311:639e7bc0b42f)
11772Sjl139090/*
21772Sjl139090 * CDDL HEADER START
31772Sjl139090 *
41772Sjl139090 * The contents of this file are subject to the terms of the
51772Sjl139090 * Common Development and Distribution License (the "License").
61772Sjl139090 * You may not use this file except in compliance with the License.
71772Sjl139090 *
81772Sjl139090 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91772Sjl139090 * or http://www.opensolaris.org/os/licensing.
101772Sjl139090 * See the License for the specific language governing permissions
111772Sjl139090 * and limitations under the License.
121772Sjl139090 *
131772Sjl139090 * When distributing Covered Code, include this CDDL HEADER in each
141772Sjl139090 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151772Sjl139090 * If applicable, add the following below this CDDL HEADER, with the
161772Sjl139090 * fields enclosed by brackets "[]" replaced with your own identifying
171772Sjl139090 * information: Portions Copyright [yyyy] [name of copyright owner]
181772Sjl139090 *
191772Sjl139090 * CDDL HEADER END
201772Sjl139090 */
21*11311SSurya.Prakki@Sun.COM
221772Sjl139090/*
23*11311SSurya.Prakki@Sun.COM * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
241772Sjl139090 * Use is subject to license terms.
251772Sjl139090 */
261772Sjl139090
271772Sjl139090/*
281772Sjl139090 * This file is through cpp before being used as
291772Sjl139090 * an inline.  It contains support routines used
301772Sjl139090 * only by DR for the copy-rename sequence.
311772Sjl139090 */
321772Sjl139090
331772Sjl139090#if defined(lint)
341772Sjl139090#include <sys/types.h>
351772Sjl139090#else
361772Sjl139090#include "assym.h"
371772Sjl139090#include "drmach_offsets.h"
381772Sjl139090#endif /* lint */
391772Sjl139090
401772Sjl139090#include <sys/asm_linkage.h>
411772Sjl139090#include <sys/param.h>
421772Sjl139090#include <sys/privregs.h>
431772Sjl139090#include <sys/spitregs.h>
441772Sjl139090#include <sys/mmu.h>
451772Sjl139090#include <sys/machthread.h>
461772Sjl139090#include <sys/pte.h>
471772Sjl139090#include <sys/stack.h>
481772Sjl139090#include <sys/vis.h>
491772Sjl139090#include <sys/intreg.h>
501772Sjl139090#include <sys/cheetahregs.h>
511772Sjl139090#include <sys/drmach.h>
523712Sbm42561#include <sys/sbd_ioctl.h>
531772Sjl139090
541772Sjl139090#if !defined(lint)
551772Sjl139090
561772Sjl139090/*
571772Sjl139090 * turn off speculative mode to prevent unwanted memory access
581772Sjl139090 * when we are in the FMEM loops
591772Sjl139090 */
601772Sjl139090
611772Sjl139090#define	FJSV_SPECULATIVE_OFF(reg, tmp1, tmp2)				\
621772Sjl139090	rdpr	%pstate, reg						;\
631772Sjl139090	andn	reg, PSTATE_IE, tmp1					;\
641772Sjl139090	wrpr	%g0, tmp1, %pstate					;\
651772Sjl139090	ldxa	[%g0]ASI_MCNTL, tmp1					;\
661772Sjl139090	set	1, tmp2							;\
671772Sjl139090	sllx	tmp2, MCNTL_SPECULATIVE_SHIFT, tmp2						;\
681772Sjl139090	or	tmp1, tmp2, tmp1					;\
691772Sjl139090	stxa	tmp1, [%g0]ASI_MCNTL					;\
701772Sjl139090	membar #Sync
711772Sjl139090#endif
721772Sjl139090
731772Sjl139090
741772Sjl139090#if defined(lint)
751772Sjl139090/*ARGSUSED*/
761772Sjl139090void
771772Sjl139090drmach_fmem_loop_script(caddr_t critical, int size, caddr_t stat)
781772Sjl139090{ return; }
791772Sjl139090#else /* lint */
801772Sjl139090	.align  8
811772Sjl139090	ENTRY_NP(drmach_fmem_loop_script)
821772Sjl139090	/* turn off speculative mode */
831772Sjl139090	FJSV_SPECULATIVE_OFF(%o5, %o3, %o4);
841772Sjl139090
851772Sjl139090	/* read the critical region to get everything in the cache */
861772Sjl139090	mov	%o0, %o3
871772Sjl1390900:
881772Sjl139090	ldx	[%o3], %o4
891772Sjl139090	sub	%o1, 8, %o1
901772Sjl139090	brnz	%o1, 0b
911772Sjl139090	 add	%o3, 8, %o3
921772Sjl139090
931772Sjl139090	/* clear L2_CTRL_UGE_TRAP error bit */
941772Sjl139090	mov	ASI_L2_CTRL_RW_ADDR, %o1
951772Sjl139090	ldxa	[%o1]ASI_L2_CTRL, %o3
961772Sjl139090	sethi	%hi(ASI_L2_CTRL_UGE_TRAP), %o4
971772Sjl139090	btst	%o3, %o4
981772Sjl139090	bz,pn	%xcc, 1f
991772Sjl139090	 nop
1001772Sjl139090	stxa	%o4, [%o1]ASI_L2_CTRL
1011772Sjl139090
1021772Sjl139090	/* now tell the master CPU that we are ready */
1031772Sjl1390901:
1041772Sjl139090	set	FMEM_LOOP_FMEM_READY, %o3
1051772Sjl139090	stb	%o3, [%o2]
1061772Sjl139090	membar #Sync
1071772Sjl139090	ba	 5f
1081772Sjl139090	 nop
1091772Sjl139090
1101772Sjl139090	/*
1111772Sjl139090	 * note that we branch to 5f, which branches right back to 2 here.
1121772Sjl139090	 * The trick is that when that branch instruction has already been
1131772Sjl139090	 * patched to a branch to itself - an infinite loop.
1141772Sjl139090	 * The master thread will patch it back to "ba 2b" when it
1151772Sjl139090	 * completes.
1161772Sjl139090	 */
1171772Sjl139090
1181772Sjl139090	/* Once we are back, we first check if there has been any
1191772Sjl139090	 * L2_CTRL_UGE_TRAP errors, if so we have to fail the
1201772Sjl139090	 * operation.  This will cause a panic because the system
1211772Sjl139090	 * is already in inconsistent state.
1221772Sjl139090	 */
1231772Sjl1390902:
1241772Sjl139090	mov	ASI_L2_CTRL_RW_ADDR, %o3
1251772Sjl139090	ldxa	[%o3]ASI_L2_CTRL, %o3
1261772Sjl139090	sethi	%hi(ASI_L2_CTRL_UGE_TRAP), %o4
1271772Sjl139090	btst	%o3, %o4
1281772Sjl139090	bz,pn	%xcc, 3f
1291772Sjl139090	 mov	%g0, %o4
1303712Sbm42561	set	EOPL_FMEM_HW_ERROR, %o4
1311772Sjl139090
1321772Sjl139090	/* set error code and stat code */
1331772Sjl1390903:
1341772Sjl139090	set	FMEM_LOOP_DONE, %o3
1351772Sjl139090	stb	%o3, [%o2]
1361772Sjl139090
1371772Sjl139090	/* turn on speculative mode again */
1381772Sjl139090	ldxa	[%g0]ASI_MCNTL, %o0
1391772Sjl139090	set	1, %o1
1401772Sjl139090	sllx	%o1, MCNTL_SPECULATIVE_SHIFT, %o1
1411772Sjl139090	andn	%o0, %o1, %o0
1421772Sjl139090	ba	4f
1431772Sjl139090	 nop
1441772Sjl139090.align 32
1451772Sjl1390904:
1461772Sjl139090	stxa	%o0, [%g0]ASI_MCNTL
1471772Sjl139090	membar	#Sync
1481772Sjl139090	wrpr	%g0, %o5, %pstate
1491772Sjl139090	retl
1501772Sjl139090	 mov	%o4, %o0
1511772Sjl139090.align 8
1521772Sjl1390905:
1531772Sjl139090	ALTENTRY(drmach_fmem_loop_script_rtn)
1541772Sjl139090	/*
1551772Sjl139090	 * busy wait will affect sibling strands so
1561772Sjl139090	 * we put sleep instruction in the delay slot
1571772Sjl139090	 */
1581772Sjl139090	ba	2b
1591772Sjl139090.word	 0x81b01060
1601772Sjl139090	SET_SIZE(drmach_fmem_loop_script)
1611772Sjl139090#endif /* lint */
1621772Sjl139090
1631772Sjl139090#if defined(lint)
1641772Sjl139090/*ARGSUSED*/
1651772Sjl139090void
1661772Sjl139090drmach_flush_icache(void)
1671772Sjl139090{ return; }
1681772Sjl139090#else /* lint */
1691772Sjl139090	.align  8
1701772Sjl139090	ENTRY_NP(drmach_flush_icache)
1711772Sjl139090	stxa	%g0, [%g0]ASI_ALL_FLUSH_L1I
1721772Sjl139090	membar	#Sync
1731772Sjl139090	retl
1741772Sjl139090	 nop
1751772Sjl139090	SET_SIZE(drmach_flush_icache)
1761772Sjl139090#endif
1771772Sjl139090
1781772Sjl139090#if defined(lint)
1791772Sjl139090/*ARGSUSED*/
1801772Sjl139090int
1811772Sjl139090drmach_fmem_exec_script(caddr_t critical, int size)
1821772Sjl139090{ return (0); }
1831772Sjl139090#else /* lint */
1841772Sjl139090.align 32
1851772Sjl139090	ENTRY_NP(drmach_fmem_exec_script)
1861772Sjl139090	/* turn off speculative mode */
1871772Sjl139090	FJSV_SPECULATIVE_OFF(%o5, %o3, %o4);
1881772Sjl139090	/* save locals to save area */
1891772Sjl139090	add	%o0, SAVE_LOCAL, %o2
1901772Sjl139090	stx	%l0, [%o2+8*0]
1911772Sjl139090	stx	%l1, [%o2+8*1]
1921772Sjl139090	stx	%l2, [%o2+8*2]
1931772Sjl139090	stx	%l3, [%o2+8*3]
1941772Sjl139090	stx	%l4, [%o2+8*4]
1951772Sjl139090	stx	%l5, [%o2+8*5]
1961772Sjl139090	stx	%l6, [%o2+8*6]
1971772Sjl139090	stx	%l7, [%o2+8*7]
1981772Sjl139090	mov	%o5, %l6
1991772Sjl139090	/* l7 is set only when FMEM cmd is issued to SCF */
2001772Sjl139090	mov	%g0, %l7
2011772Sjl139090
2021772Sjl139090	/* read the critical region to put everything in the cache */
2031772Sjl139090	mov	%o0, %o2
2041772Sjl1390900:
2051772Sjl139090	ldx	[%o2], %o4
2061772Sjl139090	sub	%o1, 8, %o1
2071772Sjl139090	brnz	%o1, 0b
2081772Sjl139090	 add	%o2, 8, %o2
2091772Sjl139090	ba	4f
2101772Sjl139090	 nop
2111772Sjl139090
2121772Sjl139090	/* we branch to 4f but eventually we branch back here to finish up */
2131772Sjl1390901:
2141772Sjl139090	mov	%l6, %o5
2151772Sjl139090	/*
2161772Sjl139090	 * save some registers for debugging
2171772Sjl139090	 * l0 - SCF_REG_BASE
2181772Sjl139090	 * l1 - SCF_TD
2191772Sjl139090	 * l2 - SCF_TD + 8
2201772Sjl139090	 * l5 - DELAY
2211772Sjl139090	 */
2221772Sjl139090	add	%o0, SAVE_LOG, %o1
2231772Sjl139090	stx	%l0, [%o1+8*0]
2241772Sjl139090	stx	%l1, [%o1+8*1]
2251772Sjl139090	stx	%l2, [%o1+8*2]
2261772Sjl139090	stx	%l5, [%o1+8*3]
2271772Sjl139090
2281772Sjl139090	add	%o0, FMEM_ISSUED, %o1
2291772Sjl139090	st	%l7, [%o1]
2301772Sjl139090
2311772Sjl139090	/* Check for L2_CTRL_UGE_TRAP error */
2321772Sjl139090	mov	ASI_L2_CTRL_RW_ADDR, %l0
2331772Sjl139090	ldxa	[%l0]ASI_L2_CTRL, %l1
2341772Sjl139090	sethi	%hi(ASI_L2_CTRL_UGE_TRAP), %l2
2351772Sjl139090	btst	%l1, %l2
2361772Sjl139090	bz,pn	%xcc, 2f
2371772Sjl139090	 nop
2383712Sbm42561	set	EOPL_FMEM_HW_ERROR, %o4
2391772Sjl1390902:
2401772Sjl139090	/* restore all locals */
2411772Sjl139090	add	%o0, SAVE_LOCAL, %o1
2421772Sjl139090	ldx	[%o1+8*0], %l0
2431772Sjl139090	ldx	[%o1+8*1], %l1
2441772Sjl139090	ldx	[%o1+8*2], %l2
2451772Sjl139090	ldx	[%o1+8*3], %l3
2461772Sjl139090	ldx	[%o1+8*4], %l4
2471772Sjl139090	ldx	[%o1+8*5], %l5
2481772Sjl139090	ldx	[%o1+8*6], %l6
2491772Sjl139090	ldx	[%o1+8*7], %l7
2501772Sjl139090
2511772Sjl139090	/* turn on speculative mode */
2521772Sjl139090	ldxa	[%g0]ASI_MCNTL, %o1
2531772Sjl139090	set	1, %o2
2541772Sjl139090	sllx	%o2, MCNTL_SPECULATIVE_SHIFT, %o2
2551772Sjl139090	andn	%o1, %o2, %o1
2561772Sjl139090	ba	3f
2571772Sjl139090	 nop
2581772Sjl139090.align 32
2591772Sjl1390903:
2601772Sjl139090	stxa	%o1, [%g0]ASI_MCNTL
2611772Sjl139090	membar	#Sync
2621772Sjl139090	/* return error code here */
2631772Sjl139090	mov	%o4, %o0
2641772Sjl139090	retl
2651772Sjl139090	 wrpr	%g0, %o5, %pstate
2661772Sjl139090
2671772Sjl139090	/* clear L2_CTRL_UGE_TRAP error bit */
2681772Sjl1390904:
2691772Sjl139090	mov	ASI_L2_CTRL_RW_ADDR, %l0
2701772Sjl139090	ldxa	[%l0]ASI_L2_CTRL, %l1
2711772Sjl139090	sethi	%hi(ASI_L2_CTRL_UGE_TRAP), %l2
2721772Sjl139090	btst	%l1, %l2
2731772Sjl139090	bz,pn	%xcc, 5f
2741772Sjl139090	 nop
2751772Sjl139090	stxa	%l2, [%l0]ASI_L2_CTRL
2761772Sjl1390905:
2771772Sjl139090	/* set up the register locations and parameters */
2781772Sjl139090	ldx	[%o0 + SCF_REG_BASE], %l0
2791772Sjl139090	ldx	[%o0 + SCF_TD], %l1
2801772Sjl139090	ldx	[%o0 + SCF_TD+8], %l2
2811772Sjl139090	ldx	[%o0 + DELAY], %l5
2821772Sjl139090
2838340SJames.Anderson@Sun.COM	/* check if SCF is ONLINE */
2848340SJames.Anderson@Sun.COM	add	%l0, SCF_STATUS_EX, %o1
2858340SJames.Anderson@Sun.COM	lduwa	[%o1]ASI_IO, %o2
2868340SJames.Anderson@Sun.COM	sethi	%hi(SCF_STATUS_EX_ONLINE), %o3
2878340SJames.Anderson@Sun.COM	btst	%o2, %o3
2888340SJames.Anderson@Sun.COM	bne	%xcc, 6f
2898340SJames.Anderson@Sun.COM	 nop
2908340SJames.Anderson@Sun.COM	set	EOPL_FMEM_SCF_OFFLINE, %o4
2918340SJames.Anderson@Sun.COM	ba	1b
2928340SJames.Anderson@Sun.COM	 nop
2938340SJames.Anderson@Sun.COM
2941772Sjl139090	/* check if SCF is busy */
2951772Sjl139090	add	%l0, SCF_COMMAND, %o1
2961772Sjl139090	lduha	[%o1]ASI_IO, %o2
2971772Sjl139090	sethi	%hi(SCF_CMD_BUSY), %o3
2981772Sjl139090	btst	%o2, %o3
2991772Sjl139090	be	%xcc, 6f
3001772Sjl139090	 nop
3013712Sbm42561	set	EOPL_FMEM_SCF_BUSY, %o4
3021772Sjl139090	ba	1b
3033712Sbm42561	 nop
3041772Sjl139090
3051772Sjl139090	/* clear STATUS bit */
3061772Sjl1390906:
3071772Sjl139090	add	%l0, SCF_STATUS, %o1
3081772Sjl139090	lduha	[%o1]ASI_IO, %o2
3091772Sjl139090	sethi	%hi(SCF_STATUS_READY), %o3
3101772Sjl139090	btst	%o2, %o3
3111772Sjl139090	be	%xcc, 7f
3121772Sjl139090	 nop
3131772Sjl139090	stha	%o3, [%o1]ASI_IO
3141772Sjl139090
3151772Sjl139090	/* clear CMD_COMPLETE bit */
3161772Sjl1390907:
3171772Sjl139090	mov	SCF_STATUS_CMD_COMPLETE, %o3
3181772Sjl139090	btst	%o2, %o3
3191772Sjl139090	be,a	%xcc, 8f
3201772Sjl139090	 nop
3211772Sjl139090	stha	%o3, [%o1]ASI_IO
3221772Sjl1390908:
3231772Sjl139090	add	%l0, (SCF_TDATA+0xe), %o1
3241772Sjl139090	mov	%l2, %o4
3251772Sjl139090	mov	SCF_RETRY_CNT, %o5
3261772Sjl139090
3271772Sjl139090	sethi	%hi(0xffff), %l2
3281772Sjl139090	or	%l2, %lo(0xffff), %l2
3291772Sjl139090
3301772Sjl139090	and	%o4, %l2, %o3
3311772Sjl139090
3321772Sjl139090	/*
3331772Sjl139090	 * o1 points to SCFBASE.SCF_TDATA[0xe]
3341772Sjl139090	 * l0 points to SCFBASE
3351772Sjl139090	 * crticial->SCF_TD[0] = source board #
3361772Sjl139090	 * crticial->SCF_TD[1] = target board #
3371772Sjl139090	 * l1 = critical->SCF_TD[0 - 7]
3381772Sjl139090	 * l2 = 0xffff
3391772Sjl139090	 * o4 = critical->SCF_TD[8 - 15]
3401772Sjl139090	 * o3 = (*o4) & 0xffff
3411772Sjl139090
3421772Sjl139090	/*
3431772Sjl139090	 * Because there is no parity protection on the ebus
3441772Sjl139090	 * we read the data back after the write to verify
3451772Sjl139090	 * we write 2 bytes at a time.
3461772Sjl139090	 * If the data read is not the same as data written
3473712Sbm42561	 * we retry up to a limit of SCF_RETRY_CNT
3481772Sjl139090	 */
3491772Sjl1390909:
3501772Sjl139090	stha	%o3, [%o1]ASI_IO
3511772Sjl139090	lduha	[%o1]ASI_IO, %o2
3521772Sjl139090	sub	%o5, 1, %o5
3533712Sbm42561	brnz	%o5, 7f
3543712Sbm42561	 nop
3553712Sbm42561	set	EOPL_FMEM_RETRY_OUT, %o4
3563712Sbm42561	ba	1b
3573712Sbm42561	 nop
3583712Sbm425617:
3591772Sjl139090	cmp	%o2, %o3
3601772Sjl139090	bne,a	9b
3611772Sjl139090	 nop
3621772Sjl139090
3631772Sjl139090	sub	%o1, %l0, %o2
3641772Sjl139090	cmp	%o2, (SCF_TDATA+0x8)
3651772Sjl139090	bne	%xcc, 2f
3661772Sjl139090	 srlx	%o4, 16, %o4
3671772Sjl139090	mov	%l1, %o4
3681772Sjl139090
3691772Sjl139090	/* if we have reach TDATA+8, we switch to l1 */
3701772Sjl139090	/* XXX: Why we need 2 loops??? */
3711772Sjl1390902:
3721772Sjl139090	sub	%o1, 2, %o1
3731772Sjl139090	mov	SCF_RETRY_CNT, %o5
3741772Sjl139090	and	%o4, %l2, %o3
3751772Sjl139090
3761772Sjl139090	sub	%o1, %l0, %o2
3771772Sjl139090	cmp	%o2, (SCF_TDATA)
3781772Sjl139090	bge,a	9b
3791772Sjl139090	 nop
3801772Sjl139090
3811772Sjl139090	/* if we reach TDATA, we are done */
3821772Sjl139090
3831772Sjl139090	/* read from SCF back to our buffer for debugging */
3841772Sjl139090	add	%l0, (SCF_TDATA), %o1
3851772Sjl139090	ldxa	[%o1]ASI_IO, %o2
3861772Sjl139090	stx	%o2, [%o0+SCF_TD]
3871772Sjl139090
3881772Sjl139090	add	%l0, (SCF_TDATA+8), %o1
3891772Sjl139090	ldxa	[%o1]ASI_IO, %o2
3901772Sjl139090	stx	%o2, [%o0+SCF_TD+8]
3911772Sjl139090
3923712Sbm42561	/* The following code conforms to the FMEM
3933712Sbm42561	   sequence (4) as described in the Columbus2
3943712Sbm42561	   logical spec section 4.6
3953712Sbm42561	*/
3963712Sbm42561
3973712Sbm42561	/* read from SCF SB INFO register */
3983712Sbm42561	sethi	%hi(SCF_SB_INFO_OFFSET), %o2
3993712Sbm42561	or	%o2, %lo(SCF_SB_INFO_OFFSET), %o2
4003712Sbm42561	add	%l0, %o2, %o1
4013712Sbm42561	lduba	[%o1]ASI_IO, %o2
4023712Sbm42561
4033712Sbm42561	/* If BUSY bit is set, abort */
4043712Sbm42561	or	%g0, (SCF_SB_INFO_BUSY), %o1
4053712Sbm42561	btst	%o1, %o2
4063712Sbm42561	set	EOPL_FMEM_SCF_BUSY, %o4
4073712Sbm42561	bne	1b
4083712Sbm42561	 nop
4091772Sjl139090
4101772Sjl139090	rd	STICK, %l1
4111772Sjl139090	add	%l5, %l1, %l5
4121772Sjl139090
4131772Sjl139090	/* Now tell SCF to do it */
4141772Sjl139090	add	%l0, SCF_COMMAND, %o1
4151772Sjl139090
4161772Sjl139090	/* 0x10A6 is the magic command */
4171772Sjl139090	sethi	%hi(0x10A6), %o2
4181772Sjl139090	or	%o2, %lo(0x10A6), %o2
4191772Sjl139090	stha	%o2, [%o1]ASI_IO
4201772Sjl139090
4211772Sjl139090	mov	1, %l7			! FMEM is issued
4221772Sjl139090
4231772Sjl139090	add	%l0, SCF_STATUS, %o1
4241772Sjl139090	sethi	%hi(SCF_STATUS_READY), %o2
4251772Sjl139090	mov	SCF_STATUS_CMD_COMPLETE, %o3
4261772Sjl139090
4271772Sjl139090	/* read STATUS_READY bit and clear it only if it is set */
4281772Sjl139090	/* XXX: this STATUS_READY checking seems meaningless */
4291772Sjl1390903:
4301772Sjl139090	lduha	[%o1]ASI_IO, %o4
4311772Sjl139090	btst	%o2, %o4
4321772Sjl139090	be	%xcc, 4f		! STATUS_READY is not set
4331772Sjl139090	 nop
4341772Sjl139090	stha	%o2, [%o1]ASI_IO	! Clear if the bit is set
4351772Sjl139090
4361772Sjl139090	/* check CMD_COMPLETE bit and clear */
4371772Sjl1390904:
4381772Sjl139090	btst	%o3, %o4
4391772Sjl139090	be	%xcc, 5f		! CMD_COMPLETE is not set
4401772Sjl139090	 nop
4411772Sjl139090	stha	%o3, [%o1]ASI_IO	! Now we are done and clear it
4421772Sjl139090	ba	%xcc, 6f
4433712Sbm42561	 mov	ESBD_NOERROR, %o4
4441772Sjl139090
4451772Sjl139090	/* timeout delay checking */
4461772Sjl1390905:
4471772Sjl139090	rd	STICK, %l2
4481772Sjl139090	cmp	%l5, %l2
4491772Sjl139090	bge	%xcc, 3b
4501772Sjl139090	 nop
4513712Sbm42561	set	EOPL_FMEM_TIMEOUT, %o4
4521772Sjl139090
4531772Sjl139090	/* we are done or timed out */
4541772Sjl1390906:
4551772Sjl139090	ba,a	1b
4561772Sjl139090	 nop
4571772Sjl139090	SET_SIZE(drmach_fmem_exec_script)
4581772Sjl139090#endif /* lint */
4591772Sjl139090
4601772Sjl139090#if defined(lint)
4611772Sjl139090/*ARGSUSED*/
4621772Sjl139090void
4631772Sjl139090drmach_fmem_exec_script_end(caddr_t critical, int size)
4641772Sjl139090{ return; }
4651772Sjl139090#else /* lint */
4661772Sjl139090	ENTRY_NP(drmach_fmem_exec_script_end)
4671772Sjl139090	nop
4681772Sjl139090	SET_SIZE(drmach_fmem_exec_script_end)
4691772Sjl139090#endif /* lint */
4701772Sjl139090
4711772Sjl139090#if defined(lint)
4721772Sjl139090uint64_t
4731772Sjl139090patch_inst(uint64_t *x, uint64_t y)
4741772Sjl139090{
4751772Sjl139090	*x = y;
4761772Sjl139090	return (0);
4771772Sjl139090}
4781772Sjl139090
4791772Sjl139090#else   /* lint */
4801772Sjl139090
4811772Sjl139090	ENTRY_NP(patch_inst)
4821772Sjl139090	ldx	[%o0], %o2
4831772Sjl139090	casx	[%o0], %o2, %o1
4841772Sjl139090	flush	%o0
4851772Sjl139090	membar #Sync
4861772Sjl139090	ldx	[%o0], %o2
4871772Sjl139090	retl
4881772Sjl139090	 mov	%o2, %o0
4891772Sjl139090	SET_SIZE(patch_inst)
4901772Sjl139090
4911772Sjl139090#endif /* lint */
4921772Sjl139090
4931772Sjl139090#if defined(lint)
4941772Sjl139090void
4951772Sjl139090drmach_sys_trap()
4961772Sjl139090{
4971772Sjl139090}
4981772Sjl139090#else   /* lint */
4991772Sjl139090	ENTRY_NP(drmach_sys_trap)
5001772Sjl139090	mov	-1, %g4
5011772Sjl139090	set	sys_trap, %g5
5021772Sjl139090	jmp	%g5
5031772Sjl139090	 nop
5041772Sjl139090	SET_SIZE(drmach_sys_trap)
5051772Sjl139090#endif /* lint */
5061772Sjl139090
5071772Sjl139090#if defined(lint)
5081772Sjl139090uint64_t
5091772Sjl139090drmach_get_stick()
5101772Sjl139090{
5111772Sjl139090	return (0);
5121772Sjl139090}
5131772Sjl139090#else   /* lint */
5141772Sjl139090	ENTRY_NP(drmach_get_stick)
5151772Sjl139090	retl
5161772Sjl139090	rd	STICK, %o0
5171772Sjl139090	SET_SIZE(drmach_get_stick)
5181772Sjl139090#endif /* lint */
5191772Sjl139090
5201772Sjl139090#if defined(lint)
5211772Sjl139090/*ARGSUSED*/
5221772Sjl139090void
523*11311SSurya.Prakki@Sun.COMdrmach_flush(drmach_copy_rename_critical_t *x, uint_t y)
5241772Sjl139090{}
5251772Sjl139090
5261772Sjl139090#else /* lint */
5271772Sjl139090	ENTRY_NP(drmach_flush)
5281772Sjl139090	mov	%o0, %o2
5291772Sjl1390900:
5301772Sjl139090	flush	%o2
5311772Sjl139090	sub	%o1, 8, %o1
5321772Sjl139090	brnz	%o1, 0b
5331772Sjl139090	 add	%o2, 8, %o2
5341772Sjl139090	retl
5351772Sjl139090	 nop
5361772Sjl139090	SET_SIZE(drmach_flush)
5371772Sjl139090#endif /* lint */
538