]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/intr.h
vfs: ifdef out noop vop_* primitives on !DEBUG_VFS_LOCKS kernels
[FreeBSD/FreeBSD.git] / sys / sys / intr.h
1 /*-
2  * Copyright (c) 2015-2016 Svatopluk Kraus
3  * Copyright (c) 2015-2016 Michal Meloun
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following 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 AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  * $FreeBSD$
28  */
29
30 #ifndef _SYS_INTR_H_
31 #define _SYS_INTR_H_
32
33 #include <sys/systm.h>
34
35 #define INTR_IRQ_INVALID        0xFFFFFFFF
36
37 #ifdef notyet
38 #define INTR_SOLO       INTR_MD1
39 typedef int intr_irq_filter_t(void *arg, struct trapframe *tf);
40 #else
41 typedef int intr_irq_filter_t(void *arg);
42 #endif
43 typedef int intr_child_irq_filter_t(void *arg, uintptr_t irq);
44
45 #define INTR_ISRC_NAMELEN       (MAXCOMLEN + 1)
46
47 #define INTR_ISRCF_IPI          0x01    /* IPI interrupt */
48 #define INTR_ISRCF_PPI          0x02    /* PPI interrupt */
49 #define INTR_ISRCF_BOUND        0x04    /* bound to a CPU */
50
51 struct intr_pic;
52
53 /* Interrupt source definition. */
54 struct intr_irqsrc {
55         device_t                isrc_dev;       /* where isrc is mapped */
56         u_int                   isrc_irq;       /* unique identificator */
57         u_int                   isrc_flags;
58         char                    isrc_name[INTR_ISRC_NAMELEN];
59         cpuset_t                isrc_cpu;       /* on which CPUs is enabled */
60         u_int                   isrc_index;
61         u_long *                isrc_count;
62         u_int                   isrc_handlers;
63         struct intr_event *     isrc_event;
64 #ifdef INTR_SOLO
65         intr_irq_filter_t *     isrc_filter;
66         void *                  isrc_arg;
67 #endif
68 };
69
70 /* Intr interface for PIC. */
71 int intr_isrc_deregister(struct intr_irqsrc *);
72 int intr_isrc_register(struct intr_irqsrc *, device_t, u_int, const char *, ...)
73     __printflike(4, 5);
74
75 #ifdef SMP
76 bool intr_isrc_init_on_cpu(struct intr_irqsrc *isrc, u_int cpu);
77 #endif
78
79 int intr_isrc_dispatch(struct intr_irqsrc *, struct trapframe *);
80 u_int intr_irq_next_cpu(u_int current_cpu, cpuset_t *cpumask);
81
82 struct intr_pic *intr_pic_register(device_t, intptr_t);
83 int intr_pic_deregister(device_t, intptr_t);
84 int intr_pic_claim_root(device_t, intptr_t, intr_irq_filter_t *, void *, u_int);
85 struct intr_pic *intr_pic_add_handler(device_t, struct intr_pic *,
86     intr_child_irq_filter_t *, void *, uintptr_t, uintptr_t);
87
88 extern device_t intr_irq_root_dev;
89
90 /* Intr interface for BUS. */
91 int intr_map_irq(device_t, intptr_t, struct intr_map_data *, u_int *);
92
93 int intr_alloc_irq(device_t, struct resource *);
94 int intr_release_irq(device_t, struct resource *);
95
96 int intr_setup_irq(device_t, struct resource *, driver_filter_t, driver_intr_t,
97     void *, int, void **);
98 int intr_teardown_irq(device_t, struct resource *, void *);
99
100 int intr_describe_irq(device_t, struct resource *, void *, const char *);
101 int intr_child_irq_handler(struct intr_pic *, uintptr_t);
102
103 /* MSI/MSI-X handling */
104 int intr_msi_register(device_t, intptr_t);
105 int intr_alloc_msi(device_t, device_t, intptr_t, int, int, int *);
106 int intr_release_msi(device_t, device_t, intptr_t, int, int *);
107 int intr_map_msi(device_t, device_t, intptr_t, int, uint64_t *, uint32_t *);
108 int intr_alloc_msix(device_t, device_t, intptr_t, int *);
109 int intr_release_msix(device_t, device_t, intptr_t, int);
110
111 #ifdef SMP
112 int intr_bind_irq(device_t, struct resource *, int);
113
114 void intr_pic_init_secondary(void);
115
116 /* Virtualization for interrupt source IPI counter increment. */
117 static inline void
118 intr_ipi_increment_count(u_long *counter, u_int cpu)
119 {
120
121         KASSERT(cpu < MAXCPU, ("%s: too big cpu %u", __func__, cpu));
122         counter[cpu]++;
123 }
124
125 /* Virtualization for interrupt source IPI counters setup. */
126 u_long * intr_ipi_setup_counters(const char *name);
127
128 #endif
129 #endif  /* _SYS_INTR_H */