xref: /aosp_15_r20/external/mesa3d/src/intel/vulkan_hasvk/anv_gem_stubs.c (revision 6104692788411f58d303aa86923a9ff6ecaded22)
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 void*
anv_gem_mmap(struct anv_device * device,uint32_t gem_handle,uint64_t offset,uint64_t size,uint32_t flags)49 anv_gem_mmap(struct anv_device *device, uint32_t gem_handle,
50              uint64_t offset, uint64_t size, uint32_t flags)
51 {
52    /* Ignore flags, as they're specific to I915_GEM_MMAP. */
53    (void) flags;
54 
55    return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
56                gem_handle, offset);
57 }
58 
59 /* This is just a wrapper around munmap, but it also notifies valgrind that
60  * this map is no longer valid.  Pair this with anv_gem_mmap().
61  */
62 void
anv_gem_munmap(struct anv_device * device,void * p,uint64_t size)63 anv_gem_munmap(struct anv_device *device, void *p, uint64_t size)
64 {
65    munmap(p, size);
66 }
67 
68 uint32_t
anv_gem_userptr(struct anv_device * device,void * mem,size_t size)69 anv_gem_userptr(struct anv_device *device, void *mem, size_t size)
70 {
71    int fd = os_create_anonymous_file(size, "fake bo");
72    if (fd == -1)
73       return 0;
74 
75    assert(fd != 0);
76 
77    return fd;
78 }
79 
80 int
anv_gem_wait(struct anv_device * device,uint32_t gem_handle,int64_t * timeout_ns)81 anv_gem_wait(struct anv_device *device, uint32_t gem_handle, int64_t *timeout_ns)
82 {
83    return 0;
84 }
85 
86 int
anv_gem_execbuffer(struct anv_device * device,struct drm_i915_gem_execbuffer2 * execbuf)87 anv_gem_execbuffer(struct anv_device *device,
88                    struct drm_i915_gem_execbuffer2 *execbuf)
89 {
90    return 0;
91 }
92 
93 int
anv_gem_set_tiling(struct anv_device * device,uint32_t gem_handle,uint32_t stride,uint32_t tiling)94 anv_gem_set_tiling(struct anv_device *device,
95                    uint32_t gem_handle, uint32_t stride, uint32_t tiling)
96 {
97    return 0;
98 }
99 
100 int
anv_gem_get_tiling(struct anv_device * device,uint32_t gem_handle)101 anv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle)
102 {
103    return 0;
104 }
105 
106 int
anv_gem_set_caching(struct anv_device * device,uint32_t gem_handle,uint32_t caching)107 anv_gem_set_caching(struct anv_device *device, uint32_t gem_handle,
108                     uint32_t caching)
109 {
110    return 0;
111 }
112 
113 int
anv_gem_set_context_param(int fd,uint32_t context,uint32_t param,uint64_t value)114 anv_gem_set_context_param(int fd, uint32_t context, uint32_t param, uint64_t value)
115 {
116    unreachable("Unused");
117 }
118 
119 bool
anv_gem_has_context_priority(int fd,int priority)120 anv_gem_has_context_priority(int fd, int priority)
121 {
122    unreachable("Unused");
123 }
124 
125 int
anv_gem_context_get_reset_stats(int fd,int context,uint32_t * active,uint32_t * pending)126 anv_gem_context_get_reset_stats(int fd, int context,
127                                 uint32_t *active, uint32_t *pending)
128 {
129    unreachable("Unused");
130 }
131 
132 int
anv_gem_handle_to_fd(struct anv_device * device,uint32_t gem_handle)133 anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle)
134 {
135    unreachable("Unused");
136 }
137 
138 uint32_t
anv_gem_fd_to_handle(struct anv_device * device,int fd)139 anv_gem_fd_to_handle(struct anv_device *device, int fd)
140 {
141    unreachable("Unused");
142 }
143