os/kernelhwsrv/kernel/eka/include/nkern/nk_priv.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32\include\nkern\nk_priv.h
sl@0
    15
// 
sl@0
    16
// WARNING: This file contains some APIs which are internal and are subject
sl@0
    17
//          to change without notice. Such APIs should therefore not be used
sl@0
    18
//          outside the Kernel and Hardware Services package.
sl@0
    19
//
sl@0
    20
sl@0
    21
#ifndef __NK_PRIV_H__
sl@0
    22
#define __NK_PRIV_H__
sl@0
    23
#include <cpudefs.h>
sl@0
    24
#include <nkern.h>
sl@0
    25
sl@0
    26
/********************************************
sl@0
    27
 * DFCs
sl@0
    28
 ********************************************/
sl@0
    29
sl@0
    30
/**
sl@0
    31
@internalComponent
sl@0
    32
*/
sl@0
    33
inline TBool TDfc::TestAndSetQueued()
sl@0
    34
	{ return __e32_atomic_swp_ord8(&iSpare3, 1); }
sl@0
    35
sl@0
    36
/********************************************
sl@0
    37
 * Thread
sl@0
    38
 ********************************************/
sl@0
    39
sl@0
    40
class TUserModeCallback;
sl@0
    41
sl@0
    42
/**
sl@0
    43
@publishedPartner
sl@0
    44
@released
sl@0
    45
sl@0
    46
Base class for a nanokernel thread.
sl@0
    47
*/
sl@0
    48
