d0538f66491267879b7418b21ad78e3dcc2dcc83cg * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
60405de4d8688d96dd05157c28db3ade5c9bc234kz * Use is subject to license terms.
60405de4d8688d96dd05157c28db3ade5c9bc234kz/* BEGIN CSTYLED */
60405de4d8688d96dd05157c28db3ade5c9bc234kz * \brief PCI consistent, DMA-accessible memory functions.
60405de4d8688d96dd05157c28db3ade5c9bc234kz * \author Eric Anholt <anholt@FreeBSD.org>
60405de4d8688d96dd05157c28db3ade5c9bc234kz * Copyright 2003 Eric Anholt.
60405de4d8688d96dd05157c28db3ade5c9bc234kz * All Rights Reserved.
60405de4d8688d96dd05157c28db3ade5c9bc234kz * Permission is hereby granted, free of charge, to any person obtaining a
60405de4d8688d96dd05157c28db3ade5c9bc234kz * copy of this software and associated documentation files (the "Software"),
60405de4d8688d96dd05157c28db3ade5c9bc234kz * to deal in the Software without restriction, including without limitation
60405de4d8688d96dd05157c28db3ade5c9bc234kz * the rights to use, copy, modify, merge, publish, distribute, sublicense,
60405de4d8688d96dd05157c28db3ade5c9bc234kz * and/or sell copies of the Software, and to permit persons to whom the
60405de4d8688d96dd05157c28db3ade5c9bc234kz * Software is furnished to do so, subject to the following conditions:
60405de4d8688d96dd05157c28db3ade5c9bc234kz * The above copyright notice and this permission notice (including the next
60405de4d8688d96dd05157c28db3ade5c9bc234kz * paragraph) shall be included in all copies or substantial portions of the
60405de4d8688d96dd05157c28db3ade5c9bc234kz * Software.
60405de4d8688d96dd05157c28db3ade5c9bc234kz * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
60405de4d8688d96dd05157c28db3ade5c9bc234kz * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60405de4d8688d96dd05157c28db3ade5c9bc234kz * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
60405de4d8688d96dd05157c28db3ade5c9bc234kz * AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
60405de4d8688d96dd05157c28db3ade5c9bc234kz * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
60405de4d8688d96dd05157c28db3ade5c9bc234kz * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
60405de4d8688d96dd05157c28db3ade5c9bc234kz/**********************************************************************/
60405de4d8688d96dd05157c28db3ade5c9bc234kz/** \name PCI memory */
60405de4d8688d96dd05157c28db3ade5c9bc234kz/* END CSTYLED */
60405de4d8688d96dd05157c28db3ade5c9bc234kz#pragma ident "%Z%%M% %I% %E% SMI"
d0538f66491267879b7418b21ad78e3dcc2dcc83cgpci_get_info(drm_device_t *softstate, int *bus, int *slot, int *func)
60405de4d8688d96dd05157c28db3ade5c9bc234kz if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, softstate->dip,
60405de4d8688d96dd05157c28db3ade5c9bc234kz DRM_ERROR("pci_get_info: get pci function bus device failed");
60405de4d8688d96dd05157c28db3ade5c9bc234kz if (nregs > 0) {
60405de4d8688d96dd05157c28db3ade5c9bc234kz if (nregs > 0) {
d0538f66491267879b7418b21ad78e3dcc2dcc83cg extern int drm_supp_get_irq(void *);
d0538f66491267879b7418b21ad78e3dcc2dcc83cg if (irq > 0) {
d0538f66491267879b7418b21ad78e3dcc2dcc83cgdrm_core_ioremap(struct drm_local_map *map, drm_device_t *dev)
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * During AGP mapping initialization, we map AGP aperture
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * into kernel space. So, when we access the memory which
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * managed by agp gart in kernel space, we have to go
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * through two-level address translation: kernel virtual
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * address --> aperture address --> physical address. For
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * improving this, here in opensourced code, agp_remap()
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * gets invoking to dispose the mapping between agp aperture
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * and kernel space, and directly map the actual physical
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * memory which is allocated to agp gart to kernel space.
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * After that, access to physical memory managed by agp gart
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * hardware in kernel space doesn't go through agp hardware,
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * it will be: kernel virtual ---> physical address.
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * Obviously, it is more efficient. But in solaris operating
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * system, the ioctl AGPIOC_ALLOCATE of apggart driver does
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * not return physical address. We are unable to create the
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * direct mapping between kernel space and agp memory. So,
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * we remove the calling to agp_remap().
d0538f66491267879b7418b21ad78e3dcc2dcc83cg/*ARGSUSED*/
d0538f66491267879b7418b21ad78e3dcc2dcc83cgdrm_core_ioremapfree(struct drm_local_map *map, drm_device_t *dev)
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * Refer to the comments in drm_core_ioremap() where we removed
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * the calling to agp_remap(), correspondingly, we remove the
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * calling to agp_remap_free(dev, map);
d0538f66491267879b7418b21ad78e3dcc2dcc83cg DRM_DEBUG("drm_core_ioremap: skipping agp_remap_free\n");
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * For the time being, we compare the low 32 bit only,
d0538f66491267879b7418b21ad78e3dcc2dcc83cg * We will hash handle to 32-bit to solve this issue later.
60405de4d8688d96dd05157c28db3ade5c9bc234kz * pci_alloc_consistent()
d0538f66491267879b7418b21ad78e3dcc2dcc83cg 0, /* addr_lo */
d0538f66491267879b7418b21ad78e3dcc2dcc83cg 0 /* flags */
60405de4d8688d96dd05157c28db3ade5c9bc234kz /* allocat continous physical memory for hw status page */
60405de4d8688d96dd05157c28db3ade5c9bc234kz DRM_ERROR("drm_pci_alloc:ddi_dma_alloc_handle failed\n");
d0538f66491267879b7418b21ad78e3dcc2dcc83cg if (ret = ddi_dma_mem_alloc(dmah->dma_hdl, size, &hw_acc_attr,
60405de4d8688d96dd05157c28db3ade5c9bc234kz * pci_free_consistent()
60405de4d8688d96dd05157c28db3ade5c9bc234kz/*ARGSUSED*/
d0538f66491267879b7418b21ad78e3dcc2dcc83cgdo_get_pci_res(drm_device_t *dev, drm_pci_resource_t *resp)
d0538f66491267879b7418b21ad78e3dcc2dcc83cg return (0);
60405de4d8688d96dd05157c28db3ade5c9bc234kz/*ARGSUSED*/
60405de4d8688d96dd05157c28db3ade5c9bc234kzunsigned long
d0538f66491267879b7418b21ad78e3dcc2dcc83cgdrm_get_resource_start(drm_device_t *softstate, unsigned int regnum)
d0538f66491267879b7418b21ad78e3dcc2dcc83cg if (ret != 0) {
60405de4d8688d96dd05157c28db3ade5c9bc234kz return (0);
60405de4d8688d96dd05157c28db3ade5c9bc234kz/*ARGSUSED*/
60405de4d8688d96dd05157c28db3ade5c9bc234kzunsigned long
d0538f66491267879b7418b21ad78e3dcc2dcc83cgdrm_get_resource_len(drm_device_t *softstate, unsigned int regnum)
d0538f66491267879b7418b21ad78e3dcc2dcc83cg if (ret != 0) {
60405de4d8688d96dd05157c28db3ade5c9bc234kz return (0);