1/* 2 * Copyright © 2015 Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24#include <sys/mman.h> 25#include <sys/syscall.h> 26 27#include "util/anon_file.h" 28#include "anv_private.h" 29 30uint32_t 31anv_gem_create(struct anv_device *device, uint64_t size) 32{ 33 int fd = os_create_anonymous_file(size, "fake bo"); 34 if (fd == -1) 35 return 0; 36 37 assert(fd != 0); 38 39 return fd; 40} 41 42void 43anv_gem_close(struct anv_device *device, uint32_t gem_handle) 44{ 45 close(gem_handle); 46} 47 48uint32_t 49anv_gem_create_regions(struct anv_device *device, uint64_t anv_bo_size, 50 uint32_t flags, uint32_t num_regions, 51 struct drm_i915_gem_memory_class_instance *regions) 52{ 53 return 0; 54} 55 56void* 57anv_gem_mmap(struct anv_device *device, uint32_t gem_handle, 58 uint64_t offset, uint64_t size, uint32_t flags) 59{ 60 /* Ignore flags, as they're specific to I915_GEM_MMAP. */ 61 (void) flags; 62 63 return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, 64 gem_handle, offset); 65} 66 67/* This is just a wrapper around munmap, but it also notifies valgrind that 68 * this map is no longer valid. Pair this with anv_gem_mmap(). 69 */ 70void 71anv_gem_munmap(struct anv_device *device, void *p, uint64_t size) 72{ 73 munmap(p, size); 74} 75 76uint32_t 77anv_gem_userptr(struct anv_device *device, void *mem, size_t size) 78{ 79 int fd = os_create_anonymous_file(size, "fake bo"); 80 if (fd == -1) 81 return 0; 82 83 assert(fd != 0); 84 85 return fd; 86} 87 88int 89anv_gem_busy(struct anv_device *device, uint32_t gem_handle) 90{ 91 return 0; 92} 93 94int 95anv_gem_wait(struct anv_device *device, uint32_t gem_handle, int64_t *timeout_ns) 96{ 97 return 0; 98} 99 100int 101anv_gem_execbuffer(struct anv_device *device, 102 struct drm_i915_gem_execbuffer2 *execbuf) 103{ 104 return 0; 105} 106 107int 108anv_gem_set_tiling(struct anv_device *device, 109 uint32_t gem_handle, uint32_t stride, uint32_t tiling) 110{ 111 return 0; 112} 113 114int 115anv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle) 116{ 117 return 0; 118} 119 120int 121anv_gem_set_caching(struct anv_device *device, uint32_t gem_handle, 122 uint32_t caching) 123{ 124 return 0; 125} 126 127int 128anv_gem_set_domain(struct anv_device *device, uint32_t gem_handle, 129 uint32_t read_domains, uint32_t write_domain) 130{ 131 return 0; 132} 133 134int 135anv_gem_get_param(int fd, uint32_t param) 136{ 137 unreachable("Unused"); 138} 139 140int 141anv_gem_create_context(struct anv_device *device) 142{ 143 unreachable("Unused"); 144} 145 146int 147anv_gem_destroy_context(struct anv_device *device, int context) 148{ 149 unreachable("Unused"); 150} 151 152int 153anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value) 154{ 155 unreachable("Unused"); 156} 157 158bool 159anv_gem_has_context_priority(int fd, int priority) 160{ 161 unreachable("Unused"); 162} 163 164int 165anv_gem_context_get_reset_stats(int fd, int context, 166 uint32_t *active, uint32_t *pending) 167{ 168 unreachable("Unused"); 169} 170 171int 172anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle) 173{ 174 unreachable("Unused"); 175} 176 177uint32_t 178anv_gem_fd_to_handle(struct anv_device *device, int fd) 179{ 180 unreachable("Unused"); 181} 182 183int 184anv_i915_query(int fd, uint64_t query_id, void *buffer, 185 int32_t *buffer_len) 186{ 187 unreachable("Unused"); 188} 189 190struct drm_i915_query_engine_info * 191anv_gem_get_engine_info(int fd) 192{ 193 unreachable("Unused"); 194} 195 196int 197anv_gem_reg_read(int fd, uint32_t offset, uint64_t *result) 198{ 199 unreachable("Unused"); 200} 201