intr.h revision 1.13
1/*	$NetBSD: intr.h,v 1.13 2006/12/21 15:55:23 yamt Exp $	*/
2
3/*
4 *
5 * Copyright (c) 1998 NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Minoura Makoto and Jason R. Thorpe.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 *    notice, this list of conditions and the following disclaimer in the
18 *    documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 *    must display the following acknowledgement:
21 *      This product includes software developed by The NetBSD Foundation
22 *	Inc. and its contributers.
23 * 4. The name of the author may not be used to endorse or promote products
24 *    derived from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _NEWS68K_INTR_H_
39#define	_NEWS68K_INTR_H_
40
41#include <machine/psl.h>
42#include <m68k/asm_single.h>
43
44#ifdef _KERNEL
45/*
46 * news68k can handle software interrupts by its own hardware
47 * so has no need to check for any simulated interrupts, etc.
48 */
49#define	spl0()		_spl0()
50
51#define	spllowersoftclock()	spl2()
52
53#define	IPL_NONE	0
54#define	IPL_SOFTCLOCK	(PSL_S|PSL_IPL2)
55#define	IPL_SOFTNET	(PSL_S|PSL_IPL2)
56#define	IPL_BIO		(PSL_S|PSL_IPL4)
57#define	IPL_NET		(PSL_S|PSL_IPL4)
58#define	IPL_TTY		(PSL_S|PSL_IPL5)
59#define	IPL_VM		(PSL_S|PSL_IPL5)
60#define	IPL_SERIAL	(PSL_S|PSL_IPL5)
61#define	IPL_CLOCK	(PSL_S|PSL_IPL6)
62#define	IPL_STATCLOCK	IPL_CLOCK
63#define	IPL_SCHED	(PSL_S|PSL_IPL7)
64#define	IPL_HIGH	(PSL_S|PSL_IPL7)
65#define	IPL_LOCK	(PSL_S|PSL_IPL7)
66
67typedef int ipl_t;
68typedef struct {
69	ipl_t _ipl;
70} ipl_cookie_t;
71
72static inline ipl_cookie_t
73makeiplcookie(ipl_t ipl)
74{
75
76	return (ipl_cookie_t){._ipl = ipl};
77}
78
79static inline int
80splraiseipl(ipl_cookie_t icookie)
81{
82
83	return _splraise(icookie._ipl);
84}
85
86#include <sys/spl.h>
87
88static __inline void
89splx(int sr)
90{
91
92	__asm volatile("movw %0,%%sr" : : "di" (sr));
93}
94
95/*
96 * simulated software interrupt register
97 */
98extern u_char ssir;
99extern volatile u_char *ctrl_int2;
100
101#define	NSIR		(sizeof(ssir) * 8)
102#define	SIR_NET		0
103#define	SIR_CLOCK	1
104#define	NEXT_SIR	2
105
106#define	siron(x)	single_inst_bset_b((ssir), (x))
107#define	siroff(x)	single_inst_bclr_b((ssir), (x))
108#define	setsoftint(x)	do {				\
109				siron(x);		\
110				*ctrl_int2 = 0xff;	\
111			} while (0)
112#define	setsoftnet()	setsoftint(1 << SIR_NET)
113#define	setsoftclock()	setsoftint(1 << SIR_CLOCK)
114
115u_char allocate_sir(void (*)(void *), void *);
116void init_sir(void);
117#endif /* _KERNEL */
118
119#endif /* _NEWS68K_INTR_H_ */
120