I'm working on a JIT and I'd like to be able to flush icache. I've tried writing a 0 to ICIALLU
(at address 0xE000EF50
) and I've also tried the STM32CubeF7 library's InvalidateICache()
. However, all methods I've tried result in the device crashing. I'm not sure what to do at this point except to execute 4kb of nop
s.
Right, we don't provide direct access to system registers. I'll file a feature request for a cache-flushing function on the C API. My first though was nah, that's too niche, but now I really want to see what you can do with JIT code.
I'll try and get that into the 2.0.0 release!
Thank you so much! I hope not to disappoint
Excuse me, I'm doing the same now. Am I understanding it correctly - all heap-allocated memory is rwx
? I mean that I should not specially map-protect it. Am I right?
I believe that is right.
Please note, that because the Playdate operates exclusively in THUMB mode, pointers to instructions (i.e. function pointers) always have the lowest bit set. In other words, they point to one byte after the instructions begin; and if you jump to/call arbitrary code, you need the address (ptr|1)
instead.