Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/alpha Don't use a bunch of switch() statements in t...
details: https://anonhg.NetBSD.org/src/rev/7cb5563364e3
branches: trunk
changeset: 379792:7cb5563364e3
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Jun 19 16:59:07 2021 +0000
description:
Don't use a bunch of switch() statements in the core logic drivers to select
the PCI interrupt initialization routine. Instead, register said routines
by systype in a link set, and look them up and invoke them in a new function
alpha_pci_intr_init().
diffstat:
sys/arch/alpha/include/pci_machdep.h | 17 +++++++++-
sys/arch/alpha/pci/apecs.c | 52 +----------------------------
sys/arch/alpha/pci/cia.c | 61 +----------------------------------
sys/arch/alpha/pci/dwlpx.c | 8 ++--
sys/arch/alpha/pci/irongate.c | 21 +----------
sys/arch/alpha/pci/lca.c | 38 +--------------------
sys/arch/alpha/pci/mcpcia.c | 7 +--
sys/arch/alpha/pci/pci_1000.c | 13 ++++---
sys/arch/alpha/pci/pci_1000.h | 33 -------------------
sys/arch/alpha/pci/pci_1000a.c | 13 ++++---
sys/arch/alpha/pci/pci_1000a.h | 33 -------------------
sys/arch/alpha/pci/pci_2100_a50.c | 16 ++++----
sys/arch/alpha/pci/pci_2100_a50.h | 30 -----------------
sys/arch/alpha/pci/pci_2100_a500.c | 18 ++++++----
sys/arch/alpha/pci/pci_2100_a500.h | 3 +-
sys/arch/alpha/pci/pci_550.c | 18 ++++-----
sys/arch/alpha/pci/pci_550.h | 30 -----------------
sys/arch/alpha/pci/pci_6600.c | 18 +++++-----
sys/arch/alpha/pci/pci_6600.h | 5 --
sys/arch/alpha/pci/pci_alphabook1.c | 16 ++++----
sys/arch/alpha/pci/pci_alphabook1.h | 30 -----------------
sys/arch/alpha/pci/pci_axppci_33.c | 16 ++++----
sys/arch/alpha/pci/pci_axppci_33.h | 30 -----------------
sys/arch/alpha/pci/pci_eb164.c | 17 ++++-----
sys/arch/alpha/pci/pci_eb164.h | 30 -----------------
sys/arch/alpha/pci/pci_eb64plus.c | 17 ++++-----
sys/arch/alpha/pci/pci_eb64plus.h | 30 -----------------
sys/arch/alpha/pci/pci_eb66.c | 17 ++++-----
sys/arch/alpha/pci/pci_eb66.h | 30 -----------------
sys/arch/alpha/pci/pci_kn20aa.c | 19 ++++------
sys/arch/alpha/pci/pci_kn20aa.h | 30 -----------------
sys/arch/alpha/pci/pci_kn300.c | 16 +++++----
sys/arch/alpha/pci/pci_kn300.h | 33 -------------------
sys/arch/alpha/pci/pci_kn8ae.c | 15 ++++----
sys/arch/alpha/pci/pci_kn8ae.h | 33 -------------------
sys/arch/alpha/pci/pci_machdep.c | 20 ++++++++++-
sys/arch/alpha/pci/pci_up1000.c | 17 ++++-----
sys/arch/alpha/pci/pci_up1000.h | 32 ------------------
sys/arch/alpha/pci/tsc.c | 12 +-----
sys/arch/alpha/pci/ttwoga.c | 19 ++--------
40 files changed, 185 insertions(+), 728 deletions(-)
diffs (truncated from 1932 to 300 lines):
diff -r 06685493a0f2 -r 7cb5563364e3 sys/arch/alpha/include/pci_machdep.h
--- a/sys/arch/alpha/include/pci_machdep.h Sat Jun 19 16:43:11 2021 +0000
+++ b/sys/arch/alpha/include/pci_machdep.h Sat Jun 19 16:59:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.h,v 1.22 2021/05/27 22:11:31 thorpej Exp $ */
+/* $NetBSD: pci_machdep.h,v 1.23 2021/06/19 16:59:07 thorpej Exp $ */
/*
* Copyright (c) 1996 Carnegie-Mellon University.
@@ -96,6 +96,18 @@ struct alpha_pci_chipset {
struct cpu_info *);
};
+struct alpha_pci_intr_impl {
+ uint64_t systype;
+ void (*intr_init)(void *, bus_space_tag_t, bus_space_tag_t,
+ pci_chipset_tag_t);
+};
+
+#define ALPHA_PCI_INTR_INIT(_st_, _fn_) \
+static const struct alpha_pci_intr_impl __CONCAT(intr_impl_st_,_st_) = {\
+ .systype = (_st_), .intr_init = (_fn_), \
+}; \
+__link_set_add_rodata(alpha_pci_intr_impls, __CONCAT(intr_impl_st_,_st_));
+
/*
* Functions provided to machine-independent PCI code.
*/
@@ -122,6 +134,9 @@ void pci_display_console(bus_space_tag_t
pci_chipset_tag_t, int, int, int);
void device_pci_register(device_t, void *);
+void alpha_pci_intr_init(void *, bus_space_tag_t, bus_space_tag_t,
+ pci_chipset_tag_t);
+
int alpha_pci_generic_intr_map(const struct pci_attach_args *,
pci_intr_handle_t *);
const char *alpha_pci_generic_intr_string(pci_chipset_tag_t,
diff -r 06685493a0f2 -r 7cb5563364e3 sys/arch/alpha/pci/apecs.c
--- a/sys/arch/alpha/pci/apecs.c Sat Jun 19 16:43:11 2021 +0000
+++ b/sys/arch/alpha/pci/apecs.c Sat Jun 19 16:59:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: apecs.c,v 1.56 2021/06/18 22:17:53 thorpej Exp $ */
+/* $NetBSD: apecs.c,v 1.57 2021/06/19 16:59:07 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -56,14 +56,9 @@
* rights to redistribute these changes.
*/
-#include "opt_dec_2100_a50.h"
-#include "opt_dec_eb64plus.h"
-#include "opt_dec_1000a.h"
-#include "opt_dec_1000.h"
-
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: apecs.c,v 1.56 2021/06/18 22:17:53 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apecs.c,v 1.57 2021/06/19 16:59:07 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -82,18 +77,6 @@
#include <dev/pci/pcivar.h>
#include <alpha/pci/apecsreg.h>
#include <alpha/pci/apecsvar.h>
-#ifdef DEC_2100_A50
-#include <alpha/pci/pci_2100_a50.h>
-#endif
-#ifdef DEC_EB64PLUS
-#include <alpha/pci/pci_eb64plus.h>
-#endif
-#ifdef DEC_1000A
-#include <alpha/pci/pci_1000a.h>
-#endif
-#ifdef DEC_1000
-#include <alpha/pci/pci_1000.h>
-#endif
static int apecsmatch(device_t, cfdata_t, void *);
static void apecsattach(device_t, device_t, void *);
@@ -189,36 +172,7 @@ apecsattach(device_t parent, device_t se
if (!acp->ac_epic_pass2)
printf("WARNING: 21071-DA NOT PASS2... NO BETS...\n");
- switch (cputype) {
-#ifdef DEC_2100_A50
- case ST_DEC_2100_A50:
- pci_2100_a50_pickintr(acp);
- break;
-#endif
-
-#ifdef DEC_EB64PLUS
- case ST_EB64P:
- pci_eb64plus_pickintr(acp);
- break;
-#endif
-
-#ifdef DEC_1000A
- case ST_DEC_1000A:
- pci_1000a_pickintr(acp, &acp->ac_iot, &acp->ac_memt,
- &acp->ac_pc);
- break;
-#endif
-
-#ifdef DEC_1000
- case ST_DEC_1000:
- pci_1000_pickintr(acp, &acp->ac_iot, &acp->ac_memt,
- &acp->ac_pc);
- break;
-#endif
-
- default:
- panic("apecsattach: shouldn't be here, really...");
- }
+ alpha_pci_intr_init(acp, &acp->ac_iot, &acp->ac_memt, &acp->ac_pc);
pba.pba_iot = &acp->ac_iot;
pba.pba_memt = &acp->ac_memt;
diff -r 06685493a0f2 -r 7cb5563364e3 sys/arch/alpha/pci/cia.c
--- a/sys/arch/alpha/pci/cia.c Sat Jun 19 16:43:11 2021 +0000
+++ b/sys/arch/alpha/pci/cia.c Sat Jun 19 16:59:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cia.c,v 1.76 2021/06/18 22:17:53 thorpej Exp $ */
+/* $NetBSD: cia.c,v 1.77 2021/06/19 16:59:07 thorpej Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -57,15 +57,11 @@
* rights to redistribute these changes.
*/
-#include "opt_dec_eb164.h"
-#include "opt_dec_kn20aa.h"
#include "opt_dec_550.h"
-#include "opt_dec_1000a.h"
-#include "opt_dec_1000.h"
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: cia.c,v 1.76 2021/06/18 22:17:53 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cia.c,v 1.77 2021/06/19 16:59:07 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -86,22 +82,6 @@
#include <alpha/pci/ciareg.h>
#include <alpha/pci/ciavar.h>
-#ifdef DEC_KN20AA
-#include <alpha/pci/pci_kn20aa.h>
-#endif
-#ifdef DEC_EB164
-#include <alpha/pci/pci_eb164.h>
-#endif
-#ifdef DEC_550
-#include <alpha/pci/pci_550.h>
-#endif
-#ifdef DEC_1000A
-#include <alpha/pci/pci_1000a.h>
-#endif
-#ifdef DEC_1000
-#include <alpha/pci/pci_1000.h>
-#endif
-
static int ciamatch(device_t, cfdata_t, void *);
static void ciaattach(device_t, device_t, void *);
@@ -353,42 +333,7 @@ ciaattach(device_t parent, device_t self
cia_dma_init(ccp);
- switch (cputype) {
-#ifdef DEC_KN20AA
- case ST_DEC_KN20AA:
- pci_kn20aa_pickintr(ccp);
- break;
-#endif
-
-#ifdef DEC_EB164
- case ST_EB164:
- pci_eb164_pickintr(ccp);
- break;
-#endif
-
-#ifdef DEC_550
- case ST_DEC_550:
- pci_550_pickintr(ccp);
- break;
-#endif
-
-#ifdef DEC_1000A
- case ST_DEC_1000A:
- pci_1000a_pickintr(ccp, &ccp->cc_iot, &ccp->cc_memt,
- &ccp->cc_pc);
- break;
-#endif
-
-#ifdef DEC_1000
- case ST_DEC_1000:
- pci_1000_pickintr(ccp, &ccp->cc_iot, &ccp->cc_memt,
- &ccp->cc_pc);
- break;
-#endif
-
- default:
- panic("ciaattach: shouldn't be here, really...");
- }
+ alpha_pci_intr_init(ccp, &ccp->cc_iot, &ccp->cc_memt, &ccp->cc_pc);
pba.pba_iot = &ccp->cc_iot;
pba.pba_memt = &ccp->cc_memt;
diff -r 06685493a0f2 -r 7cb5563364e3 sys/arch/alpha/pci/dwlpx.c
--- a/sys/arch/alpha/pci/dwlpx.c Sat Jun 19 16:43:11 2021 +0000
+++ b/sys/arch/alpha/pci/dwlpx.c Sat Jun 19 16:59:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwlpx.c,v 1.41 2021/06/19 16:29:03 thorpej Exp $ */
+/* $NetBSD: dwlpx.c,v 1.42 2021/06/19 16:59:07 thorpej Exp $ */
/*
* Copyright (c) 1997 by Matthew Jacob
@@ -32,7 +32,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: dwlpx.c,v 1.41 2021/06/19 16:29:03 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwlpx.c,v 1.42 2021/06/19 16:59:07 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -50,7 +50,6 @@
#include <alpha/tlsb/kftxxreg.h>
#include <alpha/pci/dwlpxreg.h>
#include <alpha/pci/dwlpxvar.h>
-#include <alpha/pci/pci_kn8ae.h>
#define KV(_addr) ((void *)ALPHA_PHYS_TO_K0SEG((_addr)))
#define DWLPX_SYSBASE(sc) \
@@ -160,7 +159,8 @@ dwlpxattach(device_t parent, device_t se
/*
* Set up interrupts
*/
- pci_kn8ae_pickintr(&sc->dwlpx_cc);
+ alpha_pci_intr_init(&sc->dwlpx_cc, &sc->dwlpx_cc.cc_iot,
+ &sc->dwlpx_cc.cc_memt, &sc->dwlpx_cc.cc_pc);
/*
* Attach PCI bus
diff -r 06685493a0f2 -r 7cb5563364e3 sys/arch/alpha/pci/irongate.c
--- a/sys/arch/alpha/pci/irongate.c Sat Jun 19 16:43:11 2021 +0000
+++ b/sys/arch/alpha/pci/irongate.c Sat Jun 19 16:59:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irongate.c,v 1.18 2021/06/18 22:17:53 thorpej Exp $ */
+/* $NetBSD: irongate.c,v 1.19 2021/06/19 16:59:07 thorpej Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -29,11 +29,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "opt_api_up1000.h"
-
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irongate.c,v 1.18 2021/06/18 22:17:53 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irongate.c,v 1.19 2021/06/19 16:59:07 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -53,10 +51,6 @@
#include <alpha/pci/irongatereg.h>
#include <alpha/pci/irongatevar.h>
-#ifdef API_UP1000
-#include <alpha/pci/pci_up1000.h>
-#endif
-
static int irongate_match(device_t, cfdata_t, void *);
static void irongate_attach(device_t, device_t, void *);
@@ -157,16 +151,7 @@ irongate_attach(device_t parent, device_
*/
irongate_bus_mem_init2(&icp->ic_memt, icp);
- switch (cputype) {
-#ifdef API_UP1000
- case ST_API_NAUTILUS:
- pci_up1000_pickintr(icp);
- break;
-#endif
-
- default:
- panic("irongate_attach: shouldn't be here, really...");
- }
+ alpha_pci_intr_init(icp, &icp->ic_iot, &icp->ic_memt, &icp->ic_pc);
tag = pci_make_tag(&icp->ic_pc, 0, IRONGATE_PCIHOST_DEV, 0);
Home |
Main Index |
Thread Index |
Old Index