11.29Sriastrad/* $NetBSD: intr.h,v 1.29 2023/07/11 10:42:07 riastradh Exp $ */ 21.1Smatt 31.1Smatt/* 41.10Sthorpej * Copyright (c) 2001, 2003 Wasabi Systems, Inc. 51.1Smatt * All rights reserved. 61.1Smatt * 71.7Sthorpej * Written by Jason R. Thorpe for Wasabi Systems, Inc. 81.7Sthorpej * 91.1Smatt * Redistribution and use in source and binary forms, with or without 101.1Smatt * modification, are permitted provided that the following conditions 111.1Smatt * are met: 121.1Smatt * 1. Redistributions of source code must retain the above copyright 131.1Smatt * notice, this list of conditions and the following disclaimer. 141.1Smatt * 2. Redistributions in binary form must reproduce the above copyright 151.1Smatt * notice, this list of conditions and the following disclaimer in the 161.1Smatt * documentation and/or other materials provided with the distribution. 171.1Smatt * 3. All advertising materials mentioning features or use of this software 181.1Smatt * must display the following acknowledgement: 191.7Sthorpej * This product includes software developed for the NetBSD Project by 201.7Sthorpej * Wasabi Systems, Inc. 211.7Sthorpej * 4. The name of Wasabi Systems, Inc. may not be used to endorse 221.7Sthorpej * or promote products derived from this software without specific prior 231.7Sthorpej * written permission. 241.1Smatt * 251.7Sthorpej * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 261.7Sthorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 271.7Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 281.7Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 291.7Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 301.7Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 311.7Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 321.7Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 331.7Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 341.7Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 351.7Sthorpej * POSSIBILITY OF SUCH DAMAGE. 361.1Smatt */ 371.1Smatt 381.7Sthorpej#ifndef _EVBARM_INTR_H_ 391.7Sthorpej#define _EVBARM_INTR_H_ 401.3Srearnsha 411.7Sthorpej#ifdef _KERNEL 421.3Srearnsha 431.7Sthorpej/* Interrupt priority "levels". */ 441.19Smatt#define IPL_NONE 0 /* nothing */ 451.19Smatt#define IPL_SOFTCLOCK 1 /* clock */ 461.19Smatt#define IPL_SOFTBIO 2 /* block I/O */ 471.19Smatt#define IPL_SOFTNET 3 /* software network interrupt */ 481.19Smatt#define IPL_SOFTSERIAL 4 /* software serial interrupt */ 491.19Smatt#define IPL_VM 5 /* memory allocation */ 501.19Smatt#define IPL_SCHED 6 /* clock interrupt */ 511.19Smatt#define IPL_HIGH 7 /* everything */ 521.3Srearnsha 531.18Sad#define NIPL 8 541.3Srearnsha 551.7Sthorpej/* Interrupt sharing types. */ 561.7Sthorpej#define IST_NONE 0 /* none */ 571.3Srearnsha#define IST_PULSE 1 /* pulsed */ 581.3Srearnsha#define IST_EDGE 2 /* edge-triggered */ 591.3Srearnsha#define IST_LEVEL 3 /* level-triggered */ 601.11Sbsh 611.20Smatt#define IST_LEVEL_LOW IST_LEVEL 621.20Smatt#define IST_LEVEL_HIGH 4 631.11Sbsh#define IST_EDGE_FALLING IST_EDGE 641.20Smatt#define IST_EDGE_RISING 5 651.20Smatt#define IST_EDGE_BOTH 6 661.20Smatt#define IST_SOFT 7 671.3Srearnsha 681.26Smatt#define IST_MPSAFE 0x100 /* interrupt is MPSAFE */ 691.26Smatt 701.7Sthorpej#ifndef _LOCORE 711.7Sthorpej 721.7Sthorpej#include <sys/queue.h> 731.7Sthorpej 741.29Sriastradtypedef uint8_t ipl_t; 751.29Sriastradtypedef struct { 761.29Sriastrad ipl_t _ipl; 771.29Sriastrad} ipl_cookie_t; 781.29Sriastrad 791.28Sskrll#if defined(_MODULE) 801.28Sskrll 811.28Sskrllint _splraise(int); 821.28Sskrllint _spllower(int); 831.28Sskrllvoid splx(int); 841.28Sskrll 851.28Sskrll#else /* _MODULE */ 861.28Sskrll 871.10Sthorpej#include "opt_arm_intr_impl.h" 881.8Sbriggs 891.10Sthorpej#if defined(ARM_INTR_IMPL) 901.8Sbriggs 911.8Sbriggs/* 921.8Sbriggs * Each board needs to define the following functions: 931.8Sbriggs * 941.8Sbriggs * int _splraise(int); 951.8Sbriggs * int _spllower(int); 961.8Sbriggs * void splx(int); 971.8Sbriggs * 981.13Sperry * These may be defined as functions, static inline functions, or macros, 991.8Sbriggs * but there must be a _spllower() and splx() defined as functions callable 1001.8Sbriggs * from assembly language (for cpu_switch()). However, since it's quite 1011.8Sbriggs * useful to be able to inline splx(), you could do something like the 1021.8Sbriggs * following: 1031.8Sbriggs * 1041.8Sbriggs * in <boardtype>_intr.h: 1051.13Sperry * static inline int 1061.8Sbriggs * boardtype_splx(int spl) 1071.8Sbriggs * {...} 1081.8Sbriggs * 1091.8Sbriggs * #define splx(nspl) boardtype_splx(nspl) 1101.8Sbriggs * ... 1111.8Sbriggs * and in boardtype's machdep code: 1121.8Sbriggs * 1131.8Sbriggs * ... 1141.8Sbriggs * #undef splx 1151.8Sbriggs * int 1161.8Sbriggs * splx(int spl) 1171.8Sbriggs * { 1181.8Sbriggs * return boardtype_splx(spl); 1191.8Sbriggs * } 1201.8Sbriggs */ 1211.8Sbriggs 1221.10Sthorpej#include ARM_INTR_IMPL 1231.8Sbriggs 1241.10Sthorpej#else /* ARM_INTR_IMPL */ 1251.8Sbriggs 1261.10Sthorpej#error ARM_INTR_IMPL not defined. 1271.8Sbriggs 1281.10Sthorpej#endif /* ARM_INTR_IMPL */ 1291.8Sbriggs 1301.28Sskrll#endif /* _MODULE */ 1311.28Sskrll 1321.15Syamtstatic inline ipl_cookie_t 1331.15Syamtmakeiplcookie(ipl_t ipl) 1341.15Syamt{ 1351.15Syamt 1361.15Syamt return (ipl_cookie_t){._ipl = ipl}; 1371.15Syamt} 1381.15Syamt 1391.15Syamtstatic inline int 1401.15Syamtsplraiseipl(ipl_cookie_t icookie) 1411.15Syamt{ 1421.15Syamt 1431.15Syamt return _splraise(icookie._ipl); 1441.15Syamt} 1451.7Sthorpej 1461.7Sthorpej#define spl0() _spllower(IPL_NONE) 1471.7Sthorpej 1481.14Syamt#include <sys/spl.h> 1491.7Sthorpej 1501.10Sthorpej#endif /* ! _LOCORE */ 1511.7Sthorpej 1521.7Sthorpej#endif /* _KERNEL */ 1531.7Sthorpej 1541.7Sthorpej#endif /* _EVBARM_INTR_H_ */ 155