我正在尝试编译以下两段代码ARM编译器5对于 Cortex A 微处理器:
Part 1:
static inline void cp15_write_sctlr(uint32_t value)
{
asm("mcr p15, 0, %0, c1, c0, 0" :: "r"(value));
}
static inline uint32_t cp15_read_actlr(void)
{
uint32_t actlr;
asm("mrc p15, 0, %0, c1, c0, 1" : "=r"(actlr));
return actlr;
}
Part 2:
static inline void dmb(void)
{
asm("dmb" ::: "memory");
}
static inline void dsb(void)
{
asm("dsb" ::: "memory");
}
static inline void isb(void)
{
asm("isb" ::: "memory");
}
在这两种情况下我都会遇到编译错误。请参阅下面的示例。
line 64: Error: #18: expected a ")"
asm("dsb" ::: "memory");
该错误是由编译器版本(ARM编译器5)引起的,它不支持扩展Asm吗?
如果我重写代码Part 1如下,我没有收到任何错误。以下代码与第 1 部分中的代码等效吗?
static inline void cp15_write_sctlr(uint32_t value)
{
__asm
{
MCR p15, 0, value, c1, c0, 0
}
}
static inline uint32_t cp15_read_actlr(void)
{
uint32_t actlr;
__asm
{
MRC p15, 0, actlr, c1, c0, 1
}
return actlr;
}
如果编译器不支持扩展 Asm,我如何重写第 2 部分中的代码?
我想到了以下内容,但我不确定是否相同。
static inline void dmb(void)
{
__schedule_barrier();
__asm("dmb");
__schedule_barrier();
}
static inline void dsb(void)
{
__schedule_barrier();
__asm("dsb");
__schedule_barrier();
}
static inline void isb(void)
{
__schedule_barrier();
__asm("isb");
__schedule_barrier();
}
任何帮助将非常感激。