Path: blob/21.2-virgl/src/broadcom/cle/v3d_decoder.h
4560 views
/*1* Copyright © 2016 Intel Corporation2* Copyright © 2017 Broadcom3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING20* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS21* IN THE SOFTWARE.22*/2324#ifndef V3D_DECODER_H25#define V3D_DECODER_H2627#include <stdint.h>28#include <stdio.h>29#include <stdbool.h>3031#include "broadcom/common/v3d_device_info.h"3233struct v3d_spec;34struct v3d_group;35struct v3d_field;36struct clif_dump;3738struct v3d_group *v3d_spec_find_struct(struct v3d_spec *spec, const char *name);39struct v3d_spec *v3d_spec_load(const struct v3d_device_info *devinfo);40struct v3d_group *v3d_spec_find_instruction(struct v3d_spec *spec, const uint8_t *p);41struct v3d_group *v3d_spec_find_register(struct v3d_spec *spec, uint32_t offset);42struct v3d_group *v3d_spec_find_register_by_name(struct v3d_spec *spec, const char *name);43int v3d_group_get_length(struct v3d_group *group);44const char *v3d_group_get_name(struct v3d_group *group);45uint8_t v3d_group_get_opcode(struct v3d_group *group);46struct v3d_enum *v3d_spec_find_enum(struct v3d_spec *spec, const char *name);4748struct v3d_field_iterator {49struct v3d_group *group;50char name[128];51char value[128];52struct v3d_group *struct_desc;53const uint8_t *p;54int offset; /**< current field starts at &p[offset] */5556int field_iter;57int group_iter;5859struct v3d_field *field;60};6162struct v3d_group {63struct v3d_spec *spec;64char *name;6566struct v3d_field **fields;67uint32_t nfields;68uint32_t fields_size;6970uint32_t group_offset, group_count;71uint32_t group_size;72bool variable;7374struct v3d_group *parent;75struct v3d_group *next;7677uint8_t opcode;7879/* Register specific */80uint32_t register_offset;81};8283struct v3d_value {84char *name;85uint64_t value;86};8788struct v3d_enum {89char *name;90int nvalues;91struct v3d_value **values;92};9394struct v3d_type {95enum {96V3D_TYPE_UNKNOWN,97V3D_TYPE_INT,98V3D_TYPE_UINT,99V3D_TYPE_BOOL,100V3D_TYPE_FLOAT,101V3D_TYPE_F187,102V3D_TYPE_ADDRESS,103V3D_TYPE_OFFSET,104V3D_TYPE_STRUCT,105V3D_TYPE_UFIXED,106V3D_TYPE_SFIXED,107V3D_TYPE_MBO,108V3D_TYPE_ENUM109} kind;110111/* Struct definition for V3D_TYPE_STRUCT */112union {113struct v3d_group *v3d_struct;114struct v3d_enum *v3d_enum;115struct {116/* Integer and fractional sizes for V3D_TYPE_UFIXED and117* V3D_TYPE_SFIXED118*/119int i, f;120};121};122};123124struct v3d_field {125char *name;126int start, end;127struct v3d_type type;128bool minus_one;129bool has_default;130uint32_t default_value;131132struct v3d_enum inline_enum;133};134135void v3d_field_iterator_init(struct v3d_field_iterator *iter,136struct v3d_group *group,137const uint8_t *p);138139bool v3d_field_iterator_next(struct clif_dump *clif,140struct v3d_field_iterator *iter);141142void v3d_print_group(struct clif_dump *clif,143struct v3d_group *group,144uint64_t offset, const uint8_t *p);145146#endif /* V3D_DECODER_H */147148149