intr.h revision 1.4 1 1.4 mrg /* $NetBSD: intr.h,v 1.4 2023/07/12 06:45:24 mrg 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.3 riastrad #if defined(_KERNEL) || defined(_KMEMUSER)
44 1.4 mrg typedef int ipl_t;
45 1.3 riastrad typedef struct {
46 1.3 riastrad ipl_t _ipl;
47 1.3 riastrad } ipl_cookie_t;
48 1.3 riastrad #endif
49 1.3 riastrad
50 1.1 skrll #ifdef _KERNEL
51 1.1 skrll
52 1.1 skrll struct cpu_info;
53 1.1 skrll
54 1.1 skrll /*
55 1.1 skrll * The maximum number of bits in a cpl value/spl mask, the maximum number of
56 1.1 skrll * bits in an interrupt request register, and the maximum number of interrupt
57 1.1 skrll * registers.
58 1.1 skrll */
59 1.1 skrll #define HPPA_INTERRUPT_BITS (32)
60 1.1 skrll #define CPU_NINTS HPPA_INTERRUPT_BITS /* Use this one */
61 1.1 skrll
62 1.1 skrll /*
63 1.1 skrll * This describes one HPPA interrupt register.
64 1.1 skrll */
65 1.1 skrll struct hppa_interrupt_register {
66 1.1 skrll bool ir_iscpu;
67 1.1 skrll const char *ir_name; /* name for this intr reg */
68 1.1 skrll struct cpu_info *ir_ci; /* cpu this intr reg */
69 1.1 skrll
70 1.1 skrll /*
71 1.1 skrll * The virtual address of the mask, request and level
72 1.1 skrll * registers.
73 1.1 skrll */
74 1.1 skrll volatile int *ir_mask;
75 1.1 skrll volatile int *ir_req;
76 1.1 skrll volatile int *ir_level;
77 1.1 skrll
78 1.1 skrll /*
79 1.1 skrll * This array has one entry for each bit in the interrupt request
80 1.1 skrll * register.
81 1.1 skrll *
82 1.1 skrll * If the 24 most significant bits are set, the low 8 bits are the
83 1.1 skrll * index of the hppa_interrupt_register that this interrupt bit leads
84 1.1 skrll * to, with zero meaning that the interrupt bit is unused.
85 1.1 skrll *
86 1.1 skrll * Otherwise these bits correspond to hppa_interrupt_bits. That is,
87 1.1 skrll * these bits are ORed to ipending_new in hppa_intr_ipending() when
88 1.1 skrll * an interrupt happens.
89 1.1 skrll *
90 1.1 skrll * Note that this array is indexed by HP bit number, *not* by "normal"
91 1.1 skrll * bit number. In other words, the least significant bit in the inter-
92 1.1 skrll * rupt register corresponds to array index 31.
93 1.1 skrll */
94 1.1 skrll
95 1.1 skrll unsigned int ir_bits_map[HPPA_INTERRUPT_BITS];
96 1.1 skrll
97 1.1 skrll #define IR_BIT_MASK 0xffffff00
98 1.1 skrll #define IR_BIT_REG(x) (IR_BIT_MASK | (x))
99 1.1 skrll #define IR_BIT_UNUSED IR_BIT_REG(0)
100 1.1 skrll #define IR_BIT_USED_P(x) (((x) & IR_BIT_MASK) != IR_BIT_MASK)
101 1.1 skrll #define IR_BIT_NESTED_P(x) (((x) & IR_BIT_MASK) == IR_BIT_MASK)
102 1.2 macallan /* true if not used for interrupt or nested interrupt register */
103 1.2 macallan #define IR_BIT_UNUSED_P(x) ((x) == IR_BIT_MASK)
104 1.1 skrll
105 1.1 skrll int ir_bits; /* mask of allocatable bit numbers */
106 1.1 skrll int ir_rbits; /* mask of reserved (for lasi/asp) bit numbers */
107 1.1 skrll };
108 1.1 skrll
109 1.1 skrll struct hppa_interrupt_bit {
110 1.1 skrll
111 1.1 skrll /*
112 1.1 skrll * The interrupt register this bit is in. Some handlers, e.g
113 1.1 skrll * apic_intr, don't make use of an hppa_interrupt_register, but are
114 1.1 skrll * nested.
115 1.1 skrll */
116 1.1 skrll struct hppa_interrupt_register *ib_reg;
117 1.1 skrll
118 1.1 skrll /*
119 1.1 skrll * The priority level associated with this bit, e.g, IPL_BIO, IPL_NET,
120 1.1 skrll * etc.
121 1.1 skrll */
122 1.1 skrll int ib_ipl;
123 1.1 skrll
124 1.1 skrll /*
125 1.1 skrll * The spl mask for this bit. This starts out as the spl bit assigned
126 1.1 skrll * to this particular interrupt, and later gets fleshed out by the mask
127 1.1 skrll * calculator to be the full mask that we need to raise spl to when we
128 1.1 skrll * get this interrupt.
129 1.1 skrll */
130 1.1 skrll int ib_spl;
131 1.1 skrll
132 1.1 skrll /* The interrupt name. */
133 1.1 skrll char ib_name[16];
134 1.1 skrll
135 1.1 skrll /* The interrupt event count. */
136 1.1 skrll struct evcnt ib_evcnt;
137 1.1 skrll
138 1.1 skrll /*
139 1.1 skrll * The interrupt handler and argument for this bit. If the argument is
140 1.1 skrll * NULL, the handler gets the trapframe.
141 1.1 skrll */
142 1.1 skrll int (*ib_handler)(void *);
143 1.1 skrll void *ib_arg;
144 1.1 skrll
145 1.1 skrll };
146 1.1 skrll
147 1.1 skrll void hppa_intr_bootstrap(void);
148 1.1 skrll void hppa_intr_initialise(struct cpu_info *);
149 1.1 skrll void hppa_interrupt_register_establish(struct cpu_info *,
150 1.1 skrll struct hppa_interrupt_register *);
151 1.1 skrll void * hppa_intr_establish(int, int (*)(void *), void *,
152 1.1 skrll struct hppa_interrupt_register *, int);
153 1.1 skrll int hppa_intr_allocate_bit(struct hppa_interrupt_register *, int);
154 1.1 skrll void hppa_intr_enable(void);
155 1.1 skrll
156 1.1 skrll /* splraise()/spllower() are in locore.S */
157 1.1 skrll int splraise(int);
158 1.1 skrll void spllower(int);
159 1.1 skrll
160 1.1 skrll /*
161 1.1 skrll * Miscellaneous
162 1.1 skrll */
163 1.1 skrll #define spl0() spllower(0)
164 1.1 skrll #define splx(x) spllower(x)
165 1.1 skrll
166 1.1 skrll static inline ipl_cookie_t
167 1.1 skrll makeiplcookie(ipl_t ipl)
168 1.1 skrll {
169 1.1 skrll
170 1.1 skrll return (ipl_cookie_t){._ipl = ipl};
171 1.1 skrll }
172 1.1 skrll
173 1.1 skrll static inline int
174 1.1 skrll splraiseipl(ipl_cookie_t icookie)
175 1.1 skrll {
176 1.1 skrll
177 1.1 skrll return splraise(icookie._ipl);
178 1.1 skrll }
179 1.1 skrll
180 1.1 skrll #include <sys/spl.h>
181 1.1 skrll #endif
182 1.1 skrll
183 1.1 skrll #define setsoftast(l) ((l)->l_md.md_astpending = 1)
184 1.1 skrll
185 1.1 skrll #ifdef MULTIPROCESSOR
186 1.1 skrll
187 1.1 skrll struct cpu_info;
188 1.1 skrll
189 1.1 skrll void hppa_ipi_init(struct cpu_info *);
190 1.1 skrll int hppa_ipi_intr(void *arg);
191 1.1 skrll int hppa_ipi_send(struct cpu_info *, u_long);
192 1.1 skrll int hppa_ipi_broadcast(u_long);
193 1.1 skrll #endif
194 1.1 skrll
195 1.1 skrll #endif /* !_LOCORE */
196 1.1 skrll
197 1.1 skrll #endif /* !_HPPA_INTR_H_ */
198