intr.h revision 1.19
11.19Sisaki/*	$NetBSD: intr.h,v 1.19 2008/05/23 13:07:44 isaki Exp $	*/
21.1Sminoura
31.5Sminoura/*-
41.5Sminoura * Copyright (c) 1998 The NetBSD Foundation, Inc.
51.1Sminoura * All rights reserved.
61.1Sminoura *
71.1Sminoura * This code is derived from software contributed to The NetBSD Foundation
81.1Sminoura * by Minoura Makoto and Jason R. Thorpe.
91.1Sminoura *
101.1Sminoura * Redistribution and use in source and binary forms, with or without
111.1Sminoura * modification, are permitted provided that the following conditions
121.1Sminoura * are met:
131.1Sminoura * 1. Redistributions of source code must retain the above copyright
141.1Sminoura *    notice, this list of conditions and the following disclaimer.
151.1Sminoura * 2. Redistributions in binary form must reproduce the above copyright
161.1Sminoura *    notice, this list of conditions and the following disclaimer in the
171.1Sminoura *    documentation and/or other materials provided with the distribution.
181.1Sminoura *
191.5Sminoura * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.5Sminoura * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.5Sminoura * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.5Sminoura * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.5Sminoura * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.5Sminoura * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.5Sminoura * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.5Sminoura * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.5Sminoura * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.5Sminoura * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.5Sminoura * POSSIBILITY OF SUCH DAMAGE.
301.1Sminoura */
311.1Sminoura
321.1Sminoura#ifndef _X68K_INTR_H_
331.1Sminoura#define	_X68K_INTR_H_
341.1Sminoura
351.1Sminoura#include <machine/psl.h>
361.1Sminoura
371.1Sminoura/* spl0 requires checking for software interrupts */
381.9Schsvoid	spl0(void);
391.1Sminoura
401.17Sad#define splsoftbio()	splraise1()
411.17Sad#define splsoftclock()	splraise1()
421.17Sad#define splsoftnet()	splraise1()
431.17Sad#define splsoftserial()	splraise1()
441.19Sisaki#define splvm()         splraise5()
451.17Sad#define splsched()      spl7()
461.13Stsutsui#define splhigh()       spl7()
471.13Stsutsui
481.10Syamt#define	splnone()	spl0()
491.10Syamt#define	splzs()		splraise5()	/* disallow serial interrupts */
501.1Sminoura
511.1Sminoura/* watch out for side effects */
521.1Sminoura#define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
531.1Sminoura
541.10Syamt#define	IPL_NONE	0
551.13Stsutsui#define	IPL_SOFTCLOCK	1
561.17Sad#define	IPL_SOFTBIO	2
571.17Sad#define	IPL_SOFTNET	3
581.17Sad#define	IPL_SOFTSERIAL	4
591.17Sad#define	IPL_VM		5
601.19Sisaki#define	IPL_SCHED	6
611.17Sad#define	IPL_HIGH	6
621.17Sad#define	NIPL		7
631.10Syamt
641.11Syamttypedef int ipl_t;
651.11Syamttypedef struct {
661.15Sthorpej	uint16_t _psl;
671.11Syamt} ipl_cookie_t;
681.11Syamt
691.13Stsutsuiipl_cookie_t makeiplcookie(ipl_t);
701.11Syamt
711.11Syamtstatic inline int
721.11Syamtsplraiseipl(ipl_cookie_t icookie)
731.11Syamt{
741.11Syamt
751.13Stsutsui	return _splraise(icookie._psl);
761.11Syamt}
771.10Syamt
781.13Stsutsui#endif /* !_X68K_INTR_H_ */
79