class NThreadBase : public TPriListLink
sl@0
    49
	{
sl@0
    50
public:
sl@0
    51
    /**
sl@0
    52
    Defines the possible states of a nanokernel thread.
sl@0
    53
    */
sl@0
    54
	enum NThreadState
sl@0
    55
		{
sl@0
    56
		/**
sl@0
    57
		The thread is eligible for execution.
sl@0
    58
		
sl@0
    59
		Threads in this state are linked into the ready list.
sl@0
    60
		The highest priority READY thread is the one that will run, unless it
sl@0
    61
		is blocked on a fast mutex.
sl@0
    62
		*/
sl@0
    63
		EReady,
sl@0
    64
		
sl@0
    65
		/**
sl@0
    66
		The thread is explicitly suspended (rather than blocking on
sl@0
    67
		a wait object).
sl@0
    68
		*/
sl@0
    69
		ESuspended,
sl@0
    70
		
sl@0
    71
		/**
sl@0
    72
		The thread is blocked waiting for a fast semaphore to be signalled.
sl@0
    73
		*/
sl@0
    74
		EWaitFastSemaphore,
sl@0
    75
		
sl@0
    76
		/**
sl@0
    77
		The thread is blocked waiting for a specific time period to elapse.
sl@0
    78
		*/
sl@0
    79
		ESleep,
sl@0
    80
		
sl@0
    81
		/**
sl@0
    82
		The thread is blocked on a wait object implemented in a layer above
sl@0
    83
		the nanokernel.
sl@0
    84
		
sl@0
    85
		In practice, this means that it is blocked on a Symbian OS
sl@0
    86
		semaphore or mutex.
sl@0
    87
		*/
sl@0
    88
		EBlocked,
sl@0
    89
		
sl@0
    90
		/**
sl@0
    91
		The thread has terminated and will not execute again.
sl@0
    92
		*/
sl@0
    93
		EDead,
sl@0
    94
		
sl@0
    95
		/**
sl@0
    96
		The thread is a DFC-handling thread and it is blocked waiting for
sl@0
    97
		the DFC to be queued.
sl@0
    98
		*/
sl@0
    99
		EWaitDfc,
sl@0
   100
		
sl@0
   101
		/**
sl@0
   102
		Not a thread state, but defines the maximum number of states.
sl@0
   103
		*/
sl@0
   104
		ENumNStates
sl@0
   105
		};
sl@0
   106
sl@0
   107
sl@0
   108
sl@0
   109
sl@0
   110
    /**
sl@0
   111
    Defines a set of values that, when passed to a nanokernel state handler,
sl@0
   112
    indicates which operation is being performed on the thread.
sl@0
   113
    
sl@0
   114
    Every thread that can use a new type of wait object, must have a nanokernel
sl@0
   115
    state handler installed to handle operations on that thread while it is
sl@0
   116
    waiting on that wait object.
sl@0
   117
    
sl@0
   118
    A wait handler has the signature:
sl@0
   119
    @code
sl@0
   120
    void StateHandler(NThread* aThread, TInt aOp, TInt aParam);
sl@0
   121
    @endcode
sl@0
   122
    
sl@0
   123
    where aOp is one of these enum values.
sl@0
   124
    
sl@0
   125
    The state handler is always called with preemption disabled.
sl@0
   126
    */
sl@0
   127
	enum NThreadOperation
sl@0
   128
		{
sl@0
   129
		/**
sl@0
   130
		Indicates that the thread is suspended while not in a critical section,
sl@0
   131
		and not holding a fast mutex.
sl@0
   132
		
sl@0
   133
		StateHandler() is called in whichever context
sl@0
   134
		NThreadBase::Suspend() is called from.
sl@0
   135
		
sl@0
   136
		Note that the third parameter passed to StateHandler() contains
sl@0
   137
		the requested suspension count.
sl@0
   138
		*/
sl@0
   139
		ESuspend=0,
sl@0
   140
		
sl@0
   141
		/**
sl@0
   142
		Indicates that the thread is being resumed while suspended, and
sl@0
   143
		the last suspension has been removed.
sl@0
   144
		
sl@0
   145
		StateHandler() is called in whichever context
sl@0
   146
		NThreadBase::Resume() is called from.
sl@0
   147
		*/
sl@0
   148
		EResume=1,
sl@0
   149
		
sl@0
   150
		/**
sl@0
   151
		Indicates that the thread has all suspensions cancelled while
sl@0
   152
		actually suspended.
sl@0
   153
		
sl@0
   154
		Statehandler() is called in whichever context
sl@0
   155
		NThreadBase::ForceResume() is called from.
sl@0
   156
		*/
sl@0
   157
		EForceResume=2,
sl@0
   158
		
sl@0
   159
		/**
sl@0
   160
		Indicates that the thread is being released from its wait.
sl@0
   161
		
sl@0
   162
		Statehandler() is called in whichever context
sl@0
   163
		NThreadBase::Release() is called from.
sl@0
   164
		*/
sl@0
   165
		ERelease=3,
sl@0
   166
		
sl@0
   167
		/**
sl@0
   168
		Indicates that the thread's priority is being changed.
sl@0
   169
		
sl@0
   170
		StateHandler() is called in whichever context
sl@0
   171
		NThreadBase::SetPriority() is called from.
sl@0
   172
		*/
sl@0
   173
		EChangePriority=4,
sl@0
   174
		
sl@0
   175
		/**
sl@0
   176
		Indicates that the thread has called NKern::ThreadLeaveCS() with
sl@0
   177
		an unknown NThreadBase::iCsFunction that is negative, but not equal
sl@0
   178
		to NThreadBase::ECsExitPending.
sl@0
   179
		
sl@0
   180
		Note that NThreadBase::iCsFunction is internal to Symbian OS.
sl@0
   181
		*/
sl@0
   182
		ELeaveCS=5,
sl@0
   183
		
sl@0
   184
		/**
sl@0
   185
		Indicates that the thread's wait timeout has expired, and no timeout
sl@0
   186
		handler has been defined for that thread.
sl@0
   187
	    
sl@0
   188
	    StateHandler() is called in the context of the nanokernel
sl@0
   189
	    timer thread, DfcThread1.
sl@0
   190
	    */
sl@0
   191
		ETimeout=6,
sl@0
   192
		};
sl@0
   193
		
sl@0
   194
	enum NThreadCSFunction
sl@0
   195
		{
sl@0
   196
		ECSExitPending=-1,
sl@0
   197
		ECSExitInProgress=-2
sl@0
   198
		};
sl@0
   199
sl@0
   200
	enum NThreadTimeoutOp
sl@0
   201
		{
sl@0
   202
		ETimeoutPreamble=0,
sl@0
   203
		ETimeoutPostamble=1,
sl@0
   204
		ETimeoutSpurious=2,
sl@0
   205
		};
sl@0
   206
public:
sl@0
   207
	NThreadBase();
sl@0
   208
	TInt Create(SNThreadCreateInfo& anInfo,	TBool aInitial);
sl@0
   209
	IMPORT_C void CheckSuspendThenReady();
sl@0
   210
	IMPORT_C void Ready();
sl@0
   211
	void DoReady();
sl@0
   212
	void DoCsFunction();
sl@0
   213
	IMPORT_C TBool Suspend(TInt aCount);
sl@0
   214
	IMPORT_C TBool Resume();
sl@0
   215
	IMPORT_C TBool ForceResume();
sl@0
   216
	IMPORT_C void Release(TInt aReturnCode);
sl@0
   217
	IMPORT_C void RequestSignal();
sl@0
   218
	IMPORT_C void SetPriority(TInt aPriority);
sl@0
   219
	void SetEntry(NThreadFunction aFunction);
sl@0
   220
	IMPORT_C void Kill();
sl@0
   221
	void Exit();
sl@0
   222
	void ForceExit();
sl@0
   223
	// hooks for platform-specific code
sl@0
   224
	void OnKill(); 
sl@0
   225
	void OnExit();
sl@0
   226
public:
sl@0
   227
	static void TimerExpired(TAny* aPtr);
sl@0
   228
	inline void UnknownState(TInt aOp, TInt aParam)
sl@0
   229
		{ (*iHandlers->iStateHandler)((NThread*)this,aOp,aParam); }
sl@0
   230
sl@0
   231
	/** @internalComponent */
sl@0
   232
	inline TUint8 Attributes()
sl@0
   233
		{ return iSpare2; }
sl@0
   234
sl@0
   235
	/** @internalComponent */
sl@0
   236
	inline TUint8 SetAttributes(TUint8 aNewAtt)
sl@0
   237
		{ return __e32_atomic_swp_ord8(&iSpare2, aNewAtt); }
sl@0
   238
sl@0
   239
	/** @internalComponent */
sl@0
   240
	inline TUint8 ModifyAttributes(TUint8 aClearMask, TUint8 aSetMask)
sl@0
   241
		{ return __e32_atomic_axo_ord8(&iSpare2, (TUint8)~(aClearMask|aSetMask), aSetMask); }
sl@0
   242
sl@0
   243
	/** @internalComponent */
sl@0
   244
	inline void SetAddressSpace(TAny* a)
sl@0
   245
		{ iAddressSpace=a; }
sl@0
   246
sl@0
   247
	inline void SetReturnValue(TInt aValue)
sl@0
   248
		{ iReturnValue=aValue; }
sl@0
   249
	inline void SetExtraContext(TAny* a, TInt aSize)
sl@0
   250
		{ iExtraContext = a; iExtraContextSize = aSize; }
sl@0
   251
sl@0
   252
	/** @internalComponent */
sl@0
   253
	void CallUserModeCallbacks();
sl@0
   254
public:
sl@0
   255
//	TUint8 iNState;														// use iSpare1 for state
sl@0
   256
//	TUint8 i_ThrdAttr;						/**< @internalComponent */	// use iSpare2 for attributes
sl@0
   257
//	TUint8 iUserContextType;											// use iSpare3
sl@0
   258
	NFastMutex* iHeldFastMutex;				/**< @internalComponent */	// fast mutex held by this thread
sl@0
   259
	NFastMutex* iWaitFastMutex;				/**< @internalComponent */	// fast mutex on which this thread is blocked
sl@0
   260
	TAny* iAddressSpace;					/**< @internalComponent */
sl@0
   261
	TInt iTime;															// time remaining
sl@0
   262
	TInt iTimeslice;													// timeslice for this thread
sl@0
   263
	NFastSemaphore iRequestSemaphore;		/**< @internalComponent */
sl@0
   264
	TAny* iWaitObj;														// object on which this thread is waiting
sl@0
   265
	TInt iSuspendCount;						/**< @internalComponent */	// -how many times we have been suspended
sl@0
   266
	TInt iCsCount;							/**< @internalComponent */	// critical section count
sl@0
   267
	TInt iCsFunction;						/**< @internalComponent */	// what to do on leaving CS: +n=suspend n times, 0=nothing, -1=exit
sl@0
   268
	NTimer iTimer;							/**< @internalComponent */
sl@0
   269
	TInt iReturnValue;
sl@0
   270
	TLinAddr iStackBase;					/**< @internalComponent */
sl@0
   271
	TInt iStackSize;						/**< @internalComponent */
sl@0
   272
	const SNThreadHandlers* iHandlers;		/**< @internalComponent */	// additional thread event handlers
sl@0
   273
	const SFastExecTable* iFastExecTable;	/**< @internalComponent */
sl@0
   274
	const SSlowExecEntry* iSlowExecTable;	/**< @internalComponent */	// points to first entry iEntries[0]
sl@0
   275
	TLinAddr iSavedSP;						/**< @internalComponent */
sl@0
   276
	TAny* iExtraContext;					/**< @internalComponent */	// parent FPSCR value (iExtraContextSize == -1), coprocessor context (iExtraContextSize > 0) or NULL
sl@0
   277
	TInt iExtraContextSize;					/**< @internalComponent */	// +ve=dynamically allocated, 0=none, -1=iExtraContext stores parent FPSCR value
sl@0
   278
	TUint iLastStartTime;					/**< @internalComponent */	// last start of execution timestamp
sl@0
   279
	TUint64 iTotalCpuTime;					/**< @internalComponent */	// total time spent running, in hi-res timer ticks
sl@0
   280
	TUint32 iTag;							/**< @internalComponent */	// User defined set of bits which is ANDed with a mask when the thread is scheduled, and indicates if a DFC should be scheduled.
sl@0
   281
	TAny* iVemsData;						/**< @internalComponent */	// This pointer can be used by any VEMS to store any data associated with the thread.  This data must be clean up before the Thread Exit Monitor completes.
sl@0
   282
	TUserModeCallback* volatile iUserModeCallbacks;	/**< @internalComponent */	// Head of singly-linked list of callbacks
sl@0
   283
	TUint32 iSpare7;						/**< @internalComponent */	// spare to allow growth while preserving BC
sl@0
   284
	TUint32 iSpare8;						/**< @internalComponent */	// spare to allow growth while preserving BC
sl@0
   285
	};
