xref: /titanic_52/usr/src/uts/sun4/sys/ivintr.h (revision b0fc0e77220f1fa4c933fd58a4e1dedcd650b0f1)
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*b0fc0e77Sgovinda  * Common Development and Distribution License (the "License").
6*b0fc0e77Sgovinda  * 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  */
217c478bd9Sstevel@tonic-gate /*
22*b0fc0e77Sgovinda  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_IVINTR_H
277c478bd9Sstevel@tonic-gate #define	_SYS_IVINTR_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
35*b0fc0e77Sgovinda /* Software interrupt and other bit flags */
36*b0fc0e77Sgovinda #define	IV_SOFTINT_PEND	0x1	/* Software interrupt is pending */
37*b0fc0e77Sgovinda #define	IV_SOFTINT_MT	0x2	/* Multi target software interrupt */
38*b0fc0e77Sgovinda #define	IV_CACHE_ALLOC	0x4	/* Allocated using kmem_cache_alloc() */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /*
41*b0fc0e77Sgovinda  * Reserve some interrupt vector data structures for the hardware and software
42*b0fc0e77Sgovinda  * interrupts.
437c478bd9Sstevel@tonic-gate  *
44*b0fc0e77Sgovinda  * NOTE: Need two single target software interrupts per cpu for cyclics.
457c478bd9Sstevel@tonic-gate  */
46*b0fc0e77Sgovinda #define	MAX_RSVD_IV	((NCPU * 2) + 256) /* HW and Single target SW intrs */
47*b0fc0e77Sgovinda #define	MAX_RSVD_IVX	32		/* Multi target software intrs */
48*b0fc0e77Sgovinda 
49*b0fc0e77Sgovinda #ifndef _ASM
50*b0fc0e77Sgovinda 
51*b0fc0e77Sgovinda typedef	uint_t (*intrfunc)(caddr_t, caddr_t);
52*b0fc0e77Sgovinda typedef	uint_t (*softintrfunc)(caddr_t, caddr_t);
53*b0fc0e77Sgovinda typedef	struct intr_vec intr_vec_t;
54*b0fc0e77Sgovinda typedef	struct intr_vecx intr_vecx_t;
55*b0fc0e77Sgovinda 
56*b0fc0e77Sgovinda /* Software interrupt type */
57*b0fc0e77Sgovinda typedef enum softint_type {
58*b0fc0e77Sgovinda 	SOFTINT_ST 	= (ushort_t)0,	/* Single target */
59*b0fc0e77Sgovinda 	SOFTINT_MT	= (ushort_t)1	/* Multi target */
60*b0fc0e77Sgovinda } softint_type_t;
61*b0fc0e77Sgovinda 
62*b0fc0e77Sgovinda /*
63*b0fc0e77Sgovinda  * Interrupt Vector Structure.
64*b0fc0e77Sgovinda  *
65*b0fc0e77Sgovinda  * Interrupt vector structure is allocated either from the reserved pool or
66*b0fc0e77Sgovinda  * dynamically using kmem cache method. For the hardware interrupts, one per
67*b0fc0e77Sgovinda  * vector with unique pil basis, i.e, interrupts sharing the same ino and the
68*b0fc0e77Sgovinda  * same pil do share the same structure.
69*b0fc0e77Sgovinda  *
70*b0fc0e77Sgovinda  * Used by Hardware and Single target Software interrupts.
71*b0fc0e77Sgovinda  */
72*b0fc0e77Sgovinda struct intr_vec {
73*b0fc0e77Sgovinda 	ushort_t	iv_inum;	/* MDB: interrupt mondo number */
74*b0fc0e77Sgovinda 	ushort_t	iv_pil;		/* Interrupt priority level */
75*b0fc0e77Sgovinda 	ushort_t	iv_flags;	/* SW interrupt and other bit flags */
76*b0fc0e77Sgovinda 	uint8_t		iv_pad[10];	/* Align on cache line boundary */
77*b0fc0e77Sgovinda 
78*b0fc0e77Sgovinda 	intrfunc	iv_handler;	/* ISR */
79*b0fc0e77Sgovinda 	caddr_t		iv_arg1;	/* ISR arg1 */
80*b0fc0e77Sgovinda 	caddr_t		iv_arg2;	/* ISR arg2 */
81*b0fc0e77Sgovinda 	caddr_t		iv_payload_buf;	/* Sun4v: mondo payload, epkt */
82*b0fc0e77Sgovinda 
83*b0fc0e77Sgovinda 	intr_vec_t	*iv_vec_next;	/* Per vector list */
84*b0fc0e77Sgovinda 	intr_vec_t	*iv_pil_next;	/* Per PIL list */
857c478bd9Sstevel@tonic-gate };
867c478bd9Sstevel@tonic-gate 
87*b0fc0e77Sgovinda /*
88*b0fc0e77Sgovinda  * Extended version of Interrupt Vector Structure.
89*b0fc0e77Sgovinda  *
90*b0fc0e77Sgovinda  * Used by Multi target Software interrupts.
91*b0fc0e77Sgovinda  */
92*b0fc0e77Sgovinda struct intr_vecx {
93*b0fc0e77Sgovinda 	intr_vec_t	iv_vec;		/* CPU0 uses iv_pil_next */
94*b0fc0e77Sgovinda 	intr_vec_t	*iv_pil_xnext[NCPU -1]; /* For CPU1 through N-1 */
95*b0fc0e77Sgovinda };
967c478bd9Sstevel@tonic-gate 
97*b0fc0e77Sgovinda #define	IV_GET_PIL_NEXT(iv_p, cpu_id) \
98*b0fc0e77Sgovinda 	(((iv_p->iv_flags & IV_SOFTINT_MT) && (cpu_id != 0)) ? \
99*b0fc0e77Sgovinda 	((intr_vecx_t *)iv_p)->iv_pil_xnext[cpu_id - 1] : iv_p->iv_pil_next)
100*b0fc0e77Sgovinda #define	IV_SET_PIL_NEXT(iv_p, cpu_id, next) \
101*b0fc0e77Sgovinda 	(((iv_p->iv_flags & IV_SOFTINT_MT) && (cpu_id != 0)) ? \
102*b0fc0e77Sgovinda 	(((intr_vecx_t *)iv_p)->iv_pil_xnext[cpu_id - 1] = next) : \
103*b0fc0e77Sgovinda 	(iv_p->iv_pil_next = next))
104*b0fc0e77Sgovinda 
105*b0fc0e77Sgovinda extern  uint64_t intr_vec_table[];
106*b0fc0e77Sgovinda 
1077c478bd9Sstevel@tonic-gate extern	void init_ivintr(void);
108*b0fc0e77Sgovinda extern	void fini_ivintr(void);
1097c478bd9Sstevel@tonic-gate 
110*b0fc0e77Sgovinda extern	int add_ivintr(uint_t inum, uint_t pil, intrfunc intr_handler,
111*b0fc0e77Sgovinda 	caddr_t intr_arg1, caddr_t intr_arg2, caddr_t intr_payload);
112*b0fc0e77Sgovinda extern	int rem_ivintr(uint_t inum, uint_t pil);
113*b0fc0e77Sgovinda 
114*b0fc0e77Sgovinda extern	uint64_t add_softintr(uint_t pil, softintrfunc intr_handler,
115*b0fc0e77Sgovinda 	caddr_t intr_arg1, softint_type_t type);
116*b0fc0e77Sgovinda extern	int rem_softintr(uint64_t softint_id);
117*b0fc0e77Sgovinda extern	int update_softint_arg2(uint64_t softint_id, caddr_t intr_arg2);
118*b0fc0e77Sgovinda extern	int update_softint_pri(uint64_t softint_id, uint_t pil);
119*b0fc0e77Sgovinda 
120*b0fc0e77Sgovinda #endif	/* !_ASM */
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1237c478bd9Sstevel@tonic-gate }
1247c478bd9Sstevel@tonic-gate #endif
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate #endif	/* _SYS_IVINTR_H */
127