diff options
author | Jason Wright <jason@cvs.openbsd.org> | 2003-01-13 16:04:39 +0000 |
---|---|---|
committer | Jason Wright <jason@cvs.openbsd.org> | 2003-01-13 16:04:39 +0000 |
commit | 66983a3519c3248880de09417f7edb422c0bdcf3 (patch) | |
tree | a936849ed82f096d616f09bc1cad7121f7b16bb7 /sys/arch/sparc64 | |
parent | dd528744f516d63f3c525d8e4d1e83008f338fb8 (diff) |
Don't use a global variable to determine which pci_conf* function to call,
store function pointers in the pci_chipset_tag_t (ie. fix an ugly hack
I did during the hackathon last year).
Diffstat (limited to 'sys/arch/sparc64')
-rw-r--r-- | sys/arch/sparc64/dev/pci_machdep.c | 22 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/psycho.c | 7 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/schizo.c | 7 | ||||
-rw-r--r-- | sys/arch/sparc64/include/pci_machdep.h | 18 |
4 files changed, 20 insertions, 34 deletions
diff --git a/sys/arch/sparc64/dev/pci_machdep.c b/sys/arch/sparc64/dev/pci_machdep.c index 782a46fd9dc..7889eada313 100644 --- a/sys/arch/sparc64/dev/pci_machdep.c +++ b/sys/arch/sparc64/dev/pci_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.c,v 1.9 2002/06/08 18:06:02 jason Exp $ */ +/* $OpenBSD: pci_machdep.c,v 1.10 2003/01/13 16:04:38 jason Exp $ */ /* $NetBSD: pci_machdep.c,v 1.22 2001/07/20 00:07:13 eeh Exp $ */ /* @@ -336,18 +336,6 @@ pci_make_tag(pc, b, d, f) return (tag); } -pcireg_t (*sparc64_pci_conf_read)(pci_chipset_tag_t, pcitag_t, int); -void (*sparc64_pci_conf_write)(pci_chipset_tag_t, pcitag_t, int, pcireg_t); - -void -pci_conf_setfunc(rd, wr) - pcireg_t (*rd)(pci_chipset_tag_t, pcitag_t, int); - void (*wr)(pci_chipset_tag_t, pcitag_t, int, pcireg_t); -{ - sparc64_pci_conf_read = rd; - sparc64_pci_conf_write = wr; -} - /* assume we are mapped little-endian/side-effect */ pcireg_t pci_conf_read(pc, tag, reg) @@ -355,9 +343,7 @@ pci_conf_read(pc, tag, reg) pcitag_t tag; int reg; { - if (sparc64_pci_conf_read == NULL) - panic("no pci_conf_read"); - return ((*sparc64_pci_conf_read)(pc, tag, reg)); + return (pc->conf_read(pc, tag, reg)); } void @@ -367,9 +353,7 @@ pci_conf_write(pc, tag, reg, data) int reg; pcireg_t data; { - if (sparc64_pci_conf_write == NULL) - panic("no pci_conf_read"); - return ((*sparc64_pci_conf_write)(pc, tag, reg, data)); + return (pc->conf_write(pc, tag, reg, data)); } diff --git a/sys/arch/sparc64/dev/psycho.c b/sys/arch/sparc64/dev/psycho.c index 1937ba28392..09b9ddd72c6 100644 --- a/sys/arch/sparc64/dev/psycho.c +++ b/sys/arch/sparc64/dev/psycho.c @@ -1,4 +1,4 @@ -/* $OpenBSD: psycho.c,v 1.24 2002/12/02 17:08:51 jason Exp $ */ +/* $OpenBSD: psycho.c,v 1.25 2003/01/13 16:04:38 jason Exp $ */ /* $NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp $ */ /* @@ -389,8 +389,6 @@ psycho_attach(parent, self, aux) printf("bus range %u to %u", psycho_br[0], psycho_br[1]); printf("; PCI bus %d", psycho_br[0]); - pci_conf_setfunc(psycho_pci_conf_read, psycho_pci_conf_write); - pp->pp_pcictl = &sc->sc_regs->psy_pcictl[0]; /* allocate our tags */ @@ -406,6 +404,9 @@ psycho_attach(parent, self, aux) /* setup the rest of the psycho pbm */ pba.pba_pc = pp->pp_pc; + pba.pba_pc->conf_read = psycho_pci_conf_read; + pba.pba_pc->conf_write = psycho_pci_conf_write; + printf("\n"); /* diff --git a/sys/arch/sparc64/dev/schizo.c b/sys/arch/sparc64/dev/schizo.c index 2819e098597..beb43cce579 100644 --- a/sys/arch/sparc64/dev/schizo.c +++ b/sys/arch/sparc64/dev/schizo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: schizo.c,v 1.7 2002/08/01 18:26:35 jason Exp $ */ +/* $OpenBSD: schizo.c,v 1.8 2003/01/13 16:04:38 jason Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -171,8 +171,6 @@ schizo_init(sc, busa) printf(": bus %c %d to %d\n", busa ? 'A' : 'B', busranges[0], busranges[1]); - pci_conf_setfunc(schizo_pci_conf_read, schizo_pci_conf_write); - schizo_init_iommu(sc, pbm); match = bus_space_read_8(sc->sc_bust, sc->sc_ctrlh, @@ -191,6 +189,9 @@ schizo_init(sc, busa) pbm->sp_pc = schizo_alloc_chipset(pbm, sc->sc_node, &_sparc_pci_chipset); + pbm->sp_pc->conf_read = schizo_pci_conf_read; + pbm->sp_pc->conf_write = schizo_pci_conf_write; + pba.pba_busname = "pci"; pba.pba_bus = busranges[0]; pba.pba_pc = pbm->sp_pc; diff --git a/sys/arch/sparc64/include/pci_machdep.h b/sys/arch/sparc64/include/pci_machdep.h index e7178d376a4..40e1177ef00 100644 --- a/sys/arch/sparc64/include/pci_machdep.h +++ b/sys/arch/sparc64/include/pci_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.h,v 1.9 2002/06/09 23:28:21 jason Exp $ */ +/* $OpenBSD: pci_machdep.h,v 1.10 2003/01/13 16:04:38 jason Exp $ */ /* $NetBSD: pci_machdep.h,v 1.7 2001/07/20 00:07:14 eeh Exp $ */ /* @@ -50,12 +50,6 @@ struct pci_attach_args; typedef struct sparc_pci_chipset *pci_chipset_tag_t; typedef u_int pci_intr_handle_t; -struct sparc_pci_chipset { - void *cookie; /* psycho_pbm, but sssh! */ - int rootnode; /* PCI controller */ - int curnode; /* Current OFW node */ -}; - /* * The stuuuuuuupid allegedly MI PCI code expects pcitag_t to be a * scalar type. But we really need to store both the OFW node and @@ -74,6 +68,14 @@ struct sparc_pci_chipset { #define PCITAG_SETNODE(t,n) ((t)&0xffffffff)|(((n)<<32) typedef u_int64_t pcitag_t; +struct sparc_pci_chipset { + void *cookie; /* psycho_pbm, but sssh! */ + pcireg_t (*conf_read)(pci_chipset_tag_t, pcitag_t, int); + void (*conf_write)(pci_chipset_tag_t, pcitag_t, int, pcireg_t); + int rootnode; /* PCI controller */ + int curnode; /* Current OFW node */ + +}; void pci_attach_hook(struct device *, struct device *, struct pcibus_attach_args *); @@ -85,8 +87,6 @@ int pci_dev_funcorder(pci_chipset_tag_t, int, int, char *); #endif int pci_bus_maxdevs(pci_chipset_tag_t, int); pcitag_t pci_make_tag(pci_chipset_tag_t, int, int, int); -void pci_conf_setfunc(pcireg_t (*rd)(pci_chipset_tag_t, pcitag_t, int), - void (*wr)(pci_chipset_tag_t, pcitag_t, int, pcireg_t)); pcireg_t pci_conf_read(pci_chipset_tag_t, pcitag_t, int); void pci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t); |