sl@0
   286
sl@0
   287
__ASSERT_COMPILE(!(_FOFF(NThreadBase,iTotalCpuTime)&7));
sl@0
   288
sl@0
   289
#ifdef __INCLUDE_NTHREADBASE_DEFINES__
sl@0
   290
#define iNState				iSpare1
sl@0
   291
#define	i_ThrdAttr			iSpare2
sl@0
   292
#define iUserContextType	iSpare3
sl@0
   293
#endif
sl@0
   294
sl@0
   295
#define	i_NThread_BasePri	iPriority
sl@0
   296
sl@0
   297
/********************************************
sl@0
   298
 * Scheduler
sl@0
   299
 ********************************************/
sl@0
   300
sl@0
   301
/**
sl@0
   302
@internalComponent
sl@0
   303
*/
sl@0
   304
class TScheduler : public TPriListBase
sl@0
   305
	{
sl@0
   306
public:
sl@0
   307
	TScheduler();
sl@0
   308
	void Remove(NThreadBase* aThread);
sl@0
   309
	void RotateReadyList(TInt aPriority);
sl@0
   310
	void QueueDfcs();
sl@0
   311
	static void Reschedule();
sl@0
   312
	static void YieldTo(NThreadBase* aThread);
sl@0
   313
	void TimesliceTick();
sl@0
   314
	IMPORT_C static TScheduler* Ptr();
sl@0
   315
	inline void SetProcessHandler(TLinAddr aHandler) {iProcessHandler=aHandler;}
sl@0
   316
private:
sl@0
   317
	SDblQueLink* iExtraQueues[KNumPriorities-1];
sl@0
   318
public:
sl@0
   319
	TUint8 iRescheduleNeededFlag;
sl@0
   320
	TUint8 iDfcPendingFlag;
sl@0
   321
	TInt iKernCSLocked;
sl@0
   322
	SDblQue iDfcs;
sl@0
   323
	TLinAddr iMonitorExceptionHandler;
sl@0
   324
	TLinAddr iProcessHandler;
sl@0
   325
	TLinAddr iRescheduleHook;
sl@0
   326
	TUint8 iInIDFC;
sl@0
   327
	NFastMutex iLock;
sl@0
   328
	NThreadBase* iCurrentThread;
sl@0
   329
	TAny* iAddressSpace;
sl@0
   330
	TAny* iExtras[16];
sl@0
   331
	// For EMI support
sl@0
   332
	NThread* iSigma;	
sl@0
   333
	TDfc* iEmiDfc;
sl@0
   334
	TUint32 iEmiMask;
sl@0
   335
	TUint32 iEmiState;
sl@0
   336
	TUint32 iEmiDfcTrigger;
sl@0
   337
	TBool iLogging;
sl@0
   338
	TAny* iBufferStart;
sl@0
   339
	TAny* iBufferEnd;
sl@0
   340
	TAny* iBufferTail;
sl@0
   341
	TAny* iBufferHead;
sl@0
   342
	// For BTrace suport
sl@0
   343
	TUint8 iCpuUsageFilter;
sl@0
   344
	TUint8 iFastMutexFilter;
sl@0
   345
	BTrace::THandler iBTraceHandler;
sl@0
   346
	// Idle notification
sl@0
   347
	SDblQue iIdleDfcs;
sl@0
   348
	TUint32 iIdleGenerationCount;
sl@0
   349
	// Delayed threads
sl@0
   350
	SDblQue iDelayedQ;
sl@0
   351
	TDfc iDelayDfc;
sl@0
   352
	};
