anv: Move anv_device_check_status() code to i915/anv_device.c
[platform/upstream/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 <sys/mman.h>
25 #include <sys/syscall.h>
26
27 #include "util/anon_file.h"
28 #include "anv_private.h"
29
30 uint32_t
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
43 anv_gem_close(struct anv_device *device, uint32_t gem_handle)
44 {
45    close(gem_handle);
46 }
47
48 uint32_t
49 anv_gem_create_regions(struct anv_device *device, uint64_t anv_bo_size,
50                        uint32_t flags, uint32_t num_regions,
51                        struct drm_i915_gem_memory_class_instance *regions)
52 {
53    return 0;
54 }
55
56 void*
57 anv_gem_mmap(struct anv_device *device, struct anv_bo *bo,
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                bo->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
71 anv_gem_munmap(struct anv_device *device, void *p, uint64_t size)
72 {
73    munmap(p, size);
74 }
75
76 uint32_t
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
89 anv_gem_wait(struct anv_device *device, uint32_t gem_handle, int64_t *timeout_ns)
90 {
91    return 0;
92 }
93
94 int
95 anv_gem_set_tiling(struct anv_device *device,
96                    uint32_t gem_handle, uint32_t stride, uint32_t tiling)
97 {
98    return 0;
99 }
100
101 int
102 anv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle)
103 {
104    return 0;
105 }
106
107 int
108 anv_gem_set_caching(struct anv_device *device, uint32_t gem_handle,
109                     uint32_t caching)
110 {
111    return 0;
112 }
113
114 int
115 anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle)
116 {
117    unreachable("Unused");
118 }
119
120 uint32_t
121 anv_gem_fd_to_handle(struct anv_device *device, int fd)
122 {
123    unreachable("Unused");
124 }
125
126 int
127 anv_i915_query(int fd, uint64_t query_id, void *buffer,
128                int32_t *buffer_len)
129 {
130    unreachable("Unused");
131 }