intr.h revision 1.27
11.27Schristos/*	$NetBSD: intr.h,v 1.27 2018/04/19 21:50:07 christos Exp $	*/
21.1Stsutsui
31.21Stsutsui/*-
41.21Stsutsui * Copyright (c) 1998 The NetBSD Foundation, Inc.
51.1Stsutsui * All rights reserved.
61.1Stsutsui *
71.1Stsutsui * This code is derived from software contributed to The NetBSD Foundation
81.1Stsutsui * by Minoura Makoto and Jason R. Thorpe.
91.1Stsutsui *
101.1Stsutsui * Redistribution and use in source and binary forms, with or without
111.1Stsutsui * modification, are permitted provided that the following conditions
121.1Stsutsui * are met:
131.1Stsutsui * 1. Redistributions of source code must retain the above copyright
141.1Stsutsui *    notice, this list of conditions and the following disclaimer.
151.1Stsutsui * 2. Redistributions in binary form must reproduce the above copyright
161.1Stsutsui *    notice, this list of conditions and the following disclaimer in the
171.1Stsutsui *    documentation and/or other materials provided with the distribution.
181.1Stsutsui *
191.21Stsutsui * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.21Stsutsui * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.21Stsutsui * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.21Stsutsui * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.21Stsutsui * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.21Stsutsui * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.21Stsutsui * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.21Stsutsui * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.21Stsutsui * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.21Stsutsui * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.21Stsutsui * POSSIBILITY OF SUCH DAMAGE.
301.1Stsutsui */
311.1Stsutsui
321.1Stsutsui#ifndef _NEWS68K_INTR_H_
331.1Stsutsui#define	_NEWS68K_INTR_H_
341.1Stsutsui
351.25Stsutsui#include <sys/evcnt.h>
361.14Stsutsui#include <sys/queue.h>
371.1Stsutsui#include <machine/psl.h>
381.5Stsutsui#include <m68k/asm_single.h>
391.1Stsutsui
401.13Syamt#define	IPL_NONE	0
411.14Stsutsui#define	IPL_SOFTCLOCK	1
421.19Sad#define	IPL_SOFTBIO	2
431.19Sad#define	IPL_SOFTNET	3
441.19Sad#define	IPL_SOFTSERIAL	4
451.19Sad#define	IPL_VM		5
461.19Sad#define	IPL_SCHED	6
471.22Stsutsui#define	IPL_HIGH	7
481.22Stsutsui#define	NIPL		8
491.13Syamt
501.20Stsutsuiextern int idepth;
511.23Stsutsui
521.27Schristosstatic __inline bool
531.23Stsutsuicpu_intr_p(void)
541.23Stsutsui{
551.23Stsutsui
561.23Stsutsui	return idepth != 0;
571.26Stsutsui}
581.26Stsutsui
591.22Stsutsuiextern const uint16_t ipl2psl_table[NIPL];
601.20Stsutsui
611.13Syamttypedef int ipl_t;
621.13Syamttypedef struct {
631.18Sthorpej	uint16_t _psl;
641.13Syamt} ipl_cookie_t;
651.13Syamt
661.27Schristosstatic __inline ipl_cookie_t
671.22Stsutsuimakeiplcookie(ipl_t ipl)
681.22Stsutsui{
691.22Stsutsui
701.22Stsutsui	return (ipl_cookie_t){._psl = ipl2psl_table[ipl]};
711.22Stsutsui}
721.13Syamt
731.27Schristosstatic __inline int
741.13Syamtsplraiseipl(ipl_cookie_t icookie)
751.13Syamt{
761.13Syamt
771.14Stsutsui	return _splraise(icookie._psl);
781.13Syamt}
791.13Syamt
801.27Schristosstatic __inline void
811.9Stsutsuisplx(int sr)
821.9Stsutsui{
831.9Stsutsui
841.11Sperry	__asm volatile("movw %0,%%sr" : : "di" (sr));
851.9Stsutsui}
861.1Stsutsui
871.1Stsutsui/*
881.14Stsutsui * news68k can handle software interrupts by its own hardware
891.14Stsutsui * so has no need to check for any simulated interrupts, etc.
901.14Stsutsui */
911.14Stsutsui#define	spl0()		_spl0()
921.14Stsutsui
931.19Sad#define	splsoftbio()	splraise2()
941.19Sad#define	splsoftclock()	splraise2()
951.19Sad#define	splsoftnet()	splraise2()
961.19Sad#define	splsoftserial()	splraise2()
971.14Stsutsui#define	splvm()		splraise5()
981.14Stsutsui#define	splhigh()	spl7()
991.14Stsutsui#define	splsched()	spl7()
1001.1Stsutsui
1011.1Stsutsui#endif /* _NEWS68K_INTR_H_ */
102