intr.h revision 1.22 1 1.22 christos /* $NetBSD: intr.h,v 1.22 2018/04/19 21:50:07 christos Exp $ */
2 1.1 dbj
3 1.1 dbj /*
4 1.1 dbj * Copyright (C) 1997 Scott Reynolds
5 1.1 dbj * Copyright (C) 1998 Darrin Jewell
6 1.1 dbj * All rights reserved.
7 1.1 dbj *
8 1.1 dbj * Redistribution and use in source and binary forms, with or without
9 1.1 dbj * modification, are permitted provided that the following conditions
10 1.1 dbj * are met:
11 1.1 dbj * 1. Redistributions of source code must retain the above copyright
12 1.1 dbj * notice, this list of conditions and the following disclaimer.
13 1.1 dbj * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 dbj * notice, this list of conditions and the following disclaimer in the
15 1.1 dbj * documentation and/or other materials provided with the distribution.
16 1.1 dbj * 3. The name of the author may not be used to endorse or promote products
17 1.1 dbj * derived from this software without specific prior written permission.
18 1.1 dbj *
19 1.1 dbj * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 1.1 dbj * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 1.1 dbj * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 1.1 dbj * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 1.1 dbj * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 1.1 dbj * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 1.1 dbj * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 1.1 dbj * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 1.1 dbj * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 1.1 dbj * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 1.1 dbj */
30 1.1 dbj
31 1.1 dbj #ifndef _NEXT68K_INTR_H_
32 1.1 dbj #define _NEXT68K_INTR_H_
33 1.1 dbj
34 1.1 dbj #include <machine/psl.h>
35 1.1 dbj
36 1.1 dbj /* Probably want to dealwith IPL's here @@@ */
37 1.1 dbj
38 1.1 dbj #ifdef _KERNEL
39 1.1 dbj
40 1.1 dbj /* spl0 requires checking for software interrupts */
41 1.1 dbj
42 1.1 dbj /* watch out for side effects */
43 1.1 dbj #define splx(s) ((s) & PSL_IPL ? _spl(s) : spl0())
44 1.1 dbj
45 1.20 ad #define splsoftbio() splraise1()
46 1.20 ad #define splsoftnet() splraise1()
47 1.20 ad #define splsoftclock() splraise1()
48 1.20 ad #define splsoftserial() splraise1()
49 1.18 tsutsui #define splvm() splraise6()
50 1.18 tsutsui #define splhigh() spl7()
51 1.18 tsutsui #define splsched() spl7()
52 1.18 tsutsui
53 1.18 tsutsui #define spldma() splraise6()
54 1.18 tsutsui
55 1.1 dbj /****************************************************************/
56 1.1 dbj
57 1.18 tsutsui #define IPL_NONE 0
58 1.18 tsutsui #define IPL_SOFTCLOCK 1
59 1.20 ad #define IPL_SOFTBIO 2
60 1.20 ad #define IPL_SOFTNET 3
61 1.20 ad #define IPL_SOFTSERIAL 4
62 1.20 ad #define IPL_VM 5
63 1.20 ad #define IPL_SCHED 6
64 1.21 isaki #define IPL_HIGH 7
65 1.21 isaki #define NIPL 8
66 1.21 isaki
67 1.21 isaki extern const uint16_t ipl2psl_table[NIPL];
68 1.16 yamt
69 1.16 yamt typedef int ipl_t;
70 1.16 yamt typedef struct {
71 1.19 thorpej uint16_t _psl;
72 1.16 yamt } ipl_cookie_t;
73 1.16 yamt
74 1.22 christos static __inline ipl_cookie_t
75 1.21 isaki makeiplcookie(ipl_t ipl)
76 1.21 isaki {
77 1.16 yamt
78 1.21 isaki return (ipl_cookie_t){._psl = ipl2psl_table[ipl]};
79 1.21 isaki }
80 1.16 yamt
81 1.22 christos static __inline int
82 1.16 yamt splraiseipl(ipl_cookie_t icookie)
83 1.16 yamt {
84 1.16 yamt
85 1.18 tsutsui return _splraise(icookie._psl);
86 1.16 yamt }
87 1.16 yamt
88 1.1 dbj /****************************************************************/
89 1.1 dbj
90 1.1 dbj /* locore.s */
91 1.12 chs int spl0(void);
92 1.11 mycroft
93 1.11 mycroft extern volatile u_long *intrstat;
94 1.11 mycroft extern volatile u_long *intrmask;
95 1.11 mycroft #define INTR_SETMASK(x) (*intrmask = (x))
96 1.11 mycroft #define INTR_ENABLE(x) (*intrmask |= NEXT_I_BIT(x))
97 1.11 mycroft #define INTR_DISABLE(x) (*intrmask &= (~NEXT_I_BIT(x)))
98 1.11 mycroft #define INTR_OCCURRED(x) (*intrstat & NEXT_I_BIT(x))
99 1.11 mycroft
100 1.1 dbj #endif /* _KERNEL */
101 1.1 dbj
102 1.1 dbj #endif /* _NEXT68K_INTR_H_ */
103