psl.h revision 1.13 1 /* $NetBSD: psl.h,v 1.13 1998/06/14 19:47:14 kleink Exp $ */
2
3 #ifndef _MACHINE_PSL_H_
4 #define _MACHINE_PSL_H_
5
6 #include <m68k/psl.h>
7
8 #if defined(_KERNEL) && !defined(_LOCORE)
9
10 #if 0
11 #define _debug_spl(s) \
12 ({ \
13 register int _spl_r; \
14 \
15 __asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \
16 "&=d" (_spl_r) : "di" (s)); \
17 if ((_spl_r&PSL_IPL) > ((s)&PSL_IPL)&&((s)&PSL_IPL)!=PSL_IPL1) \
18 printf ("%s:%d:spl(%d) ==> spl(%d)!!\n",__FILE__,__LINE__, \
19 ((PSL_IPL&_spl_r)>>8), ((PSL_IPL&(s))>>8)); \
20 _spl_r; \
21 })
22 #else
23 /*
24 * Don't lower IPL below current IPL (unless new IPL is 6)
25 */
26 #define _debug_spl(s) \
27 ({ \
28 register int _spl_r; \
29 \
30 __asm __volatile ("clrl %0; movew sr,%0" : \
31 "&=d" (_spl_r)); \
32 if ((((s)&PSL_IPL) >= PSL_IPL6) || (_spl_r&PSL_IPL) < ((s)&PSL_IPL) || ((s)&PSL_IPL) <= PSL_IPL1) \
33 __asm __volatile ("movew %0,sr" : : "di" (s)); \
34 _spl_r; \
35 })
36 #endif
37
38 #define _spl_no_check(s) \
39 ({ \
40 register int _spl_r; \
41 \
42 __asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \
43 "&=d" (_spl_r) : "di" (s)); \
44 _spl_r; \
45 })
46 #if defined (DEBUGXX) /* No workee */
47 #define _spl _debug_spl
48 #else
49 #define _spl _spl_no_check
50 #endif
51
52 #define spl0() _spl(PSL_S|PSL_IPL0)
53 #define spl1() _spl(PSL_S|PSL_IPL1)
54 #define spl2() _spl(PSL_S|PSL_IPL2)
55 #define spl3() _spl(PSL_S|PSL_IPL3)
56 #define spl4() _spl(PSL_S|PSL_IPL4)
57 #define spl5() _spl(PSL_S|PSL_IPL5)
58 #define spl6() _spl(PSL_S|PSL_IPL6)
59 #define spl7() _spl(PSL_S|PSL_IPL7)
60
61 #define splnone() spl0()
62 #define splsoftclock() spl1()
63 #define splsoftnet() spl1()
64 #define splbio() spl3()
65 #define splnet() spl3()
66
67 /*
68 * splserial hack, idea by Jason Thorpe.
69 * drivers which need it (at the present only the coms) raise the variable to
70 * their serial interrupt level.
71 *
72 * serialspl is statically initialized in machdep.c at the moment; should
73 * be some driver independent file.
74 *
75 * XXX should serialspl be volatile? I think not; it is intended to be set only
76 * during xxx_attach() time, and will be used only later.
77 * -is
78 */
79
80 extern u_int16_t amiga_serialspl;
81 #define splserial() _spl(amiga_serialspl)
82 #define spltty() spl4()
83 #define splimp() spltty() /* XXX for the full story, see i386 */
84
85 #ifndef LEV6_DEFER
86 #define splclock() spl6()
87 #define splstatclock() spl6()
88 #define splvm() spl6()
89 #define splhigh() spl7()
90 #define splsched() spl7()
91 #else
92 #define splclock() spl4()
93 #define splstatclock() spl4()
94 #define splvm() spl4()
95 #define splhigh() spl4()
96 #define splsched() spl4()
97 #endif
98
99 #define splx(s) _spl_no_check(s)
100
101 #endif /* KERNEL && !_LOCORE */
102 #endif /* _MACHINE_PSL_H_ */
103