2 *Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
3 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
4 * Copyright (c) 2011 The FreeBSD Foundation
7 * Portions of this software were developed by Konstantin Belousov
8 * under sponsorship from the FreeBSD Foundation.
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice (including the next
18 * paragraph) shall be included in all copies or substantial portions of the
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
30 * Rickard E. (Rik) Faith <faith@valinux.com>
31 * Gareth Hughes <gareth@valinux.com>
35 /** @file drm_memory.c
36 * Wrappers for kernel memory allocation routines, and MTRR management support.
38 * This file previously implemented a memory consumption tracking system using
39 * the "area" argument for various different types of allocations, but that
40 * has been stripped out for now.
45 MALLOC_DEFINE(M_DRM, "m_drm", "DRM memory allocations");
47 void drm_mem_init(void)
51 void drm_mem_uninit(void)
55 void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map)
57 return pmap_mapdev_attr(map->offset, map->size, VM_MEMATTR_WRITE_COMBINING);
60 void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map)
62 return pmap_mapdev(map->offset, map->size);
65 void drm_ioremapfree(drm_local_map_t *map)
67 pmap_unmapdev((vm_offset_t) map->handle, map->size);
71 drm_mtrr_add(unsigned long offset, size_t size, int flags)
74 struct mem_range_desc mrdesc;
76 mrdesc.mr_base = offset;
78 mrdesc.mr_flags = flags;
79 act = MEMRANGE_SET_UPDATE;
80 strlcpy(mrdesc.mr_owner, "drm", sizeof(mrdesc.mr_owner));
81 return mem_range_attr_set(&mrdesc, &act);
85 drm_mtrr_del(int __unused handle, unsigned long offset, size_t size, int flags)
88 struct mem_range_desc mrdesc;
90 mrdesc.mr_base = offset;
92 mrdesc.mr_flags = flags;
93 act = MEMRANGE_SET_REMOVE;
94 strlcpy(mrdesc.mr_owner, "drm", sizeof(mrdesc.mr_owner));
95 return mem_range_attr_set(&mrdesc, &act);
99 drm_clflush_pages(vm_page_t *pages, unsigned long num_pages)
102 pmap_invalidate_cache_pages(pages, num_pages);