Pain-free HAL and ARMop calling from C
Jeffrey Lee (213) 6048 posts |
I’m here to plug a macro-based approach I developed for making HAL and ARMop calls from within the SMP module. It allows you to call HAL and ARMop routines as if they were native C functions, with minimal overhead, and minimal setup fuss. Apart from a bit of macro soup, the only downside is that it doesn’t allow the calls to easily be made from assembler. But with some tweaks that could be supported as well. See armops.h and armops.c for the ARMops code, and halcalls.h and halcalls.c for the HAL code. Both operate on similar principles:
For ARMops, the routines are made available as standard C function pointers. C doesn’t require any special syntax to call a function pointer, so they can be invoked directly. For the HAL calls, the macros construct inline functions which use inline assembler to perform the call. Most of the inline assembler is just boilerplate that Norcroft will be able to optimise out (moving parameters to the correct registers), so the cost shouldn’t be any higher than invoking a C function. (Note that the current version uses BLX, so will need tweaking it you want to use it on pre-ARMv5) |
Timothy Baldwin (184) 242 posts |
No, in ROOL C inline pseudo-assembly BLX works fine on pre-ARMv5 as it compiles to supported instructions. |