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
30 uint32_t
anv_gem_create(struct anv_device * device,uint64_t size)31 anv_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
42 void
anv_gem_close(struct anv_device * device,uint32_t gem_handle)43 anv_gem_close(struct anv_device *device, uint32_t gem_handle)
44 {
45 close(gem_handle);
46 }
47
48 uint32_t
anv_gem_create_regions(struct anv_device * device,uint64_t anv_bo_size,uint32_t flags,uint32_t num_regions,struct drm_i915_gem_memory_class_instance * regions)49 anv_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
56 void*
anv_gem_mmap(struct anv_device * device,uint32_t gem_handle,uint64_t offset,uint64_t size,uint32_t flags)57 anv_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 */
70 void
anv_gem_munmap(struct anv_device * device,void * p,uint64_t size)71 anv_gem_munmap(struct anv_device *device, void *p, uint64_t size)
72 {
73 munmap(p, size);
74 }
75
76 uint32_t
anv_gem_userptr(struct anv_device * device,void * mem,size_t size)77 anv_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
88 int
anv_gem_busy(struct anv_device * device,uint32_t gem_handle)89 anv_gem_busy(struct anv_device *device, uint32_t gem_handle)
90 {
91 return 0;
92 }
93
94 int
anv_gem_wait(struct anv_device * device,uint32_t gem_handle,int64_t * timeout_ns)95 anv_gem_wait(struct anv_device *device, uint32_t gem_handle, int64_t *timeout_ns)
96 {
97 return 0;
98 }
99
100 int
anv_gem_execbuffer(struct anv_device * device,struct drm_i915_gem_execbuffer2 * execbuf)101 anv_gem_execbuffer(struct anv_device *device,
102 struct drm_i915_gem_execbuffer2 *execbuf)
103 {
104 return 0;
105 }
106
107 int
anv_gem_set_tiling(struct anv_device * device,uint32_t gem_handle,uint32_t stride,uint32_t tiling)108 anv_gem_set_tiling(struct anv_device *device,
109 uint32_t gem_handle, uint32_t stride, uint32_t tiling)
110 {
111 return 0;
112 }
113
114 int
anv_gem_get_tiling(struct anv_device * device,uint32_t gem_handle)115 anv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle)
116 {
117 return 0;
118 }
119
120 int
anv_gem_set_caching(struct anv_device * device,uint32_t gem_handle,uint32_t caching)121 anv_gem_set_caching(struct anv_device *device, uint32_t gem_handle,
122 uint32_t caching)
123 {
124 return 0;
125 }
126
127 int
anv_gem_set_domain(struct anv_device * device,uint32_t gem_handle,uint32_t read_domains,uint32_t write_domain)128 anv_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
134 int
anv_gem_get_param(int fd,uint32_t param)135 anv_gem_get_param(int fd, uint32_t param)
136 {
137 unreachable("Unused");
138 }
139
140 int
anv_gem_create_context(struct anv_device * device)141 anv_gem_create_context(struct anv_device *device)
142 {
143 unreachable("Unused");
144 }
145
146 int
anv_gem_destroy_context(struct anv_device * device,int context)147 anv_gem_destroy_context(struct anv_device *device, int context)
148 {
149 unreachable("Unused");
150 }
151
152 int
anv_gem_set_context_param(int fd,int context,uint32_t param,uint64_t value)153 anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value)
154 {
155 unreachable("Unused");
156 }
157
158 bool
anv_gem_has_context_priority(int fd,int priority)159 anv_gem_has_context_priority(int fd, int priority)
160 {
161 unreachable("Unused");
162 }
163
164 int
anv_gem_context_get_reset_stats(int fd,int context,uint32_t * active,uint32_t * pending)165 anv_gem_context_get_reset_stats(int fd, int context,
166 uint32_t *active, uint32_t *pending)
167 {
168 unreachable("Unused");
169 }
170
171 int
anv_gem_handle_to_fd(struct anv_device * device,uint32_t gem_handle)172 anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle)
173 {
174 unreachable("Unused");
175 }
176
177 uint32_t
anv_gem_fd_to_handle(struct anv_device * device,int fd)178 anv_gem_fd_to_handle(struct anv_device *device, int fd)
179 {
180 unreachable("Unused");
181 }
182
183 int
anv_i915_query(int fd,uint64_t query_id,void * buffer,int32_t * buffer_len)184 anv_i915_query(int fd, uint64_t query_id, void *buffer,
185 int32_t *buffer_len)
186 {
187 unreachable("Unused");
188 }
189
190 struct drm_i915_query_engine_info *
anv_gem_get_engine_info(int fd)191 anv_gem_get_engine_info(int fd)
192 {
193 unreachable("Unused");
194 }
195
196 int
anv_gem_reg_read(int fd,uint32_t offset,uint64_t * result)197 anv_gem_reg_read(int fd, uint32_t offset, uint64_t *result)
198 {
199 unreachable("Unused");
200 }
201