Indentation fix, cleanup.
[AROS.git] / arch / arm-native / exec / exec_platform.h
blobe90fc4d7fe04da1714e55e5cf4e402388f47f13f
1 /*
2 Copyright © 2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
5 #ifndef __EXEC_PLATFORM_H
6 #define __EXEC_PLATFORM_H
8 // needed to determine if this is an smp build..
9 #include <aros/config.h>
11 #if defined(__AROSEXEC_SMP__)
12 #include <aros/types/spinlock_s.h>
13 #include <utility/hooks.h>
15 extern struct Hook Exec_TaskSpinLockFailHook;
16 extern void Exec_TaskSpinUnlock(spinlock_t *);
18 extern void Kernel_40_KrnSpinInit(spinlock_t *, void *);
19 #define EXEC_SPINLOCK_INIT(a) Kernel_40_KrnSpinInit((a), NULL)
20 extern spinlock_t *Kernel_43_KrnSpinLock(spinlock_t *, struct Hook *, ULONG, void *);
21 #define EXEC_SPINLOCK_LOCK(a,b) Kernel_43_KrnSpinLock((a), NULL, (b), NULL)
22 #define EXECTASK_SPINLOCK_LOCK(a,b) Kernel_43_KrnSpinLock((a), &Exec_TaskSpinLockFailHook, (b), NULL)
23 extern void Kernel_44_KrnSpinUnLock(spinlock_t *, void *);
24 #define EXEC_SPINLOCK_UNLOCK(a) Kernel_44_KrnSpinUnLock((a), NULL)
25 #define EXECTASK_SPINLOCK_UNLOCK(a) Kernel_44_KrnSpinUnLock((a), NULL); \
26 Exec_TaskSpinUnlock((a))
28 #endif
30 #include "tls.h"
32 struct Exec_PlatformData
34 /* No platform-specific data by default */
37 #if defined(AROS_NO_ATOMIC_OPERATIONS)
38 #define IDNESTCOUNT_INC \
39 do { \
40 tls_t *__tls; \
41 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
42 __tls->IDNestCnt++; \
43 } while(0)
44 #define IDNESTCOUNT_DEC \
45 do { \
46 tls_t *__tls; \
47 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
48 __tls->IDNestCnt--; \
49 } while(0)
50 #define TDNESTCOUNT_INC \
51 do { \
52 tls_t *__tls; \
53 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
54 __tls->TDNestCnt++; \
55 } while(0)
56 #define TDNESTCOUNT_DEC \
57 do { \
58 tls_t *__tls; \
59 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
60 __tls->TDNestCnt--; \
61 } while(0)
62 #define FLAG_SCHEDQUANTUM_CLEAR \
63 do { \
64 tls_t *__tls; \
65 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
66 __tls->ScheduleFlags &= ~TLSSF_Quantum; \
67 } while(0)
68 #define FLAG_SCHEDQUANTUM_SET \
69 do { \
70 tls_t *__tls; \
71 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
72 __tls->ScheduleFlags |= TLSSF_Quantum; \
73 } while(0)
74 #define FLAG_SCHEDSWITCH_CLEAR \
75 do { \
76 tls_t *__tls; \
77 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
78 __tls->ScheduleFlags &= ~TLSSF_Switch; \
79 } while(0)
80 #define FLAG_SCHEDSWITCH_SET \
81 do { \
82 tls_t *__tls; \
83 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
84 __tls->ScheduleFlags |= TLSSF_Switch; \
85 } while(0)
86 #define FLAG_SCHEDDISPATCH_CLEAR \
87 do { \
88 tls_t *__tls; \
89 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
90 __tls->ScheduleFlags &= ~TLSSF_Dispatch; \
91 } while(0)
92 #define FLAG_SCHEDDISPATCH_SET \
93 do { \
94 tls_t *__tls; \
95 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
96 __tls->ScheduleFlags |= TLSSF_Dispatch; \
97 } while(0)
98 #else
99 #define IDNESTCOUNT_INC \
100 do { \
101 tls_t *__tls; \
102 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
103 AROS_ATOMIC_INC(__tls->IDNestCnt); \
104 } while(0)
105 #define IDNESTCOUNT_DEC \
106 do { \
107 tls_t *__tls; \
108 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
109 AROS_ATOMIC_DEC(__tls->IDNestCnt); \
110 } while(0)
111 #define TDNESTCOUNT_INC \
112 do { \
113 tls_t *__tls; \
114 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
115 AROS_ATOMIC_INC(__tls->TDNestCnt); \
116 } while(0)
117 #define TDNESTCOUNT_DEC \
118 do { \
119 tls_t *__tls; \
120 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
121 AROS_ATOMIC_DEC(__tls->TDNestCnt); \
122 } while(0)
123 #define FLAG_SCHEDQUANTUM_CLEAR \
124 do { \
125 tls_t *__tls; \
126 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
127 AROS_ATOMIC_AND(__tls->ScheduleFlags, ~TLSSF_Quantum); \
128 } while(0)
129 #define FLAG_SCHEDQUANTUM_SET \
130 do { \
131 tls_t *__tls; \
132 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
133 AROS_ATOMIC_OR(__tls->ScheduleFlags, TLSSF_Quantum); \
134 } while(0)
135 #define FLAG_SCHEDSWITCH_CLEAR \
136 do { \
137 tls_t *__tls; \
138 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
139 AROS_ATOMIC_AND(__tls->ScheduleFlags, ~TLSSF_Switch); \
140 } while(0)
141 #define FLAG_SCHEDSWITCH_SET \
142 do { \
143 tls_t *__tls; \
144 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
145 AROS_ATOMIC_OR(__tls->ScheduleFlags, TLSSF_Switch); \
146 } while(0)
147 #define FLAG_SCHEDDISPATCH_CLEAR \
148 do { \
149 tls_t *__tls; \
150 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
151 AROS_ATOMIC_AND(__tls->ScheduleFlags, ~TLSSF_Dispatch); \
152 } while(0)
153 #define FLAG_SCHEDDISPATCH_SET \
154 do { \
155 tls_t *__tls; \
156 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
157 AROS_ATOMIC_OR(__tls->ScheduleFlags, TLSSF_Dispatch); \
158 } while(0)
159 #endif
160 #define IDNESTCOUNT_GET \
161 ({ \
162 tls_t *__tls; \
163 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
164 LONG __ret = (__tls->IDNestCnt); \
165 __ret; \
167 #define IDNESTCOUNT_SET(val) \
168 do { \
169 tls_t *__tls; \
170 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
171 __tls->IDNestCnt = val; \
172 } while(0)
173 #define TDNESTCOUNT_GET \
174 ({ \
175 tls_t *__tls; \
176 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
177 LONG __ret = (__tls->TDNestCnt); \
178 __ret; \
180 #define TDNESTCOUNT_SET(val) \
181 do { \
182 tls_t *__tls; \
183 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
184 __tls->TDNestCnt = val; \
185 } while(0)
186 #define FLAG_SCHEDQUANTUM_ISSET \
187 ({ \
188 tls_t *__tls; \
189 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
190 BOOL __ret = (__tls->ScheduleFlags & TLSSF_Quantum); \
191 __ret; \
193 #define FLAG_SCHEDSWITCH_ISSET \
194 ({ \
195 tls_t *__tls; \
196 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
197 BOOL __ret = (__tls->ScheduleFlags & TLSSF_Switch); \
198 __ret; \
200 #define FLAG_SCHEDDISPATCH_ISSET \
201 ({ \
202 tls_t *__tls; \
203 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
204 BOOL __ret = (__tls->ScheduleFlags & TLSSF_Dispatch); \
205 __ret; \
207 #define GET_THIS_TASK TLS_GET(ThisTask)
208 #if !defined(__AROSEXEC_SMP__)
209 #define SET_THIS_TASK(x) TLS_SET(ThisTask,(x))
210 #else
211 #define SET_THIS_TASK(x) TLS_SET(ThisTask,(x)); \
212 KrnSpinLock(&PrivExecBase(SysBase)->TaskRunningSpinLock, NULL, SPINLOCK_MODE_WRITE); \
213 AddHead(&PrivExecBase(SysBase)->TaskRunning, (struct Node *)(x)); \
214 KrnSpinUnLock(&PrivExecBase(SysBase)->TaskRunningSpinLock)
215 #endif
217 #endif /* __EXEC_PLATFORM_H */