Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.1
      1 /*	$NetBSD: intr.h,v 1.1 2001/04/06 13:13:03 fredette Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2001 Matt Fredette.
      5  * Copyright (c) 1998 Matt Thomas.
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. The name of the company nor the names of the authors may be used to
     17  *    endorse or promote products derived from this software without specific
     18  *    prior written permission.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
     21  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     22  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  * IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     24  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     25  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     26  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30  * SUCH DAMAGE.
     31  */
     32 
     33 #ifndef _SUN2_INTR_H_
     34 #define _SUN2_INTR_H_
     35 
     36 #include <sys/queue.h>
     37 
     38 /*
     39  * Interrupt levels.  Right now these correspond to real
     40  * hardware levels, but I don't think anything counts on
     41  * that (yet?).
     42  */
     43 #define _IPL_SOFT_LEVEL1	1
     44 #define _IPL_SOFT_LEVEL2	2
     45 #define _IPL_SOFT_LEVEL3	3
     46 #define _IPL_SOFT_LEVEL_MIN	1
     47 #define _IPL_SOFT_LEVEL_MAX	3
     48 #define IPL_SOFTNET  		_IPL_SOFT_LEVEL1
     49 #define IPL_SOFTCLOCK		_IPL_SOFT_LEVEL1
     50 #define IPL_SOFTSERIAL		_IPL_SOFT_LEVEL3
     51 #define	IPL_NET			3
     52 #define	IPL_CLOCK		5
     53 #define	IPL_SERIAL		6
     54 
     55 #ifdef _KERNEL
     56 LIST_HEAD(sh_head, softintr_handler);
     57 
     58 struct softintr_head {
     59 	int shd_ipl;
     60 	struct sh_head shd_intrs;
     61 };
     62 
     63 struct softintr_handler {
     64 	struct softintr_head *sh_head;
     65 	LIST_ENTRY(softintr_handler) sh_link;
     66 	void (*sh_func)(void *);
     67 	void *sh_arg;
     68 	int sh_pending;
     69 };
     70 
     71 extern void softintr_init __P((void));
     72 extern void *softintr_establish __P((int, void (*)(void *), void *));
     73 extern void softintr_disestablish __P((void *));
     74 extern void isr_soft_request __P((int level));
     75 
     76 static __inline void
     77 softintr_schedule(void *arg)
     78 {
     79 	struct softintr_handler * const sh = arg;
     80 	if (sh->sh_pending == 0) {
     81 		sh->sh_pending = 1;
     82 		isr_soft_request(sh->sh_head->shd_ipl);
     83 	}
     84 }
     85 
     86 #endif /* _KERNEL */
     87 #endif	/* _SUN2_INTR_H */
     88