1 1.12 skrll /* $NetBSD: intr.h,v 1.12 2020/07/27 12:32:54 skrll Exp $ */ 2 1.1 gavan 3 1.1 gavan /* 4 1.1 gavan * Copyright (c) 2001, 2003 Wasabi Systems, Inc. 5 1.1 gavan * All rights reserved. 6 1.1 gavan * 7 1.1 gavan * Written by Jason R. Thorpe for Wasabi Systems, Inc. 8 1.1 gavan * 9 1.1 gavan * Redistribution and use in source and binary forms, with or without 10 1.1 gavan * modification, are permitted provided that the following conditions 11 1.1 gavan * are met: 12 1.1 gavan * 1. Redistributions of source code must retain the above copyright 13 1.1 gavan * notice, this list of conditions and the following disclaimer. 14 1.1 gavan * 2. Redistributions in binary form must reproduce the above copyright 15 1.1 gavan * notice, this list of conditions and the following disclaimer in the 16 1.1 gavan * documentation and/or other materials provided with the distribution. 17 1.1 gavan * 3. All advertising materials mentioning features or use of this software 18 1.1 gavan * must display the following acknowledgement: 19 1.1 gavan * This product includes software developed for the NetBSD Project by 20 1.1 gavan * Wasabi Systems, Inc. 21 1.1 gavan * 4. The name of Wasabi Systems, Inc. may not be used to endorse 22 1.1 gavan * or promote products derived from this software without specific prior 23 1.1 gavan * written permission. 24 1.1 gavan * 25 1.1 gavan * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 26 1.1 gavan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27 1.1 gavan * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28 1.1 gavan * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 29 1.1 gavan * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 1.1 gavan * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 1.1 gavan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 1.1 gavan * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 1.1 gavan * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 1.1 gavan * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 1.1 gavan * POSSIBILITY OF SUCH DAMAGE. 36 1.1 gavan */ 37 1.1 gavan 38 1.1 gavan #ifndef _IYONIX_INTR_H_ 39 1.1 gavan #define _IYONIX_INTR_H_ 40 1.1 gavan 41 1.1 gavan #ifdef _KERNEL 42 1.1 gavan 43 1.1 gavan /* Interrupt priority "levels". */ 44 1.1 gavan #define IPL_NONE 0 /* nothing */ 45 1.8 ad #define IPL_SOFTCLOCK 1 /* software clock interrupt */ 46 1.8 ad #define IPL_SOFTBIO 2 /* generic software interrupts */ 47 1.1 gavan #define IPL_SOFTNET 3 /* software network interrupt */ 48 1.8 ad #define IPL_SOFTSERIAL 4 /* software serial interrupt */ 49 1.8 ad #define IPL_VM 5 /* memory allocation */ 50 1.8 ad #define IPL_SCHED 6 /* scheduler */ 51 1.8 ad #define IPL_HIGH 6 /* everything */ 52 1.1 gavan 53 1.8 ad #define NIPL 7 54 1.1 gavan 55 1.1 gavan /* Interrupt sharing types. */ 56 1.1 gavan #define IST_NONE 0 /* none */ 57 1.1 gavan #define IST_PULSE 1 /* pulsed */ 58 1.1 gavan #define IST_EDGE 2 /* edge-triggered */ 59 1.1 gavan #define IST_LEVEL 3 /* level-triggered */ 60 1.1 gavan 61 1.1 gavan #define IST_LEVEL_LOW IST_LEVEL 62 1.1 gavan #define IST_LEVEL_HIGH 4 63 1.1 gavan #define IST_EDGE_FALLING IST_EDGE 64 1.1 gavan #define IST_EDGE_RISING 5 65 1.1 gavan #define IST_EDGE_BOTH 6 66 1.1 gavan 67 1.1 gavan #ifndef _LOCORE 68 1.1 gavan 69 1.12 skrll #if defined(_MODULE) 70 1.12 skrll 71 1.12 skrll int _splraise(int); 72 1.12 skrll int _spllower(int); 73 1.12 skrll void splx(int); 74 1.12 skrll 75 1.12 skrll #else /* _MODULE */ 76 1.12 skrll 77 1.1 gavan #include "opt_arm_intr_impl.h" 78 1.1 gavan 79 1.1 gavan #if defined(ARM_INTR_IMPL) 80 1.1 gavan 81 1.1 gavan /* 82 1.1 gavan * Each board needs to define the following functions: 83 1.1 gavan * 84 1.1 gavan * int _splraise(int); 85 1.1 gavan * int _spllower(int); 86 1.1 gavan * void splx(int); 87 1.1 gavan * void _setsoftintr(int); 88 1.1 gavan * 89 1.3 perry * These may be defined as functions, static inline functions, or macros, 90 1.1 gavan * but there must be a _spllower() and splx() defined as functions callable 91 1.1 gavan * from assembly language (for cpu_switch()). However, since it's quite 92 1.1 gavan * useful to be able to inline splx(), you could do something like the 93 1.1 gavan * following: 94 1.1 gavan * 95 1.1 gavan * in <boardtype>_intr.h: 96 1.3 perry * static inline int 97 1.1 gavan * boardtype_splx(int spl) 98 1.1 gavan * {...} 99 1.1 gavan * 100 1.1 gavan * #define splx(nspl) boardtype_splx(nspl) 101 1.1 gavan * ... 102 1.1 gavan * and in boardtype's machdep code: 103 1.1 gavan * 104 1.1 gavan * ... 105 1.1 gavan * #undef splx 106 1.1 gavan * int 107 1.1 gavan * splx(int spl) 108 1.1 gavan * { 109 1.1 gavan * return boardtype_splx(spl); 110 1.1 gavan * } 111 1.1 gavan */ 112 1.1 gavan 113 1.1 gavan #include ARM_INTR_IMPL 114 1.1 gavan 115 1.1 gavan #else /* ARM_INTR_IMPL */ 116 1.1 gavan 117 1.1 gavan #error ARM_INTR_IMPL not defined. 118 1.1 gavan 119 1.1 gavan #endif /* ARM_INTR_IMPL */ 120 1.1 gavan 121 1.12 skrll #endif /* _MODULE */ 122 1.12 skrll 123 1.7 thorpej typedef uint8_t ipl_t; 124 1.5 yamt typedef struct { 125 1.5 yamt ipl_t _ipl; 126 1.5 yamt } ipl_cookie_t; 127 1.5 yamt 128 1.5 yamt static inline ipl_cookie_t 129 1.5 yamt makeiplcookie(ipl_t ipl) 130 1.5 yamt { 131 1.5 yamt 132 1.5 yamt return (ipl_cookie_t){._ipl = ipl}; 133 1.5 yamt } 134 1.5 yamt 135 1.5 yamt static inline int 136 1.5 yamt splraiseipl(ipl_cookie_t icookie) 137 1.5 yamt { 138 1.5 yamt 139 1.5 yamt return _splraise(icookie._ipl); 140 1.5 yamt } 141 1.1 gavan 142 1.1 gavan #define spl0() _spllower(IPL_NONE) 143 1.1 gavan 144 1.4 yamt #include <sys/spl.h> 145 1.1 gavan 146 1.1 gavan #endif /* ! _LOCORE */ 147 1.1 gavan 148 1.1 gavan #endif /* _KERNEL */ 149 1.1 gavan 150 1.1 gavan #endif /* _IYONIX_INTR_H_ */ 151