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