intr.h revision 1.17
11.17Smatt/* $NetBSD: intr.h,v 1.17 2009/12/14 00:46:02 matt Exp $ */ 21.1Ssimonb 31.1Ssimonb/*- 41.1Ssimonb * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. 51.1Ssimonb * All rights reserved. 61.1Ssimonb * 71.1Ssimonb * This code is derived from software contributed to The NetBSD Foundation 81.1Ssimonb * by Jason R. Thorpe. 91.1Ssimonb * 101.1Ssimonb * Redistribution and use in source and binary forms, with or without 111.1Ssimonb * modification, are permitted provided that the following conditions 121.1Ssimonb * are met: 131.1Ssimonb * 1. Redistributions of source code must retain the above copyright 141.1Ssimonb * notice, this list of conditions and the following disclaimer. 151.1Ssimonb * 2. Redistributions in binary form must reproduce the above copyright 161.1Ssimonb * notice, this list of conditions and the following disclaimer in the 171.1Ssimonb * documentation and/or other materials provided with the distribution. 181.1Ssimonb * 191.1Ssimonb * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Ssimonb * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Ssimonb * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Ssimonb * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Ssimonb * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Ssimonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Ssimonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Ssimonb * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Ssimonb * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Ssimonb * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Ssimonb * POSSIBILITY OF SUCH DAMAGE. 301.1Ssimonb */ 311.1Ssimonb 321.1Ssimonb#ifndef _EVBMIPS_INTR_H_ 331.8Ssimonb#define _EVBMIPS_INTR_H_ 341.1Ssimonb 351.1Ssimonb#include <sys/queue.h> 361.1Ssimonb 371.1Ssimonb#define IPL_NONE 0 /* disable only this interrupt */ 381.14Sad#define IPL_SOFTCLOCK 1 /* software interrupts */ 391.14Sad#define IPL_SOFTBIO 1 /* software interrupts */ 401.14Sad#define IPL_SOFTNET 2 /* software interrupts */ 411.14Sad#define IPL_SOFTSERIAL 2 /* software interrupts */ 421.14Sad#define IPL_VM 3 431.14Sad#define IPL_SCHED 4 441.14Sad#define IPL_HIGH 4 451.1Ssimonb 461.14Sad#define _IPL_N 5 /* max IPL + 1 */ 471.1Ssimonb 481.14Sad#define _IPL_SI0_FIRST IPL_SOFTCLOCK 491.14Sad#define _IPL_SI0_LAST IPL_SOFTBIO 501.1Ssimonb 511.1Ssimonb#define _IPL_SI1_FIRST IPL_SOFTNET 521.1Ssimonb#define _IPL_SI1_LAST IPL_SOFTSERIAL 531.1Ssimonb 541.1Ssimonb#define IST_UNUSABLE -1 /* interrupt cannot be used */ 551.1Ssimonb#define IST_NONE 0 /* none (dummy) */ 561.1Ssimonb#define IST_PULSE 1 /* pulsed */ 571.1Ssimonb#define IST_EDGE 2 /* edge-triggered */ 581.1Ssimonb#define IST_LEVEL 3 /* level-triggered */ 591.8Ssimonb#define IST_LEVEL_HIGH 4 /* level triggered, active high */ 601.8Ssimonb#define IST_LEVEL_LOW 5 /* level triggered, active low */ 611.1Ssimonb 621.1Ssimonb#ifdef _KERNEL 631.1Ssimonb 641.12Stsutsui#include <mips/locore.h> 651.12Stsutsui 661.7Sgdamoreextern const uint32_t ipl_sr_bits[_IPL_N]; 671.1Ssimonb 681.1Ssimonb#define spl0() (void) _spllower(0) 691.1Ssimonb#define splx(s) (void) _splset(s) 701.1Ssimonb 711.1Ssimonb#define splsoft() _splraise(ipl_sr_bits[IPL_SOFT]) 721.1Ssimonb 731.10Syamttypedef int ipl_t; 741.10Syamttypedef struct { 751.10Syamt ipl_t _sr; 761.10Syamt} ipl_cookie_t; 771.10Syamt 781.10Syamtstatic inline ipl_cookie_t 791.10Syamtmakeiplcookie(ipl_t ipl) 801.10Syamt{ 811.10Syamt 821.10Syamt return (ipl_cookie_t){._sr = ipl_sr_bits[ipl]}; 831.10Syamt} 841.10Syamt 851.10Syamtstatic inline int 861.10Syamtsplraiseipl(ipl_cookie_t icookie) 871.10Syamt{ 881.10Syamt 891.10Syamt return _splraise(icookie._sr); 901.10Syamt} 911.6Syamt 921.6Syamt#include <sys/spl.h> 931.6Syamt 941.1Ssimonbstruct evbmips_intrhand { 951.1Ssimonb LIST_ENTRY(evbmips_intrhand) ih_q; 961.1Ssimonb int (*ih_func)(void *); 971.1Ssimonb void *ih_arg; 981.1Ssimonb int ih_irq; 991.17Smatt int ih_ipl; 1001.1Ssimonb}; 1011.1Ssimonb 1021.5Stsutsui#include <mips/softintr.h> 1031.1Ssimonb 1041.1Ssimonbvoid evbmips_intr_init(void); 1051.1Ssimonbvoid intr_init(void); 1061.7Sgdamorevoid evbmips_iointr(uint32_t, uint32_t, uint32_t, uint32_t); 1071.1Ssimonbvoid *evbmips_intr_establish(int, int (*)(void *), void *); 1081.1Ssimonbvoid evbmips_intr_disestablish(void *); 1091.1Ssimonb#endif /* _KERNEL */ 1101.1Ssimonb#endif /* ! _EVBMIPS_INTR_H_ */ 111