1b8e80941Smrg/*
2b8e80941Smrg * Copyright © 2015 Intel Corporation
3b8e80941Smrg *
4b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a
5b8e80941Smrg * copy of this software and associated documentation files (the "Software"),
6b8e80941Smrg * to deal in the Software without restriction, including without limitation
7b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the
9b8e80941Smrg * Software is furnished to do so, subject to the following conditions:
10b8e80941Smrg *
11b8e80941Smrg * The above copyright notice and this permission notice (including the next
12b8e80941Smrg * paragraph) shall be included in all copies or substantial portions of the
13b8e80941Smrg * Software.
14b8e80941Smrg *
15b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16b8e80941Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18b8e80941Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19b8e80941Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20b8e80941Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21b8e80941Smrg * IN THE SOFTWARE.
22b8e80941Smrg */
23b8e80941Smrg
24b8e80941Smrg#include <linux/memfd.h>
25b8e80941Smrg#include <sys/mman.h>
26b8e80941Smrg#include <sys/syscall.h>
27b8e80941Smrg
28b8e80941Smrg#include "anv_private.h"
29b8e80941Smrg
30b8e80941Smrg#ifndef HAVE_MEMFD_CREATE
31b8e80941Smrgstatic inline int
32b8e80941Smrgmemfd_create(const char *name, unsigned int flags)
33b8e80941Smrg{
34b8e80941Smrg   return syscall(SYS_memfd_create, name, flags);
35b8e80941Smrg}
36b8e80941Smrg#endif
37b8e80941Smrg
38b8e80941Smrguint32_t
39b8e80941Smrganv_gem_create(struct anv_device *device, uint64_t size)
40b8e80941Smrg{
41b8e80941Smrg   int fd = memfd_create("fake bo", MFD_CLOEXEC);
42b8e80941Smrg   if (fd == -1)
43b8e80941Smrg      return 0;
44b8e80941Smrg
45b8e80941Smrg   assert(fd != 0);
46b8e80941Smrg
47b8e80941Smrg   if (ftruncate(fd, size) == -1)
48b8e80941Smrg      return 0;
49b8e80941Smrg
50b8e80941Smrg   return fd;
51b8e80941Smrg}
52b8e80941Smrg
53b8e80941Smrgvoid
54b8e80941Smrganv_gem_close(struct anv_device *device, uint32_t gem_handle)
55b8e80941Smrg{
56b8e80941Smrg   close(gem_handle);
57b8e80941Smrg}
58b8e80941Smrg
59b8e80941Smrgvoid*
60b8e80941Smrganv_gem_mmap(struct anv_device *device, uint32_t gem_handle,
61b8e80941Smrg             uint64_t offset, uint64_t size, uint32_t flags)
62b8e80941Smrg{
63b8e80941Smrg   /* Ignore flags, as they're specific to I915_GEM_MMAP. */
64b8e80941Smrg   (void) flags;
65b8e80941Smrg
66b8e80941Smrg   return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
67b8e80941Smrg               gem_handle, offset);
68b8e80941Smrg}
69b8e80941Smrg
70b8e80941Smrg/* This is just a wrapper around munmap, but it also notifies valgrind that
71b8e80941Smrg * this map is no longer valid.  Pair this with anv_gem_mmap().
72b8e80941Smrg */
73b8e80941Smrgvoid
74b8e80941Smrganv_gem_munmap(void *p, uint64_t size)
75b8e80941Smrg{
76b8e80941Smrg   munmap(p, size);
77b8e80941Smrg}
78b8e80941Smrg
79b8e80941Smrguint32_t
80b8e80941Smrganv_gem_userptr(struct anv_device *device, void *mem, size_t size)
81b8e80941Smrg{
82b8e80941Smrg   return -1;
83b8e80941Smrg}
84b8e80941Smrg
85b8e80941Smrgint
86b8e80941Smrganv_gem_busy(struct anv_device *device, uint32_t gem_handle)
87b8e80941Smrg{
88b8e80941Smrg   return 0;
89b8e80941Smrg}
90b8e80941Smrg
91b8e80941Smrgint
92b8e80941Smrganv_gem_wait(struct anv_device *device, uint32_t gem_handle, int64_t *timeout_ns)
93b8e80941Smrg{
94b8e80941Smrg   return 0;
95b8e80941Smrg}
96b8e80941Smrg
97b8e80941Smrgint
98b8e80941Smrganv_gem_execbuffer(struct anv_device *device,
99b8e80941Smrg                   struct drm_i915_gem_execbuffer2 *execbuf)
100b8e80941Smrg{
101b8e80941Smrg   return 0;
102b8e80941Smrg}
103b8e80941Smrg
104b8e80941Smrgint
105b8e80941Smrganv_gem_set_tiling(struct anv_device *device,
106b8e80941Smrg                   uint32_t gem_handle, uint32_t stride, uint32_t tiling)
107b8e80941Smrg{
108b8e80941Smrg   return 0;
109b8e80941Smrg}
110b8e80941Smrg
111b8e80941Smrgint
112b8e80941Smrganv_gem_set_caching(struct anv_device *device, uint32_t gem_handle,
113b8e80941Smrg                    uint32_t caching)
114b8e80941Smrg{
115b8e80941Smrg   return 0;
116b8e80941Smrg}
117b8e80941Smrg
118b8e80941Smrgint
119b8e80941Smrganv_gem_set_domain(struct anv_device *device, uint32_t gem_handle,
120b8e80941Smrg                   uint32_t read_domains, uint32_t write_domain)
121b8e80941Smrg{
122b8e80941Smrg   return 0;
123b8e80941Smrg}
124b8e80941Smrg
125b8e80941Smrgint
126b8e80941Smrganv_gem_get_param(int fd, uint32_t param)
127b8e80941Smrg{
128b8e80941Smrg   unreachable("Unused");
129b8e80941Smrg}
130b8e80941Smrg
131b8e80941Smrgbool
132b8e80941Smrganv_gem_get_bit6_swizzle(int fd, uint32_t tiling)
133b8e80941Smrg{
134b8e80941Smrg   unreachable("Unused");
135b8e80941Smrg}
136b8e80941Smrg
137b8e80941Smrgint
138b8e80941Smrganv_gem_create_context(struct anv_device *device)
139b8e80941Smrg{
140b8e80941Smrg   unreachable("Unused");
141b8e80941Smrg}
142b8e80941Smrg
143b8e80941Smrgint
144b8e80941Smrganv_gem_destroy_context(struct anv_device *device, int context)
145b8e80941Smrg{
146b8e80941Smrg   unreachable("Unused");
147b8e80941Smrg}
148b8e80941Smrg
149b8e80941Smrgint
150b8e80941Smrganv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value)
151b8e80941Smrg{
152b8e80941Smrg   unreachable("Unused");
153b8e80941Smrg}
154b8e80941Smrg
155b8e80941Smrgint
156b8e80941Smrganv_gem_get_context_param(int fd, int context, uint32_t param, uint64_t *value)
157b8e80941Smrg{
158b8e80941Smrg   unreachable("Unused");
159b8e80941Smrg}
160b8e80941Smrg
161b8e80941Smrgbool
162b8e80941Smrganv_gem_has_context_priority(int fd)
163b8e80941Smrg{
164b8e80941Smrg   unreachable("Unused");
165b8e80941Smrg}
166b8e80941Smrg
167b8e80941Smrgint
168b8e80941Smrganv_gem_get_aperture(int fd, uint64_t *size)
169b8e80941Smrg{
170b8e80941Smrg   unreachable("Unused");
171b8e80941Smrg}
172b8e80941Smrg
173b8e80941Smrgint
174b8e80941Smrganv_gem_gpu_get_reset_stats(struct anv_device *device,
175b8e80941Smrg                            uint32_t *active, uint32_t *pending)
176b8e80941Smrg{
177b8e80941Smrg   unreachable("Unused");
178b8e80941Smrg}
179b8e80941Smrg
180b8e80941Smrgint
181b8e80941Smrganv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle)
182b8e80941Smrg{
183b8e80941Smrg   unreachable("Unused");
184b8e80941Smrg}
185b8e80941Smrg
186b8e80941Smrguint32_t
187b8e80941Smrganv_gem_fd_to_handle(struct anv_device *device, int fd)
188b8e80941Smrg{
189b8e80941Smrg   unreachable("Unused");
190b8e80941Smrg}
191b8e80941Smrg
192b8e80941Smrgint
193b8e80941Smrganv_gem_sync_file_merge(struct anv_device *device, int fd1, int fd2)
194b8e80941Smrg{
195b8e80941Smrg   unreachable("Unused");
196b8e80941Smrg}
197b8e80941Smrg
198b8e80941Smrgint
199b8e80941Smrganv_gem_syncobj_export_sync_file(struct anv_device *device, uint32_t handle)
200b8e80941Smrg{
201b8e80941Smrg   unreachable("Unused");
202b8e80941Smrg}
203b8e80941Smrg
204b8e80941Smrgint
205b8e80941Smrganv_gem_syncobj_import_sync_file(struct anv_device *device,
206b8e80941Smrg                                 uint32_t handle, int fd)
207b8e80941Smrg{
208b8e80941Smrg   unreachable("Unused");
209b8e80941Smrg}
210b8e80941Smrg
211b8e80941Smrguint32_t
212b8e80941Smrganv_gem_syncobj_create(struct anv_device *device, uint32_t flags)
213b8e80941Smrg{
214b8e80941Smrg   unreachable("Unused");
215b8e80941Smrg}
216b8e80941Smrg
217b8e80941Smrgvoid
218b8e80941Smrganv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle)
219b8e80941Smrg{
220b8e80941Smrg   unreachable("Unused");
221b8e80941Smrg}
222b8e80941Smrg
223b8e80941Smrgint
224b8e80941Smrganv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle)
225b8e80941Smrg{
226b8e80941Smrg   unreachable("Unused");
227b8e80941Smrg}
228b8e80941Smrg
229b8e80941Smrguint32_t
230b8e80941Smrganv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
231b8e80941Smrg{
232b8e80941Smrg   unreachable("Unused");
233b8e80941Smrg}
234b8e80941Smrg
235b8e80941Smrgvoid
236b8e80941Smrganv_gem_syncobj_reset(struct anv_device *device, uint32_t handle)
237b8e80941Smrg{
238b8e80941Smrg   unreachable("Unused");
239b8e80941Smrg}
240b8e80941Smrg
241b8e80941Smrgbool
242b8e80941Smrganv_gem_supports_syncobj_wait(int fd)
243b8e80941Smrg{
244b8e80941Smrg   return false;
245b8e80941Smrg}
246b8e80941Smrg
247b8e80941Smrgint
248b8e80941Smrganv_gem_syncobj_wait(struct anv_device *device,
249b8e80941Smrg                     uint32_t *handles, uint32_t num_handles,
250b8e80941Smrg                     int64_t abs_timeout_ns, bool wait_all)
251b8e80941Smrg{
252b8e80941Smrg   unreachable("Unused");
253b8e80941Smrg}
254b8e80941Smrg
255b8e80941Smrgint
256b8e80941Smrganv_gem_reg_read(struct anv_device *device,
257b8e80941Smrg                 uint32_t offset, uint64_t *result)
258b8e80941Smrg{
259b8e80941Smrg   unreachable("Unused");
260b8e80941Smrg}
261