intr.h revision 1.18
11.18Sthorpej/* $NetBSD: intr.h,v 1.18 2007/03/11 05:22:25 thorpej Exp $ */ 21.1Stsutsui 31.1Stsutsui/* 41.1Stsutsui * 51.1Stsutsui * Copyright (c) 1998 NetBSD Foundation, Inc. 61.1Stsutsui * All rights reserved. 71.1Stsutsui * 81.1Stsutsui * This code is derived from software contributed to The NetBSD Foundation 91.1Stsutsui * by Minoura Makoto and Jason R. Thorpe. 101.1Stsutsui * 111.1Stsutsui * Redistribution and use in source and binary forms, with or without 121.1Stsutsui * modification, are permitted provided that the following conditions 131.1Stsutsui * are met: 141.1Stsutsui * 1. Redistributions of source code must retain the above copyright 151.1Stsutsui * notice, this list of conditions and the following disclaimer. 161.1Stsutsui * 2. Redistributions in binary form must reproduce the above copyright 171.1Stsutsui * notice, this list of conditions and the following disclaimer in the 181.1Stsutsui * documentation and/or other materials provided with the distribution. 191.1Stsutsui * 3. All advertising materials mentioning features or use of this software 201.1Stsutsui * must display the following acknowledgement: 211.1Stsutsui * This product includes software developed by The NetBSD Foundation 221.1Stsutsui * Inc. and its contributers. 231.1Stsutsui * 4. The name of the author may not be used to endorse or promote products 241.1Stsutsui * derived from this software without specific prior written permission. 251.1Stsutsui * 261.1Stsutsui * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 271.1Stsutsui * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 281.1Stsutsui * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 291.1Stsutsui * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 301.1Stsutsui * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 311.1Stsutsui * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 321.1Stsutsui * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 331.1Stsutsui * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 341.1Stsutsui * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 351.1Stsutsui * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 361.1Stsutsui */ 371.1Stsutsui 381.1Stsutsui#ifndef _NEWS68K_INTR_H_ 391.1Stsutsui#define _NEWS68K_INTR_H_ 401.1Stsutsui 411.14Stsutsui#include <sys/device.h> 421.14Stsutsui#include <sys/queue.h> 431.1Stsutsui#include <machine/psl.h> 441.5Stsutsui#include <m68k/asm_single.h> 451.1Stsutsui 461.13Syamt#define IPL_NONE 0 471.14Stsutsui#define IPL_SOFTCLOCK 1 481.14Stsutsui#define IPL_SOFTNET 2 491.14Stsutsui#define IPL_SOFTSERIAL 3 501.14Stsutsui#define IPL_SOFT 4 511.14Stsutsui#define IPL_BIO 5 521.14Stsutsui#define IPL_NET 6 531.14Stsutsui#define IPL_TTY 7 541.14Stsutsui#define IPL_VM 8 551.14Stsutsui#define IPL_SERIAL 9 561.14Stsutsui#define IPL_CLOCK 10 571.13Syamt#define IPL_STATCLOCK IPL_CLOCK 581.14Stsutsui#define IPL_HIGH 11 591.14Stsutsui#define IPL_SCHED IPL_HIGH 601.14Stsutsui#define IPL_LOCK IPL_HIGH 611.14Stsutsui#define NIPL 12 621.14Stsutsui 631.14Stsutsui#define SI_SOFTSERIAL 0 641.14Stsutsui#define SI_SOFTNET 1 651.14Stsutsui#define SI_SOFTCLOCK 2 661.14Stsutsui#define SI_SOFT 3 671.14Stsutsui 681.14Stsutsui#define SI_NQUEUES 4 691.14Stsutsui 701.14Stsutsui#define SI_QUEUENAMES { \ 711.14Stsutsui "serial", \ 721.14Stsutsui "net", \ 731.14Stsutsui "clock", \ 741.14Stsutsui "misc", \ 751.14Stsutsui} 761.13Syamt 771.13Syamttypedef int ipl_t; 781.13Syamttypedef struct { 791.18Sthorpej uint16_t _psl; 801.13Syamt} ipl_cookie_t; 811.13Syamt 821.14Stsutsuiipl_cookie_t makeiplcookie(ipl_t); 831.13Syamt 841.13Syamtstatic inline int 851.13Syamtsplraiseipl(ipl_cookie_t icookie) 861.13Syamt{ 871.13Syamt 881.14Stsutsui return _splraise(icookie._psl); 891.13Syamt} 901.13Syamt 911.12Sperrystatic __inline void 921.9Stsutsuisplx(int sr) 931.9Stsutsui{ 941.9Stsutsui 951.11Sperry __asm volatile("movw %0,%%sr" : : "di" (sr)); 961.9Stsutsui} 971.1Stsutsui 981.1Stsutsui/* 991.14Stsutsui * news68k can handle software interrupts by its own hardware 1001.14Stsutsui * so has no need to check for any simulated interrupts, etc. 1011.14Stsutsui */ 1021.14Stsutsui#define spl0() _spl0() 1031.14Stsutsui 1041.14Stsutsui#define splsoft() splraise2() 1051.14Stsutsui#define splsoftclock() splsoft() 1061.14Stsutsui#define splsoftnet() splsoft() 1071.14Stsutsui#define splsoftserial() splsoft() 1081.14Stsutsui#define splbio() splraise4() 1091.14Stsutsui#define splnet() splraise4() 1101.14Stsutsui#define spltty() splraise5() 1111.14Stsutsui#define splvm() splraise5() 1121.14Stsutsui#define splserial() splraise5() 1131.14Stsutsui#define splclock() splraise6() 1141.14Stsutsui#define splstatclock() splclock() 1151.14Stsutsui#define splhigh() spl7() 1161.14Stsutsui#define splsched() spl7() 1171.14Stsutsui#define spllock() spl7() 1181.14Stsutsui 1191.14Stsutsui/* 1201.1Stsutsui * simulated software interrupt register 1211.1Stsutsui */ 1221.14Stsutsui#define SOFTINTR_IPL 2 1231.15Stsutsuiextern volatile uint8_t *ctrl_int2; 1241.1Stsutsui 1251.15Stsutsui#define setsoft(x) (x = 0) 1261.15Stsutsui#define softintr_assert() (*ctrl_int2 = 0xff) 1271.15Stsutsui#define softintr_clear() (*ctrl_int2 = 0) 1281.14Stsutsui 1291.14Stsutsuistruct news68k_soft_intrhand { 1301.14Stsutsui LIST_ENTRY(news68k_soft_intrhand) sih_q; 1311.14Stsutsui struct news68k_soft_intr *sih_intrhead; 1321.14Stsutsui void (*sih_fn)(void *); 1331.14Stsutsui void *sih_arg; 1341.14Stsutsui volatile int sih_pending; 1351.14Stsutsui}; 1361.14Stsutsui 1371.14Stsutsuistruct news68k_soft_intr { 1381.14Stsutsui LIST_HEAD(, news68k_soft_intrhand) nsi_q; 1391.14Stsutsui struct evcnt nsi_evcnt; 1401.14Stsutsui volatile unsigned char nsi_ssir; 1411.14Stsutsui}; 1421.14Stsutsui 1431.14Stsutsuivoid *softintr_establish(int, void (*)(void *), void *); 1441.14Stsutsuivoid softintr_disestablish(void *); 1451.14Stsutsuivoid softintr_init(void); 1461.14Stsutsuivoid softintr_dispatch(void); 1471.14Stsutsui 1481.14Stsutsui#define softintr_schedule(arg) \ 1491.14Stsutsui do { \ 1501.14Stsutsui struct news68k_soft_intrhand *__sih = (arg); \ 1511.14Stsutsui __sih->sih_pending = 1; \ 1521.14Stsutsui setsoft(__sih->sih_intrhead->nsi_ssir); \ 1531.14Stsutsui softintr_assert(); \ 1541.14Stsutsui } while (/*CONSTCOND*/ 0) 1551.14Stsutsui 1561.14Stsutsui/* XXX For legacy software interrupts */ 1571.14Stsutsuiextern struct news68k_soft_intrhand *softnet_intrhand; 1581.14Stsutsui 1591.14Stsutsui#define setsoftnet() softintr_schedule(softnet_intrhand) 1601.1Stsutsui 1611.1Stsutsui#endif /* _NEWS68K_INTR_H_ */ 162