- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
It seems that some inline assembler functions in the hwlib are not working correctly when compiled with armclang compiler with moderate optimization level (-O2).
As an example lets take a helper function from "alt_cache.c" file:
static __inline __attribute__((always_inline)) void sctlr_write_helper(uint32_t sctlr)
{
#if defined(__ARMCOMPILER_VERSION)
__asm("MCR p15, 0, %[sctlr], c1, c0, 0" : : [sctlr] "r" (sctlr));
#elif defined(__ARMCC_VERSION)
__asm("MCR p15, 0, sctlr, c1, c0, 0");
#else
__asm("MCR p15, 0, %0, c1, c0, 0" : : "r" (sctlr));
#endif
}
The armclang inline assembler requires the "volatile" keyword to be used like this:
static __inline __attribute__((always_inline)) void sctlr_write_helper(uint32_t sctlr)
{
#if defined(__ARMCOMPILER_VERSION)
__asm volatile ("MCR p15, 0, %[sctlr], c1, c0, 0" : : [sctlr] "r" (sctlr));
#elif defined(__ARMCC_VERSION)
__asm("MCR p15, 0, sctlr, c1, c0, 0");
#else
__asm("MCR p15, 0, %0, c1, c0, 0" : : "r" (sctlr));
#endif
}
Here is the link to the ARM documentation:
Link Copied

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page