intr.h revision 1.1
11.1Such/* $NetBSD: intr.h,v 1.1 2001/10/16 15:38:46 uch Exp $ */ 21.1Such 31.1Such/*- 41.1Such * Copyright (c) 2001 The NetBSD Foundation, Inc. 51.1Such * All rights reserved. 61.1Such * 71.1Such * This code is derived from software contributed to The NetBSD Foundation 81.1Such * by Jason R. Thorpe, UCHIYAMA Yasushi. 91.1Such * 101.1Such * Redistribution and use in source and binary forms, with or without 111.1Such * modification, are permitted provided that the following conditions 121.1Such * are met: 131.1Such * 1. Redistributions of source code must retain the above copyright 141.1Such * notice, this list of conditions and the following disclaimer. 151.1Such * 2. Redistributions in binary form must reproduce the above copyright 161.1Such * notice, this list of conditions and the following disclaimer in the 171.1Such * documentation and/or other materials provided with the distribution. 181.1Such * 3. All advertising materials mentioning features or use of this software 191.1Such * must display the following acknowledgement: 201.1Such * This product includes software developed by the NetBSD 211.1Such * Foundation, Inc. and its contributors. 221.1Such * 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Such * contributors may be used to endorse or promote products derived 241.1Such * from this software without specific prior written permission. 251.1Such * 261.1Such * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Such * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Such * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Such * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Such * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Such * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.1Such * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.1Such * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.1Such * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Such * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.1Such * POSSIBILITY OF SUCH DAMAGE. 371.1Such */ 381.1Such 391.1Such#ifndef _PLAYSTATION2_INTR_H_ 401.1Such#define _PLAYSTATION2_INTR_H_ 411.1Such#ifdef _KERNEL 421.1Such 431.1Such#include <sys/device.h> 441.1Such#include <sys/lock.h> 451.1Such#include <sys/queue.h> 461.1Such 471.1Such/* Interrupt sharing types. */ 481.1Such#define IST_NONE 0 /* none */ 491.1Such#define IST_PULSE 1 /* pulsed */ 501.1Such#define IST_EDGE 2 /* edge-triggered */ 511.1Such#define IST_LEVEL 3 /* level-triggered */ 521.1Such 531.1Such/* Interrupt priority levels */ 541.1Such#define IPL_NONE 0 /* nothing */ 551.1Such 561.1Such#define IPL_SOFT 1 /* generic */ 571.1Such#define IPL_SOFTCLOCK 2 /* timeouts */ 581.1Such#define IPL_SOFTNET 3 /* protocol stacks */ 591.1Such#define IPL_SOFTSERIAL 4 /* serial */ 601.1Such 611.1Such#define IPL_BIO 5 /* block I/O */ 621.1Such#define IPL_NET 6 /* network */ 631.1Such#define IPL_TTY 7 /* terminal */ 641.1Such#define IPL_SERIAL 7 /* serial */ 651.1Such#define IPL_CLOCK 8 /* clock */ 661.1Such#define IPL_HIGH 8 /* everything */ 671.1Such 681.1Such#define _IPL_NSOFT 4 691.1Such#define _IPL_N 9 701.1Such#define IPL_SOFTNAMES { \ 711.1Such "misc", \ 721.1Such "clock", \ 731.1Such "net", \ 741.1Such "serial", \ 751.1Such} 761.1Such 771.1Such/* 781.1Such * Hardware interrupt masks 791.1Such */ 801.1Suchextern u_int32_t __icu_mask[_IPL_N]; 811.1Such 821.1Such#define splbio() splraise(__icu_mask[IPL_BIO]) 831.1Such#define splnet() splraise(__icu_mask[IPL_NET]) 841.1Such#define spltty() splraise(__icu_mask[IPL_TTY]) 851.1Such#define splserial() splraise(__icu_mask[IPL_SERIAL]) 861.1Such#define splclock() splraise(__icu_mask[IPL_CLOCK]) 871.1Such 881.1Such#define splstatclock() splclock() 891.1Such#define splvm() spltty() 901.1Such 911.1Such/* 921.1Such * Software interrupt masks 931.1Such */ 941.1Such#define splsoft() splraise(__icu_mask[IPL_SOFT]) 951.1Such#define splsoftclock() splraise(__icu_mask[IPL_SOFTCLOCK]) 961.1Such#define splsoftnet() splraise(__icu_mask[IPL_SOFTNET]) 971.1Such#define splsoftserial() splraise(__icu_mask[IPL_SOFTSERIAL]) 981.1Such 991.1Such#define spllowersoftclock() splset(__icu_mask[IPL_SOFTCLOCK]) 1001.1Suchvoid spllowersofthigh(void); 1011.1Such 1021.1Such/* 1031.1Such * Miscellaneous 1041.1Such */ 1051.1Such#define splx(s) splset(s) 1061.1Such#define splhigh() splraise(__icu_mask[IPL_HIGH]) 1071.1Such#define splsched() splhigh() 1081.1Such#define spllock() splhigh() 1091.1Such 1101.1Such/* 1111.1Such * software simulated interrupt 1121.1Such */ 1131.1Suchstruct playstation2_soft_intrhand { 1141.1Such TAILQ_ENTRY(playstation2_soft_intrhand) sih_q; 1151.1Such struct playstation2_soft_intr *sih_intrhead; 1161.1Such void (*sih_fn)(void *); 1171.1Such void *sih_arg; 1181.1Such int sih_pending; 1191.1Such}; 1201.1Such 1211.1Suchstruct playstation2_soft_intr { 1221.1Such TAILQ_HEAD(, playstation2_soft_intrhand) softintr_q; 1231.1Such struct evcnt softintr_evcnt; 1241.1Such struct simplelock softintr_slock; 1251.1Such unsigned long softintr_ipl; 1261.1Such}; 1271.1Such 1281.1Such#define softintr_schedule(arg) \ 1291.1Suchdo { \ 1301.1Such struct playstation2_soft_intrhand *__sih = (arg); \ 1311.1Such struct playstation2_soft_intr *__si = __sih->sih_intrhead; \ 1321.1Such int __s; \ 1331.1Such \ 1341.1Such __s = _intr_suspend(); \ 1351.1Such simple_lock(&__si->softintr_slock); \ 1361.1Such if (__sih->sih_pending == 0) { \ 1371.1Such TAILQ_INSERT_TAIL(&__si->softintr_q, __sih, sih_q); \ 1381.1Such __sih->sih_pending = 1; \ 1391.1Such setsoft(__si->softintr_ipl); \ 1401.1Such } \ 1411.1Such simple_unlock(&__si->softintr_slock); \ 1421.1Such _intr_resume(__s); \ 1431.1Such} while (0) 1441.1Such 1451.1Suchvoid *softintr_establish(int, void (*)(void *), void *); 1461.1Suchvoid softintr_disestablish(void *); 1471.1Suchvoid setsoft(int); 1481.1Such 1491.1Such/* XXX For legacy software interrupts. */ 1501.1Suchextern struct playstation2_soft_intrhand *softnet_intrhand; 1511.1Such 1521.1Such#define setsoftnet() softintr_schedule(softnet_intrhand) 1531.1Such 1541.1Suchextern int splraise(int); 1551.1Suchextern void splset(int); 1561.1Suchextern void spl0(void); 1571.1Suchextern int _splset(int); 1581.1Such 1591.1Such/* fast interrupt locking for MD use. */ 1601.1Suchextern int _intr_suspend(void); 1611.1Suchextern void _intr_resume(int); 1621.1Such 1631.1Such#endif /* _KERNEL */ 1641.1Such#endif /* _PLAYSTATION2_INTR_H_ */ 165