The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/drm/ati_pcigart.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* ati_pcigart.h -- ATI PCI GART support -*- linux-c -*-
    2  * Created: Wed Dec 13 21:52:19 2000 by gareth@valinux.com
    3  */
    4 /*-
    5  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
    6  * All Rights Reserved.
    7  *
    8  * Permission is hereby granted, free of charge, to any person obtaining a
    9  * copy of this software and associated documentation files (the "Software"),
   10  * to deal in the Software without restriction, including without limitation
   11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
   12  * and/or sell copies of the Software, and to permit persons to whom the
   13  * Software is furnished to do so, subject to the following conditions:
   14  *
   15  * The above copyright notice and this permission notice (including the next
   16  * paragraph) shall be included in all copies or substantial portions of the
   17  * Software.
   18  *
   19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
   22  * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
   23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
   24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   25  * DEALINGS IN THE SOFTWARE.
   26  *
   27  * Authors:
   28  *   Gareth Hughes <gareth@valinux.com>
   29  *
   30  */
   31 
   32 #include <sys/cdefs.h>
   33 __FBSDID("$FreeBSD: releng/6.4/sys/dev/drm/ati_pcigart.c 153401 2005-12-14 00:52:59Z anholt $");
   34 
   35 #include "dev/drm/drmP.h"
   36 
   37 #define ATI_PCIGART_PAGE_SIZE           4096    /* PCI GART page size */
   38 #define ATI_MAX_PCIGART_PAGES           8192    /* 32 MB aperture, 4K pages */
   39 #define ATI_PCIGART_TABLE_SIZE          32768
   40 
   41 int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
   42 {
   43         unsigned long pages;
   44         u32 *pci_gart = NULL, page_base;
   45         int i, j;
   46 
   47         if (dev->sg == NULL) {
   48                 DRM_ERROR( "no scatter/gather memory!\n" );
   49                 return 0;
   50         }
   51 
   52         if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
   53                 /* GART table in system memory */
   54                 dev->sg->dmah = drm_pci_alloc(dev, ATI_PCIGART_TABLE_SIZE, 0,
   55                     0xfffffffful);
   56                 if (dev->sg->dmah == NULL) {
   57                         DRM_ERROR("cannot allocate PCI GART table!\n");
   58                         return 0;
   59                 }
   60         
   61                 gart_info->addr = (void *)dev->sg->dmah->vaddr;
   62                 gart_info->bus_addr = dev->sg->dmah->busaddr;
   63                 pci_gart = (u32 *)dev->sg->dmah->vaddr;
   64         } else {
   65                 /* GART table in framebuffer memory */
   66                 pci_gart = gart_info->addr;
   67         }
   68         
   69         pages = DRM_MIN(dev->sg->pages, ATI_MAX_PCIGART_PAGES);
   70 
   71         bzero(pci_gart, ATI_PCIGART_TABLE_SIZE);
   72 
   73         KASSERT(PAGE_SIZE >= ATI_PCIGART_PAGE_SIZE, ("page size too small"));
   74 
   75         for ( i = 0 ; i < pages ; i++ ) {
   76                 page_base = (u32) dev->sg->busaddr[i];
   77 
   78                 for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
   79                         if (gart_info->is_pcie)
   80                                 *pci_gart = (cpu_to_le32(page_base) >> 8) | 0xc;
   81                         else
   82                                 *pci_gart = cpu_to_le32(page_base);
   83                         pci_gart++;
   84                         page_base += ATI_PCIGART_PAGE_SIZE;
   85                 }
   86         }
   87 
   88         DRM_MEMORYBARRIER();
   89 
   90         return 1;
   91 }
   92 
   93 int drm_ati_pcigart_cleanup(drm_device_t *dev, drm_ati_pcigart_info *gart_info)
   94 {
   95         if (dev->sg == NULL) {
   96                 DRM_ERROR( "no scatter/gather memory!\n" );
   97                 return 0;
   98         }
   99 
  100         drm_pci_free(dev, dev->sg->dmah);
  101 
  102         return 1;
  103 }

Cache object: a560a26c7cc6dd90d9119f228f913724


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.