Home | History | Annotate | Line # | Download | only in decode
      1 /*
      2  * Copyright (c) 2012 Rob Clark <robdclark (at) gmail.com>
      3  *
      4  * Permission is hereby granted, free of charge, to any person obtaining a
      5  * copy of this software and associated documentation files (the "Software"),
      6  * to deal in the Software without restriction, including without limitation
      7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      8  * and/or sell copies of the Software, and to permit persons to whom the
      9  * Software is furnished to do so, subject to the following conditions:
     10  *
     11  * The above copyright notice and this permission notice (including the next
     12  * paragraph) shall be included in all copies or substantial portions of the
     13  * Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     21  * SOFTWARE.
     22  */
     23 
     24 #ifndef __CFFDEC_H__
     25 #define __CFFDEC_H__
     26 
     27 #include <stdbool.h>
     28 
     29 enum query_mode {
     30    /* default mode, dump all queried regs on each draw: */
     31    QUERY_ALL = 0,
     32 
     33    /* only dump if any of the queried regs were written
     34     * since last draw:
     35     */
     36    QUERY_WRITTEN,
     37 
     38    /* only dump if any of the queried regs changed since
     39     * last draw:
     40     */
     41    QUERY_DELTA,
     42 };
     43 
     44 struct cffdec_options {
     45    unsigned gpu_id;
     46    int draw_filter;
     47    int color;
     48    int dump_shaders;
     49    int summary;
     50    int allregs;
     51    int dump_textures;
     52    int decode_markers;
     53    char *script;
     54 
     55    int query_compare; /* binning vs SYSMEM/GMEM compare mode */
     56    int query_mode;    /* enum query_mode */
     57    char **querystrs;
     58    int nquery;
     59 
     60    /* In "once" mode, only decode a cmdstream buffer once (per draw
     61     * mode, in the case of a6xx+ where a single cmdstream buffer can
     62     * be used for both binning and draw pass), rather than each time
     63     * encountered (ie. once per tile/bin in GMEM draw passes)
     64     */
     65    int once;
     66 
     67    /* In unit_test mode, suppress pathnames in output so that we can have references
     68     * independent of the build dir.
     69     */
     70    int unit_test;
     71 
     72    /* for crashdec, where we know CP_IBx_REM_SIZE, we can use this
     73     * to highlight the cmdstream not parsed yet, to make it easier
     74     * to see how far along the CP is.
     75     */
     76    struct {
     77       uint64_t base;
     78       uint32_t rem;
     79    } ibs[4];
     80 };
     81 
     82 void printl(int lvl, const char *fmt, ...);
     83 const char *pktname(unsigned opc);
     84 uint32_t regbase(const char *name);
     85 const char *regname(uint32_t regbase, int color);
     86 bool reg_written(uint32_t regbase);
     87 uint32_t reg_lastval(uint32_t regbase);
     88 uint32_t reg_val(uint32_t regbase);
     89 void reg_set(uint32_t regbase, uint32_t val);
     90 void reset_regs(void);
     91 void cffdec_init(const struct cffdec_options *options);
     92 void dump_register_val(uint32_t regbase, uint32_t dword, int level);
     93 void dump_commands(uint32_t *dwords, uint32_t sizedwords, int level);
     94 
     95 #endif /* __CFFDEC_H__ */
     96