v3d: Introduce a DRM shim for calling out to the simulator.
[mesa.git] / src / broadcom / drm-shim / v3d.h
1 /*
2 * Copyright © 2018 Broadcom
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 #ifndef DRM_SHIM_V3D_H
25 #define DRM_SHIM_V3D_H
26
27 #include "broadcom/common/v3d_device_info.h"
28 #include "util/vma.h"
29
30 struct drm_shim_fd;
31
32 struct v3d_shim_device {
33 struct v3d_hw *hw;
34 struct v3d_device_info *devinfo;
35
36 /* Base virtual address of the heap. */
37 void *mem;
38 /* Base hardware address of the heap. */
39 uint32_t mem_base;
40 /* Size of the heap. */
41 size_t mem_size;
42
43 /* Allocator for the GPU virtual addresses. */
44 struct util_vma_heap heap;
45 };
46 extern struct v3d_shim_device v3d;
47
48 struct v3d_bo {
49 struct shim_bo base;
50 uint64_t offset;
51 void *sim_vaddr;
52 void *gem_vaddr;
53 };
54
55 static inline struct v3d_bo *
56 v3d_bo(struct shim_bo *bo)
57 {
58 return (struct v3d_bo *)bo;
59 }
60
61 struct v3d_bo *v3d_bo_lookup(struct shim_fd *shim_fd, int handle);
62 int v3d_ioctl_wait_bo(int fd, unsigned long request, void *arg);
63 int v3d_ioctl_mmap_bo(int fd, unsigned long request, void *arg);
64 int v3d_ioctl_get_bo_offset(int fd, unsigned long request, void *arg);
65
66 void v3d33_drm_shim_driver_init(void);
67 void v3d41_drm_shim_driver_init(void);
68 void v3d42_drm_shim_driver_init(void);
69
70 #endif /* DRM_SHIM_V3D_H */