2 *Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
3 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
26 * Rickard E. (Rik) Faith <faith@valinux.com>
27 * Gareth Hughes <gareth@valinux.com>
31 /** @file drm_memory.c
32 * Wrappers for kernel memory allocation routines, and MTRR management support.
34 * This file previously implemented a memory consumption tracking system using
35 * the "area" argument for various different types of allocations, but that
36 * has been stripped out for now.
41 MALLOC_DEFINE(DRM_MEM_DMA, "drm_dma", "DRM DMA Data Structures");
42 MALLOC_DEFINE(DRM_MEM_SAREA, "drm_sarea", "DRM SAREA Data Structures");
43 MALLOC_DEFINE(DRM_MEM_DRIVER, "drm_driver", "DRM DRIVER Data Structures");
44 MALLOC_DEFINE(DRM_MEM_MAGIC, "drm_magic", "DRM MAGIC Data Structures");
45 MALLOC_DEFINE(DRM_MEM_IOCTLS, "drm_ioctls", "DRM IOCTL Data Structures");
46 MALLOC_DEFINE(DRM_MEM_MAPS, "drm_maps", "DRM MAP Data Structures");
47 MALLOC_DEFINE(DRM_MEM_BUFS, "drm_bufs", "DRM BUFFER Data Structures");
48 MALLOC_DEFINE(DRM_MEM_SEGS, "drm_segs", "DRM SEGMENTS Data Structures");
49 MALLOC_DEFINE(DRM_MEM_PAGES, "drm_pages", "DRM PAGES Data Structures");
50 MALLOC_DEFINE(DRM_MEM_FILES, "drm_files", "DRM FILE Data Structures");
51 MALLOC_DEFINE(DRM_MEM_QUEUES, "drm_queues", "DRM QUEUE Data Structures");
52 MALLOC_DEFINE(DRM_MEM_CMDS, "drm_cmds", "DRM COMMAND Data Structures");
53 MALLOC_DEFINE(DRM_MEM_MAPPINGS, "drm_mapping", "DRM MAPPING Data Structures");
54 MALLOC_DEFINE(DRM_MEM_BUFLISTS, "drm_buflists", "DRM BUFLISTS Data Structures");
55 MALLOC_DEFINE(DRM_MEM_AGPLISTS, "drm_agplists", "DRM AGPLISTS Data Structures");
56 MALLOC_DEFINE(DRM_MEM_CTXBITMAP, "drm_ctxbitmap",
57 "DRM CTXBITMAP Data Structures");
58 MALLOC_DEFINE(DRM_MEM_SGLISTS, "drm_sglists", "DRM SGLISTS Data Structures");
59 MALLOC_DEFINE(DRM_MEM_DRAWABLE, "drm_drawable", "DRM DRAWABLE Data Structures");
61 void drm_mem_init(void)
65 void drm_mem_uninit(void)
69 void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map)
71 return pmap_mapdev_attr(map->offset, map->size, PAT_WRITE_COMBINING);
74 void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map)
76 return pmap_mapdev(map->offset, map->size);
79 void drm_ioremapfree(drm_local_map_t *map)
81 pmap_unmapdev((vm_offset_t) map->handle, map->size);
85 drm_mtrr_add(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_UPDATE;
94 strlcpy(mrdesc.mr_owner, "drm", sizeof(mrdesc.mr_owner));
95 return mem_range_attr_set(&mrdesc, &act);
99 drm_mtrr_del(int __unused handle, unsigned long offset, size_t size, int flags)
102 struct mem_range_desc mrdesc;
104 mrdesc.mr_base = offset;
105 mrdesc.mr_len = size;
106 mrdesc.mr_flags = flags;
107 act = MEMRANGE_SET_REMOVE;
108 strlcpy(mrdesc.mr_owner, "drm", sizeof(mrdesc.mr_owner));
109 return mem_range_attr_set(&mrdesc, &act);