xref: /illumos-gate/usr/src/uts/sun4/sys/ivintr.h (revision b48b4544)
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
5b0fc0e77Sgovinda  * Common Development and Distribution License (the "License").
6b0fc0e77Sgovinda  * 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*b48b4544SGangadhar Mylapuram  * Copyright 2010 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 
29*b48b4544SGangadhar Mylapuram #include <sys/intreg.h>
30*b48b4544SGangadhar Mylapuram #include <sys/param.h>
31*b48b4544SGangadhar Mylapuram 
327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
337c478bd9Sstevel@tonic-gate extern "C" {
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
36b0fc0e77Sgovinda /* Software interrupt and other bit flags */
37b0fc0e77Sgovinda #define	IV_SOFTINT_PEND	0x1	/* Software interrupt is pending */
38b0fc0e77Sgovinda #define	IV_SOFTINT_MT	0x2	/* Multi target software interrupt */
39b0fc0e77Sgovinda #define	IV_CACHE_ALLOC	0x4	/* Allocated using kmem_cache_alloc() */
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
42b0fc0e77Sgovinda  * Reserve some interrupt vector data structures for the hardware and software
43b0fc0e77Sgovinda  * interrupts.
447c478bd9Sstevel@tonic-gate  *
45b0fc0e77Sgovinda  * NOTE: Need two single target software interrupts per cpu for cyclics.
462850d85bSmv  *       Need one single target software interrupt per cpu for tick accounting.
477c478bd9Sstevel@tonic-gate  */
482850d85bSmv #define	MAX_RSVD_IV	((NCPU * 3) + 256) /* HW and Single target SW intrs */
49b0fc0e77Sgovinda #define	MAX_RSVD_IVX	32		/* Multi target software intrs */
50b0fc0e77Sgovinda 
51*b48b4544SGangadhar Mylapuram #define	IVSIZE	roundup(((MAXIVNUM * sizeof (intr_vec_t *)) + \
52*b48b4544SGangadhar Mylapuram 			(MAX_RSVD_IV * sizeof (intr_vec_t)) + \
53*b48b4544SGangadhar Mylapuram 			(MAX_RSVD_IVX * sizeof (intr_vecx_t))), PAGESIZE)
54*b48b4544SGangadhar Mylapuram 
55b0fc0e77Sgovinda #ifndef _ASM
56b0fc0e77Sgovinda 
57b0fc0e77Sgovinda typedef	uint_t (*intrfunc)(caddr_t, caddr_t);
58b0fc0e77Sgovinda typedef	uint_t (*softintrfunc)(caddr_t, caddr_t);
59b0fc0e77Sgovinda typedef	struct intr_vec intr_vec_t;
60b0fc0e77Sgovinda typedef	struct intr_vecx intr_vecx_t;
61b0fc0e77Sgovinda 
62492887eeSChristopher Baumbauer - Sun Microsystems - San Diego United States extern uint_t ignore_invalid_vecintr;
63492887eeSChristopher Baumbauer - Sun Microsystems - San Diego United States 
64b0fc0e77Sgovinda /* Software interrupt type */
65b0fc0e77Sgovinda typedef enum softint_type {
66b0fc0e77Sgovinda 	SOFTINT_ST 	= (ushort_t)0,	/* Single target */
67b0fc0e77Sgovinda 	SOFTINT_MT	= (ushort_t)1	/* Multi target */
68b0fc0e77Sgovinda } softint_type_t;
69b0fc0e77Sgovinda 
70b0fc0e77Sgovinda /*
71b0fc0e77Sgovinda  * Interrupt Vector Structure.
72b0fc0e77Sgovinda  *
73b0fc0e77Sgovinda  * Interrupt vector structure is allocated either from the reserved pool or
74b0fc0e77Sgovinda  * dynamically using kmem cache method. For the hardware interrupts, one per
75b0fc0e77Sgovinda  * vector with unique pil basis, i.e, interrupts sharing the same ino and the
76b0fc0e77Sgovinda  * same pil do share the same structure.
77b0fc0e77Sgovinda  *
78b0fc0e77Sgovinda  * Used by Hardware and Single target Software interrupts.
79b0fc0e77Sgovinda  */
80b0fc0e77Sgovinda struct intr_vec {
81b0fc0e77Sgovinda 	ushort_t	iv_inum;	/* MDB: interrupt mondo number */
82b0fc0e77Sgovinda 	ushort_t	iv_pil;		/* Interrupt priority level */
83b0fc0e77Sgovinda 	ushort_t	iv_flags;	/* SW interrupt and other bit flags */
84b0fc0e77Sgovinda 	uint8_t		iv_pad[10];	/* Align on cache line boundary */
85b0fc0e77Sgovinda 
86b0fc0e77Sgovinda 	intrfunc	iv_handler;	/* ISR */
87b0fc0e77Sgovinda 	caddr_t		iv_arg1;	/* ISR arg1 */
88b0fc0e77Sgovinda 	caddr_t		iv_arg2;	/* ISR arg2 */
89b0fc0e77Sgovinda 	caddr_t		iv_payload_buf;	/* Sun4v: mondo payload, epkt */
90b0fc0e77Sgovinda 
91b0fc0e77Sgovinda 	intr_vec_t	*iv_vec_next;	/* Per vector list */
92b0fc0e77Sgovinda 	intr_vec_t	*iv_pil_next;	/* Per PIL list */
937c478bd9Sstevel@tonic-gate };
947c478bd9Sstevel@tonic-gate 
95b0fc0e77Sgovinda /*
96b0fc0e77Sgovinda  * Extended version of Interrupt Vector Structure.
97b0fc0e77Sgovinda  *
98b0fc0e77Sgovinda  * Used by Multi target Software interrupts.
99b0fc0e77Sgovinda  */
100b0fc0e77Sgovinda struct intr_vecx {
101b0fc0e77Sgovinda 	intr_vec_t	iv_vec;		/* CPU0 uses iv_pil_next */
102b0fc0e77Sgovinda 	intr_vec_t	*iv_pil_xnext[NCPU -1]; /* For CPU1 through N-1 */
103b0fc0e77Sgovinda };
104b0fc0e77Sgovinda 
105b0fc0e77Sgovinda #define	IV_GET_PIL_NEXT(iv_p, cpu_id) \
106b0fc0e77Sgovinda 	(((iv_p->iv_flags & IV_SOFTINT_MT) && (cpu_id != 0)) ? \
107b0fc0e77Sgovinda 	((intr_vecx_t *)iv_p)->iv_pil_xnext[cpu_id - 1] : iv_p->iv_pil_next)
108b0fc0e77Sgovinda #define	IV_SET_PIL_NEXT(iv_p, cpu_id, next) \
109b0fc0e77Sgovinda 	(((iv_p->iv_flags & IV_SOFTINT_MT) && (cpu_id != 0)) ? \
110b0fc0e77Sgovinda 	(((intr_vecx_t *)iv_p)->iv_pil_xnext[cpu_id - 1] = next) : \
111b0fc0e77Sgovinda 	(iv_p->iv_pil_next = next))
112b0fc0e77Sgovinda 
113b0fc0e77Sgovinda extern  uint64_t intr_vec_table[];
114b0fc0e77Sgovinda 
115b0fc0e77Sgovinda extern	void init_ivintr(void);
116b0fc0e77Sgovinda extern	void fini_ivintr(void);
117b0fc0e77Sgovinda 
118b0fc0e77Sgovinda extern	int add_ivintr(uint_t inum, uint_t pil, intrfunc intr_handler,
119b0fc0e77Sgovinda 	caddr_t intr_arg1, caddr_t intr_arg2, caddr_t intr_payload);
120b0fc0e77Sgovinda extern	int rem_ivintr(uint_t inum, uint_t pil);
1217c478bd9Sstevel@tonic-gate 
122b0fc0e77Sgovinda extern	uint64_t add_softintr(uint_t pil, softintrfunc intr_handler,
123b0fc0e77Sgovinda 	caddr_t intr_arg1, softint_type_t type);
124b0fc0e77Sgovinda extern	int rem_softintr(uint64_t softint_id);
125b0fc0e77Sgovinda extern	int update_softint_arg2(uint64_t softint_id, caddr_t intr_arg2);
126b0fc0e77Sgovinda extern	int update_softint_pri(uint64_t softint_id, uint_t pil);
1277c478bd9Sstevel@tonic-gate 
128b0fc0e77Sgovinda #endif	/* !_ASM */
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1317c478bd9Sstevel@tonic-gate }
1327c478bd9Sstevel@tonic-gate #endif
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate #endif	/* _SYS_IVINTR_H */
135