1/* 2 * Copyright © 2014 Broadcom 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 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24#include "util/u_math.h" 25#include "util/u_prim.h" 26#include "util/macros.h" 27#include "vc4_cl_dump.h" 28#include "kernel/vc4_packet.h" 29 30#include "broadcom/cle/v3d_decoder.h" 31#include "broadcom/clif/clif_dump.h" 32 33void 34vc4_dump_cl(void *cl, uint32_t size, bool is_render) 35{ 36 struct v3d_device_info devinfo = { 37 /* While the driver supports V3D 2.1 and 2.6, we haven't split 38 * off a 2.6 XML yet (there are a couple of fields different 39 * in render target formatting) 40 */ 41 .ver = 21, 42 }; 43 struct v3d_spec *spec = v3d_spec_load(&devinfo); 44 45 struct clif_dump *clif = clif_dump_init(&devinfo, stderr, true, false); 46 47 uint32_t offset = 0, hw_offset = 0; 48 uint8_t *p = cl; 49 50 while (offset < size) { 51 struct v3d_group *inst = v3d_spec_find_instruction(spec, p); 52 uint8_t header = *p; 53 uint32_t length; 54 55 if (inst == NULL) { 56 fprintf(stderr, "0x%08x 0x%08x: Unknown packet 0x%02x (%d)!\n", 57 offset, hw_offset, header, header); 58 return; 59 } 60 61 length = v3d_group_get_length(inst); 62 63 fprintf(stderr, "0x%08x 0x%08x: 0x%02x %s\n", 64 offset, hw_offset, header, v3d_group_get_name(inst)); 65 66 v3d_print_group(clif, inst, offset, p); 67 68 switch (header) { 69 case VC4_PACKET_HALT: 70 case VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF: 71 return; 72 default: 73 break; 74 } 75 76 offset += length; 77 if (header != VC4_PACKET_GEM_HANDLES) 78 hw_offset += length; 79 p += length; 80 } 81 82 clif_dump_destroy(clif); 83} 84 85