#include <stdbool.h>
#include <string.h>
+#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <errno.h>
+#include "vc4_context.h"
+#include "vc4_qpu_defines.h"
+
+struct vc4_exec_info;
+
#define DRM_INFO(...) fprintf(stderr, __VA_ARGS__)
#define DRM_ERROR(...) fprintf(stderr, __VA_ARGS__)
#define kmalloc(size, arg) malloc(size)
+#define kcalloc(size, count, arg) calloc(size, count)
#define kfree(ptr) free(ptr)
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#define krealloc(ptr, size, args) realloc(ptr, size)
#define roundup(x, y) align(x, y)
+#define round_up(x, y) align(x, y)
+#define max(x, y) MAX2(x, y)
+#define min(x, y) MIN2(x, y)
+#define BUG_ON(condition) assert(!(condition))
+#define BIT(bit) (1u << bit)
+
+/* Unsigned long-based bitmap interface in the linux kernel */
+#define BITMAP_WORDBITS (sizeof(unsigned long) * 8)
+#define BITS_TO_LONGS(bits) (roundup(bits, BITMAP_WORDBITS) / \
+ sizeof(unsigned long))
+static inline bool
+test_bit(unsigned int bit, unsigned long *addr)
+{
+ return addr[bit / BITMAP_WORDBITS] & (1ul << (bit % BITMAP_WORDBITS));
+}
+
+static inline bool
+set_bit(unsigned int bit, unsigned long *addr)
+{
+ return addr[bit / BITMAP_WORDBITS] |= (1ul << (bit % BITMAP_WORDBITS));
+}
+
static inline int
copy_from_user(void *dst, void *src, size_t size)
typedef uint32_t u32;
struct drm_device {
- struct vc4_context *vc4;
- uint32_t simulator_mem_next;
+ struct vc4_screen *screen;
};
-struct drm_gem_cma_object {
- struct vc4_bo *bo;
+struct drm_gem_object {
+ size_t size;
+ struct drm_device *dev;
+};
- struct {
- uint32_t size;
- } base;
+struct drm_gem_cma_object {
+ struct drm_gem_object base;
uint32_t paddr;
void *vaddr;
};
-struct exec_info {
- /* This is the array of BOs that were looked up at the start of exec.
- * Command validation will use indices into this array.
- */
- struct drm_gem_cma_object **bo;
- uint32_t bo_count;
-
- /* Current indices into @bo loaded by the non-hardware packet
- * that passes in indices. This can be used even without
- * checking that we've seen one of those packets, because
- * @bo_count is always >= 1, and this struct is initialized to
- * 0.
- */
- uint32_t bo_index[2];
- uint32_t max_width, max_height;
-
- /**
- * This is the BO where we store the validated command lists
- * and shader records.
- */
- struct drm_gem_cma_object *exec_bo;
-
- /**
- * This tracks the per-shader-record state (packet 64) that
- * determines the length of the shader record and the offset
- * it's expected to be found at. It gets read in from the
- * command lists.
- */
- struct vc4_shader_state {
- uint8_t packet;
- uint32_t addr;
- } *shader_state;
-
- /** How many shader states the user declared they were using. */
- uint32_t shader_state_size;
- /** How many shader state records the validator has seen. */
- uint32_t shader_state_count;
-
- /**
- * Computed addresses pointing into exec_bo where we start the
- * bin thread (ct0) and render thread (ct1).
- */
- uint32_t ct0ca, ct0ea;
- uint32_t ct1ca, ct1ea;
- uint32_t shader_paddr;
+struct drm_vc4_bo {
+ struct drm_gem_cma_object base;
+ struct vc4_validated_shader_info *validated_shader;
+ struct list_head unref_head;
};
-int vc4_validate_cl(struct drm_device *dev,
- void *validated,
- void *unvalidated,
- uint32_t len,
- bool is_bin,
- struct exec_info *exec);
-
-int vc4_validate_shader_recs(struct drm_device *dev,
- void *validated,
- void *unvalidated,
- uint32_t len,
- struct exec_info *exec);
+static inline struct drm_vc4_bo *to_vc4_bo(struct drm_gem_object *obj)
+{
+ return (struct drm_vc4_bo *)obj;
+}
+
+struct drm_gem_cma_object *
+drm_gem_cma_create(struct drm_device *dev, size_t size);
+
+int
+vc4_cl_validate(struct drm_device *dev, struct vc4_exec_info *exec);
#endif /* VC4_SIMULATOR_VALIDATE_H */