Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
barrier.h
Go to the documentation of this file.
1
6#ifndef ZEPHYR_INCLUDE_ARCH_ARC_BARRIER_H_
7#define ZEPHYR_INCLUDE_ARCH_ARC_BARRIER_H_
8
9#ifndef ZEPHYR_INCLUDE_SYS_BARRIER_H_
10#error Please include <zephyr/sys/barrier.h>
11#endif
12
13#ifndef __CCAC__
14/* ARC GNU GCC lowers the barrier builtins correctly, so it keeps using
15 * <zephyr/sys/barrier_builtin.h>. Only MWDT needs this backend.
16 */
17#error "The ARC barrier backend is a MWDT-only workaround"
18#endif
19
20#include <zephyr/toolchain.h>
21#include <zephyr/arch/arc/dmb.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* MWDT implements __sync_synchronize() as a bare return and emits no dmb for
28 * __atomic_thread_fence(), so emit the ARC barrier instructions directly.
29 */
30
31static ALWAYS_INLINE void z_barrier_sync_synchronize(void)
32{
33 __asm__ volatile("dmb " STRINGIFY(ARC_DMB_LOAD_STORE) ::: "memory");
34}
35
36static ALWAYS_INLINE void z_barrier_dmem_fence_full(void)
37{
38 __asm__ volatile("dmb " STRINGIFY(ARC_DMB_LOAD_STORE) ::: "memory");
39}
40
41static ALWAYS_INLINE void z_barrier_dsync_fence_full(void)
42{
43 /* dsync additionally stalls until the prior data accesses completed */
44 __asm__ volatile("dsync" ::: "memory");
45}
46
47static ALWAYS_INLINE void z_barrier_isync_fence_full(void)
48{
49 /* sync is ARC's pipeline-affecting synchronization */
50 __asm__ volatile("sync" ::: "memory");
51}
52
53#ifdef __cplusplus
54}
55#endif
56
57#endif /* ZEPHYR_INCLUDE_ARCH_ARC_BARRIER_H_ */
Copyright (c) 2026 GlobalFoundries Inc.
#define ARC_DMB_LOAD_STORE
Order prior loads and stores before subsequent loads and stores.
Definition dmb.h:24
#define STRINGIFY(s)
Definition common.h:185
#define ALWAYS_INLINE
Definition common.h:180
Macros to abstract toolchain specific capabilities.