intr.h revision 1.20 1 1.20 ad /* $NetBSD: intr.h,v 1.20 2007/12/03 15:34:06 ad 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.20 ad #define IPL_HIGH 6
65 1.20 ad #define NIPL 7
66 1.16 yamt
67 1.16 yamt typedef int ipl_t;
68 1.16 yamt typedef struct {
69 1.19 thorpej uint16_t _psl;
70 1.16 yamt } ipl_cookie_t;
71 1.16 yamt
72 1.18 tsutsui extern const int ipl2psl_table[NIPL];
73 1.16 yamt
74 1.18 tsutsui ipl_cookie_t makeiplcookie(ipl_t);
75 1.16 yamt
76 1.16 yamt static inline int
77 1.16 yamt splraiseipl(ipl_cookie_t icookie)
78 1.16 yamt {
79 1.16 yamt
80 1.18 tsutsui return _splraise(icookie._psl);
81 1.16 yamt }
82 1.16 yamt
83 1.1 dbj /****************************************************************/
84 1.1 dbj
85 1.1 dbj /* locore.s */
86 1.12 chs int spl0(void);
87 1.11 mycroft
88 1.11 mycroft extern volatile u_long *intrstat;
89 1.11 mycroft extern volatile u_long *intrmask;
90 1.11 mycroft #define INTR_SETMASK(x) (*intrmask = (x))
91 1.11 mycroft #define INTR_ENABLE(x) (*intrmask |= NEXT_I_BIT(x))
92 1.11 mycroft #define INTR_DISABLE(x) (*intrmask &= (~NEXT_I_BIT(x)))
93 1.11 mycroft #define INTR_OCCURRED(x) (*intrstat & NEXT_I_BIT(x))
94 1.11 mycroft
95 1.1 dbj #endif /* _KERNEL */
96 1.1 dbj
97 1.1 dbj #endif /* _NEXT68K_INTR_H_ */
98