sl@0
   353
sl@0
   354
GLREF_D TScheduler TheScheduler;
sl@0
   355
sl@0
   356
/**
sl@0
   357
@internalComponent
sl@0
   358
*/
sl@0
   359
inline void RescheduleNeeded()
sl@0
   360
	{TheScheduler.iRescheduleNeededFlag=TRUE;}
sl@0
   361
sl@0
   362
#include <nk_plat.h>
sl@0
   363
sl@0
   364
/**
sl@0
   365
@internalComponent
sl@0
   366
*/
sl@0
   367
inline NThread* NCurrentThread()
sl@0
   368
	{ return (NThread*)TheScheduler.iCurrentThread; }
sl@0
   369
sl@0
   370
sl@0
   371
/**
sl@0
   372
@internalComponent
sl@0
   373
*/
sl@0
   374
#define __NK_ASSERT_UNLOCKED	__NK_ASSERT_DEBUG(TheScheduler.iKernCSLocked==0)
sl@0
   375
sl@0
   376
/**
sl@0
   377
@internalComponent
sl@0
   378
*/
sl@0
   379
#define __NK_ASSERT_LOCKED		__NK_ASSERT_DEBUG(TheScheduler.iKernCSLocked!=0)
sl@0
   380
sl@0
   381
#ifdef _DEBUG
sl@0
   382
