1/* 2 * Copyright 2017, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10* @TAG(DATA61_BSD) 11*/ 12 13#pragma once 14 15#define DMB() asm volatile("dmb" ::: "memory") 16#define DSB() asm volatile("dsb" ::: "memory") 17#define ISB() asm volatile("isb" ::: "memory") 18#define IO_READ_MEM_BARRIER() DMB() 19#define IO_WRITE_MEM_BARRIER() DMB() 20 21/* Helper for forcing a read and returning a value 22 * 23 * Forces a memory read access to the given address. 24 */ 25static inline uintptr_t force_read_value(uintptr_t *address) { 26 uintptr_t value; 27 asm volatile ("mov %[val], %[addr]" 28 : [val]"=r"(value) 29 : [addr]"r"(*address) 30 /* no clobbers */ 31 ); 32 return value; 33} 34