xref: /titanic_52/usr/src/uts/i86pc/sys/apix.h (revision 7ff178cd8db129d385d3177eb20744d3b6efc59b)
1*7ff178cdSJimmy Vetayases /*
2*7ff178cdSJimmy Vetayases  * CDDL HEADER START
3*7ff178cdSJimmy Vetayases  *
4*7ff178cdSJimmy Vetayases  * The contents of this file are subject to the terms of the
5*7ff178cdSJimmy Vetayases  * Common Development and Distribution License (the "License").
6*7ff178cdSJimmy Vetayases  * You may not use this file except in compliance with the License.
7*7ff178cdSJimmy Vetayases  *
8*7ff178cdSJimmy Vetayases  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7ff178cdSJimmy Vetayases  * or http://www.opensolaris.org/os/licensing.
10*7ff178cdSJimmy Vetayases  * See the License for the specific language governing permissions
11*7ff178cdSJimmy Vetayases  * and limitations under the License.
12*7ff178cdSJimmy Vetayases  *
13*7ff178cdSJimmy Vetayases  * When distributing Covered Code, include this CDDL HEADER in each
14*7ff178cdSJimmy Vetayases  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7ff178cdSJimmy Vetayases  * If applicable, add the following below this CDDL HEADER, with the
16*7ff178cdSJimmy Vetayases  * fields enclosed by brackets "[]" replaced with your own identifying
17*7ff178cdSJimmy Vetayases  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7ff178cdSJimmy Vetayases  *
19*7ff178cdSJimmy Vetayases  * CDDL HEADER END
20*7ff178cdSJimmy Vetayases  */
21*7ff178cdSJimmy Vetayases /*
22*7ff178cdSJimmy Vetayases  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23*7ff178cdSJimmy Vetayases  */
24*7ff178cdSJimmy Vetayases 
25*7ff178cdSJimmy Vetayases #ifndef __SYS_APIX_APIX_H
26*7ff178cdSJimmy Vetayases #define	__SYS_APIX_APIX_H
27*7ff178cdSJimmy Vetayases 
28*7ff178cdSJimmy Vetayases #include <sys/note.h>
29*7ff178cdSJimmy Vetayases #include <sys/avintr.h>
30*7ff178cdSJimmy Vetayases #include <sys/traptrace.h>
31*7ff178cdSJimmy Vetayases #include <sys/apic.h>
32*7ff178cdSJimmy Vetayases #include <sys/apic_common.h>
33*7ff178cdSJimmy Vetayases 
34*7ff178cdSJimmy Vetayases #ifdef	__cplusplus
35*7ff178cdSJimmy Vetayases extern	"C" {
36*7ff178cdSJimmy Vetayases #endif
37*7ff178cdSJimmy Vetayases 
38*7ff178cdSJimmy Vetayases #ifdef	DEBUG
39*7ff178cdSJimmy Vetayases #ifndef	TRAPTRACE
40*7ff178cdSJimmy Vetayases #define	TRAPTRACE
41*7ff178cdSJimmy Vetayases #endif
42*7ff178cdSJimmy Vetayases #endif
43*7ff178cdSJimmy Vetayases 
44*7ff178cdSJimmy Vetayases #define	APIX_NAME		"apix"
45*7ff178cdSJimmy Vetayases 
46*7ff178cdSJimmy Vetayases #define	APIX_NVECTOR		256	/* max number of per-cpu vectors */
47*7ff178cdSJimmy Vetayases #define	APIX_NIRQ		256	/* maximum number of IRQs */
48*7ff178cdSJimmy Vetayases #define	APIX_INVALID_VECT	0	/* invalid vector */
49*7ff178cdSJimmy Vetayases 
50*7ff178cdSJimmy Vetayases /* vector type */
51*7ff178cdSJimmy Vetayases #define	APIX_TYPE_FIXED	DDI_INTR_TYPE_FIXED	/* 1 */
52*7ff178cdSJimmy Vetayases #define	APIX_TYPE_MSI		DDI_INTR_TYPE_MSI	/* 2 */
53*7ff178cdSJimmy Vetayases #define	APIX_TYPE_MSIX	DDI_INTR_TYPE_MSIX	/* 4 */
54*7ff178cdSJimmy Vetayases #define	APIX_TYPE_IPI		8
55*7ff178cdSJimmy Vetayases 
56*7ff178cdSJimmy Vetayases /* vector states */
57*7ff178cdSJimmy Vetayases enum {
58*7ff178cdSJimmy Vetayases 	APIX_STATE_FREED = 0,
59*7ff178cdSJimmy Vetayases 	APIX_STATE_OBSOLETED,	/* 1 */
60*7ff178cdSJimmy Vetayases 	APIX_STATE_ALLOCED,	/* 2 */
61*7ff178cdSJimmy Vetayases 	APIX_STATE_ENABLED,	/* 3 */
62*7ff178cdSJimmy Vetayases 	APIX_STATE_DISABLED	/* 4 */
63*7ff178cdSJimmy Vetayases };
64*7ff178cdSJimmy Vetayases #define	IS_VECT_FREE(p)		\
65*7ff178cdSJimmy Vetayases 	(((p) == NULL) || ((p)->v_state == APIX_STATE_FREED))
66*7ff178cdSJimmy Vetayases #define	IS_VECT_OBSOL(p)	\
67*7ff178cdSJimmy Vetayases 	(((p) != NULL) && ((p)->v_state == APIX_STATE_OBSOLETED))
68*7ff178cdSJimmy Vetayases #define	IS_VECT_ENABLED(p)	\
69*7ff178cdSJimmy Vetayases 	(((p) != NULL) && ((p)->v_state == APIX_STATE_ENABLED))
70*7ff178cdSJimmy Vetayases 
71*7ff178cdSJimmy Vetayases /* flags */
72*7ff178cdSJimmy Vetayases #define	APIX_VECT_USER_BOUND	0x1
73*7ff178cdSJimmy Vetayases #define	APIX_VECT_MASKABLE	0x2
74*7ff178cdSJimmy Vetayases 
75*7ff178cdSJimmy Vetayases /*
76*7ff178cdSJimmy Vetayases  * Number of interrupt vectors reserved by software on each LOCAL APIC:
77*7ff178cdSJimmy Vetayases  * 	1. Dtrace
78*7ff178cdSJimmy Vetayases  *	2. int80
79*7ff178cdSJimmy Vetayases  *	3. system-call
80*7ff178cdSJimmy Vetayases  *	4. fast-trap
81*7ff178cdSJimmy Vetayases  * 	5. apix-reserved
82*7ff178cdSJimmy Vetayases  */
83*7ff178cdSJimmy Vetayases #define	APIX_SW_RESERVED_VECTORS	5
84*7ff178cdSJimmy Vetayases 
85*7ff178cdSJimmy Vetayases /*
86*7ff178cdSJimmy Vetayases  * Macros to help deal with shared interrupts and to differentiate
87*7ff178cdSJimmy Vetayases  * between vector and irq number when passing arguments to interfaces
88*7ff178cdSJimmy Vetayases  * xxx_avintr()
89*7ff178cdSJimmy Vetayases  */
90*7ff178cdSJimmy Vetayases #define	APIX_VIRTVEC_VECMASK		0xff
91*7ff178cdSJimmy Vetayases #define	APIX_VIRTVEC_FLAG		0x80000000
92*7ff178cdSJimmy Vetayases #define	APIX_VIRTVECTOR(cpuid, v)	\
93*7ff178cdSJimmy Vetayases 	(APIX_VIRTVEC_FLAG | ((cpuid) << 8) | (v))
94*7ff178cdSJimmy Vetayases #define	APIX_IS_VIRTVEC(vv)		\
95*7ff178cdSJimmy Vetayases 	((vv) & APIX_VIRTVEC_FLAG)
96*7ff178cdSJimmy Vetayases #define	APIX_VIRTVEC_VECTOR(vv)	\
97*7ff178cdSJimmy Vetayases 	(((uchar_t)(vv)) & APIX_VIRTVEC_VECMASK)
98*7ff178cdSJimmy Vetayases #define	APIX_VIRTVEC_CPU(vv)		\
99*7ff178cdSJimmy Vetayases 	(((uint32_t)(vv) & ~APIX_VIRTVEC_FLAG) >> 8)
100*7ff178cdSJimmy Vetayases 
101*7ff178cdSJimmy Vetayases struct apix_dev_vector;
102*7ff178cdSJimmy Vetayases typedef struct apix_vector {
103*7ff178cdSJimmy Vetayases 	ushort_t		v_state;
104*7ff178cdSJimmy Vetayases 	ushort_t		v_type;	/* interrupt type */
105*7ff178cdSJimmy Vetayases 	processorid_t		v_cpuid;	/* current target cpu */
106*7ff178cdSJimmy Vetayases 	uchar_t			v_vector;	/* vector */
107*7ff178cdSJimmy Vetayases 	uchar_t			v_share;	/* intrs at this vector */
108*7ff178cdSJimmy Vetayases 	int			v_inum;	/* irq for fixed, inum for msi/x */
109*7ff178cdSJimmy Vetayases 	uint_t			v_flags;
110*7ff178cdSJimmy Vetayases 	processorid_t		v_bound_cpuid;	/* binding cpu */
111*7ff178cdSJimmy Vetayases 	uint_t			v_busy;	/* How frequently did clock */
112*7ff178cdSJimmy Vetayases 					/* find us in this */
113*7ff178cdSJimmy Vetayases 	uint_t			v_pri;	/* maximum priority */
114*7ff178cdSJimmy Vetayases 	struct autovec		*v_autovect;	/* ISR linked list */
115*7ff178cdSJimmy Vetayases 	void			*v_intrmap_private; /* intr remap data */
116*7ff178cdSJimmy Vetayases 	struct apix_dev_vector *v_devp;	/* pointer to device */
117*7ff178cdSJimmy Vetayases 	struct apix_vector	*v_next; /* next on per-cpu obosoletes chain */
118*7ff178cdSJimmy Vetayases } apix_vector_t;
119*7ff178cdSJimmy Vetayases 
120*7ff178cdSJimmy Vetayases typedef struct apix_impl {
121*7ff178cdSJimmy Vetayases 	processorid_t		x_cpuid;	/* cpu number */
122*7ff178cdSJimmy Vetayases 
123*7ff178cdSJimmy Vetayases 	uint16_t		x_intr_pending;	/* pending intr by IPL */
124*7ff178cdSJimmy Vetayases 	/* pointer to head of interrupt pending list */
125*7ff178cdSJimmy Vetayases 	struct autovec		*x_intr_head[PIL_MAX + 1];
126*7ff178cdSJimmy Vetayases 	/* pointer to tail of interrupt pending list */
127*7ff178cdSJimmy Vetayases 	struct autovec		*x_intr_tail[PIL_MAX + 1];
128*7ff178cdSJimmy Vetayases 
129*7ff178cdSJimmy Vetayases 	apix_vector_t		*x_obsoletes;	/* obosoleted vectors */
130*7ff178cdSJimmy Vetayases 	apix_vector_t		*x_vectbl[APIX_NVECTOR]; /* vector table */
131*7ff178cdSJimmy Vetayases 
132*7ff178cdSJimmy Vetayases 	lock_t			x_lock;
133*7ff178cdSJimmy Vetayases } apix_impl_t;
134*7ff178cdSJimmy Vetayases 
135*7ff178cdSJimmy Vetayases #define	HILEVEL_PENDING(cpu)	\
136*7ff178cdSJimmy Vetayases 	(apixs[(cpu)->cpu_id]->x_intr_pending & CPU_INTR_ACTV_HIGH_LEVEL_MASK)
137*7ff178cdSJimmy Vetayases #define	LOWLEVEL_PENDING(cpu)	\
138*7ff178cdSJimmy Vetayases 	(apixs[(cpu)->cpu_id]->x_intr_pending & ~CPU_INTR_ACTV_HIGH_LEVEL_MASK)
139*7ff178cdSJimmy Vetayases #define	IS_HILEVEL_RUNNING(cpu)	\
140*7ff178cdSJimmy Vetayases 	(((ushort_t)((cpu)->intr_actv)) & CPU_INTR_ACTV_HIGH_LEVEL_MASK)
141*7ff178cdSJimmy Vetayases #define	IS_LOWLEVEL_RUNNING(cpu)	\
142*7ff178cdSJimmy Vetayases 	(((ushort_t)((cpu)->intr_actv)) & ~CPU_INTR_ACTV_HIGH_LEVEL_MASK)
143*7ff178cdSJimmy Vetayases 
144*7ff178cdSJimmy Vetayases #define	INTR_PENDING(apixp, ipl)			\
145*7ff178cdSJimmy Vetayases 	((ipl) <= LOCK_LEVEL ?				\
146*7ff178cdSJimmy Vetayases 	((apixp)->x_intr_pending & (1 << (ipl))) :	\
147*7ff178cdSJimmy Vetayases 	((apixp)->x_intr_pending >> (LOCK_LEVEL + 1)))
148*7ff178cdSJimmy Vetayases 
149*7ff178cdSJimmy Vetayases /*
150*7ff178cdSJimmy Vetayases  * We need a way to find allocated vector for a device. One option
151*7ff178cdSJimmy Vetayases  * is to maintain a mapping table in pcplusmp. Another option would
152*7ff178cdSJimmy Vetayases  * be to record vector or irq with interrupt handler hdlp->ih_vector or
153*7ff178cdSJimmy Vetayases  * hdlp->ih_irq.
154*7ff178cdSJimmy Vetayases  * Second option requires interface changes, such as, a new interface
155*7ff178cdSJimmy Vetayases  * for  noticing vector changes caused by interrupt re-targeting.
156*7ff178cdSJimmy Vetayases  * Currently we choose the first option cause it doesn't require
157*7ff178cdSJimmy Vetayases  * new interfaces.
158*7ff178cdSJimmy Vetayases  */
159*7ff178cdSJimmy Vetayases typedef struct apix_dev_vector {
160*7ff178cdSJimmy Vetayases 	dev_info_t		*dv_dip;
161*7ff178cdSJimmy Vetayases 	int			dv_inum;	/* interrupt number */
162*7ff178cdSJimmy Vetayases 	int			dv_type;	/* interrupt type */
163*7ff178cdSJimmy Vetayases 	apix_vector_t		*dv_vector;	/* vector */
164*7ff178cdSJimmy Vetayases 	struct apix_dev_vector *dv_next;	/* per major chain */
165*7ff178cdSJimmy Vetayases } apix_dev_vector_t;
166*7ff178cdSJimmy Vetayases 
167*7ff178cdSJimmy Vetayases extern lock_t apix_lock;
168*7ff178cdSJimmy Vetayases extern apix_impl_t *apixs[];
169*7ff178cdSJimmy Vetayases extern int apix_nipis;
170*7ff178cdSJimmy Vetayases extern int apix_cpu_nvectors;
171*7ff178cdSJimmy Vetayases extern apix_dev_vector_t **apix_dev_vector;
172*7ff178cdSJimmy Vetayases extern processorid_t *apix_major_to_cpu;
173*7ff178cdSJimmy Vetayases extern kmutex_t apix_mutex;
174*7ff178cdSJimmy Vetayases 
175*7ff178cdSJimmy Vetayases #define	xv_vector(cpu, v)	apixs[(cpu)]->x_vectbl[(v)]
176*7ff178cdSJimmy Vetayases #define	xv_intrmap_private(cpu, v)	(xv_vector(cpu, v))->v_intrmap_private
177*7ff178cdSJimmy Vetayases 
178*7ff178cdSJimmy Vetayases #define	APIX_IPI_MAX		APIC_MAX_VECTOR
179*7ff178cdSJimmy Vetayases #define	APIX_IPI_MIN		(APIX_NVECTOR - apix_nipis)
180*7ff178cdSJimmy Vetayases #define	APIX_AVINTR_MIN	0x20
181*7ff178cdSJimmy Vetayases #define	APIX_NAVINTR		\
182*7ff178cdSJimmy Vetayases 	(apix_cpu_nvectors - apix_nipis - APIX_AVINTR_MIN)
183*7ff178cdSJimmy Vetayases #define	APIX_AVINTR_MAX	\
184*7ff178cdSJimmy Vetayases 	((APIX_NAVINTR <= 0) ? 0 : \
185*7ff178cdSJimmy Vetayases 	(((APIX_AVINTR_MIN + APIX_NAVINTR) > APIX_IPI_MIN) ? \
186*7ff178cdSJimmy Vetayases 	(APIX_IPI_MIN - 2) : \
187*7ff178cdSJimmy Vetayases 	(APIX_AVINTR_MIN + APIX_NAVINTR - 2)))
188*7ff178cdSJimmy Vetayases #define	APIX_RESV_VECTOR	(APIX_AVINTR_MAX + 1)
189*7ff178cdSJimmy Vetayases 
190*7ff178cdSJimmy Vetayases #define	IS_VALID_AVINTR(v)		\
191*7ff178cdSJimmy Vetayases 	((v) >= APIX_AVINTR_MIN && (v) <= APIX_AVINTR_MAX)
192*7ff178cdSJimmy Vetayases 
193*7ff178cdSJimmy Vetayases #define	APIX_ENTER_CPU_LOCK(cpuid)	lock_set(&apixs[(cpuid)]->x_lock)
194*7ff178cdSJimmy Vetayases #define	APIX_LEAVE_CPU_LOCK(cpuid)	lock_clear(&apixs[(cpuid)]->x_lock)
195*7ff178cdSJimmy Vetayases #define	APIX_CPU_LOCK_HELD(cpuid)	LOCK_HELD(&apixs[(cpuid)]->x_lock)
196*7ff178cdSJimmy Vetayases 
197*7ff178cdSJimmy Vetayases /* Get dip for msi/x */
198*7ff178cdSJimmy Vetayases #define	APIX_GET_DIP(v)		\
199*7ff178cdSJimmy Vetayases 	((v)->v_devp->dv_dip)
200*7ff178cdSJimmy Vetayases 
201*7ff178cdSJimmy Vetayases /*
202*7ff178cdSJimmy Vetayases  * For irq
203*7ff178cdSJimmy Vetayases  */
204*7ff178cdSJimmy Vetayases extern apic_irq_t *apic_irq_table[APIC_MAX_VECTOR+1];
205*7ff178cdSJimmy Vetayases #define	IS_IRQ_FREE(p)		\
206*7ff178cdSJimmy Vetayases 	((p) == NULL || ((p)->airq_mps_intr_index == FREE_INDEX))
207*7ff178cdSJimmy Vetayases 
208*7ff178cdSJimmy Vetayases #define	UNREFERENCED_1PARAMETER(_p)		_NOTE(ARGUNUSED(_p))
209*7ff178cdSJimmy Vetayases #define	UNREFERENCED_3PARAMETER(_p, _q, _r)	_NOTE(ARGUNUSED(_p, _q, _r))
210*7ff178cdSJimmy Vetayases 
211*7ff178cdSJimmy Vetayases /*
212*7ff178cdSJimmy Vetayases  * From mp_platform_common.c
213*7ff178cdSJimmy Vetayases  */
214*7ff178cdSJimmy Vetayases extern int apic_intr_policy;
215*7ff178cdSJimmy Vetayases extern iflag_t apic_sci_flags;
216*7ff178cdSJimmy Vetayases extern int apic_hpet_vect;
217*7ff178cdSJimmy Vetayases extern iflag_t apic_hpet_flags;
218*7ff178cdSJimmy Vetayases extern int	apic_redist_cpu_skip;
219*7ff178cdSJimmy Vetayases extern int	apic_num_imbalance;
220*7ff178cdSJimmy Vetayases extern int	apic_num_rebind;
221*7ff178cdSJimmy Vetayases extern struct apic_io_intr *apic_io_intrp;
222*7ff178cdSJimmy Vetayases extern int	apic_use_acpi_madt_only;
223*7ff178cdSJimmy Vetayases extern uint32_t	eisa_level_intr_mask;
224*7ff178cdSJimmy Vetayases extern int	apic_pci_bus_total;
225*7ff178cdSJimmy Vetayases extern uchar_t	apic_single_pci_busid;
226*7ff178cdSJimmy Vetayases 
227*7ff178cdSJimmy Vetayases extern ACPI_MADT_INTERRUPT_OVERRIDE *acpi_isop;
228*7ff178cdSJimmy Vetayases extern int acpi_iso_cnt;
229*7ff178cdSJimmy Vetayases 
230*7ff178cdSJimmy Vetayases extern int	apic_defconf;
231*7ff178cdSJimmy Vetayases extern int	apic_irq_translate;
232*7ff178cdSJimmy Vetayases 
233*7ff178cdSJimmy Vetayases extern int apic_max_reps_clear_pending;
234*7ff178cdSJimmy Vetayases 
235*7ff178cdSJimmy Vetayases extern int apic_probe_common(char *modname);
236*7ff178cdSJimmy Vetayases extern uchar_t acpi_find_ioapic(int irq);
237*7ff178cdSJimmy Vetayases extern int apic_find_bus_id(int bustype);
238*7ff178cdSJimmy Vetayases extern int apic_find_intin(uchar_t ioapic, uchar_t intin);
239*7ff178cdSJimmy Vetayases extern struct apic_io_intr *apic_find_io_intr_w_busid(int irqno, int busid);
240*7ff178cdSJimmy Vetayases extern int apic_acpi_translate_pci_irq(dev_info_t *dip, int busid, int devid,
241*7ff178cdSJimmy Vetayases     int ipin, int *pci_irqp, iflag_t *intr_flagp);
242*7ff178cdSJimmy Vetayases extern int apic_handle_pci_pci_bridge(dev_info_t *idip, int child_devno,
243*7ff178cdSJimmy Vetayases     int child_ipin, struct apic_io_intr **intrp);
244*7ff178cdSJimmy Vetayases extern void apic_record_rdt_entry(apic_irq_t *irqptr, int irq);
245*7ff178cdSJimmy Vetayases 
246*7ff178cdSJimmy Vetayases /*
247*7ff178cdSJimmy Vetayases  * From apic_regops.c
248*7ff178cdSJimmy Vetayases  */
249*7ff178cdSJimmy Vetayases extern int apic_have_32bit_cr8;
250*7ff178cdSJimmy Vetayases 
251*7ff178cdSJimmy Vetayases /*
252*7ff178cdSJimmy Vetayases  * apix_intr.c
253*7ff178cdSJimmy Vetayases  */
254*7ff178cdSJimmy Vetayases extern void apix_do_interrupt(struct regs *rp, trap_trace_rec_t *ttp);
255*7ff178cdSJimmy Vetayases 
256*7ff178cdSJimmy Vetayases /*
257*7ff178cdSJimmy Vetayases  * apix_utils.c
258*7ff178cdSJimmy Vetayases  */
259*7ff178cdSJimmy Vetayases 
260*7ff178cdSJimmy Vetayases typedef struct apix_rebind_info {
261*7ff178cdSJimmy Vetayases 	int		i_go;	/* if rebinding op is in progress */
262*7ff178cdSJimmy Vetayases 	uint_t		i_pri;
263*7ff178cdSJimmy Vetayases 	processorid_t	i_old_cpuid;
264*7ff178cdSJimmy Vetayases 	struct autovec	*i_old_av;
265*7ff178cdSJimmy Vetayases 	processorid_t	i_new_cpuid;
266*7ff178cdSJimmy Vetayases 	struct autovec	*i_new_av;
267*7ff178cdSJimmy Vetayases } apix_rebind_info_t;
268*7ff178cdSJimmy Vetayases 
269*7ff178cdSJimmy Vetayases extern struct apix_rebind_info apix_rebindinfo;
270*7ff178cdSJimmy Vetayases 
271*7ff178cdSJimmy Vetayases #define	APIX_SET_REBIND_INFO(_ovp, _nvp)\
272*7ff178cdSJimmy Vetayases 	if (((_ovp)->v_flags & APIX_VECT_MASKABLE) == 0) {\
273*7ff178cdSJimmy Vetayases 		apix_rebindinfo.i_pri = (_ovp)->v_pri;\
274*7ff178cdSJimmy Vetayases 		apix_rebindinfo.i_old_cpuid = (_ovp)->v_cpuid;\
275*7ff178cdSJimmy Vetayases 		apix_rebindinfo.i_old_av = (_ovp)->v_autovect;\
276*7ff178cdSJimmy Vetayases 		apix_rebindinfo.i_new_cpuid = (_nvp)->v_cpuid;\
277*7ff178cdSJimmy Vetayases 		apix_rebindinfo.i_new_av = (_nvp)->v_autovect;\
278*7ff178cdSJimmy Vetayases 		apix_rebindinfo.i_go = 1;\
279*7ff178cdSJimmy Vetayases 	}
280*7ff178cdSJimmy Vetayases 
281*7ff178cdSJimmy Vetayases #define	APIX_CLR_REBIND_INFO() \
282*7ff178cdSJimmy Vetayases 	apix_rebindinfo.i_go = 0
283*7ff178cdSJimmy Vetayases 
284*7ff178cdSJimmy Vetayases #define	APIX_IS_FAKE_INTR(_vector)\
285*7ff178cdSJimmy Vetayases 	(apix_rebindinfo.i_go && (_vector) == APIX_RESV_VECTOR)
286*7ff178cdSJimmy Vetayases 
287*7ff178cdSJimmy Vetayases #define	APIX_DO_FAKE_INTR(_cpu, _vector)\
288*7ff178cdSJimmy Vetayases 	if (APIX_IS_FAKE_INTR(_vector)) {\
289*7ff178cdSJimmy Vetayases 		struct autovec *tp;\
290*7ff178cdSJimmy Vetayases 		if ((_cpu) == apix_rebindinfo.i_old_cpuid)\
291*7ff178cdSJimmy Vetayases 			tp = apix_rebindinfo.i_old_av;\
292*7ff178cdSJimmy Vetayases 		else if ((_cpu) == apix_rebindinfo.i_new_cpuid)\
293*7ff178cdSJimmy Vetayases 			tp = apix_rebindinfo.i_new_av;\
294*7ff178cdSJimmy Vetayases 		if (tp->av_vector != NULL &&\
295*7ff178cdSJimmy Vetayases 		    (tp->av_flags & AV_PENTRY_PEND) == 0) {\
296*7ff178cdSJimmy Vetayases 			tp->av_flags |= AV_PENTRY_PEND;\
297*7ff178cdSJimmy Vetayases 			apix_insert_pending_av(apixs[(_cpu)], tp,\
298*7ff178cdSJimmy Vetayases 			    tp->av_prilevel);\
299*7ff178cdSJimmy Vetayases 			apixs[(_cpu)]->x_intr_pending |=\
300*7ff178cdSJimmy Vetayases 			    (1 << tp->av_prilevel);\
301*7ff178cdSJimmy Vetayases 		}\
302*7ff178cdSJimmy Vetayases 	}
303*7ff178cdSJimmy Vetayases 
304*7ff178cdSJimmy Vetayases extern int apix_add_avintr(void *intr_id, int ipl, avfunc xxintr, char *name,
305*7ff178cdSJimmy Vetayases     int vector, caddr_t arg1, caddr_t arg2, uint64_t *ticksp, dev_info_t *dip);
306*7ff178cdSJimmy Vetayases extern void apix_rem_avintr(void *intr_id, int ipl, avfunc xxintr,
307*7ff178cdSJimmy Vetayases     int virt_vect);
308*7ff178cdSJimmy Vetayases 
309*7ff178cdSJimmy Vetayases extern uint32_t apix_bind_cpu_locked(dev_info_t *dip);
310*7ff178cdSJimmy Vetayases extern apix_vector_t *apix_rebind(apix_vector_t *vecp, processorid_t tocpu,
311*7ff178cdSJimmy Vetayases     int count);
312*7ff178cdSJimmy Vetayases 
313*7ff178cdSJimmy Vetayases extern uchar_t apix_alloc_ipi(int ipl);
314*7ff178cdSJimmy Vetayases extern apix_vector_t *apix_alloc_intx(dev_info_t *dip, int inum, int irqno);
315*7ff178cdSJimmy Vetayases extern int apix_alloc_msi(dev_info_t *dip, int inum, int count, int behavior);
316*7ff178cdSJimmy Vetayases extern int apix_alloc_msix(dev_info_t *dip, int inum, int count, int behavior);
317*7ff178cdSJimmy Vetayases extern void apix_free_vectors(dev_info_t *dip, int inum, int count, int type);
318*7ff178cdSJimmy Vetayases extern void apix_enable_vector(apix_vector_t *vecp);
319*7ff178cdSJimmy Vetayases extern void apix_disable_vector(apix_vector_t *vecp);
320*7ff178cdSJimmy Vetayases extern int apix_obsolete_vector(apix_vector_t *vecp);
321*7ff178cdSJimmy Vetayases extern int apix_find_cont_vector_oncpu(uint32_t cpuid, int count);
322*7ff178cdSJimmy Vetayases 
323*7ff178cdSJimmy Vetayases extern void apix_set_dev_map(apix_vector_t *vecp, dev_info_t *dip, int inum);
324*7ff178cdSJimmy Vetayases extern apix_vector_t *apix_get_dev_map(dev_info_t *dip, int inum, int type);
325*7ff178cdSJimmy Vetayases extern apix_vector_t *apix_setup_io_intr(apix_vector_t *vecp);
326*7ff178cdSJimmy Vetayases extern void ioapix_init_intr(int mask_apic);
327*7ff178cdSJimmy Vetayases extern int apix_get_min_dev_inum(dev_info_t *dip, int type);
328*7ff178cdSJimmy Vetayases extern int apix_get_max_dev_inum(dev_info_t *dip, int type);
329*7ff178cdSJimmy Vetayases 
330*7ff178cdSJimmy Vetayases /*
331*7ff178cdSJimmy Vetayases  * apix.c
332*7ff178cdSJimmy Vetayases  */
333*7ff178cdSJimmy Vetayases extern int apix_addspl(int virtvec, int ipl, int min_ipl, int max_ipl);
334*7ff178cdSJimmy Vetayases extern int apix_delspl(int virtvec, int ipl, int min_ipl, int max_ipl);
335*7ff178cdSJimmy Vetayases extern void apix_intx_set_vector(int irqno, uint32_t cpuid, uchar_t vector);
336*7ff178cdSJimmy Vetayases extern apix_vector_t *apix_intx_get_vector(int irqno);
337*7ff178cdSJimmy Vetayases extern void apix_intx_enable(int irqno);
338*7ff178cdSJimmy Vetayases extern void apix_intx_disable(int irqno);
339*7ff178cdSJimmy Vetayases extern void apix_intx_free(int irqno);
340*7ff178cdSJimmy Vetayases extern int apix_intx_rebind(int irqno, processorid_t cpuid, uchar_t vector);
341*7ff178cdSJimmy Vetayases extern apix_vector_t *apix_set_cpu(apix_vector_t *vecp, int new_cpu,
342*7ff178cdSJimmy Vetayases     int *result);
343*7ff178cdSJimmy Vetayases extern apix_vector_t *apix_grp_set_cpu(apix_vector_t *vecp, int new_cpu,
344*7ff178cdSJimmy Vetayases     int *result);
345*7ff178cdSJimmy Vetayases extern void apix_level_intr_pre_eoi(int irq);
346*7ff178cdSJimmy Vetayases extern void apix_level_intr_post_dispatch(int irq);
347*7ff178cdSJimmy Vetayases 
348*7ff178cdSJimmy Vetayases #ifdef	__cplusplus
349*7ff178cdSJimmy Vetayases }
350*7ff178cdSJimmy Vetayases #endif
351*7ff178cdSJimmy Vetayases 
352*7ff178cdSJimmy Vetayases #endif	/* __SYS_APIX_APIX_H */
353