]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/interrupt.h
This commit was generated by cvs2svn to compensate for changes in r74722,
[FreeBSD/FreeBSD.git] / sys / sys / interrupt.h
1 /*
2  * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice unmodified, this list of conditions, and the following
10  *    disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 #ifndef _SYS_INTERRUPT_H_
30 #define _SYS_INTERRUPT_H_
31
32 /*
33  * Describe a hardware interrupt handler.
34  *
35  * Multiple interrupt handlers for a specific vector can be chained
36  * together.
37  */
38 struct  intrhand {
39         driver_intr_t   *ih_handler;    /* Handler function. */
40         void            *ih_argument;   /* Argument to pass to handler. */
41         int              ih_flags;
42         const char      *ih_name;       /* Name of handler. */
43         struct ithd     *ih_ithread;    /* Ithread we are connected to. */
44         int              ih_need;       /* Needs service. */
45         TAILQ_ENTRY(intrhand) ih_next;  /* Next handler for this vector. */
46         u_char           ih_pri;        /* Priority of this handler. */
47 };
48
49 /* Interrupt handle flags kept in ih_flags */
50 #define IH_FAST         0x00000001      /* Fast interrupt. */
51 #define IH_EXCLUSIVE    0x00000002      /* Exclusive interrupt. */
52 #define IH_ENTROPY      0x00000004      /* Device is a good entropy source. */
53 #define IH_DEAD         0x00000008      /* Handler should be removed. */
54 #define IH_MPSAFE       0x80000000      /* Handler does not need Giant. */
55
56 /*
57  * Describe an interrupt thread.  There is one of these per interrupt vector.
58  * Note that this actually describes an interrupt source.  There may or may
59  * not be an actual kernel thread attached to a given source.
60  */
61 struct  ithd {
62         struct  proc *it_proc;          /* Interrupt process. */
63         LIST_ENTRY(ithd) it_list;       /* All interrupt threads. */
64         TAILQ_HEAD(, intrhand) it_handlers; /* Interrupt handlers. */
65         struct  ithd *it_interrupted;   /* Who we interrupted. */
66         void    (*it_disable)(int);     /* Enable interrupt source. */
67         void    (*it_enable)(int);      /* Disable interrupt source. */
68         void    *it_md;                 /* Hook for MD interrupt code. */
69         int     it_flags;               /* Interrupt-specific flags. */
70         int     it_need;                /* Needs service. */
71         int     it_vector;
72         char    it_name[MAXCOMLEN + 1];
73 };
74
75 /* Interrupt thread flags kept in it_flags */
76 #define IT_SOFT         0x000001        /* Software interrupt. */
77 #define IT_ENTROPY      0x000002        /* Interrupt is an entropy source. */
78 #define IT_DEAD         0x000004        /* Thread is waiting to exit. */
79
80 /* Flags to pass to sched_swi. */
81 #define SWI_NOSWITCH    0x0
82 #define SWI_SWITCH      0x1
83 #define SWI_DELAY       0x2     /* implies NOSWITCH */
84
85 extern struct   ithd *tty_ithd;
86 extern struct   ithd *clk_ithd;
87 extern void     *net_ih;
88 extern void     *softclock_ih;
89 extern void     *vm_ih;
90
91 int     ithread_create __P((struct ithd **ithread, int vector, int flags,
92             void (*disable)(int), void (*enable)(int), const char *fmt, ...))
93             __printflike(6, 7);
94 int     ithread_destroy __P((struct ithd *ithread));
95 u_char  ithread_priority __P((enum intr_type flags));
96 int     ithread_add_handler __P((struct ithd *ithread, const char *name,
97             driver_intr_t handler, void *arg, u_char pri, enum intr_type flags,
98             void **cookiep));
99 int     ithread_remove_handler __P((void *cookie));
100 int     ithread_schedule __P((struct ithd *ithread, int do_switch));
101 int     swi_add __P((struct ithd **ithdp, const char *name,
102             driver_intr_t handler, void *arg, int pri, enum intr_type flags,
103             void **cookiep));
104 void    swi_sched __P((void *cookie, int flags));
105
106 #endif