Index: bsd/drm/kernel/Makefile.bsd =================================================================== RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Makefile.bsd,v retrieving revision 1.6.22.1 diff -u -r1.6.22.1 Makefile.bsd --- bsd/drm/kernel/Makefile.bsd 30 Mar 2003 04:52:41 -0000 1.6.22.1 +++ bsd/drm/kernel/Makefile.bsd 8 Apr 2003 04:40:40 -0000 @@ -1,6 +1,6 @@ # $FreeBSD$ # i810, i830 & sis are not complete -SUBDIR = mga r128 radeon tdfx # i810 i830 sis gamma +SUBDIR = mach64 mga r128 radeon tdfx # i810 i830 sis gamma .include Index: bsd/drm/kernel/drmP.h =================================================================== RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drmP.h,v retrieving revision 1.11.4.2 diff -u -r1.11.4.2 drmP.h --- bsd/drm/kernel/drmP.h 8 Apr 2003 04:32:04 -0000 1.11.4.2 +++ bsd/drm/kernel/drmP.h 8 Apr 2003 04:40:40 -0000 @@ -731,6 +731,11 @@ extern int DRM(sg_free)(DRM_IOCTL_ARGS); #endif +/* consistent PCI memory functions (drm_pci.h) */ +extern void *DRM(pci_alloc)(drm_device_t *dev, size_t size, + dma_addr_t *busaddr, dma_addr_t maxaddr); +extern void DRM(pci_free)(drm_device_t *dev, size_t size, + void *vaddr, dma_addr_t busaddr); #endif /* __KERNEL__ */ #endif /* _DRM_P_H_ */ Index: bsd/drm/kernel/drm_pci.h =================================================================== RCS file: bsd/drm/kernel/drm_pci.h diff -N bsd/drm/kernel/drm_pci.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ bsd/drm/kernel/drm_pci.h 8 Apr 2003 04:40:40 -0000 @@ -0,0 +1,73 @@ +/** + * \file drm_pci.h + * \brief ioctl's to manage PCI memory + * + * \warning These interfaces aren't stable yet. + * + * \todo Implement the remaining ioctl's for the PCI pools. + * \todo Add support to map these buffers. + * \todo The wrappers here are so thin that they would be better off inlined.. + * + * \author José Fonseca + */ + +/* + * Copyright 2003 José Fonseca. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#define __NO_VERSION__ +#include "drmP.h" + + +/**********************************************************************/ +/** \name PCI memory */ +/*@{*/ + +/** + * \brief Allocate a PCI consistent memory block, for DMA. + */ +void * +DRM(pci_alloc)(drm_device_t *dev, size_t size, dma_addr_t *busaddr, + dma_addr_t maxaddr) +{ + void *vaddr; + + vaddr = contigmalloc(size, DRM(M_DRM), M_WAITOK, 0ul, maxaddr, + PAGE_SIZE, 0); + *busaddr = vtophys(vaddr); + + return vaddr; +} + +/** + * \brief Free a PCI consistent memory block. + */ +void +DRM(pci_free)(drm_device_t *dev, size_t size, void *vaddr, dma_addr_t busaddr) +{ +#if __FreeBSD_version > 500000 + contigfree( vaddr, size, DRM(M_DRM)); /* Not available on 4.x */ +#endif +} + +/*@}*/ Index: linux/drm/kernel/drm_pci.h =================================================================== RCS file: linux/drm/kernel/drm_pci.h diff -N linux/drm/kernel/drm_pci.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux/drm/kernel/drm_pci.h 8 Apr 2003 04:40:40 -0000 @@ -0,0 +1,66 @@ +/** + * \file drm_pci.h + * \brief ioctl's to manage PCI memory + * + * \warning These interfaces aren't stable yet. + * + * \todo Implement the remaining ioctl's for the PCI pools. + * \todo Add support to map these buffers. + * \todo The wrappers here are so thin that they would be better off inlined.. + * + * \author José Fonseca + */ + +/* + * Copyright 2003 José Fonseca. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#define __NO_VERSION__ +#include +#include "drmP.h" + + +/**********************************************************************/ +/** \name PCI memory */ +/*@{*/ + +/** + * \brief Allocate a PCI consistent memory block, for DMA. + */ +void * +DRM(pci_alloc)(drm_device_t *dev, size_t size, dma_addr_t *busaddr, + dma_addr_t maxaddr) +{ + return pci_alloc_consistent( dev->pdev, size, busaddr ); +} + +/** + * \brief Free a PCI consistent memory block. + */ +void +DRM(pci_free)(drm_device_t *dev, size_t size, void *vaddr, dma_addr_t busaddr) +{ + pci_free_consistent( dev->pdev, size, cpuaddr, busaddr ); +} + +/*@}*/ Index: linux/drm/kernel/mach64_drv.c =================================================================== RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Attic/mach64_drv.c,v retrieving revision 1.1.10.3 diff -u -r1.1.10.3 mach64_drv.c --- linux/drm/kernel/mach64_drv.c 16 Feb 2003 21:28:33 -0000 1.1.10.3 +++ linux/drm/kernel/mach64_drv.c 8 Apr 2003 04:40:40 -0000 @@ -46,6 +46,7 @@ #include "drm_ioctl.h" #include "drm_lock.h" #include "drm_memory.h" +#include "drm_pci.h" #include "drm_proc.h" #include "drm_vm.h" #include "drm_stub.h" Index: shared/drm/kernel/mach64_dma.c =================================================================== RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/Attic/mach64_dma.c,v retrieving revision 1.1.2.5 diff -u -r1.1.2.5 mach64_dma.c --- shared/drm/kernel/mach64_dma.c 30 Mar 2003 04:52:48 -0000 1.1.2.5 +++ shared/drm/kernel/mach64_dma.c 8 Apr 2003 04:40:40 -0000 @@ -156,7 +156,8 @@ return mach64_ring_idle( dev_priv ); } -int mach64_do_dma_idle( drm_mach64_private_t *dev_priv ) { +int mach64_do_dma_idle( drm_mach64_private_t *dev_priv ) +{ int ret; /* wait for completion */ @@ -446,7 +447,7 @@ /* FIXME: get a dma buffer from the freelist here */ DRM_DEBUG( "Allocating data memory ...\n" ); - cpu_addr_data = pci_alloc_consistent( dev->pdev, 0x1000, &data_handle ); + cpu_addr_data = DRM(pci_alloc)( dev, 0x1000, &data_handle, 0xfffffffful ); if (!cpu_addr_data || !data_handle) { DRM_INFO( "data-memory allocation failed!\n" ); return DRM_ERR(ENOMEM); @@ -480,7 +481,7 @@ DRM_INFO( "resetting engine ...\n"); mach64_do_engine_reset( dev_priv ); DRM_INFO( "freeing data buffer memory.\n" ); - pci_free_consistent( dev->pdev, 0x1000, + DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle ); return DRM_ERR(EIO); } @@ -523,7 +524,7 @@ DRM_DEBUG( " data[%d] = 0x%08x\n", i, data[i] ); } - DRM_READMEMORYBARRIER(); + DRM_READMEMORYBARRIER(dev_priv->mmio); DRM_DEBUG( "waiting for idle...\n" ); if ( ( i = mach64_do_wait_for_idle( dev_priv ) ) ) { @@ -535,7 +536,7 @@ MACH64_WRITE( MACH64_PAT_REG0, pat_reg0 ); MACH64_WRITE( MACH64_PAT_REG1, pat_reg1 ); DRM_INFO( "freeing data buffer memory.\n" ); - pci_free_consistent( dev->pdev, 0x1000, cpu_addr_data, data_handle ); + DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle ); return i; } DRM_DEBUG( "waiting for idle...done\n" ); @@ -572,7 +573,7 @@ MACH64_WRITE( MACH64_PAT_REG0, pat_reg0 ); MACH64_WRITE( MACH64_PAT_REG1, pat_reg1 ); DRM_INFO( "freeing data buffer memory.\n" ); - pci_free_consistent( dev->pdev, 0x1000, cpu_addr_data, data_handle ); + DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle ); return i; } @@ -600,7 +601,7 @@ MACH64_WRITE( MACH64_PAT_REG1, pat_reg1 ); DRM_DEBUG( "freeing data buffer memory.\n" ); - pci_free_consistent( dev->pdev, 0x1000, cpu_addr_data, data_handle ); + DRM(pci_free)( dev, 0x1000, cpu_addr_data, data_handle ); DRM_DEBUG( "returning ...\n" ); return failed; @@ -725,18 +726,22 @@ } /* check DMA addressing limitations */ + /* FIXME */ + /* DRM_DEBUG( "Setting 32-bit pci dma mask\n" ); if ((ret=pci_set_dma_mask( dev->pdev, 0xffffffff ))) { DRM_ERROR( "Setting 32-bit pci dma mask failed\n" ); mach64_do_cleanup_dma( dev ); return ret; } + */ /* allocate descriptor memory from pci pool */ DRM_DEBUG( "Allocating dma descriptor ring\n" ); dev_priv->ring.size = 0x4000; /* 16KB */ - dev_priv->ring.start = pci_alloc_consistent( dev->pdev, dev_priv->ring.size, - &dev_priv->ring.handle ); + dev_priv->ring.start = DRM(pci_alloc)( dev, dev_priv->ring.size, + &dev_priv->ring.handle, + 0xfffffffful ); if (!dev_priv->ring.start || !dev_priv->ring.handle) { DRM_ERROR( "Allocating dma descriptor ring failed\n"); @@ -960,10 +965,9 @@ drm_mach64_private_t *dev_priv = dev->dev_private; /* Discard the allocations for the descriptor table... */ - if ( (dev->pdev != NULL) && - (dev_priv->ring.start != NULL) && dev_priv->ring.handle ) { + if ( (dev_priv->ring.start != NULL) && dev_priv->ring.handle ) { DRM_DEBUG( "freeing dma descriptor ring\n" ); - pci_free_consistent( dev->pdev, dev_priv->ring.size, + DRM(pci_free)( dev, dev_priv->ring.size, dev_priv->ring.start, dev_priv->ring.handle ); }