/**
sl@0
   383
@publishedPartner
sl@0
   384
@released
sl@0
   385
*/
sl@0
   386
#define __ASSERT_NO_FAST_MUTEX	{	\
sl@0
   387
								NThread* nt=NKern::CurrentThread();	\
sl@0
   388
								__NK_ASSERT_DEBUG(!nt->iHeldFastMutex); \
sl@0
   389
								}
sl@0
   390
sl@0
   391
/**
sl@0
   392
@publishedPartner
sl@0
   393
@released
sl@0
   394
*/
sl@0
   395
#define __ASSERT_FAST_MUTEX(m)	{	\
sl@0
   396
								NThread* nt=NKern::CurrentThread();	\
sl@0
   397
								__NK_ASSERT_DEBUG(nt->iHeldFastMutex==(m) && (m)->iHoldingThread==nt); \
sl@0
   398
								}
sl@0
   399
sl@0
   400
/**
sl@0
   401
@publishedPartner
sl@0
   402
@released
sl@0
   403
*/
sl@0
   404
#define __ASSERT_SYSTEM_LOCK	{	\
sl@0
   405
								NThread* nt=NKern::CurrentThread();	\
sl@0
   406
								NFastMutex& m=TScheduler::Ptr()->iLock; \
sl@0
   407
								__NK_ASSERT_DEBUG(nt->iHeldFastMutex==&m && m.iHoldingThread==nt); \
