xref: /onnv-gate/usr/src/uts/sun4/sys/ivintr.h (revision 11444:a66b92050004)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52973Sgovinda  * Common Development and Distribution License (the "License").
62973Sgovinda  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*11444SGangadhar.M@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_IVINTR_H
270Sstevel@tonic-gate #define	_SYS_IVINTR_H
280Sstevel@tonic-gate 
29*11444SGangadhar.M@Sun.COM #include <sys/intreg.h>
30*11444SGangadhar.M@Sun.COM #include <sys/param.h>
31*11444SGangadhar.M@Sun.COM 
320Sstevel@tonic-gate #ifdef	__cplusplus
330Sstevel@tonic-gate extern "C" {
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate 
362973Sgovinda /* Software interrupt and other bit flags */
372973Sgovinda #define	IV_SOFTINT_PEND	0x1	/* Software interrupt is pending */
382973Sgovinda #define	IV_SOFTINT_MT	0x2	/* Multi target software interrupt */
392973Sgovinda #define	IV_CACHE_ALLOC	0x4	/* Allocated using kmem_cache_alloc() */
402973Sgovinda 
412973Sgovinda /*
422973Sgovinda  * Reserve some interrupt vector data structures for the hardware and software
432973Sgovinda  * interrupts.
442973Sgovinda  *
452973Sgovinda  * NOTE: Need two single target software interrupts per cpu for cyclics.
465788Smv143129  *       Need one single target software interrupt per cpu for tick accounting.
472973Sgovinda  */
485788Smv143129 #define	MAX_RSVD_IV	((NCPU * 3) + 256) /* HW and Single target SW intrs */
492973Sgovinda #define	MAX_RSVD_IVX	32		/* Multi target software intrs */
502973Sgovinda 
51*11444SGangadhar.M@Sun.COM #define	IVSIZE	roundup(((MAXIVNUM * sizeof (intr_vec_t *)) + \
52*11444SGangadhar.M@Sun.COM 			(MAX_RSVD_IV * sizeof (intr_vec_t)) + \
53*11444SGangadhar.M@Sun.COM 			(MAX_RSVD_IVX * sizeof (intr_vecx_t))), PAGESIZE)
54*11444SGangadhar.M@Sun.COM 
552973Sgovinda #ifndef _ASM
562973Sgovinda 
572973Sgovinda typedef	uint_t (*intrfunc)(caddr_t, caddr_t);
582973Sgovinda typedef	uint_t (*softintrfunc)(caddr_t, caddr_t);
592973Sgovinda typedef	struct intr_vec intr_vec_t;
602973Sgovinda typedef	struct intr_vecx intr_vecx_t;
612973Sgovinda 
627459SChristopher.Baumbauer@Sun.COM extern uint_t ignore_invalid_vecintr;
637459SChristopher.Baumbauer@Sun.COM 
642973Sgovinda /* Software interrupt type */
652973Sgovinda typedef enum softint_type {
662973Sgovinda 	SOFTINT_ST 	= (ushort_t)0,	/* Single target */
672973Sgovinda 	SOFTINT_MT	= (ushort_t)1	/* Multi target */
682973Sgovinda } softint_type_t;
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /*
712973Sgovinda  * Interrupt Vector Structure.
720Sstevel@tonic-gate  *
732973Sgovinda  * Interrupt vector structure is allocated either from the reserved pool or
742973Sgovinda  * dynamically using kmem cache method. For the hardware interrupts, one per
752973Sgovinda  * vector with unique pil basis, i.e, interrupts sharing the same ino and the
762973Sgovinda  * same pil do share the same structure.
772973Sgovinda  *
782973Sgovinda  * Used by Hardware and Single target Software interrupts.
790Sstevel@tonic-gate  */
802973Sgovinda struct intr_vec {
812973Sgovinda 	ushort_t	iv_inum;	/* MDB: interrupt mondo number */
822973Sgovinda 	ushort_t	iv_pil;		/* Interrupt priority level */
832973Sgovinda 	ushort_t	iv_flags;	/* SW interrupt and other bit flags */
842973Sgovinda 	uint8_t		iv_pad[10];	/* Align on cache line boundary */
852973Sgovinda 
862973Sgovinda 	intrfunc	iv_handler;	/* ISR */
872973Sgovinda 	caddr_t		iv_arg1;	/* ISR arg1 */
882973Sgovinda 	caddr_t		iv_arg2;	/* ISR arg2 */
892973Sgovinda 	caddr_t		iv_payload_buf;	/* Sun4v: mondo payload, epkt */
902973Sgovinda 
912973Sgovinda 	intr_vec_t	*iv_vec_next;	/* Per vector list */
922973Sgovinda 	intr_vec_t	*iv_pil_next;	/* Per PIL list */
930Sstevel@tonic-gate };
940Sstevel@tonic-gate 
952973Sgovinda /*
962973Sgovinda  * Extended version of Interrupt Vector Structure.
972973Sgovinda  *
982973Sgovinda  * Used by Multi target Software interrupts.
992973Sgovinda  */
1002973Sgovinda struct intr_vecx {
1012973Sgovinda 	intr_vec_t	iv_vec;		/* CPU0 uses iv_pil_next */
1022973Sgovinda 	intr_vec_t	*iv_pil_xnext[NCPU -1]; /* For CPU1 through N-1 */
1032973Sgovinda };
1040Sstevel@tonic-gate 
1052973Sgovinda #define	IV_GET_PIL_NEXT(iv_p, cpu_id) \
1062973Sgovinda 	(((iv_p->iv_flags & IV_SOFTINT_MT) && (cpu_id != 0)) ? \
1072973Sgovinda 	((intr_vecx_t *)iv_p)->iv_pil_xnext[cpu_id - 1] : iv_p->iv_pil_next)
1082973Sgovinda #define	IV_SET_PIL_NEXT(iv_p, cpu_id, next) \
1092973Sgovinda 	(((iv_p->iv_flags & IV_SOFTINT_MT) && (cpu_id != 0)) ? \
1102973Sgovinda 	(((intr_vecx_t *)iv_p)->iv_pil_xnext[cpu_id - 1] = next) : \
1112973Sgovinda 	(iv_p->iv_pil_next = next))
1122973Sgovinda 
1132973Sgovinda extern  uint64_t intr_vec_table[];
1140Sstevel@tonic-gate 
1152973Sgovinda extern	void init_ivintr(void);
1162973Sgovinda extern	void fini_ivintr(void);
1172973Sgovinda 
1182973Sgovinda extern	int add_ivintr(uint_t inum, uint_t pil, intrfunc intr_handler,
1192973Sgovinda 	caddr_t intr_arg1, caddr_t intr_arg2, caddr_t intr_payload);
1202973Sgovinda extern	int rem_ivintr(uint_t inum, uint_t pil);
1212973Sgovinda 
1222973Sgovinda extern	uint64_t add_softintr(uint_t pil, softintrfunc intr_handler,
1232973Sgovinda 	caddr_t intr_arg1, softint_type_t type);
1242973Sgovinda extern	int rem_softintr(uint64_t softint_id);
1252973Sgovinda extern	int update_softint_arg2(uint64_t softint_id, caddr_t intr_arg2);
1262973Sgovinda extern	int update_softint_pri(uint64_t softint_id, uint_t pil);
1272973Sgovinda 
1282973Sgovinda #endif	/* !_ASM */
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate #ifdef	__cplusplus
1310Sstevel@tonic-gate }
1320Sstevel@tonic-gate #endif
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate #endif	/* _SYS_IVINTR_H */
135