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/drm_vm.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 /*
    2  * $FreeBSD: releng/5.0/sys/dev/drm/drm_vm.h 95693 2002-04-29 00:25:10Z anholt $
    3  */
    4 
    5 #include <vm/vm.h>
    6 #include <vm/pmap.h>
    7 
    8 static int DRM(dma_mmap)(dev_t kdev, vm_offset_t offset, int prot)
    9 {
   10         drm_device_t     *dev    = kdev->si_drv1;
   11         drm_device_dma_t *dma    = dev->dma;
   12         unsigned long    physical;
   13         unsigned long    page;
   14 
   15         if (!dma)                  return -1; /* Error */
   16         if (!dma->pagelist)        return -1; /* Nothing allocated */
   17 
   18         page     = offset >> PAGE_SHIFT;
   19         physical = dma->pagelist[page];
   20 
   21         DRM_DEBUG("0x%08x (page %lu) => 0x%08lx\n", offset, page, physical);
   22         return atop(physical);
   23 }
   24 
   25 int DRM(mmap)(dev_t kdev, vm_offset_t offset, int prot)
   26 {
   27         drm_device_t    *dev    = kdev->si_drv1;
   28         drm_map_t       *map    = NULL;
   29         drm_map_list_entry_t *listentry=NULL;
   30         /*drm_file_t *priv;*/
   31 
   32 /*      DRM_DEBUG("offset = 0x%x\n", offset);*/
   33 
   34         /*XXX Fixme */
   35         /*priv = DRM(find_file_by_proc)(dev, p);
   36         if (!priv) {
   37                 DRM_DEBUG("can't find authenticator\n");
   38                 return EINVAL;
   39         }
   40 
   41         if (!priv->authenticated) return DRM_OS_ERR(EACCES);*/
   42 
   43         if (dev->dma
   44             && offset >= 0
   45             && offset < ptoa(dev->dma->page_count))
   46                 return DRM(dma_mmap)(kdev, offset, prot);
   47 
   48                                 /* A sequential search of a linked list is
   49                                    fine here because: 1) there will only be
   50                                    about 5-10 entries in the list and, 2) a
   51                                    DRI client only has to do this mapping
   52                                    once, so it doesn't have to be optimized
   53                                    for performance, even if the list was a
   54                                    bit longer. */
   55         TAILQ_FOREACH(listentry, dev->maplist, link) {
   56                 map = listentry->map;
   57 /*              DRM_DEBUG("considering 0x%x..0x%x\n", map->offset, map->offset + map->size - 1);*/
   58                 if (offset >= map->offset
   59                     && offset < map->offset + map->size) break;
   60         }
   61         
   62         if (!listentry) {
   63                 DRM_DEBUG("can't find map\n");
   64                 return -1;
   65         }
   66         if (((map->flags&_DRM_RESTRICTED) && suser(DRM_OS_CURPROC))) {
   67                 DRM_DEBUG("restricted map\n");
   68                 return -1;
   69         }
   70 
   71         switch (map->type) {
   72         case _DRM_FRAME_BUFFER:
   73         case _DRM_REGISTERS:
   74         case _DRM_AGP:
   75                 return atop(offset);
   76         case _DRM_SHM:
   77                 return atop(vtophys(offset));
   78         default:
   79                 return -1;      /* This should never happen. */
   80         }
   81         DRM_DEBUG("bailing out\n");
   82         
   83         return -1;
   84 }
   85 

Cache object: b8303656dfbbc2086e9a8cdcb3e05a2a


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