sl@0
   408
								}
sl@0
   409
sl@0
   410
#define __ASSERT_NOT_ISR		__NK_ASSERT_DEBUG(NKern::CurrentContext()!=NKern::EInterrupt)
sl@0
   411
sl@0
   412
#else
sl@0
   413
#define __ASSERT_NO_FAST_MUTEX
sl@0
   414
#define __ASSERT_FAST_MUTEX(m)
sl@0
   415
#define	__ASSERT_SYSTEM_LOCK
sl@0
   416
#define __ASSERT_NOT_ISR
sl@0
   417
#endif
sl@0
   418
sl@0
   419
/********************************************
sl@0
   420
 * System timer queue
sl@0
   421
 ********************************************/
sl@0
   422
sl@0
   423
/**
sl@0
   424
@publishedPartner
sl@0
   425
@released
sl@0
   426
*/
sl@0
   427
class NTimerQ
sl@0
   428
	{
sl@0
   429
	friend class NTimer;
sl@0
   430
public:
sl@0
   431
	typedef void (*TDebugFn)(TAny* aPtr, TInt aPos);	/**< @internalComponent */
sl@0
   432
	enum { ETimerQMask=31, ENumTimerQueues=32 };		/**< @internalComponent */	// these are not easily modifiable
sl@0
   433
sl@0
   434
	/** @internalComponent */
sl@0
   435
	struct STimerQ
sl@0
   436
		{
sl@0
   437
		SDblQue iIntQ;
sl@0
   438
		SDblQue iDfcQ;
sl@0
   439
		};
sl@0
   440
public:
sl@0
   441
	NTimerQ();
sl@0
   442
	static void Init1(TInt aTickPeriod);
sl@0
   443
	static void Init3(TDfcQue* aDfcQ);
sl@0
   444
	IMPORT_C static TAny* TimerAddress();
sl@0
   445
	IMPORT_C void Tick();
sl@0
   446
	IMPORT_C static TInt IdleTime();
sl@0
   447
	IMPORT_C static void Advance(TInt aTicks);
sl@0
   448
private:
sl@0
   449
	static void DfcFn(TAny* aPtr);
sl@0
   450
	void Dfc();
sl@0
   451
	void Add(NTimer* aTimer);
sl@0
   452
	void AddFinal(NTimer* aTimer);
sl@0
   453
public:
sl@0
   454
	STimerQ iTickQ[ENumTimerQueues];	/**< @internalComponent */	// NOTE: the order of member data is important
sl@0
   455
	TUint32 iPresent;					/**< @internalComponent */	// The assembler code relies on it
sl@0
   456
	TUint32 iMsCount;					/**< @internalComponent */
sl@0
   457
	SDblQue iHoldingQ;					/**< @internalComponent */
sl@0
   458
	SDblQue iOrderedQ;					/**< @internalComponent */
sl@0
   459
	SDblQue iCompletedQ;				/**< @internalComponent */
sl@0
   460
	TDfc iDfc;							/**< @internalComponent */
sl@0
   461
	TUint8 iTransferringCancelled;		/**< @internalComponent */
sl@0
   462
	TUint8 iCriticalCancelled;			/**< @internalComponent */
sl@0
   463
	TUint8 iPad1;						/**< @internalComponent */
sl@0
   464
	TUint8 iPad2;						/**< @internalComponent */
sl@0
   465
	TDebugFn iDebugFn;					/**< @internalComponent */
sl@0
   466
	TAny* iDebugPtr;					/**< @internalComponent */
sl@0
   467
	TInt iTickPeriod;					/**< @internalComponent */	// in microseconds
sl@0
   468
	/**
sl@0
   469
	This member is intended for use by ASSP/variant interrupt code as a convenient
sl@0
   470
	location to store rounding error information where hardware interrupts are not
sl@0
   471
	exactly one millisecond. The Symbian kernel does not make any use of this member.
sl@0
   472
	@publishedPartner
sl@0
   473
	@released
sl@0
   474
	*/
sl@0
   475
	TInt iRounding;
sl@0
   476
	};
sl@0
   477
sl@0
   478
GLREF_D NTimerQ TheTimerQ;
sl@0
   479
