1/*
2 * Copyright © 2021 Google, Inc.
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 __CRASHDEC_H__
25#define __CRASHDEC_H__
26
27#include <assert.h>
28#include <getopt.h>
29#include <inttypes.h>
30#include <stdarg.h>
31#include <stdbool.h>
32#include <stdint.h>
33#include <stdio.h>
34#include <stdlib.h>
35#include <string.h>
36#include <unistd.h>
37
38#include "freedreno_pm4.h"
39
40#include "ir3/instr-a3xx.h"
41#include "buffers.h"
42#include "cffdec.h"
43#include "disasm.h"
44#include "pager.h"
45#include "rnnutil.h"
46#include "util.h"
47
48extern struct rnn *rnn_gmu;
49extern struct rnn *rnn_control;
50extern struct rnn *rnn_pipe;
51
52extern bool verbose;
53
54extern struct cffdec_options options;
55
56static inline bool
57is_a6xx(void)
58{
59   return (600 <= options.gpu_id) && (options.gpu_id < 700);
60}
61
62static inline bool
63is_a5xx(void)
64{
65   return (500 <= options.gpu_id) && (options.gpu_id < 600);
66}
67
68static inline bool
69is_64b(void)
70{
71   return options.gpu_id >= 500;
72}
73
74static inline bool
75is_gmu_legacy(void)
76{
77   switch (options.gpu_id) {
78   case 615:
79   case 618:
80   case 630:
81      return true;
82   default:
83      return false;
84   }
85}
86
87void dump_register(struct rnn *rnn, uint32_t offset, uint32_t value);
88void dump_cp_mem_pool(uint32_t *mempool);
89
90struct a6xx_hfi_state {
91   uint64_t iova;
92   void *buf;
93   uint32_t size;
94   int32_t history[2][8];
95};
96void dump_gmu_hfi(struct a6xx_hfi_state *hfi);
97
98#endif /* __CRASHDEC_H__ */
99