intr.h revision 1.27.4.1 1 1.27.4.1 ad /* $NetBSD: intr.h,v 1.27.4.1 2007/01/12 01:00:57 ad Exp $ */
2 1.1 nonaka
3 1.1 nonaka /*-
4 1.1 nonaka * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 1.1 nonaka * All rights reserved.
6 1.1 nonaka *
7 1.1 nonaka * This code is derived from software contributed to The NetBSD Foundation
8 1.1 nonaka * by Charles M. Hannum.
9 1.1 nonaka *
10 1.1 nonaka * Redistribution and use in source and binary forms, with or without
11 1.1 nonaka * modification, are permitted provided that the following conditions
12 1.1 nonaka * are met:
13 1.1 nonaka * 1. Redistributions of source code must retain the above copyright
14 1.1 nonaka * notice, this list of conditions and the following disclaimer.
15 1.1 nonaka * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 nonaka * notice, this list of conditions and the following disclaimer in the
17 1.1 nonaka * documentation and/or other materials provided with the distribution.
18 1.1 nonaka * 3. All advertising materials mentioning features or use of this software
19 1.1 nonaka * must display the following acknowledgement:
20 1.1 nonaka * This product includes software developed by the NetBSD
21 1.1 nonaka * Foundation, Inc. and its contributors.
22 1.1 nonaka * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 nonaka * contributors may be used to endorse or promote products derived
24 1.1 nonaka * from this software without specific prior written permission.
25 1.1 nonaka *
26 1.1 nonaka * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 nonaka * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 nonaka * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 nonaka * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 nonaka * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 nonaka * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 nonaka * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 nonaka * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 nonaka * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 nonaka * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 nonaka * POSSIBILITY OF SUCH DAMAGE.
37 1.1 nonaka */
38 1.1 nonaka
39 1.1 nonaka #ifndef _PREP_INTR_H_
40 1.1 nonaka #define _PREP_INTR_H_
41 1.1 nonaka
42 1.1 nonaka /* Interrupt priority `levels'. */
43 1.1 nonaka #define IPL_NONE 9 /* nothing */
44 1.1 nonaka #define IPL_SOFTCLOCK 8 /* software clock interrupt */
45 1.1 nonaka #define IPL_SOFTNET 7 /* software network interrupt */
46 1.1 nonaka #define IPL_BIO 6 /* block I/O */
47 1.1 nonaka #define IPL_NET 5 /* network */
48 1.1 nonaka #define IPL_SOFTSERIAL 4 /* software serial interrupt */
49 1.1 nonaka #define IPL_TTY 3 /* terminal */
50 1.27.4.1 ad #define IPL_LPT IPL_TTY
51 1.18 thorpej #define IPL_VM 3 /* memory allocation */
52 1.1 nonaka #define IPL_AUDIO 2 /* audio */
53 1.1 nonaka #define IPL_CLOCK 1 /* clock */
54 1.27.4.1 ad #define IPL_STATCLOCK IPL_CLOCK
55 1.1 nonaka #define IPL_HIGH 1 /* everything */
56 1.27.4.1 ad #define IPL_SCHED IPL_HIGH
57 1.27.4.1 ad #define IPL_LOCK IPL_HIGH
58 1.1 nonaka #define IPL_SERIAL 0 /* serial */
59 1.1 nonaka #define NIPL 10
60 1.1 nonaka
61 1.1 nonaka /* Interrupt sharing types. */
62 1.1 nonaka #define IST_NONE 0 /* none */
63 1.1 nonaka #define IST_PULSE 1 /* pulsed */
64 1.1 nonaka #define IST_EDGE 2 /* edge-triggered */
65 1.1 nonaka #define IST_LEVEL 3 /* level-triggered */
66 1.1 nonaka
67 1.1 nonaka #ifndef _LOCORE
68 1.24 garbled #include <powerpc/softintr.h>
69 1.25 garbled #include <machine/cpu.h>
70 1.1 nonaka
71 1.1 nonaka /*
72 1.1 nonaka * Interrupt handler chains. intr_establish() inserts a handler into
73 1.1 nonaka * the list. The handler is called with its (single) argument.
74 1.1 nonaka */
75 1.1 nonaka struct intrhand {
76 1.10 nonaka int (*ih_fun)(void *);
77 1.1 nonaka void *ih_arg;
78 1.1 nonaka u_long ih_count;
79 1.1 nonaka struct intrhand *ih_next;
80 1.1 nonaka int ih_level;
81 1.1 nonaka int ih_irq;
82 1.1 nonaka };
83 1.1 nonaka
84 1.25 garbled #include <sys/device.h>
85 1.25 garbled struct intrsource {
86 1.25 garbled int is_type;
87 1.25 garbled int is_level;
88 1.25 garbled int is_hwirq;
89 1.25 garbled int is_mask;
90 1.25 garbled struct intrhand *is_hand;
91 1.25 garbled struct evcnt is_ev;
92 1.25 garbled char is_source[16];
93 1.25 garbled };
94 1.25 garbled
95 1.25 garbled int splraise(int);
96 1.25 garbled int spllower(int);
97 1.25 garbled void softintr(int);
98 1.25 garbled
99 1.10 nonaka void do_pending_int(void);
100 1.1 nonaka
101 1.16 nonaka void init_intr(void);
102 1.16 nonaka void init_intr_ivr(void);
103 1.16 nonaka void init_intr_openpic(void);
104 1.26 garbled void openpic_init(unsigned char *);
105 1.1 nonaka
106 1.10 nonaka void enable_intr(void);
107 1.10 nonaka void disable_intr(void);
108 1.1 nonaka
109 1.10 nonaka void *intr_establish(int, int, int, int (*)(void *), void *);
110 1.10 nonaka void intr_disestablish(void *);
111 1.1 nonaka
112 1.17 matt void softnet(int);
113 1.10 nonaka void softserial(void);
114 1.11 matt int isa_intr(void);
115 1.11 matt void isa_intr_mask(int);
116 1.11 matt void isa_intr_clr(int);
117 1.11 matt void isa_setirqstat(int, int, int);
118 1.1 nonaka
119 1.10 nonaka extern int imen;
120 1.1 nonaka extern int imask[];
121 1.5 matt extern struct intrhand *intrhand[];
122 1.12 kleink extern vaddr_t prep_intr_reg;
123 1.27 garbled extern uint32_t prep_intr_reg_off;
124 1.8 nonaka
125 1.25 garbled #define ICU_LEN 32
126 1.25 garbled extern struct intrsource intrsources[ICU_LEN];
127 1.1 nonaka
128 1.16 nonaka #define IRQ_SLAVE 2
129 1.16 nonaka #define LEGAL_IRQ(x) ((x) >= 0 && (x) < ICU_LEN && (x) != IRQ_SLAVE)
130 1.16 nonaka #define I8259_INTR_NUM 16
131 1.16 nonaka #define OPENPIC_INTR_NUM ((ICU_LEN)-(I8259_INTR_NUM))
132 1.19 matt #define CLKF_BASEPRI(frame) ((frame)->pri == 0)
133 1.1 nonaka
134 1.1 nonaka #define PREP_INTR_REG 0xbffff000
135 1.1 nonaka #define INTR_VECTOR_REG 0xff0
136 1.1 nonaka
137 1.1 nonaka #define SINT_CLOCK 0x20000000
138 1.1 nonaka #define SINT_NET 0x40000000
139 1.1 nonaka #define SINT_SERIAL 0x80000000
140 1.1 nonaka #define SPL_CLOCK 0x00000001
141 1.1 nonaka #define SINT_MASK (SINT_CLOCK|SINT_NET|SINT_SERIAL)
142 1.1 nonaka
143 1.1 nonaka #define CNT_SINT_NET 29
144 1.1 nonaka #define CNT_SINT_CLOCK 30
145 1.1 nonaka #define CNT_SINT_SERIAL 31
146 1.1 nonaka #define CNT_CLOCK 0
147 1.1 nonaka
148 1.1 nonaka #define spllowersoftclock() spllower(imask[IPL_SOFTCLOCK])
149 1.1 nonaka
150 1.25 garbled #define setsoftclock() softintr(SINT_CLOCK);
151 1.25 garbled #define setsoftnet() softintr(SINT_NET);
152 1.25 garbled #define setsoftserial() softintr(SINT_SERIAL);
153 1.1 nonaka
154 1.2 kleink #define splx(x) spllower(x)
155 1.1 nonaka #define spl0() spllower(0)
156 1.1 nonaka
157 1.27.4.1 ad typedef int ipl_t;
158 1.27.4.1 ad typedef struct {
159 1.27.4.1 ad ipl_t _ipl;
160 1.27.4.1 ad } ipl_cookie_t;
161 1.27.4.1 ad
162 1.27.4.1 ad static inline ipl_cookie_t
163 1.27.4.1 ad makeiplcookie(ipl_t ipl)
164 1.27.4.1 ad {
165 1.27.4.1 ad
166 1.27.4.1 ad return (ipl_cookie_t){._ipl = ipl};
167 1.27.4.1 ad }
168 1.27.4.1 ad
169 1.27.4.1 ad static inline int
170 1.27.4.1 ad splraiseipl(ipl_cookie_t icookie)
171 1.27.4.1 ad {
172 1.27.4.1 ad
173 1.27.4.1 ad return splraise(imask[icookie._ipl]);
174 1.27.4.1 ad }
175 1.27.4.1 ad
176 1.27.4.1 ad #include <sys/spl.h>
177 1.27.4.1 ad
178 1.1 nonaka #endif /* !_LOCORE */
179 1.1 nonaka
180 1.1 nonaka #endif /* !_PREP_INTR_H_ */
181