16 #include <linux/types.h>
37 #define MAXBUCKETS 211
42 #define DOFF_ALIGN(x) (((x) + 3) & ~3UL)
154 *
this,
const char *
name,
157 *
this,
const char *
name,
186 static u16 name_hash(
void *
key,
u16 max_bucket);
187 static bool name_match(
void *
key,
void *
sp);
188 static void sym_delete(
void *
value);
191 static int redefined_symbol;
192 static int gbl_search = 1;
205 if (zl_target->
head == zl_lib)
239 if (target_obj !=
NULL) {
240 if (pzl_target ==
NULL) {
244 pzl_target->
attrs = *pattrs;
284 *sym_val = &sym->
value;
288 dev_dbg(
bridge,
"%s: lib: %p name: %s paddr: %p, status 0x%x\n",
289 __func__, zl_lib, name, sym_val, status);
301 if ((pattrs !=
NULL) && (zl_target !=
NULL))
302 *pattrs = zl_target->
attrs;
319 strncpy(cname + 1, name,
sizeof(cname) - 2);
326 *sym_val = &sym->
value;
341 bool opened_doff =
false;
347 if (zl_lib !=
NULL) {
349 status = dof_open(zl_lib);
365 *psize = sect->
size * byte_size;
382 "status 0x%x\n", __func__, lib, name, paddr, psize, status);
405 bool got_symbols =
true;
408 bool opened_doff =
false;
422 name_match, sym_delete);
431 zl_lib->
stream.dl_stream.read_buffer = dbll_read_buffer;
432 zl_lib->
stream.dl_stream.set_file_posn = dbll_set_file_posn;
433 zl_lib->
stream.lib = zl_lib;
435 zl_lib->
symbol.dl_symbol.find_matching_symbol =
438 zl_lib->
symbol.dl_symbol.add_to_symbol_table =
439 find_in_symbol_table;
441 zl_lib->
symbol.dl_symbol.add_to_symbol_table =
442 dbll_add_to_symbol_table;
444 zl_lib->
symbol.dl_symbol.purge_symbol_table =
445 dbll_purge_symbol_table;
446 zl_lib->
symbol.dl_symbol.dload_allocate = allocate;
447 zl_lib->
symbol.dl_symbol.dload_deallocate = deallocate;
448 zl_lib->
symbol.dl_symbol.error_report = dbll_err_report;
449 zl_lib->
symbol.lib = zl_lib;
451 zl_lib->
allocate.dl_alloc.dload_allocate = dbll_rmm_alloc;
452 zl_lib->
allocate.dl_alloc.dload_deallocate = rmm_dealloc;
455 zl_lib->
init.dl_init.connect = connect;
456 zl_lib->
init.dl_init.readmem = read_mem;
457 zl_lib->
init.dl_init.writemem = write_mem;
458 zl_lib->
init.dl_init.fillmem = fill_mem;
459 zl_lib->
init.dl_init.execute = execute;
461 zl_lib->
init.lib = zl_lib;
464 status = dof_open(zl_lib);
482 &zl_lib->
symbol.dl_symbol,
484 &zl_lib->
init.dl_init,
490 }
else if (redefined_symbol) {
493 redefined_symbol =
false;
496 *entry = zl_lib->
entry;
507 dev_dbg(
bridge,
"%s: lib: %p flags: 0x%x entry: %p, status 0x%x\n",
508 __func__, lib, flags, entry, status);
524 zl_lib = zl_target->
head;
525 while (zl_lib !=
NULL) {
531 zl_lib = zl_lib->
next;
533 if (zl_lib ==
NULL) {
536 if (zl_lib ==
NULL) {
563 zl_lib->
stream.dl_stream.read_buffer = dbll_read_buffer;
564 zl_lib->
stream.dl_stream.set_file_posn = dbll_set_file_posn;
565 zl_lib->
stream.lib = zl_lib;
567 zl_lib->
symbol.dl_symbol.add_to_symbol_table = dbll_add_to_symbol_table;
568 zl_lib->
symbol.dl_symbol.find_matching_symbol = dbll_find_symbol;
569 zl_lib->
symbol.dl_symbol.purge_symbol_table = dbll_purge_symbol_table;
571 zl_lib->
symbol.dl_symbol.dload_deallocate = deallocate;
572 zl_lib->
symbol.dl_symbol.error_report = dbll_err_report;
573 zl_lib->
symbol.lib = zl_lib;
575 zl_lib->
allocate.dl_alloc.dload_allocate = dbll_rmm_alloc;
576 zl_lib->
allocate.dl_alloc.dload_deallocate = rmm_dealloc;
579 zl_lib->
init.dl_init.connect = connect;
580 zl_lib->
init.dl_init.readmem = read_mem;
581 zl_lib->
init.dl_init.writemem = write_mem;
582 zl_lib->
init.dl_init.fillmem = fill_mem;
583 zl_lib->
init.dl_init.execute = execute;
585 zl_lib->
init.lib = zl_lib;
586 if (!status && zl_lib->
fp ==
NULL)
587 status = dof_open(zl_lib);
597 name_match, sym_delete);
602 zl_lib->
init.dl_init.writemem = no_op;
604 &zl_lib->
symbol.dl_symbol,
606 &zl_lib->
init.dl_init, 0,
613 &zl_lib->
symbol.dl_symbol,
615 &zl_lib->
init.dl_init);
631 zl_target->
head = zl_lib;
641 dev_dbg(
bridge,
"%s: target: %p file: %s lib_obj: %p, status 0x%x\n",
642 __func__, target, file, lib_obj, status);
655 bool opened_doff =
false;
662 if (zl_lib !=
NULL) {
664 status = dof_open(zl_lib);
688 ul_sect_size = sect->
size * byte_size;
690 if (ul_sect_size % 2)
695 if (ul_sect_size > size) {
709 "status 0x%x\n", __func__, lib, name, buf, size, status);
730 &zl_lib->
symbol.dl_symbol,
732 &zl_lib->
init.dl_init);
780 &zl_lib->
symbol.dl_symbol);
796 static u16 name_hash(
void *
key,
u16 max_bucket)
800 char *
name = (
char *)key;
809 ret = hash % max_bucket;
817 static bool name_match(
void *key,
void *
sp)
819 if ((key !=
NULL) && (sp !=
NULL)) {
839 static void sym_delete(
void *
value)
908 status = (*(lib->
target_obj->attrs.sym_lookup))
916 (
char *)name, &dbll_sym);
926 if (!status && gbl_search)
927 dev_dbg(bridge,
"%s: Symbol not found: %s\n", __func__, name);
937 *
this,
const char *name,
956 *
this,
const char *name,
971 dbll_sym = dbll_find_symbol(
this, name);
974 redefined_symbol =
true;
975 dev_dbg(bridge,
"%s already defined in symbol table\n",
988 strlen((
char *
const)name) + 1);
1060 dev_dbg(bridge,
"%s\n", temp_buf);
1079 char *sz_sec_last_token =
NULL;
1080 char *sz_last_token =
NULL;
1081 char *sz_sect_name =
NULL;
1088 u32 run_addr_flag = 0;
1090 lib = dbll_alloc_obj->
lib;
1099 token_len =
strlen((
char *)(info->
name)) + 1;
1101 sz_sect_name = kzalloc(token_len,
GFP_KERNEL);
1102 sz_last_token = kzalloc(token_len,
GFP_KERNEL);
1103 sz_sec_last_token = kzalloc(token_len,
GFP_KERNEL);
1105 if (sz_sect_name ==
NULL || sz_sec_last_token ==
NULL ||
1106 sz_last_token ==
NULL) {
1110 strncpy(sz_sect_name, (
char *)(info->
name), token_len);
1111 psz_cur = sz_sect_name;
1112 while ((token =
strsep(&psz_cur,
":")) && *token !=
'\0') {
1113 strncpy(sz_sec_last_token, sz_last_token,
1114 strlen(sz_last_token) + 1);
1116 token =
strsep(&psz_cur,
":");
1126 if ((req == 0) || (req == 1)) {
1127 if (
strcmp(sz_sec_last_token,
"DYN_DARAM") == 0) {
1130 if (
strcmp(sz_sec_last_token,
"DYN_SARAM") == 0) {
1133 if (
strcmp(sz_sec_last_token,
1134 "DYN_EXTERNAL") == 0)
1140 kfree(sz_sect_name);
1141 sz_sect_name =
NULL;
1142 kfree(sz_last_token);
1143 sz_last_token =
NULL;
1144 kfree(sz_sec_last_token);
1145 sz_sec_last_token =
NULL;
1150 alloc_size = info->
size;
1159 rmm_handle, mem_sect_type,
1161 (
u32 *) &rmm_addr_obj,
1162 seg_id,
req,
false);
1172 dev_dbg(bridge,
"%s: %s base = 0x%x len = 0x%x, "
1173 "info->run_addr 0x%x, info->load_addr 0x%x\n",
1199 lib = dbll_alloc_obj->
lib;
1205 free_size = info->
size;
1237 lib = init_obj->
lib;
1256 lib = init_obj->
lib;
1265 if (target_obj && target_obj->
attrs.write) {
1267 (*target_obj->
attrs.write) (target_obj->
attrs.input_params,
1271 if (target_obj->
attrs.log_write) {
1272 sect_info.name = info->
name;
1273 sect_info.sect_run_addr = info->
run_addr;
1274 sect_info.sect_load_addr = info->
load_addr;
1275 sect_info.size = info->
size;
1276 sect_info.type = mem_sect_type;
1279 (*target_obj->
attrs.log_write) (target_obj->
attrs.
1302 lib = init_obj->
lib;
1309 write_mem(
this, &pbuf, addr, info, 0);
1311 memset(pbuf, val, bytes);
1325 lib = init_obj->
lib;
1340 #ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
1351 struct find_symbol_context {
1356 u32 cur_best_offset;
1373 u32 symbol_addr = symbol->
value.value;
1374 u32 offset = context->address - symbol_addr;
1381 if (context->address >= symbol_addr && symbol_addr < (
u32)-1 &&
1383 context->cur_best_offset =
offset;
1384 context->sym_addr = symbol_addr;
1385 strncpy(context->name, symbol->
name,
sizeof(context->name));
1402 u32 offset_range,
u32 *sym_addr_output,
1405 bool status =
false;
1406 struct find_symbol_context context;
1409 context.offset_range = offset_range;
1410 context.cur_best_offset = offset_range;
1411 context.sym_addr = 0;
1412 context.name[0] =
'\0';
1414 gh_iterate(zl_lib->
sym_tab, find_symbol_callback, &context);
1416 if (context.name[0]) {
1418 strcpy(name_output, context.name);
1419 *sym_addr_output = context.sym_addr;