First public contribution.
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\include\nkern\arm\nk_plat.h
16 // WARNING: This file contains some APIs which are internal and are subject
17 // to change without notice. Such APIs should therefore not be used
18 // outside the Kernel and Hardware Services package.
30 // These macros are intended for Symbian use only.
31 // It may not be possible to build the kernel if any of these macros are undefined
32 #define __SCHEDULER_MACHINE_CODED__
33 #define __DFC_MACHINE_CODED__
34 #define __MSTIM_MACHINE_CODED__
35 #define __PRI_LIST_MACHINE_CODED__
36 #define __FAST_SEM_MACHINE_CODED__
37 #define __FAST_MUTEX_MACHINE_CODED__
38 #define __USER_CONTEXT_TYPE_MACHINE_CODED__
39 #define __CLIENT_REQUEST_MACHINE_CODED__
41 // TScheduler member data
42 #define i_Regs iExtras[14]
43 #define i_ExcInfo iExtras[15] // pointer to exception info for crash debugger
45 const TUint32 KNThreadContextFlagThumbBit0=1;
47 #ifdef __CPU_ARM_USE_DOMAINS
48 #define DOMAIN_STACK_SPACE 4
50 #define DOMAIN_STACK_SPACE 0
52 #ifdef __CPU_HAS_COPROCESSOR_ACCESS_REG
53 #define CAR_STACK_SPACE 4
55 #define CAR_STACK_SPACE 0
58 #define VFP_STACK_SPACE 4
60 #define VFP_STACK_SPACE 0
62 #ifdef __CPU_HAS_CP15_THREAD_ID_REG
63 #define TID_STACK_SPACE 4
65 #define TID_STACK_SPACE 0
67 #ifdef __CPU_SUPPORT_THUMB2EE
68 #define THUMB2EE_STACK_SPACE 4
70 #define THUMB2EE_STACK_SPACE 0
73 #define EXTRA_STACK_SPACE (DOMAIN_STACK_SPACE+CAR_STACK_SPACE+VFP_STACK_SPACE+TID_STACK_SPACE+THUMB2EE_STACK_SPACE)
75 #ifdef __INCLUDE_REG_OFFSETS__
76 // Positions of registers on stack, relative to saved SP
77 #define EXTRA_WORDS (EXTRA_STACK_SPACE/4)
80 #define SP_FPEXC ((THUMB2EE_STACK_SPACE+TID_STACK_SPACE)/4)
82 #ifdef __CPU_HAS_COPROCESSOR_ACCESS_REG
83 #define SP_CAR ((THUMB2EE_STACK_SPACE+TID_STACK_SPACE+VFP_STACK_SPACE)/4)
85 #ifdef __CPU_ARM_USE_DOMAINS
86 #define SP_DACR ((THUMB2EE_STACK_SPACE+TID_STACK_SPACE+VFP_STACK_SPACE+CAR_STACK_SPACE)/4)
89 #define SP_R13U EXTRA_WORDS
90 #define SP_R14U (SP_R13U+1)
91 #define SP_SPSR (SP_R13U+2)
92 #define SP_R4 (SP_R13U+3)
93 #define SP_R5 (SP_R13U+4)
94 #define SP_R6 (SP_R13U+5)
95 #define SP_R7 (SP_R13U+6)
96 #define SP_R8 (SP_R13U+7)
97 #define SP_R9 (SP_R13U+8)
98 #define SP_R10 (SP_R13U+9)
99 #define SP_R11 (SP_R13U+10)
100 #define SP_PC (SP_R13U+11)
102 #define SP_NEXT (SP_PC+1) // first word on stack before reschedule
103 #endif // __INCLUDE_REG_OFFSETS__
105 class TArmContextElement;
108 /** ARM-specific part of the nano-thread abstraction.
111 class NThread : public NThreadBase
114 TInt Create(SNThreadCreateInfo& aInfo, TBool aInitial);
115 inline void Stillborn()
118 /** Value indicating what event caused thread to enter privileged mode.
122 enum TUserContextType
124 EContextNone=0, /**< Thread has no user context */
125 EContextException=1, /**< Hardware exception while in user mode */
127 EContextUserInterrupt, /**< Preempted by interrupt taken in user mode */
128 EContextUserInterruptDied, /**< Killed while preempted by interrupt taken in user mode */
129 EContextSvsrInterrupt1, /**< Preempted by interrupt taken in executive call handler */
130 EContextSvsrInterrupt1Died, /**< Killed while preempted by interrupt taken in executive call handler */
131 EContextSvsrInterrupt2, /**< Preempted by interrupt taken in executive call handler */
132 EContextSvsrInterrupt2Died, /**< Killed while preempted by interrupt taken in executive call handler */
133 EContextWFAR, /**< Blocked on User::WaitForAnyRequest() */
134 EContextWFARDied, /**< Killed while blocked on User::WaitForAnyRequest() */
135 EContextExec, /**< Slow executive call */
136 EContextKernel, /**< Kernel side context (for kernel threads) */
137 EContextUserIntrCallback, /**< Blocked/preempted in a user callback on the way back from interrupt */
138 EContextWFARCallback, /**< Blocked/preempted in a user callback on the way back from User::WFAR */
141 IMPORT_C static const TArmContextElement* const* UserContextTables();
142 IMPORT_C TUserContextType UserContextType();
143 inline TInt SetUserContextType()
144 { return iSpare3=UserContextType(); }
145 inline void ResetUserContextType()
146 { if(iSpare3>EContextUndefined && iSpare3<EContextUserIntrCallback) iSpare3=EContextUndefined; }
147 void GetContext(TArmRegSet& aContext, TUint32& aAvailRegistersMask, const TArmContextElement* aContextTable);
148 void GetUserContext(TArmRegSet& aContext, TUint32& aAvailRegistersMask);
149 void SetUserContext(const TArmRegSet& aContext);
150 void GetSystemContext(TArmRegSet& aContext, TUint32& aAvailRegistersMask);
152 void ModifyUsp(TLinAddr aUsp);
154 #ifdef __CPU_ARM_USE_DOMAINS
156 void SetDacr(TUint32 aDacr);
157 TUint32 ModifyDacr(TUint32 aClearMask, TUint32 aSetMask);
160 #ifdef __CPU_HAS_COPROCESSOR_ACCESS_REG
161 void SetCar(TUint32 aDacr);
163 IMPORT_C TUint32 Car();
164 IMPORT_C TUint32 ModifyCar(TUint32 aClearMask, TUint32 aSetMask);
167 void SetFpExc(TUint32 aDacr);
169 IMPORT_C TUint32 FpExc();
170 IMPORT_C TUint32 ModifyFpExc(TUint32 aClearMask, TUint32 aSetMask);
174 struct SArmInterruptInfo
176 TLinAddr iIrqHandler;
177 TLinAddr iFiqHandler;
178 TUint8 iCpuUsageFilter;
179 BTrace::THandler iBTraceHandler;
180 SCpuIdleHandler iCpuIdleHandler;
183 extern "C" SArmInterruptInfo ArmInterruptInfo;