xref: /illumos-gate/usr/src/uts/i86pc/sys/x_call.h (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  * Copyright 2018 Joyent, Inc.
26  */
27 
28 #ifndef	_SYS_X_CALL_H
29 #define	_SYS_X_CALL_H
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #ifndef _ASM
36 
37 #define	XC_MSG_FREE	(0)	/* msg in xc_free queue */
38 #define	XC_MSG_ASYNC	(1)	/* msg in slave xc_msgbox */
39 #define	XC_MSG_CALL	(2)	/* msg in slave xc_msgbox */
40 #define	XC_MSG_SYNC	(3)	/* msg in slave xc_msgbox */
41 #define	XC_MSG_WAITING	(4)	/* msg in master xc_msgbox or xc_waiters */
42 #define	XC_MSG_RELEASED	(5)	/* msg in slave xc_msgbox */
43 #define	XC_MSG_DONE	(6)	/* msg in master xc_msgbox */
44 
45 typedef uintptr_t xc_arg_t;
46 typedef int (*xc_func_t)(xc_arg_t, xc_arg_t, xc_arg_t);
47 
48 /*
49  * One of these is stored in each CPU's machcpu data, plus one extra for
50  * priority (ie panic) messages
51  */
52 typedef struct xc_data {
53 	xc_func_t	xc_func;
54 	xc_arg_t	xc_a1;
55 	xc_arg_t	xc_a2;
56 	xc_arg_t	xc_a3;
57 } xc_data_t;
58 
59 /*
60  * This is kept as small as possible, since for N CPUs we need N * N of them.
61  */
62 typedef struct xc_msg {
63 	uint8_t		xc_command;
64 	uint16_t	xc_master;
65 	uint16_t	xc_slave;
66 	struct xc_msg	*xc_next;
67 } xc_msg_t;
68 
69 /*
70  * Cross-call routines.
71  */
72 #if defined(_KERNEL)
73 
74 extern void	xc_init_cpu(struct cpu *);
75 extern void	xc_fini_cpu(struct cpu *);
76 extern int	xc_flush_cpu(struct cpu *);
77 extern uint_t	xc_serv(caddr_t, caddr_t);
78 
79 #define	CPUSET2BV(set)	((ulong_t *)(void *)&(set))
80 extern void	xc_call(xc_arg_t, xc_arg_t, xc_arg_t, ulong_t *, xc_func_t);
81 extern void	xc_call_nowait(xc_arg_t, xc_arg_t, xc_arg_t, ulong_t *,
82     xc_func_t);
83 extern void	xc_sync(xc_arg_t, xc_arg_t, xc_arg_t, ulong_t *, xc_func_t);
84 extern void	xc_priority(xc_arg_t, xc_arg_t, xc_arg_t, ulong_t *, xc_func_t);
85 
86 #endif	/* _KERNEL */
87 
88 #endif	/* !_ASM */
89 
90 #ifdef	__cplusplus
91 }
92 #endif
93 
94 #endif	/* _SYS_X_CALL_H */
95