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