Add some generic interrupt dispatch code.
This commit is contained in:
parent
cefd88ce75
commit
56abfaf4eb
@ -1,4 +1,4 @@
|
||||
/* $Id: interrupt.c,v 1.2 1998/06/10 20:13:32 dfr Exp $ */
|
||||
/* $Id: interrupt.c,v 1.3 1998/07/05 12:22:56 dfr Exp $ */
|
||||
/* $NetBSD: interrupt.c,v 1.23 1998/02/24 07:38:01 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
@ -41,11 +41,14 @@
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/vmmeter.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/malloc.h>
|
||||
|
||||
#include <machine/reg.h>
|
||||
#include <machine/frame.h>
|
||||
#include <machine/cpuconf.h>
|
||||
#include <machine/bwx.h>
|
||||
#include <machine/intr.h>
|
||||
|
||||
#if 0
|
||||
#ifdef EVCNT_COUNTERS
|
||||
@ -271,3 +274,44 @@ badaddr_read(addr, size, rptr)
|
||||
/* Return non-zero (i.e. true) if it's a bad address. */
|
||||
return (mc_received);
|
||||
}
|
||||
|
||||
#define HASHVEC(vector) ((vector) % 31)
|
||||
|
||||
static struct alpha_intr_list alpha_intr_hash[31];
|
||||
|
||||
struct alpha_intr *
|
||||
alpha_create_intr(int vector, driver_intr_t *intr, void *arg)
|
||||
{
|
||||
struct alpha_intr *i;
|
||||
|
||||
i = malloc(sizeof(struct alpha_intr), M_DEVBUF, M_NOWAIT);
|
||||
if (!i)
|
||||
return NULL;
|
||||
i->vector = vector;
|
||||
i->intr = intr;
|
||||
i->arg = arg;
|
||||
return i;
|
||||
}
|
||||
|
||||
int
|
||||
alpha_connect_intr(struct alpha_intr *i)
|
||||
{
|
||||
int h = HASHVEC(i->vector);
|
||||
int s;
|
||||
|
||||
s = splhigh();
|
||||
LIST_INSERT_HEAD(&alpha_intr_hash[h], i, list);
|
||||
splx(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
alpha_dispatch_intr(int vector)
|
||||
{
|
||||
struct alpha_intr *i;
|
||||
int h = HASHVEC(vector);
|
||||
for (i = LIST_FIRST(&alpha_intr_hash[h]); i; i = LIST_NEXT(i, list))
|
||||
if (i->vector == vector)
|
||||
i->intr(i->arg);
|
||||
}
|
||||
|
@ -1,124 +1,46 @@
|
||||
/* $Id$ */
|
||||
/* From: NetBSD: intr.h,v 1.11 1997/11/10 18:23:50 mjacob Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Christopher G. Demetriou. All rights reserved.
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
/*-
|
||||
* Copyright (c) 1998 Doug Rabson
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
* 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.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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, 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.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _ALPHA_INTR_H_
|
||||
#define _ALPHA_INTR_H_
|
||||
#ifndef _MACHINE_INTR_H_
|
||||
#define _MACHINE_INTR_H_
|
||||
|
||||
#include <sys/queue.h>
|
||||
LIST_HEAD(alpha_intr_list, alpha_intr);
|
||||
|
||||
#define IPL_NONE 0 /* disable only this interrupt */
|
||||
#define IPL_BIO 1 /* disable block I/O interrupts */
|
||||
#define IPL_NET 2 /* disable network interrupts */
|
||||
#define IPL_TTY 3 /* disable terminal interrupts */
|
||||
#define IPL_CLOCK 4 /* disable clock interrupts */
|
||||
#define IPL_HIGH 5 /* disable all interrupts */
|
||||
|
||||
#define IST_UNUSABLE -1 /* interrupt cannot be used */
|
||||
#define IST_NONE 0 /* none (dummy) */
|
||||
#define IST_PULSE 1 /* pulsed */
|
||||
#define IST_EDGE 2 /* edge-triggered */
|
||||
#define IST_LEVEL 3 /* level-triggered */
|
||||
#ifdef _KERNEL
|
||||
|
||||
/* IPL-lowering/restoring macros */
|
||||
#define splx(s) \
|
||||
((s) == ALPHA_PSL_IPL_0 ? spl0() : alpha_pal_swpipl(s))
|
||||
#define splsoft() alpha_pal_swpipl(ALPHA_PSL_IPL_SOFT)
|
||||
#define splsoftclock() splsoft()
|
||||
#define splsoftnet() splsoft()
|
||||
|
||||
/* IPL-raising functions/macros */
|
||||
static __inline int _splraise __P((int)) __attribute__ ((unused));
|
||||
static __inline int
|
||||
_splraise(s)
|
||||
int s;
|
||||
{
|
||||
int cur = alpha_pal_rdps() & ALPHA_PSL_IPL_MASK;
|
||||
return (s > cur ? alpha_pal_swpipl(s) : cur);
|
||||
}
|
||||
#define splnet() _splraise(ALPHA_PSL_IPL_IO)
|
||||
#define splbio() _splraise(ALPHA_PSL_IPL_IO)
|
||||
#define splimp() _splraise(ALPHA_PSL_IPL_IO)
|
||||
#define spltty() _splraise(ALPHA_PSL_IPL_IO)
|
||||
#define splclock() _splraise(ALPHA_PSL_IPL_CLOCK)
|
||||
#define splstatclock() _splraise(ALPHA_PSL_IPL_CLOCK)
|
||||
#define splhigh() _splraise(ALPHA_PSL_IPL_HIGH)
|
||||
|
||||
/*
|
||||
* simulated software interrupt register
|
||||
*/
|
||||
extern u_int64_t ssir;
|
||||
|
||||
#define SIR_NET 0x1
|
||||
#define SIR_CLOCK 0x2
|
||||
|
||||
#define setsoftnet() ssir |= SIR_NET
|
||||
#define setsoftclock() ssir |= SIR_CLOCK
|
||||
|
||||
/*
|
||||
* Alpha shared-interrupt-line common code.
|
||||
*/
|
||||
|
||||
struct alpha_shared_intrhand {
|
||||
TAILQ_ENTRY(alpha_shared_intrhand)
|
||||
ih_q;
|
||||
int (*ih_fn) __P((void *));
|
||||
void *ih_arg;
|
||||
int ih_level;
|
||||
struct alpha_intr {
|
||||
LIST_ENTRY(alpha_intr) list; /* chain handlers in this hash bucket */
|
||||
int vector; /* vector to match */
|
||||
driver_intr_t *intr; /* handler function */
|
||||
void *arg; /* argument to handler */
|
||||
};
|
||||
|
||||
struct alpha_shared_intr {
|
||||
TAILQ_HEAD(,alpha_shared_intrhand)
|
||||
intr_q;
|
||||
int intr_sharetype;
|
||||
int intr_dfltsharetype;
|
||||
int intr_nstrays;
|
||||
int intr_maxstrays;
|
||||
};
|
||||
struct alpha_intr *alpha_create_intr(int vector,
|
||||
driver_intr_t *intr, void *arg);
|
||||
int alpha_connect_intr(struct alpha_intr *i);
|
||||
void alpha_dispatch_intr(int vector);
|
||||
|
||||
struct alpha_shared_intr *alpha_shared_intr_alloc __P((unsigned int));
|
||||
int alpha_shared_intr_dispatch __P((struct alpha_shared_intr *,
|
||||
unsigned int));
|
||||
void *alpha_shared_intr_establish __P((struct alpha_shared_intr *,
|
||||
unsigned int, int, int, int (*)(void *), void *, const char *));
|
||||
int alpha_shared_intr_get_sharetype __P((struct alpha_shared_intr *,
|
||||
unsigned int));
|
||||
int alpha_shared_intr_isactive __P((struct alpha_shared_intr *,
|
||||
unsigned int));
|
||||
void alpha_shared_intr_set_dfltsharetype __P((struct alpha_shared_intr *,
|
||||
unsigned int, int));
|
||||
void alpha_shared_intr_set_maxstrays __P((struct alpha_shared_intr *,
|
||||
unsigned int, int));
|
||||
void alpha_shared_intr_stray __P((struct alpha_shared_intr *, unsigned int,
|
||||
const char *));
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif /* !_MACHINE_INTR_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user