intr.h revision 1.26 1 1.26 thorpej /* $NetBSD: intr.h,v 1.26 2024/01/19 03:09:05 thorpej Exp $ */
2 1.1 fredette
3 1.24 thorpej /*-
4 1.24 thorpej * Copyright (c) 2024 The NetBSD Foundation, Inc.
5 1.1 fredette * All rights reserved.
6 1.1 fredette *
7 1.24 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.24 thorpej * by Jason R. Thorpe.
9 1.24 thorpej *
10 1.1 fredette * Redistribution and use in source and binary forms, with or without
11 1.1 fredette * modification, are permitted provided that the following conditions
12 1.1 fredette * are met:
13 1.1 fredette * 1. Redistributions of source code must retain the above copyright
14 1.1 fredette * notice, this list of conditions and the following disclaimer.
15 1.1 fredette * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 fredette * notice, this list of conditions and the following disclaimer in the
17 1.1 fredette * documentation and/or other materials provided with the distribution.
18 1.1 fredette *
19 1.24 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.24 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.24 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.24 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.24 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.24 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.24 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.24 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.24 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.24 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.24 thorpej * POSSIBILITY OF SUCH DAMAGE.
30 1.1 fredette */
31 1.1 fredette
32 1.1 fredette #ifndef _SUN68K_INTR_H_
33 1.1 fredette #define _SUN68K_INTR_H_
34 1.1 fredette
35 1.26 thorpej #ifdef _KERNEL
36 1.26 thorpej
37 1.3 chs #include <m68k/psl.h>
38 1.1 fredette
39 1.24 thorpej #define MACHINE_PSL_IPL_SOFTCLOCK PSL_IPL1
40 1.24 thorpej #define MACHINE_PSL_IPL_SOFTBIO PSL_IPL1
41 1.24 thorpej #define MACHINE_PSL_IPL_SOFTNET PSL_IPL1
42 1.24 thorpej #define MACHINE_PSL_IPL_SOFTSERIAL PSL_IPL3
43 1.24 thorpej #define MACHINE_PSL_IPL_VM PSL_IPL4
44 1.24 thorpej #define MACHINE_PSL_IPL_SCHED PSL_IPL7
45 1.24 thorpej
46 1.25 thorpej #define MACHINE_INTREVCNT_NAMES \
47 1.25 thorpej { "spur", "lev1", "lev2", "lev3", "lev4", "clock", "lev6", "nmi" }
48 1.25 thorpej
49 1.24 thorpej /* Zilog Serial hardware interrupts (hard-wired at 6) */
50 1.24 thorpej #define splzs() splserial() /* aliased to splhigh() */
51 1.24 thorpej #define IPL_ZS IPL_SERIAL
52 1.10 yamt
53 1.1 fredette #define _IPL_SOFT_LEVEL1 1
54 1.1 fredette #define _IPL_SOFT_LEVEL2 2
55 1.1 fredette #define _IPL_SOFT_LEVEL3 3
56 1.1 fredette #define _IPL_SOFT_LEVEL_MIN 1
57 1.1 fredette #define _IPL_SOFT_LEVEL_MAX 3
58 1.7 yamt
59 1.26 thorpej #endif /* _KERNEL */
60 1.26 thorpej
61 1.24 thorpej #include <m68k/intr.h>
62 1.21 riastrad
63 1.10 yamt #ifdef _KERNEL
64 1.10 yamt
65 1.24 thorpej /*
66 1.24 thorpej * Aliases for the legacy sun68k ISR routines.
67 1.24 thorpej */
68 1.20 tsutsui
69 1.24 thorpej typedef int (*isr_func_t)(void *);
70 1.18 tsutsui
71 1.24 thorpej static inline void
72 1.24 thorpej isr_add_autovect(isr_func_t func, void *arg, int ipl)
73 1.19 tsutsui {
74 1.24 thorpej /* XXX leaks interrupt handle. */
75 1.24 thorpej m68k_intr_establish(func, arg, (void *)0, 0, ipl, 0, 0);
76 1.19 tsutsui }
77 1.10 yamt
78 1.24 thorpej static inline void
79 1.24 thorpej isr_add_vectored(isr_func_t func, void *arg, int ipl, int vec)
80 1.10 yamt {
81 1.24 thorpej /* XXX leaks interrupt handle. */
82 1.24 thorpej m68k_intr_establish(func, arg, (void *)0, vec, ipl, 0, 0);
83 1.10 yamt }
84 1.1 fredette
85 1.3 chs /* This returns true iff the spl given is spl0. */
86 1.3 chs #define is_spl0(s) (((s) & PSL_IPL7) == 0)
87 1.3 chs
88 1.24 thorpej #endif /* _KERNEL */
89 1.3 chs
90 1.1 fredette #endif /* _SUN68K_INTR_H */
91