kern_softint.c revision 1.1.6.1 1 1.1.6.1 joerg /* $NetBSD: kern_softint.c,v 1.1.6.1 2007/10/26 15:48:35 joerg Exp $ */
2 1.1.6.1 joerg
3 1.1.6.1 joerg /*-
4 1.1.6.1 joerg * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 1.1.6.1 joerg * All rights reserved.
6 1.1.6.1 joerg *
7 1.1.6.1 joerg * This code is derived from software contributed to The NetBSD Foundation
8 1.1.6.1 joerg * by Andrew Doran.
9 1.1.6.1 joerg *
10 1.1.6.1 joerg * Redistribution and use in source and binary forms, with or without
11 1.1.6.1 joerg * modification, are permitted provided that the following conditions
12 1.1.6.1 joerg * are met:
13 1.1.6.1 joerg * 1. Redistributions of source code must retain the above copyright
14 1.1.6.1 joerg * notice, this list of conditions and the following disclaimer.
15 1.1.6.1 joerg * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.6.1 joerg * notice, this list of conditions and the following disclaimer in the
17 1.1.6.1 joerg * documentation and/or other materials provided with the distribution.
18 1.1.6.1 joerg * 3. All advertising materials mentioning features or use of this software
19 1.1.6.1 joerg * must display the following acknowledgement:
20 1.1.6.1 joerg * This product includes software developed by the NetBSD
21 1.1.6.1 joerg * Foundation, Inc. and its contributors.
22 1.1.6.1 joerg * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.6.1 joerg * contributors may be used to endorse or promote products derived
24 1.1.6.1 joerg * from this software without specific prior written permission.
25 1.1.6.1 joerg *
26 1.1.6.1 joerg * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.6.1 joerg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.6.1 joerg * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.6.1 joerg * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.6.1 joerg * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.6.1 joerg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.6.1 joerg * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.6.1 joerg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.6.1 joerg * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.6.1 joerg * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.6.1 joerg * POSSIBILITY OF SUCH DAMAGE.
37 1.1.6.1 joerg */
38 1.1.6.1 joerg
39 1.1.6.1 joerg /*
40 1.1.6.1 joerg * Stub for code to be merged from the vmlocking CVS branch.
41 1.1.6.1 joerg */
42 1.1.6.1 joerg
43 1.1.6.1 joerg #include <sys/cdefs.h>
44 1.1.6.1 joerg __KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.1.6.1 2007/10/26 15:48:35 joerg Exp $");
45 1.1.6.1 joerg
46 1.1.6.1 joerg #include <sys/param.h>
47 1.1.6.1 joerg #include <sys/intr.h>
48 1.1.6.1 joerg
49 1.1.6.1 joerg u_int softint_timing;
50 1.1.6.1 joerg
51 1.1.6.1 joerg /*
52 1.1.6.1 joerg * softint_init:
53 1.1.6.1 joerg *
54 1.1.6.1 joerg * Initialize per-CPU data structures. Called from mi_cpu_attach().
55 1.1.6.1 joerg */
56 1.1.6.1 joerg void
57 1.1.6.1 joerg softint_init(struct cpu_info *ci)
58 1.1.6.1 joerg {
59 1.1.6.1 joerg
60 1.1.6.1 joerg /* nothing yet */
61 1.1.6.1 joerg }
62 1.1.6.1 joerg
63 1.1.6.1 joerg /*
64 1.1.6.1 joerg * softint_establish:
65 1.1.6.1 joerg *
66 1.1.6.1 joerg * Register a software interrupt handler.
67 1.1.6.1 joerg */
68 1.1.6.1 joerg void *
69 1.1.6.1 joerg softint_establish(u_int flags, void (*func)(void *), void *arg)
70 1.1.6.1 joerg {
71 1.1.6.1 joerg u_int level;
72 1.1.6.1 joerg
73 1.1.6.1 joerg level = (flags & SOFTINT_LVLMASK);
74 1.1.6.1 joerg KASSERT(level < SOFTINT_COUNT);
75 1.1.6.1 joerg
76 1.1.6.1 joerg switch (level) {
77 1.1.6.1 joerg case SOFTINT_CLOCK:
78 1.1.6.1 joerg level = IPL_SOFTCLOCK;
79 1.1.6.1 joerg break;
80 1.1.6.1 joerg case SOFTINT_NET:
81 1.1.6.1 joerg case SOFTINT_BIO:
82 1.1.6.1 joerg level = IPL_SOFTNET;
83 1.1.6.1 joerg break;
84 1.1.6.1 joerg case SOFTINT_SERIAL:
85 1.1.6.1 joerg #ifdef IPL_SOFTSERIAL
86 1.1.6.1 joerg level = IPL_SOFTSERIAL;
87 1.1.6.1 joerg #else
88 1.1.6.1 joerg level = IPL_SOFTNET;
89 1.1.6.1 joerg #endif
90 1.1.6.1 joerg break;
91 1.1.6.1 joerg default:
92 1.1.6.1 joerg panic("softint_establish");
93 1.1.6.1 joerg }
94 1.1.6.1 joerg
95 1.1.6.1 joerg return softintr_establish(level, func, arg);
96 1.1.6.1 joerg }
97 1.1.6.1 joerg
98 1.1.6.1 joerg /*
99 1.1.6.1 joerg * softint_disestablish:
100 1.1.6.1 joerg *
101 1.1.6.1 joerg * Unregister a software interrupt handler.
102 1.1.6.1 joerg */
103 1.1.6.1 joerg void
104 1.1.6.1 joerg softint_disestablish(void *arg)
105 1.1.6.1 joerg {
106 1.1.6.1 joerg
107 1.1.6.1 joerg softintr_disestablish(arg);
108 1.1.6.1 joerg }
109 1.1.6.1 joerg
110 1.1.6.1 joerg /*
111 1.1.6.1 joerg * softint_schedule:
112 1.1.6.1 joerg *
113 1.1.6.1 joerg * Trigger a software interrupt. Must be called from a hardware
114 1.1.6.1 joerg * interrupt handler, or with preemption disabled (since we are
115 1.1.6.1 joerg * using the value of curcpu()).
116 1.1.6.1 joerg */
117 1.1.6.1 joerg void
118 1.1.6.1 joerg softint_schedule(void *arg)
119 1.1.6.1 joerg {
120 1.1.6.1 joerg
121 1.1.6.1 joerg softintr_schedule(arg);
122 1.1.6.1 joerg }
123 1.1.6.1 joerg
124 1.1.6.1 joerg /*
125 1.1.6.1 joerg * softint_block:
126 1.1.6.1 joerg *
127 1.1.6.1 joerg * Update statistics when the soft interrupt blocks.
128 1.1.6.1 joerg */
129 1.1.6.1 joerg void
130 1.1.6.1 joerg softint_block(lwp_t *l)
131 1.1.6.1 joerg {
132 1.1.6.1 joerg
133 1.1.6.1 joerg /* nothing yet */
134 1.1.6.1 joerg }
135