Use the mace interrupt handler for PCI interrupts.

From KIYOHARA Takashi
This commit is contained in:
sekiya 2004-09-06 07:24:06 +00:00
parent 4a83eca5d5
commit 8590eac465
7 changed files with 69 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: crime.c,v 1.18 2004/01/18 04:06:42 sekiya Exp $ */
/* $NetBSD: crime.c,v 1.19 2004/09/06 07:24:06 sekiya Exp $ */
/*
* Copyright (c) 2004 Christopher SEKIYA
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: crime.c,v 1.18 2004/01/18 04:06:42 sekiya Exp $");
__KERNEL_RCSID(0, "$NetBSD: crime.c,v 1.19 2004/09/06 07:24:06 sekiya Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -183,7 +183,7 @@ crime_attach(struct device *parent, struct device *self, void *aux)
void *
crime_intr_establish(int irq, int level, int (*func)(void *), void *arg)
{
if (irq < 8)
if (irq < 16)
return mace_intr_establish(irq, level, func, arg);
if (crime[irq].func != NULL)
@ -209,8 +209,8 @@ crime_intr(u_int32_t status, u_int32_t cause, u_int32_t pc, u_int32_t ipending)
crime_intstat = bus_space_read_8(crm_iot, crm_ioh, CRIME_INTSTAT);
crime_ipending = (crime_intstat & crime_intmask);
if (crime_ipending & 0xff)
mace_intr(crime_ipending & 0xff);
if (crime_ipending & 0xffff)
mace_intr(crime_ipending & 0xffff);
if (crime_ipending & 0xffff0000) {
/*
@ -255,6 +255,16 @@ crime_intr_mask(unsigned int intr)
bus_space_write_8(crm_iot, crm_ioh, CRIME_INTMASK, mask);
}
void
crime_intr_unmask(unsigned int intr)
{
u_int64_t mask;
mask = bus_space_read_8(crm_iot, crm_ioh, CRIME_INTMASK);
mask &= ~(1 << intr);
bus_space_write_8(crm_iot, crm_ioh, CRIME_INTMASK, mask);
}
void
crime_bus_reset(void)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: crimevar.h,v 1.3 2004/01/18 00:54:55 sekiya Exp $ */
/* $NetBSD: crimevar.h,v 1.4 2004/09/06 07:24:06 sekiya Exp $ */
/*
* Copyright (c) 2003 Christopher SEKIYA
@ -39,3 +39,4 @@ struct crime_softc {
};
void crime_intr_mask(unsigned int);
void crime_intr_unmask(unsigned int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci_machdep.h,v 1.5 2004/07/29 16:55:25 drochner Exp $ */
/* $NetBSD: pci_machdep.h,v 1.6 2004/09/06 07:24:06 sekiya Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@ -55,6 +55,9 @@ struct sgimips_pci_chipset {
pcireg_t (*pc_conf_read)(pci_chipset_tag_t, pcitag_t, int);
void (*pc_conf_write)(pci_chipset_tag_t, pcitag_t, int,
pcireg_t);
void *(*intr_establish)(int , int, int (*)(void *), void *);
void (*intr_disestablish)(void *ih);
bus_space_tag_t iot;
bus_space_handle_t ioh;
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: mace.c,v 1.4 2004/07/10 08:47:33 tsutsui Exp $ */
/* $NetBSD: mace.c,v 1.5 2004/09/06 07:24:06 sekiya Exp $ */
/*
* Copyright (c) 2003 Christopher Sekiya
@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mace.c,v 1.4 2004/07/10 08:47:33 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: mace.c,v 1.5 2004/09/06 07:24:06 sekiya Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -267,7 +267,7 @@ mace_intr_establish(int intr, int level, int (*func)(void *), void *arg)
{
int i;
if (intr < 0 || intr >= 8)
if (intr < 0 || intr >= 16)
panic("invalid interrupt number");
for (i = 0; i < MACE_NINTR; i++)
@ -291,6 +291,41 @@ mace_intr_establish(int intr, int level, int (*func)(void *), void *arg)
return (void *)&maceintrtab[i];
}
void
mace_intr_disestablish(void *cookie)
{
int intr = -1, level = 0, irq = 0, i;
for (i = 0; i < MACE_NINTR; i++)
if (&maceintrtab[i] == cookie) {
evcnt_detach(&maceintrtab[i].evcnt);
for (intr = 0;
maceintrtab[i].irq == (1 << intr); intr ++);
level = maceintrtab[i].intrmask;
irq = maceintrtab[i].irq;
maceintrtab[i].irq = 0;
maceintrtab[i].intrmask = 0;
maceintrtab[i].func = NULL;
maceintrtab[i].arg = NULL;
bzero(&maceintrtab[i].evcnt, sizeof (struct evcnt));
bzero(&maceintrtab[i].evname,
sizeof (maceintrtab[i].evname));
break;
}
if (intr == -1)
panic("mace: lost maceintrtab");
/* do not do a unmask, when irq is being shared. */
for (i = 0; i < MACE_NINTR; i++)
if (&maceintrtab[i].func != NULL && maceintrtab[i].irq == irq)
break;
if (i == MACE_NINTR)
crime_intr_unmask(intr);
aprint_normal("mace: disestablished interrupt %d (level %x)\n",
intr, level);
}
void
mace_intr(int irqs)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: macevar.h,v 1.1 2004/01/18 04:06:43 sekiya Exp $ */
/* $NetBSD: macevar.h,v 1.2 2004/09/06 07:24:06 sekiya Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang
@ -44,4 +44,5 @@ struct mace_attach_args {
};
void * mace_intr_establish(int, int, int (*)(void *), void *);
void mace_intr_disestablish(void *);
void mace_intr(int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci_mace.c,v 1.3 2004/08/30 15:05:18 drochner Exp $ */
/* $NetBSD: pci_mace.c,v 1.4 2004/09/06 07:24:06 sekiya Exp $ */
/*
* Copyright (c) 2001,2003 Christopher Sekiya
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pci_mace.c,v 1.3 2004/08/30 15:05:18 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: pci_mace.c,v 1.4 2004/09/06 07:24:06 sekiya Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -131,6 +131,8 @@ macepci_attach(parent, self, aux)
pc->pc_conf_read = macepci_conf_read;
pc->pc_conf_write = macepci_conf_write;
pc->intr_establish = mace_intr_establish;
pc->intr_disestablish = mace_intr_disestablish;
bus_space_write_4(pc->iot, pc->ioh, MACE_PCI_ERROR_ADDR, 0);
bus_space_write_4(pc->iot, pc->ioh, MACE_PCI_ERROR_FLAGS, 0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci_machdep.c,v 1.13 2004/01/18 00:50:08 sekiya Exp $ */
/* $NetBSD: pci_machdep.c,v 1.14 2004/09/06 07:24:06 sekiya Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.13 2004/01/18 00:50:08 sekiya Exp $");
__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.14 2004/09/06 07:24:06 sekiya Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -213,7 +213,7 @@ pci_intr_establish(pc, ih, level, func, arg)
void *arg;
{
return (void *)(*platform.intr_establish)(ih, 0, func, arg);
return (void *)(pc->intr_establish)(ih, 0, func, arg);
}
void
@ -222,5 +222,5 @@ pci_intr_disestablish(pc, cookie)
void *cookie;
{
panic("pci_intr_disestablish: not implemented");
(pc->intr_disestablish)(cookie);
}