2001-09-05 20:17:35 +04:00
|
|
|
/* $NetBSD: intr.c,v 1.2 2001/09/05 16:17:35 matt Exp $ */
|
1997-10-14 13:31:14 +04:00
|
|
|
|
|
|
|
/*
|
1998-09-05 07:59:29 +04:00
|
|
|
* Copyright (c) 1994-1998 Mark Brinicombe.
|
1997-10-14 13:31:14 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1998-09-05 07:59:29 +04:00
|
|
|
* This product includes software developed by Mark Brinicombe
|
|
|
|
* for the NetBSD Project.
|
1997-10-14 13:31:14 +04:00
|
|
|
* 4. The name of the company nor the name of the author may be used to
|
|
|
|
* endorse or promote products derived from this software without specific
|
|
|
|
* prior written permission.
|
|
|
|
*
|
1998-09-05 07:59:29 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
1997-10-14 13:31:14 +04:00
|
|
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1998-09-05 07:59:29 +04:00
|
|
|
*
|
|
|
|
* Soft interrupt and other generic interrupt functions.
|
1997-10-14 13:31:14 +04:00
|
|
|
*/
|
|
|
|
|
1998-07-06 04:53:07 +04:00
|
|
|
#include "opt_irqstats.h"
|
1998-07-05 04:51:04 +04:00
|
|
|
|
1997-10-14 13:31:14 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
1998-06-03 00:41:46 +04:00
|
|
|
#include <uvm/uvm_extern.h>
|
|
|
|
|
2001-09-05 20:17:35 +04:00
|
|
|
#include <machine/intr.h>
|
1997-10-14 13:31:14 +04:00
|
|
|
#include <machine/cpu.h>
|
|
|
|
|
1998-06-04 21:45:50 +04:00
|
|
|
#include <net/netisr.h>
|
|
|
|
|
1998-09-05 07:59:29 +04:00
|
|
|
u_int soft_interrupts = 0;
|
|
|
|
|
|
|
|
extern int current_spl_level;
|
|
|
|
|
|
|
|
/* Generate soft interrupt counts if IRQSTATS is defined */
|
1998-01-22 03:04:10 +03:00
|
|
|
#ifdef IRQSTATS
|
1998-09-05 07:59:29 +04:00
|
|
|
extern u_int sintrcnt[];
|
|
|
|
#define INC_SINTRCNT(x) ++sintrcnt[x]
|
|
|
|
#else
|
|
|
|
#define INC_SINTRCNT(x)
|
1998-01-22 03:04:10 +03:00
|
|
|
#endif /* IRQSTATS */
|
1997-10-14 13:31:14 +04:00
|
|
|
|
1998-09-05 07:59:29 +04:00
|
|
|
#define COUNT uvmexp.softs;
|
|
|
|
|
|
|
|
/* Prototypes */
|
|
|
|
|
|
|
|
#include "com.h"
|
|
|
|
#if NCOM > 0
|
|
|
|
extern void comsoft __P((void));
|
|
|
|
#endif /* NCOM > 0 */
|
|
|
|
|
|
|
|
/* Eventually these will become macros */
|
1997-10-14 13:31:14 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
setsoftintr(intrmask)
|
|
|
|
u_int intrmask;
|
|
|
|
{
|
|
|
|
atomic_set_bit(&soft_interrupts, intrmask);
|
|
|
|
}
|
|
|
|
|
1998-09-05 07:59:29 +04:00
|
|
|
void
|
|
|
|
clearsoftintr(intrmask)
|
|
|
|
u_int intrmask;
|
|
|
|
{
|
|
|
|
atomic_clear_bit(&soft_interrupts, intrmask);
|
|
|
|
}
|
|
|
|
|
1997-10-14 13:31:14 +04:00
|
|
|
void
|
|
|
|
setsoftclock()
|
|
|
|
{
|
1998-09-05 07:59:29 +04:00
|
|
|
atomic_set_bit(&soft_interrupts, SOFTIRQ_BIT(SOFTIRQ_CLOCK));
|
1997-10-14 13:31:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
setsoftnet()
|
|
|
|
{
|
1998-09-05 07:59:29 +04:00
|
|
|
atomic_set_bit(&soft_interrupts, SOFTIRQ_BIT(SOFTIRQ_NET));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
setsoftserial()
|
|
|
|
{
|
|
|
|
atomic_set_bit(&soft_interrupts, SOFTIRQ_BIT(SOFTIRQ_SERIAL));
|
1997-10-14 13:31:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int astpending;
|
|
|
|
|
|
|
|
/* Handle software interrupts */
|
|
|
|
|
|
|
|
void
|
|
|
|
dosoftints()
|
|
|
|
{
|
1998-09-05 07:59:29 +04:00
|
|
|
u_int softints;
|
1997-10-14 13:31:14 +04:00
|
|
|
int s;
|
|
|
|
|
1998-09-05 07:59:29 +04:00
|
|
|
softints = soft_interrupts & spl_smasks[current_spl_level];
|
1997-10-14 13:31:14 +04:00
|
|
|
if (softints == 0) return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Software clock interrupts
|
|
|
|
*/
|
|
|
|
|
1998-09-05 07:59:29 +04:00
|
|
|
if (softints & SOFTIRQ_BIT(SOFTIRQ_CLOCK)) {
|
|
|
|
s = splsoftclock();
|
|
|
|
++COUNT;
|
|
|
|
INC_SINTRCNT(SOFTIRQ_CLOCK);
|
|
|
|
clearsoftintr(SOFTIRQ_BIT(SOFTIRQ_CLOCK));
|
2001-01-15 23:19:50 +03:00
|
|
|
softclock(NULL);
|
2000-01-10 07:05:50 +03:00
|
|
|
(void)splx(s);
|
1997-10-14 13:31:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Network software interrupts
|
|
|
|
*/
|
|
|
|
|
1998-09-05 07:59:29 +04:00
|
|
|
if (softints & SOFTIRQ_BIT(SOFTIRQ_NET)) {
|
|
|
|
s = splsoftnet();
|
|
|
|
++COUNT;
|
|
|
|
INC_SINTRCNT(SOFTIRQ_NET);
|
|
|
|
clearsoftintr(SOFTIRQ_BIT(SOFTIRQ_NET));
|
1997-10-14 13:31:14 +04:00
|
|
|
|
2000-02-21 23:38:46 +03:00
|
|
|
#define DONETISR(bit, fn) do { \
|
|
|
|
if (netisr & (1 << bit)) { \
|
|
|
|
atomic_clear_bit(&netisr, (1 << bit)); \
|
|
|
|
fn(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#include <net/netisr_dispatch.h>
|
|
|
|
|
|
|
|
#undef DONETISR
|
|
|
|
|
2000-01-10 07:05:50 +03:00
|
|
|
(void)splx(s);
|
1998-09-05 07:59:29 +04:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Serial software interrupts
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (softints & SOFTIRQ_BIT(SOFTIRQ_SERIAL)) {
|
|
|
|
s = splsoftserial();
|
|
|
|
++COUNT;
|
|
|
|
INC_SINTRCNT(SOFTIRQ_SERIAL);
|
|
|
|
clearsoftintr(SOFTIRQ_BIT(SOFTIRQ_SERIAL));
|
|
|
|
#if NCOM > 0
|
|
|
|
comsoft();
|
|
|
|
#endif /* NCOM > 0 */
|
2000-01-10 07:05:50 +03:00
|
|
|
(void)splx(s);
|
1997-10-14 13:31:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* End of intr.c */
|