17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
5186d582Surya Prakki * Common Development and Distribution License (the "License").
6186d582Surya Prakki * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
21186d582Surya Prakki
227c478bdstevel@tonic-gate/*
23186d582Surya Prakki * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
247c478bdstevel@tonic-gate * Use is subject to license terms.
257c478bdstevel@tonic-gate */
267c478bdstevel@tonic-gate
277c478bdstevel@tonic-gate/*
287c478bdstevel@tonic-gate * Utility Assembly routines used by the debugger.
297c478bdstevel@tonic-gate */
307c478bdstevel@tonic-gate
317c478bdstevel@tonic-gate#if defined(__lint)
327c478bdstevel@tonic-gate#include <sys/types.h>
337c478bdstevel@tonic-gate#include <kmdb/kmdb_asmutil.h>
347c478bdstevel@tonic-gate#endif
357c478bdstevel@tonic-gate
367c478bdstevel@tonic-gate#include <sys/asm_linkage.h>
377c478bdstevel@tonic-gate#include <sys/privregs.h>
387c478bdstevel@tonic-gate#include "mach_asmutil.h"
397c478bdstevel@tonic-gate
407c478bdstevel@tonic-gate#if defined(__lint)
417c478bdstevel@tonic-gateint
427c478bdstevel@tonic-gateget_nwin(void)
437c478bdstevel@tonic-gate{
447c478bdstevel@tonic-gate	return (0);	/* wouldn't that be amusing */
457c478bdstevel@tonic-gate}
467c478bdstevel@tonic-gate#else
477c478bdstevel@tonic-gate
487c478bdstevel@tonic-gate	ENTRY(get_nwin)
497c478bdstevel@tonic-gate	GET_NWIN(%g4, %g3);	/* %g4 is scratch, %g3 set to nwin-1 */
507c478bdstevel@tonic-gate	mov	%g3, %o0
517c478bdstevel@tonic-gate	retl
527c478bdstevel@tonic-gate	add	%o0, 1, %o0
537c478bdstevel@tonic-gate	SET_SIZE(get_nwin)
547c478bdstevel@tonic-gate
557c478bdstevel@tonic-gate#endif
567c478bdstevel@tonic-gate
577c478bdstevel@tonic-gate#if defined(__lint)
587c478bdstevel@tonic-gateuintptr_t
597c478bdstevel@tonic-gateget_fp(void)
607c478bdstevel@tonic-gate{
617c478bdstevel@tonic-gate	return (0);
627c478bdstevel@tonic-gate}
637c478bdstevel@tonic-gate#else
647c478bdstevel@tonic-gate
657c478bdstevel@tonic-gate	ENTRY(get_fp)
667c478bdstevel@tonic-gate	retl
677c478bdstevel@tonic-gate	mov	%fp, %o0
687c478bdstevel@tonic-gate	SET_SIZE(get_fp)
697c478bdstevel@tonic-gate
707c478bdstevel@tonic-gate#endif
717c478bdstevel@tonic-gate
727c478bdstevel@tonic-gate#if defined(__lint)
737c478bdstevel@tonic-gatevoid
747c478bdstevel@tonic-gateinterrupts_on(void)
757c478bdstevel@tonic-gate{
767c478bdstevel@tonic-gate}
777c478bdstevel@tonic-gate#else
787c478bdstevel@tonic-gate
797c478bdstevel@tonic-gate	ENTRY(interrupts_on)
807c478bdstevel@tonic-gate	rdpr	%pstate, %o0
817c478bdstevel@tonic-gate	bset	PSTATE_IE, %o0
827c478bdstevel@tonic-gate	retl
837c478bdstevel@tonic-gate	wrpr	%o0, %pstate
847c478bdstevel@tonic-gate	SET_SIZE(interrupts_on)
857c478bdstevel@tonic-gate
867c478bdstevel@tonic-gate#endif
877c478bdstevel@tonic-gate
887c478bdstevel@tonic-gate#if defined(__lint)
897c478bdstevel@tonic-gatevoid
907c478bdstevel@tonic-gateinterrupts_off(void)
917c478bdstevel@tonic-gate{
927c478bdstevel@tonic-gate}
937c478bdstevel@tonic-gate#else
947c478bdstevel@tonic-gate
957c478bdstevel@tonic-gate	ENTRY(interrupts_off)
967c478bdstevel@tonic-gate	rdpr	%pstate, %o0
977c478bdstevel@tonic-gate	bclr	PSTATE_IE, %o0
987c478bdstevel@tonic-gate	retl
997c478bdstevel@tonic-gate	wrpr	%o0, %pstate
1007c478bdstevel@tonic-gate	SET_SIZE(interrupts_off)
1017c478bdstevel@tonic-gate
1027c478bdstevel@tonic-gate#endif
1037c478bdstevel@tonic-gate
1047c478bdstevel@tonic-gate#if defined(__lint)
1057c478bdstevel@tonic-gatecaddr_t
1067c478bdstevel@tonic-gateget_tba(void)
1077c478bdstevel@tonic-gate{
1087c478bdstevel@tonic-gate	return (0);
1097c478bdstevel@tonic-gate}
1107c478bdstevel@tonic-gate#else
1117c478bdstevel@tonic-gate
1127c478bdstevel@tonic-gate	ENTRY(get_tba)
1137c478bdstevel@tonic-gate	retl
1147c478bdstevel@tonic-gate	rdpr	%tba, %o0
1157c478bdstevel@tonic-gate	SET_SIZE(get_tba)
1167c478bdstevel@tonic-gate
1177c478bdstevel@tonic-gate#endif
1187c478bdstevel@tonic-gate
1197c478bdstevel@tonic-gate#if defined(__lint)
1207c478bdstevel@tonic-gate/*ARGSUSED*/
121186d582Surya Prakkivoid *
122186d582Surya Prakkiset_tba(void *new)
1237c478bdstevel@tonic-gate{
124186d582Surya Prakki	return (0);
1257c478bdstevel@tonic-gate}
1267c478bdstevel@tonic-gate#else
1277c478bdstevel@tonic-gate
1287c478bdstevel@tonic-gate	ENTRY(set_tba)
1297c478bdstevel@tonic-gate	retl
1307c478bdstevel@tonic-gate	wrpr	%o0, %tba
1317c478bdstevel@tonic-gate	SET_SIZE(set_tba)
1327c478bdstevel@tonic-gate
1337c478bdstevel@tonic-gate#endif
134