anv: add new gem/drm helpers
[mesa.git] / src / intel / vulkan / anv_gem_stubs.c
index a63e96d52beb73a32c9606b7ac236d4423fe0324..35285c08d7170f062e44b5764e1c9777db8a60ab 100644 (file)
  * IN THE SOFTWARE.
  */
 
-#include <linux/memfd.h>
 #include <sys/mman.h>
 #include <sys/syscall.h>
 
+#include "util/anon_file.h"
 #include "anv_private.h"
 
-static inline int
-memfd_create(const char *name, unsigned int flags)
-{
-   return syscall(SYS_memfd_create, name, flags);
-}
-
 uint32_t
-anv_gem_create(struct anv_device *device, size_t size)
+anv_gem_create(struct anv_device *device, uint64_t size)
 {
-   int fd = memfd_create("fake bo", MFD_CLOEXEC);
+   int fd = os_create_anonymous_file(size, "fake bo");
    if (fd == -1)
       return 0;
 
    assert(fd != 0);
 
-   if (ftruncate(fd, size) == -1)
-      return 0;
-
    return fd;
 }
 
@@ -69,7 +60,7 @@ anv_gem_mmap(struct anv_device *device, uint32_t gem_handle,
  * this map is no longer valid.  Pair this with anv_gem_mmap().
  */
 void
-anv_gem_munmap(void *p, uint64_t size)
+anv_gem_munmap(struct anv_device *device, void *p, uint64_t size)
 {
    munmap(p, size);
 }
@@ -77,7 +68,13 @@ anv_gem_munmap(void *p, uint64_t size)
 uint32_t
 anv_gem_userptr(struct anv_device *device, void *mem, size_t size)
 {
-   return -1;
+   int fd = os_create_anonymous_file(size, "fake bo");
+   if (fd == -1)
+      return 0;
+
+   assert(fd != 0);
+
+   return fd;
 }
 
 int
@@ -106,6 +103,12 @@ anv_gem_set_tiling(struct anv_device *device,
    return 0;
 }
 
+int
+anv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle)
+{
+   return 0;
+}
+
 int
 anv_gem_set_caching(struct anv_device *device, uint32_t gem_handle,
                     uint32_t caching)
@@ -126,6 +129,12 @@ anv_gem_get_param(int fd, uint32_t param)
    unreachable("Unused");
 }
 
+uint64_t
+anv_gem_get_drm_cap(int fd, uint32_t capability)
+{
+   return 0;
+}
+
 bool
 anv_gem_get_bit6_swizzle(int fd, uint32_t tiling)
 {
@@ -145,19 +154,19 @@ anv_gem_destroy_context(struct anv_device *device, int context)
 }
 
 int
-anv_gem_get_context_param(int fd, int context, uint32_t param, uint64_t *value)
+anv_gem_set_context_param(int fd, int context, uint32_t param, uint64_t value)
 {
    unreachable("Unused");
 }
 
 int
-anv_gem_get_aperture(int fd, uint64_t *size)
+anv_gem_get_context_param(int fd, int context, uint32_t param, uint64_t *value)
 {
    unreachable("Unused");
 }
 
 bool
-anv_gem_supports_48b_addresses(int fd)
+anv_gem_has_context_priority(int fd)
 {
    unreachable("Unused");
 }
@@ -180,3 +189,97 @@ anv_gem_fd_to_handle(struct anv_device *device, int fd)
 {
    unreachable("Unused");
 }
+
+int
+anv_gem_sync_file_merge(struct anv_device *device, int fd1, int fd2)
+{
+   unreachable("Unused");
+}
+
+int
+anv_gem_syncobj_export_sync_file(struct anv_device *device, uint32_t handle)
+{
+   unreachable("Unused");
+}
+
+int
+anv_gem_syncobj_import_sync_file(struct anv_device *device,
+                                 uint32_t handle, int fd)
+{
+   unreachable("Unused");
+}
+
+uint32_t
+anv_gem_syncobj_create(struct anv_device *device, uint32_t flags)
+{
+   unreachable("Unused");
+}
+
+void
+anv_gem_syncobj_destroy(struct anv_device *device, uint32_t handle)
+{
+   unreachable("Unused");
+}
+
+int
+anv_gem_syncobj_handle_to_fd(struct anv_device *device, uint32_t handle)
+{
+   unreachable("Unused");
+}
+
+uint32_t
+anv_gem_syncobj_fd_to_handle(struct anv_device *device, int fd)
+{
+   unreachable("Unused");
+}
+
+void
+anv_gem_syncobj_reset(struct anv_device *device, uint32_t handle)
+{
+   unreachable("Unused");
+}
+
+bool
+anv_gem_supports_syncobj_wait(int fd)
+{
+   return false;
+}
+
+int
+anv_gem_syncobj_wait(struct anv_device *device,
+                     const uint32_t *handles, uint32_t num_handles,
+                     int64_t abs_timeout_ns, bool wait_all)
+{
+   unreachable("Unused");
+}
+
+int
+anv_gem_reg_read(int fd, uint32_t offset, uint64_t *result)
+{
+   unreachable("Unused");
+}
+
+int
+anv_gem_syncobj_timeline_wait(struct anv_device *device,
+                              const uint32_t *handles, const uint64_t *points,
+                              uint32_t num_items, int64_t abs_timeout_ns,
+                              bool wait_all, bool wait_materialize)
+{
+   unreachable("Unused");
+}
+
+int
+anv_gem_syncobj_timeline_signal(struct anv_device *device,
+                                const uint32_t *handles, const uint64_t *points,
+                                uint32_t num_items)
+{
+   unreachable("Unused");
+}
+
+int
+anv_gem_syncobj_timeline_query(struct anv_device *device,
+                               const uint32_t *handles, uint64_t *points,
+                               uint32_t num_items)
+{
+   unreachable("Unused");
+}