2 Copyright © 2015, The AROS Development Team. All rights reserved.
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))
32 struct Exec_PlatformData
34 /* No platform-specific data by default */
37 #if defined(AROS_NO_ATOMIC_OPERATIONS)
38 #define IDNESTCOUNT_INC \
41 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
44 #define IDNESTCOUNT_DEC \
47 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
50 #define TDNESTCOUNT_INC \
53 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
56 #define TDNESTCOUNT_DEC \
59 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
62 #define FLAG_SCHEDQUANTUM_CLEAR \
65 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
66 __tls->ScheduleFlags &= ~TLSSF_Quantum; \
68 #define FLAG_SCHEDQUANTUM_SET \
71 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
72 __tls->ScheduleFlags |= TLSSF_Quantum; \
74 #define FLAG_SCHEDSWITCH_CLEAR \
77 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
78 __tls->ScheduleFlags &= ~TLSSF_Switch; \
80 #define FLAG_SCHEDSWITCH_SET \
83 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
84 __tls->ScheduleFlags |= TLSSF_Switch; \
86 #define FLAG_SCHEDDISPATCH_CLEAR \
89 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
90 __tls->ScheduleFlags &= ~TLSSF_Dispatch; \
92 #define FLAG_SCHEDDISPATCH_SET \
95 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
96 __tls->ScheduleFlags |= TLSSF_Dispatch; \
99 #define IDNESTCOUNT_INC \
102 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
103 AROS_ATOMIC_INC(__tls->IDNestCnt); \
105 #define IDNESTCOUNT_DEC \
108 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
109 AROS_ATOMIC_DEC(__tls->IDNestCnt); \
111 #define TDNESTCOUNT_INC \
114 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
115 AROS_ATOMIC_INC(__tls->TDNestCnt); \
117 #define TDNESTCOUNT_DEC \
120 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
121 AROS_ATOMIC_DEC(__tls->TDNestCnt); \
123 #define FLAG_SCHEDQUANTUM_CLEAR \
126 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
127 AROS_ATOMIC_AND(__tls->ScheduleFlags, ~TLSSF_Quantum); \
129 #define FLAG_SCHEDQUANTUM_SET \
132 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
133 AROS_ATOMIC_OR(__tls->ScheduleFlags, TLSSF_Quantum); \
135 #define FLAG_SCHEDSWITCH_CLEAR \
138 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
139 AROS_ATOMIC_AND(__tls->ScheduleFlags, ~TLSSF_Switch); \
141 #define FLAG_SCHEDSWITCH_SET \
144 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
145 AROS_ATOMIC_OR(__tls->ScheduleFlags, TLSSF_Switch); \
147 #define FLAG_SCHEDDISPATCH_CLEAR \
150 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
151 AROS_ATOMIC_AND(__tls->ScheduleFlags, ~TLSSF_Dispatch); \
153 #define FLAG_SCHEDDISPATCH_SET \
156 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
157 AROS_ATOMIC_OR(__tls->ScheduleFlags, TLSSF_Dispatch); \
160 #define IDNESTCOUNT_GET \
163 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
164 LONG __ret = (__tls->IDNestCnt); \
167 #define IDNESTCOUNT_SET(val) \
170 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
171 __tls->IDNestCnt = val; \
173 #define TDNESTCOUNT_GET \
176 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
177 LONG __ret = (__tls->TDNestCnt); \
180 #define TDNESTCOUNT_SET(val) \
183 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
184 __tls->TDNestCnt = val; \
186 #define FLAG_SCHEDQUANTUM_ISSET \
189 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
190 BOOL __ret = (__tls->ScheduleFlags & TLSSF_Quantum); \
193 #define FLAG_SCHEDSWITCH_ISSET \
196 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
197 BOOL __ret = (__tls->ScheduleFlags & TLSSF_Switch); \
200 #define FLAG_SCHEDDISPATCH_ISSET \
203 asm volatile("mrc p15, 0, %0, c13, c0, 3":"=r"(__tls)); \
204 BOOL __ret = (__tls->ScheduleFlags & TLSSF_Dispatch); \
207 #define GET_THIS_TASK TLS_GET(ThisTask)
208 #if !defined(__AROSEXEC_SMP__)
209 #define SET_THIS_TASK(x) TLS_SET(ThisTask,(x))
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)
217 #endif /* __EXEC_PLATFORM_H */