sl@0
   480
/**
sl@0
   481
@internalComponent
sl@0
   482
*/
sl@0
   483
inline TUint32 NTickCount()
sl@0
   484
	{return TheTimerQ.iMsCount;}
sl@0
   485
sl@0
   486
/**
sl@0
   487
@internalComponent
sl@0
   488
*/
sl@0
   489
inline TInt NTickPeriod()
sl@0
   490
	{return TheTimerQ.iTickPeriod;}
sl@0
   491
sl@0
   492
sl@0
   493
extern "C" {
sl@0
   494
/**
sl@0
   495
@internalComponent
sl@0
   496
*/
sl@0
   497
extern void NKCrashHandler(TInt aPhase, const TAny* a0, TInt a1);
sl@0
   498
sl@0
   499
/**
sl@0
   500
@internalComponent
sl@0
   501
*/
sl@0
   502
extern TUint32 CrashState;
sl@0
   503
}
sl@0
   504
sl@0
   505
sl@0
   506
#define	__ACQUIRE_BTRACE_LOCK()
sl@0
   507
#define	__RELEASE_BTRACE_LOCK()
sl@0
   508
sl@0
   509
/**
sl@0
   510
@internalComponent
sl@0
   511
*/
sl@0
   512
TBool InterruptsStatus(TBool aRequest);
sl@0
   513
sl@0
   514
//declarations for the checking of kernel preconditions
sl@0
   515
sl@0
   516
/**
sl@0
   517
@internalComponent
sl@0
   518
sl@0
   519
PRECOND_FUNCTION_CALLER is needed for __ASSERT_WITH_MESSAGE_ALWAYS(),
sl@0
   520
so is outside the #ifdef _DEBUG.
sl@0
   521
*/
sl@0
   522
#ifndef PRECOND_FUNCTION_CALLER
sl@0
   523
#define PRECOND_FUNCTION_CALLER		0
sl@0
   524
#endif
sl@0
   525
sl@0
   526
#ifdef _DEBUG
sl@0
   527
sl@0
   528
/**
sl@0
   529
@internalComponent
sl@0
   530
*/
sl@0
   531
#define MASK_NO_FAST_MUTEX 0x1
sl@0
   532
#define MASK_CRITICAL 0x2
sl@0
   533
#define MASK_NO_CRITICAL 0x4
sl@0
   534
#define MASK_KERNEL_LOCKED 0x8
sl@0
   535
#define MASK_KERNEL_UNLOCKED 0x10
sl@0
   536
#define MASK_KERNEL_LOCKED_ONCE 0x20
sl@0
   537
#define MASK_INTERRUPTS_ENABLED 0x40
sl@0
   538
#define MASK_INTERRUPTS_DISABLED 0x80
sl@0
   539
#define MASK_SYSTEM_LOCKED 0x100
sl@0
   540
#define MASK_NOT_ISR 0x400
sl@0
   541
#define MASK_NOT_IDFC 0x800 
sl@0
   542
#define MASK_NOT_THREAD 0x1000
sl@0
   543
#define MASK_NO_CRITICAL_IF_USER 0x2000
sl@0
   544
#define MASK_THREAD_STANDARD ( MASK_NO_FAST_MUTEX | MASK_KERNEL_UNLOCKED | MASK_INTERRUPTS_ENABLED | MASK_NOT_ISR | MASK_NOT_IDFC )
sl@0
   545
#define MASK_THREAD_CRITICAL ( MASK_THREAD_STANDARD | MASK_CRITICAL )
sl@0
   546
#define MASK_ALWAYS_FAIL 0x4000
sl@0
   547
#define	MASK_NO_RESCHED 0x8000
sl@0
   548
sl@0
   549
#if defined(__STANDALONE_NANOKERNEL__) || (!defined (__KERNEL_APIS_CONTEXT_CHECKS_WARNING__)&&!defined (__KERNEL_APIS_CONTEXT_CHECKS_FAULT__))
sl@0
   550
#define CHECK_PRECONDITIONS(mask,function)
sl@0
   551
#define __ASSERT_WITH_MESSAGE_DEBUG(cond,message,function) 
sl@0
   552
sl@0
   553
#else
sl@0
   554
