author | hgs |
Tue, 02 Nov 2010 15:29:23 +0000 | |
changeset 300 | 1d28c8722707 |
parent 177 | a232af6b0b1f |
permissions | -rw-r--r-- |
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\kernel\kern_priv.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 __K32KERN_H__ |
|
27 |
#define __K32KERN_H__ |
|
28 |
#include <kernel/kernel.h> |
|
29 |
#include <nk_priv.h> |
|
30 |
#include <kernel/kpower.h> |
|
31 |
#include <platform.h> |
|
32 |
#include <e32uid.h> |
|
33 |
#include <kernel/kernboot.h> |
|
34 |
#include <e32def_private.h> |
|
35 |
#include <e32const_private.h> |
|
36 |
#include <e32des8_private.h> |
|
37 |
#include <e32event_private.h> |
|
121 | 38 |
#include <kernel/heap_hybrid.h> |
0 | 39 |
|
40 |
#ifndef __MINIMUM_MACHINE_CODE__ |
|
41 |
#ifdef __MARM__ |
|
42 |
#ifndef __BIG_ENDIAN__ |
|
43 |
||
44 |
#ifdef __SMP__ |
|
45 |
#define __FASTEXEC_MACHINE_CODED__ |
|
46 |
#define __TBMA_MACHINE_CODED__ |
|
47 |
#else |
|
48 |
// These macros are intended for Symbian use only. |
|
49 |
// It may not be possible to build the kernel if particular combinations |
|
50 |
// of these macros are undefined |
|
51 |
#define __FASTEXEC_MACHINE_CODED__ |
|
52 |
#define __MMU_MACHINE_CODED__ |
|
53 |
#define __PROCESS_MACHINE_CODED__ |
|
54 |
#define __TBMA_MACHINE_CODED__ |
|
55 |
#define __MESSAGE_MACHINE_CODED_2__ |
|
56 |
#define __HANDLES_MACHINE_CODED__ |
|
57 |
#define __REQUEST_COMPLETE_MACHINE_CODED__ |
|
58 |
#define __MESSAGE_MACHINE_CODED__ |
|
59 |
#endif |
|
60 |
||
61 |
#endif |
|
62 |
#endif |
|
63 |
#endif |
|
64 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
65 |
// size of each buffer used to store entropy data before it is passed to the RNG |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
66 |
const TUint KEntropyBufferSizeWords = 1024;// maximum size of 1024 words (32Kbit); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
67 |
|
0 | 68 |
const TInt KKernelServerDefaultPriority=16; |
69 |
const TInt KDefaultExitPriority=KKernelServerDefaultPriority; |
|
70 |
||
71 |
// counter to ensure that priority inheritance has bounded execution time |
|
72 |
const TInt KMaxPriorityInheritanceNesting=10; |
|
73 |
||
74 |
||
75 |
const TInt KArgIndex = 16; //number of slots in DProcess for passing info to child process on creation |
|
76 |
||
77 |
const TInt KDefaultMaxMemCopyInOneGo = 512; |
|
78 |
||
79 |
// Forward declare Shareable data buffer classes |
|
80 |
class DShPool; |
|
81 |
class TShPoolCreateInfo; |
|
82 |
||
83 |
//Forward declare Debug namespace for StopMode API |
|
84 |
namespace Debug { class StopModeDebug; } |
|
85 |
||
86 |
/*************************************************** |
|
87 |
* Kernel-side trap harness for catching exceptions |
|
88 |
* Not nestable, one per thread only |
|
89 |
***************************************************/ |
|
90 |
class TExcTrap; |
|
91 |
typedef void (*TExcTrapHandler)(TExcTrap*,DThread*,TAny*); |
|
92 |
||
93 |
class TExcTrap |
|
94 |
{ |
|
95 |
public: |
|
96 |
IMPORT_C TInt Trap(); // use default exception handler |
|
97 |
IMPORT_C TInt Trap(TExcTrapHandler aHandler); |
|
98 |
inline void UnTrap(); |
|
99 |
IMPORT_C void Exception(TInt aResult); |
|
100 |
public: |
|
101 |
TUint32 iState[EXC_TRAP_CTX_SZ]; |
|
102 |
TExcTrapHandler iHandler; |
|
103 |
DThread* iThread; |
|
104 |
}; |
|
105 |
||
106 |
class TPagingExcTrap |
|
107 |
{ |
|
108 |
public: |
|
109 |
TInt Trap(); |
|
110 |
inline void UnTrap(); |
|
111 |
void Exception(TInt aResult); |
|
112 |
public: |
|
113 |
TUint32 iState[EXC_TRAP_CTX_SZ]; |
|
114 |
DThread* iThread; |
|
115 |
}; |
|
116 |
||
117 |
#define XT_DEFAULT |
|
118 |
#define XTRAP(_r,_h,_s) { \ |
|
119 |
TExcTrap __t; \ |
|
120 |
if (((_r)=__t.Trap(_h))==0) \ |
|
121 |
{ \ |
|
122 |
_s; \ |
|
123 |
__t.UnTrap(); \ |
|
124 |
} \ |
|
125 |
} |
|
126 |
||
127 |
#define XTRAPD(_r,_h,_s) TInt _r; \ |
|
128 |
{ \ |
|
129 |
TExcTrap __t; \ |
|
130 |
if (((_r)=__t.Trap(_h))==0) \ |
|
131 |
{ \ |
|
132 |
_s; \ |
|
133 |
__t.UnTrap(); \ |
|
134 |
} \ |
|
135 |
} |
|
136 |
||
137 |
#ifdef __DEMAND_PAGING__ |
|
138 |
||
139 |
#define CHECK_PAGING_SAFE __NK_ASSERT_DEBUG(M::CheckPagingSafe(EFalse)) |
|
140 |
||
141 |
#define CHECK_PAGING_SAFE_RANGE(s, l) __NK_ASSERT_DEBUG(M::CheckPagingSafe(EFalse, (s), (l))) |
|
142 |
||
143 |
#define CHECK_DATA_PAGING_SAFE __NK_ASSERT_DEBUG(M::CheckPagingSafe(ETrue)) |
|
144 |
||
145 |
#define CHECK_DATA_PAGING_SAFE_RANGE(s, l) __NK_ASSERT_DEBUG(M::CheckPagingSafe(ETrue, (s), (l))) |
|
146 |
||
147 |
// |
|
148 |
// Important - Do not use XTRAP inside an XTRAP_PAGING |
|
149 |
// I.e. |
|
150 |
// XTRAP(XTRAP_PAGING(foo)) |
|
151 |
// is OK, but |
|
152 |
// XTRAP_PAGING(XTRAP(foo)) |
|
153 |
// will put the system into a bad state when a paging exception happens |
|
154 |
// because TExcTrap::UnTrap won't get called. |
|
155 |
// |
|
156 |
||
157 |
#define XTRAP_PAGING(_r,_s) { \ |
|
158 |
TPagingExcTrap __t; \ |
|
159 |
if (((_r)=__t.Trap())==0) \ |
|
160 |
{ \ |
|
161 |
_s; \ |
|
162 |
__t.UnTrap(); \ |
|
163 |
} \ |
|
164 |
} |
|
165 |
||
166 |
#define XTRAP_PAGING_START(_r) { \ |
|
167 |
TPagingExcTrap __t; \ |
|
168 |
if (((_r)=__t.Trap())==0) \ |
|
169 |
{ |
|
170 |
||
171 |
#define XTRAP_PAGING_END __t.UnTrap(); \ |
|
172 |
} \ |
|
173 |
} |
|
174 |
||
175 |
#define XTRAP_PAGING_RETRY(_s) { \ |
|
176 |
_retry: \ |
|
177 |
TInt _exc; \ |
|
178 |
XTRAP_PAGING_START(_exc); \ |
|
179 |
_s; \ |
|
180 |
XTRAP_PAGING_END; \ |
|
181 |
if(_exc) goto _retry; \ |
|
182 |
} |
|
183 |
||
184 |
#else |
|
185 |
||
186 |
#define XTRAP_PAGING(_r,_s) { _s } |
|
187 |
#define XTRAP_PAGING_START(_r) {_r=0;{ |
|
188 |
#define XTRAP_PAGING_END }} |
|
189 |
#define CHECK_PAGING_SAFE |
|
190 |
#define CHECK_PAGING_SAFE_RANGE(s, l) |
|
191 |
#define CHECK_DATA_PAGING_SAFE |
|
192 |
#define CHECK_DATA_PAGING_SAFE_RANGE(s, l) |
|
193 |
#define XTRAP_PAGING_RETRY(_s) { _s } |
|
194 |
||
195 |
#endif |
|
196 |
||
197 |
class TIpcExcTrap : public TExcTrap |
|
198 |
{ |
|
199 |
public: |
|
200 |
TInt Trap(DThread* aClientThread); // use default ipc exception handler |
|
201 |
inline void UnTrap(); |
|
202 |
enum TExcLocation { EExcUnknown, EExcLocal, EExcRemote }; |
|
203 |
TExcLocation ExcLocation(DThread* aThread, TAny* aContext); |
|
204 |
TBool IsTIpcExcTrap(); |
|
205 |
public: |
|
206 |
TLinAddr iLocalBase; |
|
207 |
TLinAddr iRemoteBase; |
|
208 |
TUint32 iSize; |
|
209 |
TInt iDir; // 0=read, 1=write |
|
210 |
}; |
|
211 |
||
212 |
||
213 |
||
214 |
/************************************************** |
|
215 |
* Structure used for miscellaneous notifications |
|
216 |
**************************************************/ |
|
217 |
class TMiscNotifier : public TClientRequest |
|
218 |
{ |
|
219 |
public: |
|
220 |
SDblQueLink iThreadLink; |
|
221 |
SDblQueLink iObjLink; |
|
222 |
DThread* iThread; // doesn't need to be reference counted since all notifiers are removed when thread terminates |
|
223 |
private: |
|
224 |
~TMiscNotifier(); // call Close(), don't delete |
|
225 |
}; |
|
226 |
||
227 |
struct SMiscNotifierQ : public SDblQue |
|
228 |
{ |
|
229 |
}; |
|
230 |
||
231 |
class TMiscNotifierMgr |
|
232 |
{ |
|
233 |
public: |
|
234 |
TMiscNotifierMgr(); |
|
235 |
void Init2(); |
|
236 |
void CompleteNotifications(SDblQue& aQ); |
|
237 |
static void CompletionDfcFn(TAny* aMgr); |
|
238 |
static void IdleDfcFn(TAny* aMgr); |
|
239 |
inline void Lock() |
|
240 |
{NKern::FMWait(&iLock);} |
|
241 |
inline void Unlock() |
|
242 |
{NKern::FMSignal(&iLock);} |
|
243 |
TInt NewMiscNotifier(TRequestStatus* aStatus, TBool aObj, TAny* aPtr, TMiscNotifier*& aN, SMiscNotifierQ*& aQ); |
|
244 |
public: |
|
245 |
SDblQue iCompleted; |
|
246 |
TDfc iCompletionDfc; |
|
247 |
SMiscNotifierQ* iIdleNotifierQ; |
|
248 |
TDfc iIdleDfc; |
|
249 |
NFastMutex iLock; |
|
250 |
}; |
|
251 |
||
252 |
||
253 |
||
254 |
/******************************************** |
|
255 |
* Kernel object index (handles array) |
|
256 |
********************************************/ |
|
257 |
class DMutex; |
|
258 |
||
259 |
/** Handle analysis and synthesis |
|
260 |
@internalComponent |
|
261 |
*/ |
|
262 |
inline TBool HandleIsSpecial(TInt aHandle) |
|
263 |
{ return aHandle<0; } |
|
264 |
inline TBool HandleIsThreadLocal(TInt aHandle) |
|
265 |
{ return aHandle&0x40000000; } |
|
266 |
inline TBool HandleNoClose(TInt aHandle) |
|
267 |
{ return aHandle&0x00008000; } |
|
268 |
inline TInt HandleIndex(TInt aHandle) |
|
269 |
{ return aHandle&0x00007FFF; } |
|
270 |
inline TInt HandleInstance(TInt aHandle) |
|
271 |
{ return (aHandle&0x3FFF0000)>>16; } |
|
272 |
inline TInt MakeHandle(TInt aIndex, TInt aInstance) |
|
273 |
{ return ((aInstance&0x3FFF)<<16)|(aIndex&0x7FFF); } |
|
274 |
||
275 |
||
276 |
/** |
|
277 |
@internalComponent |
|
278 |
*/ |
|
279 |
class RObjectIx |
|
280 |
{ |
|
281 |
public: |
|
282 |
enum {ENoClose=KHandleNoClose,ELocalHandle=0x40000000}; |
|
283 |
enum {EReserved=0x80000000u, EAttributeMask=0xfffu}; |
|
284 |
enum {EMinSlots=8, EMaxSlots=32768}; |
|
285 |
public: |
|
286 |
enum {ENumFreeQ=6, EModCount=4, EBitMapSize=128, EMaxLockedIter=8}; |
|
287 |
private: |
|
288 |
// queue numbers |
|
289 |
enum {EQFree=-6, EQAltFree=-5, EQTempFree=-4, EQRsvd=-3, EQAltRsvd=-2, EQTempRsvd=-1}; |
|
290 |
// iObjR, iRsvd fields |
|
291 |
enum {EObjROccupied=4u, EObjRObjMask=0xfffffffcu, EObjRRsvd=1u}; |
|
292 |
// states |
|
293 |
enum {ENormal=0u, ETidying=1u, EFindingLast=2u, ECounting=3u, ESearching=4u, ETerminated=5u}; |
|
294 |
struct SSlotQLink |
|
295 |
{ |
|
296 |
TInt16 iNext; // pointer to next free slot, -n if no next |
|
297 |
TInt16 iPrev; // pointer to previous free slot, -n if no previous |
|
298 |
}; |
|
299 |
struct SFreeSlot : public SSlotQLink |
|
300 |
{ |
|
301 |
TUint32 iRsvd; // 0 for normal, 1 for reserved slot |
|
302 |
}; |
|
303 |
struct SUsedSlot |
|
304 |
{ |
|
305 |
TUint32 iAttr; // bits 0-13 = instance (nonzero), bits 14-19 = object type, bits 20-31 = handle attributes |
|
306 |
TUint32 iObjR; // pointer to object (nonzero), bit 0=1 if reserved slot |
|
307 |
}; |
|
308 |
union SSlot |
|
309 |
{ |
|
310 |
SFreeSlot iFree; |
|
311 |
SUsedSlot iUsed; |
|
312 |
}; |
|
313 |
struct SMonitorObj |
|
314 |
{ |
|
315 |
DObject* iObj; |
|
316 |
TInt iBoundary; |
|
317 |
TInt iResult; |
|
318 |
}; |
|
319 |
union SModList |
|
320 |
{ |
|
321 |
TInt16 iIndex[EModCount]; |
|
322 |
TUint32 iBitMap[EBitMapSize/32]; |
|
323 |
SMonitorObj iMonitor; |
|
324 |
}; |
|
325 |
private: |
|
326 |
#ifdef __HANDLES_USE_RW_SPIN_LOCK__ |
|
327 |
// Beginning of support for spinlock-only protection (i.e. not requiring the system lock) |
|
328 |
// for access to handles. Requires changes everywhere objects returned from handles are |
|
329 |
// used, and some additional work in the handle lookup code in cutils.cia. |
|
330 |
#error "spinlocks for handle lookup not supported" |
|
331 |
inline void AcquireReadLock() |
|
332 |
{ __SPIN_LOCK_IRQ_R(iRWL); } |
|
333 |
inline void ReleaseReadLock() |
|
334 |
{ __SPIN_UNLOCK_IRQ_R(iRWL); } |
|
335 |
inline void AcquireWriteLock() |
|
336 |
{ __SPIN_LOCK_IRQ_W(iRWL); } |
|
337 |
inline void ReleaseWriteLock() |
|
338 |
{ __SPIN_UNLOCK_IRQ_W(iRWL); } |
|
339 |
#else |
|
340 |
/* Places which use a read lock would already have the system lock held */ |
|
341 |
inline void AcquireReadLock() |
|
342 |
{ __ASSERT_SYSTEM_LOCK; } |
|
343 |
inline void ReleaseReadLock() |
|
344 |
{ } |
|
345 |
inline void AcquireWriteLock() |
|
346 |
{ NKern::LockSystem(); } |
|
347 |
inline void ReleaseWriteLock() |
|
348 |
{ NKern::UnlockSystem(); } |
|
349 |
#endif |
|
350 |
private: |
|
351 |
static inline DObject* Occupant(SSlot* aS) |
|
352 |
{ return (DObject*)(aS->iUsed.iObjR & EObjRObjMask); } |
|
353 |
static inline TBool IsReserved(SSlot* aS) |
|
354 |
{ return aS->iUsed.iObjR & EObjRRsvd; } |
|
355 |
static inline TBool IsFreeReserved(SSlot* aS) |
|
356 |
{ return (aS->iUsed.iObjR & EObjRRsvd) && (aS->iUsed.iObjR<EObjROccupied); } |
|
357 |
void Empty(TInt aQueue); |
|
358 |
SSlot* Dequeue(TInt aSlotIndex); |
|
359 |
inline void AddHead(TInt aQueue, TInt aSlotIndex); |
|
360 |
inline void AddTail(TInt aQueue, TInt aSlotIndex); |
|
361 |
void AddBefore(TInt aBase, TInt aSlotIndex); |
|
362 |
void AddAfter(TInt aBase, TInt aSlotIndex); |
|
363 |
void AppendList(TInt aSrcQ, TInt aDestQ); |
|
364 |
void PrependList(TInt aSrcQ, TInt aDestQ); |
|
365 |
TInt DoAdd(DObject* aObj, TUint32 aAttr, SSlot* aSlot); // add aObj using an existing slot (don't grow) |
|
366 |
TInt DoRemove(TInt aHandle, DObject*& aObject, TUint32& aAttr); // remove a handle (don't shrink) |
|
367 |
void MarkModified(TInt aSlotIndex); |
|
368 |
static TUint32 GetNextInstanceValue(); |
|
369 |
TInt UnReserveSlots(TInt aCount, TBool aAmortize); |
|
370 |
TInt ReserveSlots(TInt aCount); |
|
371 |
TInt Grow(TInt aReserve, SSlot* aSlotData); |
|
372 |
void TidyAndCompact(); |
|
373 |
inline SSlotQLink* Link(TInt aIndex) |
|
374 |
{ return (aIndex<0) ? (iFreeQ+ENumFreeQ+aIndex) : &(iSlots+aIndex)->iFree; } |
|
375 |
public: |
|
376 |
// common operations |
|
377 |
RObjectIx(); |
|
378 |
TInt Close(TAny* aPtr); |
|
379 |
||
380 |
TInt Add(DObject* aObj, TUint32 aAttr); |
|
381 |
TInt Remove(TInt aHandle, DObject*& aObject, TUint32& aAttr); |
|
382 |
TInt Reserve(TInt aCount); |
|
383 |
DObject* At(TInt aHandle, TInt aUniqueID, TUint32 aRequiredAttr); |
|
384 |
DObject* At(TInt aHandle, TInt aUniqueID, TUint32* aAttr); |
|
385 |
DObject* At(TInt aHandle, TInt aUniqueID); |
|
386 |
DObject* At(TInt aHandle); |
|
387 |
static void Wait(); |
|
388 |
static void Signal(); |
|
389 |
inline TInt Count() |
|
390 |
{ return iCount; } |
|
391 |
inline TInt ActiveCount() |
|
392 |
{ return iActiveCount; } |
|
393 |
public: |
|
394 |
// uncommon operations |
|
395 |
DObject* operator[](TInt aIndex); |
|
396 |
TInt At(DObject* aObject); |
|
397 |
TInt Count(DObject* aObject); |
|
398 |
TInt LastHandle(); |
|
399 |
#ifdef DOBJECT_TEST_CODE |
|
400 |
typedef void (*TValidateEntry)(TInt, TInt, TInt, TInt, TUint, DObject*); |
|
401 |
void Check(TValidateEntry aV); |
|
402 |
#endif |
|
403 |
private: |
|
404 |
TRWSpinLock iRWL; |
|
405 |
TInt iAllocated; // Max entries before realloc needed |
|
406 |
volatile TInt iCount; // Points to at least 1 above the highest occupied slot or unoccupied reserved slot |
|
407 |
volatile TInt iActiveCount; // Number of occupied entries in the index (reserved or normal) |
|
408 |
volatile TInt iReservedFree; // Number of unoccupied reserved slots |
|
409 |
volatile TInt iReservedTotal; // Number of reserved slots (occupied or unoccupied) |
|
410 |
volatile TInt iReservedFreeHWM; // Points to at least 1 above the last unoccupied reserved slot |
|
411 |
SSlotQLink iFreeQ[ENumFreeQ]; // queues of free slots |
|
412 |
SSlot* iSlots; // array of handle slots |
|
413 |
TInt iAmortize; // Number of handle removals before we see if we can shrink |
|
414 |
TUint8 iState; |
|
415 |
TUint8 iModCount; // 255=not in use, 0...EModCount->use iModList.iIndex[], EModCount+1->use iModList.iBitMap |
|
416 |
TUint8 iModListShift; |
|
417 |
TUint8 iSpare1; |
|
418 |
SModList iModList; // Entries modified while array moving |
|
419 |
public: |
|
420 |
static volatile TUint32 NextInstance; |
|
421 |
static DMutex* HandleMutex; |
|
422 |
public: |
|
423 |
friend void PreprocessHandler(); |
|
424 |
friend class DThread; |
|
425 |
friend class K; |
|
426 |
friend class Monitor; |
|
427 |
}; |
|
428 |
// |
|
429 |
// These are the same as their e32base.h versions |
|
430 |
/*inline TBool IsLocalHandle(TInt aHandle) |
|
431 |
{return(aHandle&RObjectIx::ELocalHandle);} |
|
432 |
inline void SetLocalHandle(TInt &aHandle) |
|
433 |
{aHandle|=RObjectIx::ELocalHandle;} |
|
434 |
inline void UnSetLocalHandle(TInt &aHandle) |
|
435 |
{aHandle&=(~RObjectIx::ELocalHandle);} |
|
436 |
*/ |
|
437 |
/******************************************** |
|
438 |
* Kernel object container |
|
439 |
********************************************/ |
|
440 |
class DObjectCon : public DBase |
|
441 |
{ |
|
442 |
protected: |
|
443 |
enum {ENotOwnerID}; |
|
444 |
public: |
|
445 |
~DObjectCon(); |
|
446 |
static DObjectCon* New(TInt aUniqueID); |
|
447 |
IMPORT_C void Remove(DObject* aObj); |
|
448 |
IMPORT_C TInt Add(DObject* aObj); |
|
449 |
IMPORT_C DObject* operator[](TInt aIndex); |
|
450 |
IMPORT_C DObject* At(const TFindHandle& aFindHandle); |
|
451 |
IMPORT_C TInt CheckUniqueFullName(DObject* aOwner, const TDesC& aName); |
|
452 |
IMPORT_C TInt CheckUniqueFullName(DObject* aObject); |
|
453 |
IMPORT_C TInt FindByName(TFindHandle& aFindHandle, const TDesC& aMatch, TKName& aName); |
|
454 |
IMPORT_C TInt FindByFullName(TFindHandle& aFindHandle, const TDesC& aMatch, TFullName& aFullName); |
|
455 |
IMPORT_C TInt OpenByFullName(DObject*& aObject, const TDesC& aMatch); |
|
456 |
inline TInt UniqueID() {return iUniqueID;} |
|
457 |
inline TInt Count() {return iCount;} |
|
458 |
inline void Wait() {Kern::MutexWait(*iMutex);} |
|
459 |
inline void Signal() {Kern::MutexSignal(*iMutex);} |
|
460 |
inline DMutex* Lock() {return iMutex;} |
|
461 |
protected: |
|
462 |
DObjectCon(TInt aUniqueID); |
|
463 |
TBool NamesMatch(DObject* aObject, const TDesC& aObjectName, DObject* aCurrentObject); |
|
464 |
public: |
|
465 |
TInt iUniqueID; |
|
466 |
private: |
|
467 |
TInt iAllocated; |
|
468 |
TInt iCount; |
|
469 |
DObject** iObjects; |
|
470 |
DMutex* iMutex; |
|
471 |
public: |
|
472 |
friend class Monitor; |
|
473 |
friend class Debugger; |
|
300 | 474 |
// Although SCMonitor is outside of the kernel sources, this friend declaration is still required |
475 |
// so that SCMonitor can collect kernel data at crash time |
|
0 | 476 |
friend class SCMonitor; |
477 |
friend class Debug::StopModeDebug; |
|
478 |
}; |
|
479 |
||
480 |
/******************************************** |
|
481 |
* Process and process-relative thread priorities |
|
482 |
********************************************/ |
|
483 |
enum TThrdPriority |
|
484 |
{ |
|
485 |
EThrdPriorityIdle=-8, |
|
486 |
EThrdPriorityMuchLess=-7, |
|
487 |
EThrdPriorityLess=-6, |
|
488 |
EThrdPriorityNormal=-5, |
|
489 |
EThrdPriorityMore=-4, |
|
490 |
EThrdPriorityMuchMore=-3, |
|
491 |
EThrdPriorityRealTime=-2, |
|
492 |
||
493 |
EThrdPriorityNull=0, |
|
494 |
EThrdPriorityAbsoluteVeryLow=1, |
|
495 |
EThrdPriorityAbsoluteLowNormal=3, |
|
496 |
EThrdPriorityAbsoluteLow=5, |
|
497 |
EThrdPriorityAbsoluteBackgroundNormal=7, |
|
498 |
EThrdPriorityAbsoluteBackground=10, |
|
499 |
EThrdPriorityAbsoluteForegroundNormal=12, |
|
500 |
EThrdPriorityAbsoluteForeground=15, |
|
501 |
EThrdPriorityAbsoluteHighNormal=19, |
|
502 |
EThrdPriorityAbsoluteHigh=23, |
|
503 |
EThrdPriorityAbsoluteRealTime1=24, |
|
504 |
EThrdPriorityAbsoluteRealTime2=25, |
|
505 |
EThrdPriorityAbsoluteRealTime3=26, |
|
506 |
EThrdPriorityAbsoluteRealTime4=27, |
|
507 |
EThrdPriorityAbsoluteRealTime5=28, |
|
508 |
EThrdPriorityAbsoluteRealTime6=29, |
|
509 |
EThrdPriorityAbsoluteRealTime7=30, |
|
510 |
EThrdPriorityAbsoluteRealTime8=31 |
|
511 |
}; |
|
512 |
||
513 |
enum TProcPriority |
|
514 |
{ |
|
515 |
EProcPriorityLow=0, |
|
516 |
EProcPriorityBackground=1, |
|
517 |
EProcPriorityForeground=2, |
|
518 |
EProcPriorityHigh=3, |
|
519 |
EProcPrioritySystemServer1=4, |
|
520 |
EProcPrioritySystemServer2=5, |
|
521 |
EProcPrioritySystemServer3=6, |
|
522 |
EProcPriorityRealTimeServer=7, |
|
523 |
}; |
|
524 |
||
525 |
/******************************************** |
|
526 |
* Multipurpose timer |
|
527 |
********************************************/ |
|
528 |
#ifndef MAX |
|
529 |
#define MAX(a,b) ((a)<(b)?(b):(a)) |
|
530 |
#endif |
|
531 |
#ifndef MAX3 |
|
532 |
#define MAX3(a,b,c) MAX(MAX(a,b),c) |
|
533 |
#endif |
|
534 |
#ifndef MAX4 |
|
535 |
#define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d)) |
|
536 |
#endif |
|
537 |
#define TIMER_SIZE MAX4(sizeof(TTickLink),sizeof(TSecondLink),sizeof(NTimer),sizeof(TInactivityLink)) |
|
538 |
||
539 |
class TTimer |
|
540 |
{ |
|
541 |
public: |
|
542 |
enum TTimerType {ERelative=1,EAbsolute=2,ELocked=4,EHighRes=8,EInactivity=16}; |
|
543 |
enum TTimerState {EIdle,EWaiting,EWaitHighRes}; |
|
544 |
public: |
|
545 |
TInt Create(); |
|
546 |
inline TTimer(); |
|
547 |
~TTimer(); |
|
548 |
TInt After(TInt aInterval, TTickCallBack aFunction, TRequestStatus& aStatus); |
|
549 |
TInt At(const TTimeK& aTime, TSecondCallBack aFunction, TRequestStatus& aStatus); |
|
550 |
TInt AfterHighRes(TInt aInterval, NTimerFn aFunction, TRequestStatus& aStatus); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
551 |
TInt AgainHighRes(TInt aInterval, NTimerFn aFunction, TRequestStatus& aStatus); |
0 | 552 |
TInt Inactivity(TInt aSeconds, TInactivityCallBack aFunction, TRequestStatus& aStatus); |
553 |
void Cancel(DThread* aThread); |
|
554 |
void Abort(DThread* aThread, TInt aTypeMask); |
|
555 |
void SetType(TTimerType aType); |
|
556 |
public: |
|
557 |
inline TTickLink& TickLink() |
|
558 |
{ return *(TTickLink*)iUnion; } |
|
559 |
inline TSecondLink& SecondLink() |
|
560 |
{ return *(TSecondLink*)iUnion; } |
|
561 |
inline NTimer& Ms() |
|
562 |
{ return *(NTimer*)iUnion; } |
|
563 |
inline TInactivityLink& Inact() |
|
564 |
{ return *(TInactivityLink*)iUnion; } |
|
565 |
inline TTimerType Type() |
|
566 |
{ return (TTimerType)iType; } |
|
567 |
public: |
|
568 |
TUint32 iUnion[TIMER_SIZE/sizeof(TUint32)]; // this field must always be 8-byte aligned |
|
569 |
TClientRequest* iRequest; |
|
570 |
TUint8 iState; |
|
571 |
TUint8 iType; |
|
572 |
}; |
|
573 |
||
574 |
inline TTimer::TTimer() |
|
575 |
: iState(EIdle) |
|
576 |
{} |
|
577 |
||
578 |
/******************************************** |
|
579 |
* Timer control block |
|
580 |
********************************************/ |
|
581 |
class DTimer : public DObject |
|
582 |
{ |
|
583 |
public: |
|
584 |
TInt Create(DThread* aThread); |
|
585 |
public: |
|
586 |
DTimer(); |
|
587 |
~DTimer(); |
|
588 |
public: |
|
589 |
void Cancel(); |
|
590 |
TInt After(TRequestStatus& aStatus, TInt aInterval); |
|
591 |
TInt At(TRequestStatus& aStatus, const TTimeK& aTime); |
|
592 |
TInt Lock(TRequestStatus& aStatus, TTimerLockSpec aLock); |
|
593 |
void HighRes(TRequestStatus& aStatus, TInt aInterval); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
594 |
void AgainHighRes(TRequestStatus& aStatus, TInt aInterval); |
0 | 595 |
TInt Inactivity(TRequestStatus& aStatus, TInt aSeconds); |
596 |
void Abort(TBool aAbortAbsolute); |
|
597 |
virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType); |
|
598 |
private: |
|
599 |
inline DThread* Owner(); |
|
600 |
static void TimerComplete(TAny* aPtr); |
|
601 |
static void SecondComplete(TAny* aPtr); |
|
602 |
static void LockComplete(TAny* aPtr); |
|
603 |
static void LockSynchronize(TAny* aPtr); |
|
604 |
static void MsComplete(TAny* aTimer); |
|
605 |
inline static DTimer* FromPtr(TAny* aPtr); |
|
606 |
public: |
|
607 |
// TAny* __padding; // for alignment |
|
608 |
TTimer iTimer; |
|
609 |
public: |
|
610 |
friend class Monitor; |
|
611 |
}; |
|
612 |
||
613 |
__ASSERT_COMPILE((_FOFF(DTimer,iTimer.iUnion) & 7)==0); |
|
614 |
||
615 |
inline DTimer* DTimer::FromPtr(TAny* aPtr) |
|
616 |
{ return _LOFF(aPtr,DTimer,iTimer); } |
|
617 |
inline DThread* DTimer::Owner() |
|
618 |
{return (DThread*)DObject::Owner();} |
|
619 |
||
620 |
||
621 |
/******************************************** |
|
622 |
* Thread cleanup entries |
|
623 |
********************************************/ |
|
624 |
class DThread; |
|
625 |
class TThreadCleanup : public TPriListLink |
|
626 |
{ |
|
627 |
public: |
|
628 |
IMPORT_C TThreadCleanup(); |
|
629 |
void ChangePriority(TInt aNewPriority); |
|
630 |
IMPORT_C void Remove(); |
|
631 |
virtual void Cleanup()=0; |
|
632 |
public: |
|
633 |
DThread* iThread; |
|
634 |
public: |
|
635 |
friend class Monitor; |
|
636 |
}; |
|
637 |
||
638 |
class TThreadMutexCleanup : public TThreadCleanup |
|
639 |
{ |
|
640 |
public: |
|
641 |
inline TThreadMutexCleanup(DMutex* aMutex); |
|
642 |
virtual void Cleanup(); |
|
643 |
DMutex *iMutex; |
|
644 |
public: |
|
645 |
friend class Monitor; |
|
646 |
}; |
|
647 |
||
648 |
/******************************************** |
|
649 |
* Deterministic thread wait queue |
|
650 |
********************************************/ |
|
651 |
class TThreadWaitList |
|
652 |
{ |
|
653 |
private: |
|
654 |
enum { EEmpty=0u, EFlagList=1u, EInitValue=3u, ENonEmptyMask=0xfffffffcu }; |
|
655 |
private: |
|
656 |
class TList : public TPriListBase |
|
657 |
{ |
|
658 |
private: |
|
659 |
TList() : TPriListBase(KNumPriorities) {} |
|
660 |
inline TList*& Next() |
|
661 |
{ return *(TList**)this; } |
|
662 |
private: |
|
663 |
SDblQueLink* iExtraQueues[KNumPriorities-1]; |
|
664 |
||
665 |
friend class TThreadWaitList; |
|
666 |
friend class Monitor; |
|
667 |
}; |
|
668 |
public: |
|
669 |
inline TThreadWaitList() |
|
670 |
{ iWaitPtr=EInitValue; } |
|
671 |
~TThreadWaitList(); |
|
672 |
TInt Construct(); |
|
673 |
inline TBool NonEmpty() const |
|
674 |
{ return (iWaitPtr & ENonEmptyMask); } |
|
675 |
DThread* First() const; |
|
676 |
TInt HighestPriority() const; |
|
677 |
void Add(DThread* aThread); |
|
678 |
void Remove(DThread* aThread); |
|
679 |
void ChangePriority(DThread* aThread, TInt aNewPriority); |
|
680 |
static TInt ThreadCreated(); |
|
681 |
static void ThreadDestroyed(); |
|
682 |
private: |
|
683 |
static TInt Up(TBool aThread); |
|
684 |
static void Down(TBool aThread); |
|
685 |
#ifdef _DEBUG |
|
686 |
void Check() const; |
|
687 |
#endif |
|
688 |
private: |
|
689 |
TLinAddr iWaitPtr; |
|
690 |
||
691 |
static TList* FirstFree; // first free list |
|
692 |
static TInt NLists; // number of TLists in existence |
|
693 |
static TInt NWaitObj; // number of wait objects in existence which use TThreadWaitList |
|
694 |
static TInt NThrd; // number of DThreads in existence |
|
695 |
}; |
|
696 |
||
697 |
||
698 |
/******************************************** |
|
699 |
* Semaphore control block |
|
700 |
********************************************/ |
|
701 |
class DSemaphore : public DObject |
|
702 |
{ |
|
703 |
public: |
|
704 |
TInt Create(DObject* aOwner, const TDesC* aName, TInt aInitialCount, TBool aVisible=ETrue); |
|
705 |
public: |
|
706 |
~DSemaphore(); |
|
707 |
void WaitCancel(DThread* aThread); |
|
708 |
void WaitCancelSuspended(DThread* aThread); |
|
709 |
void SuspendWaitingThread(DThread* aThread); |
|
710 |
void ResumeWaitingThread(DThread* aThread); |
|
711 |
void ChangeWaitingThreadPriority(DThread* aThread, TInt aNewPriority); |
|
712 |
public: |
|
713 |
TInt Wait(TInt aNTicks); |
|
714 |
void Signal(); |
|
715 |
void SignalN(TInt aCount); |
|
716 |
void Reset(); |
|
717 |
public: |
|
718 |
TInt iCount; |
|
719 |
TUint8 iResetting; |
|
720 |
TUint8 iPad1; |
|
721 |
TUint8 iPad2; |
|
722 |
TUint8 iPad3; |
|
723 |
SDblQue iSuspendedQ; |
|
724 |
TThreadWaitList iWaitQ; |
|
725 |
public: |
|
726 |
friend class Monitor; |
|
727 |
}; |
|
728 |
||
729 |
/******************************************** |
|
730 |
* Mutex control block |
|
731 |
********************************************/ |
|
732 |
class DMutex : public DObject |
|
733 |
{ |
|
734 |
public: |
|
735 |
TInt Create(DObject* aOwner, const TDesC* aName, TBool aVisible, TUint aOrder); |
|
736 |
public: |
|
737 |
DMutex(); |
|
738 |
~DMutex(); |
|
739 |
TInt HighestWaitingPriority(); |
|
740 |
void WaitCancel(DThread* aThread); |
|
741 |
void WaitCancelSuspended(DThread* aThread); |
|
742 |
void SuspendWaitingThread(DThread* aThread); |
|
743 |
void ResumeWaitingThread(DThread* aThread); |
|
744 |
void ChangeWaitingThreadPriority(DThread* aThread, TInt aNewPriority); |
|
745 |
void SuspendPendingThread(DThread* aThread); |
|
746 |
void RemovePendingThread(DThread* aThread); |
|
747 |
void ChangePendingThreadPriority(DThread* aThread, TInt aNewPriority); |
|
748 |
void WakeUpNextThread(); |
|
749 |
public: |
|
177 | 750 |
TInt Wait(TInt aTimeout=0); // 0 means wait forever, -1 means poll, n>0 means n nanokernel ticks |
0 | 751 |
void Signal(); |
752 |
void Reset(); |
|
753 |
public: |
|
754 |
TInt iHoldCount; // number of times held by current thread |
|
755 |
TInt iWaitCount; // number of waiting threads |
|
756 |
TUint8 iResetting; |
|
757 |
TUint8 iOrder; |
|
758 |
TUint8 iPad1; |
|
759 |
TUint8 iPad2; |
|
760 |
TThreadMutexCleanup iCleanup; |
|
761 |
SDblQue iSuspendedQ; |
|
762 |
SDblQue iPendingQ; |
|
763 |
TThreadWaitList iWaitQ; |
|
764 |
#ifdef _DEBUG |
|
765 |
SDblQueLink iOrderLink; // used for acquisition order checking |
|
766 |
#endif |
|
767 |
public: |
|
768 |
friend class Monitor; |
|
769 |
}; |
|
770 |
||
771 |
/******************************************** |
|
772 |
* Condition variable control block |
|
773 |
********************************************/ |
|
774 |
class DCondVar : public DObject |
|
775 |
{ |
|
776 |
public: |
|
777 |
TInt Create(DObject* aOwner, const TDesC* aName, TBool aVisible); |
|
778 |
public: |
|
779 |
DCondVar(); |
|
780 |
~DCondVar(); |
|
781 |
void WaitCancel(DThread* aThread); |
|
782 |
void WaitCancelSuspended(DThread* aThread); |
|
783 |
void SuspendWaitingThread(DThread* aThread); |
|
784 |
void ResumeWaitingThread(DThread* aThread); |
|
785 |
void ChangeWaitingThreadPriority(DThread* aThread, TInt aNewPriority); |
|
786 |
public: |
|
787 |
TInt Wait(DMutex* aMutex, TInt aTimeout); |
|
788 |
void Signal(); |
|
789 |
void Broadcast(DMutex* aMutex); |
|
790 |
void Reset(); |
|
791 |
void UnBlockThread(DThread* aThread, TBool aUnlock); |
|
792 |
public: |
|
793 |
TUint8 iResetting; |
|
794 |
TUint8 iPad1; |
|
795 |
TUint8 iPad2; |
|
796 |
TUint8 iPad3; |
|
797 |
DMutex* iMutex; |
|
798 |
TInt iWaitCount; |
|
799 |
SDblQue iSuspendedQ; |
|
800 |
TThreadWaitList iWaitQ; |
|
801 |
public: |
|
802 |
friend class Monitor; |
|
803 |
}; |
|
804 |
||
805 |
/******************************************** |
|
806 |
* Kernel representation of session message |
|
807 |
********************************************/ |
|
808 |
||
809 |
class DSession; |
|
810 |
class RMessageK : public TClientRequest |
|
811 |
{ |
|
812 |
public: |
|
813 |
inline TInt Arg(TInt aParam) const; |
|
814 |
inline TAny* Ptr(TInt aParam) const; |
|
815 |
inline TInt ArgType(TInt aParam) const; |
|
816 |
inline TUint IsDescriptor(TInt aParam) const; |
|
817 |
inline const TDesHeader& Descriptor(TInt aParam) const; |
|
818 |
inline TDesHeader& Descriptor(TInt aParam); |
|
819 |
inline TInt DesLength(TInt aParam) const; |
|
820 |
inline TInt DesMaxLength(TInt aParam) const; |
|
821 |
IMPORT_C DThread* Thread() const; |
|
822 |
IMPORT_C static RMessageK* MessageK(TInt aHandle); |
|
823 |
static RMessageK* MessageK(TInt aHandle, DThread* aThread); |
|
824 |
void OpenRef(); |
|
825 |
void CloseRef(); |
|
826 |
||
827 |
public: |
|
828 |
// message is always in one of the following message states, |
|
829 |
// a change of state requires the system lock. |
|
830 |
inline TBool IsFree() const; |
|
831 |
inline TBool IsInitialising() const; |
|
832 |
inline TBool IsDelivered() const; |
|
833 |
inline TBool IsAccepted() const; |
|
834 |
inline TBool IsCompleting() const; |
|
835 |
inline void SetFree(); |
|
836 |
inline void SetInitialising(); |
|
837 |
inline void SetDelivered(SDblQue& aDeliveredQ); |
|
838 |
inline void SetAccepted(DProcess* aServerProcess); |
|
839 |
inline void SetCompleting(); |
|
840 |
||
841 |
// WARNING: Some ARM assembler code makes assumptions about the *ordering* of these enum values! |
|
842 |
enum TMsgType {EDisc=32, ESync, ESession, EGlobal}; |
|
843 |
static RMessageK* GetNextFreeMessage(DSession* aSession); |
|
844 |
static RMessageK* ClaimMessagePool(enum TMsgType aType, TInt aCount, DSession* aSession); |
|
845 |
void ReleaseMessagePool(enum TMsgType aType, TInt aMax); |
|
846 |
||
847 |
private: |
|
848 |
friend class DSession; |
|
849 |
friend class ExecHandler; |
|
850 |
class TMsgArgs |
|
851 |
{ |
|
852 |
friend class RMessageK; |
|
853 |
friend class DSession; |
|
854 |
friend class ExecHandler; |
|
855 |
friend class TServerMessage; |
|
856 |
void ReadDesHeaders(const TInt aArgsPtr[KMaxMessageArguments+1]); |
|
857 |
inline TInt ArgType(TInt aParam) const; |
|
858 |
inline TUint IsDescriptor(TInt aParam) const; |
|
859 |
inline TUint AllDescriptorFlags() const; |
|
860 |
inline TUint AllPinFlags() const; |
|
861 |
inline TUint AllDesWritten() const; |
|
862 |
inline void SetArgUndefined(TInt aParam); |
|
863 |
inline void SetDesWritten(TInt aParam); |
|
864 |
||
865 |
inline TBool IsDesWritten(TInt aParam) const; |
|
866 |
||
867 |
TUint iArgFlags; // describes which arguments are descriptors/handles etc. |
|
868 |
TInt iArgs[KMaxMessageArguments]; // the arguments themselves |
|
869 |
TDesHeader iDesInfo[KMaxMessageArguments]; // info for any descriptor args |
|
870 |
||
871 |
// The iArgFlags words has a strange layout. The bottom 16 bits have to match those |
|
872 |
// TIpcArgs::iFlags, which -- from LSB upwards -- is KMaxMessageArguments (4) fields |
|
873 |
// of KBitsPerType (3) each, describing arguments 0-3, followed by 4 bits requesting |
|
874 |
// pinning of the corresponding (descriptor) argument. We then use the next 4 bits |
|
875 |
// to record whether each (descriptor) argument has been written. |
|
876 |
||
877 |
enum |
|
878 |
{ |
|
879 |
KArgFlagMask = (1 << TIpcArgs::KBitsPerType) - 1, |
|
880 |
KAllArgTypesMask = (1 << (TIpcArgs::KBitsPerType*KMaxMessageArguments)) - 1, |
|
881 |
KAllIpcFlagsMask = (KAllArgTypesMask | TIpcArgs::KPinMask), |
|
882 |
KAllDesArgMask = (TIpcArgs::EFlagDes << (0 * TIpcArgs::KBitsPerType)) | |
|
883 |
(TIpcArgs::EFlagDes << (1 * TIpcArgs::KBitsPerType)) | |
|
884 |
(TIpcArgs::EFlagDes << (2 * TIpcArgs::KBitsPerType)) | |
|
885 |
(TIpcArgs::EFlagDes << (3 * TIpcArgs::KBitsPerType)), |
|
886 |
||
887 |
KDesWrittenShift = (TIpcArgs::KBitsPerType*KMaxMessageArguments + TIpcArgs::KPinArgShift), |
|
888 |
KDesWrittenMask = ((1 << KMaxMessageArguments) - 1) << KDesWrittenShift |
|
889 |
}; |
|
890 |
}; |
|
891 |
||
892 |
private: |
|
893 |
RMessageK(); // call GetNextFreeMessage() or ClaimMessagePool() instead |
|
894 |
~RMessageK(); // Don't delete, call CloseRef() |
|
895 |
void Free(); // only called from last CloseRef() |
|
896 |
static TInt ExpandMessagePool(); |
|
897 |
static void CallbackFunc(TAny* aData, TUserModeCallbackReason aReason); |
|
898 |
TInt PinDescriptors(DSession* aSession, TBool aPinningServer); |
|
899 |
||
900 |
public: |
|
901 |
TUint8 iMsgType; // where this message belongs - one of the TMsgType values above |
|
902 |
TUint8 iAccessCount; |
|
903 |
DSession* iSession; // pointer to session |
|
904 |
SDblQueLink iSessionLink; // attaches message to session or freelist |
|
905 |
// WARNING: Some ARM assembler code makes assumptions about the layout of this structure! |
|
906 |
SDblQueLink iServerLink; // Also represents message state! |
|
907 |
TInt iFunction; |
|
908 |
TMsgArgs iMsgArgs; |
|
909 |
DThread* iClient; // pointer to client thread (not reference counted, see below) |
|
910 |
||
911 |
// An encapsulated array of pointers to pin objects associated with any descriptor arguments. |
|
912 |
struct TPinArray |
|
913 |
{ |
|
914 |
TVirtualPinObject* iPinPtrs[KMaxMessageArguments]; |
|
915 |
} *iPinArray; // Pointer to (heap-allocated) array of pointers to pin objects |
|
916 |
||
917 |
public: |
|
918 |
enum { KMessageSize = 128 }; // sizeof(RMessageK) rounded up to a power of 2 |
|
919 |
}; |
|
920 |
||
921 |
inline TInt RMessageK::TMsgArgs::ArgType(TInt aParam) const |
|
922 |
{ |
|
923 |
return (iArgFlags >> (aParam * TIpcArgs::KBitsPerType)) & KArgFlagMask; |
|
924 |
} |
|
925 |
inline TUint RMessageK::TMsgArgs::IsDescriptor(TInt aParam) const |
|
926 |
{ |
|
927 |
return (iArgFlags >> (aParam * TIpcArgs::KBitsPerType)) & TIpcArgs::EFlagDes; |
|
928 |
} |
|
929 |
inline TUint RMessageK::TMsgArgs::AllDescriptorFlags() const |
|
930 |
{ |
|
931 |
return iArgFlags & KAllDesArgMask; |
|
932 |
} |
|
933 |
inline TUint RMessageK::TMsgArgs::AllPinFlags() const |
|
934 |
{ |
|
935 |
return (iArgFlags & TIpcArgs::KPinMask) >> TIpcArgs::KPinArgShift; |
|
936 |
} |
|
937 |
inline TUint RMessageK::TMsgArgs::AllDesWritten() const |
|
938 |
{ |
|
939 |
return (iArgFlags & KDesWrittenMask) >> KDesWrittenShift; |
|
940 |
} |
|
941 |
inline void RMessageK::TMsgArgs::SetArgUndefined(TInt aParam) |
|
942 |
{ |
|
943 |
iArgFlags &= ~(KArgFlagMask << (aParam * TIpcArgs::KBitsPerType)); |
|
944 |
iArgFlags |= TIpcArgs::EUnspecified << (aParam * TIpcArgs::KBitsPerType); |
|
945 |
} |
|
946 |
inline void RMessageK::TMsgArgs::SetDesWritten(TInt aParam) |
|
947 |
{ |
|
948 |
iArgFlags |= 1 << (aParam + KDesWrittenShift); |
|
949 |
} |
|
950 |
||
951 |
inline TInt RMessageK::Arg(TInt aParam) const |
|
952 |
{ |
|
953 |
return iMsgArgs.iArgs[aParam]; |
|
954 |
} |
|
955 |
inline TAny* RMessageK::Ptr(TInt aParam) const |
|
956 |
{ |
|
957 |
return (TAny*)Arg(aParam); |
|
958 |
} |
|
959 |
inline TInt RMessageK::ArgType(TInt aParam) const |
|
960 |
{ |
|
961 |
return iMsgArgs.ArgType(aParam); |
|
962 |
} |
|
963 |
inline TUint RMessageK::IsDescriptor(TInt aParam) const |
|
964 |
{ |
|
965 |
return iMsgArgs.IsDescriptor(aParam); |
|
966 |
} |
|
967 |
inline const TDesHeader& RMessageK::Descriptor(TInt aParam) const |
|
968 |
{ |
|
969 |
return iMsgArgs.iDesInfo[aParam]; |
|
970 |
} |
|
971 |
inline TDesHeader& RMessageK::Descriptor(TInt aParam) |
|
972 |
{ |
|
973 |
return iMsgArgs.iDesInfo[aParam]; |
|
974 |
} |
|
975 |
inline TInt RMessageK::DesLength(TInt aParam) const |
|
976 |
{ |
|
977 |
return Descriptor(aParam).Length(); |
|
978 |
} |
|
979 |
inline TInt RMessageK::DesMaxLength(TInt aParam) const |
|
980 |
{ |
|
981 |
return Descriptor(aParam).MaxLength(); |
|
982 |
} |
|
983 |
inline TBool RMessageK::IsFree() const |
|
984 |
{ |
|
985 |
__ASSERT_SYSTEM_LOCK; |
|
986 |
return !iServerLink.iNext; |
|
987 |
} |
|
988 |
inline TBool RMessageK::IsInitialising() const |
|
989 |
{ |
|
990 |
__ASSERT_SYSTEM_LOCK; |
|
991 |
return iServerLink.iNext == (TAny*)2; |
|
992 |
} |
|
993 |
inline TBool RMessageK::IsDelivered() const |
|
994 |
{ |
|
995 |
__ASSERT_SYSTEM_LOCK; |
|
996 |
return iServerLink.iNext != 0 && (TLinAddr(iServerLink.iNext) & 3) == 0; |
|
997 |
} |
|
998 |
inline TBool RMessageK::IsAccepted() const |
|
999 |
{ |
|
1000 |
__ASSERT_SYSTEM_LOCK; |
|
1001 |
return ((TLinAddr)iServerLink.iNext & 3) == 3; |
|
1002 |
} |
|
1003 |
inline TBool RMessageK::IsCompleting() const |
|
1004 |
{ |
|
1005 |
__ASSERT_SYSTEM_LOCK; |
|
1006 |
return iServerLink.iNext == (TAny*)1; |
|
1007 |
} |
|
1008 |
inline void RMessageK::SetFree() |
|
1009 |
{ |
|
1010 |
__ASSERT_SYSTEM_LOCK; |
|
1011 |
iServerLink.iNext = 0; |
|
1012 |
} |
|
1013 |
inline void RMessageK::SetInitialising() |
|
1014 |
{ |
|
1015 |
__ASSERT_SYSTEM_LOCK; |
|
1016 |
iServerLink.iNext = (SDblQueLink*)2; |
|
1017 |
} |
|
1018 |
inline void RMessageK::SetDelivered(SDblQue& aDeliveredQ) |
|
1019 |
{ |
|
1020 |
__ASSERT_SYSTEM_LOCK; |
|
1021 |
aDeliveredQ.Add(&iServerLink); |
|
1022 |
} |
|
1023 |
inline void RMessageK::SetAccepted(DProcess* aServerProcess) |
|
1024 |
{ |
|
1025 |
__ASSERT_SYSTEM_LOCK; |
|
1026 |
iServerLink.iNext = (SDblQueLink*)~TUint32(this); |
|
1027 |
iServerLink.iPrev = (SDblQueLink*)~TUint32(aServerProcess); |
|
1028 |
} |
|
1029 |
inline void RMessageK::SetCompleting() |
|
1030 |
{ |
|
1031 |
__ASSERT_SYSTEM_LOCK; |
|
1032 |
iServerLink.iNext = (SDblQueLink*)1; |
|
1033 |
} |
|
1034 |
||
1035 |
/******************************************** |
|
1036 |
* Thread control block |
|
1037 |
********************************************/ |
|
1038 |
class DChunk; |
|
1039 |
class DProcess; |
|
1040 |
class TTrap; |
|
1041 |
||
1042 |
const TInt KMaxThreadContext=256; |
|
1043 |
typedef void (*TUnknownStateHandler)(DThread*,TInt,TInt); |
|
1044 |
||
1045 |
class DThread : public DObject |
|
1046 |
{ |
|
1047 |
public: |
|
1048 |
enum {EDefaultUserTimeSliceMs = 20}; |
|
1049 |
||
1050 |
enum TThreadState |
|
1051 |
{ |
|
1052 |
ECreated, |
|
1053 |
EDead, |
|
1054 |
EReady, |
|
1055 |
EWaitSemaphore, |
|
1056 |
EWaitSemaphoreSuspended, |
|
1057 |
EWaitMutex, |
|
1058 |
EWaitMutexSuspended, |
|
1059 |
EHoldMutexPending, |
|
1060 |
EWaitCondVar, |
|
1061 |
EWaitCondVarSuspended, |
|
1062 |
}; |
|
1063 |
||
1064 |
enum TOperation |
|
1065 |
{ |
|
1066 |
ESuspend=0, |
|
1067 |
EResume=1, |
|
1068 |
EForceResume=2, |
|
1069 |
EReleaseWait=3, |
|
1070 |
EChangePriority=4, |
|
1071 |
}; |
|
1072 |
||
1073 |
enum TUserThreadState |
|
1074 |
{ |
|
1075 |
EUserThreadNone, |
|
1076 |
EUserThreadCreated, |
|
1077 |
EUserThreadRunning, |
|
1078 |
EUserThreadExiting, |
|
1079 |
}; |
|
1080 |
||
1081 |
public: |
|
1082 |
DThread(); |
|
1083 |
void Destruct(); |
|
1084 |
TInt Create(SThreadCreateInfo& aInfo); |
|
1085 |
TInt SetPriority(TThreadPriority aPriority); |
|
1086 |
TInt MakeHandle(TOwnerType aType, DObject* aObject, TInt& aHandle); |
|
1087 |
TInt MakeHandle(TOwnerType aType, DObject* aObject, TInt& aHandle, TUint aAttr); |
|
1088 |
TInt MakeHandleAndOpen(TOwnerType aType, DObject* aObject, TInt& aHandle); |
|
1089 |
TInt MakeHandleAndOpen(TOwnerType aType, DObject* aObject, TInt& aHandle, TUint aAttr); |
|
1090 |
TInt HandleClose(TInt aHandle); |
|
1091 |
TInt OpenFindHandle(TOwnerType aType, const TFindHandle& aFindHandle, TInt& aHandle); |
|
1092 |
TInt OpenObject(TOwnerType aType, const TDesC& aName, TInt& aHandle, DObject*& aObj, TInt aObjType); |
|
1093 |
IMPORT_C DObject* ObjectFromHandle(TInt aHandle); |
|
1094 |
IMPORT_C DObject* ObjectFromHandle(TInt aHandle, TInt aObjType); |
|
1095 |
IMPORT_C DObject* ObjectFromHandle(TInt aHandle, TInt aObjType, TUint& aAttr); |
|
1096 |
void RequestComplete(TRequestStatus*& aStatus, TInt aReason); |
|
1097 |
TInt SetTls(TInt aHandle, TInt aDllUid, TAny* aPtr); |
|
1098 |
TAny* Tls(TInt aHandle, TInt aDllUid); |
|
1099 |
void FreeTls(TInt aHandle); |
|
1100 |
TInt Rename(const TDesC& aName); |
|
1101 |
TBool IsExceptionHandled(TExcType aType); |
|
1102 |
TInt RaiseException(TExcType aType); |
|
1103 |
void SetExitInfo(TExitType aType, TInt aReason, const TDesC& aCategory); |
|
1104 |
void CloseCreatedHeap(); |
|
1105 |
void RemoveClosingLibs(); |
|
1106 |
inline TBool HasCapability(/*TInt aCapability*/); |
|
1107 |
TBool IsRealtime(); |
|
1108 |
void SetRealtimeState(TThreadRealtimeState aNewState); |
|
1109 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1110 |
inline TBool HasCapability(TCapability aCapability, const char* aDiagnosticText=0); |
|
1111 |
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1112 |
// Only available to NULL arguments |
|
1113 |
inline TBool HasCapability(TCapability aCapability, OnlyCreateWithNull aDiagnostic=NULL); |
|
1114 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1115 |
private: |
|
1116 |
IMPORT_C TBool DoHasCapability(TCapability aCapability, const char* aDiagnosticText); |
|
1117 |
IMPORT_C TBool DoHasCapability(TCapability aCapability); |
|
1118 |
public: |
|
1119 |
// not memory model dependent |
|
1120 |
virtual TInt Context(TDes8& aDes)=0; |
|
1121 |
public: |
|
1122 |
inline void Stillborn(); |
|
1123 |
void Release(); |
|
1124 |
TInt CalcDefaultThreadPriority(); |
|
1125 |
IMPORT_C void AddCleanup(TThreadCleanup* aCleanup); |
|
1126 |
void SetRequiredPriority(); |
|
1127 |
void SetActualPriority(TInt aActualPriority); |
|
1128 |
void RevertPriority(); |
|
1129 |
void SvKill(); |
|
1130 |
IMPORT_C TInt ReleaseWait(TInt aReturnCode); |
|
1131 |
IMPORT_C void CancelTimer(); |
|
1132 |
void ExtractMiscNotifiers(SDblQue& aQ, TRequestStatus* aStatus); |
|
1133 |
void KillMiscNotifiers(); |
|
1134 |
public: |
|
1135 |
// not memory model dependent |
|
1136 |
TInt DoCreate(SThreadCreateInfo& aInfo); |
|
1137 |
IMPORT_C void SetThreadPriority(TInt aThreadPriority); |
|
1138 |
void SetDefaultPriority(TInt aDefaultPriority); |
|
1139 |
void AbortTimer(TBool aAbortAbsolute); |
|
1140 |
void Suspend(TInt aCount); |
|
1141 |
void Resume(); |
|
1142 |
void ForceResume(); |
|
1143 |
void Exit(); |
|
1144 |
void Die(TExitType aType, TInt aReason, const TDesC& aCategory); |
|
1145 |
TInt Logon(TRequestStatus* aStatus, TBool aRendezvous); |
|
1146 |
void Rendezvous(TInt aReason); |
|
1147 |
void CleanupLeave(TInt aDepth = 1); |
|
1148 |
#ifdef __SMP__ |
|
1149 |
static void SMPSafeCallback(TAny* aThisPtr, TUserModeCallbackReason aReasonCode); |
|
1150 |
#endif |
|
1151 |
public: |
|
1152 |
// memory model dependent |
|
1153 |
TInt AllocateSupervisorStack(); |
|
1154 |
void FreeSupervisorStack(); |
|
1155 |
void FreeUserStack(); |
|
1156 |
TInt AllocateUserStack(TInt aSize, TBool aPaged); |
|
1157 |
DChunk* OpenSharedChunk(const TAny* aAddress, TBool aWrite, TInt& aOffset); |
|
1158 |
DChunk* OpenSharedChunk(TInt aHandle,TBool aWrite); |
|
1159 |
TInt PrepareMemoryForDMA(const TAny* aAddress, TInt aSize, TPhysAddr* aPageList); |
|
1160 |
TInt ReleaseMemoryFromDMA(const TAny* aAddress, TInt aSize, TPhysAddr* aPageList); |
|
1161 |
||
1162 |
static void IpcExcHandler(TExcTrap* aTrap, DThread* aThread, TAny* aContext); |
|
1163 |
virtual void DoExit1(); |
|
1164 |
public: |
|
1165 |
// pure virtual |
|
1166 |
virtual TInt SetupContext(SThreadCreateInfo& aInfo)=0; |
|
1167 |
virtual void DoExit2()=0; |
|
1168 |
protected: |
|
1169 |
virtual void SetPaging(TUint& aCreateFlags); |
|
1170 |
public: |
|
1171 |
inline void UnknownState(TInt aOperation, TInt aParameter); |
|
1172 |
inline static DThread* FromTimer(TAny* aPtr); |
|
1173 |
static void ExitCurrentThread(); |
|
1174 |
static void DefaultUnknownStateHandler(DThread* aThread, TInt aOperation, TInt aParameter); |
|
1175 |
static void EpocThreadFunction(TAny* aPtr); |
|
1176 |
static TDfc* EpocThreadExitHandler(NThread* aThread); |
|
1177 |
static void EpocThreadTimeoutHandler(NThread* aThread, TInt aOp); |
|
1178 |
public: |
|
1179 |
virtual void BTracePrime(TInt aCategory); |
|
1180 |
||
1181 |
private: |
|
1182 |
// Functions that access user-side memory |
|
1183 |
TInt GetDesInfo(const TAny* aDes, TInt& aLength, TInt& aMaxLength, TUint8*& aPtr, TBool aWriteable); |
|
1184 |
TInt GetDesLength(const TAny* aPtr); |
|
1185 |
TInt GetDesMaxLength(const TAny* aPtr); |
|
1186 |
TInt DesRead(const TAny* aPtr, TUint8* aDes, TInt aMax, TInt aOffset, TInt aMode); |
|
1187 |
TInt DesWrite(const TAny* aPtr, const TUint8* aDes, TInt aLength, TInt aOffset, TInt aMode, DThread* aOriginatingThread); |
|
1188 |
TInt DoDesRead(const TDesHeader& aDesInfo, TUint8* aDes, TInt aMax, TInt aOffset, TInt aMode); |
|
1189 |
TInt DoDesWrite(const TAny* aPtr, TDesHeader& aDesInfo, const TUint8* aDes, TInt aLength, TInt aOffset, TInt aMode, DThread* aOriginatingThread); |
|
1190 |
// (the following are memory model dependent) |
|
1191 |
TInt RawRead(const TAny* aSrc, TAny* aDest, TInt aLength, TInt aFlags, TIpcExcTrap* aExcTrap); |
|
1192 |
TInt RawWrite(const TAny* aDest, const TAny* aSrc, TInt aLength, TInt aFlags, DThread* aOriginatingThread, TIpcExcTrap* aExcTrap); |
|
1193 |
TInt ReadAndParseDesHeader(const TAny* aSrc, TDesHeader& aDest); |
|
1194 |
||
1195 |
public: |
|
1196 |
TUint32 iIpcCount; |
|
1197 |
TLinAddr iUserStackRunAddress; |
|
1198 |
TInt iUserStackSize; |
|
1199 |
TUint32 iFlags; |
|
1200 |
DProcess* iOwningProcess; |
|
1201 |
SDblQueLink iProcessLink; |
|
1202 |
TInt iThreadPriority; |
|
1203 |
RObjectIx iHandles; |
|
1204 |
TUint iId; |
|
1205 |
RAllocator* iAllocator; |
|
1206 |
RAllocator* iCreatedAllocator; |
|
1207 |
TTrap* iFrame; |
|
1208 |
TTrapHandler* iTrapHandler; |
|
1209 |
RArray<STls> iTls; |
|
1210 |
CActiveScheduler* iScheduler; |
|
1211 |
TExceptionHandler iExceptionHandler; |
|
1212 |
TUint iExceptionMask; |
|
1213 |
TExcTrap* iExcTrap; |
|
1214 |
TInt iDebugMask; |
|
1215 |
TThreadMessage iKernMsg; |
|
1216 |
DObject* iTempObj; |
|
1217 |
DObject* iExtTempObj; |
|
1218 |
TAny* iTempAlloc; |
|
1219 |
SDblQue iOwnedLogons; |
|
1220 |
SDblQue iTargetLogons; |
|
1221 |
RMessageK* iSyncMsgPtr; |
|
1222 |
TDfc iKillDfc; |
|
1223 |
SDblQue iClosingLibs; |
|
1224 |
TPriListLink iWaitLink; |
|
1225 |
// TUint8 iMState; // use iSpare1 for iMState |
|
1226 |
// TUint8 iExiting; // use iSpare2 for iExiting |
|
1227 |
// TUint8 iWaitListReserved; // use iSpare3 for iWaitListReserved |
|
1228 |
TInt iDefaultPriority; // default scheduling priority |
|
1229 |
TAny* iWaitObj; // object on which this thread is waiting |
|
1230 |
TUnknownStateHandler iUnknownStateHandler; // handler for extra thread states - used by RTOS personality layers |
|
1231 |
TAny* iExtras; // pointer to extra data used by RTOS personality layers |
|
1232 |
TAny* iSupervisorStack; // thread's supervisor mode stack |
|
1233 |
TInt iSupervisorStackSize; |
|
1234 |
TUint8 iSupervisorStackAllocated; |
|
1235 |
TUint8 iThreadType; |
|
1236 |
TUint8 iExitType; |
|
1237 |
TUint8 iEmiFlags; |
|
1238 |
TInt iExitReason; |
|
1239 |
TBufC<KMaxExitCategoryName> iExitCategory; |
|
1240 |
SDblQue iMutexList; // list of held mutexes, used only for acquisition order checking |
|
1241 |
TPriList<TThreadCleanup,KNumPriorities> iCleanupQ; // things to clean up when we die |
|
1242 |
TTimer iTimer; |
|
1243 |
TInt iLeaveDepth; // recursive depth of User::Leave() calls |
|
1244 |
TAny* iEmiStartMonitor; |
|
1245 |
NThread iNThread; |
|
1246 |
TPagingExcTrap* iPagingExcTrap; |
|
1247 |
TUserThreadState iUserThreadState; |
|
1248 |
SDblQue iMiscNotifiers; // miscellaneous notifiers owned by this thread |
|
1249 |
DThread* iIpcClient; // client thread when doing IPC, used if realtime therad takes fault |
|
1250 |
#ifdef __SMP__ |
|
1251 |
TUserModeCallback iSMPSafeCallback; |
|
1252 |
#endif |
|
1253 |
RMessageK* iTempMsg; |
|
1254 |
||
1255 |
public: |
|
1256 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ |
|
1257 |
#ifdef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1258 |
// This exported Kern:: function takes diagnostic strings that |
|
1259 |
// should still work by calling the DoHasCapability function here even |
|
1260 |
// though we have removed diagnostic strings from ekern proper |
|
1261 |
friend TBool Kern::DoCurrentThreadHasCapability(TCapability aCapability, const char* aContextText); |
|
1262 |
#endif //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1263 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ |
|
1264 |
||
1265 |
friend class Monitor; |
|
1266 |
friend class Kern; |
|
1267 |
friend class ExecHandler; |
|
1268 |
friend class TClientBuffer; |
|
1269 |
}; |
|
1270 |
||
1271 |
__ASSERT_COMPILE((_FOFF(DThread,iTimer.iUnion) & 7)==0); |
|
1272 |
||
1273 |
inline DThread* DThread::FromTimer(TAny* aPtr) |
|
1274 |
{ return _LOFF(aPtr,DThread,iTimer); } |
|
1275 |
inline void DThread::UnknownState(TInt aOperation, TInt aParameter) |
|
1276 |
{ (*iUnknownStateHandler)(this,aOperation,aParameter); } |
|
1277 |
inline void DThread::Stillborn() |
|
1278 |
{iNThread.Stillborn();Release();} |
|
1279 |
||
1280 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1281 |
inline TBool DThread::HasCapability(TCapability aCapability, const char* aDiagnosticText) |
|
1282 |
{ |
|
1283 |
return DoHasCapability(aCapability, aDiagnosticText); |
|
1284 |
} |
|
1285 |
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1286 |
// Only available to NULL arguments |
|
1287 |
inline TBool DThread::HasCapability(TCapability aCapability, OnlyCreateWithNull /*aDiagnostic*/) |
|
1288 |
{ |
|
1289 |
return DoHasCapability(aCapability); |
|
1290 |
} |
|
1291 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1292 |
||
1293 |
#define TheCurrentThread _LOFF(NCurrentThread(),DThread,iNThread) |
|
1294 |
||
1295 |
class TLogon : public TClientRequest |
|
1296 |
{ |
|
1297 |
public: |
|
1298 |
enum TType |
|
1299 |
{ |
|
1300 |
ETargetThread=0, |
|
1301 |
ETargetProcess=1, |
|
1302 |
ERendezvous=0x80, |
|
1303 |
}; |
|
1304 |
TInt Attach(SDblQue& aList, DThread* aOwner, DObject* aTarget, TRequestStatus* aStatus, TUint32 aType); |
|
1305 |
static TInt Cancel(SDblQue& aList, DObject* aTarget, TRequestStatus* aStatus, TUint32 aType); |
|
1306 |
||
1307 |
enum TComplete { ETargetRendezvous, ETarget, EOwned }; |
|
1308 |
static void CompleteAll(SDblQue& aList, TComplete aAction, TInt aReason); |
|
1309 |
||
1310 |
static NFastMutex LogonLock; |
|
1311 |
||
1312 |
private: |
|
1313 |
inline static void Lock() |
|
1314 |
{ NKern::FMWait(&LogonLock); } |
|
1315 |
inline static void Unlock() |
|
1316 |
{ NKern::FMSignal(&LogonLock); } |
|
1317 |
||
1318 |
TUint32 iType; |
|
1319 |
inline TBool IsRendezvous() |
|
1320 |
{ return (iType & ERendezvous); } |
|
1321 |
||
1322 |
DThread* iOwningThread; |
|
1323 |
DObject* iTarget; |
|
1324 |
SDblQueLink iOwningThreadLink; |
|
1325 |
SDblQueLink iTargetLink; |
|
1326 |
private: |
|
1327 |
~TLogon(); // call Close(), don't delete |
|
1328 |
}; |
|
1329 |
||
1330 |
/******************************************** |
|
1331 |
* Platform-independent chunk type abstraction |
|
1332 |
********************************************/ |
|
1333 |
enum TChunkType |
|
1334 |
{ |
|
1335 |
// these never change or move or anything |
|
1336 |
EKernelData = 0, // Supervisor,Rw,Cacheable |
|
1337 |
EKernelStack = 1, // Supervisor,Rw,Cacheable |
|
1338 |
EKernelCode = 2, // Supervisor,Rw,Cacheable |
|
1339 |
EDll = 3, // User,Ro,Cacheable |
|
1340 |
EUserCode = 4, |
|
1341 |
||
1342 |
// This changes on a PDE basis when the file server runs |
|
1343 |
ERamDrive = 5, // Supervisor,Rw,Cacheable |
|
1344 |
||
1345 |
// these change on PDE basis when run |
|
1346 |
EUserData = 6, |
|
1347 |
EDllData = 7, |
|
1348 |
EUserSelfModCode = 8, |
|
1349 |
||
1350 |
ESharedKernelSingle = 9, // Must be same value as TChunkCreateInfo::ESharedKernelSingle |
|
1351 |
ESharedKernelMultiple = 10, // Must be same value as TChunkCreateInfo::ESharedKernelMultiple |
|
1352 |
||
1353 |
ESharedIo = 11, |
|
1354 |
ESharedKernelMirror = 12, |
|
1355 |
||
1356 |
EKernelMessage = 13, // Dedicated chunk for RMessageK objects |
|
1357 |
||
1358 |
ENumChunkTypes // Keep as last value |
|
1359 |
}; |
|
1360 |
||
1361 |
/******************************************** |
|
1362 |
* Chunk creation info block |
|
1363 |
********************************************/ |
|
1364 |
struct SChunkCreateInfo |
|
1365 |
{ |
|
1366 |
enum {EAdjust=1, EAdd=2}; // iOperations |
|
1367 |
||
1368 |
TBool iGlobal; |
|
1369 |
TInt iAtt; // Set with values from TChunkCreate::TChunkCreateAtt NOT DChunk::TChunkAttributes |
|
1370 |
TBool iForceFixed; |
|
1371 |
TUint iOperations; |
|
1372 |
TLinAddr iRunAddress; |
|
1373 |
TChunkType iType; |
|
1374 |
TInt iMaxSize; |
|
1375 |
TInt iInitialBottom; |
|
1376 |
TInt iInitialTop; |
|
1377 |
TInt iPreallocated; |
|
1378 |
TPtrC iName; |
|
1379 |
DObject* iOwner; |
|
1380 |
TUint32 iMapAttr; |
|
1381 |
TDfc* iDestroyedDfc; |
|
1382 |
TUint8 iClearByte; |
|
1383 |
public: |
|
1384 |
SChunkCreateInfo(); |
|
1385 |
}; |
|
1386 |
||
1387 |
/** The different types of pages that the allocator should consider |
|
1388 |
*/ |
|
1389 |
enum TZonePageType |
|
1390 |
{ |
|
1391 |
EPageUnknown = 0, /**<Pages that are at physical addresses the kernel has no knowledge of*/ |
|
1392 |
EPageFixed, /**<Pages that shouldn't be physically moved*/ |
|
1393 |
EPageMovable, /**<Pages that may be physically moved*/ |
|
1394 |
EPageDiscard, /**<Pages that may be removed*/ |
|
1395 |
EPageTypes /**<The no of different page types*/ |
|
1396 |
}; |
|
1397 |
||
1398 |
/******************************************** |
|
1399 |
* Chunk control block |
|
1400 |
********************************************/ |
|
1401 |
class DChunk : public DObject |
|
1402 |
{ |
|
1403 |
public: |
|
1404 |
/** |
|
1405 |
@see DMemModelChunk::TMemModelChunkAttributes for memory model specific attribute flags |
|
1406 |
*/ |
|
1407 |
enum TChunkAttributes |
|
1408 |
{ |
|
1409 |
ENormal =0x00, |
|
1410 |
EDoubleEnded =0x01, |
|
1411 |
EDisconnected =0x02, |
|
1412 |
EConstructed =0x04, |
|
1413 |
EMemoryNotOwned =0x08, |
|
1414 |
ETrustedChunk =0x10, |
|
1415 |
EDataPaged =0x20, // Set when the chunk is data paged. |
|
1416 |
ECache =0x40, |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1417 |
EReadOnly =0x80, |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1418 |
EChunkAttributesMask = 0xff, |
0 | 1419 |
}; |
1420 |
||
1421 |
enum TCommitType |
|
1422 |
{ |
|
1423 |
ECommitDiscontiguous = 0, |
|
1424 |
ECommitContiguous = 1, |
|
1425 |
ECommitPhysicalMask = 2, |
|
1426 |
ECommitDiscontiguousPhysical = ECommitDiscontiguous|ECommitPhysicalMask, |
|
1427 |
ECommitContiguousPhysical = ECommitContiguous|ECommitPhysicalMask, |
|
1428 |
ECommitVirtual = 4, // only supported by moving and multiple memory models on arm |
|
1429 |
}; |
|
1430 |
||
1431 |
enum TDecommitType |
|
1432 |
{ |
|
1433 |
EDecommitNormal = 0, |
|
1434 |
EDecommitVirtual = 1, |
|
1435 |
}; |
|
1436 |
||
1437 |
DChunk(); |
|
1438 |
~DChunk(); |
|
1439 |
TInt Create(SChunkCreateInfo& aInfo); |
|
1440 |
inline TInt Size() const {return iSize;} |
|
1441 |
inline TInt MaxSize() const {return iMaxSize;} |
|
1442 |
#ifndef __MEMMODEL_FLEXIBLE__ |
|
1443 |
inline TUint8 *Base() const {return iBase;} |
|
1444 |
#endif |
|
1445 |
inline TInt Bottom() const {return iStartPos;} |
|
1446 |
inline TInt Top() const {return iStartPos+iSize;} |
|
1447 |
inline DProcess* OwningProcess() const {return iOwningProcess;} |
|
1448 |
protected: |
|
1449 |
virtual void SetPaging(TUint aCreateAtt); |
|
1450 |
public: |
|
1451 |
virtual TInt AddToProcess(DProcess* aProcess); |
|
1452 |
virtual TInt DoCreate(SChunkCreateInfo& aInfo)=0; |
|
1453 |
virtual TInt Adjust(TInt aNewSize)=0; |
|
1454 |
virtual TInt AdjustDoubleEnded(TInt aBottom, TInt aTop)=0; |
|
1455 |
virtual TInt CheckAccess()=0; |
|
1456 |
virtual TInt Commit(TInt aOffset, TInt aSize, TCommitType aCommitType=DChunk::ECommitDiscontiguous, TUint32* aExtraArg=0)=0; |
|
1457 |
virtual TInt Allocate(TInt aSize, TInt aGuard=0, TInt aAlign=0)=0; |
|
1458 |
virtual TInt Decommit(TInt aOffset, TInt aSize)=0; |
|
1459 |
virtual TInt Lock(TInt aOffset, TInt aSize)=0; |
|
1460 |
virtual TInt Unlock(TInt aOffset, TInt aSize)=0; |
|
1461 |
virtual TInt Address(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress)=0; |
|
1462 |
virtual TInt PhysicalAddress(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress, TUint32& aPhysicalAddress, TUint32* aPhysicalPageList=NULL)=0; |
|
1463 |
virtual void BTracePrime(TInt aCategory); |
|
1464 |
virtual void Substitute(TInt aOffset, TPhysAddr aOldAddr, TPhysAddr aNewAddr)=0; |
|
1465 |
virtual TUint8* Base(DProcess* aProcess)=0; |
|
1466 |
public: |
|
1467 |
DProcess* iOwningProcess; // NULL for global chunks |
|
1468 |
TInt iSize; // always the committed size (i.e. gaps not included) |
|
1469 |
TInt iMaxSize; |
|
1470 |
#ifndef __MEMMODEL_FLEXIBLE__ |
|
1471 |
TUint8* iBase; |
|
1472 |
#else |
|
1473 |
TLinAddr iFixedBase; |
|
1474 |
#endif |
|
1475 |
TInt iAttributes; |
|
1476 |
TInt iStartPos; // start of committed area for double-ended chunks |
|
1477 |
TUint iControllingOwner; // ProcessID of process which set protection |
|
1478 |
TUint iRestrictions; |
|
1479 |
TUint iMapAttr; // only for shared kernel chunks |
|
1480 |
TDfc* iDestroyedDfc; |
|
1481 |
TChunkType iChunkType; |
|
1482 |
TUint8 iClearByte; // The byte value to clear all memory committed to the chunk to. |
|
1483 |
public: |
|
1484 |
friend class Monitor; |
|
1485 |
}; |
|
1486 |
||
1487 |
/******************************************** |
|
1488 |
* Platform security |
|
1489 |
********************************************/ |
|
1490 |
||
1491 |
/** |
|
1492 |
@deprecated |
|
1493 |
*/ |
|
1494 |
#define __SECURE_KERNEL(p) { p; }; |
|
1495 |
||
1496 |
/** |
|
1497 |
@deprecated |
|
1498 |
*/ |
|
1499 |
#define __KERNEL_CAPABILITY_CHECK(p) { p; }; |
|
1500 |
||
1501 |
/** TCompiledSecurityPolicy uses the upper two bits in iCaps to store a reduced |
|
1502 |
version of TSecurityPolicy's iType. This constant is the number of free bits. |
|
1503 |
@internalTechnology |
|
1504 |
*/ |
|
1505 |
const TUint32 KCSPBitsFree = 30; |
|
1506 |
||
1507 |
/** TCompiledSecurityPolicy can only represent capabilities less than |
|
1508 |
KCSPBitsFree-1 |
|
1509 |
*/ |
|
1510 |
__ASSERT_COMPILE(ECapability_Limit <= KCSPBitsFree); |
|
1511 |
||
1512 |
/** A precompiled security policy useful for fast checking of policies. |
|
1513 |
@internalComponent |
|
1514 |
*/ |
|
1515 |
class TCompiledSecurityPolicy |
|
1516 |
{ |
|
1517 |
public: |
|
1518 |
enum TType |
|
1519 |
{ |
|
1520 |
ETypeFail = 0, |
|
1521 |
ETypeCapsOnly = 1, |
|
1522 |
ETypeSecureId= 2, |
|
1523 |
ETypeVendorId= 3, |
|
1524 |
}; |
|
1525 |
enum TMask |
|
1526 |
{ |
|
121 | 1527 |
EMaskFail = TUint32 (ETypeFail) << KCSPBitsFree, |
1528 |
EMaskCapsOnly = TUint32 (ETypeCapsOnly) << KCSPBitsFree, |
|
1529 |
EMaskSecureId = TUint32 (ETypeSecureId) << KCSPBitsFree, |
|
1530 |
EMaskVendorId = TUint32 (ETypeVendorId) << KCSPBitsFree, |
|
0 | 1531 |
}; |
1532 |
TInt Set(const TSecurityPolicy& aPolicy); |
|
1533 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1534 |
inline TBool CheckPolicy(DProcess* aProcess, const char* aDiagnostic=0) const |
|
1535 |
{ |
|
1536 |
return DoCheckPolicy(aProcess, aDiagnostic); |
|
1537 |
} |
|
1538 |
||
1539 |
inline TBool CheckPolicy(DThread* aThread, const char* aDiagnostic=0) const |
|
1540 |
{ |
|
1541 |
return DoCheckPolicy(aThread, aDiagnostic); |
|
1542 |
} |
|
1543 |
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1544 |
// Only available to NULL arguments |
|
1545 |
inline TBool CheckPolicy(DProcess* aProcess, OnlyCreateWithNull /*aDiagnostic*/=NULL) const |
|
1546 |
{ |
|
1547 |
return DoCheckPolicy(aProcess); |
|
1548 |
} |
|
1549 |
||
1550 |
inline TBool CheckPolicy(DThread* aThread, OnlyCreateWithNull /*aDiagnostic*/=NULL) const |
|
1551 |
{ |
|
1552 |
return DoCheckPolicy(aThread); |
|
1553 |
} |
|
1554 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1555 |
||
1556 |
private: |
|
1557 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTICS__ |
|
1558 |
TBool DoCheckPolicy(DProcess* aProcess, const char* aDiagnostic) const; |
|
1559 |
TBool DoCheckPolicy(DThread* aThread, const char* aDiagnostic) const; |
|
1560 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTICS__ |
|
1561 |
TBool DoCheckPolicy(DProcess* aProcess) const; |
|
1562 |
TBool DoCheckPolicy(DThread* aThread) const; |
|
1563 |
||
1564 |
TBool CheckPolicy(const SSecurityInfo& aSecInfo, SSecurityInfo& aMissing) const; |
|
1565 |
void AddCapability(TCapability aCap); |
|
1566 |
||
1567 |
inline void SetETypeFail() { /* Yes, it's a NOP */iCaps |= EMaskFail; } |
|
1568 |
inline void SetETypePass() { iCaps |= EMaskCapsOnly; } |
|
1569 |
inline void SetETypeCapsOnly() { iCaps |= EMaskCapsOnly; } |
|
1570 |
inline void SetETypeSecureId() { iCaps |= (TUint32)EMaskSecureId; } |
|
1571 |
inline void SetETypeVendorId() { iCaps |= (TUint32)EMaskVendorId; } |
|
1572 |
||
1573 |
inline TUint32 Caps() const { return iCaps & ~EMaskVendorId; } |
|
1574 |
inline TUint32 Type() const { return iCaps >> KCSPBitsFree; } |
|
1575 |
union |
|
1576 |
{ |
|
1577 |
TUint32 iSecureId; |
|
1578 |
TUint32 iVendorId; |
|
1579 |
}; |
|
1580 |
TUint32 iCaps; |
|
1581 |
}; |
|
1582 |
||
1583 |
/******************************************** |
|
1584 |
* Process control block |
|
1585 |
********************************************/ |
|
1586 |
struct SCodeSegEntry |
|
1587 |
{ |
|
1588 |
DCodeSeg* iSeg; // code segment in use |
|
1589 |
DLibrary* iLib; // client representation object (DLibrary or DxxDevice) |
|
1590 |
}; |
|
1591 |
||
1592 |
class DProcess : public DObject |
|
1593 |
{ |
|
1594 |
public: |
|
1595 |
/** Possible values for bitmask specifying how to iterate dependency graph. |
|
1596 |
@see TraverseCodeSegs |
|
1597 |
@publishedPartner |
|
1598 |
@released |
|
1599 |
*/ |
|
1600 |
enum TTraverseFlags |
|
1601 |
{ |
|
1602 |
/** Add code segment to queue if set, remove it if cleared */ |
|
1603 |
ETraverseFlagAdd=1, |
|
1604 |
/** Restrict iteration to dynamic dependencies in ELoaded state if set, |
|
1605 |
iterate everything if cleared */ |
|
1606 |
ETraverseFlagRestrict=2 |
|
1607 |
}; |
|
1608 |
public: |
|
1609 |
DProcess(); |
|
1610 |
~DProcess(); |
|
1611 |
TInt Create(TBool aKernelProcess, TProcessCreateInfo& aInfo, HBuf* aCommandLine); |
|
1612 |
TInt SetPriority(TProcessPriority aPriority); |
|
1613 |
TInt ConvertPriority(TProcessPriority aPriority); |
|
1614 |
void Destruct(); |
|
1615 |
TInt Rename(const TDesC& aName); |
|
1616 |
TInt Logon(TRequestStatus* aStatus, TBool aRendezvous); |
|
1617 |
void Rendezvous(TInt aReason); |
|
1618 |
IMPORT_C TInt TraverseCodeSegs(SDblQue* aQ, DCodeSeg* aExclude, TUint32 aMark, TUint32 aFlags); |
|
1619 |
TInt OpenDeps(); |
|
1620 |
TInt AddCodeSeg(DCodeSeg* aSeg, DLibrary* aLib, SDblQue& aQ); |
|
1621 |
void RemoveCodeSeg(DCodeSeg* aCodeSeg, SDblQue* aQ); |
|
1622 |
TInt CallList(SDblQue& aQ, DCodeSeg* aSeg, TUint32 aFlag); |
|
1623 |
DCodeSeg* CodeSeg(); |
|
1624 |
TBool HasCapabilityNoDiagnostic(TCapability aCapability); |
|
1625 |
inline TBool HasCapability(/*TInt aCapability*/); |
|
1626 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1627 |
inline TBool HasCapability(TCapability aCapability, const char* aDiagnosticText=0); |
|
1628 |
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1629 |
// Only available to NULL arguments |
|
1630 |
inline TBool HasCapability(TCapability aCapability, OnlyCreateWithNull aDiagnostic=NULL); |
|
1631 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1632 |
private: |
|
1633 |
IMPORT_C TBool DoHasCapability(TCapability aCapability, const char* aDiagnostic); |
|
1634 |
IMPORT_C TBool DoHasCapability(TCapability aCapability); |
|
1635 |
protected: |
|
1636 |
virtual TInt SetPaging(const TProcessCreateInfo& aInfo); |
|
1637 |
public: |
|
1638 |
virtual void DoAppendName(TDes& aName); |
|
1639 |
virtual TInt NewChunk(DChunk*& aChunk, SChunkCreateInfo& aInfo, TLinAddr& aRunAddr)=0; |
|
1640 |
virtual TInt AddChunk(DChunk* aChunk,TBool isReadOnly)=0; |
|
1641 |
virtual TInt NewShPool(DShPool*& aPool, TShPoolCreateInfo& aInfo)=0; |
|
1642 |
virtual TInt DoCreate(TBool aKernelProcess, TProcessCreateInfo& aInfo)=0; |
|
1643 |
virtual TInt AttachExistingCodeSeg(TProcessCreateInfo& aInfo)=0; |
|
1644 |
virtual TInt Loaded(TProcessCreateInfo& aInfo); |
|
1645 |
virtual void FinalRelease()=0; |
|
1646 |
public: |
|
1647 |
TInt NewThread(DThread*& aThread, SThreadCreateInfo& aInfo, TInt* aHandle, TOwnerType aType); |
|
1648 |
virtual void Resume(); |
|
1649 |
void Die(TExitType aType,TInt aReason,const TDesC &aCategory); |
|
1650 |
virtual void Release(); |
|
1651 |
TBool KillAllThreads(TExitType aType, TInt aReason, const TDesC &aCategory); |
|
1652 |
||
1653 |
public: |
|
1654 |
virtual TInt GetNewThread(DThread*& aThread, SThreadCreateInfo& aInfo)=0; |
|
1655 |
virtual TInt CreateDataBssStackArea(TProcessCreateInfo& aInfo)=0; |
|
1656 |
virtual TInt MapCodeSeg(DCodeSeg* aCodeSeg)=0; |
|
1657 |
virtual void UnmapCodeSeg(DCodeSeg* aCodeSeg)=0; |
|
1658 |
virtual void RemoveDllData()=0; |
|
1659 |
virtual void BTracePrime(TInt aCategory); |
|
1660 |
public: |
|
1661 |
TInt WaitProcessLock(); |
|
1662 |
TInt SignalProcessLock(); |
|
1663 |
TInt WaitDllLock(); |
|
1664 |
void SignalDllLock(); |
|
1665 |
void AddThread(DThread &aThread); |
|
1666 |
#ifdef __SMP__ |
|
1667 |
TInt UpdateSMPSafe(); |
|
1668 |
#endif |
|
1669 |
inline DThread* FirstThread() |
|
1670 |
{ return _LOFF(iThreadQ.First(),DThread,iProcessLink); } |
|
1671 |
public: |
|
1672 |
TInt iPriority; |
|
1673 |
SDblQue iThreadQ; |
|
1674 |
TUint8 iExitType; |
|
1675 |
TUint8 iFinalReleaseFlag; |
|
1676 |
TUint8 iPad2; |
|
1677 |
TUint8 iDebugAttributes; |
|
1678 |
TInt iExitReason; |
|
1679 |
TBufC<KMaxExitCategoryName> iExitCategory; |
|
1680 |
RObjectIx iHandles; |
|
1681 |
TUidType iUids; |
|
1682 |
TInt iGeneration; |
|
1683 |
TUint iId; |
|
1684 |
TUint32 iFlags; |
|
1685 |
HBuf* iCommandLine; |
|
1686 |
DProcess* iOwningProcess; |
|
1687 |
SDblQue iTargetLogons; |
|
1688 |
RArray<SCodeSegEntry> iDynamicCode; |
|
1689 |
// RPointerArray<DLibrary> iDynamicCode; |
|
1690 |
SSecurityInfo iS; |
|
1691 |
SSecurityInfo iCreatorInfo; |
|
1692 |
TUint iCreatorId; |
|
1693 |
TUint iSecurityZone; |
|
1694 |
TInt iEnvironmentData[KArgIndex]; |
|
1695 |
||
1696 |
public: |
|
1697 |
enum TProcessAttributes { |
|
1698 |
EPrivate = 0x00000002, |
|
300 | 1699 |
EDataPaged = 0x00000004, // Set when the process is data paged |
1700 |
EStaticCallsDone= 0x00000010, // Set after static constructors are called |
|
1701 |
EResumed = 0x00010000, |
|
0 | 1702 |
EBeingLoaded = 0x08000000, |
300 | 1703 |
ESupervisor = (TInt)0x80000000, |
0 | 1704 |
}; |
1705 |
TInt iAttributes; |
|
1706 |
TLinAddr iDataBssRunAddress; |
|
1707 |
DChunk* iDataBssStackChunk; |
|
1708 |
DCodeSeg* iCodeSeg; |
|
1709 |
DCodeSeg* iTempCodeSeg; |
|
1710 |
DMutex* iProcessLock; |
|
1711 |
DMutex* iDllLock; // can be held while in user mode |
|
1712 |
TLinAddr iReentryPoint; // user address to jump to for new threads, exceptions |
|
1713 |
SDblQue iGarbageList; // list of DLibrary containing code which will be unmapped later |
|
1714 |
TInt iThreadsLeaving; // count of threads currently leaving [only w/C++ exceptions] |
|
1715 |
TInt iUserThreadsRunning; // count of running user threads that have not yet called User::Exit |
|
1716 |
volatile TInt iSMPUnsafeCount; // count of top level codesegs that are SMP unsafe |
|
1717 |
// i.e. the exe itself or things RLibrary::Load'ed - not deps |
|
1718 |
#ifdef __SMP__ |
|
1719 |
NThreadGroup* iSMPUnsafeGroup; // group used to keep unsafe threads scheduled together |
|
1720 |
#endif |
|
1721 |
public: |
|
1722 |
friend class Monitor; |
|
1723 |
||
1724 |
}; |
|
1725 |
||
1726 |
inline TBool DProcess::HasCapabilityNoDiagnostic(TCapability aCapability) |
|
1727 |
{ |
|
1728 |
if(aCapability==ECapability_None) |
|
1729 |
return ETrue; |
|
1730 |
if((TUint32)aCapability<(TUint32)ECapability_Limit) |
|
1731 |
return (iS.iCaps[aCapability>>5]>>(aCapability&31))&1; |
|
1732 |
return EFalse; |
|
1733 |
} |
|
1734 |
||
1735 |
inline TBool DProcess::HasCapability(/*TInt aCapability*/) |
|
1736 |
{ return iS.iCaps[0]!=~1u; } // Always return true for now |
|
1737 |
||
1738 |
inline TBool DThread::HasCapability(/*TInt aCapability*/) |
|
1739 |
{ return iOwningProcess->HasCapability(/*aCapability*/); } |
|
1740 |
||
1741 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1742 |
inline TBool DProcess::HasCapability(TCapability aCapability, const char* aDiagnosticText) |
|
1743 |
{ |
|
1744 |
return DoHasCapability(aCapability, aDiagnosticText); |
|
1745 |
} |
|
1746 |
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1747 |
// Only available to NULL arguments |
|
1748 |
inline TBool DProcess::HasCapability(TCapability aCapability, OnlyCreateWithNull /*aDiagnostic*/) |
|
1749 |
{ |
|
1750 |
return DoHasCapability(aCapability); |
|
1751 |
} |
|
1752 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
1753 |
||
1754 |
||
1755 |
/******************************************** |
|
1756 |
* Session control block |
|
1757 |
********************************************/ |
|
1758 |
class DServer; |
|
1759 |
class DSession : public DObject |
|
1760 |
{ |
|
1761 |
public: |
|
1762 |
DSession(); |
|
1763 |
virtual ~DSession(); |
|
1764 |
TInt Add(DServer* aSvr, const TSecurityPolicy* aSecurityPolicy); |
|
1765 |
void Transfer(DServer* aServer, RMessageK* aMsg); |
|
1766 |
TInt MakeHandle(); |
|
1767 |
virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType); |
|
1768 |
virtual TInt Close(TAny*); |
|
1769 |
void Detach(TInt aReason); |
|
1770 |
void CloseFromDisconnect(); |
|
1771 |
inline TBool IsClosing(); |
|
1772 |
inline void TotalAccessInc() |
|
1773 |
{__ASSERT_SYSTEM_LOCK; iTotalAccessCount++;}; |
|
1774 |
TInt TotalAccessDec(); |
|
1775 |
TInt TotalAccessDecRel(); |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1776 |
void BTracePrime(TInt aCategory); |
0 | 1777 |
|
1778 |
public: |
|
1779 |
// Static methods called from exec handlers |
|
1780 |
static TInt New(DSession*& aS, TInt aMsgSlots, TInt aMode); |
|
1781 |
static TInt Send(TInt aHandle, TInt aFunction, const TInt* aPtr, TRequestStatus* aStatus); |
|
1782 |
static TInt SendSync(TInt aHandle, TInt aFunction, const TInt* aPtr, TRequestStatus* aStatus); |
|
1783 |
||
1784 |
private: |
|
1785 |
TInt Send(RMessageK* aMsg, TInt aFunction, const RMessageK::TMsgArgs* aArgs, TRequestStatus* aStatus); |
|
1786 |
RMessageK* GetNextFreeMessage(); |
|
1787 |
||
1788 |
public: |
|
1789 |
DServer* iServer; // pointer to kernel-side server object |
|
1790 |
SDblQueLink iServerLink; // link to attach session to server |
|
1791 |
const TAny* iSessionCookie; // pointer to server-side CSession2 (user cookie) |
|
1792 |
TUint8 iSessionType; // TIpcSessionType |
|
1793 |
TUint8 iSvrSessionType; // TIpcSessionType |
|
1794 |
TUint8 iHasSessionPool; // TIpcSessionType |
|
1795 |
TUint8 iTotalAccessCount; // all client accesses together contribute 1, modify with system locked |
|
1796 |
TInt iPoolSize; // number of messages in private pool |
|
1797 |
TInt iMsgCount; // total number of outstanding messages on this session |
|
1798 |
TInt iMsgLimit; // maximum number of outstanding messages on this session |
|
1799 |
SDblQue iMsgQ; // queue of all outstanding messages on this session (by iSessionLink) |
|
1800 |
RMessageK* iDisconnectMsgPtr; // preallocated disconnect message |
|
1801 |
RMessageK* volatile iConnectMsgPtr; // pointer to connect message, if any |
|
1802 |
RMessageK* volatile iNextFreeMessage; // pointer to next free message in per-session message pool, if any |
|
1803 |
}; |
|
1804 |
||
1805 |
inline TBool DSession::IsClosing() |
|
1806 |
{ return !AccessCount(); } |
|
1807 |
||
1808 |
/******************************************** |
|
1809 |
* Server control block |
|
1810 |
********************************************/ |
|
1811 |
||
1812 |
class TServerMessage : public TClientRequest |
|
1813 |
{ |
|
1814 |
public: |
|
1815 |
TServerMessage(); |
|
1816 |
private: |
|
1817 |
static void CallbackFunc(TAny* aData, TUserModeCallbackReason aReason); |
|
1818 |
private: |
|
1819 |
TAny* iMessagePtr; // where to deliver messages |
|
1820 |
RMessageK* iMessageData; // message to deliver |
|
1821 |
friend class DServer; |
|
1822 |
private: |
|
1823 |
~TServerMessage(); // call Close(), don't delete |
|
1824 |
}; |
|
1825 |
||
1826 |
class DServer : public DObject |
|
1827 |
{ |
|
1828 |
public: |
|
1829 |
DServer(); |
|
1830 |
TInt Create(); |
|
1831 |
virtual ~DServer(); |
|
1832 |
virtual TInt Close(TAny*); |
|
1833 |
virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType); |
|
1834 |
void Receive(TRequestStatus& aStatus, TAny* aMessage); // aMessage bit 0 = 0 -> RMessage, bit 0 = 1 -> RMessage2 |
|
1835 |
void Cancel(); |
|
1836 |
void Accept(RMessageK* aMsg); |
|
1837 |
void Deliver(RMessageK* aMsg); |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1838 |
void BTracePrime(TInt aCategory); |
0 | 1839 |
public: |
1840 |
inline TBool IsClosing(); |
|
1841 |
public: |
|
1842 |
DThread* iOwningThread; // thread which receives messages |
|
1843 |
TServerMessage* iMessage; |
|
1844 |
SDblQue iSessionQ; // list of sessions |
|
1845 |
SDblQue iDeliveredQ; // list of messages delivered but not yet accepted |
|
1846 |
TUint8 iSessionType; // TIpcSessionType |
|
1847 |
TUint8 iPinClientDescriptors; // Set to 1 to make the server pin client descriptor |
|
1848 |
// arguments it receives, 0 otherwise. |
|
1849 |
TUint8 iServerRole; // TIpcServerRole: Standalone, Master, or Slave? |
|
1850 |
TUint8 iPadding; |
|
1851 |
}; |
|
1852 |
||
1853 |
inline TBool DServer::IsClosing() |
|
1854 |
{ return !AccessCount(); } |
|
1855 |
||
1856 |
||
1857 |
struct TCodeSegLoaderCookieList |
|
1858 |
{ |
|
1859 |
TCodeSegLoaderCookieList* iNext; |
|
1860 |
TCodeSegLoaderCookie iCookie; |
|
1861 |
}; |
|
1862 |
||
1863 |
/******************************************** |
|
1864 |
* Code segment |
|
1865 |
********************************************/ |
|
1866 |
||
1867 |
/** Code segment |
|
1868 |
||
1869 |
Low-level abstraction describing an executable or DLL used by one or more |
|
1870 |
processes. Higher-level abstraction (DLibrary, DPhysicalDevice, |
|
1871 |
DLogicalDevice and DProcess) use code segments internally. |
|
1872 |
||
1873 |
Each code segment maintains a table of all code segments it directly |
|
1874 |
depends on, thus forming a dependency graph. |
|
1875 |
||
1876 |
Note that dependency information about ROM-based DLLs without static |
|
1877 |
data is lost during the ROM building process. Therefore These DLLs are not |
|
1878 |
included in the dependency graph. |
|
1879 |
||
1880 |
@internalTechnology |
|
1881 |
*/ |
|
1882 |
||
1883 |
class DCodeSeg : public DBase |
|
1884 |
{ |
|
1885 |
public: |
|
1886 |
/** Possible values for DCodeSeg::iMark bitmask. |
|
1887 |
All values except explicitly specified are reserved for internal |
|
1888 |
kernel use. |
|
1889 |
*/ |
|
1890 |
enum TMark |
|
1891 |
{ |
|
1892 |
EMarkListDeps=0x01, |
|
1893 |
EMarkUnListDeps=0x02, |
|
1894 |
EMarkLdr=0x04, |
|
1895 |
EMarkProfilerTAG=0x08, // used by profiler tool to mark processed non-XIP objects. |
|
1896 |
EMarkLoaded=0x10, // this code segment is reloadable |
|
1897 |
EMarkRecursiveFlagsValid=0x20, // the recursively computed bits are valid |
|
1898 |
EMarkRecursiveFlagsCheck=0x40, // the recursively computed bits are being checked or are valid |
|
1899 |
EMarkData=0x04000000u, // image has data and is not extension or variant (=KRomImageFlagData) |
|
1900 |
EMarkDataInit=0x02000000u, // graph below and including image requires user init (=KRomImageFlagDataInit) |
|
1901 |
EMarkDataPresent=0x01000000u, // graph below and including image has data (=KRomImageFlagDataPresent) |
|
1902 |
EMarkDebug=0x08000000u, // reserved for debug agents |
|
1903 |
}; |
|
1904 |
public: |
|
1905 |
DCodeSeg(); |
|
1906 |
void Destruct(); |
|
1907 |
inline void Open() {++iAccessCount;} |
|
1908 |
void Close(); |
|
1909 |
void CheckedClose(); |
|
1910 |
void CheckedOpen(); |
|
1911 |
void WaitCheckedOpen(); |
|
1912 |
TInt Create(TCodeSegCreateInfo& aInfo, DProcess* aProcess); |
|
1913 |
TInt ListDeps(SDblQue* aQ, TUint32 aMark); |
|
1914 |
TInt UnListDeps(TUint32 aMark); |
|
1915 |
TInt MarkAndOpenDeps(TUint32 aMark); |
|
1916 |
void FinaliseRecursiveFlags(); |
|
1917 |
void CalcRecursiveFlags(); |
|
1918 |
void SetAttachProcess(DProcess* aProcess); |
|
1919 |
public: |
|
1920 |
// virtual |
|
1921 |
virtual void Info(TCodeSegCreateInfo& aInfo); |
|
1922 |
virtual TInt Loaded(TCodeSegCreateInfo& aInfo); |
|
1923 |
virtual TInt AddDependency(DCodeSeg* aExporter); |
|
1924 |
virtual void BTracePrime(TInt aCategory); |
|
1925 |
// Pure virtual |
|
1926 |
virtual TLibraryFunction Lookup(TInt aOrdinal) =0; |
|
1927 |
virtual TInt GetMemoryInfo(TModuleMemoryInfo& aInfo, DProcess* aProcess) =0; |
|
1928 |
virtual TInt DoCreate(TCodeSegCreateInfo& aInfo, DProcess* aProcess)=0; |
|
1929 |
virtual void InitData()=0; |
|
1930 |
virtual void ReadExportDir(TUint32* aDest)=0; |
|
1931 |
virtual TBool FindCheck(DProcess* aProcess)=0; |
|
1932 |
virtual TBool OpenCheck(DProcess* aProcess)=0; |
|
1933 |
public: |
|
1934 |
static void Wait(); |
|
1935 |
static void Signal(); |
|
1936 |
IMPORT_C static DCodeSeg* VerifyHandle(TAny* aHandle); |
|
1937 |
static DCodeSeg* VerifyHandleP(TAny* aHandle); |
|
1938 |
static DCodeSeg* VerifyCallerAndHandle(TAny* aHandle); |
|
1939 |
static DCodeSeg* FindCodeSeg(const TFindCodeSeg& aFind); |
|
1940 |
static DCodeSeg* FindRomCode(const TAny* aRomImgHdr); |
|
1941 |
IMPORT_C static void UnmarkAll(TUint32 aMask); |
|
1942 |
static void UnmarkAndCloseAll(TUint32 aMask); |
|
1943 |
static TInt ListMarked(SDblQue& aQ, TUint32 aMask); |
|
1944 |
IMPORT_C static void EmptyQueue(SDblQue& aQ, TUint32 aMask); |
|
1945 |
static void EmptyGarbageList(); |
|
1946 |
static void DeferDeletes(); |
|
1947 |
static void EndDeferDeletes(); |
|
1948 |
static TInt WriteCallList(SDblQue& aList, TLinAddr* aEpList, TBool aInitData); |
|
1949 |
IMPORT_C static DCodeSeg* CodeSegFromEntryPoint(TInt aEntryPoint); |
|
1950 |
static void DoKernelCleanup(TAny*); |
|
1951 |
void ScheduleKernelCleanup(TBool aImmed); |
|
1952 |
static void QueueKernelCleanup(); |
|
1953 |
static void DeferKernelCleanup(); |
|
1954 |
static void EndDeferKernelCleanup(); |
|
1955 |
void AppendFullRootName(TDes& aDes); |
|
1956 |
void AppendFullFileName(TDes& aDes); |
|
1957 |
void AppendVerExt(TDes& aDes); |
|
1958 |
void TraceAppendFullName(TDes& aDes); |
|
1959 |
TLinAddr ExceptionDescriptor(); |
|
1960 |
public: |
|
1961 |
inline TBool IsDll() const |
|
1962 |
{return iUids.iUid[0].iUid==KDynamicLibraryUidValue;} |
|
1963 |
inline TBool IsExe() const |
|
1964 |
{return iUids.iUid[0].iUid==KExecutableImageUidValue;} |
|
1965 |
public: |
|
1966 |
SDblQueLink iLink; // link to global list |
|
1967 |
SDblQueLink iTempLink; // temporary link for computing lists |
|
1968 |
SDblQueLink iGbgLink; // link to garbage list |
|
1969 |
TUint32 iGbgIdleGenerationCount; |
|
1970 |
TInt iAccessCount; |
|
1971 |
TLinAddr iEntryPtVeneer; // address of first instruction to be called |
|
1972 |
TLinAddr iFileEntryPoint; // address of entry point within this code segment |
|
1973 |
HBuf* iFileName; // Full path name |
|
1974 |
TPtrC iRootName; // Filename.Ext - points into iFileName |
|
1975 |
TInt iExtOffset; // Offset of extension in iFileName |
|
1976 |
TUidType iUids; |
|
1977 |
DCodeSeg** iDeps; // code segments on which this one depends (not reference counted) |
|
1978 |
TInt iDepCount; // number of dependencies |
|
1979 |
TInt iNextDep; |
|
1980 |
TUint32 iMark; |
|
1981 |
TUint32 iAttr; |
|
1982 |
DCodeSeg* iExeCodeSeg; // EXE code segment with which this can be used |
|
1983 |
DProcess* iAttachProcess; // Process with which this can be used (NULL if several) |
|
1984 |
TUint32 iModuleVersion; |
|
1985 |
SSecurityInfo iS; |
|
1986 |
TLinAddr iRunAddress; |
|
1987 |
TUint32 iSize; |
|
1988 |
||
1989 |
public: |
|
1990 |
static SDblQue GlobalList; // list of all existing DCodeSeg |
|
1991 |
static SDblQue GarbageList; // list of DCodeSeg whose deletion is pending due to DeferDeletes() |
|
1992 |
static SDblQue KernelGarbageList; // list of DCodeSeg containing kernel code which will be unmapped when the system goes idle |
|
1993 |
static SDblQue DeferredKernelGarbageList; |
|
1994 |
static TDfc KernelCleanupDfc; |
|
1995 |
static TInt KernelCleanupLock; |
|
1996 |
static DMutex* CodeSegLock; |
|
1997 |
static TInt DeleteLock; |
|
1998 |
static RPointerArray<DCodeSeg> CodeSegsByName; // list of code segments in name order |
|
1999 |
||
2000 |
class RCodeSegsByAddress |
|
2001 |
{ |
|
2002 |
public: |
|
2003 |
RCodeSegsByAddress(TInt aMinGrowBy, TInt aFactor); |
|
2004 |
TInt Add(DCodeSeg* aCodeSeg); |
|
2005 |
TInt Remove(DCodeSeg* aCodeseg); |
|
2006 |
DCodeSeg* Find(TLinAddr aAddress); |
|
2007 |
private: |
|
2008 |
static TInt Compare(const DCodeSeg& aA, const DCodeSeg& aB); |
|
2009 |
private: |
|
2010 |
TInt iActive; |
|
2011 |
RPointerArray<DCodeSeg> iArray[2]; |
|
2012 |
}; |
|
2013 |
static RCodeSegsByAddress CodeSegsByAddress; // list of code segments in run address order |
|
2014 |
static TClientRequest* DestructNotifyRequest; // Used to complete NotifyIfCodeSegDestroyed |
|
2015 |
static DThread* DestructNotifyThread; // Used to complete NotifyIfCodeSegDestroyed |
|
2016 |
static TCodeSegLoaderCookieList* DestructNotifyList; //Used to hold the list of cookie for destroyed codsegs. |
|
2017 |
}; |
|
2018 |
||
2019 |
/******************************************** |
|
2020 |
* Library control block |
|
2021 |
********************************************/ |
|
2022 |
class DLibrary : public DObject |
|
2023 |
{ |
|
2024 |
public: |
|
2025 |
enum TState |
|
2026 |
{ |
|
2027 |
ECreated=0, // initial state |
|
2028 |
ELoaded=1, // code segment loaded |
|
2029 |
EAttaching=2, // calling constructors |
|
2030 |
EAttached=3, // all constructors done |
|
2031 |
EDetachPending=4, // about to call destructors |
|
2032 |
EDetaching=5, // calling destructors |
|
2033 |
}; |
|
2034 |
public: |
|
2035 |
static TInt New(DLibrary*& aLib, DProcess* aProcess, DCodeSeg* aSeg); |
|
2036 |
DLibrary(); |
|
2037 |
void RemoveFromProcess(); |
|
2038 |
void ReallyRemoveFromProcess(); |
|
2039 |
virtual ~DLibrary(); |
|
2040 |
virtual TInt Close(TAny* aPtr); |
|
2041 |
virtual TInt AddToProcess(DProcess* aProcess); |
|
2042 |
virtual void DoAppendName(TDes& aName); |
|
2043 |
public: |
|
2044 |
TInt iMapCount; |
|
2045 |
TUint8 iState; |
|
2046 |
SDblQueLink iThreadLink; // attaches to opening or closing thread |
|
2047 |
DCodeSeg* iCodeSeg; |
|
2048 |
SDblQueLink iGbgLink; |
|
2049 |
}; |
|
2050 |
||
2051 |
/******************************************** |
|
2052 |
* Change notifier control block |
|
2053 |
********************************************/ |
|
2054 |
class DChangeNotifier : public DObject |
|
2055 |
{ |
|
2056 |
public: |
|
2057 |
DChangeNotifier(); |
|
2058 |
~DChangeNotifier(); |
|
2059 |
TInt Create(); |
|
2060 |
void Notify(TUint aChanges); |
|
2061 |
TInt Logon(TRequestStatus& aStatus, DThread* aThread); |
|
2062 |
TInt LogonCancel(DThread* aThread); |
|
2063 |
void Complete(TInt aResult); |
|
2064 |
public: |
|
2065 |
TUint iChanges; |
|
2066 |
TClientRequest* iRequest; |
|
2067 |
DThread* iThread; |
|
2068 |
public: |
|
2069 |
friend class Monitor; |
|
2070 |
}; |
|
2071 |
||
2072 |
/******************************************** |
|
2073 |
* Undertaker control block |
|
2074 |
********************************************/ |
|
2075 |
||
2076 |
class DUndertaker : public DObject |
|
2077 |
{ |
|
2078 |
public: |
|
2079 |
TInt Create(); |
|
2080 |
~DUndertaker(); |
|
2081 |
void Notify(DThread* aDeadThread); |
|
2082 |
TInt Logon(TRequestStatus *aStatus, TInt* aDeadThreadHandle); |
|
2083 |
TInt LogonCancel(); |
|
2084 |
void Complete(TInt aValue, DThread* aDeadThread); |
|
2085 |
public: |
|
2086 |
TClientDataRequest<TInt>* iRequest; |
|
2087 |
DThread* iOwningThread; |
|
2088 |
public: |
|
2089 |
friend class Monitor; |
|
2090 |
}; |
|
2091 |
||
2092 |
/******************************************** |
|
2093 |
* Shared Io Buffers |
|
2094 |
********************************************/ |
|
2095 |
||
2096 |
/** |
|
2097 |
@publishedPartner |
|
2098 |
@released |
|
2099 |
||
2100 |
A kernel object for sharing memory between kernel code and user space code. |
|
2101 |
||
2102 |
It is used to avoid an extra copy when handling large amounts of data between |
|
2103 |
kernel and user space code. Used in device drivers that will handle instances |
|
2104 |
of this class and pass pointers to the buffer to user space clients. |
|
2105 |
Each buffer can be mapped into a single process. |
|
2106 |
The lifetime of this object is maintained by the device driver. |
|
2107 |
These objects are intended for use where speed is essential, such as for |
|
2108 |
streaming media data. |
|
2109 |
*/ |
|
2110 |
class DSharedIoBuffer : public DBase |
|
2111 |
{ |
|
2112 |
public: |
|
2113 |
/** |
|
2114 |
@internalComponent |
|
2115 |
*/ |
|
2116 |
enum TPanic |
|
2117 |
{ |
|
2118 |
EAlreadyCreated=1, |
|
2119 |
EAlreadyMapped |
|
2120 |
}; |
|
2121 |
IMPORT_C ~DSharedIoBuffer(); |
|
2122 |
IMPORT_C static TInt New(DSharedIoBuffer*& aBuffer, TUint32 aSize, TUint aAttribs); |
|
2123 |
#if defined(__EPOC32__) |
|
2124 |
IMPORT_C static TInt New(DSharedIoBuffer*& aBuffer, TPhysAddr aPhysAddr, TUint32 aSize, TUint aAttribs); |
|
2125 |
#endif |
|
2126 |
IMPORT_C TInt UserMap(DProcess* aUserProcess); |
|
2127 |
IMPORT_C TInt UserUnmap(); |
|
2128 |
IMPORT_C TLinAddr UserToKernel(TLinAddr aUserAddress, TUint32 aSize); |
|
2129 |
IMPORT_C TLinAddr KernelToUser(TLinAddr aKernelAddress); |
|
2130 |
public: |
|
2131 |
/** |
|
2132 |
The address of the shared buffer that code running on the kernel side uses |
|
2133 |
to access the buffer. |
|
2134 |
||
2135 |
@see DSharedIoBuffer::UserToKernel() |
|
2136 |
@see DSharedIoBuffer::KernelToUser() |
|
2137 |
*/ |
|
2138 |
TLinAddr iAddress; |
|
2139 |
||
2140 |
/** |
|
2141 |
The size of the shared buffer. |
|
2142 |
||
2143 |
After mapping the buffer into the user-side address space via a call |
|
2144 |
to DSharedIoBuffer::UserMap(), this value must be returned to |
|
2145 |
the user-side via normal logical channel operations so that user |
|
2146 |
code can start using the buffer. |
|
2147 |
||
2148 |
@see DSharedIoBuffer::UserMap() |
|
2149 |
*/ |
|
2150 |
TUint32 iSize; |
|
2151 |
||
2152 |
/** |
|
2153 |
The address of the shared buffer that code running in the user process |
|
2154 |
will use to access that buffer. |
|
2155 |
||
2156 |
After mapping the buffer into the user-side address space via a call |
|
2157 |
to DSharedIoBuffer::UserMap(), this value must be returned to |
|
2158 |
the user-side via normal logical channel operations so that user |
|
2159 |
code can start using the buffer. |
|
2160 |
||
2161 |
@see DSharedIoBuffer::UserMap() |
|
2162 |
@see DSharedIoBuffer::UserToKernel() |
|
2163 |
@see DSharedIoBuffer::KernelToUser() |
|
2164 |
*/ |
|
2165 |
TLinAddr iUserAddress; |
|
2166 |
||
2167 |
/** |
|
2168 |
@internalComponent |
|
2169 |
*/ |
|
2170 |
DProcess* iUserProcess; |
|
2171 |
private: |
|
2172 |
/** |
|
2173 |
@internalComponent |
|
2174 |
*/ |
|
2175 |
DChunk* iChunk; |
|
2176 |
private: |
|
2177 |
TInt DoCreate(TUint32 aSize, TUint aAttribs); /**< @internalComponent */ |
|
2178 |
TInt DoCreate(TUint32 aPhysAddr, TUint32 aSize, TUint aAttribs); /**< @internalComponent */ |
|
2179 |
private: |
|
2180 |
DSharedIoBuffer(); /**< @internalComponent */ |
|
2181 |
}; |
|
2182 |
||
2183 |
/******************************************** |
|
2184 |
* System tick-based timer queues |
|
2185 |
********************************************/ |
|
2186 |
/******************************************** |
|
2187 |
* Timers based on the system tick |
|
2188 |
* Platform layer code |
|
2189 |
********************************************/ |
|
2190 |
class TTickQ : public SDeltaQue |
|
2191 |
{ |
|
2192 |
public: |
|
2193 |
TTickQ(); |
|
2194 |
void Tick(); |
|
2195 |
static TInt Init(); |
|
2196 |
static void Wait(); |
|
2197 |
static void Signal(); |
|
2198 |
public: |
|
2199 |
// In platform layer |
|
2200 |
void Add(TTickLink* aLink, TInt aPeriod); |
|
2201 |
void StartTimer(); |
|
2202 |
void Update(); |
|
2203 |
void Synchronise(); // update everything as if a tick has just occurred |
|
2204 |
void Check(); |
|
2205 |
public: |
|
2206 |
TInt iLastDelta; // delta ticks at next ms timer expiry |
|
2207 |
TUint32 iLastTicks; // tick count at last expiry |
|
2208 |
Int64 iRtc; // tick count acting as RTC (ticks from 00:00:00 01-01-0000 UTC) |
|
2209 |
TInt iTickPeriod; // tick period in microseconds |
|
2210 |
TInt iTicksPerSecond; // ticks per second, rounded up |
|
2211 |
TInt iNominalTickPeriod; // nominal tick period in microseconds |
|
2212 |
TBool iInTick; |
|
2213 |
static DMutex* Mutex; |
|
2214 |
public: |
|
2215 |
TInt iRounding; // rounding applied to current ms timer in us |
|
2216 |
TInt iPrevRounding; // rounding applied to last ms timer in us |
|
2217 |
TUint32 iLastMs; // ms count at last expiry |
|
2218 |
TInt iMsTickPeriod; // in microseconds |
|
2219 |
TDfc iTickDfc; |
|
2220 |
NTimer iMsTimer; |
|
2221 |
}; |
|
2222 |
||
2223 |
class TSecondQ : public SDblQue |
|
2224 |
{ |
|
2225 |
public: |
|
2226 |
TSecondQ(); |
|
2227 |
void Tick(); |
|
2228 |
void WakeUp(); |
|
2229 |
static void TickCallBack(TAny* aPtr); |
|
2230 |
static void WakeUpDfc(TAny* aPtr); |
|
2231 |
public: |
|
2232 |
void Add(TSecondLink* aLink); |
|
2233 |
void StartTimer(); |
|
2234 |
TInt FirstDelta(); |
|
2235 |
TTimeK WakeupTime(); |
|
2236 |
public: |
|
2237 |
TBool iInTick; |
|
2238 |
Int64 iNextTrigger; // next trigger time in ticks from 00:00:00 01-01-0000 UTC |
|
2239 |
Int64 iMidnight; // next midnight (home time) in ticks from 00:00:00 01-01-0000 UTC |
|
2240 |
TInt iTicksPerDay; |
|
2241 |
TTickLink iTimer; |
|
2242 |
TDfc iWakeUpDfc; |
|
2243 |
}; |
|
2244 |
||
2245 |
class TInactivityQ : public SDblQue |
|
2246 |
{ |
|
2247 |
public: |
|
2248 |
TInactivityQ(); |
|
2249 |
void Reset(); |
|
2250 |
TInt InactiveTime(); |
|
2251 |
public: |
|
2252 |
void Expired(TBool aTicksUpdated); |
|
2253 |
void EventDfc(); |
|
2254 |
static void TimerCallBack(TAny* aPtr); |
|
2255 |
static void EventDfcFn(TAny* aPtr); |
|
2256 |
public: |
|
2257 |
SDblQue iPending; |
|
2258 |
TUint32 iLastEventTime; |
|
2259 |
TBool iInTick; |
|
2260 |
TTickLink iTimer; |
|
2261 |
TDfc iEventDfc; |
|
2262 |
}; |
|
2263 |
||
2264 |
||
2265 |
/******************************************** |
|
2266 |
* Kernel heap |
|
2267 |
********************************************/ |
|
121 | 2268 |
class RHeapK : public RHybridHeap |
0 | 2269 |
{ |
2270 |
public: |
|
2271 |
static RHeapK* FixedHeap(TAny* aBase, TInt aMaxLength); |
|
2272 |
TInt CreateMutex(); |
|
2273 |
void Mutate(TInt aOffset, TInt aMaxLength); |
|
2274 |
public: |
|
2275 |
RHeapK(TInt aInitialSize); |
|
2276 |
virtual TInt Compress(); |
|
2277 |
virtual void Reset(); |
|
2278 |
virtual TInt AllocSize(TInt& aTotalAllocSize) const; |
|
2279 |
virtual TInt Available(TInt& aBiggestBlock) const; |
|
2280 |
public: |
|
2281 |
inline TInt TotalAllocSize() const |
|
2282 |
{ return iTotalAllocSize; } |
|
2283 |
static void CheckThreadState(); |
|
2284 |
static void Fault(TInt aFault); |
|
2285 |
inline TBool CheckForSimulatedAllocFail() |
|
121 | 2286 |
{ return RHybridHeap::CheckForSimulatedAllocFail(); } |
0 | 2287 |
inline DMutex* Mutex() const; /**< @internalComponent */ |
2288 |
public: |
|
2289 |
friend class Monitor; |
|
2290 |
}; |
|
2291 |
||
2292 |
/** |
|
2293 |
@internalComponent |
|
2294 |
*/ |
|
2295 |
inline DMutex* RHeapK::Mutex() const |
|
2296 |
{ return *(DMutex**)&iLock; } |
|
2297 |
||
2298 |
enum TSecureClockStatusFlags |
|
2299 |
{ |
|
2300 |
ESecureClockPresent = 1, // signals a trusted time source has been found |
|
2301 |
ESecureClockOffsetPresent = 2, // signals nonsecure offset was read from HAL |
|
2302 |
ESecureClockOk = ESecureClockPresent | ESecureClockOffsetPresent |
|
2303 |
}; |
|
2304 |
||
2305 |
/** |
|
2306 |
An unparsed descriptor header. |
|
2307 |
||
2308 |
@see TDesHeader. |
|
2309 |
||
2310 |
@prototype |
|
2311 |
@internalTechnology |
|
2312 |
*/ |
|
2313 |
class TRawDesHeader |
|
2314 |
{ |
|
2315 |
public: |
|
2316 |
const TUint32& operator[](TInt aIndex) const { return iData[aIndex]; } |
|
2317 |
TUint32& operator[](TInt aIndex) { return iData[aIndex]; } |
|
2318 |
private: |
|
2319 |
TUint32 iData[3]; |
|
2320 |
}; |
|
2321 |
||
2322 |
/******************************************** |
|
2323 |
* Functions defined in kernel layer 1 |
|
2324 |
********************************************/ |
|
2325 |
||
2326 |
extern "C" { |
|
2327 |
extern TLinAddr SuperPageAddress; |
|
2328 |
} |
|
2329 |
||
2330 |
class DObjectCon; |
|
2331 |
struct SExtInit1EntryPoint; |
|
2332 |
class K |
|
2333 |
{ |
|
2334 |
public: |
|
2335 |
enum TFault |
|
2336 |
{ |
|
2337 |
EBadPriListPriority=0, |
|
2338 |
EKillWhileCSLocked=1, |
|
2339 |
ESvrStraySignal=2, |
|
2340 |
ESvrBadMessage=3, |
|
2341 |
ESystemThreadPanic=4, |
|
2342 |
EThreadDiedInCS=5, |
|
2343 |
ECodeDependenciesInconsistent=6, |
|
2344 |
EUnTrapWithoutTrap=7, |
|
2345 |
EThrdEventHookDied=8, |
|
2346 |
ECreateEventQueueFailed=9, |
|
2347 |
EInvalidDfcPriority=10, |
|
2348 |
EMessageBadWriteAddress=11, |
|
2349 |
EMessageAlreadyPending=12, |
|
2350 |
EKernelMsgNotFree=13, |
|
2351 |
EKernelMsgNotAccepted=14, |
|
2352 |
EPanicWhileKernelLocked=15, |
|
2353 |
EPoweredChannelNoDfcQ=16, |
|
2354 |
EKernelHeapCorrupted=17, |
|
2355 |
EBadObjectType=18, |
|
2356 |
ESessionDestruct=19, |
|
2357 |
EMessageNotFree=20, |
|
2358 |
ESessionCreateBadServerTAC=21, |
|
2359 |
ESessionDestructMsgCount=22, |
|
2360 |
EServerDestructMsgCount=23, |
|
2361 |
EServerDestructSessionsRemain=24, |
|
2362 |
EServerDestructMessagesRemain=25, |
|
2363 |
EServerCloseLeftoverMsg=26, |
|
2364 |
EInvalidSessionAccessCount=27, |
|
2365 |
EMsgFreeBadPool=28, |
|
2366 |
ESessionDestructMsgQ=29, |
|
2367 |
EKHeapBadCellAddress=30, |
|
2368 |
EKHeapBadAllocatedCellSize=31, |
|
2369 |
EKHeapBadAllocatedCellAddress=32, |
|
2370 |
EKHeapBadFreeCellAddress=33, |
|
2371 |
EKHeapFreeBadNextCell=34, |
|
2372 |
EKHeapFreeBadPrevCell=35, |
|
2373 |
EKHeapReAllocBadNextCell=36, |
|
2374 |
EKHeapAllocSizeNegative=37, |
|
2375 |
EKHeapReAllocSizeNegative=38, |
|
2376 |
EKHeapDebugUnmatchedCallToCheckHeap=39, |
|
2377 |
EKHeapAllocCheckFailed=40, |
|
2378 |
ETickQNotLocked=41, |
|
2379 |
ELogicalChannelMsgUncompleted=42, |
|
2380 |
ESessionDestructStillRef=43, |
|
2381 |
ETHeapMaxLengthNegative=44, |
|
2382 |
ETHeapMutateNotSame=45, |
|
2383 |
EKernLeaveNoTrap=46, |
|
2384 |
EProcResumeNotLoaded=47, |
|
2385 |
EMachineConfigMutexCreateFailed=48, |
|
2386 |
ERamDriveChunkCreateFailed=49, |
|
2387 |
EInitMicrokernelFailed=50, |
|
2388 |
EInit3Failed=51, |
|
2389 |
EStartExtensionsFailed=52, |
|
2390 |
ETBmaFreeNotAllocated=53, |
|
2391 |
ETBmaBlockAllocNotFree=54, |
|
2392 |
ETBmaBlockFreeNotAllocated=55, |
|
2393 |
ETBmaAllocConsecBadLength=56, |
|
2394 |
ERamDriveInitFailed=57, |
|
2395 |
EKernelHeapOperationWithKernelLocked=58, |
|
2396 |
EKernelHeapOperationNotCritical=59, |
|
2397 |
EWaitMsTimerNotIdle=60, |
|
2398 |
EThreadDieWhileExit=61, |
|
2399 |
EThreadSvKillNotDead=62, |
|
2400 |
EDeadThreadRunning=63, |
|
2401 |
EBadTimerType=64, |
|
2402 |
ESynchroniseMsDeltaTooBig=65, |
|
2403 |
EBadThreadPriority=66, |
|
2404 |
EMutexSignalWrongThread=67, |
|
2405 |
EMutexSignalBadState=68, |
|
2406 |
EMutexWaitBadState=69, |
|
2407 |
EMutexWaitBadWaitObj=70, |
|
2408 |
ESemSignalBadState=71, |
|
2409 |
ESemWaitBadState=72, |
|
2410 |
ESemWaitBadWaitObj=73, |
|
2411 |
EInvalidKernHeapCPtr=74, |
|
2412 |
ELibDestructBadMapCount=75, |
|
2413 |
ECodeStillMapped=76, |
|
2414 |
EProcessDataAddressInvalid=77, |
|
2415 |
ECodeSegBadExeCodeSeg=78, |
|
2416 |
ECodeSegAttachProcess=79, |
|
2417 |
EPermanentThreadExit=80, |
|
2418 |
EJitCrashHandlerCreation=81, |
|
2419 |
EMsqQueueLengthInvalid=82, |
|
2420 |
EProcessFromIdNoLock=83, |
|
2421 |
EThreadFromIdNoLock=84, |
|
2422 |
EMutexWaitNotInCs=85, |
|
2423 |
EMutexSignalNotInCs=86, |
|
2424 |
EDebugEventHandlerBadCallBack=87, |
|
2425 |
EMutexOrderingViolation=88, |
|
2426 |
ECondVarWaitBadState1=89, |
|
2427 |
ECondVarWaitBadState2=90, |
|
2428 |
ECondVarWaitBadState3=91, |
|
2429 |
ECondVarUnBlockBadState=92, |
|
2430 |
ESharedIoBufferBadInternalState=93, |
|
2431 |
ENonUserThreadKilled=94, |
|
2432 |
EOutOfIds=95, |
|
2433 |
EBadLogSize=96, |
|
2434 |
EAlreadyCalled=97, |
|
2435 |
EMutexWaitNotDThread=98, |
|
2436 |
EBadKernelHookType=99, |
|
2437 |
EKernelHookAlreadySet=100, |
|
2438 |
EMsgCompleteDiscNotSent=101, |
|
2439 |
ESystemProcessPanic=102, |
|
2440 |
EPermanentProcessExit=103, |
|
2441 |
ECodeSegBadFixupAddress=104, |
|
2442 |
ECodeSegBadFixupTables=105, |
|
2443 |
EAPInitialThreadCreateFailed=106, |
|
2444 |
EInit2APTimeout=107, |
|
2445 |
EChunkCommitBadType = 108, |
|
2446 |
EBadSetRamZoneConfig = 109, /**< SetRamZoneConfig can only be invoked during boot*/ |
|
2447 |
ETooManyExtensions = 110, |
|
2448 |
EExtensionArrayAllocationFailed = 111, |
|
2449 |
EInsertExtensionFailed = 112, |
|
2450 |
EExtensionArrayOverflowed = 113, |
|
2451 |
EThreadWaitListDestroy = 114, |
|
2452 |
EThreadWaitListCheck = 115, |
|
2453 |
EThreadWaitListUp = 116, |
|
2454 |
EThreadWaitListChangePriority = 117, |
|
2455 |
EThreadWaitListRemove = 118, |
|
2456 |
EThreadWaitListRemove2 = 119, |
|
2457 |
EClientRequestDeletedNotClosed=120, |
|
2458 |
EClientRequestSetStatusInWrongState=121, |
|
2459 |
EClientRequestCompleteInWrongState=122, |
|
2460 |
EClientRequestResetInWrongState=123, |
|
2461 |
EClientRequestCallbackInWrongState=124, |
|
2462 |
EClientRequestCloseInWrongState=126, |
|
2463 |
EMessageInUse=127, |
|
2464 |
EVirtualPinObjectBad=128, |
|
2465 |
EIpcClientNotNull=129, |
|
2466 |
EBufferRequestAddInWrongState=130, |
|
2467 |
EBufferRequestEndSetupInWrongState=131, |
|
2468 |
EBufferRequestResetInWrongState=132, |
|
2469 |
EThreadBufReadWithNullPointer=133, |
|
2470 |
EThreadBufWriteWithNullPointer=134, |
|
2471 |
ECodeSegRemoveAbsent=135, |
|
2472 |
EPhysicalPinObjectBad=136, |
|
2473 |
EShBufVirtualNotDefined=137, //< A required virtual method is not present in a shared buffer derived class (internal error) |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
2474 |
ESecureRNGInitializationFailed = 138, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
2475 |
ESecureRNGInternalStateNotSecure = 139, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
2476 |
ESecureRNGOutputsInBadState = 140, |
0 | 2477 |
|
2478 |
ESystemException=0x10000000, |
|
2479 |
ESoftwareWarmReset=0x10000001 |
|
2480 |
}; |
|
2481 |
||
2482 |
static void Fault(TFault aFault); |
|
2483 |
public: |
|
2484 |
static TMachineConfig* MachineConfig; |
|
2485 |
static RAllocator* Allocator; |
|
2486 |
static struct SHeapInfo |
|
2487 |
{ |
|
2488 |
DChunk* iChunk; |
|
2489 |
TUint8* iBase; |
|
2490 |
TUint iMaxSize; |
|
2491 |
} HeapInfo; |
|
2492 |
static struct SMsgInfo |
|
2493 |
{ |
|
2494 |
DChunk* iChunk; |
|
2495 |
TUint8* iBase; |
|
2496 |
TUint iMaxSize; |
|
2497 |
TUint iCurrSize; |
|
2498 |
DMutex* iMsgChunkLock; |
|
2499 |
RMessageK* iNextMessage; |
|
2500 |
TInt iFreeMessageCount; |
|
2501 |
} MsgInfo; |
|
2502 |
static DThread* TheKernelThread; |
|
2503 |
static DProcess* TheKernelProcess; |
|
2504 |
static DThread* TheNullThread; |
|
2505 |
static DThread* SvThread; |
|
2506 |
static TDfcQue* SvMsgQ; |
|
2507 |
static TMessageQue SvBarrierQ; |
|
2508 |
static NFastMutex EventQueueMutex; |
|
2509 |
static TRawEvent *EventHeadPtr; |
|
2510 |
static TRawEvent *EventTailPtr; |
|
2511 |
static TRawEvent *EventBufferStart; |
|
2512 |
static TRawEvent *EventBufferEnd; |
|
2513 |
static TClientDataRequest<TRawEvent>* EventRequest; |
|
2514 |
static DThread *EventThread; |
|
2515 |
static TDfcQue* DfcQ0; |
|
2516 |
static TDfcQue* DfcQ1; |
|
2517 |
static TDfcQue* TimerDfcQ; |
|
2518 |
static TTickQ* TickQ; |
|
2519 |
static TSecondQ* SecondQ; |
|
2520 |
static TInactivityQ* InactivityQ; |
|
2521 |
static TInt HomeTimeOffsetSeconds; |
|
2522 |
static TInt NonSecureOffsetSeconds; |
|
2523 |
static TInt SecureClockStatus; |
|
2524 |
static TInt64 Year2000InSeconds; |
|
2525 |
static DPowerModel* PowerModel; |
|
2526 |
static TBool PowerGood; |
|
2527 |
static TInt MaxMemCopyInOneGo; |
|
2528 |
static TInt MaxFreeRam; |
|
2529 |
public: |
|
2530 |
static DObjectCon* Containers[ENumObjectTypes]; |
|
2531 |
public: |
|
2532 |
static TInt NextId; |
|
2533 |
static TInt DfcQId; |
|
2534 |
static volatile TUint DynamicDfcQId; |
|
2535 |
static SHalEntry2* HalEntryArray; |
|
2536 |
static DMutex* MachineConfigMutex; |
|
2537 |
static TAny* volatile AsyncFreeHead; |
|
2538 |
static DBase* volatile AsyncDeleteHead; |
|
2539 |
static TDfc AsyncFreeDfc; |
|
2540 |
static TInt MemoryLowThreshold; |
|
2541 |
static TInt MemoryGoodThreshold; |
|
2542 |
static TUint AsyncChanges; |
|
2543 |
static TDfc AsyncChangeNotifierDfc; |
|
2544 |
public: |
|
2545 |
static TBool Initialising; |
|
2546 |
static TBool ColdStart; |
|
2547 |
static TInt ExtensionCount; |
|
2548 |
static RArray<SExtInit1EntryPoint>* ExtensionArray; |
|
2549 |
static DProcess* TheFileServerProcess; |
|
2550 |
static DProcess* TheWindowServerProcess; |
|
2551 |
static TInt PINestLevel; |
|
2552 |
static TInt SupervisorThreadStackSize; |
|
2553 |
static TUint32 MemModelAttributes; |
|
2554 |
static TKernelHookFn KernelHooks[ENumKernelHooks]; |
|
2555 |
static TMiscNotifierMgr TheMiscNotifierMgr; |
|
2556 |
static TAny* VariantData[31]; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
2557 |
static TUint32 EntropyBufferStatus[KMaxCpus]; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
2558 |
static TUint32* EntropyBuffer[KMaxCpus]; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
2559 |
static TUint32 TempEntropyBuffer[KEntropyBufferSizeWords]; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
2560 |
static TDfc EntropyBufferDfc; |
0 | 2561 |
public: |
2562 |
static TInt InitialiseMicrokernel(); |
|
2563 |
#ifdef __SMP__ |
|
2564 |
static void InitAP(TInt aCpu, volatile SAPBootInfo* aInfo, TInt aTimeout); |
|
2565 |
#endif |
|
2566 |
static TInt Init3(); |
|
2567 |
static void InitNvRam(); |
|
2568 |
static void InitLocaleData(); |
|
2569 |
static void SetDefaultLocaleData1(); |
|
2570 |
static void SetDefaultLocaleData2(); |
|
2571 |
static void InitHalEntryArray(); |
|
2572 |
static TInt CreateObjectContainers(); |
|
2573 |
static DObjectCon* ContainerFromFindHandle(const TFindHandle& aFindHandle); |
|
2574 |
static void LockContainer(TInt aObjType); |
|
2575 |
static void UnlockContainer(TInt aObjType); |
|
2576 |
static TInt AddObject(DObject* aObj, TInt aObjType); |
|
2577 |
static TInt StartTickQueue(); |
|
2578 |
static void PanicKernExec(TInt aReason); |
|
2579 |
static void PanicCurrentThread(TInt aReason); |
|
2580 |
static void UnmarkAllLibraries(); |
|
2581 |
static void CreateEventQueue(TInt aSize); |
|
2582 |
static void TryDeliverEvent(); |
|
2583 |
static DObject* ObjectFromHandle(TInt aHandle); |
|
2584 |
static DObject* ObjectFromHandle(TInt aHandle, TInt aObjType); |
|
2585 |
static DObject* ObjectFromHandle(TInt aHandle, TInt aObjType, TUint& aAttr); |
|
2586 |
static TInt OpenObjectFromHandle(TInt aHandle, DObject*& aObject); |
|
2587 |
static TInt MakeHandle(TOwnerType aType, DObject* aObject); |
|
2588 |
static TInt MakeHandle(TOwnerType aType, DObject* aObject, TUint aAttr); |
|
2589 |
static TInt MakeHandleAndOpen(TOwnerType aType, DObject* aObject, TInt& aHandle); |
|
2590 |
static TInt MakeHandleAndOpen(TOwnerType aType, DObject* aObject, TInt& aHandle, TUint aAttr); |
|
2591 |
static TInt HandleClose(TInt aHandle); |
|
2592 |
static void ObjDelete(DObject* aObj); |
|
2593 |
static TInt SecondsFrom2000(const TTimeK& aTime, TInt& aSeconds); |
|
2594 |
static TInt SetSystemTime(TInt aSecondsFrom2000, TInt aUTCOffset, TUint& aChanges, TUint aMode); |
|
2595 |
static TInt SetSystemTimeAndOffset(const TTimeK& aTime, TInt aOffset, TUint aTimeSetMode, TUint& aChanges, TUint aMode); |
|
2596 |
static void StartKernelServer(); |
|
2597 |
static TInt MutexCreate(DMutex*& aMutex, const TDesC& aName, DObject* aOwner, TBool aVisible, TUint aOrder); |
|
2598 |
static void Randomize(); |
|
2599 |
static void DoAsyncFree(TAny*); |
|
2600 |
static void DoAsyncNotify(TAny*); |
|
2601 |
static TUint CheckFreeMemoryLevel(TInt aInitial, TInt aFinal, TBool aFailed); |
|
2602 |
static TBool CheckForSimulatedAllocFail(); |
|
2603 |
static void DoSvBarrier(TAny*); |
|
2604 |
||
2605 |
// |
|
2606 |
static void CheckKernelUnlocked(); |
|
2607 |
static TInt KernelHal(TInt aFunction, TAny* a1, TAny* a2); |
|
2608 |
static void SetMachineConfiguration(const TDesC8& aConfig); |
|
2609 |
||
2610 |
static DThread* ThreadEnterCS(); |
|
2611 |
static DThread* ThreadLeaveCS(); |
|
2612 |
static DObject* ThreadEnterCS(TInt aHandle, TInt aObjType); |
|
2613 |
static void CheckFileServerAccess(); |
|
2614 |
||
2615 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
2616 |
inline static void ProcessIsolationFailure(const char* aContextText); |
|
2617 |
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
2618 |
// Only available to NULL arguments |
|
2619 |
inline static void ProcessIsolationFailure(OnlyCreateWithNull aContextText); |
|
2620 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
2621 |
||
2622 |
static void LockedPlatformSecurityPanic(); |
|
2623 |
static void UnlockedPlatformSecurityPanic(); |
|
2624 |
static TBool IsInKernelHeap(const TAny* aPtr, TInt aSize); |
|
2625 |
static TUint32 CompressKHeapPtr(const TAny* aPtr); |
|
2626 |
static const TAny* RestoreKHeapPtr(TUint32 aCPtr); |
|
2627 |
static TBool CheckUids(const TUidType& aUids, const TUidType& aRequestedUids); |
|
2628 |
static TUint NewId(); |
|
2629 |
inline static TTraceHandler TraceHandler(); |
|
2630 |
inline static TNanoWaitHandler NanoWaitHandler(); |
|
2631 |
static TInt FloatingPointTypes(TUint32& aTypes); |
|
2632 |
static TInt FloatingPointSystemId(TUint32& aSysId); |
|
2633 |
inline static TInitialTimeHandler InitialTimeHandler(); |
|
2634 |
||
2635 |
static void TextTrace(const TDesC8& aText, TTraceSource aTraceSource, TBool aNewLine=ETrue); |
|
2636 |
static TUint TextTraceMode; |
|
2637 |
||
2638 |
static void CheckThreadNotRealtime(const char* aTraceMessage=NULL); |
|
2639 |
static TBool IllegalFunctionForRealtimeThread(DThread* aThread,const char* aTraceMessage=NULL); |
|
2640 |
static TAny* USafeRead(const TAny* aSrc, TAny* aDest, TInt aSize); |
|
2641 |
static TAny* USafeWrite(TAny* aDest, const TAny* aSrc, TInt aSize); |
|
2642 |
static TInt ParseDesHeader(const TAny* aDesPtr, const TRawDesHeader& aIn, TDesHeader& aOut); |
|
2643 |
static TInt USafeReadAndParseDesHeader(TAny* aDesPtr, TDesHeader& aOut); |
|
2644 |
static TUint32 KernelConfigFlags(); |
|
2645 |
||
2646 |
static void DoFault(const TAny* a0, TInt a1); |
|
2647 |
||
2648 |
static TInt ShPoolCreate(DShPool*& aPool, TShPoolCreateInfo& aInfo); |
|
2649 |
||
2650 |
private: |
|
2651 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
2652 |
static void DoProcessIsolationFailure(const char* aContextText); |
|
2653 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
2654 |
static void DoProcessIsolationFailure(); |
|
2655 |
static void DoNanoWait(TUint32 aInterval); |
|
2656 |
}; |
|
2657 |
||
2658 |
#ifndef __REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
2659 |
inline void K::ProcessIsolationFailure(const char* aContextText) |
|
2660 |
{ |
|
2661 |
DoProcessIsolationFailure(aContextText); |
|
2662 |
} |
|
2663 |
#else //__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
2664 |
// Only available to NULL arguments |
|
2665 |
inline void K::ProcessIsolationFailure(OnlyCreateWithNull /*aContextText*/) |
|
2666 |
{ |
|
2667 |
DoProcessIsolationFailure(); |
|
2668 |
} |
|
2669 |
#endif // !__REMOVE_PLATSEC_DIAGNOSTIC_STRINGS__ |
|
2670 |
||
2671 |
inline TTraceHandler K::TraceHandler() |
|
2672 |
{ |
|
2673 |
return (TTraceHandler)KernelHooks[EHookTrace]; |
|
2674 |
} |
|
2675 |
||
2676 |
inline TNanoWaitHandler K::NanoWaitHandler() |
|
2677 |
{ |
|
2678 |
return (TNanoWaitHandler)KernelHooks[EHookNanoWait]; |
|
2679 |
} |
|
2680 |
||
2681 |
inline TInitialTimeHandler K::InitialTimeHandler() |
|
2682 |
{ |
|
2683 |
return (TInitialTimeHandler)KernelHooks[EHookInitialTime]; |
|
2684 |
} |
|
2685 |
||
2686 |
#ifdef __DEBUGGER_SUPPORT__ |
|
2687 |
#define __DEBUG_EVENT(aEvent, a1) DKernelEventHandler::Dispatch((aEvent),(a1),NULL) |
|
2688 |
#define __DEBUG_EVENT2(aEvent, a1, a2) DKernelEventHandler::Dispatch((aEvent),(a1),(a2)) |
|
2689 |
#define __COND_DEBUG_EVENT(aCond, aEvent, a1) {if (aCond) DKernelEventHandler::Dispatch((aEvent),(a1),NULL);} |
|
2690 |
||
2691 |
#ifdef __EPOC32__ |
|
2692 |
//Setting breakpoints is only available on target and if kernel is built with __DEBUGGER_SUPPORT__ option |
|
2693 |
#define __REMOVE_CODESEG_FROM_CODEMODIFIER(segment, process) CodeModifier::CodeSegRemoved((segment),(process)) |
|
2694 |
#else |
|
2695 |
#define __REMOVE_CODESEG_FROM_CODEMODIFIER(segment, process) |
|
2696 |
#endif |
|
2697 |
||
2698 |
#else |
|
2699 |
#define __DEBUG_EVENT(aEvent, a1) |
|
2700 |
#define __DEBUG_EVENT2(aEvent, a1, a2) |
|
2701 |
#define __COND_DEBUG_EVENT(aCond, aEvent, a1) |
|
2702 |
#define __REMOVE_CODESEG_FROM_CODEMODIFIER(segment, process) |
|
2703 |
#endif |
|
2704 |
||
2705 |
/******************************************** |
|
2706 |
* Functions defined in layer 1M or below of |
|
2707 |
* the kernel and available to layer 1. |
|
2708 |
********************************************/ |
|
2709 |
class P |
|
2710 |
{ |
|
2711 |
public: |
|
2712 |
static TInt InitSystemTime(); |
|
2713 |
static TInt DefaultInitialTime(); |
|
2714 |
static void CreateVariant(); |
|
2715 |
static void StartExtensions(); |
|
2716 |
static void KernelInfo(TProcessCreateInfo& aInfo, TAny*& aStack, TAny*& aHeap); |
|
2717 |
static void NormalizeExecutableFileName(TDes& aFileName); |
|
2718 |
static void SetSuperPageSignature(); |
|
2719 |
static TBool CheckSuperPageSignature(); |
|
2720 |
// |
|
2721 |
static DProcess* NewProcess(); |
|
2722 |
}; |
|
2723 |
||
2724 |
||
2725 |
struct SCacheInfo; |
|
2726 |
||
2727 |
/* |
|
2728 |
Symbian OS currently supports 5 memory models one for the WIN32 platform (the emulator model) |
|
2729 |
and three for the EPOC platform (moving, multiple, direct and flexible). |
|
2730 |
||
2731 |
Model layer is the third layer in EKA2 software layer which consist of 6 layers, |
|
2732 |
There are two static interfaces to the memory model, the first to be in Class Epoc and the second in Class M. |
|
2733 |
||
2734 |
||
2735 |
Class M consists of functions provided by the memory model to the independent layer which is |
|
2736 |
the first layer in EKA2 software layer, M denotes the API exposed by the model layer |
|
2737 |
*/ |
|
2738 |
||
2739 |
||
2740 |
struct SCacheInfo; |
|
2741 |
struct SPageInfo; |
|
2742 |
struct SZone; |
|
2743 |
class M |
|
2744 |
{ |
|
2745 |
public: |
|
176 | 2746 |
/** |
2747 |
Flags to control the moving or discarding of a page via the methods M::DiscardPage(), |
|
2748 |
M::MovePage()and M::MoveAndAllocPage(). |
|
2749 |
*/ |
|
2750 |
enum TMoveDiscardFlags |
|
2751 |
{ |
|
2752 |
/** Set this flag so dirty discardable page are moved rather than |
|
2753 |
written to swap. |
|
2754 |
*/ |
|
2755 |
EMoveDisMoveDirty = 0x1, |
|
2756 |
/** Set this so the attempt to allocate the location to move the page to |
|
2757 |
will fail if the blocked RAM zone is reached. |
|
2758 |
*/ |
|
2759 |
EMoveDisBlockRest = 0x2, |
|
2760 |
}; |
|
2761 |
||
0 | 2762 |
static void Init1(); |
2763 |
static void Init2(); |
|
2764 |
#ifdef __SMP__ |
|
2765 |
static void GetAPBootInfo(TInt aCpu, volatile SAPBootInfo* aInfo); |
|
2766 |
static void Init2AP(); |
|
2767 |
#endif |
|
2768 |
static void Init3(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
39
diff
changeset
|
2769 |
static void Init4(); |
0 | 2770 |
static TInt InitSvHeapChunk(DChunk* aChunk, TInt aSize); |
2771 |
static TInt InitSvStackChunk(); |
|
2772 |
static TBool IsRomAddress(const TAny* aPtr); |
|
2773 |
static TInt PageSizeInBytes(); |
|
2774 |
static TInt PageShift(); |
|
2775 |
static void SetupCacheFlushPtr(TInt aCache, SCacheInfo& c); |
|
2776 |
static void FsRegisterThread(); |
|
2777 |
static DCodeSeg* NewCodeSeg(TCodeSegCreateInfo& aInfo); |
|
2778 |
static void DemandPagingInit(); |
|
2779 |
static TInt DemandPagingFault(TAny* aExceptionInfo); |
|
2780 |
static TBool CheckPagingSafe(TBool aDataPaging, TLinAddr aStartAddr=0, TUint aLength=KMaxTUint); |
|
2781 |
static TInt LockRegion(TLinAddr aStart,TInt aSize); |
|
2782 |
static TInt UnlockRegion(TLinAddr aStart,TInt aSize); |
|
2783 |
static void BTracePrime(TUint aCategory); |
|
2784 |
static void LockUserMemory(); |
|
2785 |
static void UnlockUserMemory(); |
|
2786 |
static TInt CreateVirtualPinObject(TVirtualPinObject*& aPinObject); |
|
2787 |
static TInt PinVirtualMemory(TVirtualPinObject* aPinObject, TLinAddr aStart, TUint aSize, DThread* DThread); |
|
2788 |
static TInt CreateAndPinVirtualMemory(TVirtualPinObject*& aPinObject, TLinAddr aStart, TUint aSize); |
|
2789 |
static void UnpinVirtualMemory(TVirtualPinObject* aPinObject); |
|
2790 |
static void DestroyVirtualPinObject(TVirtualPinObject*& aPinObject); |
|
2791 |
||
2792 |
static TInt CreatePhysicalPinObject(TPhysicalPinObject*& aPinObject); |
|
2793 |
static TInt PinPhysicalMemory(TPhysicalPinObject* aPinObject, TLinAddr aStart, TUint aSize, TBool aReadOnly, TPhysAddr& aAddress, TPhysAddr* aPages, TUint32& aMapAttr, TUint& aColour, DThread* aThread); |
|
2794 |
static void UnpinPhysicalMemory(TPhysicalPinObject* aPinObject); |
|
2795 |
static void DestroyPhysicalPinObject(TPhysicalPinObject*& aPinObject); |
|
2796 |
||
39
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
2797 |
static TInt CreateKernelMapObject(TKernelMapObject*& aMapObject, TUint aMaxReserveSize); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
2798 |
static TInt MapAndPinMemory(TKernelMapObject* aMapObject, DThread* aThread, TLinAddr aStart, TUint aSize, TUint aMapAttributes, TLinAddr& aKernelAddr, TPhysAddr* aPages); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
2799 |
static void UnmapAndUnpinMemory(TKernelMapObject* aMapObject); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
2800 |
static void DestroyKernelMapObject(TKernelMapObject*& aMapObject); |
5d2844f35677
Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
2801 |
|
0 | 2802 |
// RAM allocator and defrag interfaces. |
2803 |
static void RamAllocLock(); |
|
2804 |
static void RamAllocUnlock(); |
|
2805 |
static void RamAllocIsLocked(); |
|
2806 |
static TUint NumberOfFreeDpPages(); |
|
2807 |
static TUint NumberOfDirtyDpPages(); |
|
176 | 2808 |
static TInt MovePage(TPhysAddr aOld, TPhysAddr& aNew, TUint aBlockZoneId, TUint aMoveDisFlags); |
132 | 2809 |
static TInt MoveAndAllocPage(TPhysAddr aAddr, TZonePageType aPageType); |
176 | 2810 |
static TInt DiscardPage(TPhysAddr aAddr, TUint aBlockZoneId, TUint aMoveDisFlags); |
2811 |
static TBool GetFreePages(TUint aNumPages); |
|
0 | 2812 |
static void RamZoneClaimed(SZone* aZone); |
2813 |
static TInt RamDefragFault(TAny* aExceptionInfo); |
|
2814 |
}; |
|
2815 |
||
2816 |
#ifdef __USER_MEMORY_GUARDS_ENABLED__ |
|
2817 |
#define LOCK_USER_MEMORY() M::LockUserMemory() |
|
2818 |
#define UNLOCK_USER_MEMORY() M::UnlockUserMemory() |
|
2819 |
#define COND_LOCK_USER_MEMORY(c) ((void)((c)&&(M::LockUserMemory(),0))) |
|
2820 |
#define COND_UNLOCK_USER_MEMORY(c) ((void)((c)&&(M::UnlockUserMemory(),0))) |
|
2821 |
#else |
|
2822 |
#define LOCK_USER_MEMORY() |
|
2823 |
#define UNLOCK_USER_MEMORY() |
|
2824 |
#define COND_LOCK_USER_MEMORY(c) |
|
2825 |
#define COND_UNLOCK_USER_MEMORY(c) |
|
2826 |
#endif |
|
2827 |
||
2828 |
/******************************************** |
|
2829 |
* Functions defined in layer 3 or below and |
|
2830 |
* available to layer 2 |
|
2831 |
********************************************/ |
|
2832 |
class DPlatChunkHw; |
|
2833 |
class A |
|
2834 |
{ |
|
2835 |
public: |
|
2836 |
static void Init1(); |
|
2837 |
static void Init2(); |
|
2838 |
#ifdef __SMP__ |
|
2839 |
static void InitAPs(); |
|
2840 |
static void Init2AP(); |
|
2841 |
#endif |
|
2842 |
static void Init3(); |
|
2843 |
static void DebugPrint(const TText* aPtr, TInt aLen, TBool aNewLine=ETrue); |
|
2844 |
static TInt CreateVariant(const TAny* aFile, TInt aMode); |
|
2845 |
static DPlatChunkHw* NewHwChunk(); |
|
2846 |
static TPtr8 MachineConfiguration(); |
|
2847 |
static void StartCrashDebugger(const TAny* a0, TInt a1); |
|
2848 |
static TInt CallSupervisorFunction(TSupervisorFunction aFunction, TAny* aParameter); |
|
2849 |
static TInt VariantHal(TInt aFunction, TAny* a1, TAny* a2); |
|
2850 |
static TInt SystemTimeInSecondsFrom2000(TInt& aTime); |
|
2851 |
static TInt SetSystemTimeInSecondsFrom2000(TInt aTime); |
|
2852 |
}; |
|
2853 |
||
2854 |
class Exc |
|
2855 |
{ |
|
2856 |
public: |
|
2857 |
static void Dispatch(TAny* aPtr, NThread*); |
|
2858 |
IMPORT_C static void Fault(TAny* aPtr); |
|
2859 |
static TBool IsMagic(TLinAddr aAddress); |
|
2860 |
#ifdef __ATOMIC64_USE_SLOW_EXEC__ |
|
2861 |
static TBool IsMagicAtomic64(TLinAddr aAddress); |
|
2862 |
#endif //__ATOMIC64_USE_SLOW_EXEC__ |
|
2863 |
}; |
|
2864 |
||
2865 |
/******************************************** |
|
2866 |
* Super page definition |
|
2867 |
********************************************/ |
|
2868 |
class DDebuggerInfo; |
|
2869 |
class TSuperPage : public SSuperPageBase |
|
2870 |
{ |
|
2871 |
public: |
|
2872 |
TInt iDebugMask[KNumTraceMaskWords]; // kernel trace mask |
|
2873 |
TInt iKernelExcId; |
|
2874 |
TExcInfo iKernelExcInfo; |
|
2875 |
TUint32 iSignature[2]; |
|
2876 |
TMachineStartupType iStartupReason; |
|
2877 |
DDebuggerInfo* iDebuggerInfo; |
|
2878 |
TUint32 iDisabledCapabilities[(((TInt)ECapability_HardLimit + 7)>>3) / sizeof(TUint32)]; |
|
2879 |
TUint32 iInitialBTraceFilter[8]; |
|
2880 |
TInt iInitialBTraceBuffer; |
|
2881 |
TInt iInitialBTraceMode; |
|
2882 |
||
2883 |
private: |
|
2884 |
TUint32 iKernelConfigFlags; |
|
2885 |
||
2886 |
public: |
|
2887 |
/* |
|
2888 |
* Unless __PLATSEC_UNLOCKED__ is defined, __PLATSEC_FORCED_FLAGS__ is set to a |
|
2889 |
* bitmask of platsec flags which must always be considered to be set, even if |
|
2890 |
* they are not really set in iKernelConfigFlags. Therefore, use this function |
|
2891 |
* to access iKernelConfigFlags. |
|
2892 |
* |
|
2893 |
* __PLATSEC_UNLOCKED__, if set, is set by the base port. |
|
2894 |
* |
|
2895 |
* __PLATSEC_FORCED_FLAGS__ is defined in u32std.h near the TKernelConfigFlags enumeration. |
|
2896 |
*/ |
|
2897 |
inline TUint32 KernelConfigFlags() |
|
2898 |
{ |
|
2899 |
#ifdef __PLATSEC_UNLOCKED__ |
|
2900 |
return (iKernelConfigFlags | __PLATSEC_FORCED_FLAGS__) & ~EKernelConfigPlatSecLocked; |
|
2901 |
#else |
|
2902 |
return (iKernelConfigFlags | __PLATSEC_FORCED_FLAGS__ | EKernelConfigPlatSecLocked); |
|
2903 |
#endif |
|
2904 |
} |
|
2905 |
||
2906 |
inline void SetKernelConfigFlags(TUint32 aKernelConfigFlags) |
|
2907 |
{ |
|
2908 |
iKernelConfigFlags = aKernelConfigFlags; |
|
2909 |
} |
|
2910 |
}; |
|
2911 |
||
2912 |
inline TSuperPage& TheSuperPage() {return *(TSuperPage*)SuperPageAddress;} |
|
2913 |
inline TMachineConfig& TheMachineConfig() {return *(TMachineConfig*)K::MachineConfig; } |
|
2914 |
||
2915 |
#define TEST_DEBUG_MASK_BIT(n) ( TheSuperPage().iDebugMask[(n)>>5] & (1<<((n)&31)) ) |
|
2916 |
||
2917 |
/******************************************** |
|
2918 |
* Miscellaneous stuff |
|
2919 |
********************************************/ |
|
2920 |
||
2921 |
inline void TExcTrap::UnTrap() |
|
2922 |
{iThread->iExcTrap=NULL;} |
|
2923 |
inline void TIpcExcTrap::UnTrap() |
|
2924 |
{iThread->iExcTrap=NULL;iThread->iIpcClient=NULL;} |
|
2925 |
inline void TPagingExcTrap::UnTrap() |
|
2926 |
{iThread->iPagingExcTrap=NULL;} |
|
2927 |
||
2928 |
GLREF_D const TUint32 EpocFastExecTable[]; |
|
2929 |
GLREF_D const TUint32 EpocSlowExecTable[]; |
|
2930 |
||
2931 |
inline SMiscNotifierQ* DObject::NotifierQ() const |
|
2932 |
{ |
|
2933 |
TUint32 cptr = ((TUint32(iObjectId)<<14)>>6) | iNotQLow; |
|
2934 |
return cptr ? (SMiscNotifierQ*)K::RestoreKHeapPtr(cptr) : (SMiscNotifierQ*)0; |
|
2935 |
} |
|
2936 |
||
2937 |
inline void DObject::SetNotifierQ(SMiscNotifierQ* aQ) |
|
2938 |
{ |
|
2939 |
TUint32 cptr = aQ ? K::CompressKHeapPtr(aQ) : 0; |
|
2940 |
iNotQLow = (TUint8)cptr; |
|
2941 |
volatile TUint32& x = (volatile TUint32&)iObjectId; |
|
2942 |
x = ((x>>18)<<18) | (cptr>>8); |
|
2943 |
} |
|
2944 |
||
2945 |
inline TBool DObject::HasNotifierQ() const |
|
2946 |
{ |
|
2947 |
return (TUint32(iObjectId)<<14) | iNotQLow; |
|
2948 |
} |
|
2949 |
||
2950 |
#ifdef _DEBUG |
|
2951 |
||
2952 |
/** |
|
2953 |
@publishedPartner |
|
2954 |
@released |
|
2955 |
*/ |
|
2956 |
#define __ASSERT_CRITICAL { \ |
|
2957 |
DThread& t=Kern::CurrentThread(); \ |
|
2958 |
__NK_ASSERT_DEBUG(t.iThreadType!=EThreadUser || t.iNThread.iCsCount>0); \ |
|
2959 |
} |
|
2960 |
||
2961 |
/** |
|
2962 |
@publishedPartner |
|
2963 |
@released |
|
2964 |
*/ |
|
2965 |
#define __ASSERT_MUTEX(m) { \ |
|
2966 |
DThread& t=Kern::CurrentThread(); \ |
|
2967 |
__NK_ASSERT_DEBUG((m)->iCleanup.iThread==&t); \ |
|
2968 |
} |
|
2969 |
#else |
|
2970 |
/** |
|
2971 |
@publishedPartner |
|
2972 |
@released |
|
2973 |
*/ |
|
2974 |
#define __ASSERT_CRITICAL |
|
2975 |
||
2976 |
/** |
|
2977 |
@publishedPartner |
|
2978 |
@released |
|
2979 |
*/ |
|
2980 |
#define __ASSERT_MUTEX(m) |
|
2981 |
#endif |
|
2982 |
||
2983 |
||
2984 |
#define LOGICAL_XOR(a,b) (((a)==0)^((b)==0)) |
|
2985 |
||
2986 |
||
2987 |
#if defined(__GCC32__) |
|
2988 |
#define __RETURN_ADDRESS() __builtin_return_address(0) |
|
2989 |
#elif defined (__ARMCC__) |
|
2990 |
#define __RETURN_ADDRESS() ((TAny*)__return_address()) |
|
2991 |
#else |
|
2992 |
#define __RETURN_ADDRESS() 0 // not supported |
|
2993 |
#endif |
|
2994 |
||
2995 |
#ifdef _DEBUG |
|
2996 |
#if defined(__STANDALONE_NANOKERNEL__) || (!defined (__KERNEL_APIS_CONTEXT_CHECKS_WARNING__)&&!defined (__KERNEL_APIS_CONTEXT_CHECKS_FAULT__)) |
|
2997 |
#define __ASSERT_WITH_MESSAGE_MUTEX(m,message,function ) |
|
2998 |
||
2999 |
#else |
|
3000 |
/** |
|
3001 |
@internalComponent |
|
3002 |
*/ |
|
3003 |
#define __ASSERT_WITH_MESSAGE_MUTEX(m,message,function ) \ |
|
3004 |
{ \ |
|
3005 |
DThread& t=Kern::CurrentThread(); \ |
|
3006 |
__ASSERT_WITH_MESSAGE_DEBUG((NKern::Crashed() || ((m)->iCleanup.iThread==&t)),message,function); \ |
|
3007 |
} |
|
3008 |
||
3009 |
#endif//(!defined (__KERNEL_APIS_CONTEXT_CHECKS_WARNING__)&&!defined (__KERNEL_APIS_CONTEXT_CHECKS_FAULT__)) |
|
3010 |
||
3011 |
#else//if !DEBUG |
|
3012 |
||
3013 |
#define __ASSERT_WITH_MESSAGE_MUTEX(m,message,function ) |
|
3014 |
||
3015 |
#endif//_DEBUG |
|
3016 |
||
3017 |
// Implementation constants for TClientRequest |
|
3018 |
const T_UintPtr KClientRequestFlagClosing = 1 << 0; |
|
3019 |
const T_UintPtr KClientRequestFlagInUse = 1 << 1; |
|
3020 |
const T_UintPtr KClientRequestFlagMask = KClientRequestFlagClosing | KClientRequestFlagInUse; |
|
3021 |
const T_UintPtr KClientRequestNullStatus = 0x00000004; // must be non-zero but never a valid TRequestStatus pointer |
|
3022 |
||
3023 |
#endif |