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