xref: /titanic_52/usr/src/uts/sun4/sys/ivintr.h (revision 2850d85b7b93f31e578520dc3b3feb24db609c62)
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*2850d85bSmv143129  * Copyright 2008 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 
35b0fc0e77Sgovinda /* Software interrupt and other bit flags */
36b0fc0e77Sgovinda #define	IV_SOFTINT_PEND	0x1	/* Software interrupt is pending */
37b0fc0e77Sgovinda #define	IV_SOFTINT_MT	0x2	/* Multi target software interrupt */
38b0fc0e77Sgovinda #define	IV_CACHE_ALLOC	0x4	/* Allocated using kmem_cache_alloc() */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /*
41b0fc0e77Sgovinda  * Reserve some interrupt vector data structures for the hardware and software
42b0fc0e77Sgovinda  * interrupts.
437c478bd9Sstevel@tonic-gate  *
44b0fc0e77Sgovinda  * NOTE: Need two single target software interrupts per cpu for cyclics.
45*2850d85bSmv143129  *       Need one single target software interrupt per cpu for tick accounting.
467c478bd9Sstevel@tonic-gate  */
47*2850d85bSmv143129 #define	MAX_RSVD_IV	((NCPU * 3) + 256) /* HW and Single target SW intrs */
48b0fc0e77Sgovinda #define	MAX_RSVD_IVX	32		/* Multi target software intrs */
49b0fc0e77Sgovinda 
50b0fc0e77Sgovinda #ifndef _ASM
51b0fc0e77Sgovinda 
52b0fc0e77Sgovinda typedef	uint_t (*intrfunc)(caddr_t, caddr_t);
53b0fc0e77Sgovinda typedef	uint_t (*softintrfunc)(caddr_t, caddr_t);
54b0fc0e77Sgovinda typedef	struct intr_vec intr_vec_t;
55b0fc0e77Sgovinda typedef	struct intr_vecx intr_vecx_t;
56b0fc0e77Sgovinda 
57b0fc0e77Sgovinda /* Software interrupt type */
58b0fc0e77Sgovinda typedef enum softint_type {
59b0fc0e77Sgovinda 	SOFTINT_ST 	= (ushort_t)0,	/* Single target */
60b0fc0e77Sgovinda 	SOFTINT_MT	= (ushort_t)1	/* Multi target */
61b0fc0e77Sgovinda } softint_type_t;
62b0fc0e77Sgovinda 
63b0fc0e77Sgovinda /*
64b0fc0e77Sgovinda  * Interrupt Vector Structure.
65b0fc0e77Sgovinda  *
66b0fc0e77Sgovinda  * Interrupt vector structure is allocated either from the reserved pool or
67b0fc0e77Sgovinda  * dynamically using kmem cache method. For the hardware interrupts, one per
68b0fc0e77Sgovinda  * vector with unique pil basis, i.e, interrupts sharing the same ino and the
69b0fc0e77Sgovinda  * same pil do share the same structure.
70b0fc0e77Sgovinda  *
71b0fc0e77Sgovinda  * Used by Hardware and Single target Software interrupts.
72b0fc0e77Sgovinda  */
73b0fc0e77Sgovinda struct intr_vec {
74b0fc0e77Sgovinda 	ushort_t	iv_inum;	/* MDB: interrupt mondo number */
75b0fc0e77Sgovinda 	ushort_t	iv_pil;		/* Interrupt priority level */
76b0fc0e77Sgovinda 	ushort_t	iv_flags;	/* SW interrupt and other bit flags */
77b0fc0e77Sgovinda 	uint8_t		iv_pad[10];	/* Align on cache line boundary */
78b0fc0e77Sgovinda 
79b0fc0e77Sgovinda 	intrfunc	iv_handler;	/* ISR */
80b0fc0e77Sgovinda 	caddr_t		iv_arg1;	/* ISR arg1 */
81b0fc0e77Sgovinda 	caddr_t		iv_arg2;	/* ISR arg2 */
82b0fc0e77Sgovinda 	caddr_t		iv_payload_buf;	/* Sun4v: mondo payload, epkt */
83b0fc0e77Sgovinda 
84b0fc0e77Sgovinda 	intr_vec_t	*iv_vec_next;	/* Per vector list */
85b0fc0e77Sgovinda 	intr_vec_t	*iv_pil_next;	/* Per PIL list */
867c478bd9Sstevel@tonic-gate };
877c478bd9Sstevel@tonic-gate 
88b0fc0e77Sgovinda /*
89b0fc0e77Sgovinda  * Extended version of Interrupt Vector Structure.
90b0fc0e77Sgovinda  *
91b0fc0e77Sgovinda  * Used by Multi target Software interrupts.
92b0fc0e77Sgovinda  */
93b0fc0e77Sgovinda struct intr_vecx {
94b0fc0e77Sgovinda 	intr_vec_t	iv_vec;		/* CPU0 uses iv_pil_next */
95b0fc0e77Sgovinda 	intr_vec_t	*iv_pil_xnext[NCPU -1]; /* For CPU1 through N-1 */
96b0fc0e77Sgovinda };
977c478bd9Sstevel@tonic-gate 
98b0fc0e77Sgovinda #define	IV_GET_PIL_NEXT(iv_p, cpu_id) \
99b0fc0e77Sgovinda 	(((iv_p->iv_flags & IV_SOFTINT_MT) && (cpu_id != 0)) ? \
100b0fc0e77Sgovinda 	((intr_vecx_t *)iv_p)->iv_pil_xnext[cpu_id - 1] : iv_p->iv_pil_next)
101b0fc0e77Sgovinda #define	IV_SET_PIL_NEXT(iv_p, cpu_id, next) \
102b0fc0e77Sgovinda 	(((iv_p->iv_flags & IV_SOFTINT_MT) && (cpu_id != 0)) ? \
103b0fc0e77Sgovinda 	(((intr_vecx_t *)iv_p)->iv_pil_xnext[cpu_id - 1] = next) : \
104b0fc0e77Sgovinda 	(iv_p->iv_pil_next = next))
105b0fc0e77Sgovinda 
106b0fc0e77Sgovinda extern  uint64_t intr_vec_table[];
107b0fc0e77Sgovinda 
1087c478bd9Sstevel@tonic-gate extern	void init_ivintr(void);
109b0fc0e77Sgovinda extern	void fini_ivintr(void);
1107c478bd9Sstevel@tonic-gate 
111b0fc0e77Sgovinda extern	int add_ivintr(uint_t inum, uint_t pil, intrfunc intr_handler,
112b0fc0e77Sgovinda 	caddr_t intr_arg1, caddr_t intr_arg2, caddr_t intr_payload);
113b0fc0e77Sgovinda extern	int rem_ivintr(uint_t inum, uint_t pil);
114b0fc0e77Sgovinda 
115b0fc0e77Sgovinda extern	uint64_t add_softintr(uint_t pil, softintrfunc intr_handler,
116b0fc0e77Sgovinda 	caddr_t intr_arg1, softint_type_t type);
117b0fc0e77Sgovinda extern	int rem_softintr(uint64_t softint_id);
118b0fc0e77Sgovinda extern	int update_softint_arg2(uint64_t softint_id, caddr_t intr_arg2);
119b0fc0e77Sgovinda extern	int update_softint_pri(uint64_t softint_id, uint_t pil);
120b0fc0e77Sgovinda 
121b0fc0e77Sgovinda #endif	/* !_ASM */
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1247c478bd9Sstevel@tonic-gate }
1257c478bd9Sstevel@tonic-gate #endif
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate #endif	/* _SYS_IVINTR_H */
128