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 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
140uint64_t
141anv_gem_get_drm_cap(int fd, uint32_t capability)
142{
143   return 0;
144}
145
146bool
147anv_gem_get_bit6_swizzle(int fd, uint32_t tiling)
148{
149   unreachable("Unused");
150}
151
152int
153anv_gem_create_context(struct anv_device *device)
154{
155   unreachable("Unused");
156}
157
158int
159anv_gem_destroy_context(struct anv_device *device, int context)
160{
161   unreachable("Unused");
162}
163
164int
165anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value)
166{
167   unreachable("Unused");
168}
169
170int
171anv_gem_get_context_param(int fd, int context, uint32_t param, uint64_t *value)
172{
173   unreachable("Unused");
174}
175
176bool
177anv_gem_has_context_priority(int fd)
178{
179   unreachable("Unused");
180}
181
182int
183anv_gem_context_get_reset_stats(int fd, int context,
184                                uint32_t *active, uint32_t *pending)
185{
186   unreachable("Unused");
187}
188
189int
190anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle)
191{
192   unreachable("Unused");
193}
194
195uint32_t
196anv_gem_fd_to_handle(struct anv_device *device, int fd)
197{
198   unreachable("Unused");
199}
200
201int
202anv_gem_sync_file_merge(struct anv_device *device, int fd1, int fd2)
203{
204   unreachable("Unused");
205}
206
207int
208anv_gem_syncobj_export_sync_file(struct anv_device *device, uint32_t handle)
209{
210   unreachable("Unused");
211}
212
213int
214anv_gem_syncobj_import_sync_file(struct anv_device *device,
215                                 uint32_t handle, int fd)
216{
217   unreachable("Unused");
218}
219
220uint32_t
221anv_gem_syncobj_create(struct anv_device *device, uint32_t flags)
222{
223   unreachable("Unused");
224}
225
226void
227anv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle)
228{
229   unreachable("Unused");
230}
231
232int
233anv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle)
234{
235   unreachable("Unused");
236}
237
238uint32_t
239anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
240{
241   unreachable("Unused");
242}
243
244void
245anv_gem_syncobj_reset(struct anv_device *device, uint32_t handle)
246{
247   unreachable("Unused");
248}
249
250bool
251anv_gem_supports_syncobj_wait(int fd)
252{
253   return false;
254}
255
256int
257anv_i915_query(int fd, uint64_t query_id, void *buffer,
258               int32_t *buffer_len)
259{
260   unreachable("Unused");
261}
262
263int
264anv_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
272struct drm_i915_query_engine_info *
273anv_gem_get_engine_info(int fd)
274{
275   unreachable("Unused");
276}
277
278int
279anv_gem_count_engines(const struct drm_i915_query_engine_info *info,
280                      uint16_t engine_class)
281{
282   unreachable("Unused");
283}
284
285int
286anv_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
293int
294anv_gem_reg_read(int fd, uint32_t offset, uint64_t *result)
295{
296   unreachable("Unused");
297}
298
299int
300anv_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
308int
309anv_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
316int
317anv_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