/**
sl@0
   555
@internalComponent
sl@0
   556
*/
sl@0
   557
extern "C" TInt CheckPreconditions(TUint32 aConditionMask, const char* aFunction, TLinAddr aAddr);
sl@0
   558
/**
sl@0
   559
@internalComponent
sl@0
   560
*/
sl@0
   561
#define CHECK_PRECONDITIONS(mask,function) CheckPreconditions(mask,function,PRECOND_FUNCTION_CALLER)
sl@0
   562
sl@0
   563
#ifdef __KERNEL_APIS_CONTEXT_CHECKS_FAULT__
sl@0
   564
sl@0
   565
/**
sl@0
   566
@internalComponent
sl@0
   567
*/
sl@0
   568
#define __ASSERT_WITH_MESSAGE_DEBUG(cond,message,function) \
sl@0
   569
			__ASSERT_DEBUG( (cond), ( \
sl@0
   570
			DEBUGPRINT("Assertion failed: %s\nFunction: %s; called from: %08x\n",message,function,PRECOND_FUNCTION_CALLER),\
sl@0
   571
			NKFault(function, 0)))
sl@0
   572
sl@0
   573
#else//!__KERNEL_APIS_CONTEXT_CHECKS_FAULT__
sl@0
   574
/**
sl@0
   575
@internalComponent
sl@0
   576
*/
sl@0
   577
#define __ASSERT_WITH_MESSAGE_DEBUG(cond,message,function) \
sl@0
   578
			__ASSERT_DEBUG( (cond), \
sl@0
   579
			DEBUGPRINT("Assertion failed: %s\nFunction: %s; called from: %08x\n",message,function,PRECOND_FUNCTION_CALLER))
sl@0
   580
sl@0
   581
sl@0
   582
#endif//__KERNEL_APIS_CONTEXT_CHECKS_FAULT__
sl@0
   583
#endif//(!defined (__KERNEL_APIS_CONTEXT_CHECKS_WARNING__)&&!defined (__KERNEL_APIS_CONTEXT_CHECKS_FAULT__))
sl@0
   584
sl@0
   585
#else//if !DEBUG
sl@0
   586
sl@0
   587
#define CHECK_PRECONDITIONS(mask,function)
sl@0
   588
#define __ASSERT_WITH_MESSAGE_DEBUG(cond,message,function)
sl@0
   589
sl@0
   590
#endif//_DEBUG
sl@0
   591
sl@0
   592
#if (!defined (__KERNEL_APIS_CONTEXT_CHECKS_WARNING__)&&!defined (__KERNEL_APIS_CONTEXT_CHECKS_FAULT__))
sl@0
   593
#define __ASSERT_WITH_MESSAGE_ALWAYS(cond,message,function)
sl@0
   594
#else
sl@0
   595
#ifdef __KERNEL_APIS_CONTEXT_CHECKS_FAULT__
sl@0
   596
/**
sl@0
   597
@internalComponent
sl@0
   598
*/
sl@0
   599
#define __ASSERT_WITH_MESSAGE_ALWAYS(cond,message,function) \
sl@0
   600
			__ASSERT_ALWAYS( (cond), ( \
sl@0
   601
			DEBUGPRINT("Assertion failed: %s\nFunction: %s; called from: %08x\n",message,function,PRECOND_FUNCTION_CALLER),\
sl@0
   602
			NKFault(function, 0)))
sl@0
   603
#else
sl@0
   604
/**
sl@0
   605
@internalComponent
sl@0
   606
*/
sl@0
   607
#define __ASSERT_WITH_MESSAGE_ALWAYS(cond,message,function) \
sl@0
   608
			__ASSERT_ALWAYS( (cond), \
sl@0
   609
			DEBUGPRINT("Assertion failed: %s\nFunction: %s; called from: %08x\n",message,function,PRECOND_FUNCTION_CALLER))
sl@0
   610
#endif//__KERNEL_APIS_CONTEXT_CHECKS_FAULT__
sl@0
   611
#endif//(!defined (__KERNEL_APIS_CONTEXT_CHECKS_WARNING__)&&!defined (__KERNEL_APIS_CONTEXT_CHECKS_FAULT__))
sl@0
   612
sl@0
   613
#endif