101e04c3fSmrg/* 201e04c3fSmrg * Copyright © 2016 Broadcom 301e04c3fSmrg * 401e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a 501e04c3fSmrg * copy of this software and associated documentation files (the "Software"), 601e04c3fSmrg * to deal in the Software without restriction, including without limitation 701e04c3fSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 801e04c3fSmrg * and/or sell copies of the Software, and to permit persons to whom the 901e04c3fSmrg * Software is furnished to do so, subject to the following conditions: 1001e04c3fSmrg * 1101e04c3fSmrg * The above copyright notice and this permission notice (including the next 1201e04c3fSmrg * paragraph) shall be included in all copies or substantial portions of the 1301e04c3fSmrg * Software. 1401e04c3fSmrg * 1501e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1601e04c3fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1701e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1801e04c3fSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1901e04c3fSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2001e04c3fSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 2101e04c3fSmrg * IN THE SOFTWARE. 2201e04c3fSmrg */ 2301e04c3fSmrg 2401e04c3fSmrg#include <stdio.h> 2501e04c3fSmrg#include <stdlib.h> 2601e04c3fSmrg#include <string.h> 2701e04c3fSmrg#include "drm-uapi/v3d_drm.h" 2801e04c3fSmrg#include "clif_dump.h" 2901e04c3fSmrg#include "clif_private.h" 3001e04c3fSmrg#include "util/list.h" 3101e04c3fSmrg#include "util/ralloc.h" 3201e04c3fSmrg 3301e04c3fSmrg#include "broadcom/cle/v3d_decoder.h" 3401e04c3fSmrg 3501e04c3fSmrgstruct reloc_worklist_entry * 3601e04c3fSmrgclif_dump_add_address_to_worklist(struct clif_dump *clif, 3701e04c3fSmrg enum reloc_worklist_type type, 3801e04c3fSmrg uint32_t addr) 3901e04c3fSmrg{ 4001e04c3fSmrg struct reloc_worklist_entry *entry = 4101e04c3fSmrg rzalloc(clif, struct reloc_worklist_entry); 4201e04c3fSmrg if (!entry) 4301e04c3fSmrg return NULL; 4401e04c3fSmrg 4501e04c3fSmrg entry->type = type; 4601e04c3fSmrg entry->addr = addr; 4701e04c3fSmrg 4801e04c3fSmrg list_addtail(&entry->link, &clif->worklist); 4901e04c3fSmrg 5001e04c3fSmrg return entry; 5101e04c3fSmrg} 5201e04c3fSmrg 5301e04c3fSmrgstruct clif_dump * 5401e04c3fSmrgclif_dump_init(const struct v3d_device_info *devinfo, 557ec681f3Smrg FILE *out, bool pretty, bool nobin) 5601e04c3fSmrg{ 5701e04c3fSmrg struct clif_dump *clif = rzalloc(NULL, struct clif_dump); 5801e04c3fSmrg 5901e04c3fSmrg clif->devinfo = devinfo; 6001e04c3fSmrg clif->out = out; 6101e04c3fSmrg clif->spec = v3d_spec_load(devinfo); 6201e04c3fSmrg clif->pretty = pretty; 637ec681f3Smrg clif->nobin = nobin; 6401e04c3fSmrg 6501e04c3fSmrg list_inithead(&clif->worklist); 6601e04c3fSmrg 6701e04c3fSmrg return clif; 6801e04c3fSmrg} 6901e04c3fSmrg 7001e04c3fSmrgvoid 7101e04c3fSmrgclif_dump_destroy(struct clif_dump *clif) 7201e04c3fSmrg{ 7301e04c3fSmrg ralloc_free(clif); 7401e04c3fSmrg} 7501e04c3fSmrg 7601e04c3fSmrgstruct clif_bo * 7701e04c3fSmrgclif_lookup_bo(struct clif_dump *clif, uint32_t addr) 7801e04c3fSmrg{ 7901e04c3fSmrg for (int i = 0; i < clif->bo_count; i++) { 8001e04c3fSmrg struct clif_bo *bo = &clif->bo[i]; 8101e04c3fSmrg 8201e04c3fSmrg if (addr >= bo->offset && 8301e04c3fSmrg addr < bo->offset + bo->size) { 8401e04c3fSmrg return bo; 8501e04c3fSmrg } 8601e04c3fSmrg } 8701e04c3fSmrg 8801e04c3fSmrg return NULL; 8901e04c3fSmrg} 9001e04c3fSmrg 9101e04c3fSmrgstatic bool 9201e04c3fSmrgclif_lookup_vaddr(struct clif_dump *clif, uint32_t addr, void **vaddr) 9301e04c3fSmrg{ 9401e04c3fSmrg struct clif_bo *bo = clif_lookup_bo(clif, addr); 9501e04c3fSmrg if (!bo) 9601e04c3fSmrg return false; 9701e04c3fSmrg 9801e04c3fSmrg *vaddr = bo->vaddr + addr - bo->offset; 9901e04c3fSmrg return true; 10001e04c3fSmrg} 10101e04c3fSmrg 10201e04c3fSmrg#define out_uint(_clif, field) out(_clif, " /* %s = */ %u\n", \ 10301e04c3fSmrg #field, values-> field); 10401e04c3fSmrg 10501e04c3fSmrgstatic bool 10601e04c3fSmrgclif_dump_packet(struct clif_dump *clif, uint32_t offset, const uint8_t *cl, 10701e04c3fSmrg uint32_t *size, bool reloc_mode) 10801e04c3fSmrg{ 1097ec681f3Smrg if (clif->devinfo->ver >= 42) 1107ec681f3Smrg return v3d42_clif_dump_packet(clif, offset, cl, size, reloc_mode); 1117ec681f3Smrg else if (clif->devinfo->ver >= 41) 11201e04c3fSmrg return v3d41_clif_dump_packet(clif, offset, cl, size, reloc_mode); 11301e04c3fSmrg else 11401e04c3fSmrg return v3d33_clif_dump_packet(clif, offset, cl, size, reloc_mode); 11501e04c3fSmrg} 11601e04c3fSmrg 11701e04c3fSmrgstatic uint32_t 11801e04c3fSmrgclif_dump_cl(struct clif_dump *clif, uint32_t start, uint32_t end, 11901e04c3fSmrg bool reloc_mode) 12001e04c3fSmrg{ 12101e04c3fSmrg struct clif_bo *bo = clif_lookup_bo(clif, start); 12201e04c3fSmrg if (!bo) { 12301e04c3fSmrg out(clif, "Failed to look up address 0x%08x\n", 12401e04c3fSmrg start); 12501e04c3fSmrg return 0; 12601e04c3fSmrg } 12701e04c3fSmrg 12801e04c3fSmrg void *start_vaddr = bo->vaddr + start - bo->offset; 12901e04c3fSmrg 13001e04c3fSmrg /* The end address is optional (for example, a BRANCH instruction 13101e04c3fSmrg * won't set an end), but is used for BCL/RCL termination. 13201e04c3fSmrg */ 13301e04c3fSmrg void *end_vaddr = NULL; 13401e04c3fSmrg if (end && !clif_lookup_vaddr(clif, end, &end_vaddr)) { 13501e04c3fSmrg out(clif, "Failed to look up address 0x%08x\n", 13601e04c3fSmrg end); 13701e04c3fSmrg return 0; 13801e04c3fSmrg } 13901e04c3fSmrg 14001e04c3fSmrg if (!reloc_mode) 14101e04c3fSmrg out(clif, "@format ctrllist /* [%s+0x%08x] */\n", 14201e04c3fSmrg bo->name, start - bo->offset); 14301e04c3fSmrg 14401e04c3fSmrg uint32_t size; 14501e04c3fSmrg uint8_t *cl = start_vaddr; 14601e04c3fSmrg while (clif_dump_packet(clif, start, cl, &size, reloc_mode)) { 14701e04c3fSmrg cl += size; 14801e04c3fSmrg start += size; 14901e04c3fSmrg 15001e04c3fSmrg if (cl == end_vaddr) 15101e04c3fSmrg break; 15201e04c3fSmrg } 15301e04c3fSmrg 15401e04c3fSmrg return (void *)cl - bo->vaddr; 15501e04c3fSmrg} 15601e04c3fSmrg 15701e04c3fSmrg/* Walks the worklist, parsing the relocs for any memory regions that might 15801e04c3fSmrg * themselves have additional relocations. 15901e04c3fSmrg */ 16001e04c3fSmrgstatic uint32_t 16101e04c3fSmrgclif_dump_gl_shader_state_record(struct clif_dump *clif, 16201e04c3fSmrg struct reloc_worklist_entry *reloc, 16301e04c3fSmrg void *vaddr) 16401e04c3fSmrg{ 16501e04c3fSmrg struct v3d_group *state = v3d_spec_find_struct(clif->spec, 16601e04c3fSmrg "GL Shader State Record"); 16701e04c3fSmrg struct v3d_group *attr = v3d_spec_find_struct(clif->spec, 16801e04c3fSmrg "GL Shader State Attribute Record"); 16901e04c3fSmrg assert(state); 17001e04c3fSmrg assert(attr); 17101e04c3fSmrg uint32_t offset = 0; 17201e04c3fSmrg 17301e04c3fSmrg out(clif, "@format shadrec_gl_main\n"); 17401e04c3fSmrg v3d_print_group(clif, state, 0, vaddr + offset); 17501e04c3fSmrg offset += v3d_group_get_length(state); 17601e04c3fSmrg 17701e04c3fSmrg for (int i = 0; i < reloc->shader_state.num_attrs; i++) { 17801e04c3fSmrg out(clif, "@format shadrec_gl_attr /* %d */\n", i); 17901e04c3fSmrg v3d_print_group(clif, attr, 0, vaddr + offset); 18001e04c3fSmrg offset += v3d_group_get_length(attr); 18101e04c3fSmrg } 18201e04c3fSmrg 18301e04c3fSmrg return offset; 18401e04c3fSmrg} 18501e04c3fSmrg 18601e04c3fSmrgstatic void 18701e04c3fSmrgclif_process_worklist(struct clif_dump *clif) 18801e04c3fSmrg{ 18901e04c3fSmrg list_for_each_entry_safe(struct reloc_worklist_entry, reloc, 19001e04c3fSmrg &clif->worklist, link) { 19101e04c3fSmrg void *vaddr; 19201e04c3fSmrg if (!clif_lookup_vaddr(clif, reloc->addr, &vaddr)) { 19301e04c3fSmrg out(clif, "Failed to look up address 0x%08x\n", 19401e04c3fSmrg reloc->addr); 19501e04c3fSmrg continue; 19601e04c3fSmrg } 19701e04c3fSmrg 19801e04c3fSmrg switch (reloc->type) { 19901e04c3fSmrg case reloc_cl: 20001e04c3fSmrg clif_dump_cl(clif, reloc->addr, reloc->cl.end, true); 20101e04c3fSmrg break; 20201e04c3fSmrg 20301e04c3fSmrg case reloc_gl_shader_state: 20401e04c3fSmrg break; 20501e04c3fSmrg case reloc_generic_tile_list: 20601e04c3fSmrg clif_dump_cl(clif, reloc->addr, 20701e04c3fSmrg reloc->generic_tile_list.end, true); 20801e04c3fSmrg break; 20901e04c3fSmrg } 21001e04c3fSmrg } 21101e04c3fSmrg} 21201e04c3fSmrg 21301e04c3fSmrgstatic int 21401e04c3fSmrgworklist_entry_compare(const void *a, const void *b) 21501e04c3fSmrg{ 21601e04c3fSmrg return ((*(struct reloc_worklist_entry **)a)->addr - 21701e04c3fSmrg (*(struct reloc_worklist_entry **)b)->addr); 21801e04c3fSmrg} 21901e04c3fSmrg 22001e04c3fSmrgstatic bool 22101e04c3fSmrgclif_dump_if_blank(struct clif_dump *clif, struct clif_bo *bo, 22201e04c3fSmrg uint32_t start, uint32_t end) 22301e04c3fSmrg{ 22401e04c3fSmrg for (int i = start; i < end; i++) { 22501e04c3fSmrg if (((uint8_t *)bo->vaddr)[i] != 0) 22601e04c3fSmrg return false; 22701e04c3fSmrg } 22801e04c3fSmrg 22901e04c3fSmrg out(clif, "\n"); 23001e04c3fSmrg out(clif, "@format blank %d /* [%s+0x%08x..0x%08x] */\n", end - start, 23101e04c3fSmrg bo->name, start, end - 1); 23201e04c3fSmrg return true; 23301e04c3fSmrg} 23401e04c3fSmrg 23501e04c3fSmrg/* Dumps the binary data in the BO from start to end (relative to the start of 23601e04c3fSmrg * the BO). 23701e04c3fSmrg */ 23801e04c3fSmrgstatic void 23901e04c3fSmrgclif_dump_binary(struct clif_dump *clif, struct clif_bo *bo, 24001e04c3fSmrg uint32_t start, uint32_t end) 24101e04c3fSmrg{ 2427ec681f3Smrg if (clif->pretty && clif->nobin) 2437ec681f3Smrg return; 2447ec681f3Smrg 24501e04c3fSmrg if (start == end) 24601e04c3fSmrg return; 24701e04c3fSmrg 24801e04c3fSmrg if (clif_dump_if_blank(clif, bo, start, end)) 24901e04c3fSmrg return; 25001e04c3fSmrg 25101e04c3fSmrg out(clif, "@format binary /* [%s+0x%08x] */\n", 25201e04c3fSmrg bo->name, start); 25301e04c3fSmrg 25401e04c3fSmrg uint32_t offset = start; 25501e04c3fSmrg int dumped_in_line = 0; 25601e04c3fSmrg while (offset < end) { 25701e04c3fSmrg if (clif_dump_if_blank(clif, bo, offset, end)) 25801e04c3fSmrg return; 25901e04c3fSmrg 26001e04c3fSmrg if (end - offset >= 4) { 26101e04c3fSmrg out(clif, "0x%08x ", *(uint32_t *)(bo->vaddr + offset)); 26201e04c3fSmrg offset += 4; 26301e04c3fSmrg } else { 26401e04c3fSmrg out(clif, "0x%02x ", *(uint8_t *)(bo->vaddr + offset)); 26501e04c3fSmrg offset++; 26601e04c3fSmrg } 26701e04c3fSmrg 26801e04c3fSmrg if (++dumped_in_line == 8) { 26901e04c3fSmrg out(clif, "\n"); 27001e04c3fSmrg dumped_in_line = 0; 27101e04c3fSmrg } 27201e04c3fSmrg } 27301e04c3fSmrg if (dumped_in_line) 27401e04c3fSmrg out(clif, "\n"); 27501e04c3fSmrg} 27601e04c3fSmrg 27701e04c3fSmrg/* Walks the list of relocations, dumping each buffer's contents (using our 27801e04c3fSmrg * codegenned dump routines for pretty printing, and most importantly proper 27901e04c3fSmrg * address references so that the CLIF parser can relocate buffers). 28001e04c3fSmrg */ 28101e04c3fSmrgstatic void 28201e04c3fSmrgclif_dump_buffers(struct clif_dump *clif) 28301e04c3fSmrg{ 28401e04c3fSmrg int num_relocs = 0; 28501e04c3fSmrg list_for_each_entry(struct reloc_worklist_entry, reloc, 28601e04c3fSmrg &clif->worklist, link) { 28701e04c3fSmrg num_relocs++; 28801e04c3fSmrg } 28901e04c3fSmrg struct reloc_worklist_entry **relocs = 29001e04c3fSmrg ralloc_array(clif, struct reloc_worklist_entry *, num_relocs); 29101e04c3fSmrg int i = 0; 29201e04c3fSmrg list_for_each_entry(struct reloc_worklist_entry, reloc, 29301e04c3fSmrg &clif->worklist, link) { 29401e04c3fSmrg relocs[i++] = reloc; 29501e04c3fSmrg } 29601e04c3fSmrg qsort(relocs, num_relocs, sizeof(*relocs), worklist_entry_compare); 29701e04c3fSmrg 29801e04c3fSmrg struct clif_bo *bo = NULL; 29901e04c3fSmrg uint32_t offset = 0; 30001e04c3fSmrg 30101e04c3fSmrg for (i = 0; i < num_relocs; i++) { 30201e04c3fSmrg struct reloc_worklist_entry *reloc = relocs[i]; 30301e04c3fSmrg struct clif_bo *new_bo = clif_lookup_bo(clif, reloc->addr); 30401e04c3fSmrg 30501e04c3fSmrg if (!new_bo) { 30601e04c3fSmrg out(clif, "Failed to look up address 0x%08x\n", 30701e04c3fSmrg reloc->addr); 30801e04c3fSmrg continue; 30901e04c3fSmrg } 31001e04c3fSmrg 31101e04c3fSmrg if (new_bo != bo) { 31201e04c3fSmrg if (bo) { 31301e04c3fSmrg /* Finish out the last of the last BO. */ 31401e04c3fSmrg clif_dump_binary(clif, bo, 31501e04c3fSmrg offset, 31601e04c3fSmrg bo->size); 31701e04c3fSmrg } 31801e04c3fSmrg 31901e04c3fSmrg out(clif, "\n"); 32001e04c3fSmrg out(clif, "@buffer %s\n", new_bo->name); 32101e04c3fSmrg bo = new_bo; 32201e04c3fSmrg offset = 0; 32301e04c3fSmrg bo->dumped = true; 32401e04c3fSmrg } 32501e04c3fSmrg 32601e04c3fSmrg int reloc_offset = reloc->addr - bo->offset; 32701e04c3fSmrg if (offset != reloc_offset) 32801e04c3fSmrg clif_dump_binary(clif, bo, offset, reloc_offset); 32901e04c3fSmrg offset = reloc_offset; 33001e04c3fSmrg 33101e04c3fSmrg switch (reloc->type) { 33201e04c3fSmrg case reloc_cl: 33301e04c3fSmrg offset = clif_dump_cl(clif, reloc->addr, reloc->cl.end, 33401e04c3fSmrg false); 33501e04c3fSmrg out(clif, "\n"); 33601e04c3fSmrg break; 33701e04c3fSmrg 33801e04c3fSmrg case reloc_gl_shader_state: 33901e04c3fSmrg offset += clif_dump_gl_shader_state_record(clif, 34001e04c3fSmrg reloc, 34101e04c3fSmrg bo->vaddr + 34201e04c3fSmrg offset); 34301e04c3fSmrg break; 34401e04c3fSmrg case reloc_generic_tile_list: 34501e04c3fSmrg offset = clif_dump_cl(clif, reloc->addr, 34601e04c3fSmrg reloc->generic_tile_list.end, 34701e04c3fSmrg false); 34801e04c3fSmrg break; 34901e04c3fSmrg } 35001e04c3fSmrg out(clif, "\n"); 35101e04c3fSmrg } 35201e04c3fSmrg 35301e04c3fSmrg if (bo) { 35401e04c3fSmrg clif_dump_binary(clif, bo, offset, bo->size); 35501e04c3fSmrg } 35601e04c3fSmrg 35701e04c3fSmrg /* For any BOs that didn't have relocations, just dump them raw. */ 35801e04c3fSmrg for (int i = 0; i < clif->bo_count; i++) { 35901e04c3fSmrg bo = &clif->bo[i]; 36001e04c3fSmrg if (bo->dumped) 36101e04c3fSmrg continue; 36201e04c3fSmrg out(clif, "@buffer %s\n", bo->name); 36301e04c3fSmrg clif_dump_binary(clif, bo, 0, bo->size); 36401e04c3fSmrg out(clif, "\n"); 36501e04c3fSmrg } 36601e04c3fSmrg} 36701e04c3fSmrg 36801e04c3fSmrgvoid 36901e04c3fSmrgclif_dump_add_cl(struct clif_dump *clif, uint32_t start, uint32_t end) 37001e04c3fSmrg{ 37101e04c3fSmrg struct reloc_worklist_entry *entry = 37201e04c3fSmrg clif_dump_add_address_to_worklist(clif, reloc_cl, start); 37301e04c3fSmrg 37401e04c3fSmrg entry->cl.end = end; 37501e04c3fSmrg} 37601e04c3fSmrg 37701e04c3fSmrgstatic int 37801e04c3fSmrgclif_bo_offset_compare(const void *a, const void *b) 37901e04c3fSmrg{ 38001e04c3fSmrg return ((struct clif_bo *)a)->offset - ((struct clif_bo *)b)->offset; 38101e04c3fSmrg} 38201e04c3fSmrg 38301e04c3fSmrgvoid 38401e04c3fSmrgclif_dump(struct clif_dump *clif, const struct drm_v3d_submit_cl *submit) 38501e04c3fSmrg{ 38601e04c3fSmrg clif_dump_add_cl(clif, submit->bcl_start, submit->bcl_end); 38701e04c3fSmrg clif_dump_add_cl(clif, submit->rcl_start, submit->rcl_end); 38801e04c3fSmrg 38901e04c3fSmrg qsort(clif->bo, clif->bo_count, sizeof(clif->bo[0]), 39001e04c3fSmrg clif_bo_offset_compare); 39101e04c3fSmrg 39201e04c3fSmrg /* A buffer needs to be defined before we can emit a CLIF address 39301e04c3fSmrg * referencing it, so emit them all now. 39401e04c3fSmrg */ 39501e04c3fSmrg for (int i = 0; i < clif->bo_count; i++) { 39601e04c3fSmrg out(clif, "@createbuf_aligned 4096 %s\n", clif->bo[i].name); 39701e04c3fSmrg } 39801e04c3fSmrg 39901e04c3fSmrg /* Walk the worklist figuring out the locations of structs based on 40001e04c3fSmrg * the CL contents. 40101e04c3fSmrg */ 40201e04c3fSmrg clif_process_worklist(clif); 40301e04c3fSmrg 40401e04c3fSmrg /* Dump the contents of the buffers using the relocations we found to 40501e04c3fSmrg * pretty-print structures. 40601e04c3fSmrg */ 40701e04c3fSmrg clif_dump_buffers(clif); 40801e04c3fSmrg 40901e04c3fSmrg out(clif, "@add_bin 0\n "); 41001e04c3fSmrg out_address(clif, submit->bcl_start); 41101e04c3fSmrg out(clif, "\n "); 41201e04c3fSmrg out_address(clif, submit->bcl_end); 41301e04c3fSmrg out(clif, "\n "); 41401e04c3fSmrg out_address(clif, submit->qma); 41501e04c3fSmrg out(clif, "\n %d\n ", submit->qms); 41601e04c3fSmrg out_address(clif, submit->qts); 41701e04c3fSmrg out(clif, "\n"); 41801e04c3fSmrg out(clif, "@wait_bin_all_cores\n"); 41901e04c3fSmrg 42001e04c3fSmrg out(clif, "@add_render 0\n "); 42101e04c3fSmrg out_address(clif, submit->rcl_start); 42201e04c3fSmrg out(clif, "\n "); 42301e04c3fSmrg out_address(clif, submit->rcl_end); 42401e04c3fSmrg out(clif, "\n "); 42501e04c3fSmrg out_address(clif, submit->qma); 42601e04c3fSmrg out(clif, "\n"); 42701e04c3fSmrg out(clif, "@wait_render_all_cores\n"); 42801e04c3fSmrg} 42901e04c3fSmrg 43001e04c3fSmrgvoid 43101e04c3fSmrgclif_dump_add_bo(struct clif_dump *clif, const char *name, 43201e04c3fSmrg uint32_t offset, uint32_t size, void *vaddr) 43301e04c3fSmrg{ 43401e04c3fSmrg if (clif->bo_count >= clif->bo_array_size) { 43501e04c3fSmrg clif->bo_array_size = MAX2(4, clif->bo_array_size * 2); 43601e04c3fSmrg clif->bo = reralloc(clif, clif->bo, struct clif_bo, 43701e04c3fSmrg clif->bo_array_size); 43801e04c3fSmrg } 43901e04c3fSmrg 44001e04c3fSmrg /* CLIF relocs use the buffer name, so make sure they're unique. */ 44101e04c3fSmrg for (int i = 0; i < clif->bo_count; i++) 44201e04c3fSmrg assert(strcmp(clif->bo[i].name, name) != 0); 44301e04c3fSmrg 44401e04c3fSmrg clif->bo[clif->bo_count].name = ralloc_strdup(clif, name); 44501e04c3fSmrg clif->bo[clif->bo_count].offset = offset; 44601e04c3fSmrg clif->bo[clif->bo_count].size = size; 44701e04c3fSmrg clif->bo[clif->bo_count].vaddr = vaddr; 44801e04c3fSmrg clif->bo[clif->bo_count].dumped = false; 44901e04c3fSmrg clif->bo_count++; 45001e04c3fSmrg} 451