xref: /illumos-gate/usr/src/uts/sun/sys/avintr.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_AVINTR_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_AVINTR_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4 */
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include <sys/dditypes.h>
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate /*
39*7c478bd9Sstevel@tonic-gate  * Period of autovector structures (add this in to get the next level).
40*7c478bd9Sstevel@tonic-gate  */
41*7c478bd9Sstevel@tonic-gate #define	MAXIPL	16
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate /*
44*7c478bd9Sstevel@tonic-gate  * These are only used by sun4m and later OBP versions
45*7c478bd9Sstevel@tonic-gate  */
46*7c478bd9Sstevel@tonic-gate #define	INTLEVEL_ONBOARD	0x20
47*7c478bd9Sstevel@tonic-gate #define	INTLEVEL_SBUS		0x30
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate #define	INT_LEVEL(lvl)	((lvl) & ~(MAXIPL-1))
50*7c478bd9Sstevel@tonic-gate #define	INT_IPL(lvl)	((lvl) & (MAXIPL-1))
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate /*
53*7c478bd9Sstevel@tonic-gate  * maximum number of autovectored interrupts at a given priority
54*7c478bd9Sstevel@tonic-gate  * XXX: This is temporary until we come up with dynamic additions..
55*7c478bd9Sstevel@tonic-gate  */
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate #define	NVECT	17	/* 16 shared per level, +1 to end the list */
58*7c478bd9Sstevel@tonic-gate #define	AV_INT_SPURIOUS	-1
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate #ifdef	__STDC__
61*7c478bd9Sstevel@tonic-gate typedef uint_t (*avfunc)(caddr_t, caddr_t);
62*7c478bd9Sstevel@tonic-gate #else
63*7c478bd9Sstevel@tonic-gate typedef uint_t (*avfunc)();
64*7c478bd9Sstevel@tonic-gate #endif	/* __STDC__ */
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate struct autovec {
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate 	/*
70*7c478bd9Sstevel@tonic-gate 	 * Interrupt handler and argument to pass to it.
71*7c478bd9Sstevel@tonic-gate 	 */
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate 	avfunc	av_vector;
74*7c478bd9Sstevel@tonic-gate 	caddr_t	av_intarg;
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate 	/*
77*7c478bd9Sstevel@tonic-gate 	 * Device that requested the interrupt, used as an id in case
78*7c478bd9Sstevel@tonic-gate 	 * we have to remove it later.
79*7c478bd9Sstevel@tonic-gate 	 */
80*7c478bd9Sstevel@tonic-gate 	dev_info_t *av_devi;
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate 	/*
83*7c478bd9Sstevel@tonic-gate 	 *
84*7c478bd9Sstevel@tonic-gate 	 * If this flag is true, then this is a 'fast' interrupt reservation.
85*7c478bd9Sstevel@tonic-gate 	 * Fast interrupts go directly out of the
86*7c478bd9Sstevel@tonic-gate 	 * trap table for speed and do not go through the normal autovector
87*7c478bd9Sstevel@tonic-gate 	 * interrupt setup code. There can be only one 'fast' interrupt
88*7c478bd9Sstevel@tonic-gate 	 * per autovector level.
89*7c478bd9Sstevel@tonic-gate 	 */
90*7c478bd9Sstevel@tonic-gate 	uint_t	av_fast;
91*7c478bd9Sstevel@tonic-gate };
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate extern const uint_t maxautovec;
96*7c478bd9Sstevel@tonic-gate extern struct autovec * const vectorlist[];
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate extern int add_avintr(dev_info_t *, int, avfunc, caddr_t);
99*7c478bd9Sstevel@tonic-gate extern void rem_avintr(dev_info_t *, int, avfunc);
100*7c478bd9Sstevel@tonic-gate extern int settrap(dev_info_t *, int, avfunc);
101*7c478bd9Sstevel@tonic-gate extern int not_serviced(int *, int, char *);
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate extern void wait_till_seen(int);
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate extern kmutex_t av_lock;
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
110*7c478bd9Sstevel@tonic-gate }
111*7c478bd9Sstevel@tonic-gate #endif
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate #endif /* _SYS_AVINTR_H */
114