summaryrefslogtreecommitdiff
path: root/tools/null_state_gen/intel_batchbuffer.h
diff options
context:
space:
mode:
authorMika Kuoppala <mika.kuoppala@linux.intel.com>2014-08-01 21:19:56 +0300
committerMika Kuoppala <mika.kuoppala@intel.com>2014-09-05 18:04:14 +0300
commit4a604dee6003d3c377a2984ce288f7e9b8fdf85b (patch)
treebd51011d7c6b4fbb04e5ebcc23f2a14c4b288dcb /tools/null_state_gen/intel_batchbuffer.h
parentb77145dd489ef4e05799aa734927b9f9e77710d2 (diff)
tools/null_state_gen: build cmd and state space separately
Instead of building batch directly to memory, build into cmd and state arrays. This representation allows us more flexibility in batch state expression and batch generation/relocation. As a bonus, we can also attach the line information that produced the batch data to help debugging. There is no change in the output states produced. This can be considered as a preparatory patch to help introduce gen8 golden state. Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Diffstat (limited to 'tools/null_state_gen/intel_batchbuffer.h')
-rw-r--r--tools/null_state_gen/intel_batchbuffer.h86
1 files changed, 46 insertions, 40 deletions
diff --git a/tools/null_state_gen/intel_batchbuffer.h b/tools/null_state_gen/intel_batchbuffer.h
index f5c29db4..e44c5c9a 100644
--- a/tools/null_state_gen/intel_batchbuffer.h
+++ b/tools/null_state_gen/intel_batchbuffer.h
@@ -34,58 +34,64 @@
#include <stdint.h>
#define MAX_RELOCS 64
+#define MAX_ITEMS 4096
+#define MAX_STRLEN 256
+
#define ALIGN(x, y) (((x) + (y)-1) & ~((y)-1))
-struct intel_batchbuffer {
- int err;
- uint8_t *base;
- uint8_t *base_ptr;
- uint8_t *state_base;
- uint8_t *state_ptr;
- int size;
-
- uint32_t relocs[MAX_RELOCS];
- uint32_t num_relocs;
+typedef enum {
+ UNINITIALIZED,
+ CMD,
+ STATE,
+ RELOC,
+ RELOC_STATE,
+ STATE_OFFSET,
+ PAD,
+} item_type;
+
+struct bb_item {
+ uint32_t data;
+ item_type type;
+ char str[MAX_STRLEN];
};
-#define OUT_BATCH(d) intel_batch_emit_dword(batch, d)
-#define OUT_RELOC(batch, read_domains, write_domain, delta) \
- intel_batch_emit_reloc(batch, delta)
-
-int intel_batch_reset(struct intel_batchbuffer *batch,
- void *p,
- uint32_t size, uint32_t split_off);
-
-uint32_t intel_batch_state_used(struct intel_batchbuffer *batch);
+struct bb_area {
+ struct bb_item item[MAX_ITEMS];
+ unsigned long num_items;
+};
-void *intel_batch_state_alloc(struct intel_batchbuffer *batch,
- uint32_t size,
- uint32_t align);
+struct intel_batchbuffer {
+ struct bb_area *cmds;
+ struct bb_area *state;
+ unsigned long cmds_end_offset;
+ unsigned long state_start_offset;
+};
-int intel_batch_offset(struct intel_batchbuffer *batch, const void *ptr);
+struct intel_batchbuffer *intel_batchbuffer_create(void);
-int intel_batch_state_copy(struct intel_batchbuffer *batch,
- const void *ptr,
- const uint32_t size,
- const uint32_t align);
+#define OUT_BATCH(d) bb_area_emit(batch->cmds, d, CMD, #d)
+#define OUT_BATCH_STATE_OFFSET(d) bb_area_emit(batch->cmds, d, STATE_OFFSET, #d)
+#define OUT_RELOC(batch, read_domain, write_domain, d) bb_area_emit(batch->cmds, d, RELOC, #d)
+#define OUT_RELOC_STATE(batch, read_domain, write_domain, d) bb_area_emit(batch->cmds, d, RELOC_STATE, #d);
+#define OUT_STATE(d) bb_area_emit(batch->state, d, STATE, #d)
+#define OUT_STATE_OFFSET(offset) bb_area_emit(batch->state, offset, STATE_OFFSET, #offset)
+#define OUT_STATE_STRUCT(name, align) intel_batch_state_copy(batch, &name, sizeof(name), align, #name " " #align)
-uint32_t intel_batch_cmds_used(struct intel_batchbuffer *batch);
+uint32_t intel_batch_state_copy(struct intel_batchbuffer *batch, void *d, unsigned bytes, unsigned align,
+ const char *name);
+uint32_t intel_batch_state_alloc(struct intel_batchbuffer *batch, unsigned bytes, unsigned align,
+ const char *name);
-int intel_batch_emit_dword(struct intel_batchbuffer *batch, uint32_t dword);
+unsigned intel_batch_num_cmds(struct intel_batchbuffer *batch);
-int intel_batch_emit_reloc(struct intel_batchbuffer *batch,
- const uint32_t delta);
+struct bb_item *intel_batch_cmd_get(struct intel_batchbuffer *batch, unsigned i);
+int intel_batch_is_reloc(struct intel_batchbuffer *batch, unsigned i);
-uint32_t intel_batch_total_used(struct intel_batchbuffer *batch);
+void intel_batch_relocate_state(struct intel_batchbuffer *batch);
-static inline int intel_batch_error(struct intel_batchbuffer *batch)
-{
- return batch->err;
-}
+const char *intel_batch_type_as_str(const struct bb_item *item);
-static inline uint32_t intel_batch_state_start(struct intel_batchbuffer *batch)
-{
- return batch->state_base - batch->base;
-}
+void bb_area_emit(struct bb_area *a, uint32_t dword, item_type type, const char *str);
+void bb_area_emit_offset(struct bb_area *a, unsigned i, uint32_t dword, item_type type, const char *str);
#endif