0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32\include\nkern\arm\nk_plat.h
|
|
15 |
//
|
|
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.
|
|
19 |
//
|
|
20 |
|
|
21 |
/**
|
|
22 |
@file
|
|
23 |
@internalComponent
|
|
24 |
*/
|
|
25 |
|
|
26 |
#ifndef __NK_ARM_H__
|
|
27 |
#define __NK_ARM_H__
|
|
28 |
#include <nk_cpu.h>
|
|
29 |
|
|
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__
|
|
40 |
|
|
41 |
// TScheduler member data
|
|
42 |
#define i_Regs iExtras[14]
|
|
43 |
#define i_ExcInfo iExtras[15] // pointer to exception info for crash debugger
|
|
44 |
|
|
45 |
const TUint32 KNThreadContextFlagThumbBit0=1;
|
|
46 |
|
|
47 |
#ifdef __CPU_ARM_USE_DOMAINS
|
|
48 |
#define DOMAIN_STACK_SPACE 4
|
|
49 |
#else
|
|
50 |
#define DOMAIN_STACK_SPACE 0
|
|
51 |
#endif
|
|
52 |
#ifdef __CPU_HAS_COPROCESSOR_ACCESS_REG
|
|
53 |
#define CAR_STACK_SPACE 4
|
|
54 |
#else
|
|
55 |
#define CAR_STACK_SPACE 0
|
|
56 |
#endif
|
|
57 |
#ifdef __CPU_HAS_VFP
|
|
58 |
#define VFP_STACK_SPACE 4
|
|
59 |
#else
|
|
60 |
#define VFP_STACK_SPACE 0
|
|
61 |
#endif
|
|
62 |
#ifdef __CPU_HAS_CP15_THREAD_ID_REG
|
|
63 |
#define TID_STACK_SPACE 4
|
|
64 |
#else
|
|
65 |
#define TID_STACK_SPACE 0
|
|
66 |
#endif
|
|
67 |
#ifdef __CPU_SUPPORT_THUMB2EE
|
|
68 |
#define THUMB2EE_STACK_SPACE 4
|
|
69 |
#else
|
|
70 |
#define THUMB2EE_STACK_SPACE 0
|
|
71 |
#endif
|
|
72 |
|
|
73 |
#define EXTRA_STACK_SPACE (DOMAIN_STACK_SPACE+CAR_STACK_SPACE+VFP_STACK_SPACE+TID_STACK_SPACE+THUMB2EE_STACK_SPACE)
|
|
74 |
|
|
75 |
#ifdef __INCLUDE_REG_OFFSETS__
|
|
76 |
// Positions of registers on stack, relative to saved SP
|
|
77 |
#define EXTRA_WORDS (EXTRA_STACK_SPACE/4)
|
|
78 |
|
|
79 |
#ifdef __CPU_HAS_VFP
|
|
80 |
#define SP_FPEXC ((THUMB2EE_STACK_SPACE+TID_STACK_SPACE)/4)
|
|
81 |
#endif
|
|
82 |
#ifdef __CPU_HAS_COPROCESSOR_ACCESS_REG
|
|
83 |
#define SP_CAR ((THUMB2EE_STACK_SPACE+TID_STACK_SPACE+VFP_STACK_SPACE)/4)
|
|
84 |
#endif
|
|
85 |
#ifdef __CPU_ARM_USE_DOMAINS
|
|
86 |
#define SP_DACR ((THUMB2EE_STACK_SPACE+TID_STACK_SPACE+VFP_STACK_SPACE+CAR_STACK_SPACE)/4)
|
|
87 |
#endif
|
|
88 |
|
|
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)
|
|
101 |
|
|
102 |
#define SP_NEXT (SP_PC+1) // first word on stack before reschedule
|
|
103 |
#endif // __INCLUDE_REG_OFFSETS__
|
|
104 |
|
|
105 |
class TArmContextElement;
|
|
106 |
class TArmRegSet;
|
|
107 |
|
|
108 |
/** ARM-specific part of the nano-thread abstraction.
|
|
109 |
@internalComponent
|
|
110 |
*/
|
|
111 |
class NThread : public NThreadBase
|
|
112 |
{
|
|
113 |
public:
|
|
114 |
TInt Create(SNThreadCreateInfo& aInfo, TBool aInitial);
|
|
115 |
inline void Stillborn()
|
|
116 |
{}
|
|
117 |
|
|
118 |
/** Value indicating what event caused thread to enter privileged mode.
|
|
119 |
@publishedPartner
|
|
120 |
@released
|
|
121 |
*/
|
|
122 |
enum TUserContextType
|
|
123 |
{
|
|
124 |
EContextNone=0, /**< Thread has no user context */
|
|
125 |
EContextException=1, /**< Hardware exception while in user mode */
|
|
126 |
EContextUndefined,
|
|
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 */
|
|
139 |
};
|
|
140 |
|
|
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);
|
|
151 |
|
|
152 |
void ModifyUsp(TLinAddr aUsp);
|
|
153 |
|
|
154 |
#ifdef __CPU_ARM_USE_DOMAINS
|
|
155 |
TUint32 Dacr();
|
|
156 |
void SetDacr(TUint32 aDacr);
|
|
157 |
TUint32 ModifyDacr(TUint32 aClearMask, TUint32 aSetMask);
|
|
158 |
#endif
|
|
159 |
|
|
160 |
#ifdef __CPU_HAS_COPROCESSOR_ACCESS_REG
|
|
161 |
void SetCar(TUint32 aDacr);
|
|
162 |
#endif
|
|
163 |
IMPORT_C TUint32 Car();
|
|
164 |
IMPORT_C TUint32 ModifyCar(TUint32 aClearMask, TUint32 aSetMask);
|
|
165 |
|
|
166 |
#ifdef __CPU_HAS_VFP
|
|
167 |
void SetFpExc(TUint32 aDacr);
|
|
168 |
#endif
|
|
169 |
IMPORT_C TUint32 FpExc();
|
|
170 |
IMPORT_C TUint32 ModifyFpExc(TUint32 aClearMask, TUint32 aSetMask);
|
|
171 |
};
|
|
172 |
|
|
173 |
|
|
174 |
struct SArmInterruptInfo
|
|
175 |
{
|
|
176 |
TLinAddr iIrqHandler;
|
|
177 |
TLinAddr iFiqHandler;
|
|
178 |
TUint8 iCpuUsageFilter;
|
|
179 |
BTrace::THandler iBTraceHandler;
|
|
180 |
SCpuIdleHandler iCpuIdleHandler;
|
|
181 |
};
|
|
182 |
|
|
183 |
extern "C" SArmInterruptInfo ArmInterruptInfo;
|
|
184 |
|
|
185 |
#endif
|