intr.h revision 1.16 1 1.16 yamt /* $NetBSD: intr.h,v 1.16 2006/12/21 15:55:24 yamt 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.16 yamt #define IPL_HIGH (PSL_S|PSL_IPL7)
48 1.16 yamt #define IPL_SERIAL (PSL_S|PSL_IPL5)
49 1.16 yamt #define IPL_SCHED (PSL_S|PSL_IPL7)
50 1.16 yamt #define IPL_LOCK (PSL_S|PSL_IPL7)
51 1.16 yamt #define IPL_CLOCK (PSL_S|PSL_IPL3)
52 1.16 yamt #define IPL_STATCLOCK IPL_CLOCK
53 1.16 yamt #define IPL_VM (PSL_S|PSL_IPL6)
54 1.16 yamt #define IPL_TTY (PSL_S|PSL_IPL3)
55 1.16 yamt #define IPL_BIO (PSL_S|PSL_IPL3)
56 1.16 yamt #define IPL_NET (PSL_S|PSL_IPL3)
57 1.16 yamt #define IPL_SOFTNET (PSL_S|PSL_IPL2)
58 1.16 yamt #define IPL_SOFTCLOCK (PSL_S|PSL_IPL1)
59 1.16 yamt #define IPL_NONE 0
60 1.16 yamt
61 1.16 yamt typedef int ipl_t;
62 1.16 yamt typedef struct {
63 1.16 yamt ipl_t _ipl;
64 1.16 yamt } ipl_cookie_t;
65 1.16 yamt
66 1.16 yamt static inline ipl_cookie_t
67 1.16 yamt makeiplcookie(ipl_t ipl)
68 1.16 yamt {
69 1.16 yamt
70 1.16 yamt return (ipl_cookie_t){._ipl = ipl};
71 1.16 yamt }
72 1.16 yamt
73 1.16 yamt static inline int
74 1.16 yamt splraiseipl(ipl_cookie_t icookie)
75 1.16 yamt {
76 1.16 yamt
77 1.16 yamt return _splraise(icookie._ipl);
78 1.16 yamt }
79 1.16 yamt
80 1.16 yamt #include <sys/spl.h>
81 1.16 yamt
82 1.6 thorpej #define spllowersoftclock() spl1()
83 1.1 dbj
84 1.4 dbj #define spldma() _splraise(PSL_S|PSL_IPL6)
85 1.1 dbj
86 1.1 dbj /****************************************************************/
87 1.1 dbj
88 1.1 dbj /*
89 1.1 dbj * simulated software interrupt register
90 1.1 dbj */
91 1.1 dbj extern volatile u_int8_t ssir;
92 1.1 dbj
93 1.1 dbj #define SIR_NET 0x01
94 1.1 dbj #define SIR_CLOCK 0x02
95 1.1 dbj #define SIR_SERIAL 0x04
96 1.1 dbj #define SIR_DTMGR 0x08
97 1.1 dbj #define SIR_ADB 0x10
98 1.1 dbj
99 1.1 dbj #define siron(mask) \
100 1.15 perry __asm volatile ( "orb %1,%0" : "=m" (ssir) : "i" (mask))
101 1.1 dbj #define siroff(mask) \
102 1.15 perry __asm volatile ( "andb %1,%0" : "=m" (ssir) : "ir" (~(mask)));
103 1.1 dbj
104 1.1 dbj #define setsoftnet() siron(SIR_NET)
105 1.1 dbj #define setsoftclock() siron(SIR_CLOCK)
106 1.1 dbj #define setsoftserial() siron(SIR_SERIAL)
107 1.1 dbj #define setsoftdtmgr() siron(SIR_DTMGR)
108 1.1 dbj #define setsoftadb() siron(SIR_ADB)
109 1.2 dbj
110 1.12 chs extern u_long allocate_sir(void (*)(void *),void *);
111 1.12 chs extern void init_sir(void);
112 1.1 dbj
113 1.1 dbj /* locore.s */
114 1.12 chs int spl0(void);
115 1.11 mycroft
116 1.11 mycroft extern volatile u_long *intrstat;
117 1.11 mycroft extern volatile u_long *intrmask;
118 1.11 mycroft #define INTR_SETMASK(x) (*intrmask = (x))
119 1.11 mycroft #define INTR_ENABLE(x) (*intrmask |= NEXT_I_BIT(x))
120 1.11 mycroft #define INTR_DISABLE(x) (*intrmask &= (~NEXT_I_BIT(x)))
121 1.11 mycroft #define INTR_OCCURRED(x) (*intrstat & NEXT_I_BIT(x))
122 1.11 mycroft
123 1.1 dbj #endif /* _KERNEL */
124 1.1 dbj
125 1.1 dbj #endif /* _NEXT68K_INTR_H_ */
126