11.3Schristos/*	$NetBSD: intr.h,v 1.3 2018/04/19 21:50:06 christos Exp $	*/
21.1Smatt
31.1Smatt/*-
41.1Smatt * Copyright (c) 2000 The NetBSD Foundation, Inc.
51.1Smatt * All rights reserved.
61.1Smatt *
71.1Smatt * This code is derived from software contributed to The NetBSD Foundation
81.1Smatt * by Jason R. Thorpe and Steve C. Woodford.
91.1Smatt *
101.1Smatt * Redistribution and use in source and binary forms, with or without
111.1Smatt * modification, are permitted provided that the following conditions
121.1Smatt * are met:
131.1Smatt * 1. Redistributions of source code must retain the above copyright
141.1Smatt *    notice, this list of conditions and the following disclaimer.
151.1Smatt * 2. Redistributions in binary form must reproduce the above copyright
161.1Smatt *    notice, this list of conditions and the following disclaimer in the
171.1Smatt *    documentation and/or other materials provided with the distribution.
181.1Smatt *
191.1Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.1Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.1Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.1Smatt * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.1Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.1Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.1Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.1Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.1Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.1Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.1Smatt * POSSIBILITY OF SUCH DAMAGE.
301.1Smatt */
311.1Smatt
321.1Smatt#ifndef _EVBCF_INTR_H
331.1Smatt#define _EVBCF_INTR_H
341.1Smatt
351.1Smatt#include <machine/psl.h>
361.1Smatt
371.1Smatt#define	IPL_NONE	0	/* disable only this interrupt */
381.1Smatt#define	IPL_SOFTCLOCK	1	/* clock software interrupts */
391.1Smatt#define	IPL_SOFTBIO	2	/* block software interrupts */
401.1Smatt#define	IPL_SOFTNET	3	/* network software interrupts */
411.1Smatt#define	IPL_SOFTSERIAL	4	/* serial software interrupts */
421.1Smatt#define	IPL_VM		5
431.1Smatt#define	IPL_SCHED	6
441.1Smatt#define	IPL_HIGH	7
451.1Smatt#define	NIPL		8
461.1Smatt
471.1Smatt#ifdef _KERNEL
481.1Smatt#define spl0()			_spl0()
491.1Smatt#define splsoftclock()		splraise1()
501.1Smatt#define splsoftbio()		splraise1()
511.1Smatt#define splsoftnet()		splraise1()
521.1Smatt#define splsoftserial()		splraise1()
531.1Smatt#define splvm()			splraise3()
541.1Smatt#define splsched()		spl7()
551.1Smatt#define splhigh()		spl7()
561.1Smatt
571.1Smatt#ifndef _LOCORE
581.1Smatt
591.1Smattextern const uint16_t ipl2psl_table[NIPL];
601.1Smatt
611.1Smatttypedef int ipl_t;
621.1Smatttypedef struct {
631.1Smatt	uint16_t _psl;
641.1Smatt} ipl_cookie_t;
651.1Smatt
661.3Schristosstatic __inline ipl_cookie_t
671.1Smattmakeiplcookie(ipl_t ipl)
681.1Smatt{
691.1Smatt
701.1Smatt	return (ipl_cookie_t){._psl = ipl2psl_table[ipl]};
711.1Smatt}
721.1Smatt
731.3Schristosstatic __inline int
741.1Smattsplraiseipl(ipl_cookie_t icookie)
751.1Smatt{
761.1Smatt
771.1Smatt	return _splraise(icookie._psl);
781.1Smatt}
791.1Smatt
801.1Smattstatic __inline void
811.1Smattsplx(int sr)
821.1Smatt{
831.1Smatt
841.1Smatt	__asm volatile("movw %0,%%sr" : : "di" (sr));
851.1Smatt}
861.1Smatt
871.1Smatt#endif /* !_LOCORE */
881.1Smatt#endif /* _KERNEL */
891.1Smatt
901.1Smatt#endif /* _EVBCF_INTR_H */
91