Move the bulk of pci_intr_string into a seperate intr_string function. Use

that new function to print the pciide compat interrupt in pciide_machdep.c.
Share pciide_machdep.c between amd64 and i386.
This commit is contained in:
fvdl 2003-09-06 17:44:36 +00:00
parent 4bfb9a4429
commit 5a759ef06c
8 changed files with 68 additions and 116 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: files.amd64,v 1.5 2003/08/20 21:48:52 fvdl Exp $
# $NetBSD: files.amd64,v 1.6 2003/09/06 17:44:36 fvdl Exp $
#
# new style config file for amd64 architecture
#
@ -107,7 +107,6 @@ file arch/amd64/amd64/cpu.c cpu
include "dev/pci/files.pci"
defparam PCI_CONF_MODE
file arch/amd64/pci/pciide_machdep.c pciide
# PCI-Host bridge chipsets
device pchb: pcibus

View File

@ -1,4 +1,4 @@
# $NetBSD: files.i386,v 1.242 2003/07/27 01:19:26 thorpej Exp $
# $NetBSD: files.i386,v 1.243 2003/09/06 17:44:38 fvdl Exp $
#
# new style config file for i386 architecture
#
@ -162,7 +162,6 @@ file arch/i386/pci/ali1543.c pcibios & pcibios_intr_fixup
file arch/i386/pci/pci_bus_fixup.c pcibios & pcibios_bus_fixup
file arch/i386/pci/pci_addr_fixup.c pcibios & pcibios_addr_fixup
defparam PCI_CONF_MODE
file arch/i386/pci/pciide_machdep.c pciide
file arch/i386/pci/pcic_pci_machdep.c pcic_pci
# PCI-Host bridge chipsets

View File

