Path: blob/21.2-virgl/src/broadcom/clif/clif_private.h
4560 views
/*1* Copyright © 2016-2018 Broadcom2*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*/2223#ifndef CLIF_PRIVATE_H24#define CLIF_PRIVATE_H2526#include <stdint.h>27#include <stdarg.h>28#include "util/list.h"2930struct clif_bo {31const char *name;32uint32_t offset;33uint32_t size;34void *vaddr;35bool dumped;36};3738struct clif_dump {39const struct v3d_device_info *devinfo;40FILE *out;4142struct v3d_spec *spec;4344/* List of struct reloc_worklist_entry */45struct list_head worklist;4647struct clif_bo *bo;48int bo_count;49int bo_array_size;5051/**52* Flag to switch from CLIF ABI to slightly more human-readable53* output.54*/55bool pretty;56};5758enum reloc_worklist_type {59reloc_cl,60reloc_gl_shader_state,61reloc_generic_tile_list,62};6364struct reloc_worklist_entry {65struct list_head link;6667enum reloc_worklist_type type;68uint32_t addr;6970union {71struct {72uint32_t end;73} cl;74struct {75uint32_t num_attrs;76} shader_state;77struct {78uint32_t end;79} generic_tile_list;80};81};8283struct clif_bo *84clif_lookup_bo(struct clif_dump *clif, uint32_t addr);8586struct reloc_worklist_entry *87clif_dump_add_address_to_worklist(struct clif_dump *clif,88enum reloc_worklist_type type,89uint32_t addr);9091bool v3d33_clif_dump_packet(struct clif_dump *clif, uint32_t offset,92const uint8_t *cl, uint32_t *size, bool reloc_mode);93bool v3d41_clif_dump_packet(struct clif_dump *clif, uint32_t offset,94const uint8_t *cl, uint32_t *size, bool reloc_mode);95bool v3d42_clif_dump_packet(struct clif_dump *clif, uint32_t offset,96const uint8_t *cl, uint32_t *size, bool reloc_mode);9798static inline void99out(struct clif_dump *clif, const char *fmt, ...)100{101va_list args;102103va_start(args, fmt);104vfprintf(clif->out, fmt, args);105va_end(args);106}107108static inline void109out_address(struct clif_dump *clif, uint32_t addr)110{111struct clif_bo *bo = clif_lookup_bo(clif, addr);112if (bo) {113out(clif, "[%s+0x%08x] /* 0x%08x */",114bo->name, addr - bo->offset, addr);115} else if (addr) {116out(clif, "/* XXX: BO unknown */ 0x%08x", addr);117} else {118out(clif, "[null]");119}120}121122#endif /* CLIF_PRIVATE_H */123124125