101e04c3fSmrg/*
201e04c3fSmrg * Copyright © 2015 Intel Corporation
301e04c3fSmrg *
401e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a
501e04c3fSmrg * copy of this software and associated documentation files (the "Software"),
601e04c3fSmrg * to deal in the Software without restriction, including without limitation
701e04c3fSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
801e04c3fSmrg * and/or sell copies of the Software, and to permit persons to whom the
901e04c3fSmrg * Software is furnished to do so, subject to the following conditions:
1001e04c3fSmrg *
1101e04c3fSmrg * The above copyright notice and this permission notice (including the next
1201e04c3fSmrg * paragraph) shall be included in all copies or substantial portions of the
1301e04c3fSmrg * Software.
1401e04c3fSmrg *
1501e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1601e04c3fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1701e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1801e04c3fSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1901e04c3fSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2001e04c3fSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2101e04c3fSmrg * IN THE SOFTWARE.
2201e04c3fSmrg */
2301e04c3fSmrg
2401e04c3fSmrg#include <sys/mman.h>
2501e04c3fSmrg#include <sys/syscall.h>
2601e04c3fSmrg
277ec681f3Smrg#include "util/anon_file.h"
2801e04c3fSmrg#include "anv_private.h"
2901e04c3fSmrg
3001e04c3fSmrguint32_t
3101e04c3fSmrganv_gem_create(struct anv_device *device, uint64_t size)
3201e04c3fSmrg{
337ec681f3Smrg   int fd = os_create_anonymous_file(size, "fake bo");
3401e04c3fSmrg   if (fd == -1)
3501e04c3fSmrg      return 0;
3601e04c3fSmrg
3701e04c3fSmrg   assert(fd != 0);
3801e04c3fSmrg
3901e04c3fSmrg   return fd;
4001e04c3fSmrg}
4101e04c3fSmrg
4201e04c3fSmrgvoid
4301e04c3fSmrganv_gem_close(struct anv_device *device, uint32_t gem_handle)
4401e04c3fSmrg{
4501e04c3fSmrg   close(gem_handle);
4601e04c3fSmrg}
4701e04c3fSmrg
487ec681f3Smrguint32_t
497ec681f3Smrganv_gem_create_regions(struct anv_device *device, uint64_t anv_bo_size,
507ec681f3Smrg                       uint32_t num_regions,
517ec681f3Smrg                       struct drm_i915_gem_memory_class_instance *regions)
527ec681f3Smrg{
537ec681f3Smrg   return 0;
547ec681f3Smrg}
557ec681f3Smrg
5601e04c3fSmrgvoid*
5701e04c3fSmrganv_gem_mmap(struct anv_device *device, uint32_t gem_handle,
5801e04c3fSmrg             uint64_t offset, uint64_t size, uint32_t flags)
5901e04c3fSmrg{
6001e04c3fSmrg   /* Ignore flags, as they're specific to I915_GEM_MMAP. */
6101e04c3fSmrg   (void) flags;
6201e04c3fSmrg
6301e04c3fSmrg   return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
6401e04c3fSmrg               gem_handle, offset);
6501e04c3fSmrg}
6601e04c3fSmrg
6701e04c3fSmrg/* This is just a wrapper around munmap, but it also notifies valgrind that
6801e04c3fSmrg * this map is no longer valid.  Pair this with anv_gem_mmap().
6901e04c3fSmrg */
7001e04c3fSmrgvoid
717ec681f3Smrganv_gem_munmap(struct anv_device *device, void *p, uint64_t size)
7201e04c3fSmrg{
7301e04c3fSmrg   munmap(p, size);
7401e04c3fSmrg}
7501e04c3fSmrg
7601e04c3fSmrguint32_t
7701e04c3fSmrganv_gem_userptr(struct anv_device *device, void *mem, size_t size)
7801e04c3fSmrg{
797ec681f3Smrg   int fd = os_create_anonymous_file(size, "fake bo");
807ec681f3Smrg   if (fd == -1)
817ec681f3Smrg      return 0;
827ec681f3Smrg
837ec681f3Smrg   assert(fd != 0);
847ec681f3Smrg
857ec681f3Smrg   return fd;
8601e04c3fSmrg}
8701e04c3fSmrg
8801e04c3fSmrgint
8901e04c3fSmrganv_gem_busy(struct anv_device *device, uint32_t gem_handle)
9001e04c3fSmrg{
9101e04c3fSmrg   return 0;
9201e04c3fSmrg}
9301e04c3fSmrg
9401e04c3fSmrgint
9501e04c3fSmrganv_gem_wait(struct anv_device *device, uint32_t gem_handle, int64_t *timeout_ns)
9601e04c3fSmrg{
9701e04c3fSmrg   return 0;
9801e04c3fSmrg}
9901e04c3fSmrg
10001e04c3fSmrgint
10101e04c3fSmrganv_gem_execbuffer(struct anv_device *device,
10201e04c3fSmrg                   struct drm_i915_gem_execbuffer2 *execbuf)
10301e04c3fSmrg{
10401e04c3fSmrg   return 0;
10501e04c3fSmrg}
10601e04c3fSmrg
10701e04c3fSmrgint
10801e04c3fSmrganv_gem_set_tiling(struct anv_device *device,
10901e04c3fSmrg                   uint32_t gem_handle, uint32_t stride, uint32_t tiling)
11001e04c3fSmrg{
11101e04c3fSmrg   return 0;
11201e04c3fSmrg}
11301e04c3fSmrg
1147ec681f3Smrgint
1157ec681f3Smrganv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle)
1167ec681f3Smrg{
1177ec681f3Smrg   return 0;
1187ec681f3Smrg}
1197ec681f3Smrg
12001e04c3fSmrgint
12101e04c3fSmrganv_gem_set_caching(struct anv_device *device, uint32_t gem_handle,
12201e04c3fSmrg                    uint32_t caching)
12301e04c3fSmrg{
12401e04c3fSmrg   return 0;
12501e04c3fSmrg}
12601e04c3fSmrg
12701e04c3fSmrgint
12801e04c3fSmrganv_gem_set_domain(struct anv_device *device, uint32_t gem_handle,
12901e04c3fSmrg                   uint32_t read_domains, uint32_t write_domain)
13001e04c3fSmrg{
13101e04c3fSmrg   return 0;
13201e04c3fSmrg}
13301e04c3fSmrg
13401e04c3fSmrgint
13501e04c3fSmrganv_gem_get_param(int fd, uint32_t param)
13601e04c3fSmrg{
13701e04c3fSmrg   unreachable("Unused");
13801e04c3fSmrg}
13901e04c3fSmrg
1407ec681f3Smrguint64_t
1417ec681f3Smrganv_gem_get_drm_cap(int fd, uint32_t capability)
1427ec681f3Smrg{
1437ec681f3Smrg   return 0;
1447ec681f3Smrg}
1457ec681f3Smrg
14601e04c3fSmrgbool
14701e04c3fSmrganv_gem_get_bit6_swizzle(int fd, uint32_t tiling)
14801e04c3fSmrg{
14901e04c3fSmrg   unreachable("Unused");
15001e04c3fSmrg}
15101e04c3fSmrg
15201e04c3fSmrgint
15301e04c3fSmrganv_gem_create_context(struct anv_device *device)
15401e04c3fSmrg{
15501e04c3fSmrg   unreachable("Unused");
15601e04c3fSmrg}
15701e04c3fSmrg
15801e04c3fSmrgint
15901e04c3fSmrganv_gem_destroy_context(struct anv_device *device, int context)
16001e04c3fSmrg{
16101e04c3fSmrg   unreachable("Unused");
16201e04c3fSmrg}
16301e04c3fSmrg
16401e04c3fSmrgint
16501e04c3fSmrganv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value)
16601e04c3fSmrg{
16701e04c3fSmrg   unreachable("Unused");
16801e04c3fSmrg}
16901e04c3fSmrg
17001e04c3fSmrgint
17101e04c3fSmrganv_gem_get_context_param(int fd, int context, uint32_t param, uint64_t *value)
17201e04c3fSmrg{
17301e04c3fSmrg   unreachable("Unused");
17401e04c3fSmrg}
17501e04c3fSmrg
17601e04c3fSmrgbool
17701e04c3fSmrganv_gem_has_context_priority(int fd)
17801e04c3fSmrg{
17901e04c3fSmrg   unreachable("Unused");
18001e04c3fSmrg}
18101e04c3fSmrg
18201e04c3fSmrgint
1837ec681f3Smrganv_gem_context_get_reset_stats(int fd, int context,
1847ec681f3Smrg                                uint32_t *active, uint32_t *pending)
18501e04c3fSmrg{
18601e04c3fSmrg   unreachable("Unused");
18701e04c3fSmrg}
18801e04c3fSmrg
18901e04c3fSmrgint
19001e04c3fSmrganv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle)
19101e04c3fSmrg{
19201e04c3fSmrg   unreachable("Unused");
19301e04c3fSmrg}
19401e04c3fSmrg
19501e04c3fSmrguint32_t
19601e04c3fSmrganv_gem_fd_to_handle(struct anv_device *device, int fd)
19701e04c3fSmrg{
19801e04c3fSmrg   unreachable("Unused");
19901e04c3fSmrg}
20001e04c3fSmrg
20101e04c3fSmrgint
20201e04c3fSmrganv_gem_sync_file_merge(struct anv_device *device, int fd1, int fd2)
20301e04c3fSmrg{
20401e04c3fSmrg   unreachable("Unused");
20501e04c3fSmrg}
20601e04c3fSmrg
20701e04c3fSmrgint
20801e04c3fSmrganv_gem_syncobj_export_sync_file(struct anv_device *device, uint32_t handle)
20901e04c3fSmrg{
21001e04c3fSmrg   unreachable("Unused");
21101e04c3fSmrg}
21201e04c3fSmrg
21301e04c3fSmrgint
21401e04c3fSmrganv_gem_syncobj_import_sync_file(struct anv_device *device,
21501e04c3fSmrg                                 uint32_t handle, int fd)
21601e04c3fSmrg{
21701e04c3fSmrg   unreachable("Unused");
21801e04c3fSmrg}
21901e04c3fSmrg
22001e04c3fSmrguint32_t
22101e04c3fSmrganv_gem_syncobj_create(struct anv_device *device, uint32_t flags)
22201e04c3fSmrg{
22301e04c3fSmrg   unreachable("Unused");
22401e04c3fSmrg}
22501e04c3fSmrg
22601e04c3fSmrgvoid
22701e04c3fSmrganv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle)
22801e04c3fSmrg{
22901e04c3fSmrg   unreachable("Unused");
23001e04c3fSmrg}
23101e04c3fSmrg
23201e04c3fSmrgint
23301e04c3fSmrganv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle)
23401e04c3fSmrg{
23501e04c3fSmrg   unreachable("Unused");
23601e04c3fSmrg}
23701e04c3fSmrg
23801e04c3fSmrguint32_t
23901e04c3fSmrganv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
24001e04c3fSmrg{
24101e04c3fSmrg   unreachable("Unused");
24201e04c3fSmrg}
24301e04c3fSmrg
24401e04c3fSmrgvoid
24501e04c3fSmrganv_gem_syncobj_reset(struct anv_device *device, uint32_t handle)
24601e04c3fSmrg{
24701e04c3fSmrg   unreachable("Unused");
24801e04c3fSmrg}
24901e04c3fSmrg
25001e04c3fSmrgbool
25101e04c3fSmrganv_gem_supports_syncobj_wait(int fd)
25201e04c3fSmrg{
25301e04c3fSmrg   return false;
25401e04c3fSmrg}
25501e04c3fSmrg
2567ec681f3Smrgint
2577ec681f3Smrganv_i915_query(int fd, uint64_t query_id, void *buffer,
2587ec681f3Smrg               int32_t *buffer_len)
2597ec681f3Smrg{
2607ec681f3Smrg   unreachable("Unused");
2617ec681f3Smrg}
2627ec681f3Smrg
2637ec681f3Smrgint
2647ec681f3Smrganv_gem_create_context_engines(struct anv_device *device,
2657ec681f3Smrg                               const struct drm_i915_query_engine_info *info,
2667ec681f3Smrg                               int num_engines,
2677ec681f3Smrg                               uint16_t *engine_classes)
2687ec681f3Smrg{
2697ec681f3Smrg   unreachable("Unused");
2707ec681f3Smrg}
2717ec681f3Smrg
2727ec681f3Smrgstruct drm_i915_query_engine_info *
2737ec681f3Smrganv_gem_get_engine_info(int fd)
2747ec681f3Smrg{
2757ec681f3Smrg   unreachable("Unused");
2767ec681f3Smrg}
2777ec681f3Smrg
2787ec681f3Smrgint
2797ec681f3Smrganv_gem_count_engines(const struct drm_i915_query_engine_info *info,
2807ec681f3Smrg                      uint16_t engine_class)
2817ec681f3Smrg{
2827ec681f3Smrg   unreachable("Unused");
2837ec681f3Smrg}
2847ec681f3Smrg
28501e04c3fSmrgint
28601e04c3fSmrganv_gem_syncobj_wait(struct anv_device *device,
2877ec681f3Smrg                     const uint32_t *handles, uint32_t num_handles,
28801e04c3fSmrg                     int64_t abs_timeout_ns, bool wait_all)
28901e04c3fSmrg{
29001e04c3fSmrg   unreachable("Unused");
29101e04c3fSmrg}
29201e04c3fSmrg
29301e04c3fSmrgint
2947ec681f3Smrganv_gem_reg_read(int fd, uint32_t offset, uint64_t *result)
2957ec681f3Smrg{
2967ec681f3Smrg   unreachable("Unused");
2977ec681f3Smrg}
2987ec681f3Smrg
2997ec681f3Smrgint
3007ec681f3Smrganv_gem_syncobj_timeline_wait(struct anv_device *device,
3017ec681f3Smrg                              const uint32_t *handles, const uint64_t *points,
3027ec681f3Smrg                              uint32_t num_items, int64_t abs_timeout_ns,
3037ec681f3Smrg                              bool wait_all, bool wait_materialize)
3047ec681f3Smrg{
3057ec681f3Smrg   unreachable("Unused");
3067ec681f3Smrg}
3077ec681f3Smrg
3087ec681f3Smrgint
3097ec681f3Smrganv_gem_syncobj_timeline_signal(struct anv_device *device,
3107ec681f3Smrg                                const uint32_t *handles, const uint64_t *points,
3117ec681f3Smrg                                uint32_t num_items)
3127ec681f3Smrg{
3137ec681f3Smrg   unreachable("Unused");
3147ec681f3Smrg}
3157ec681f3Smrg
3167ec681f3Smrgint
3177ec681f3Smrganv_gem_syncobj_timeline_query(struct anv_device *device,
3187ec681f3Smrg                               const uint32_t *handles, uint64_t *points,
3197ec681f3Smrg                               uint32_t num_items)
32001e04c3fSmrg{
32101e04c3fSmrg   unreachable("Unused");
32201e04c3fSmrg}
323