anv/gem: Add a flags parameter to syncobj_create
[mesa.git] / src / intel / vulkan / anv_gem_stubs.c
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 <linux/memfd.h>
25 #include <sys/mman.h>
26 #include <sys/syscall.h>
27
28 #include "anv_private.h"
29
30 static inline int
31 memfd_create(const char *name, unsigned int flags)
32 {
33 return syscall(SYS_memfd_create, name, flags);
34 }
35
36 uint32_t
37 anv_gem_create(struct anv_device *device, uint64_t size)
38 {
39 int fd = memfd_create("fake bo", MFD_CLOEXEC);
40 if (fd == -1)
41 return 0;
42
43 assert(fd != 0);
44
45 if (ftruncate(fd, size) == -1)
46 return 0;
47
48 return fd;
49 }
50
51 void
52 anv_gem_close(struct anv_device *device, uint32_t gem_handle)
53 {
54 close(gem_handle);
55 }
56
57 void*
58 anv_gem_mmap(struct anv_device *device, uint32_t gem_handle,
59 uint64_t offset, uint64_t size, uint32_t flags)
60 {
61 /* Ignore flags, as they're specific to I915_GEM_MMAP. */
62 (void) flags;
63
64 return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
65 gem_handle, offset);
66 }
67
68 /* This is just a wrapper around munmap, but it also notifies valgrind that
69 * this map is no longer valid. Pair this with anv_gem_mmap().
70 */
71 void
72 anv_gem_munmap(void *p, uint64_t size)
73 {
74 munmap(p, size);
75 }
76
77 uint32_t
78 anv_gem_userptr(struct anv_device *device, void *mem, size_t size)
79 {
80 return -1;
81 }
82
83 int
84 anv_gem_busy(struct anv_device *device, uint32_t gem_handle)
85 {
86 return 0;
87 }
88
89 int
90 anv_gem_wait(struct anv_device *device, uint32_t gem_handle, int64_t *timeout_ns)
91 {
92 return 0;
93 }
94
95 int
96 anv_gem_execbuffer(struct anv_device *device,
97 struct drm_i915_gem_execbuffer2 *execbuf)
98 {
99 return 0;
100 }
101
102 int
103 anv_gem_set_tiling(struct anv_device *device,
104 uint32_t gem_handle, uint32_t stride, uint32_t tiling)
105 {
106 return 0;
107 }
108
109 int
110 anv_gem_set_caching(struct anv_device *device, uint32_t gem_handle,
111 uint32_t caching)
112 {
113 return 0;
114 }
115
116 int
117 anv_gem_set_domain(struct anv_device *device, uint32_t gem_handle,
118 uint32_t read_domains, uint32_t write_domain)
119 {
120 return 0;
121 }
122
123 int
124 anv_gem_get_param(int fd, uint32_t param)
125 {
126 unreachable("Unused");
127 }
128
129 bool
130 anv_gem_get_bit6_swizzle(int fd, uint32_t tiling)
131 {
132 unreachable("Unused");
133 }
134
135 int
136 anv_gem_create_context(struct anv_device *device)
137 {
138 unreachable("Unused");
139 }
140
141 int
142 anv_gem_destroy_context(struct anv_device *device, int context)
143 {
144 unreachable("Unused");
145 }
146
147 int
148 anv_gem_get_context_param(int fd, int context, uint32_t param, uint64_t *value)
149 {
150 unreachable("Unused");
151 }
152
153 int
154 anv_gem_get_aperture(int fd, uint64_t *size)
155 {
156 unreachable("Unused");
157 }
158
159 bool
160 anv_gem_supports_48b_addresses(int fd)
161 {
162 unreachable("Unused");
163 }
164
165 int
166 anv_gem_gpu_get_reset_stats(struct anv_device *device,
167 uint32_t *active, uint32_t *pending)
168 {
169 unreachable("Unused");
170 }
171
172 int
173 anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle)
174 {
175 unreachable("Unused");
176 }
177
178 uint32_t
179 anv_gem_fd_to_handle(struct anv_device *device, int fd)
180 {
181 unreachable("Unused");
182 }
183
184 int
185 anv_gem_sync_file_merge(struct anv_device *device, int fd1, int fd2)
186 {
187 unreachable("Unused");
188 }
189
190 uint32_t
191 anv_gem_syncobj_create(struct anv_device *device, uint32_t flags)
192 {
193 unreachable("Unused");
194 }
195
196 void
197 anv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle)
198 {
199 unreachable("Unused");
200 }
201
202 int
203 anv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle)
204 {
205 unreachable("Unused");
206 }
207
208 uint32_t
209 anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
210 {
211 unreachable("Unused");
212 }