diff options
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/arm/include/armv7/arch/io.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/arch/arm/include/armv7/arch/io.h b/src/arch/arm/include/armv7/arch/io.h index 9d060032e9..94cb1312ad 100644 --- a/src/arch/arm/include/armv7/arch/io.h +++ b/src/arch/arm/include/armv7/arch/io.h @@ -29,40 +29,49 @@ static inline uint8_t read8(const void *addr) { + uint8_t val; + dmb(); - return *(volatile uint8_t *)addr; + asm volatile ("ldrb %0, [%1]" : "=r" (val) : "r" (addr) : "memory"); + return val; } static inline uint16_t read16(const void *addr) { + uint16_t val; + dmb(); - return *(volatile uint16_t *)addr; + asm volatile ("ldrh %0, [%1]" : "=r" (val) : "r" (addr) : "memory"); + return val; } static inline uint32_t read32(const void *addr) { + uint32_t val; + dmb(); - return *(volatile uint32_t *)addr; + asm volatile ("ldr %0, [%1]" : "=r" (val) : "r" (addr) : "memory"); + return val; } static inline void write8(void *addr, uint8_t val) { dmb(); - *(volatile uint8_t *)addr = val; + asm volatile ("strb %0, [%1]" : : "r" (val), "r" (addr) : "memory"); dmb(); } static inline void write16(void *addr, uint16_t val) { dmb(); - *(volatile uint16_t *)addr = val; + asm volatile ("strh %0, [%1]" : : "r" (val), "r" (addr) : "memory"); dmb(); } static inline void write32(void *addr, uint32_t val) { dmb(); - *(volatile uint32_t *)addr = val; + asm volatile ("str %0, [%1]" : : "r" (val), "r" (addr) : "memory"); dmb(); } |