FreeCalypso > hg > tcs211-l1-reconst
comparison STATUS @ 284:33b35965b4a0
STATUS: began analysis of the differences in the non-exact objects
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Tue, 14 Mar 2017 19:07:14 +0000 |
| parents | 974835ad720c |
| children | 4d9af8de3973 |
comparison
equal
deleted
inserted
replaced
| 283:974835ad720c | 284:33b35965b4a0 |
|---|---|
| 1 Objects in l1_ext.lib: | 1 Objects in l1_ext.lib: |
| 2 | 2 |
| 3 l1_afunc.obj: not exact, needs review | 3 l1_afunc.obj: not exact, see explanation below |
| 4 l1_async.obj: perfect match | 4 l1_async.obj: perfect match |
| 5 l1_cmplx.obj: perfect match to 20070608 version except line number points | 5 l1_cmplx.obj: perfect match to 20070608 version except line number points |
| 6 l1_init.obj: perfect match | 6 l1_init.obj: perfect match |
| 7 l1_pwmgr.obj: perfect match | 7 l1_pwmgr.obj: perfect match |
| 8 l1_small.obj: perfect match | 8 l1_small.obj: perfect match |
| 10 l1_trace.obj: bits match perfectly, diff only in symbolic metadata | 10 l1_trace.obj: bits match perfectly, diff only in symbolic metadata |
| 11 | 11 |
| 12 l1_dyn_dwl_afunc.obj: perfect match | 12 l1_dyn_dwl_afunc.obj: perfect match |
| 13 l1_dyn_dwl_apihisr.obj: perfect match | 13 l1_dyn_dwl_apihisr.obj: perfect match |
| 14 l1_dyn_dwl_async.obj: perfect match | 14 l1_dyn_dwl_async.obj: perfect match |
| 15 l1_dyn_dwl_func.obj: not exact, needs review | 15 l1_dyn_dwl_func.obj: not exact, see explanation below |
| 16 l1_dyn_dwl_init.obj: sole diff is in the num_of_primitives oddity | 16 l1_dyn_dwl_init.obj: sole diff is in the num_of_primitives oddity, |
| 17 see explanation below | |
| 17 l1_dyn_dwl_sync.obj: perfect match | 18 l1_dyn_dwl_sync.obj: perfect match |
| 18 | 19 |
| 19 l1audio_abb.obj: perfect match | 20 l1audio_abb.obj: perfect match |
| 20 l1audio_afunc.obj: bits match perfectly, diff only in symbolic metadata | 21 l1audio_afunc.obj: bits match perfectly, diff only in symbolic metadata |
| 21 l1audio_async.obj: diffs only in register alloc and symbolic metadata | 22 l1audio_async.obj: diffs only in register alloc and symbolic metadata |
| 55 | 56 |
| 56 Objects in tpudrv.lib: | 57 Objects in tpudrv.lib: |
| 57 | 58 |
| 58 tpudrv.obj: perfect match | 59 tpudrv.obj: perfect match |
| 59 tpudrv12.obj: not exact, needs review | 60 tpudrv12.obj: not exact, needs review |
| 61 | |
| 62 Detailed analysis of differences, i.e., cases where the reconstructed C code | |
| 63 compiles into an object that is not bit-identical to the original blob: | |
| 64 | |
| 65 l1_afunc.obj: | |
| 66 | |
| 67 The l1_afunc.c module from LoCosto is used without any changes: | |
| 68 it compiled right away after adding one constant to l1_const.h, | |
| 69 and the result of recompilation is identical to the original up until | |
| 70 the l1a_clip_txpwr() function, which is the last function in the module. | |
| 71 | |
| 72 Disassembly of the original blob version of this function has been | |
| 73 analyzed and found to be identical in logic to the available C code, | |
| 74 but there must have been some change to the code expression that | |
| 75 results in different output from the compiler. In particular, the | |
| 76 symbolic info indicates the present of a local variable named power | |
| 77 in the original, but no such local var exists in the LoCosto version. | |
| 78 The TSM30 version was of no help as it is entirely different there. | |
| 79 | |
| 80 See g23m/objdiff/l1_ext/l1_afunc.notes for further info. | |
| 81 | |
| 82 l1_sync.obj: needs further review | |
| 83 l1_sync_intram.obj: ditto | |
| 84 | |
| 85 dl1_com.obj: not exact, needs review | |
| 86 | |
| 87 l1_dyn_dwl_func.obj: | |
| 88 | |
| 89 The LoCosto version uses a function (implemented in l1_func.c in | |
| 90 the LoCosto code) named l1_memcpy_16bit() to download patch bits | |
| 91 into the DSP's API RAM; the function does what the name says, and | |
| 92 the logic of using 16-bit accesses when hitting this API RAM makes | |
| 93 perfect sense to me (Mychaela). The original TCS211 code apparently | |
| 94 used plain memcpy(), which the compiler turned into its C$MEMCPY call. | |
| 95 | |
| 96 If one does a #define l1_memcpy_16bit memcpy in l1_dyn_dwl_func.c, | |
| 97 the resulting l1_dyn_dwl_func.obj is almost bit-identical to the | |
| 98 original blob: the only diff is in register allocation - the compiler's | |
| 99 register allocator picks a different choice of registers, but all | |
| 100 instructions still perfectly line up. | |
| 101 | |
| 102 For production use of our reconstructed TCS211 L1 code, we have adopted | |
| 103 the version with l1_memcpy_16bit() - the function body itself has been | |
| 104 moved into l1_dyn_dwl_func.c so that l1_func.c remains a perfect match. | |
| 105 | |
| 106 l1_dyn_dwl_init.obj: | |
| 107 | |
| 108 In the TCS211 configuration without L1_GTT, there are a total of 5 | |
| 109 signals (aka primitives aka L1 messages) which trigger a dynamic | |
| 110 DSP patch download. These 5 signals are enumerated in | |
| 111 signal_patch_array[] in l1_dyn_dwl_afunc.c (which has been reconstructed | |
| 112 to a perfect match), and their total count (which should be 5) goes into | |
| 113 l1a.dyn_dwnld.num_of_primitives, set in l1_dyn_dwnld_initialize_var() in | |
| 114 l1_dyn_dwl_init.c. | |
| 115 | |
| 116 In the original blob version this num_of_primitives variable ends up | |
| 117 being set to 6: first set to 2, then incremented by 4. In the LoCosto | |
| 118 source this var is first set to 0 as they apparently have no patches | |
| 119 that are independent of compilation config options, and then incremented | |
| 120 for every enabled option. | |
| 121 | |
| 122 In our reconstruction we have made the GPRS and AMR_SCH patches and the | |
| 123 primitives that trigger them mandatory, and conditionalized the E2 and | |
| 124 AMR_MMS patches on MELODY_E2. The GPRS and AMR_MMS critters are | |
| 125 preinstalled by the static patch, and get pushed out by AMR_SCH and E2, | |
| 126 respectively. Of the 5 primitives listed in signal_patch_array[] in | |
| 127 the original blob, the first 2 are always-present core ones, whereas | |
| 128 the last 3 are specific to E2. The AMR_MMS patch is reinstated upon | |
| 129 L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_CON. | |
| 130 | |
| 131 Based on the above reasoning, our reconstructed version sets | |
| 132 l1a.dyn_dwnld.num_of_primitives to 5 in the full configuration: first | |
| 133 sets to 2, then increments by 3. If one makes a sans-MELODY_E2 build, | |
| 134 only the GPRS and AMR_SCH patches will be retained, and only the two | |
| 135 non-E2 primitives for entry into and exit from dedicated mode. | |
| 136 | |
| 137 l1audio_async.obj: | |
| 138 | |
| 139 The only bit diff is in register allocation - the compiler's register | |
| 140 allocator picks a different choice of registers, but all instructions | |
| 141 still perfectly line up. There is also a slight diff in the symbolic | |
| 142 metadata emitted for functions, which might be related to the diff in | |
| 143 the register allocation. | |
| 144 | |
| 145 The root cause of these diffs could not be found, but there is no | |
| 146 functional difference as only some in-function temporary registers | |
| 147 have been interchanged. | |
| 148 | |
| 149 l1audio_cust.obj: | |
| 150 | |
| 151 The original blob version has these demo/test functions at the end of | |
| 152 the module: | |
| 153 | |
| 154 audio_melo_e1_demo1_start() | |
| 155 audio_melo_e1_demo1_stop() | |
| 156 audio_melo_e1_demo2_start() | |
| 157 audio_melo_e1_demo2_stop() | |
| 158 audio_melo_e2_load_lsi() | |
| 159 audio_melo_e2_demo1_start() | |
| 160 audio_melo_e2_demo1_stop() | |
| 161 audio_melo_e2_demo2_start() | |
| 162 audio_melo_e2_demo2_stop() | |
| 163 | |
| 164 These functions are dead code, i.e., they are not called or referenced | |
| 165 from anywhere else in the firmware, and the link succeeds without them | |
| 166 being present. These dead functions have been omitted from the | |
| 167 reconstructed version. The reconstruction is a perfect match otherwise. | |
| 168 | |
| 169 tpudrv12.obj: early reconstruction, needs further review |
