| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2006, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: $ |
|---|
| 11 | * $brcm_Revision: $ |
|---|
| 12 | * $brcm_Date: $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: $ |
|---|
| 19 | * |
|---|
| 20 | ***************************************************************************/ |
|---|
| 21 | #define BDISPATCH_BYPASS |
|---|
| 22 | #include "symbols.h" |
|---|
| 23 | #undef BDISPATCH_BYPASS |
|---|
| 24 | #include "projinc.h" |
|---|
| 25 | #if CONFIG_SYMTABLE |
|---|
| 26 | #include "bsymtable.h" |
|---|
| 27 | |
|---|
| 28 | /* this function does lookup in ram and rom symbol table and returns closest match */ |
|---|
| 29 | const char * |
|---|
| 30 | bsymtable_lookup(uint32_t addr, unsigned *offset) |
|---|
| 31 | { |
|---|
| 32 | static const char sym_unknown[] = ""; |
|---|
| 33 | const char *rom_name = sym_unknown; |
|---|
| 34 | unsigned rom_offset = (unsigned)-1; |
|---|
| 35 | const char *ram_name = sym_unknown; |
|---|
| 36 | unsigned ram_offset = (unsigned)-1; |
|---|
| 37 | |
|---|
| 38 | if (g_symtable_rom) { |
|---|
| 39 | rom_name = bsymbol_lookup(g_symtable_rom, addr, &rom_offset); |
|---|
| 40 | } |
|---|
| 41 | if (g_symtable_ram) { |
|---|
| 42 | ram_name = bsymbol_lookup(g_symtable_ram, addr, &ram_offset); |
|---|
| 43 | } |
|---|
| 44 | if (rom_offset < ram_offset) { |
|---|
| 45 | *offset = rom_offset; |
|---|
| 46 | return rom_name; |
|---|
| 47 | } else { |
|---|
| 48 | *offset = ram_offset; |
|---|
| 49 | return ram_name; |
|---|
| 50 | } |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | const char * |
|---|
| 54 | bsymtable_get_name(uint32_t addr, char *buf, size_t buf_len) |
|---|
| 55 | { |
|---|
| 56 | unsigned offset; |
|---|
| 57 | const char *name; |
|---|
| 58 | |
|---|
| 59 | name = bsymtable_lookup(addr, &offset); |
|---|
| 60 | if (offset==0) { |
|---|
| 61 | return name; |
|---|
| 62 | } |
|---|
| 63 | if (offset < 4096) { /* maximum function size */ |
|---|
| 64 | snprintf(buf, buf_len, "%s+0x%x", name, offset); |
|---|
| 65 | } else { |
|---|
| 66 | snprintf(buf, buf_len, "0x%08x", addr); |
|---|
| 67 | } |
|---|
| 68 | return buf; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | void |
|---|
| 72 | bsymtable_init(void) |
|---|
| 73 | { |
|---|
| 74 | const bsymbol_table *map = bsymbol_fixup(); |
|---|
| 75 | if (g_symtable_rom==NULL) { |
|---|
| 76 | g_symtable_rom = map; |
|---|
| 77 | } else { |
|---|
| 78 | g_symtable_ram = map; |
|---|
| 79 | } |
|---|
| 80 | } |
|---|
| 81 | #else /* DCONFIG_SYMTABLE */ |
|---|
| 82 | void |
|---|
| 83 | bsymtable_init(void) |
|---|
| 84 | { |
|---|
| 85 | return; |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | const char * |
|---|
| 89 | bsymtable_lookup(uint32_t addr, unsigned *offset) |
|---|
| 90 | { |
|---|
| 91 | *offset = (unsigned)-1; |
|---|
| 92 | return ""; |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | const char * |
|---|
| 96 | bsymtable_get_name(uint32_t addr, char *buf, size_t buf_len) |
|---|
| 97 | { |
|---|
| 98 | snprintf(buf, buf_len, "0x%08x", addr); |
|---|
| 99 | return buf; |
|---|
| 100 | } |
|---|
| 101 | #endif |
|---|