1f57a6dbad541c9b77d5e07a67229dec48cac643
2 * Copyright © 2016 Broadcom
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:
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
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
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27 #include "clif_dump.h"
28 #include "clif_private.h"
29 #include "util/list.h"
30 #include "util/ralloc.h"
32 #include "broadcom/cle/v3d_decoder.h"
34 struct reloc_worklist_entry
*
35 clif_dump_add_address_to_worklist(struct clif_dump
*clif
,
36 enum reloc_worklist_type type
,
39 struct reloc_worklist_entry
*entry
=
40 rzalloc(clif
, struct reloc_worklist_entry
);
47 list_addtail(&entry
->link
, &clif
->worklist
);
53 clif_dump_init(const struct v3d_device_info
*devinfo
,
55 bool (*lookup_vaddr
)(void *data
, uint32_t addr
, void **vaddr
),
58 struct clif_dump
*clif
= rzalloc(NULL
, struct clif_dump
);
60 clif
->devinfo
= devinfo
;
61 clif
->lookup_vaddr
= lookup_vaddr
;
64 clif
->spec
= v3d_spec_load(devinfo
);
66 list_inithead(&clif
->worklist
);
72 clif_dump_destroy(struct clif_dump
*clif
)
77 #define out_uint(_clif, field) out(_clif, " /* %s = */ %u\n", \
78 #field, values-> field);
81 clif_dump_packet(struct clif_dump
*clif
, uint32_t offset
, const uint8_t *cl
,
84 if (clif
->devinfo
->ver
>= 41)
85 return v3d41_clif_dump_packet(clif
, offset
, cl
, size
);
87 return v3d33_clif_dump_packet(clif
, offset
, cl
, size
);
91 clif_dump_cl(struct clif_dump
*clif
, uint32_t start
, uint32_t end
)
94 if (!clif
->lookup_vaddr(clif
->data
, start
, &start_vaddr
)) {
95 out(clif
, "Failed to look up address 0x%08x\n",
100 /* The end address is optional (for example, a BRANCH instruction
101 * won't set an end), but is used for BCL/RCL termination.
103 void *end_vaddr
= NULL
;
104 if (end
&& !clif
->lookup_vaddr(clif
->data
, end
, &end_vaddr
)) {
105 out(clif
, "Failed to look up address 0x%08x\n",
111 uint8_t *cl
= start_vaddr
;
112 while (clif_dump_packet(clif
, start
, cl
, &size
)) {
122 clif_process_worklist(struct clif_dump
*clif
)
124 while (!list_empty(&clif
->worklist
)) {
125 struct reloc_worklist_entry
*reloc
=
126 list_first_entry(&clif
->worklist
,
127 struct reloc_worklist_entry
, link
);
128 list_del(&reloc
->link
);
131 if (!clif
->lookup_vaddr(clif
->data
, reloc
->addr
, &vaddr
)) {
132 out(clif
, "Failed to look up address 0x%08x\n",
137 switch (reloc
->type
) {
138 case reloc_gl_shader_state
:
139 if (clif
->devinfo
->ver
>= 41) {
140 v3d41_clif_dump_gl_shader_state_record(clif
,
144 v3d33_clif_dump_gl_shader_state_record(clif
,
149 case reloc_generic_tile_list
:
150 clif_dump_cl(clif
, reloc
->addr
,
151 reloc
->generic_tile_list
.end
);
159 clif_dump_add_cl(struct clif_dump
*clif
, uint32_t start
, uint32_t end
)
161 clif_dump_cl(clif
, start
, end
);
164 clif_process_worklist(clif
);