11.12Schristos/* $NetBSD: intr.h,v 1.12 2021/06/05 21:24:17 christos Exp $ */ 21.1Sober 31.1Sober/* 41.1Sober * Copyright (c) 2001, 2003 Wasabi Systems, Inc. 51.1Sober * All rights reserved. 61.1Sober * 71.1Sober * Written by Jason R. Thorpe for Wasabi Systems, Inc. 81.1Sober * 91.1Sober * Redistribution and use in source and binary forms, with or without 101.1Sober * modification, are permitted provided that the following conditions 111.1Sober * are met: 121.1Sober * 1. Redistributions of source code must retain the above copyright 131.1Sober * notice, this list of conditions and the following disclaimer. 141.1Sober * 2. Redistributions in binary form must reproduce the above copyright 151.1Sober * notice, this list of conditions and the following disclaimer in the 161.1Sober * documentation and/or other materials provided with the distribution. 171.1Sober * 3. All advertising materials mentioning features or use of this software 181.1Sober * must display the following acknowledgement: 191.1Sober * This product includes software developed for the NetBSD Project by 201.1Sober * Wasabi Systems, Inc. 211.1Sober * 4. The name of Wasabi Systems, Inc. may not be used to endorse 221.1Sober * or promote products derived from this software without specific prior 231.1Sober * written permission. 241.1Sober * 251.1Sober * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 261.1Sober * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 271.1Sober * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 281.1Sober * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 291.1Sober * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 301.1Sober * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 311.1Sober * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 321.1Sober * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 331.1Sober * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 341.1Sober * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 351.1Sober * POSSIBILITY OF SUCH DAMAGE. 361.1Sober */ 371.1Sober 381.1Sober#ifndef _ZAURUS_INTR_H_ 391.1Sober#define _ZAURUS_INTR_H_ 401.1Sober 411.1Sober#ifdef _KERNEL 421.1Sober 431.1Sober/* Interrupt priority "levels". */ 441.1Sober#define IPL_NONE 0 /* nothing */ 451.5Sad#define IPL_SOFTCLOCK 1 /* timeouts */ 461.5Sad#define IPL_SOFTBIO 2 /* block I/O */ 471.1Sober#define IPL_SOFTNET 3 /* software network interrupt */ 481.5Sad#define IPL_SOFTSERIAL 4 /* software serial interrupt */ 491.5Sad#define IPL_VM 5 /* memory allocation */ 501.5Sad#define IPL_SCHED 6 /* clock interrupt */ 511.5Sad#define IPL_HIGH 7 /* everything */ 521.1Sober 531.5Sad#define NIPL 8 541.1Sober 551.1Sober/* Interrupt sharing types. */ 561.1Sober#define IST_NONE 0 /* none */ 571.1Sober#define IST_PULSE 1 /* pulsed */ 581.1Sober#define IST_EDGE 2 /* edge-triggered */ 591.1Sober#define IST_LEVEL 3 /* level-triggered */ 601.1Sober 611.1Sober#define IST_LEVEL_LOW IST_LEVEL 621.1Sober#define IST_LEVEL_HIGH 4 631.1Sober#define IST_EDGE_FALLING IST_EDGE 641.1Sober#define IST_EDGE_RISING 5 651.1Sober#define IST_EDGE_BOTH 6 661.1Sober 671.1Sober#ifndef _LOCORE 681.1Sober 691.1Sober#include <sys/queue.h> 701.1Sober 711.11Sskrll#if defined(_MODULE) 721.11Sskrll 731.11Sskrllint _splraise(int); 741.11Sskrllint _spllower(int); 751.11Sskrllvoid splx(int); 761.11Sskrll 771.11Sskrll#else /* _MODULE */ 781.11Sskrll 791.1Sober#include "opt_arm_intr_impl.h" 801.1Sober 811.1Sober#if defined(ARM_INTR_IMPL) 821.1Sober 831.1Sober/* 841.1Sober * Each board needs to define the following functions: 851.1Sober * 861.1Sober * int _splraise(int); 871.1Sober * int _spllower(int); 881.1Sober * void splx(int); 891.1Sober * 901.1Sober * These may be defined as functions, static inline functions, or macros, 911.1Sober * but there must be a _spllower() and splx() defined as functions callable 921.1Sober * from assembly language (for cpu_switch()). However, since it's quite 931.1Sober * useful to be able to inline splx(), you could do something like the 941.1Sober * following: 951.1Sober * 961.1Sober * in <boardtype>_intr.h: 971.1Sober * static inline int 981.1Sober * boardtype_splx(int spl) 991.1Sober * {...} 1001.1Sober * 1011.1Sober * #define splx(nspl) boardtype_splx(nspl) 1021.1Sober * ... 1031.1Sober * and in boardtype's machdep code: 1041.1Sober * 1051.1Sober * ... 1061.1Sober * #undef splx 1071.1Sober * int 1081.1Sober * splx(int spl) 1091.1Sober * { 1101.1Sober * return boardtype_splx(spl); 1111.1Sober * } 1121.1Sober */ 1131.1Sober 1141.1Sober#include ARM_INTR_IMPL 1151.1Sober 1161.1Sober#else /* ARM_INTR_IMPL */ 1171.1Sober 1181.1Sober#error ARM_INTR_IMPL not defined. 1191.1Sober 1201.1Sober#endif /* ARM_INTR_IMPL */ 1211.1Sober 1221.11Sskrll#endif /* _MODULE */ 1231.11Sskrll 1241.4Sthorpejtypedef uint8_t ipl_t; 1251.2Syamttypedef struct { 1261.2Syamt ipl_t _ipl; 1271.2Syamt} ipl_cookie_t; 1281.2Syamt 1291.2Syamtstatic inline ipl_cookie_t 1301.2Syamtmakeiplcookie(ipl_t ipl) 1311.2Syamt{ 1321.2Syamt 1331.2Syamt return (ipl_cookie_t){._ipl = ipl}; 1341.2Syamt} 1351.2Syamt 1361.2Syamtstatic inline int 1371.2Syamtsplraiseipl(ipl_cookie_t icookie) 1381.2Syamt{ 1391.2Syamt 1401.2Syamt return _splraise(icookie._ipl); 1411.2Syamt} 1421.1Sober 1431.1Sober#define spl0() _spllower(IPL_NONE) 1441.1Sober 1451.1Sober#include <sys/spl.h> 1461.1Sober 1471.1Sober#endif /* ! _LOCORE */ 1481.1Sober 1491.1Sober#endif /* _KERNEL */ 1501.1Sober 1511.1Sober#endif /* _ZAURUS_INTR_H_ */ 152