• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 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 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 uint64_t
anv_gem_get_drm_cap(int fd,uint32_t capability)141 anv_gem_get_drm_cap(int fd, uint32_t capability)
142 {
143    return 0;
144 }
145 
146 bool
anv_gem_get_bit6_swizzle(int fd,uint32_t tiling)147 anv_gem_get_bit6_swizzle(int fd, uint32_t tiling)
148 {
149    unreachable("Unused");
150 }
151 
152 int
anv_gem_create_context(struct anv_device * device)153 anv_gem_create_context(struct anv_device *device)
154 {
155    unreachable("Unused");
156 }
157 
158 int
anv_gem_destroy_context(struct anv_device * device,int context)159 anv_gem_destroy_context(struct anv_device *device, int context)
160 {
161    unreachable("Unused");
162 }
163 
164 int
anv_gem_set_context_param(int fd,int context,uint32_t param,uint64_t value)165 anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value)
166 {
167    unreachable("Unused");
168 }
169 
170 int
anv_gem_get_context_param(int fd,int context,uint32_t param,uint64_t * value)171 anv_gem_get_context_param(int fd, int context, uint32_t param, uint64_t *value)
172 {
173    unreachable("Unused");
174 }
175 
176 bool
anv_gem_has_context_priority(int fd)177 anv_gem_has_context_priority(int fd)
178 {
179    unreachable("Unused");
180 }
181 
182 int
anv_gem_context_get_reset_stats(int fd,int context,uint32_t * active,uint32_t * pending)183 anv_gem_context_get_reset_stats(int fd, int context,
184                                 uint32_t *active, uint32_t *pending)
185 {
186    unreachable("Unused");
187 }
188 
189 int
anv_gem_handle_to_fd(struct anv_device * device,uint32_t gem_handle)190 anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle)
191 {
192    unreachable("Unused");
193 }
194 
195 uint32_t
anv_gem_fd_to_handle(struct anv_device * device,int fd)196 anv_gem_fd_to_handle(struct anv_device *device, int fd)
197 {
198    unreachable("Unused");
199 }
200 
201 int
anv_gem_sync_file_merge(struct anv_device * device,int fd1,int fd2)202 anv_gem_sync_file_merge(struct anv_device *device, int fd1, int fd2)
203 {
204    unreachable("Unused");
205 }
206 
207 int
anv_gem_syncobj_export_sync_file(struct anv_device * device,uint32_t handle)208 anv_gem_syncobj_export_sync_file(struct anv_device *device, uint32_t handle)
209 {
210    unreachable("Unused");
211 }
212 
213 int
anv_gem_syncobj_import_sync_file(struct anv_device * device,uint32_t handle,int fd)214 anv_gem_syncobj_import_sync_file(struct anv_device *device,
215                                  uint32_t handle, int fd)
216 {
217    unreachable("Unused");
218 }
219 
220 uint32_t
anv_gem_syncobj_create(struct anv_device * device,uint32_t flags)221 anv_gem_syncobj_create(struct anv_device *device, uint32_t flags)
222 {
223    unreachable("Unused");
224 }
225 
226 void
anv_gem_syncobj_destroy(struct anv_device * device,uint32_t handle)227 anv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle)
228 {
229    unreachable("Unused");
230 }
231 
232 int
anv_gem_syncobj_handle_to_fd(struct anv_device * device,uint32_t handle)233 anv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle)
234 {
235    unreachable("Unused");
236 }
237 
238 uint32_t
anv_gem_syncobj_fd_to_handle(struct anv_device * device,int fd)239 anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
240 {
241    unreachable("Unused");
242 }
243 
244 void
anv_gem_syncobj_reset(struct anv_device * device,uint32_t handle)245 anv_gem_syncobj_reset(struct anv_device *device, uint32_t handle)
246 {
247    unreachable("Unused");
248 }
249 
250 bool
anv_gem_supports_syncobj_wait(int fd)251 anv_gem_supports_syncobj_wait(int fd)
252 {
253    return false;
254 }
255 
256 int
anv_i915_query(int fd,uint64_t query_id,void * buffer,int32_t * buffer_len)257 anv_i915_query(int fd, uint64_t query_id, void *buffer,
258                int32_t *buffer_len)
259 {
260    unreachable("Unused");
261 }
262 
263 int
anv_gem_create_context_engines(struct anv_device * device,const struct drm_i915_query_engine_info * info,int num_engines,uint16_t * engine_classes)264 anv_gem_create_context_engines(struct anv_device *device,
265                                const struct drm_i915_query_engine_info *info,
266                                int num_engines,
267                                uint16_t *engine_classes)
268 {
269    unreachable("Unused");
270 }
271 
272 struct drm_i915_query_engine_info *
anv_gem_get_engine_info(int fd)273 anv_gem_get_engine_info(int fd)
274 {
275    unreachable("Unused");
276 }
277 
278 int
anv_gem_count_engines(const struct drm_i915_query_engine_info * info,uint16_t engine_class)279 anv_gem_count_engines(const struct drm_i915_query_engine_info *info,
280                       uint16_t engine_class)
281 {
282    unreachable("Unused");
283 }
284 
285 int
anv_gem_syncobj_wait(struct anv_device * device,const uint32_t * handles,uint32_t num_handles,int64_t abs_timeout_ns,bool wait_all)286 anv_gem_syncobj_wait(struct anv_device *device,
287                      const uint32_t *handles, uint32_t num_handles,
288                      int64_t abs_timeout_ns, bool wait_all)
289 {
290    unreachable("Unused");
291 }
292 
293 int
anv_gem_reg_read(int fd,uint32_t offset,uint64_t * result)294 anv_gem_reg_read(int fd, uint32_t offset, uint64_t *result)
295 {
296    unreachable("Unused");
297 }
298 
299 int
anv_gem_syncobj_timeline_wait(struct anv_device * device,const uint32_t * handles,const uint64_t * points,uint32_t num_items,int64_t abs_timeout_ns,bool wait_all,bool wait_materialize)300 anv_gem_syncobj_timeline_wait(struct anv_device *device,
301                               const uint32_t *handles, const uint64_t *points,
302                               uint32_t num_items, int64_t abs_timeout_ns,
303                               bool wait_all, bool wait_materialize)
304 {
305    unreachable("Unused");
306 }
307 
308 int
anv_gem_syncobj_timeline_signal(struct anv_device * device,const uint32_t * handles,const uint64_t * points,uint32_t num_items)309 anv_gem_syncobj_timeline_signal(struct anv_device *device,
310                                 const uint32_t *handles, const uint64_t *points,
311                                 uint32_t num_items)
312 {
313    unreachable("Unused");
314 }
315 
316 int
anv_gem_syncobj_timeline_query(struct anv_device * device,const uint32_t * handles,uint64_t * points,uint32_t num_items)317 anv_gem_syncobj_timeline_query(struct anv_device *device,
318                                const uint32_t *handles, uint64_t *points,
319                                uint32_t num_items)
320 {
321    unreachable("Unused");
322 }
323