@ -1,75 +0,0 @@
/* $NetBSD: pciide_machdep.c,v 1.4 2001/11/15 07:03:35 lukem Exp $ */
/*
* Copyright (c) 1998 Christopher G. Demetriou. 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:
* This product includes software developed by Christopher G. Demetriou
* for the NetBSD Project.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* 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 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.
*/
/*
* PCI IDE controller driver (i386 machine-dependent portion).
*
* Author: Christopher G. Demetriou, March 2, 1998 (derived from NetBSD
* sys/dev/pci/ppb.c, revision 1.16).
*
* See "PCI IDE Controller Specification, Revision 1.0 3/4/94" from the
* PCI SIG.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pciide_machdep.c,v 1.4 2001/11/15 07:03:35 lukem Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pciidereg.h>
#include <dev/pci/pciidevar.h>
#include <dev/isa/isavar.h>
void *
pciide_machdep_compat_intr_establish(dev, pa, chan, func, arg)
struct device *dev;
struct pci_attach_args *pa;
int chan;
int (*func) __P((void *));
void *arg;
{
int irq;
void *cookie;
irq = PCIIDE_COMPAT_IRQ(chan);
cookie = isa_intr_establish(NULL, irq, IST_EDGE, IPL_BIO, func, arg);
if (cookie == NULL)
return (NULL);
printf("%s: %s channel interrupting at irq %d\n", dev->dv_xname,
PCIIDE_CHANNEL_NAME(chan), irq);
return (cookie);
}

View File

@ -1,4 +1,4 @@
# $NetBSD: files.x86,v 1.8 2003/05/29 20:22:31 fvdl Exp $
# $NetBSD: files.x86,v 1.9 2003/09/06 17:44:39 fvdl Exp $
# options for MP configuration through the MP spec
defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@ -39,3 +39,5 @@ file arch/x86/x86/acpi_machdep.c acpi
file arch/x86/pci/pci_machdep.c pci
file arch/x86/isa/isa_machdep.c isa
file arch/x86/pci/pciide_machdep.c pciide

View File

@ -1,4 +1,4 @@
/* $NetBSD: intr.h,v 1.6 2003/08/20 21:48:46 fvdl Exp $ */
/* $NetBSD: intr.h,v 1.7 2003/09/06 17:44:39 fvdl Exp $ */
/*-
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@ -253,6 +253,7 @@ int intr_allocate_slot(struct pic *, int, int, int, struct cpu_info **, int *,
int *);
void *intr_establish(int, struct pic *, int, int, int, int (*)(void *), void *);
void intr_disestablish(struct intrhand *);
const char *intr_string(int);
void cpu_intr_init(struct cpu_info *);
int intr_find_mpmapping(int bus, int pin, int *handle);
#ifdef INTRDEBUG

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci_machdep.c,v 1.6 2003/09/06 14:55:50 fvdl Exp $ */
/* $NetBSD: pci_machdep.c,v 1.7 2003/09/06 17:44:40 fvdl Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.6 2003/09/06 14:55:50 fvdl Exp $");
__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.7 2003/09/06 17:44:40 fvdl Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -623,37 +623,10 @@ pci_intr_string(pc, ih)
pci_chipset_tag_t pc;
pci_intr_handle_t ih;
{
static char irqstr[64];
#if NIOAPIC > 0
struct pic *pic;
#endif
if (ih == 0)
panic("pci_intr_string: bogus handle 0x%x", ih);
#if NIOAPIC > 0
if (ih & APIC_INT_VIA_APIC) {
pic = (struct pic *)ioapic_find(APIC_IRQ_APIC(ih));
if (pic != NULL) {
sprintf(irqstr, "%s pin %d (irq %d)",
pic->pic_name, APIC_IRQ_PIN(ih), ih&0xff);
} else {
sprintf(irqstr, "apic %d int %d (irq %d)",
APIC_IRQ_APIC(ih),
APIC_IRQ_PIN(ih),
ih&0xff);
}
} else
sprintf(irqstr, "irq %d", ih&0xff);
#else
sprintf(irqstr, "irq %d", ih&0xff);
#endif
return (irqstr);
return intr_string(ih);
}
const struct evcnt *
pci_intr_evcnt(pc, ih)
pci_chipset_tag_t pc;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pciide_machdep.c,v 1.2 2003/07/14 23:32:34 lukem Exp $ */
/* $NetBSD: pciide_machdep.c,v 1.1 2003/09/06 17:44:40 fvdl Exp $ */
/*
* Copyright (c) 1998 Christopher G. Demetriou. All rights reserved.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pciide_machdep.c,v 1.2 2003/07/14 23:32:34 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: pciide_machdep.c,v 1.1 2003/09/06 17:44:40 fvdl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -54,6 +54,13 @@ __KERNEL_RCSID(0, "$NetBSD: pciide_machdep.c,v 1.2 2003/07/14 23:32:34 lukem Exp
#include <dev/isa/isavar.h>
#include "ioapic.h"
#if NIOAPIC > 0
#include <machine/i82093var.h>
#include <machine/mpbiosvar.h>
#endif
void *
pciide_machdep_compat_intr_establish(dev, pa, chan, func, arg)
struct device *dev;
@ -64,11 +71,23 @@ pciide_machdep_compat_intr_establish(dev, pa, chan, func, arg)
{
int irq;
void *cookie;
#if NIOAPIC > 0
int mpih;
#endif
irq = PCIIDE_COMPAT_IRQ(chan);
cookie = isa_intr_establish(NULL, irq, IST_EDGE, IPL_BIO, func, arg);
if (cookie == NULL)
return (NULL);
#if NIOAPIC > 0
if (mp_busses != NULL &&
(intr_find_mpmapping(mp_isa_bus, irq, &mpih) == 0 ||
intr_find_mpmapping(mp_eisa_bus, irq, &mpih) == 0)) {
mpih |= irq;
printf("%s: %s channel interrupting at %s\n", dev->dv_xname,
PCIIDE_CHANNEL_NAME(chan), intr_string(mpih));
} else
#endif
printf("%s: %s channel interrupting at irq %d\n", dev->dv_xname,
PCIIDE_CHANNEL_NAME(chan), irq);
return (cookie);

View File

@ -1,4 +1,4 @@
/* $NetBSD: intr.c,v 1.5 2003/08/20 21:48:47 fvdl Exp $ */
/* $NetBSD: intr.c,v 1.6 2003/09/06 17:44:40 fvdl Exp $ */
/*
* Copyright 2002 (c) Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.5 2003/08/20 21:48:47 fvdl Exp $");
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.6 2003/09/06 17:44:40 fvdl Exp $");
#include "opt_multiprocessor.h"
@ -521,6 +521,40 @@ intr_disestablish(struct intrhand *ih)
simple_unlock(&ci->ci_slock);
}
const char *
intr_string(int ih)
{
static char irqstr[64];
#if NIOAPIC > 0
struct pic *pic;
#endif
if (ih == 0)
panic("pci_intr_string: bogus handle 0x%x", ih);
#if NIOAPIC > 0
if (ih & APIC_INT_VIA_APIC) {
pic = (struct pic *)ioapic_find(APIC_IRQ_APIC(ih));
if (pic != NULL) {
sprintf(irqstr, "%s pin %d (irq %d)",
pic->pic_name, APIC_IRQ_PIN(ih), ih&0xff);
} else {
sprintf(irqstr, "apic %d int %d (irq %d)",
APIC_IRQ_APIC(ih),
APIC_IRQ_PIN(ih),
ih&0xff);
}
} else
sprintf(irqstr, "irq %d", ih&0xff);
#else
sprintf(irqstr, "irq %d", ih&0xff);
#endif
return (irqstr);
}
#define CONCAT(x,y) __CONCAT(x,y)
/*