2024-12-20 22:45:12 +00:00
|
|
|
#ifndef __GILBRALTAR_MEM__
|
|
|
|
#define __GILBRALTAR_MEM__
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
static inline uint8_t read8(uintptr_t addr) {
|
|
|
|
return *(uint8_t volatile *)addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void write8(uintptr_t addr, uint8_t v) {
|
|
|
|
*(uint8_t volatile *)addr = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t read32(uintptr_t addr) {
|
|
|
|
return *(uint32_t volatile *)addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void write32(uintptr_t addr, uint32_t v) {
|
|
|
|
*(uint32_t volatile *)addr = v;
|
|
|
|
}
|
|
|
|
|
2024-12-23 00:46:17 +00:00
|
|
|
#define data_sync_barrier() __asm__ __volatile("dsb sy" ::: "memory")
|
|
|
|
#define data_mem_barrier() __asm__ __volatile("dmb sy" ::: "memory")
|
|
|
|
#define instruction_sync_barrier() __asm__ __volatile("isb" ::: "memory")
|
|
|
|
|
2024-12-20 22:45:12 +00:00
|
|
|
#endif
|