intr.h revision 1.1 1 1.1 skrll /* $NetBSD: intr.h,v 1.1 2014/02/24 07:23:43 skrll Exp $ */
2 1.1 skrll /* $OpenBSD: intr.h,v 1.26 2009/12/29 13:11:40 jsing Exp $ */
3 1.1 skrll
4 1.1 skrll /*-
5 1.1 skrll * Copyright (c) 1998, 2001, 2002 The NetBSD Foundation, Inc.
6 1.1 skrll * All rights reserved.
7 1.1 skrll *
8 1.1 skrll * This code is derived from software contributed to The NetBSD Foundation
9 1.1 skrll * by Charles M. Hannum, and by Jason R. Thorpe, and by Matthew Fredette.
10 1.1 skrll *
11 1.1 skrll * Redistribution and use in source and binary forms, with or without
12 1.1 skrll * modification, are permitted provided that the following conditions
13 1.1 skrll * are met:
14 1.1 skrll * 1. Redistributions of source code must retain the above copyright
15 1.1 skrll * notice, this list of conditions and the following disclaimer.
16 1.1 skrll * 2. Redistributions in binary form must reproduce the above copyright
17 1.1 skrll * notice, this list of conditions and the following disclaimer in the
18 1.1 skrll * documentation and/or other materials provided with the distribution.
19 1.1 skrll *
20 1.1 skrll * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 1.1 skrll * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 1.1 skrll * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 1.1 skrll * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 1.1 skrll * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 1.1 skrll * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 1.1 skrll * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 1.1 skrll * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 1.1 skrll * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 1.1 skrll * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 1.1 skrll * POSSIBILITY OF SUCH DAMAGE.
31 1.1 skrll */
32 1.1 skrll
33 1.1 skrll #ifndef _HPPA_INTR_H_
34 1.1 skrll #define _HPPA_INTR_H_
35 1.1 skrll
36 1.1 skrll #include <machine/psl.h>
37 1.1 skrll #include <machine/intrdefs.h>
38 1.1 skrll
39 1.1 skrll #include <sys/evcnt.h>
40 1.1 skrll
41 1.1 skrll #ifndef _LOCORE
42 1.1 skrll
43 1.1 skrll #ifdef _KERNEL
44 1.1 skrll
45 1.1 skrll struct cpu_info;
46 1.1 skrll
47 1.1 skrll /*
48 1.1 skrll * The maximum number of bits in a cpl value/spl mask, the maximum number of
49 1.1 skrll * bits in an interrupt request register, and the maximum number of interrupt
50 1.1 skrll * registers.
51 1.1 skrll */
52 1.1 skrll #define HPPA_INTERRUPT_BITS (32)
53 1.1 skrll #define CPU_NINTS HPPA_INTERRUPT_BITS /* Use this one */
54 1.1 skrll
55 1.1 skrll /*
56 1.1 skrll * This describes one HPPA interrupt register.
57 1.1 skrll */
58 1.1 skrll struct hppa_interrupt_register {
59 1.1 skrll bool ir_iscpu;
60 1.1 skrll const char *ir_name; /* name for this intr reg */
61 1.1 skrll struct cpu_info *ir_ci; /* cpu this intr reg */
62 1.1 skrll
63 1.1 skrll /*
64 1.1 skrll * The virtual address of the mask, request and level
65 1.1 skrll * registers.
66 1.1 skrll */
67 1.1 skrll volatile int *ir_mask;
68 1.1 skrll volatile int *ir_req;
69 1.1 skrll volatile int *ir_level;
70 1.1 skrll
71 1.1 skrll /*
72 1.1 skrll * This array has one entry for each bit in the interrupt request
73 1.1 skrll * register.
74 1.1 skrll *
75 1.1 skrll * If the 24 most significant bits are set, the low 8 bits are the
76 1.1 skrll * index of the hppa_interrupt_register that this interrupt bit leads
77 1.1 skrll * to, with zero meaning that the interrupt bit is unused.
78 1.1 skrll *
79 1.1 skrll * Otherwise these bits correspond to hppa_interrupt_bits. That is,
80 1.1 skrll * these bits are ORed to ipending_new in hppa_intr_ipending() when
81 1.1 skrll * an interrupt happens.
82 1.1 skrll *
83 1.1 skrll * Note that this array is indexed by HP bit number, *not* by "normal"
84 1.1 skrll * bit number. In other words, the least significant bit in the inter-
85 1.1 skrll * rupt register corresponds to array index 31.
86 1.1 skrll */
87 1.1 skrll
88 1.1 skrll unsigned int ir_bits_map[HPPA_INTERRUPT_BITS];
89 1.1 skrll
90 1.1 skrll #define IR_BIT_MASK 0xffffff00
91 1.1 skrll #define IR_BIT_REG(x) (IR_BIT_MASK | (x))
92 1.1 skrll #define IR_BIT_UNUSED IR_BIT_REG(0)
93 1.1 skrll #define IR_BIT_USED_P(x) (((x) & IR_BIT_MASK) != IR_BIT_MASK)
94 1.1 skrll #define IR_BIT_NESTED_P(x) (((x) & IR_BIT_MASK) == IR_BIT_MASK)
95 1.1 skrll
96 1.1 skrll int ir_bits; /* mask of allocatable bit numbers */
97 1.1 skrll int ir_rbits; /* mask of reserved (for lasi/asp) bit numbers */
98 1.1 skrll };
99 1.1 skrll
100 1.1 skrll struct hppa_interrupt_bit {
101 1.1 skrll
102 1.1 skrll /*
103 1.1 skrll * The interrupt register this bit is in. Some handlers, e.g
104 1.1 skrll * apic_intr, don't make use of an hppa_interrupt_register, but are
105 1.1 skrll * nested.
106 1.1 skrll */
107 1.1 skrll struct hppa_interrupt_register *ib_reg;
108 1.1 skrll
109 1.1 skrll /*
110 1.1 skrll * The priority level associated with this bit, e.g, IPL_BIO, IPL_NET,
111 1.1 skrll * etc.
112 1.1 skrll */
113 1.1 skrll int ib_ipl;
114 1.1 skrll
115 1.1 skrll /*
116 1.1 skrll * The spl mask for this bit. This starts out as the spl bit assigned
117 1.1 skrll * to this particular interrupt, and later gets fleshed out by the mask
118 1.1 skrll * calculator to be the full mask that we need to raise spl to when we
119 1.1 skrll * get this interrupt.
120 1.1 skrll */
121 1.1 skrll int ib_spl;
122 1.1 skrll
123 1.1 skrll /* The interrupt name. */
124 1.1 skrll char ib_name[16];
125 1.1 skrll
126 1.1 skrll /* The interrupt event count. */
127 1.1 skrll struct evcnt ib_evcnt;
128 1.1 skrll
129 1.1 skrll /*
130 1.1 skrll * The interrupt handler and argument for this bit. If the argument is
131 1.1 skrll * NULL, the handler gets the trapframe.
132 1.1 skrll */
133 1.1 skrll int (*ib_handler)(void *);
134 1.1 skrll void *ib_arg;
135 1.1 skrll
136 1.1 skrll };
137 1.1 skrll
138 1.1 skrll void hppa_intr_bootstrap(void);
139 1.1 skrll void hppa_intr_initialise(struct cpu_info *);
140 1.1 skrll void hppa_interrupt_register_establish(struct cpu_info *,
141 1.1 skrll struct hppa_interrupt_register *);
142 1.1 skrll void * hppa_intr_establish(int, int (*)(void *), void *,
143 1.1 skrll struct hppa_interrupt_register *, int);
144 1.1 skrll int hppa_intr_allocate_bit(struct hppa_interrupt_register *, int);
145 1.1 skrll void hppa_intr_enable(void);
146 1.1 skrll
147 1.1 skrll /* splraise()/spllower() are in locore.S */
148 1.1 skrll int splraise(int);
149 1.1 skrll void spllower(int);
150 1.1 skrll
151 1.1 skrll /*
152 1.1 skrll * Miscellaneous
153 1.1 skrll */
154 1.1 skrll #define spl0() spllower(0)
155 1.1 skrll #define splx(x) spllower(x)
156 1.1 skrll
157 1.1 skrll typedef int ipl_t;
158 1.1 skrll typedef struct {
159 1.1 skrll ipl_t _ipl;
160 1.1 skrll } ipl_cookie_t;
161 1.1 skrll
162 1.1 skrll static inline ipl_cookie_t
163 1.1 skrll makeiplcookie(ipl_t ipl)
164 1.1 skrll {
165 1.1 skrll
166 1.1 skrll return (ipl_cookie_t){._ipl = ipl};
167 1.1 skrll }
168 1.1 skrll
169 1.1 skrll static inline int
170 1.1 skrll splraiseipl(ipl_cookie_t icookie)
171 1.1 skrll {
172 1.1 skrll
173 1.1 skrll return splraise(icookie._ipl);
174 1.1 skrll }
175 1.1 skrll
176 1.1 skrll #include <sys/spl.h>
177 1.1 skrll #endif
178 1.1 skrll
179 1.1 skrll #define setsoftast(l) ((l)->l_md.md_astpending = 1)
180 1.1 skrll
181 1.1 skrll #ifdef MULTIPROCESSOR
182 1.1 skrll
183 1.1 skrll struct cpu_info;
184 1.1 skrll
185 1.1 skrll void hppa_ipi_init(struct cpu_info *);
186 1.1 skrll int hppa_ipi_intr(void *arg);
187 1.1 skrll int hppa_ipi_send(struct cpu_info *, u_long);
188 1.1 skrll int hppa_ipi_broadcast(u_long);
189 1.1 skrll #endif
190 1.1 skrll
191 1.1 skrll #endif /* !_LOCORE */
192 1.1 skrll
193 1.1 skrll #endif /* !_HPPA_INTR_H_ */
194