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.h

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  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
    5  * All Rights Reserved.
    6  *
    7  * Permission is hereby granted, free of charge, to any person obtaining a
    8  * copy of this software and associated documentation files (the "Software"),
    9  * to deal in the Software without restriction, including without limitation
   10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
   11  * and/or sell copies of the Software, and to permit persons to whom the
   12  * Software is furnished to do so, subject to the following conditions:
   13  *
   14  * The above copyright notice and this permission notice (including the next
   15  * paragraph) shall be included in all copies or substantial portions of the
   16  * Software.
   17  *
   18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
   21  * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
   22  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
   23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   24  * DEALINGS IN THE SOFTWARE.
   25  *
   26  * Authors:
   27  *   Gareth Hughes <gareth@valinux.com>
   28  *
   29  * $FreeBSD$
   30  */
   31 
   32 #include "dev/drm/drmP.h"
   33 
   34 #if PAGE_SIZE == 8192
   35 # define ATI_PCIGART_TABLE_ORDER        2
   36 # define ATI_PCIGART_TABLE_PAGES        (1 << 2)
   37 #elif PAGE_SIZE == 4096
   38 # define ATI_PCIGART_TABLE_ORDER        3
   39 # define ATI_PCIGART_TABLE_PAGES        (1 << 3)
   40 #elif
   41 # error - PAGE_SIZE not 8K or 4K
   42 #endif
   43 
   44 # define ATI_MAX_PCIGART_PAGES          8192    /* 32 MB aperture, 4K pages */
   45 # define ATI_PCIGART_PAGE_SIZE          4096    /* PCI GART page size */
   46 
   47 int DRM(ati_pcigart_init)( drm_device_t *dev,
   48                            unsigned long *addr,
   49                            dma_addr_t *bus_addr)
   50 {
   51         drm_sg_mem_t *entry = dev->sg;
   52         unsigned long address = 0;
   53         unsigned long pages;
   54         u32 *pci_gart=0, page_base, bus_address = 0;
   55         int i, j, ret = 0;
   56 
   57         if ( !entry ) {
   58                 DRM_ERROR( "no scatter/gather memory!\n" );
   59                 goto done;
   60         }
   61 
   62         address = (long)contigmalloc((1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE, 
   63             DRM(M_DRM), M_NOWAIT, 0ul, 0xfffffffful, PAGE_SIZE, 0);
   64         if ( !address ) {
   65                 DRM_ERROR( "cannot allocate PCI GART page!\n" );
   66                 goto done;
   67         }
   68 
   69         /* XXX: we need to busdma this */
   70         bus_address = vtophys( address );
   71 
   72         pci_gart = (u32 *)address;
   73 
   74         pages = ( entry->pages <= ATI_MAX_PCIGART_PAGES )
   75                 ? entry->pages : ATI_MAX_PCIGART_PAGES;
   76 
   77         bzero( pci_gart, ATI_MAX_PCIGART_PAGES * sizeof(u32) );
   78 
   79         for ( i = 0 ; i < pages ; i++ ) {
   80                 entry->busaddr[i] = vtophys( entry->handle + (i*PAGE_SIZE) );
   81                 page_base = (u32) entry->busaddr[i];
   82 
   83                 for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
   84                         *pci_gart++ = cpu_to_le32( page_base );
   85                         page_base += ATI_PCIGART_PAGE_SIZE;
   86                 }
   87         }
   88 
   89         DRM_MEMORYBARRIER();
   90 
   91         ret = 1;
   92 
   93 done:
   94         *addr = address;
   95         *bus_addr = bus_address;
   96         return ret;
   97 }
   98 
   99 int DRM(ati_pcigart_cleanup)( drm_device_t *dev,
  100                               unsigned long addr,
  101                               dma_addr_t bus_addr)
  102 {
  103         drm_sg_mem_t *entry = dev->sg;
  104 
  105         /* we need to support large memory configurations */
  106         if ( !entry ) {
  107                 DRM_ERROR( "no scatter/gather memory!\n" );
  108                 return 0;
  109         }
  110 
  111 #if __FreeBSD_version > 500000
  112         contigfree( (void *)addr, (1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE, DRM(M_DRM));      /* Not available on 4.x */
  113 #endif
  114         return 1;
  115 }

Cache object: 8371eab503f7eb90ae3aaedc6497d5f6


[ 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.