1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright(C) 2015-2018 Linaro Limited. 4 * 5 * Author: Tor Jeremiassen <tor@ti.com> 6 * Author: Mathieu Poirier <mathieu.poirier@linaro.org> 7 */ 8 9 #include <linux/err.h> 10 #include <linux/list.h> 11 #include <stdlib.h> 12 #include <opencsd/c_api/opencsd_c_api.h> 13 #include <opencsd/etmv4/trc_pkt_types_etmv4.h> 14 #include <opencsd/ocsd_if_types.h> 15 16 #include "cs-etm.h" 17 #include "cs-etm-decoder.h" 18 #include "intlist.h" 19 #include "util.h" 20 21 #define MAX_BUFFER 1024 22 23 /* use raw logging */ 24 #ifdef CS_DEBUG_RAW 25 #define CS_LOG_RAW_FRAMES 26 #ifdef CS_RAW_PACKED 27 #define CS_RAW_DEBUG_FLAGS (OCSD_DFRMTR_UNPACKED_RAW_OUT | \ 28 OCSD_DFRMTR_PACKED_RAW_OUT) 29 #else 30 #define CS_RAW_DEBUG_FLAGS (OCSD_DFRMTR_UNPACKED_RAW_OUT) 31 #endif 32 #endif 33 34 #define CS_ETM_INVAL_ADDR 0xdeadbeefdeadbeefUL 35 36 struct cs_etm_decoder { 37 void *data; 38 void (*packet_printer)(const char *msg); 39 dcd_tree_handle_t dcd_tree; 40 cs_etm_mem_cb_type mem_access; 41 ocsd_datapath_resp_t prev_return; 42 u32 packet_count; 43 u32 head; 44 u32 tail; 45 struct cs_etm_packet packet_buffer[MAX_BUFFER]; 46 }; 47 48 static u32 49 cs_etm_decoder__mem_access(const void *context, 50 const ocsd_vaddr_t address, 51 const ocsd_mem_space_acc_t mem_space __maybe_unused, 52 const u32 req_size, 53 u8 *buffer) 54 { 55 struct cs_etm_decoder *decoder = (struct cs_etm_decoder *) context; 56 57 return decoder->mem_access(decoder->data, 58 address, 59 req_size, 60 buffer); 61 } 62 63 int cs_etm_decoder__add_mem_access_cb(struct cs_etm_decoder *decoder, 64 u64 start, u64 end, 65 cs_etm_mem_cb_type cb_func) 66 { 67 decoder->mem_access = cb_func; 68 69 if (ocsd_dt_add_callback_mem_acc(decoder->dcd_tree, start, end, 70 OCSD_MEM_SPACE_ANY, 71 cs_etm_decoder__mem_access, decoder)) 72 return -1; 73 74 return 0; 75 } 76 77 int cs_etm_decoder__reset(struct cs_etm_decoder *decoder) 78 { 79 ocsd_datapath_resp_t dp_ret; 80 81 decoder->prev_return = OCSD_RESP_CONT; 82 83 dp_ret = ocsd_dt_process_data(decoder->dcd_tree, OCSD_OP_RESET, 84 0, 0, NULL, NULL); 85 if (OCSD_DATA_RESP_IS_FATAL(dp_ret)) 86 return -1; 87 88 return 0; 89 } 90 91 int cs_etm_decoder__get_packet(struct cs_etm_decoder *decoder, 92 struct cs_etm_packet *packet) 93 { 94 if (!decoder || !packet) 95 return -EINVAL; 96 97 /* Nothing to do, might as well just return */ 98 if (decoder->packet_count == 0) 99 return 0; 100 /* 101 * The queueing process in function cs_etm_decoder__buffer_packet() 102 * increments the tail *before* using it. This is somewhat counter 103 * intuitive but it has the advantage of centralizing tail management 104 * at a single location. Because of that we need to follow the same 105 * heuristic with the head, i.e we increment it before using its 106 * value. Otherwise the first element of the packet queue is not 107 * used. 108 */ 109 decoder->head = (decoder->head + 1) & (MAX_BUFFER - 1); 110 111 *packet = decoder->packet_buffer[decoder->head]; 112 113 decoder->packet_count--; 114 115 return 1; 116 } 117 118 static int cs_etm_decoder__gen_etmv3_config(struct cs_etm_trace_params *params, 119 ocsd_etmv3_cfg *config) 120 { 121 config->reg_idr = params->etmv3.reg_idr; 122 config->reg_ctrl = params->etmv3.reg_ctrl; 123 config->reg_ccer = params->etmv3.reg_ccer; 124 config->reg_trc_id = params->etmv3.reg_trc_id; 125 config->arch_ver = ARCH_V7; 126 config->core_prof = profile_CortexA; 127 128 return 0; 129 } 130 131 static void cs_etm_decoder__gen_etmv4_config(struct cs_etm_trace_params *params, 132 ocsd_etmv4_cfg *config) 133 { 134 config->reg_configr = params->etmv4.reg_configr; 135 config->reg_traceidr = params->etmv4.reg_traceidr; 136 config->reg_idr0 = params->etmv4.reg_idr0; 137 config->reg_idr1 = params->etmv4.reg_idr1; 138 config->reg_idr2 = params->etmv4.reg_idr2; 139 config->reg_idr8 = params->etmv4.reg_idr8; 140 config->reg_idr9 = 0; 141 config->reg_idr10 = 0; 142 config->reg_idr11 = 0; 143 config->reg_idr12 = 0; 144 config->reg_idr13 = 0; 145 config->arch_ver = ARCH_V8; 146 config->core_prof = profile_CortexA; 147 } 148 149 static void cs_etm_decoder__print_str_cb(const void *p_context, 150 const char *msg, 151 const int str_len) 152 { 153 if (p_context && str_len) 154 ((struct cs_etm_decoder *)p_context)->packet_printer(msg); 155 } 156 157 static int 158 cs_etm_decoder__init_def_logger_printing(struct cs_etm_decoder_params *d_params, 159 struct cs_etm_decoder *decoder) 160 { 161 int ret = 0; 162 163 if (d_params->packet_printer == NULL) 164 return -1; 165 166 decoder->packet_printer = d_params->packet_printer; 167 168 /* 169 * Set up a library default logger to process any printers 170 * (packet/raw frame) we add later. 171 */ 172 ret = ocsd_def_errlog_init(OCSD_ERR_SEV_ERROR, 1); 173 if (ret != 0) 174 return -1; 175 176 /* no stdout / err / file output */ 177 ret = ocsd_def_errlog_config_output(C_API_MSGLOGOUT_FLG_NONE, NULL); 178 if (ret != 0) 179 return -1; 180 181 /* 182 * Set the string CB for the default logger, passes strings to 183 * perf print logger. 184 */ 185 ret = ocsd_def_errlog_set_strprint_cb(decoder->dcd_tree, 186 (void *)decoder, 187 cs_etm_decoder__print_str_cb); 188 if (ret != 0) 189 ret = -1; 190 191 return 0; 192 } 193 194 #ifdef CS_LOG_RAW_FRAMES 195 static void 196 cs_etm_decoder__init_raw_frame_logging(struct cs_etm_decoder_params *d_params, 197 struct cs_etm_decoder *decoder) 198 { 199 /* Only log these during a --dump operation */ 200 if (d_params->operation == CS_ETM_OPERATION_PRINT) { 201 /* set up a library default logger to process the 202 * raw frame printer we add later 203 */ 204 ocsd_def_errlog_init(OCSD_ERR_SEV_ERROR, 1); 205 206 /* no stdout / err / file output */ 207 ocsd_def_errlog_config_output(C_API_MSGLOGOUT_FLG_NONE, NULL); 208 209 /* set the string CB for the default logger, 210 * passes strings to perf print logger. 211 */ 212 ocsd_def_errlog_set_strprint_cb(decoder->dcd_tree, 213 (void *)decoder, 214 cs_etm_decoder__print_str_cb); 215 216 /* use the built in library printer for the raw frames */ 217 ocsd_dt_set_raw_frame_printer(decoder->dcd_tree, 218 CS_RAW_DEBUG_FLAGS); 219 } 220 } 221 #else 222 static void 223 cs_etm_decoder__init_raw_frame_logging( 224 struct cs_etm_decoder_params *d_params __maybe_unused, 225 struct cs_etm_decoder *decoder __maybe_unused) 226 { 227 } 228 #endif 229 230 static int cs_etm_decoder__create_packet_printer(struct cs_etm_decoder *decoder, 231 const char *decoder_name, 232 void *trace_config) 233 { 234 u8 csid; 235 236 if (ocsd_dt_create_decoder(decoder->dcd_tree, decoder_name, 237 OCSD_CREATE_FLG_PACKET_PROC, 238 trace_config, &csid)) 239 return -1; 240 241 if (ocsd_dt_set_pkt_protocol_printer(decoder->dcd_tree, csid, 0)) 242 return -1; 243 244 return 0; 245 } 246 247 static int 248 cs_etm_decoder__create_etm_packet_printer(struct cs_etm_trace_params *t_params, 249 struct cs_etm_decoder *decoder) 250 { 251 const char *decoder_name; 252 ocsd_etmv3_cfg config_etmv3; 253 ocsd_etmv4_cfg trace_config_etmv4; 254 void *trace_config; 255 256 switch (t_params->protocol) { 257 case CS_ETM_PROTO_ETMV3: 258 case CS_ETM_PROTO_PTM: 259 cs_etm_decoder__gen_etmv3_config(t_params, &config_etmv3); 260 decoder_name = (t_params->protocol == CS_ETM_PROTO_ETMV3) ? 261 OCSD_BUILTIN_DCD_ETMV3 : 262 OCSD_BUILTIN_DCD_PTM; 263 trace_config = &config_etmv3; 264 break; 265 case CS_ETM_PROTO_ETMV4i: 266 cs_etm_decoder__gen_etmv4_config(t_params, &trace_config_etmv4); 267 decoder_name = OCSD_BUILTIN_DCD_ETMV4I; 268 trace_config = &trace_config_etmv4; 269 break; 270 default: 271 return -1; 272 } 273 274 return cs_etm_decoder__create_packet_printer(decoder, 275 decoder_name, 276 trace_config); 277 } 278 279 static void cs_etm_decoder__clear_buffer(struct cs_etm_decoder *decoder) 280 { 281 int i; 282 283 decoder->head = 0; 284 decoder->tail = 0; 285 decoder->packet_count = 0; 286 for (i = 0; i < MAX_BUFFER; i++) { 287 decoder->packet_buffer[i].isa = CS_ETM_ISA_UNKNOWN; 288 decoder->packet_buffer[i].start_addr = CS_ETM_INVAL_ADDR; 289 decoder->packet_buffer[i].end_addr = CS_ETM_INVAL_ADDR; 290 decoder->packet_buffer[i].instr_count = 0; 291 decoder->packet_buffer[i].last_instr_taken_branch = false; 292 decoder->packet_buffer[i].last_instr_size = 0; 293 decoder->packet_buffer[i].last_instr_type = 0; 294 decoder->packet_buffer[i].last_instr_subtype = 0; 295 decoder->packet_buffer[i].last_instr_cond = 0; 296 decoder->packet_buffer[i].flags = 0; 297 decoder->packet_buffer[i].exception_number = UINT32_MAX; 298 decoder->packet_buffer[i].trace_chan_id = UINT8_MAX; 299 decoder->packet_buffer[i].cpu = INT_MIN; 300 } 301 } 302 303 static ocsd_datapath_resp_t 304 cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder, 305 const u8 trace_chan_id, 306 enum cs_etm_sample_type sample_type) 307 { 308 u32 et = 0; 309 int cpu; 310 311 if (decoder->packet_count >= MAX_BUFFER - 1) 312 return OCSD_RESP_FATAL_SYS_ERR; 313 314 if (cs_etm__get_cpu(trace_chan_id, &cpu) < 0) 315 return OCSD_RESP_FATAL_SYS_ERR; 316 317 et = decoder->tail; 318 et = (et + 1) & (MAX_BUFFER - 1); 319 decoder->tail = et; 320 decoder->packet_count++; 321 322 decoder->packet_buffer[et].sample_type = sample_type; 323 decoder->packet_buffer[et].isa = CS_ETM_ISA_UNKNOWN; 324 decoder->packet_buffer[et].cpu = cpu; 325 decoder->packet_buffer[et].start_addr = CS_ETM_INVAL_ADDR; 326 decoder->packet_buffer[et].end_addr = CS_ETM_INVAL_ADDR; 327 decoder->packet_buffer[et].instr_count = 0; 328 decoder->packet_buffer[et].last_instr_taken_branch = false; 329 decoder->packet_buffer[et].last_instr_size = 0; 330 decoder->packet_buffer[et].last_instr_type = 0; 331 decoder->packet_buffer[et].last_instr_subtype = 0; 332 decoder->packet_buffer[et].last_instr_cond = 0; 333 decoder->packet_buffer[et].flags = 0; 334 decoder->packet_buffer[et].exception_number = UINT32_MAX; 335 decoder->packet_buffer[et].trace_chan_id = trace_chan_id; 336 337 if (decoder->packet_count == MAX_BUFFER - 1) 338 return OCSD_RESP_WAIT; 339 340 return OCSD_RESP_CONT; 341 } 342 343 static ocsd_datapath_resp_t 344 cs_etm_decoder__buffer_range(struct cs_etm_decoder *decoder, 345 const ocsd_generic_trace_elem *elem, 346 const uint8_t trace_chan_id) 347 { 348 int ret = 0; 349 struct cs_etm_packet *packet; 350 351 ret = cs_etm_decoder__buffer_packet(decoder, trace_chan_id, 352 CS_ETM_RANGE); 353 if (ret != OCSD_RESP_CONT && ret != OCSD_RESP_WAIT) 354 return ret; 355 356 packet = &decoder->packet_buffer[decoder->tail]; 357 358 switch (elem->isa) { 359 case ocsd_isa_aarch64: 360 packet->isa = CS_ETM_ISA_A64; 361 break; 362 case ocsd_isa_arm: 363 packet->isa = CS_ETM_ISA_A32; 364 break; 365 case ocsd_isa_thumb2: 366 packet->isa = CS_ETM_ISA_T32; 367 break; 368 case ocsd_isa_tee: 369 case ocsd_isa_jazelle: 370 case ocsd_isa_custom: 371 case ocsd_isa_unknown: 372 default: 373 packet->isa = CS_ETM_ISA_UNKNOWN; 374 } 375 376 packet->start_addr = elem->st_addr; 377 packet->end_addr = elem->en_addr; 378 packet->instr_count = elem->num_instr_range; 379 packet->last_instr_type = elem->last_i_type; 380 packet->last_instr_subtype = elem->last_i_subtype; 381 packet->last_instr_cond = elem->last_instr_cond; 382 383 switch (elem->last_i_type) { 384 case OCSD_INSTR_BR: 385 case OCSD_INSTR_BR_INDIRECT: 386 packet->last_instr_taken_branch = elem->last_instr_exec; 387 break; 388 case OCSD_INSTR_ISB: 389 case OCSD_INSTR_DSB_DMB: 390 case OCSD_INSTR_OTHER: 391 default: 392 packet->last_instr_taken_branch = false; 393 break; 394 } 395 396 packet->last_instr_size = elem->last_instr_sz; 397 398 return ret; 399 } 400 401 static ocsd_datapath_resp_t 402 cs_etm_decoder__buffer_discontinuity(struct cs_etm_decoder *decoder, 403 const uint8_t trace_chan_id) 404 { 405 return cs_etm_decoder__buffer_packet(decoder, trace_chan_id, 406 CS_ETM_DISCONTINUITY); 407 } 408 409 static ocsd_datapath_resp_t 410 cs_etm_decoder__buffer_exception(struct cs_etm_decoder *decoder, 411 const ocsd_generic_trace_elem *elem, 412 const uint8_t trace_chan_id) 413 { int ret = 0; 414 struct cs_etm_packet *packet; 415 416 ret = cs_etm_decoder__buffer_packet(decoder, trace_chan_id, 417 CS_ETM_EXCEPTION); 418 if (ret != OCSD_RESP_CONT && ret != OCSD_RESP_WAIT) 419 return ret; 420 421 packet = &decoder->packet_buffer[decoder->tail]; 422 packet->exception_number = elem->exception_number; 423 424 return ret; 425 } 426 427 static ocsd_datapath_resp_t 428 cs_etm_decoder__buffer_exception_ret(struct cs_etm_decoder *decoder, 429 const uint8_t trace_chan_id) 430 { 431 return cs_etm_decoder__buffer_packet(decoder, trace_chan_id, 432 CS_ETM_EXCEPTION_RET); 433 } 434 435 static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( 436 const void *context, 437 const ocsd_trc_index_t indx __maybe_unused, 438 const u8 trace_chan_id __maybe_unused, 439 const ocsd_generic_trace_elem *elem) 440 { 441 ocsd_datapath_resp_t resp = OCSD_RESP_CONT; 442 struct cs_etm_decoder *decoder = (struct cs_etm_decoder *) context; 443 444 switch (elem->elem_type) { 445 case OCSD_GEN_TRC_ELEM_UNKNOWN: 446 break; 447 case OCSD_GEN_TRC_ELEM_EO_TRACE: 448 case OCSD_GEN_TRC_ELEM_NO_SYNC: 449 case OCSD_GEN_TRC_ELEM_TRACE_ON: 450 resp = cs_etm_decoder__buffer_discontinuity(decoder, 451 trace_chan_id); 452 break; 453 case OCSD_GEN_TRC_ELEM_INSTR_RANGE: 454 resp = cs_etm_decoder__buffer_range(decoder, elem, 455 trace_chan_id); 456 break; 457 case OCSD_GEN_TRC_ELEM_EXCEPTION: 458 resp = cs_etm_decoder__buffer_exception(decoder, elem, 459 trace_chan_id); 460 break; 461 case OCSD_GEN_TRC_ELEM_EXCEPTION_RET: 462 resp = cs_etm_decoder__buffer_exception_ret(decoder, 463 trace_chan_id); 464 break; 465 case OCSD_GEN_TRC_ELEM_PE_CONTEXT: 466 case OCSD_GEN_TRC_ELEM_ADDR_NACC: 467 case OCSD_GEN_TRC_ELEM_TIMESTAMP: 468 case OCSD_GEN_TRC_ELEM_CYCLE_COUNT: 469 case OCSD_GEN_TRC_ELEM_ADDR_UNKNOWN: 470 case OCSD_GEN_TRC_ELEM_EVENT: 471 case OCSD_GEN_TRC_ELEM_SWTRACE: 472 case OCSD_GEN_TRC_ELEM_CUSTOM: 473 default: 474 break; 475 } 476 477 return resp; 478 } 479 480 static int cs_etm_decoder__create_etm_packet_decoder( 481 struct cs_etm_trace_params *t_params, 482 struct cs_etm_decoder *decoder) 483 { 484 const char *decoder_name; 485 ocsd_etmv3_cfg config_etmv3; 486 ocsd_etmv4_cfg trace_config_etmv4; 487 void *trace_config; 488 u8 csid; 489 490 switch (t_params->protocol) { 491 case CS_ETM_PROTO_ETMV3: 492 case CS_ETM_PROTO_PTM: 493 cs_etm_decoder__gen_etmv3_config(t_params, &config_etmv3); 494 decoder_name = (t_params->protocol == CS_ETM_PROTO_ETMV3) ? 495 OCSD_BUILTIN_DCD_ETMV3 : 496 OCSD_BUILTIN_DCD_PTM; 497 trace_config = &config_etmv3; 498 break; 499 case CS_ETM_PROTO_ETMV4i: 500 cs_etm_decoder__gen_etmv4_config(t_params, &trace_config_etmv4); 501 decoder_name = OCSD_BUILTIN_DCD_ETMV4I; 502 trace_config = &trace_config_etmv4; 503 break; 504 default: 505 return -1; 506 } 507 508 if (ocsd_dt_create_decoder(decoder->dcd_tree, 509 decoder_name, 510 OCSD_CREATE_FLG_FULL_DECODER, 511 trace_config, &csid)) 512 return -1; 513 514 if (ocsd_dt_set_gen_elem_outfn(decoder->dcd_tree, 515 cs_etm_decoder__gen_trace_elem_printer, 516 decoder)) 517 return -1; 518 519 return 0; 520 } 521 522 static int 523 cs_etm_decoder__create_etm_decoder(struct cs_etm_decoder_params *d_params, 524 struct cs_etm_trace_params *t_params, 525 struct cs_etm_decoder *decoder) 526 { 527 if (d_params->operation == CS_ETM_OPERATION_PRINT) 528 return cs_etm_decoder__create_etm_packet_printer(t_params, 529 decoder); 530 else if (d_params->operation == CS_ETM_OPERATION_DECODE) 531 return cs_etm_decoder__create_etm_packet_decoder(t_params, 532 decoder); 533 534 return -1; 535 } 536 537 struct cs_etm_decoder * 538 cs_etm_decoder__new(int num_cpu, struct cs_etm_decoder_params *d_params, 539 struct cs_etm_trace_params t_params[]) 540 { 541 struct cs_etm_decoder *decoder; 542 ocsd_dcd_tree_src_t format; 543 u32 flags; 544 int i, ret; 545 546 if ((!t_params) || (!d_params)) 547 return NULL; 548 549 decoder = zalloc(sizeof(*decoder)); 550 551 if (!decoder) 552 return NULL; 553 554 decoder->data = d_params->data; 555 decoder->prev_return = OCSD_RESP_CONT; 556 cs_etm_decoder__clear_buffer(decoder); 557 format = (d_params->formatted ? OCSD_TRC_SRC_FRAME_FORMATTED : 558 OCSD_TRC_SRC_SINGLE); 559 flags = 0; 560 flags |= (d_params->fsyncs ? OCSD_DFRMTR_HAS_FSYNCS : 0); 561 flags |= (d_params->hsyncs ? OCSD_DFRMTR_HAS_HSYNCS : 0); 562 flags |= (d_params->frame_aligned ? OCSD_DFRMTR_FRAME_MEM_ALIGN : 0); 563 564 /* 565 * Drivers may add barrier frames when used with perf, set up to 566 * handle this. Barriers const of FSYNC packet repeated 4 times. 567 */ 568 flags |= OCSD_DFRMTR_RESET_ON_4X_FSYNC; 569 570 /* Create decode tree for the data source */ 571 decoder->dcd_tree = ocsd_create_dcd_tree(format, flags); 572 573 if (decoder->dcd_tree == 0) 574 goto err_free_decoder; 575 576 /* init library print logging support */ 577 ret = cs_etm_decoder__init_def_logger_printing(d_params, decoder); 578 if (ret != 0) 579 goto err_free_decoder_tree; 580 581 /* init raw frame logging if required */ 582 cs_etm_decoder__init_raw_frame_logging(d_params, decoder); 583 584 for (i = 0; i < num_cpu; i++) { 585 ret = cs_etm_decoder__create_etm_decoder(d_params, 586 &t_params[i], 587 decoder); 588 if (ret != 0) 589 goto err_free_decoder_tree; 590 } 591 592 return decoder; 593 594 err_free_decoder_tree: 595 ocsd_destroy_dcd_tree(decoder->dcd_tree); 596 err_free_decoder: 597 free(decoder); 598 return NULL; 599 } 600 601 int cs_etm_decoder__process_data_block(struct cs_etm_decoder *decoder, 602 u64 indx, const u8 *buf, 603 size_t len, size_t *consumed) 604 { 605 int ret = 0; 606 ocsd_datapath_resp_t cur = OCSD_RESP_CONT; 607 ocsd_datapath_resp_t prev_return = decoder->prev_return; 608 size_t processed = 0; 609 u32 count; 610 611 while (processed < len) { 612 if (OCSD_DATA_RESP_IS_WAIT(prev_return)) { 613 cur = ocsd_dt_process_data(decoder->dcd_tree, 614 OCSD_OP_FLUSH, 615 0, 616 0, 617 NULL, 618 NULL); 619 } else if (OCSD_DATA_RESP_IS_CONT(prev_return)) { 620 cur = ocsd_dt_process_data(decoder->dcd_tree, 621 OCSD_OP_DATA, 622 indx + processed, 623 len - processed, 624 &buf[processed], 625 &count); 626 processed += count; 627 } else { 628 ret = -EINVAL; 629 break; 630 } 631 632 /* 633 * Return to the input code if the packet buffer is full. 634 * Flushing will get done once the packet buffer has been 635 * processed. 636 */ 637 if (OCSD_DATA_RESP_IS_WAIT(cur)) 638 break; 639 640 prev_return = cur; 641 } 642 643 decoder->prev_return = cur; 644 *consumed = processed; 645 646 return ret; 647 } 648 649 void cs_etm_decoder__free(struct cs_etm_decoder *decoder) 650 { 651 if (!decoder) 652 return; 653 654 ocsd_destroy_dcd_tree(decoder->dcd_tree); 655 decoder->dcd_tree = NULL; 656 free(decoder); 657 } 658