Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.1
      1 /*	$NetBSD: intr.h,v 1.1 2001/06/14 12:57:11 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 _SUN68K_INTR_H_
     34 #define _SUN68K_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_BIO			2
     52 #define	IPL_NET			3
     53 #define	IPL_CLOCK		5
     54 #define	IPL_SERIAL		6
     55 
     56 #ifdef _KERNEL
     57 LIST_HEAD(sh_head, softintr_handler);
     58 
     59 struct softintr_head {
     60 	int shd_ipl;
     61 	struct sh_head shd_intrs;
     62 };
     63 
     64 struct softintr_handler {
     65 	struct softintr_head *sh_head;
     66 	LIST_ENTRY(softintr_handler) sh_link;
     67 	void (*sh_func)(void *);
     68 	void *sh_arg;
     69 	int sh_pending;
     70 };
     71 
     72 extern void softintr_init __P((void));
     73 extern void *softintr_establish __P((int, void (*)(void *), void *));
     74 extern void softintr_disestablish __P((void *));
     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 /* These connect interrupt handlers. */
     87 typedef int (*isr_func_t) __P((void *));
     88 extern void isr_add_autovect __P((isr_func_t, void *arg, int level));
     89 extern void isr_add_vectored __P((isr_func_t, void *arg, int pri, int vec));
     90 extern void isr_add_custom __P((int, void *));
     91 
     92 #endif /* _KERNEL */
     93 #endif	/* _SUN68K_INTR_H */
     94