diff options
author | dfr <dfr@FreeBSD.org> | 1998-10-06 14:18:40 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 1998-10-06 14:18:40 +0000 |
commit | 685a5b889f6d81b2b242340f505aceacc862b28e (patch) | |
tree | b7a83790377c30fcb1ccae004877f46dc78bea77 | |
parent | 5c811970f93597f910f75c2df6a06a262c02984f (diff) | |
download | FreeBSD-src-685a5b889f6d81b2b242340f505aceacc862b28e.zip FreeBSD-src-685a5b889f6d81b2b242340f505aceacc862b28e.tar.gz |
Add functions for accessing dense and bwx memory for pci devices. These
routines are necessary to allow the use of certain types of hardware on
the alpha, particularly a Myrinet card.
Submitted by: Andrew Gallatin <gallatin@cs.duke.edu>
-rw-r--r-- | sys/alpha/include/chipset.h | 9 | ||||
-rw-r--r-- | sys/alpha/pci/apecs.c | 15 | ||||
-rw-r--r-- | sys/alpha/pci/cia.c | 24 | ||||
-rw-r--r-- | sys/alpha/pci/lca.c | 13 | ||||
-rw-r--r-- | sys/alpha/pci/pcibus.c | 20 | ||||
-rw-r--r-- | sys/dev/pci/pcivar.h | 9 | ||||
-rw-r--r-- | sys/pci/pci_compat.c | 45 | ||||
-rw-r--r-- | sys/pci/pcivar.h | 9 |
8 files changed, 134 insertions, 10 deletions
diff --git a/sys/alpha/include/chipset.h b/sys/alpha/include/chipset.h index 5e2922e..74698c5 100644 --- a/sys/alpha/include/chipset.h +++ b/sys/alpha/include/chipset.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: chipset.h,v 1.3 1998/07/22 08:25:39 dfr Exp $ + * $Id: chipset.h,v 1.4 1998/08/10 07:53:58 dfr Exp $ */ #ifndef _MACHINE_CHIPSET_H_ @@ -53,6 +53,7 @@ typedef void alpha_chipset_cfgwritew_t(u_int, u_int, u_int, u_int, u_int16_t); typedef void alpha_chipset_cfgwritel_t(u_int, u_int, u_int, u_int, u_int32_t); +typedef vm_offset_t alpha_chipset_addrcvt_t(vm_offset_t); typedef struct alpha_chipset { @@ -88,6 +89,12 @@ typedef struct alpha_chipset { alpha_chipset_cfgwritel_t* cfgwritel; /* + * PCI address space translation functions + */ + alpha_chipset_addrcvt_t* cvt_to_dense; + alpha_chipset_addrcvt_t* cvt_to_bwx; + + /* * PCI interrupt device. * (XXX hack until I change pci code to use new * device framework.) diff --git a/sys/alpha/pci/apecs.c b/sys/alpha/pci/apecs.c index 4043fd3..4334102 100644 --- a/sys/alpha/pci/apecs.c +++ b/sys/alpha/pci/apecs.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: cia.c,v 1.3 1998/07/22 08:32:17 dfr Exp $ + * $Id: apecs.c,v 1.1 1998/08/10 07:53:59 dfr Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -102,6 +102,7 @@ static alpha_chipset_cfgreadl_t apecs_swiz_cfgreadl; static alpha_chipset_cfgwriteb_t apecs_swiz_cfgwriteb; static alpha_chipset_cfgwritew_t apecs_swiz_cfgwritew; static alpha_chipset_cfgwritel_t apecs_swiz_cfgwritel; +static alpha_chipset_addrcvt_t apecs_cvt_dense; static alpha_chipset_t apecs_swiz_chipset = { apecs_swiz_inb, @@ -123,6 +124,8 @@ static alpha_chipset_t apecs_swiz_chipset = { apecs_swiz_cfgwriteb, apecs_swiz_cfgwritew, apecs_swiz_cfgwritel, + apecs_cvt_dense, + NULL, }; static int @@ -407,6 +410,16 @@ apecs_swiz_cfgwritel(u_int b, u_int s, u_int f, u_int r, u_int32_t data) } #endif + +static vm_offset_t +apecs_cvt_dense(vm_offset_t addr) +{ + addr &= 0xffffffffUL; + return (addr | APECS_PCI_DENSE); + +} + + static int apecs_probe(device_t dev); static int apecs_attach(device_t dev); static void *apecs_create_intr(device_t dev, device_t child, int irq, driver_intr_t *intr, void *arg); diff --git a/sys/alpha/pci/cia.c b/sys/alpha/pci/cia.c index e9587b4..065c420 100644 --- a/sys/alpha/pci/cia.c +++ b/sys/alpha/pci/cia.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: cia.c,v 1.8 1998/08/13 08:11:27 dfr Exp $ + * $Id: cia.c,v 1.9 1998/09/16 08:24:30 dfr Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -137,6 +137,7 @@ static alpha_chipset_cfgreadl_t cia_bwx_cfgreadl, cia_swiz_cfgreadl; static alpha_chipset_cfgwriteb_t cia_bwx_cfgwriteb, cia_swiz_cfgwriteb; static alpha_chipset_cfgwritew_t cia_bwx_cfgwritew, cia_swiz_cfgwritew; static alpha_chipset_cfgwritel_t cia_bwx_cfgwritel, cia_swiz_cfgwritel; +static alpha_chipset_addrcvt_t cia_cvt_dense, cia_cvt_bwx; static alpha_chipset_t cia_bwx_chipset = { cia_bwx_inb, @@ -158,6 +159,8 @@ static alpha_chipset_t cia_bwx_chipset = { cia_bwx_cfgwriteb, cia_bwx_cfgwritew, cia_bwx_cfgwritel, + cia_cvt_dense, + cia_cvt_bwx, }; static alpha_chipset_t cia_swiz_chipset = { cia_swiz_inb, @@ -179,6 +182,8 @@ static alpha_chipset_t cia_swiz_chipset = { cia_swiz_cfgwriteb, cia_swiz_cfgwritew, cia_swiz_cfgwritel, + cia_cvt_dense, + NULL, }; static u_int8_t @@ -596,6 +601,23 @@ cia_swiz_cfgwritel(u_int b, u_int s, u_int f, u_int r, u_int32_t data) SWIZ_CFGWRITE(b, s, f, r, data, LONG, u_int32_t); } +vm_offset_t +cia_cvt_dense(vm_offset_t addr) +{ + addr &= 0xffffffffUL; + return (addr | CIA_PCI_DENSE); + +} + +vm_offset_t +cia_cvt_bwx(vm_offset_t addr) +{ + addr &= 0xffffffffUL; + return (addr |= CIA_EV56_BWMEM); +} + + + static int cia_probe(device_t dev); static int cia_attach(device_t dev); static void *cia_create_intr(device_t dev, device_t child, int irq, driver_intr_t *intr, void *arg); diff --git a/sys/alpha/pci/lca.c b/sys/alpha/pci/lca.c index 75b5ffc..58f873f 100644 --- a/sys/alpha/pci/lca.c +++ b/sys/alpha/pci/lca.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: lca.c,v 1.1 1998/08/10 07:53:59 dfr Exp $ + * $Id: lca.c,v 1.2 1998/09/23 21:23:51 msmith Exp $ */ #include <sys/param.h> @@ -69,6 +69,7 @@ static alpha_chipset_cfgreadl_t lca_cfgreadl; static alpha_chipset_cfgwriteb_t lca_cfgwriteb; static alpha_chipset_cfgwritew_t lca_cfgwritew; static alpha_chipset_cfgwritel_t lca_cfgwritel; +static alpha_chipset_addrcvt_t lca_cvt_dense; static alpha_chipset_t lca_chipset = { lca_inb, @@ -90,6 +91,7 @@ static alpha_chipset_t lca_chipset = { lca_cfgwriteb, lca_cfgwritew, lca_cfgwritel, + lca_cvt_dense, }; static u_int8_t @@ -302,6 +304,15 @@ lca_cfgwritel(u_int b, u_int s, u_int f, u_int r, u_int32_t data) CFGWRITE(b, s, f, r, data, LONG, u_int16_t); } +static vm_offset_t +lca_cvt_dense(vm_offset_t addr) +{ + addr &= 0xffffffffUL; + return (addr | LCA_PCI_DENSE); + +} + + static int lca_probe(device_t dev); static int lca_attach(device_t dev); static void *lca_create_intr(device_t dev, device_t child, int irq, driver_intr_t *intr, void *arg); diff --git a/sys/alpha/pci/pcibus.c b/sys/alpha/pci/pcibus.c index a350772..0cafff2 100644 --- a/sys/alpha/pci/pcibus.c +++ b/sys/alpha/pci/pcibus.c @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: pcibus.c,v 1.3 1998/07/22 08:33:30 dfr Exp $ + * $Id: pcibus.c,v 1.4 1998/08/10 07:53:59 dfr Exp $ * */ @@ -90,6 +90,24 @@ pci_cfgopen(void) return 1; } +vm_offset_t +pci_cvt_to_dense(vm_offset_t sparse) +{ + if(chipset.cvt_to_dense) + return chipset.cvt_to_dense(sparse); + else + return NULL; +} + +vm_offset_t +pci_cvt_to_bwx(vm_offset_t sparse) +{ + if(chipset.cvt_to_bwx) + return chipset.cvt_to_bwx(sparse); + else + return NULL; +} + /* * These can disappear when I update the pci code to use the new * device framework. diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index f18b2b9..13e9991 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: pcivar.h,v 1.20 1998/08/13 19:12:20 gibbs Exp $ + * $Id: pcivar.h,v 1.21 1998/09/15 08:21:09 gibbs Exp $ * */ @@ -178,7 +178,10 @@ void pci_drvattach(struct pci_devinfo *dinfo); int pci_cfgopen (void); int pci_cfgread (pcicfgregs *cfg, int reg, int bytes); void pci_cfgwrite (pcicfgregs *cfg, int reg, int data, int bytes); - +#ifdef __alpha__ +vm_offset_t pci_cvt_to_dense (vm_offset_t); +vm_offset_t pci_cvt_to_bwx (vm_offset_t); +#endif /* __alpha__ */ /* for compatibility to FreeBSD-2.2 version of PCI code */ #ifdef PCI_COMPAT @@ -218,6 +221,8 @@ void pci_conf_write (pcici_t tag, u_long reg, u_long data); void pci_configure (void); int pci_map_port (pcici_t tag, u_long reg, pci_port_t* pa); int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa); +int pci_map_dense (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa); +int pci_map_bwx (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa); int pci_map_int (pcici_t tag, pci_inthand_t *func, void *arg, unsigned *maskptr); int pci_unmap_int (pcici_t tag); int pci_register_lkm (struct pci_device *dvp, int if_revision); diff --git a/sys/pci/pci_compat.c b/sys/pci/pci_compat.c index ebec37a..c082318 100644 --- a/sys/pci/pci_compat.c +++ b/sys/pci/pci_compat.c @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: pci_compat.c,v 1.10 1998/09/06 22:41:42 tegge Exp $ + * $Id: pci_compat.c,v 1.11 1998/09/15 08:21:09 gibbs Exp $ * */ @@ -165,6 +165,49 @@ int pci_map_mem(pcici_t cfg, u_long reg, vm_offset_t* va, vm_offset_t* pa) return (0); } +int +pci_map_dense(pcici_t cfg, u_long reg, vm_offset_t* va, vm_offset_t* pa) +{ + vm_offset_t dense; + int retval = 0; + + if(pci_map_mem(cfg, reg, va, pa)){ +#ifdef __alpha__ + if(dense = pci_cvt_to_dense(*pa)){ + *pa = dense; + *va = ALPHA_PHYS_TO_K0SEG(*pa); + return (1); + } +#endif +#ifdef __i386__ + return(1); +#endif + } + return (0); +} + +int +pci_map_bwx(pcici_t cfg, u_long reg, vm_offset_t* va, vm_offset_t* pa) +{ + vm_offset_t bwx; + int retval = 0; + + if(pci_map_mem(cfg, reg, va, pa)){ +#ifdef __alpha__ + if(bwx = pci_cvt_to_bwx(*pa)){ + *pa = bwx; + *va = ALPHA_PHYS_TO_K0SEG(*pa); + return (1); + } +#endif +#ifdef __i386__ + return(1); +#endif + } + return (0); +} + + int pci_map_int(pcici_t cfg, pci_inthand_t *func, void *arg, unsigned *maskptr) { diff --git a/sys/pci/pcivar.h b/sys/pci/pcivar.h index f18b2b9..13e9991 100644 --- a/sys/pci/pcivar.h +++ b/sys/pci/pcivar.h @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: pcivar.h,v 1.20 1998/08/13 19:12:20 gibbs Exp $ + * $Id: pcivar.h,v 1.21 1998/09/15 08:21:09 gibbs Exp $ * */ @@ -178,7 +178,10 @@ void pci_drvattach(struct pci_devinfo *dinfo); int pci_cfgopen (void); int pci_cfgread (pcicfgregs *cfg, int reg, int bytes); void pci_cfgwrite (pcicfgregs *cfg, int reg, int data, int bytes); - +#ifdef __alpha__ +vm_offset_t pci_cvt_to_dense (vm_offset_t); +vm_offset_t pci_cvt_to_bwx (vm_offset_t); +#endif /* __alpha__ */ /* for compatibility to FreeBSD-2.2 version of PCI code */ #ifdef PCI_COMPAT @@ -218,6 +221,8 @@ void pci_conf_write (pcici_t tag, u_long reg, u_long data); void pci_configure (void); int pci_map_port (pcici_t tag, u_long reg, pci_port_t* pa); int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa); +int pci_map_dense (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa); +int pci_map_bwx (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa); int pci_map_int (pcici_t tag, pci_inthand_t *func, void *arg, unsigned *maskptr); int pci_unmap_int (pcici_t tag); int pci_register_lkm (struct pci_device *dvp, int if_revision); |