intr.h revision 1.1 1 1.1 matt /* $NetBSD: intr.h,v 1.1 2010/04/01 18:59:27 matt Exp $ */
2 1.1 matt
3 1.1 matt /*-
4 1.1 matt * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
5 1.1 matt * All rights reserved.
6 1.1 matt *
7 1.1 matt * This code is derived from software contributed to The NetBSD Foundation
8 1.1 matt * by Charles M. Hannum.
9 1.1 matt *
10 1.1 matt * Redistribution and use in source and binary forms, with or without
11 1.1 matt * modification, are permitted provided that the following conditions
12 1.1 matt * are met:
13 1.1 matt * 1. Redistributions of source code must retain the above copyright
14 1.1 matt * notice, this list of conditions and the following disclaimer.
15 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 matt * notice, this list of conditions and the following disclaimer in the
17 1.1 matt * documentation and/or other materials provided with the distribution.
18 1.1 matt *
19 1.1 matt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 matt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 matt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 matt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 matt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 matt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 matt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 matt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 matt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 matt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 matt * POSSIBILITY OF SUCH DAMAGE.
30 1.1 matt */
31 1.1 matt
32 1.1 matt #ifndef _BOOKE_INTR_H_
33 1.1 matt #define _BOOKE_INTR_H_
34 1.1 matt
35 1.1 matt /* Interrupt priority `levels'. */
36 1.1 matt #define IPL_NONE 0 /* nothing */
37 1.1 matt #define IPL_SOFTCLOCK 1 /* software clock interrupt */
38 1.1 matt #define IPL_SOFTBIO 2 /* software block i/o interrupt */
39 1.1 matt #define IPL_SOFTNET 3 /* software network interrupt */
40 1.1 matt #define IPL_SOFTSERIAL 4 /* software serial interrupt */
41 1.1 matt #define IPL_VM 5 /* memory allocation */
42 1.1 matt #define IPL_SCHED 6 /* clock */
43 1.1 matt #define IPL_HIGH 7 /* everything */
44 1.1 matt #define NIPL 8
45 1.1 matt
46 1.1 matt /* Interrupt sharing types. */
47 1.1 matt #define IST_NONE 0 /* none */
48 1.1 matt #define IST_EDGE 1 /* edge-triggered */
49 1.1 matt #define IST_LEVEL 2 /* level-triggered active-low */
50 1.1 matt #define IST_LEVEL_LOW IST_LEVEL
51 1.1 matt #define IST_LEVEL_HIGH 3 /* level-triggered active-high */
52 1.1 matt #define IST_MSI 4 /* message signaling interrupt (PCI) */
53 1.1 matt #define IST_ONCHIP 5 /* on-chip device */
54 1.1 matt #ifdef __INTR_PRIVATE
55 1.1 matt #define IST_MSIGROUP 6 /* openpic msi groups */
56 1.1 matt #define IST_TIMER 7 /* openpic timers */
57 1.1 matt #define IST_IPI 8 /* openpic ipi */
58 1.1 matt #define IST_MI 9 /* openpic message */
59 1.1 matt #endif
60 1.1 matt
61 1.1 matt #ifndef _LOCORE
62 1.1 matt
63 1.1 matt void *intr_establish(int, int, int, int (*)(void *), void *);
64 1.1 matt void intr_disestablish(void *);
65 1.1 matt int spl0(void);
66 1.1 matt int splraise(int);
67 1.1 matt void splx(int);
68 1.1 matt
69 1.1 matt typedef int ipl_t;
70 1.1 matt typedef struct {
71 1.1 matt ipl_t _ipl;
72 1.1 matt } ipl_cookie_t;
73 1.1 matt
74 1.1 matt #ifdef __INTR_PRIVATE
75 1.1 matt #include <sys/lwp.h>
76 1.1 matt
77 1.1 matt struct intrsw {
78 1.1 matt void *(*intrsw_establish)(int, int, int, int (*)(void *), void *);
79 1.1 matt void (*intrsw_disestablish)(void *);
80 1.1 matt void (*intrsw_cpu_init)(struct cpu_info *);
81 1.1 matt void (*intrsw_init)(void);
82 1.1 matt void (*intrsw_critintr)(struct trapframe *);
83 1.1 matt void (*intrsw_decrintr)(struct trapframe *);
84 1.1 matt void (*intrsw_extintr)(struct trapframe *);
85 1.1 matt void (*intrsw_fitintr)(struct trapframe *);
86 1.1 matt void (*intrsw_wdogintr)(struct trapframe *);
87 1.1 matt int (*intrsw_splraise)(int);
88 1.1 matt int (*intrsw_spl0)(void);
89 1.1 matt void (*intrsw_splx)(int);
90 1.1 matt #ifdef __HAVE_FAST_SOFTINTS
91 1.1 matt void (*intrsw_softint_init_md)(lwp_t *, u_int, uintptr_t *);
92 1.1 matt void (*intrsw_softint_trigger)(uintptr_t);
93 1.1 matt #endif
94 1.1 matt };
95 1.1 matt
96 1.1 matt extern struct intrsw powerpc_intrsw;
97 1.1 matt #endif /* __INTR_PRIVATE */
98 1.1 matt
99 1.1 matt static inline int
100 1.1 matt splhigh(void)
101 1.1 matt {
102 1.1 matt
103 1.1 matt return splraise(IPL_HIGH);
104 1.1 matt }
105 1.1 matt
106 1.1 matt static inline int
107 1.1 matt splsched(void)
108 1.1 matt {
109 1.1 matt
110 1.1 matt return splraise(IPL_SCHED);
111 1.1 matt }
112 1.1 matt
113 1.1 matt static inline int
114 1.1 matt splvm(void)
115 1.1 matt {
116 1.1 matt
117 1.1 matt return splraise(IPL_VM);
118 1.1 matt }
119 1.1 matt
120 1.1 matt static inline int
121 1.1 matt splsoftserial(void)
122 1.1 matt {
123 1.1 matt
124 1.1 matt return splraise(IPL_SOFTSERIAL);
125 1.1 matt }
126 1.1 matt
127 1.1 matt static inline int
128 1.1 matt splsoftnet(void)
129 1.1 matt {
130 1.1 matt
131 1.1 matt return splraise(IPL_SOFTNET);
132 1.1 matt }
133 1.1 matt
134 1.1 matt static inline int
135 1.1 matt splsoftbio(void)
136 1.1 matt {
137 1.1 matt
138 1.1 matt return splraise(IPL_SOFTBIO);
139 1.1 matt }
140 1.1 matt
141 1.1 matt static inline int
142 1.1 matt splsoftclock(void)
143 1.1 matt {
144 1.1 matt
145 1.1 matt return splraise(IPL_SOFTCLOCK);
146 1.1 matt }
147 1.1 matt
148 1.1 matt static inline int
149 1.1 matt splraiseipl(ipl_cookie_t icookie)
150 1.1 matt {
151 1.1 matt
152 1.1 matt return splraise(icookie._ipl);
153 1.1 matt }
154 1.1 matt
155 1.1 matt static inline ipl_cookie_t
156 1.1 matt makeiplcookie(ipl_t ipl)
157 1.1 matt {
158 1.1 matt
159 1.1 matt return (ipl_cookie_t){._ipl = ipl};
160 1.1 matt }
161 1.1 matt
162 1.1 matt #endif /* !_LOCORE */
163 1.1 matt #endif /* !_BOOKE_INTR_H_ */
164