xref: /illumos-gate/usr/src/uts/i86pc/sys/x_call.h (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
5*ae115bc7Smrj  * Common Development and Distribution License (the "License").
6*ae115bc7Smrj  * 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  */
21*ae115bc7Smrj 
227c478bd9Sstevel@tonic-gate /*
23*ae115bc7Smrj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_X_CALL_H
287c478bd9Sstevel@tonic-gate #define	_SYS_X_CALL_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate /*
337c478bd9Sstevel@tonic-gate  * For x86, we only have three cross call levels:
347c478bd9Sstevel@tonic-gate  * a low, med and high. (see xc_levels.h)
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate #include <sys/xc_levels.h>
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
397c478bd9Sstevel@tonic-gate extern "C" {
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * States of a cross-call session. (stored in xc_state field of the
447c478bd9Sstevel@tonic-gate  * per-CPU area).
457c478bd9Sstevel@tonic-gate  */
467c478bd9Sstevel@tonic-gate #define	XC_DONE		0	/* x-call session done */
477c478bd9Sstevel@tonic-gate #define	XC_HOLD		1	/* spin doing nothing */
487c478bd9Sstevel@tonic-gate #define	XC_SYNC_OP	2	/* perform a synchronous operation */
497c478bd9Sstevel@tonic-gate #define	XC_CALL_OP	3	/* perform a call operation */
507c478bd9Sstevel@tonic-gate #define	XC_WAIT		4	/* capture/release. callee has seen wait */
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate #ifndef _ASM
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h>
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate typedef intptr_t xc_arg_t;
577c478bd9Sstevel@tonic-gate typedef int (*xc_func_t)(xc_arg_t, xc_arg_t, xc_arg_t);
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate struct	xc_mbox {
607c478bd9Sstevel@tonic-gate 	xc_func_t	func;
617c478bd9Sstevel@tonic-gate 	xc_arg_t	arg1;
627c478bd9Sstevel@tonic-gate 	xc_arg_t	arg2;
637c478bd9Sstevel@tonic-gate 	xc_arg_t	arg3;
647c478bd9Sstevel@tonic-gate 	cpuset_t	set;
657c478bd9Sstevel@tonic-gate 	int		saved_pri;
667c478bd9Sstevel@tonic-gate };
677c478bd9Sstevel@tonic-gate 
68*ae115bc7Smrj #if defined(_MACHDEP)
69*ae115bc7Smrj extern cpuset_t cpu_ready_set;
70*ae115bc7Smrj #endif
71*ae115bc7Smrj 
727c478bd9Sstevel@tonic-gate /*
737c478bd9Sstevel@tonic-gate  * Cross-call routines.
747c478bd9Sstevel@tonic-gate  */
757c478bd9Sstevel@tonic-gate #if defined(_KERNEL)
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate extern void	xc_init(void);
787c478bd9Sstevel@tonic-gate extern uint_t	xc_serv(caddr_t, caddr_t);
797c478bd9Sstevel@tonic-gate extern void	xc_call(xc_arg_t, xc_arg_t, xc_arg_t, int, cpuset_t, xc_func_t);
807c478bd9Sstevel@tonic-gate extern void	xc_trycall(xc_arg_t, xc_arg_t, xc_arg_t, cpuset_t, xc_func_t);
817c478bd9Sstevel@tonic-gate extern void	xc_sync(xc_arg_t, xc_arg_t, xc_arg_t, int, cpuset_t, xc_func_t);
827c478bd9Sstevel@tonic-gate extern void	xc_capture_cpus(cpuset_t);
837c478bd9Sstevel@tonic-gate extern void	xc_release_cpus(void);
847c478bd9Sstevel@tonic-gate 
85*ae115bc7Smrj #if defined(TRAPTRACE)
86*ae115bc7Smrj 
87*ae115bc7Smrj /*
88*ae115bc7Smrj  * X-call tracing can be interleaved with trap tracing
89*ae115bc7Smrj  */
90*ae115bc7Smrj extern void xc_make_trap_trace_entry(uint8_t, int, ulong_t);
91*ae115bc7Smrj #define	XC_TRACE(m, pri, arg)	xc_make_trap_trace_entry(m, pri, arg)
92*ae115bc7Smrj 
93*ae115bc7Smrj #else	/* TRAPTRACE */
94*ae115bc7Smrj 
95*ae115bc7Smrj #define	XC_TRACE(m, pri, arg)	/* nothing */
96*ae115bc7Smrj 
97*ae115bc7Smrj #endif	/* TRAPTRACE */
98*ae115bc7Smrj 
997c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate #endif	/* !_ASM */
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1047c478bd9Sstevel@tonic-gate }
1057c478bd9Sstevel@tonic-gate #endif
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate #endif	/* _SYS_X_CALL_H */
108