intr.h revision 1.15 1 1.15 perry /* $NetBSD: intr.h,v 1.15 2005/12/24 20:07:24 perry 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.1 dbj /****************************************************************/
46 1.1 dbj
47 1.4 dbj #define splhigh() spl7()
48 1.4 dbj #define splserial() _splraise(PSL_S|PSL_IPL5)
49 1.7 thorpej #define splsched() spl7()
50 1.8 thorpej #define spllock() spl7()
51 1.11 mycroft #define splclock() _splraise(PSL_S|PSL_IPL3)
52 1.4 dbj #define splstatclock() splclock()
53 1.9 thorpej #define splvm() _splraise(PSL_S|PSL_IPL6)
54 1.4 dbj #define spltty() _splraise(PSL_S|PSL_IPL3)
55 1.4 dbj #define splbio() _splraise(PSL_S|PSL_IPL3)
56 1.4 dbj #define splnet() _splraise(PSL_S|PSL_IPL3)
57 1.4 dbj #define splsoftnet() _splraise(PSL_S|PSL_IPL2)
58 1.6 thorpej #define splsoftclock() splraise1()
59 1.6 thorpej #define spllowersoftclock() spl1()
60 1.1 dbj
61 1.4 dbj #define spldma() _splraise(PSL_S|PSL_IPL6)
62 1.1 dbj
63 1.1 dbj /****************************************************************/
64 1.1 dbj
65 1.1 dbj /*
66 1.1 dbj * simulated software interrupt register
67 1.1 dbj */
68 1.1 dbj extern volatile u_int8_t ssir;
69 1.1 dbj
70 1.1 dbj #define SIR_NET 0x01
71 1.1 dbj #define SIR_CLOCK 0x02
72 1.1 dbj #define SIR_SERIAL 0x04
73 1.1 dbj #define SIR_DTMGR 0x08
74 1.1 dbj #define SIR_ADB 0x10
75 1.1 dbj
76 1.1 dbj #define siron(mask) \
77 1.15 perry __asm volatile ( "orb %1,%0" : "=m" (ssir) : "i" (mask))
78 1.1 dbj #define siroff(mask) \
79 1.15 perry __asm volatile ( "andb %1,%0" : "=m" (ssir) : "ir" (~(mask)));
80 1.1 dbj
81 1.1 dbj #define setsoftnet() siron(SIR_NET)
82 1.1 dbj #define setsoftclock() siron(SIR_CLOCK)
83 1.1 dbj #define setsoftserial() siron(SIR_SERIAL)
84 1.1 dbj #define setsoftdtmgr() siron(SIR_DTMGR)
85 1.1 dbj #define setsoftadb() siron(SIR_ADB)
86 1.2 dbj
87 1.12 chs extern u_long allocate_sir(void (*)(void *),void *);
88 1.12 chs extern void init_sir(void);
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