Path: blob/21.2-virgl/src/intel/tools/aub_write.h
4547 views
/*1* Copyright © 2007-2017 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*22*/2324#ifndef INTEL_AUB_WRITE25#define INTEL_AUB_WRITE2627#include <stdarg.h>28#include <stdint.h>29#include <stdio.h>30#include <stdlib.h>3132#include "drm-uapi/i915_drm.h"3334#include "dev/intel_device_info.h"35#include "common/intel_gem.h"3637#ifdef __cplusplus38extern "C" {39#endif4041static inline void PRINTFLIKE(2, 3) NORETURN42_fail(const char *prefix, const char *format, ...)43{44va_list args;4546va_start(args, format);47if (prefix)48fprintf(stderr, "%s: ", prefix);49vfprintf(stderr, format, args);50va_end(args);5152abort();53}5455#define _fail_if(cond, prefix, ...) do { \56if (cond) \57_fail(prefix, __VA_ARGS__); \58} while (0)5960#define MAX_CONTEXT_COUNT 646162struct aub_ppgtt_table {63uint64_t phys_addr;64struct aub_ppgtt_table *subtables[512];65};6667struct aub_hw_context {68bool initialized;69uint64_t ring_addr;70uint64_t pphwsp_addr;71};7273/* GEM context, as seen from userspace */74struct aub_context {75uint32_t id;76struct aub_hw_context hw_contexts[I915_ENGINE_CLASS_VIDEO + 1];77};7879struct aub_file {80FILE *file;8182bool has_default_setup;8384/* Set if you want extra logging */85FILE *verbose_log_file;8687uint16_t pci_id;88struct intel_device_info devinfo;8990int addr_bits;9192struct aub_ppgtt_table pml4;93uint64_t phys_addrs_allocator;94uint64_t ggtt_addrs_allocator;9596struct {97uint64_t hwsp_addr;98} engine_setup[I915_ENGINE_CLASS_VIDEO_ENHANCE + 1];99100struct aub_context contexts[MAX_CONTEXT_COUNT];101int num_contexts;102103uint32_t next_context_handle;104};105106void aub_file_init(struct aub_file *aub, FILE *file, FILE *debug, uint16_t pci_id, const char *app_name);107void aub_file_finish(struct aub_file *aub);108109static inline bool aub_use_execlists(const struct aub_file *aub)110{111return aub->devinfo.ver >= 8;112}113114uint32_t aub_gtt_size(struct aub_file *aub);115116static inline void117aub_write_reloc(const struct intel_device_info *devinfo, void *p, uint64_t v)118{119if (devinfo->ver >= 8) {120*(uint64_t *)p = intel_canonical_address(v);121} else {122*(uint32_t *)p = v;123}124}125126void aub_write_default_setup(struct aub_file *aub);127void aub_map_ppgtt(struct aub_file *aub, uint64_t start, uint64_t size);128void aub_write_ggtt(struct aub_file *aub, uint64_t virt_addr, uint64_t size, const void *data);129void aub_write_trace_block(struct aub_file *aub,130uint32_t type, void *virtual,131uint32_t size, uint64_t gtt_offset);132void aub_write_exec(struct aub_file *aub, uint32_t ctx_id, uint64_t batch_addr,133uint64_t offset, enum drm_i915_gem_engine_class engine_class);134void aub_write_context_execlists(struct aub_file *aub, uint64_t context_addr,135enum drm_i915_gem_engine_class engine_class);136137uint32_t aub_write_context_create(struct aub_file *aub, uint32_t *ctx_id);138139#ifdef __cplusplus140}141#endif142143#endif /* INTEL_AUB_WRITE */144145146