intr.h revision 1.27
1/*	$NetBSD: intr.h,v 1.27 2007/03/11 05:22:25 thorpej Exp $	*/
2
3/*
4 * Copyright (C) 1997 Scott Reynolds
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 * 3. The name of the author may not be used to endorse or promote products
16 *    derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef _MAC68K_INTR_H_
31#define _MAC68K_INTR_H_
32
33#include <machine/psl.h>
34
35#ifdef _KERNEL
36
37/* spl0 requires checking for software interrupts */
38
39/*
40 * This array contains the appropriate PSL_S|PSL_IPL? values
41 * to raise interrupt priority to the requested level.
42 */
43extern unsigned short mac68k_ipls[];
44
45#define	IPL_NONE	0
46#define	IPL_SOFTCLOCK	1
47#define	IPL_SOFTNET	2
48#define	IPL_SOFTSERIAL	3
49#define	IPL_SOFT	4
50#define	IPL_BIO		5
51#define	IPL_NET		6
52#define	IPL_TTY		7
53#define	IPL_VM		8
54#define	IPL_AUDIO	9
55#define	IPL_ADB		10
56#define	IPL_STATCLOCK	11
57#define	IPL_CLOCK	12
58#define	IPL_SCHED	13
59#define	IPL_SERIAL	14
60#define	IPL_HIGH	15
61#define	IPL_LOCK	IPL_HIGH
62#define	NIPL		16
63
64/* These spl calls are _not_ to be used by machine-independent code. */
65#define	splsoft()	splraise1()
66#define	spladb()	_splraise(mac68k_ipls[IPL_ADB])
67#define	splzs()		splserial()
68
69/*
70 * These should be used for:
71 * 1) ensuring mutual exclusion (why use processor level?)
72 * 2) allowing faster devices to take priority
73 */
74
75/* watch out for side effects */
76#define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
77
78
79typedef int ipl_t;
80typedef struct {
81	uint16_t _ipl;
82} ipl_cookie_t;
83
84static inline ipl_cookie_t
85makeiplcookie(ipl_t ipl)
86{
87
88	return (ipl_cookie_t){._ipl = ipl};
89}
90
91static inline int
92splraiseipl(ipl_cookie_t icookie)
93{
94
95	return _splraise(mac68k_ipls[icookie._ipl]);
96}
97
98#include <sys/spl.h>
99
100#include <m68k/softintr.h>
101
102/* intr.c */
103void	intr_init(void);
104void	intr_establish(int (*)(void *), void *, int);
105void	intr_disestablish(int);
106void	intr_dispatch(int);
107
108/* locore.s */
109int	spl0(void);
110#endif /* _KERNEL */
111
112#endif /* _MAC68K_INTR_H_ */
113