]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/interrupt.h
Duh! put the thread name into the section that is zero'd on allocation
[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 #include <sys/_lock.h>
33 #include <sys/_mutex.h>
34
35 struct intr_event;
36 struct intr_thread;
37
38 /*
39  * Describe a hardware interrupt handler.
40  *
41  * Multiple interrupt handlers for a specific event can be chained
42  * together.
43  */
44 struct intr_handler {
45         driver_intr_t   *ih_handler;    /* Handler function. */
46         void            *ih_argument;   /* Argument to pass to handler. */
47         int              ih_flags;
48         const char      *ih_name;       /* Name of handler. */
49         struct intr_event *ih_event;    /* Event we are connected to. */
50         int              ih_need;       /* Needs service. */
51         TAILQ_ENTRY(intr_handler) ih_next; /* Next handler for this event. */
52         u_char           ih_pri;        /* Priority of this handler. */
53 };
54
55 /* Interrupt handle flags kept in ih_flags */
56 #define IH_FAST         0x00000001      /* Fast interrupt. */
57 #define IH_EXCLUSIVE    0x00000002      /* Exclusive interrupt. */
58 #define IH_ENTROPY      0x00000004      /* Device is a good entropy source. */
59 #define IH_DEAD         0x00000008      /* Handler should be removed. */
60 #define IH_MPSAFE       0x80000000      /* Handler does not need Giant. */
61
62 /*
63  * Describe an interrupt event.  An event holds a list of handlers.
64  */
65 struct intr_event {
66         TAILQ_ENTRY(intr_event) ie_list;
67         TAILQ_HEAD(, intr_handler) ie_handlers; /* Interrupt handlers. */
68         char            ie_name[MAXCOMLEN]; /* Individual event name. */
69         char            ie_fullname[MAXCOMLEN];
70         struct mtx      ie_lock;
71         void            *ie_source;     /* Cookie used by MD code. */
72         struct intr_thread *ie_thread;  /* Thread we are connected to. */
73         void            (*ie_enable)(void *);
74         int             ie_flags;
75         int             ie_count;       /* Loop counter. */
76         int             ie_warned;      /* Warned about interrupt storm. */
77 };
78
79 /* Interrupt event flags kept in ie_flags. */
80 #define IE_SOFT         0x000001        /* Software interrupt. */
81 #define IE_ENTROPY      0x000002        /* Interrupt is an entropy source. */
82 #define IE_ADDING_THREAD 0x000004       /* Currently building an ithread. */
83
84 /* Flags to pass to sched_swi. */
85 #define SWI_DELAY       0x2
86
87 /*
88  * Software interrupt numbers in priority order.  The priority determines
89  * the priority of the corresponding interrupt thread.
90  */
91 #define SWI_TTY         0
92 #define SWI_NET         1
93 #define SWI_CAMBIO      2
94 #define SWI_VM          3
95 #define SWI_CLOCK       4
96 #define SWI_TQ_FAST     5
97 #define SWI_TQ          6
98 #define SWI_TQ_GIANT    6
99
100 extern struct   intr_event *tty_intr_event;
101 extern struct   intr_event *clk_intr_event;
102 extern void     *softclock_ih;
103 extern void     *vm_ih;
104
105 /* Counts and names for statistics (defined in MD code). */
106 extern u_long   eintrcnt[];     /* end of intrcnt[] */
107 extern char     eintrnames[];   /* end of intrnames[] */
108 extern u_long   intrcnt[];      /* counts for for each device and stray */
109 extern char     intrnames[];    /* string table containing device names */
110
111 #ifdef DDB
112 void    db_dump_intr_event(struct intr_event *ie, int handlers);
113 #endif
114 u_char  intr_priority(enum intr_type flags);
115 int     intr_event_add_handler(struct intr_event *ie, const char *name,
116             driver_intr_t handler, void *arg, u_char pri, enum intr_type flags,
117             void **cookiep);
118 int     intr_event_create(struct intr_event **event, void *source,
119             int flags, void (*enable)(void *), const char *fmt, ...)
120             __printflike(5, 6);
121 int     intr_event_destroy(struct intr_event *ie);
122 int     intr_event_remove_handler(void *cookie);
123 int     intr_event_schedule_thread(struct intr_event *ie);
124 int     swi_add(struct intr_event **eventp, const char *name,
125             driver_intr_t handler, void *arg, int pri, enum intr_type flags,
126             void **cookiep);
127 void    swi_sched(void *cookie, int flags);
128 int     swi_remove(void *cookie);
129
130 #endif