intr.h revision 1.18 1 /* $NetBSD: intr.h,v 1.18 2008/06/28 05:26:33 isaki Exp $ */
2
3 /*-
4 * Copyright (c) 1997, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef _ATARI_INTR_H_
30 #define _ATARI_INTR_H_
31
32 #define IPL_NONE 0 /* disable no interrupts */
33 #define IPL_SOFTCLOCK 1
34 #define IPL_SOFTBIO 2
35 #define IPL_SOFTNET 3
36 #define IPL_SOFTSERIAL 4
37 #define IPL_VM 5
38 #define IPL_SCHED 6
39 #define IPL_HIGH 7
40 #define NIPL 8
41
42 #define IST_UNUSABLE -1 /* interrupt cannot be used */
43 #define IST_NONE 0 /* none (dummy) */
44 #define IST_PULSE 1 /* pulsed */
45 #define IST_EDGE 2 /* edge-triggered */
46 #define IST_LEVEL 3 /* level-triggered */
47
48 /*
49 * spl functions; all but spl0 are done in-line
50 */
51 #include <machine/psl.h>
52
53 /* spl0 requires checking for software interrupts */
54
55 #define splsoftclock() splraise1()
56 #define splsoftbio() splraise1()
57 #define splsoftnet() splraise1()
58 #define splsoftserial() splraise1()
59 #define splvm() splraise4()
60 #define splsched() splraise6()
61 #define splhigh() spl7()
62 #define splx(s) ((s) & PSL_IPL ? _spl(s) : spl0())
63
64 #ifdef _KERNEL
65 int spl0 __P((void));
66
67 extern const uint16_t ipl2psl_table[NIPL];
68
69 typedef int ipl_t;
70 typedef struct {
71 uint16_t _psl;
72 } ipl_cookie_t;
73
74 static inline ipl_cookie_t
75 makeiplcookie(ipl_t ipl)
76 {
77
78 return (ipl_cookie_t){._psl = ipl2psl_table[ipl]};
79 }
80
81 static inline int
82 splraiseipl(ipl_cookie_t icookie)
83 {
84
85 return _splraise(icookie._psl);
86 }
87
88 #endif /* _KERNEL */
89
90 #endif /* _ATARI_INTR_H_ */
91