intr.h revision 1.23
11.23Sisaki/* $NetBSD: intr.h,v 1.23 2024/01/07 07:58:33 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.21Stsutsui#define spl0() _spl0() 381.1Sminoura 391.17Sad#define splsoftbio() splraise1() 401.17Sad#define splsoftclock() splraise1() 411.17Sad#define splsoftnet() splraise1() 421.17Sad#define splsoftserial() splraise1() 431.23Sisaki#define splvm() splraise5() 441.23Sisaki#define splsched() spl7() 451.23Sisaki#define splhigh() spl7() 461.13Stsutsui 471.10Syamt#define splnone() spl0() 481.10Syamt#define splzs() splraise5() /* disallow serial interrupts */ 491.1Sminoura 501.10Syamt#define IPL_NONE 0 511.13Stsutsui#define IPL_SOFTCLOCK 1 521.17Sad#define IPL_SOFTBIO 2 531.17Sad#define IPL_SOFTNET 3 541.17Sad#define IPL_SOFTSERIAL 4 551.17Sad#define IPL_VM 5 561.19Sisaki#define IPL_SCHED 6 571.20Sisaki#define IPL_HIGH 7 581.20Sisaki#define NIPL 8 591.20Sisaki 601.20Sisakiextern const uint16_t ipl2psl_table[NIPL]; 611.10Syamt 621.11Syamttypedef int ipl_t; 631.11Syamttypedef struct { 641.15Sthorpej uint16_t _psl; 651.11Syamt} ipl_cookie_t; 661.11Syamt 671.22Sriastrad#ifdef _KERNEL 681.22Sriastrad 691.20Sisakistatic inline ipl_cookie_t 701.20Sisakimakeiplcookie(ipl_t ipl) 711.20Sisaki{ 721.20Sisaki 731.20Sisaki return (ipl_cookie_t){._psl = ipl2psl_table[ipl]}; 741.20Sisaki} 751.11Syamt 761.11Syamtstatic inline int 771.11Syamtsplraiseipl(ipl_cookie_t icookie) 781.11Syamt{ 791.11Syamt 801.13Stsutsui return _splraise(icookie._psl); 811.11Syamt} 821.10Syamt 831.21Stsutsuistatic inline void 841.21Stsutsuisplx(int sr) 851.21Stsutsui{ 861.21Stsutsui 871.21Stsutsui __asm volatile("movew %0,%%sr" : : "di" (sr)); 881.21Stsutsui} 891.22Sriastrad 901.22Sriastrad#endif /* _KERNEL */ 911.22Sriastrad 921.13Stsutsui#endif /* !_X68K_INTR_H_ */ 93