From 37dec27558a97e62dc2669724f0b5a5c01f68004 Mon Sep 17 00:00:00 2001 From: dfr Date: Wed, 28 Jul 1999 07:57:48 +0000 Subject: Add support for SYS_RES_DENSE and SYS_RES_BWX resource types. These are equivalent to SYS_RES_MEMORY for x86 but for alpha, the rman_get_virtual() address of the resource is initialised to point into either dense-mapped or bwx-mapped space respectively, allowing direct memory pointers to be used to device memory. Reviewed by: Andrew Gallatin --- sys/alpha/include/resource.h | 12 +++++----- sys/alpha/pci/pcibus.c | 30 ++++++++++++++++++++----- sys/amd64/include/resource.h | 10 +++++---- sys/dev/pci/pci.c | 14 +++++++++++- sys/i386/include/resource.h | 10 +++++---- sys/pci/pci.c | 14 +++++++++++- sys/pci/pci_compat.c | 50 ++++++++++++++++++------------------------ sys/powerpc/include/resource.h | 10 +++++---- 8 files changed, 96 insertions(+), 54 deletions(-) diff --git a/sys/alpha/include/resource.h b/sys/alpha/include/resource.h index 4476378..279c8db 100644 --- a/sys/alpha/include/resource.h +++ b/sys/alpha/include/resource.h @@ -1,4 +1,4 @@ -/* $Id$ */ +/* $Id: resource.h,v 1.1 1998/11/17 10:40:33 dfr Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology * @@ -36,9 +36,11 @@ * with support for legacy ISA devices and drivers. */ -#define SYS_RES_IRQ 1 -#define SYS_RES_DRQ 2 -#define SYS_RES_MEMORY 3 -#define SYS_RES_IOPORT 4 +#define SYS_RES_IRQ 1 /* interrupt lines */ +#define SYS_RES_DRQ 2 /* isa dma lines */ +#define SYS_RES_MEMORY 3 /* i/o memory */ +#define SYS_RES_IOPORT 4 /* i/o ports */ +#define SYS_RES_DENSE 5 /* i/o memory in dense space */ +#define SYS_RES_BWX 6 /* i/i memory in bwx space */ #endif /* !_MACHINE_RESOURCE_H_ */ diff --git a/sys/alpha/pci/pcibus.c b/sys/alpha/pci/pcibus.c index f8b3bd8..bcde9ec 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.15 1999/07/01 20:23:01 peter Exp $ + * $Id: pcibus.c,v 1.16 1999/07/01 22:48:30 peter Exp $ * */ @@ -119,7 +119,7 @@ vm_offset_t pci_cvt_to_dense(vm_offset_t sparse) { if(chipset.cvt_to_dense) - return chipset.cvt_to_dense(sparse); + return ALPHA_PHYS_TO_K0SEG(chipset.cvt_to_dense(sparse)); else return NULL; } @@ -128,7 +128,7 @@ vm_offset_t pci_cvt_to_bwx(vm_offset_t sparse) { if(chipset.cvt_to_bwx) - return chipset.cvt_to_bwx(sparse); + return ALPHA_PHYS_TO_K0SEG(chipset.cvt_to_bwx(sparse)); else return NULL; } @@ -207,6 +207,8 @@ pci_alloc_resource(device_t bus, device_t child, int type, int *rid, rm = &port_rman; break; + case SYS_RES_DENSE: + case SYS_RES_BWX: case SYS_RES_MEMORY: rm = &mem_rman; break; @@ -219,13 +221,29 @@ pci_alloc_resource(device_t bus, device_t child, int type, int *rid, if (rv == 0) return 0; - if (type == SYS_RES_MEMORY) { + switch (type) { + case SYS_RES_MEMORY: + rman_set_bustag(rv, ALPHA_BUS_SPACE_MEM); + rman_set_bushandle(rv, rv->r_start); + rman_set_virtual(rv, (void *) rv->r_start); /* maybe NULL? */ + break; + + case SYS_RES_DENSE: + rman_set_bustag(rv, ALPHA_BUS_SPACE_MEM); + rman_set_bushandle(rv, rv->r_start); + rman_set_virtual(rv, pci_cvt_to_dense(rv->r_start)); + break; + + case SYS_RES_BWX: rman_set_bustag(rv, ALPHA_BUS_SPACE_MEM); rman_set_bushandle(rv, rv->r_start); - rman_set_virtual(rv, (void *) rv->r_start); /* XXX */ - } else if (type == SYS_RES_IOPORT) { + rman_set_virtual(rv, pci_cvt_to_bwx(rv->r_start)); + break; + + case SYS_RES_IOPORT: rman_set_bustag(rv, ALPHA_BUS_SPACE_IO); rman_set_bushandle(rv, rv->r_start); + break; } return rv; diff --git a/sys/amd64/include/resource.h b/sys/amd64/include/resource.h index 0307182..adcf0ce 100644 --- a/sys/amd64/include/resource.h +++ b/sys/amd64/include/resource.h @@ -35,9 +35,11 @@ * with support for legacy ISA devices and drivers. */ -#define SYS_RES_IRQ 1 -#define SYS_RES_DRQ 2 -#define SYS_RES_MEMORY 3 -#define SYS_RES_IOPORT 4 +#define SYS_RES_IRQ 1 /* interrupt lines */ +#define SYS_RES_DRQ 2 /* isa dma lines */ +#define SYS_RES_MEMORY 3 /* i/o memory */ +#define SYS_RES_IOPORT 4 /* i/o ports */ +#define SYS_RES_DENSE SYS_RES_MEMORY +#define SYS_RES_BWX SYS_RES_MEMORY #endif /* !_MACHINE_RESOURCE_H_ */ diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index c2091f3..c6184da 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.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.c,v 1.111 1999/07/27 04:28:14 mdodd Exp $ + * $Id: pci.c,v 1.112 1999/07/27 05:08:36 mdodd Exp $ * */ @@ -1333,6 +1333,10 @@ pci_alloc_resource(device_t dev, device_t child, int type, int *rid, case SYS_RES_DRQ: /* passthru for child isa */ break; +#ifdef __alpha__ + case SYS_RES_DENSE: + case SYS_RES_BWX: +#endif case SYS_RES_MEMORY: if (isdefault) { map = pci_mapno(cfg, *rid); @@ -1389,6 +1393,10 @@ pci_release_resource(device_t dev, device_t child, int type, int rid, case SYS_RES_DRQ: /* passthru for child isa */ break; +#ifdef __alpha__ + case SYS_RES_DENSE: + case SYS_RES_BWX: +#endif case SYS_RES_MEMORY: case SYS_RES_IOPORT: /* @@ -1416,6 +1424,10 @@ pci_release_resource(device_t dev, device_t child, int type, int rid, case SYS_RES_DRQ: /* passthru for child isa */ break; +#ifdef __alpha__ + case SYS_RES_DENSE: + case SYS_RES_BWX: +#endif case SYS_RES_MEMORY: case SYS_RES_IOPORT: if (map != -1) diff --git a/sys/i386/include/resource.h b/sys/i386/include/resource.h index 0307182..adcf0ce 100644 --- a/sys/i386/include/resource.h +++ b/sys/i386/include/resource.h @@ -35,9 +35,11 @@ * with support for legacy ISA devices and drivers. */ -#define SYS_RES_IRQ 1 -#define SYS_RES_DRQ 2 -#define SYS_RES_MEMORY 3 -#define SYS_RES_IOPORT 4 +#define SYS_RES_IRQ 1 /* interrupt lines */ +#define SYS_RES_DRQ 2 /* isa dma lines */ +#define SYS_RES_MEMORY 3 /* i/o memory */ +#define SYS_RES_IOPORT 4 /* i/o ports */ +#define SYS_RES_DENSE SYS_RES_MEMORY +#define SYS_RES_BWX SYS_RES_MEMORY #endif /* !_MACHINE_RESOURCE_H_ */ diff --git a/sys/pci/pci.c b/sys/pci/pci.c index c2091f3..c6184da 100644 --- a/sys/pci/pci.c +++ b/sys/pci/pci.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.c,v 1.111 1999/07/27 04:28:14 mdodd Exp $ + * $Id: pci.c,v 1.112 1999/07/27 05:08:36 mdodd Exp $ * */ @@ -1333,6 +1333,10 @@ pci_alloc_resource(device_t dev, device_t child, int type, int *rid, case SYS_RES_DRQ: /* passthru for child isa */ break; +#ifdef __alpha__ + case SYS_RES_DENSE: + case SYS_RES_BWX: +#endif case SYS_RES_MEMORY: if (isdefault) { map = pci_mapno(cfg, *rid); @@ -1389,6 +1393,10 @@ pci_release_resource(device_t dev, device_t child, int type, int rid, case SYS_RES_DRQ: /* passthru for child isa */ break; +#ifdef __alpha__ + case SYS_RES_DENSE: + case SYS_RES_BWX: +#endif case SYS_RES_MEMORY: case SYS_RES_IOPORT: /* @@ -1416,6 +1424,10 @@ pci_release_resource(device_t dev, device_t child, int type, int rid, case SYS_RES_DRQ: /* passthru for child isa */ break; +#ifdef __alpha__ + case SYS_RES_DENSE: + case SYS_RES_BWX: +#endif case SYS_RES_MEMORY: case SYS_RES_IOPORT: if (map != -1) diff --git a/sys/pci/pci_compat.c b/sys/pci/pci_compat.c index 48ba902..db4d56a 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.29 1999/05/31 22:13:36 roger Exp $ + * $Id: pci_compat.c,v 1.30 1999/07/03 20:17:08 peter Exp $ * */ @@ -108,20 +108,16 @@ pci_map_mem(pcici_t cfg, u_long reg, vm_offset_t* va, vm_offset_t* pa) int pci_map_dense(pcici_t cfg, u_long reg, vm_offset_t* va, vm_offset_t* pa) { - if (pci_map_mem(cfg, reg, va, pa)){ -#ifdef __alpha__ - vm_offset_t dense; - - dense = pci_cvt_to_dense(*pa); - if (dense) { - *pa = dense; - *va = ALPHA_PHYS_TO_K0SEG(*pa); - return (1); - } -#endif -#ifdef __i386__ - return(1); -#endif + int rid; + struct resource *res; + + rid = reg; + res = bus_alloc_resource(cfg->dev, SYS_RES_DENSE, &rid, + 0, ~0, 1, RF_ACTIVE); + if (res) { + *pa = rman_get_start(res); + *va = (vm_offset_t) rman_get_virtual(res); + return (1); } return (0); } @@ -129,20 +125,16 @@ pci_map_dense(pcici_t cfg, u_long reg, vm_offset_t* va, vm_offset_t* pa) int pci_map_bwx(pcici_t cfg, u_long reg, vm_offset_t* va, vm_offset_t* pa) { - if (pci_map_mem(cfg, reg, va, pa)){ -#ifdef __alpha__ - vm_offset_t bwx; - - bwx = pci_cvt_to_bwx(*pa); - if (bwx) { - *pa = bwx; - *va = ALPHA_PHYS_TO_K0SEG(*pa); - return (1); - } -#endif -#ifdef __i386__ - return(1); -#endif + int rid; + struct resource *res; + + rid = reg; + res = bus_alloc_resource(cfg->dev, SYS_RES_BWX, &rid, + 0, ~0, 1, RF_ACTIVE); + if (res) { + *pa = rman_get_start(res); + *va = (vm_offset_t) rman_get_virtual(res); + return (1); } return (0); } diff --git a/sys/powerpc/include/resource.h b/sys/powerpc/include/resource.h index 0307182..adcf0ce 100644 --- a/sys/powerpc/include/resource.h +++ b/sys/powerpc/include/resource.h @@ -35,9 +35,11 @@ * with support for legacy ISA devices and drivers. */ -#define SYS_RES_IRQ 1 -#define SYS_RES_DRQ 2 -#define SYS_RES_MEMORY 3 -#define SYS_RES_IOPORT 4 +#define SYS_RES_IRQ 1 /* interrupt lines */ +#define SYS_RES_DRQ 2 /* isa dma lines */ +#define SYS_RES_MEMORY 3 /* i/o memory */ +#define SYS_RES_IOPORT 4 /* i/o ports */ +#define SYS_RES_DENSE SYS_RES_MEMORY +#define SYS_RES_BWX SYS_RES_MEMORY #endif /* !_MACHINE_RESOURCE_H_ */ -- cgit v1.1