0xAF wrote:
Sergei wrote:
Great! Thank you very much! I will try to understand how it works.
g3gg0 made them (cache-hacks) quite simple for usage, though it's big voodoo magic in first look.
it should be simple as this:
1. lock the caches, so nothing will change them anymore: cache_lock();
2. poison the I cache and change any instruction you want:
cache_fake(0xFFB40340, NOP_INSTR, TYPE_ICACHE); // change the instruction at this address to NOP
or
cache_fake(0xFFB40344, BL_INSTR(0xFFB40344, &my_super_special_routine), TYPE_ICACHE); // change the original BL call with our BL call
as long as the caches stays locked, it will work... but if the caches gets unlocked, our poison will be replaced very quickly... so we must be sure nothing unlocks or clears the caches once we poison them...
i've been working on these things on my 5D,
to do this i had to read the ARM ARM (ARM Architecture Reference Manual) about the caches, to see the all possible ways to clear them...
then i've looked at the firmware to see where are the caches cleared or unlocked... and replaced all instructions that are going to stop us...
some with NOPs, some i had to make a helper routines to do what's needed, since they were changing the control register 15, and we cannot nop this instructions easily...
https://bitbucket.org/0xAF/magic-lantern-5dc-port-wip/src/9900ee745965978b31f302d94a54dcf6f17ebd4f/platform/5DC.111/init.c?at=unified#cl-211
this is the code i've been doing some time ago for 5D
you can see the helper functions before that routine, but for 400d i will have to inspect the firmware again...
as it turns out, for all ML cameras there were 2-3 instructions which needs to be NOPed, so the cache stays locked and intact...
but on 5D it seems there are quite more... something like 25-30 instructions in random places in the firmware... it is not that easy to catch all of them... the main reason was that the original VxWorks code did a lot of cache stuff... and the newer cameras with Canon's DryOS do not touch the caches...
i only hope 400d to get fewer instructions, so it will be easier to port the cache-hacks... it is still a vxworks camera, but it's newer firmware and newer api than 5D...
and 40d is vxworks camera, but ML guys made it with few instructions only ....
i guess i made all this too much confusing already ...
hope this will help you (both) in understanding the initial process of the porting of the cache hacks...
just keep in mind that the most cache clear instructions are in the moment of initializing the camera ...
once its booted and runs, there are just few instructions that needs to be replaced...
if you are going to try to port them, drop a line, i can give some techniques that will help you...
another option is to wait for me to get some time (hope this week or the next one)
and do it ...