Home | History | Annotate | Line # | Download | only in booke
intr.h revision 1.5
      1 /*	$NetBSD: intr.h,v 1.5 2011/06/15 15:11:50 matt Exp $	*/
      2 /*-
      3  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
      4  * All rights reserved.
      5  *
      6  * This code is derived from software contributed to The NetBSD Foundation
      7  * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects
      8  * Agency and which was developed by Matt Thomas of 3am Software Foundry.
      9  *
     10  * This material is based upon work supported by the Defense Advanced Research
     11  * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under
     12  * Contract No. N66001-09-C-2073.
     13  * Approved for Public Release, Distribution Unlimited
     14  *
     15  * Redistribution and use in source and binary forms, with or without
     16  * modification, are permitted provided that the following conditions
     17  * are met:
     18  * 1. Redistributions of source code must retain the above copyright
     19  *    notice, this list of conditions and the following disclaimer.
     20  * 2. Redistributions in binary form must reproduce the above copyright
     21  *    notice, this list of conditions and the following disclaimer in the
     22  *    documentation and/or other materials provided with the distribution.
     23  *
     24  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     25  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     26  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     27  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     28  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     34  * POSSIBILITY OF SUCH DAMAGE.
     35  */
     36 
     37 #ifndef _BOOKE_INTR_H_
     38 #define _BOOKE_INTR_H_
     39 
     40 /* Interrupt priority `levels'. */
     41 #define	IPL_NONE	0	/* nothing */
     42 #define	IPL_SOFTCLOCK	1	/* software clock interrupt */
     43 #define	IPL_SOFTBIO	2	/* software block i/o interrupt */
     44 #define	IPL_SOFTNET	3	/* software network interrupt */
     45 #define	IPL_SOFTSERIAL	4	/* software serial interrupt */
     46 #define	IPL_VM		5	/* memory allocation */
     47 #define	IPL_SCHED	6	/* clock */
     48 #define	IPL_HIGH	7	/* everything */
     49 #define	NIPL		8
     50 
     51 /* Interrupt sharing types. */
     52 #define	IST_NONE	(NIPL+0) /* none */
     53 #define	IST_EDGE	(NIPL+1) /* edge-triggered */
     54 #define	IST_LEVEL	(NIPL+2) /* level-triggered active-low */
     55 #define	IST_LEVEL_LOW	IST_LEVEL
     56 #define	IST_LEVEL_HIGH	(NIPL+3) /* level-triggered active-high */
     57 #define	IST_PULSE	(NIPL+4) /* pulsed */
     58 #define	IST_MSI		(NIPL+5) /* message signaling interrupt (PCI) */
     59 #define	IST_ONCHIP	(NIPL+6) /* on-chip device */
     60 #ifdef __INTR_PRIVATE
     61 #define	IST_MSIGROUP	(NIPL+7) /* openpic msi groups */
     62 #define	IST_TIMER	(NIPL+8) /* openpic timers */
     63 #define	IST_IPI		(NIPL+9) /* openpic ipi */
     64 #define	IST_MI		(NIPL+10) /* openpic message */
     65 #define	IST_MAX		(NIPL+11)
     66 #endif
     67 
     68 #define	IPI_DST_ALL	((cpuid_t)-2)
     69 #define	IPI_DST_NOTME	((cpuid_t)-1)
     70 
     71 #define IPI_NOMESG	0x0000
     72 #define IPI_HALT	0x0001
     73 #define IPI_XCALL	0x0002
     74 #define	IPI_KPREEMPT	0x0004
     75 #define IPI_TLB1SYNC	0x0008
     76 
     77 #define	__HAVE_FAST_SOFTINTS	1
     78 #define	SOFTINT_KPREEMPT	SOFTINT_COUNT
     79 
     80 #ifndef _LOCORE
     81 
     82 void 	*intr_establish(int, int, int, int (*)(void *), void *);
     83 void 	intr_disestablish(void *);
     84 void	intr_cpu_attach(struct cpu_info *);
     85 void	intr_cpu_hatch(struct cpu_info *);
     86 void	intr_init(void);
     87 const char *
     88 	intr_string(int, int);
     89 const char *
     90 	intr_typename(int);
     91 
     92 void	cpu_send_ipi(cpuid_t, uint32_t);
     93 
     94 void	spl0(void);
     95 int 	splraise(int);
     96 void 	splx(int);
     97 #ifdef __INTR_NOINLINE
     98 int	splhigh(void);
     99 int	splsched(void);
    100 int	splvm(void);
    101 int	splsoftserial(void);
    102 int	splsoftnet(void);
    103 int	splsoftbio(void);
    104 int	splsoftclock(void);
    105 #endif
    106 
    107 typedef int ipl_t;
    108 typedef struct {
    109 	ipl_t _ipl;
    110 } ipl_cookie_t;
    111 
    112 #ifdef __INTR_PRIVATE
    113 
    114 struct intrsw {
    115 	void *(*intrsw_establish)(int, int, int, int (*)(void *), void *);
    116 	void (*intrsw_disestablish)(void *);
    117 	void (*intrsw_cpu_attach)(struct cpu_info *);
    118 	void (*intrsw_cpu_hatch)(struct cpu_info *);
    119 	void (*intrsw_cpu_send_ipi)(cpuid_t, uint32_t);
    120 	void (*intrsw_init)(void);
    121 	void (*intrsw_critintr)(struct trapframe *);
    122 	void (*intrsw_decrintr)(struct trapframe *);
    123 	void (*intrsw_extintr)(struct trapframe *);
    124 	void (*intrsw_fitintr)(struct trapframe *);
    125 	void (*intrsw_wdogintr)(struct trapframe *);
    126 	int (*intrsw_splraise)(int);
    127 	void (*intrsw_spl0)(void);
    128 	void (*intrsw_splx)(int);
    129 	const char *(*intrsw_string)(int, int);
    130 	const char *(*intrsw_typename)(int);
    131 #ifdef __HAVE_FAST_SOFTINTS
    132 	void (*intrsw_softint_init_md)(struct lwp *, u_int, uintptr_t *);
    133 	void (*intrsw_softint_trigger)(uintptr_t);
    134 #endif
    135 };
    136 
    137 extern const struct intrsw *powerpc_intrsw;
    138 void	softint_fast_dispatch(struct lwp *, int);
    139 #endif /* __INTR_PRIVATE */
    140 
    141 #ifndef __INTR_NOINLINE
    142 static inline int
    143 splhigh(void)
    144 {
    145 
    146 	return splraise(IPL_HIGH);
    147 }
    148 
    149 static inline int
    150 splsched(void)
    151 {
    152 
    153 	return splraise(IPL_SCHED);
    154 }
    155 
    156 static inline int
    157 splvm(void)
    158 {
    159 
    160 	return splraise(IPL_VM);
    161 }
    162 
    163 static inline int
    164 splsoftserial(void)
    165 {
    166 
    167 	return splraise(IPL_SOFTSERIAL);
    168 }
    169 
    170 static inline int
    171 splsoftnet(void)
    172 {
    173 
    174 	return splraise(IPL_SOFTNET);
    175 }
    176 
    177 static inline int
    178 splsoftbio(void)
    179 {
    180 
    181 	return splraise(IPL_SOFTBIO);
    182 }
    183 
    184 static inline int
    185 splsoftclock(void)
    186 {
    187 
    188 	return splraise(IPL_SOFTCLOCK);
    189 }
    190 
    191 static inline int
    192 splraiseipl(ipl_cookie_t icookie)
    193 {
    194 
    195 	return splraise(icookie._ipl);
    196 }
    197 
    198 static inline ipl_cookie_t
    199 makeiplcookie(ipl_t ipl)
    200 {
    201 
    202 	return (ipl_cookie_t){._ipl = ipl};
    203 }
    204 #endif /* !__INTR_NOINLINE */
    205 
    206 #endif /* !_LOCORE */
    207 #endif /* !_BOOKE_INTR_H_ */
    208