Home | History | Annotate | Line # | Download | only in arm32
intr.c revision 1.3
      1  1.3  rearnsha /*	$NetBSD: intr.c,v 1.3 2001/10/27 16:34:12 rearnsha Exp $	*/
      2  1.1     chris 
      3  1.1     chris /*
      4  1.1     chris  * Copyright (c) 1994-1998 Mark Brinicombe.
      5  1.1     chris  * All rights reserved.
      6  1.1     chris  *
      7  1.1     chris  * Redistribution and use in source and binary forms, with or without
      8  1.1     chris  * modification, are permitted provided that the following conditions
      9  1.1     chris  * are met:
     10  1.1     chris  * 1. Redistributions of source code must retain the above copyright
     11  1.1     chris  *    notice, this list of conditions and the following disclaimer.
     12  1.1     chris  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1     chris  *    notice, this list of conditions and the following disclaimer in the
     14  1.1     chris  *    documentation and/or other materials provided with the distribution.
     15  1.1     chris  * 3. All advertising materials mentioning features or use of this software
     16  1.1     chris  *    must display the following acknowledgement:
     17  1.1     chris  *	This product includes software developed by Mark Brinicombe
     18  1.1     chris  *	for the NetBSD Project.
     19  1.1     chris  * 4. The name of the company nor the name of the author may be used to
     20  1.1     chris  *    endorse or promote products derived from this software without specific
     21  1.1     chris  *    prior written permission.
     22  1.1     chris  *
     23  1.1     chris  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24  1.1     chris  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  1.1     chris  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  1.1     chris  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     27  1.1     chris  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     28  1.1     chris  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     29  1.1     chris  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.1     chris  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.1     chris  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.1     chris  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.1     chris  * SUCH DAMAGE.
     34  1.1     chris  *
     35  1.1     chris  * Soft interrupt and other generic interrupt functions.
     36  1.1     chris  */
     37  1.1     chris 
     38  1.1     chris #include "opt_irqstats.h"
     39  1.1     chris 
     40  1.1     chris #include <sys/param.h>
     41  1.1     chris #include <sys/systm.h>
     42  1.1     chris #include <sys/syslog.h>
     43  1.1     chris #include <sys/malloc.h>
     44  1.1     chris 
     45  1.1     chris #include <uvm/uvm_extern.h>
     46  1.1     chris 
     47  1.2      matt #include <machine/intr.h>
     48  1.1     chris #include <machine/cpu.h>
     49  1.1     chris 
     50  1.1     chris #include <net/netisr.h>
     51  1.1     chris 
     52  1.3  rearnsha #include <machine/conf.h>
     53  1.3  rearnsha 
     54  1.3  rearnsha #ifndef NPLCOM
     55  1.3  rearnsha #define NPLCOM 0
     56  1.3  rearnsha #endif
     57  1.3  rearnsha 
     58  1.1     chris u_int soft_interrupts = 0;
     59  1.1     chris 
     60  1.1     chris extern int current_spl_level;
     61  1.1     chris 
     62  1.3  rearnsha extern unsigned spl_mask;
     63  1.3  rearnsha 
     64  1.1     chris /* Generate soft interrupt counts if IRQSTATS is defined */
     65  1.1     chris #ifdef IRQSTATS
     66  1.1     chris extern u_int sintrcnt[];
     67  1.1     chris #define INC_SINTRCNT(x) ++sintrcnt[x]
     68  1.1     chris #else
     69  1.1     chris #define INC_SINTRCNT(x)
     70  1.1     chris #endif	/* IRQSTATS */
     71  1.1     chris 
     72  1.1     chris #define	COUNT	uvmexp.softs;
     73  1.1     chris 
     74  1.1     chris /* Prototypes */
     75  1.1     chris 
     76  1.1     chris #include "com.h"
     77  1.1     chris #if NCOM > 0
     78  1.1     chris extern void comsoft	__P((void));
     79  1.1     chris #endif	/* NCOM > 0 */
     80  1.1     chris 
     81  1.3  rearnsha #if NPLCOM > 0
     82  1.3  rearnsha extern void plcomsoft	__P((void));
     83  1.3  rearnsha #endif	/* NPLCOM > 0 */
     84  1.3  rearnsha 
     85  1.1     chris /* Eventually these will become macros */
     86  1.1     chris 
     87  1.1     chris void
     88  1.1     chris setsoftintr(intrmask)
     89  1.1     chris 	u_int intrmask;
     90  1.1     chris {
     91  1.1     chris 	atomic_set_bit(&soft_interrupts, intrmask);
     92  1.1     chris }
     93  1.1     chris 
     94  1.1     chris void
     95  1.1     chris clearsoftintr(intrmask)
     96  1.1     chris 	u_int intrmask;
     97  1.1     chris {
     98  1.1     chris 	atomic_clear_bit(&soft_interrupts, intrmask);
     99  1.1     chris }
    100  1.1     chris 
    101  1.1     chris void
    102  1.1     chris setsoftclock()
    103  1.1     chris {
    104  1.1     chris 	atomic_set_bit(&soft_interrupts, SOFTIRQ_BIT(SOFTIRQ_CLOCK));
    105  1.1     chris }
    106  1.1     chris 
    107  1.1     chris void
    108  1.1     chris setsoftnet()
    109  1.1     chris {
    110  1.1     chris 	atomic_set_bit(&soft_interrupts, SOFTIRQ_BIT(SOFTIRQ_NET));
    111  1.1     chris }
    112  1.1     chris 
    113  1.1     chris void
    114  1.1     chris setsoftserial()
    115  1.1     chris {
    116  1.1     chris 	atomic_set_bit(&soft_interrupts, SOFTIRQ_BIT(SOFTIRQ_SERIAL));
    117  1.1     chris }
    118  1.1     chris 
    119  1.1     chris int astpending;
    120  1.1     chris 
    121  1.1     chris /* Handle software interrupts */
    122  1.1     chris 
    123  1.1     chris void
    124  1.1     chris dosoftints()
    125  1.1     chris {
    126  1.1     chris 	u_int softints;
    127  1.1     chris 	int s;
    128  1.1     chris 
    129  1.1     chris 	softints = soft_interrupts & spl_smasks[current_spl_level];
    130  1.1     chris 	if (softints == 0) return;
    131  1.1     chris 
    132  1.1     chris 	/*
    133  1.1     chris 	 * Software clock interrupts
    134  1.1     chris 	 */
    135  1.1     chris 
    136  1.1     chris 	if (softints & SOFTIRQ_BIT(SOFTIRQ_CLOCK)) {
    137  1.1     chris 		s = splsoftclock();
    138  1.1     chris 		++COUNT;
    139  1.1     chris 		INC_SINTRCNT(SOFTIRQ_CLOCK);
    140  1.1     chris 		clearsoftintr(SOFTIRQ_BIT(SOFTIRQ_CLOCK));
    141  1.1     chris 		softclock(NULL);
    142  1.1     chris 		(void)splx(s);
    143  1.1     chris 	}
    144  1.1     chris 
    145  1.1     chris 	/*
    146  1.1     chris 	 * Network software interrupts
    147  1.1     chris 	 */
    148  1.1     chris 
    149  1.1     chris 	if (softints & SOFTIRQ_BIT(SOFTIRQ_NET)) {
    150  1.1     chris 		s = splsoftnet();
    151  1.1     chris 		++COUNT;
    152  1.1     chris 		INC_SINTRCNT(SOFTIRQ_NET);
    153  1.1     chris 		clearsoftintr(SOFTIRQ_BIT(SOFTIRQ_NET));
    154  1.1     chris 
    155  1.1     chris #define DONETISR(bit, fn) do {					\
    156  1.1     chris 		if (netisr & (1 << bit)) {			\
    157  1.1     chris 			atomic_clear_bit(&netisr, (1 << bit));	\
    158  1.1     chris 			fn();					\
    159  1.1     chris 		}						\
    160  1.1     chris } while (0)
    161  1.1     chris 
    162  1.1     chris #include <net/netisr_dispatch.h>
    163  1.1     chris 
    164  1.1     chris #undef DONETISR
    165  1.1     chris 
    166  1.1     chris 		(void)splx(s);
    167  1.1     chris 	}
    168  1.1     chris 	/*
    169  1.1     chris 	 * Serial software interrupts
    170  1.1     chris 	 */
    171  1.1     chris 
    172  1.1     chris 	if (softints & SOFTIRQ_BIT(SOFTIRQ_SERIAL)) {
    173  1.1     chris 		s = splsoftserial();
    174  1.1     chris 		++COUNT;
    175  1.1     chris 		INC_SINTRCNT(SOFTIRQ_SERIAL);
    176  1.1     chris 		clearsoftintr(SOFTIRQ_BIT(SOFTIRQ_SERIAL));
    177  1.1     chris #if NCOM > 0
    178  1.1     chris 		comsoft();
    179  1.1     chris #endif	/* NCOM > 0 */
    180  1.3  rearnsha #if NPLCOM > 0
    181  1.3  rearnsha 		plcomsoft();
    182  1.3  rearnsha #endif	/* NPLCOM > 0 */
    183  1.1     chris 		(void)splx(s);
    184  1.1     chris 	}
    185  1.1     chris }
    186  1.1     chris 
    187  1.1     chris /* End of intr.c */
    188