intr.h revision 1.22
1/* $NetBSD: intr.h,v 1.22 1999/11/29 19:58:39 thorpej Exp $ */ 2 3/* 4 * Copyright (c) 1997 Christopher G. Demetriou. All rights reserved. 5 * Copyright (c) 1996 Carnegie-Mellon University. 6 * All rights reserved. 7 * 8 * Author: Chris G. Demetriou 9 * 10 * Permission to use, copy, modify and distribute this software and 11 * its documentation is hereby granted, provided that both the copyright 12 * notice and this permission notice appear in all copies of the 13 * software, derivative works or modified versions, and any portions 14 * thereof, and that both notices appear in supporting documentation. 15 * 16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 18 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 19 * 20 * Carnegie Mellon requests users of this software to return to 21 * 22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 23 * School of Computer Science 24 * Carnegie Mellon University 25 * Pittsburgh PA 15213-3890 26 * 27 * any improvements or extensions that they make and grant Carnegie the 28 * rights to redistribute these changes. 29 */ 30 31#ifndef _ALPHA_INTR_H_ 32#define _ALPHA_INTR_H_ 33 34#include <sys/queue.h> 35 36#define IPL_NONE 0 /* disable only this interrupt */ 37#define IPL_BIO 1 /* disable block I/O interrupts */ 38#define IPL_NET 2 /* disable network interrupts */ 39#define IPL_TTY 3 /* disable terminal interrupts */ 40#define IPL_CLOCK 4 /* disable clock interrupts */ 41#define IPL_HIGH 5 /* disable all interrupts */ 42#define IPL_SERIAL 6 /* disable serial interrupts */ 43 44#define IST_UNUSABLE -1 /* interrupt cannot be used */ 45#define IST_NONE 0 /* none (dummy) */ 46#define IST_PULSE 1 /* pulsed */ 47#define IST_EDGE 2 /* edge-triggered */ 48#define IST_LEVEL 3 /* level-triggered */ 49 50#ifdef _KERNEL 51 52/* IPL-lowering/restoring macros */ 53#define splx(s) \ 54 ((s) == ALPHA_PSL_IPL_0 ? spl0() : alpha_pal_swpipl(s)) 55#define spllowersoftclock() alpha_pal_swpipl(ALPHA_PSL_IPL_SOFT) 56 57/* IPL-raising functions/macros */ 58static __inline int _splraise __P((int)) __attribute__ ((unused)); 59static __inline int 60_splraise(s) 61 int s; 62{ 63 int cur = alpha_pal_rdps() & ALPHA_PSL_IPL_MASK; 64 return (s > cur ? alpha_pal_swpipl(s) : cur); 65} 66#define splsoft() _splraise(ALPHA_PSL_IPL_SOFT) 67#define splsoftserial() splsoft() 68#define splsoftclock() splsoft() 69#define splsoftnet() splsoft() 70#define splnet() _splraise(ALPHA_PSL_IPL_IO) 71#define splbio() _splraise(ALPHA_PSL_IPL_IO) 72#define splimp() _splraise(ALPHA_PSL_IPL_IO) 73#define spltty() _splraise(ALPHA_PSL_IPL_IO) 74#define splserial() _splraise(ALPHA_PSL_IPL_IO) 75#define splclock() _splraise(ALPHA_PSL_IPL_CLOCK) 76#define splstatclock() _splraise(ALPHA_PSL_IPL_CLOCK) 77#define splhigh() _splraise(ALPHA_PSL_IPL_HIGH) 78 79#define spllpt() spltty() 80 81/* 82 * simulated software interrupt register 83 */ 84extern u_int64_t ssir; 85 86#define SIR_NET 0x1 87#define SIR_CLOCK 0x2 88#define SIR_SERIAL 0x4 89 90#define setsoft(x) alpha_atomic_setbits_q(&ssir, (x)) 91 92#define setsoftnet() setsoft(SIR_NET) 93#define setsoftclock() setsoft(SIR_CLOCK) 94#define setsoftserial() setsoft(SIR_SERIAL) 95 96/* 97 * Interprocessor interrupts. In order how we want them processed. 98 */ 99#define ALPHA_IPI_HALT 0x0000000000000001UL 100#define ALPHA_IPI_TBIA 0x0000000000000002UL 101#define ALPHA_IPI_TBIAP 0x0000000000000004UL 102#define ALPHA_IPI_SHOOTDOWN 0x0000000000000008UL 103#define ALPHA_IPI_IMB 0x0000000000000010UL 104#define ALPHA_IPI_AST 0x0000000000000020UL 105 106#define ALPHA_NIPIS 6 /* must not exceed 64 */ 107 108typedef void (*ipifunc_t) __P((void)); 109extern ipifunc_t ipifuncs[ALPHA_NIPIS]; 110 111void alpha_send_ipi __P((unsigned long, unsigned long)); 112void alpha_broadcast_ipi __P((unsigned long)); 113 114/* 115 * Alpha shared-interrupt-line common code. 116 */ 117 118struct alpha_shared_intrhand { 119 TAILQ_ENTRY(alpha_shared_intrhand) 120 ih_q; 121 int (*ih_fn) __P((void *)); 122 void *ih_arg; 123 int ih_level; 124 unsigned int ih_num; 125}; 126 127struct alpha_shared_intr { 128 TAILQ_HEAD(,alpha_shared_intrhand) 129 intr_q; 130 void *intr_private; 131 int intr_sharetype; 132 int intr_dfltsharetype; 133 int intr_nstrays; 134 int intr_maxstrays; 135}; 136 137#define ALPHA_SHARED_INTR_DISABLE(asi, num) \ 138 ((asi)[num].intr_maxstrays != 0 && \ 139 (asi)[num].intr_nstrays == (asi)[num].intr_maxstrays) 140 141struct alpha_shared_intr *alpha_shared_intr_alloc __P((unsigned int)); 142int alpha_shared_intr_dispatch __P((struct alpha_shared_intr *, 143 unsigned int)); 144void *alpha_shared_intr_establish __P((struct alpha_shared_intr *, 145 unsigned int, int, int, int (*)(void *), void *, const char *)); 146void alpha_shared_intr_disestablish __P((struct alpha_shared_intr *, 147 void *, const char *)); 148int alpha_shared_intr_get_sharetype __P((struct alpha_shared_intr *, 149 unsigned int)); 150int alpha_shared_intr_isactive __P((struct alpha_shared_intr *, 151 unsigned int)); 152void alpha_shared_intr_set_dfltsharetype __P((struct alpha_shared_intr *, 153 unsigned int, int)); 154void alpha_shared_intr_set_maxstrays __P((struct alpha_shared_intr *, 155 unsigned int, int)); 156void alpha_shared_intr_stray __P((struct alpha_shared_intr *, unsigned int, 157 const char *)); 158void alpha_shared_intr_set_private __P((struct alpha_shared_intr *, 159 unsigned int, void *)); 160void *alpha_shared_intr_get_private __P((struct alpha_shared_intr *, 161 unsigned int)); 162 163#endif /* _KERNEL */ 164#endif /* ! _ALPHA_INTR_H_ */ 165