kernel/eka/include/nkernsmp/nk_priv.h
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
equal deleted inserted replaced
43:c1f20ce4abcf 44:3e88ff8f41d5
    25 
    25 
    26 #define __USE_BTRACE_LOCK__
    26 #define __USE_BTRACE_LOCK__
    27 
    27 
    28 class Monitor;
    28 class Monitor;
    29 
    29 
    30 const TInt KNumPriClasses = 4;
       
    31 extern const TUint8 KClassFromPriority[KNumPriorities];
       
    32 
       
    33 #ifndef __LOAD_BALANCE_INFO_DEFINED__
       
    34 /**
       
    35 @internalComponent
       
    36 */
       
    37 struct SLbInfo
       
    38 	{
       
    39 	TUint64		i__Dummy;
       
    40 	};
       
    41 #endif
       
    42 
       
    43 /********************************************
    30 /********************************************
    44  * Schedulable = thread or thread group
    31  * Schedulable = thread or thread group
    45  ********************************************/
    32  ********************************************/
    46 
    33 
    47 /**
    34 /**
    52 */
    39 */
    53 class NThreadGroup;
    40 class NThreadGroup;
    54 class NSchedulable : public TPriListLink
    41 class NSchedulable : public TPriListLink
    55 	{
    42 	{
    56 public:
    43 public:
    57 	/**
       
    58 	@internalComponent
       
    59 	*/
       
    60 	enum
    44 	enum
    61 		{
    45 		{
    62 		EReadyGroup=1,
    46 		EReadyGroup=1,
    63 		EReadyCpuMask=0x1f,
    47 		EReadyCpuMask=0x7f,
    64 		EReadyCpuSticky=0x40,
       
    65 		EReadyOffset=0x80,
    48 		EReadyOffset=0x80,
    66 		};
    49 		};
    67 
    50 
    68 	/**
       
    69 	@internalComponent
       
    70 	*/
       
    71 	enum NReadyFlags
    51 	enum NReadyFlags
    72 		{
    52 		{
    73 		ENewTimeslice=1,
    53 		ENewTimeslice=1,
    74 		EPreferSameCpu=2,
    54 		EPreferSameCpu=2,
    75 		EUnPause=4,
    55 		EUnPause=4,
    76 		};
    56 		};
    77 
    57 
    78 	/**
       
    79 	@internalComponent
       
    80 	*/
       
    81 	enum NEventState
    58 	enum NEventState
    82 		{
    59 		{
    83 		EEventCountShift=16u,
    60 		EEventCountShift=16u,
    84 		EEventCountMask=0xffff0000u,
    61 		EEventCountMask=0xffff0000u,
    85 		EEventCountInc=0x10000u,
    62 		EEventCountInc=0x10000u,
    88 		EThreadCpuShift=8u,
    65 		EThreadCpuShift=8u,
    89 		EThreadCpuMask=0x1f00u,
    66 		EThreadCpuMask=0x1f00u,
    90 		EDeferredReady=0x4000u,
    67 		EDeferredReady=0x4000u,
    91 		EEventParent=0x8000u,
    68 		EEventParent=0x8000u,
    92 		};
    69 		};
    93 
    70 public:
    94 	/**
    71 	NSchedulable();
    95 	@internalComponent
    72 	void AcqSLock();
    96 	*/
    73 	void RelSLock();
    97 	enum NLbState
    74 	void LAcqSLock();
    98 		{
    75 	void RelSLockU();
    99 		ELbState_Inactive	= 0x00u,	// not currently involved in load balancing
    76 	void ReadyT(TUint aMode);					// make ready, assumes lock held
   100 		ELbState_Global		= 0x01u,	// flag indicating this is on global load balance list
    77 	TInt BeginTiedEvent();
   101 		ELbState_Temp		= 0x02u,	// flag indicating this is on a temporary load balance list
    78 	void EndTiedEvent();
   102 		ELbState_CpuMask	= 0x1Fu,	// mask of bits indicating CPU if on per-CPU list
    79 	TInt AddTiedEvent(NEventHandler* aEvent);
   103 		ELbState_PerCpu		= 0x20u,	// flag indicating this is on per-CPU load balance list
    80 	TBool TiedEventReadyInterlock(TInt aCpu);
   104 		ELbState_ExtraRef	= 0x40u,	// flag indicating extra reference has been taken after thread/group died
    81 	void UnPauseT();							// decrement pause count and make ready if necessary
   105 		ELbState_Generation	= 0x80u,	// 1 bit generation number
    82 	static void DeferredReadyIDfcFn(TAny*);
   106 		};
    83 	void DetachTiedEvents();
   107 
    84 public:
   108 	/**
    85 	inline TBool IsGroup()			{return !iParent;}
   109 	@internalComponent
    86 	inline TBool IsLoneThread()		{return iParent==this;}
   110 	*/
    87 	inline TBool IsGroupThread()	{return iParent && iParent!=this;}
   111 	enum NCpuStatsSelect
       
   112 		{
       
   113 		E_RunTime=0x01u,
       
   114 		E_RunTimeDelta=0x02u,
       
   115 		E_ActiveTime=0x04u,
       
   116 		E_ActiveTimeDelta=0x08u,
       
   117 		E_LastRunTime=0x10u,
       
   118 		E_LastActiveTime=0x20u,
       
   119 
       
   120 		E_AllStats = 0x3fu
       
   121 		};
       
   122 
       
   123 	/**
       
   124 	@internalComponent
       
   125 	*/
       
   126 	struct SCpuStats
       
   127 		{
       
   128 		TUint64		iRunTime;			// total run time
       
   129 		TUint64		iRunTimeDelta;		// run time since we last asked
       
   130 		TUint64		iActiveTime;		// total active time
       
   131 		TUint64		iActiveTimeDelta;	// active time since we last asked
       
   132 		TUint64		iLastRunTime;		// how long ago this last ran
       
   133 		TUint64		iLastActiveTime;	// how long ago this was last active
       
   134 		};
       
   135 public:
       
   136 	NSchedulable();								/**< @internalComponent */
       
   137 	void AcqSLock();							/**< @internalComponent */
       
   138 	void RelSLock();							/**< @internalComponent */
       
   139 	void LAcqSLock();							/**< @internalComponent */
       
   140 	void RelSLockU();							/**< @internalComponent */
       
   141 	void ReadyT(TUint aMode);					/**< @internalComponent */ // make ready, assumes lock held
       
   142 	TInt BeginTiedEvent();						/**< @internalComponent */
       
   143 	void EndTiedEvent();						/**< @internalComponent */
       
   144 	TInt AddTiedEvent(NEventHandler* aEvent);	/**< @internalComponent */
       
   145 	TBool TiedEventReadyInterlock(TInt aCpu);	/**< @internalComponent */
       
   146 	void UnPauseT();							/**< @internalComponent */ // decrement pause count and make ready if necessary
       
   147 	static void DeferredReadyIDfcFn(TAny*);		/**< @internalComponent */
       
   148 	void DetachTiedEvents();					/**< @internalComponent */
       
   149 	TBool TakeRef();							/**< @internalComponent */
       
   150 	TBool DropRef();							/**< @internalComponent */
       
   151 	void LbUnlink();							/**< @internalComponent */
       
   152 	void LbTransfer(SDblQue& aDestQ);			/**< @internalComponent */
       
   153 	void RemoveFromEnumerateList();				/**< @internalComponent */
       
   154 	void GetCpuStats(TUint aMask, SCpuStats& aOut);		/**< @internalComponent */
       
   155 	void GetCpuStatsT(TUint aMask, SCpuStats& aOut);	/**< @internalComponent */
       
   156 	void GetLbStats(TUint64 aTime);				/**< @internalComponent */
       
   157 	void LbDone(TUint aFlags);					/**< @internalComponent */
       
   158 	TUint32 SetCpuAffinityT(TUint32 aAffinity);	/**< @internalComponent */
       
   159 	TBool ShouldMigrate(TInt aCpu);				/**< @internalComponent */
       
   160 	void InitLbInfo();							/**< @internalComponent */
       
   161 	void NominalPriorityChanged();				/**< @internalComponent */
       
   162 	void AddToEnumerateList();					/**< @internalComponent */
       
   163 	void SetEventCpu();							/**< @internalComponent */
       
   164 public:
       
   165 	static TUint32 PreprocessCpuAffinity(TUint32 aAffinity);			/**< @internalComponent */
       
   166 	inline TBool IsGroup()			{return !iParent;}					/**< @internalComponent */
       
   167 	inline TBool IsLoneThread()		{return iParent==this;}				/**< @internalComponent */
       
   168 	inline TBool IsGroupThread()	{return iParent && iParent!=this;}	/**< @internalComponent */
       
   169 public:
    88 public:
   170 //	TUint8				iReady;					/**< @internalComponent */	// flag indicating thread on ready list = cpu number | EReadyOffset
    89 //	TUint8				iReady;					/**< @internalComponent */	// flag indicating thread on ready list = cpu number | EReadyOffset
   171 //	TUint8				iCurrent;				/**< @internalComponent */	// flag indicating thread is running
    90 //	TUint8				iCurrent;				/**< @internalComponent */	// flag indicating thread is running
   172 //	TUint8				iLastCpu;				/**< @internalComponent */	// CPU on which this thread last ran
    91 //	TUint8				iLastCpu;				/**< @internalComponent */	// CPU on which this thread last ran
   173 	TUint8				iPauseCount;			/**< @internalComponent */	// count of externally requested pauses extending a voluntary wait
    92 	TUint8				iPauseCount;			/**< @internalComponent */	// count of externally requested pauses extending a voluntary wait
   174 	TUint8				iSuspended;				/**< @internalComponent */	// flag indicating active external suspend (Not used for groups)
    93 	TUint8				iSuspended;				/**< @internalComponent */	// flag indicating active external suspend (Not used for groups)
   175 	TUint8				iACount;				/**< @internalComponent */	// access count
    94 	TUint8				iNSchedulableSpare1;	/**< @internalComponent */
   176 	TUint8				iPreferredCpu;			/**< @internalComponent */
    95 	TUint8				iNSchedulableSpare2;	/**< @internalComponent */
   177 
       
   178 	TInt				iActiveState;			/**< @internalComponent */
       
   179 	TUint8				i_NSchedulable_Spare2;	/**< @internalComponent */
       
   180 	TUint8				iForcedCpu;				/**< @internalComponent */
       
   181 	TUint8				iTransientCpu;			/**< @internalComponent */
       
   182 	TUint8				iLbState;				/**< @internalComponent */
       
   183 
    96 
   184 	TUint8				iCpuChange;				/**< @internalComponent */	// flag showing CPU migration outstanding
    97 	TUint8				iCpuChange;				/**< @internalComponent */	// flag showing CPU migration outstanding
   185 	TUint8				iStopping;				/**< @internalComponent */	// thread is exiting, thread group is being destroyed
    98 	TUint8				iStopping;				/**< @internalComponent */	// thread is exiting, thread group is being destroyed
   186 	TUint16				iFreezeCpu;				/**< @internalComponent */	// flag set if CPU frozen - count for groups
    99 	TUint16				iFreezeCpu;				/**< @internalComponent */	// flag set if CPU frozen - count for groups
   187 	NSchedulable*		iParent;				/**< @internalComponent */	// Pointer to group containing thread, =this for normal thread, =0 for group
   100 	NSchedulable*		iParent;				/**< @internalComponent */	// Pointer to group containing thread, =this for normal thread, =0 for group
   194 	SDblQue				iEvents;				/**< @internalComponent */	// doubly-linked list of tied events
   107 	SDblQue				iEvents;				/**< @internalComponent */	// doubly-linked list of tied events
   195 
   108 
   196 	TUint32				i_IDfcMem[sizeof(TDfc)/sizeof(TUint32)];	/**< @internalComponent */	// IDFC used to make thread ready after last tied event completes
   109 	TUint32				i_IDfcMem[sizeof(TDfc)/sizeof(TUint32)];	/**< @internalComponent */	// IDFC used to make thread ready after last tied event completes
   197 //	TDfc				iDeferredReadyIDfc;		/**< @internalComponent */	// IDFC used to make thread ready after last tied event completes
   110 //	TDfc				iDeferredReadyIDfc;		/**< @internalComponent */	// IDFC used to make thread ready after last tied event completes
   198 
   111 
   199 	union {
   112 	union
   200 		TUint64HL		iRunCount;				/**< @internalComponent */	// number of times this thread has run
   113 		{
   201 		TUint64HL		iLastStartTime;			/**< @internalComponent */	// last start time for groups
   114 		TUint64			iRunCount64;
   202 		};
   115 		TUint32			iRunCount32[2];
   203 	TUint64HL			iLastRunTime;			/**< @internalComponent */	// time when this thread last ran
   116 		};
   204 	TUint64HL			iTotalCpuTime;			/**< @internalComponent */	// total CPU time used by this thread
   117 	union
   205 	TUint64HL			iLastActivationTime;	/**< @internalComponent */	// time when this thread last became active
   118 		{
   206 	TUint64HL			iTotalActiveTime;		/**< @internalComponent */	// total time this thread has been active
   119 		TUint64			iTotalCpuTime64;		/**< @internalComponent */	// total time spent running, in hi-res timer ticks
   207 	TUint64HL			iSavedCpuTime;			/**< @internalComponent */	// Total CPU time used at last check
   120 		TUint32			iTotalCpuTime32[2];		/**< @internalComponent */	// total time spent running, in hi-res timer ticks
   208 	TUint64HL			iSavedActiveTime;		/**< @internalComponent */	// Total active time at last check
       
   209 	SDblQueLink			iLbLink;				/**< @internalComponent */	// Link into queue of tasks requiring load balancing
       
   210 	SIterDQLink			iEnumerateLink;			/**< @internalComponent */
       
   211 
       
   212 	enum {EMaxLbInfoSize = 48};					/**< @internalComponent */
       
   213 	union	{
       
   214 		TUint64			i__Dummy[EMaxLbInfoSize/sizeof(TUint64)];	/**< @internalComponent */
       
   215 		SLbInfo			iLbInfo;				/**< @internalComponent */
       
   216 		};
   121 		};
   217 	};
   122 	};
   218 
   123 
   219 __ASSERT_COMPILE(!(_FOFF(NSchedulable,iSSpinLock)&7));
   124 __ASSERT_COMPILE(!(_FOFF(NSchedulable,iSSpinLock)&7));
   220 __ASSERT_COMPILE(!(_FOFF(NSchedulable,iRunCount)&7));
   125 __ASSERT_COMPILE(!(_FOFF(NSchedulable,iRunCount64)&7));
   221 __ASSERT_COMPILE(!(_FOFF(NSchedulable,iTotalCpuTime)&7));
   126 __ASSERT_COMPILE(!(_FOFF(NSchedulable,iTotalCpuTime64)&7));
   222 __ASSERT_COMPILE(!(_FOFF(NSchedulable,iLbInfo)&7));
       
   223 __ASSERT_COMPILE(sizeof(SLbInfo) <= NSchedulable::EMaxLbInfoSize);
       
   224 __ASSERT_COMPILE(!(sizeof(NSchedulable)&7));
   127 __ASSERT_COMPILE(!(sizeof(NSchedulable)&7));
   225 
   128 
   226 
   129 
   227 /**
   130 /**
   228 @internalComponent
   131 @internalComponent
   356 		ETimeoutPostamble=1,
   259 		ETimeoutPostamble=1,
   357 		ETimeoutSpurious=2,
   260 		ETimeoutSpurious=2,
   358 		};
   261 		};
   359 public:
   262 public:
   360 	NThreadBase();
   263 	NThreadBase();
   361 	TInt Create(SNThreadCreateInfo& anInfo,	TBool aInitial);	/**< @internalComponent */
   264 	TInt Create(SNThreadCreateInfo& anInfo,	TBool aInitial);
   362 	void UnReadyT();										/**< @internalComponent */
   265 	void UnReadyT();
   363 	TBool SuspendOrKill(TInt aCount);						/**< @internalComponent */
   266 	TBool SuspendOrKill(TInt aCount);
   364 	TBool DoSuspendOrKillT(TInt aCount, TSubScheduler* aS);	/**< @internalComponent */
   267 	TBool DoSuspendOrKillT(TInt aCount, TSubScheduler* aS);
   365 	TBool CancelTimerT();									/**< @internalComponent */
   268 	TBool CancelTimerT();
   366 	void DoReleaseT(TInt aReturnCode, TUint aMode);			/**< @internalComponent */
   269 	void DoReleaseT(TInt aReturnCode, TUint aMode);
   367 	TBool CheckFastMutexDefer();							/**< @internalComponent */
   270 	TBool CheckFastMutexDefer();
   368 	void DoCsFunctionT();									/**< @internalComponent */
   271 	void DoCsFunctionT();
   369 	TBool Resume(TBool aForce);								/**< @internalComponent */
   272 	TBool Resume(TBool aForce);
   370 	IMPORT_C TBool Suspend(TInt aCount);					/**< @internalComponent */
   273 	IMPORT_C TBool Suspend(TInt aCount);		/**< @internalComponent */
   371 	IMPORT_C TBool Resume();								/**< @internalComponent */
   274 	IMPORT_C TBool Resume();					/**< @internalComponent */
   372 	IMPORT_C TBool ForceResume();							/**< @internalComponent */
   275 	IMPORT_C TBool ForceResume();				/**< @internalComponent */
   373 	IMPORT_C void Release(TInt aReturnCode, TUint aMode);	/**< @internalComponent */
   276 	IMPORT_C void Release(TInt aReturnCode, TUint aMode);	/**< @internalComponent */
   374 	IMPORT_C void RequestSignal();							/**< @internalComponent */
   277 	IMPORT_C void RequestSignal();				/**< @internalComponent */
   375 	IMPORT_C void SetPriority(TInt aPriority);				/**< @internalComponent */
   278 	IMPORT_C void SetPriority(TInt aPriority);	/**< @internalComponent */
   376 	void SetNominalPriority(TInt aPriority);				/**< @internalComponent */
   279 	void SetMutexPriority(NFastMutex* aMutex);
   377 	void SetMutexPriority(NFastMutex* aMutex);				/**< @internalComponent */
   280 	void LoseInheritedPriorityT();
   378 	void LoseInheritedPriorityT();							/**< @internalComponent */
   281 	void ChangeReadyThreadPriority();
   379 	void ChangeReadyThreadPriority();						/**< @internalComponent */
   282 	TUint32 SetCpuAffinity(TUint32 aAffinity);
   380 	TBool TiedEventLeaveInterlock();						/**< @internalComponent */
   283 	TBool TiedEventLeaveInterlock();
   381 	TBool TiedEventJoinInterlock();							/**< @internalComponent */
   284 	TBool TiedEventJoinInterlock();
   382 	IMPORT_C void Kill();									/**< @internalComponent */
   285 	IMPORT_C void Kill();						/**< @internalComponent */
   383 	void Exit();											/**< @internalComponent */
   286 	void Exit();
   384 	// hooks for platform-specific code
   287 	// hooks for platform-specific code
   385 	void OnKill();											/**< @internalComponent */
   288 	void OnKill(); 
   386 	void OnExit();											/**< @internalComponent */
   289 	void OnExit();
   387 public:
   290 public:
   388 	static void TimerExpired(TAny* aPtr);					/**< @internalComponent */
   291 	static void TimerExpired(TAny* aPtr);
   389 
   292 
   390 	/** @internalComponent */
   293 	/** @internalComponent */
   391 	inline void UnknownState(TInt aOp, TInt aParam)
   294 	inline void UnknownState(TInt aOp, TInt aParam)
   392 		{ (*iHandlers->iStateHandler)((NThread*)this,aOp,aParam); }
   295 		{ (*iHandlers->iStateHandler)((NThread*)this,aOp,aParam); }
   393 
   296 
   416 		{ return iWaitState.ThreadIsDead(); }
   319 		{ return iWaitState.ThreadIsDead(); }
   417 public:
   320 public:
   418 	TPriListLink		iWaitLink;				/**< @internalComponent */	// used to link thread into a wait queue
   321 	TPriListLink		iWaitLink;				/**< @internalComponent */	// used to link thread into a wait queue
   419 //	TUint8				iBasePri;				/**< @internalComponent */	// priority with no fast mutex held
   322 //	TUint8				iBasePri;				/**< @internalComponent */	// priority with no fast mutex held
   420 //	TUint8				iMutexPri;				/**< @internalComponent */	// priority from held fast mutex
   323 //	TUint8				iMutexPri;				/**< @internalComponent */	// priority from held fast mutex
   421 //	TUint8				iNominalPri;			/**< @internalComponent */	// nominal priority of thread (excluding effect of higher level inheritance)
   324 //	TUint8				iInitial;				/**< @internalComponent */	// TRUE if this is an initial thread
   422 	TUint8				iLinkedObjType;
   325 	TUint8				iLinkedObjType;
   423 	TUint8				i_ThrdAttr;				/**< @internalComponent */
   326 	TUint8				i_ThrdAttr;				/**< @internalComponent */
   424 	TUint8				iInitial;				/**< @internalComponent */	// TRUE if this is an initial thread
   327 	TUint8				iNThreadBaseSpare10;
   425 	TUint8				iFastMutexDefer;		/**< @internalComponent */
   328 	TUint8				iFastMutexDefer;		/**< @internalComponent */
   426 
   329 
   427 	NFastSemaphore		iRequestSemaphore;		/**< @internalComponent */
   330 	NFastSemaphore		iRequestSemaphore;		/**< @internalComponent */
   428 
   331 
   429 	TInt				iTime;					/**< @internalComponent */	// time remaining, 0 if expired
   332 	TInt				iTime;					/**< @internalComponent */	// time remaining, 0 if expired
   452 	TInt				iStackSize;				/**< @internalComponent */
   355 	TInt				iStackSize;				/**< @internalComponent */
   453 
   356 
   454 	TAny*				iExtraContext;			/**< @internalComponent */	// parent FPSCR value (iExtraContextSize == -1), coprocessor context (iExtraContextSize > 0) or NULL
   357 	TAny*				iExtraContext;			/**< @internalComponent */	// parent FPSCR value (iExtraContextSize == -1), coprocessor context (iExtraContextSize > 0) or NULL
   455 	TInt				iExtraContextSize;		/**< @internalComponent */	// +ve=dynamically allocated, 0=none, -1=iExtraContext stores parent FPSCR value
   358 	TInt				iExtraContextSize;		/**< @internalComponent */	// +ve=dynamically allocated, 0=none, -1=iExtraContext stores parent FPSCR value
   456 
   359 
   457 	TUint8				iCoreCycling;			/**< @internalComponent */	// this thread is currently cycling through all active cores
       
   458 	TUint8				iRebalanceAttr;			/**< @internalComponent */	// behaviour of load balancing wrt this thread
       
   459 	TUint8				iNThreadBaseSpare4c;	/**< @internalComponent */	// spare to allow growth while preserving BC
       
   460 	TUint8				iNThreadBaseSpare4d;	/**< @internalComponent */	// spare to allow growth while preserving BC
       
   461 	TUint32				iNThreadBaseSpare5;		/**< @internalComponent */	// spare to allow growth while preserving BC
       
   462 	TUint32				iNThreadBaseSpare6;		/**< @internalComponent */	// spare to allow growth while preserving BC
   360 	TUint32				iNThreadBaseSpare6;		/**< @internalComponent */	// spare to allow growth while preserving BC
   463 	TUint32				iNThreadBaseSpare7;		/**< @internalComponent */	// spare to allow growth while preserving BC
   361 	TUint32				iNThreadBaseSpare7;		/**< @internalComponent */	// spare to allow growth while preserving BC
   464 	TUint32				iNThreadBaseSpare8;		/**< @internalComponent */	// spare to allow growth while preserving BC
   362 	TUint32				iNThreadBaseSpare8;		/**< @internalComponent */	// spare to allow growth while preserving BC
   465 	TUint32				iNThreadBaseSpare9;		/**< @internalComponent */	// spare to allow growth while preserving BC
   363 	TUint32				iNThreadBaseSpare9;		/**< @internalComponent */	// spare to allow growth while preserving BC
       
   364 
       
   365 	// For EMI support - HOPEFULLY THIS CAN DIE
       
   366 	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.
       
   367 	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.
   466 	};
   368 	};
   467 
   369 
   468 __ASSERT_COMPILE(!(_FOFF(NThreadBase,iWaitLink)&7));
   370 __ASSERT_COMPILE(!(_FOFF(NThreadBase,iWaitLink)&7));
   469 __ASSERT_COMPILE(!(sizeof(NThreadBase)&7));
   371 __ASSERT_COMPILE(!(sizeof(NThreadBase)&7));
   470 
   372 
   473 #define	iCurrent			iSpare2				/**< @internalComponent */
   375 #define	iCurrent			iSpare2				/**< @internalComponent */
   474 #define	iLastCpu			iSpare3				/**< @internalComponent */
   376 #define	iLastCpu			iSpare3				/**< @internalComponent */
   475 
   377 
   476 #define iBasePri			iWaitLink.iSpare1	/**< @internalComponent */
   378 #define iBasePri			iWaitLink.iSpare1	/**< @internalComponent */
   477 #define	iMutexPri			iWaitLink.iSpare2	/**< @internalComponent */
   379 #define	iMutexPri			iWaitLink.iSpare2	/**< @internalComponent */
   478 #define	iNominalPri			iWaitLink.iSpare3	/**< @internalComponent */
   380 #define	i_NThread_Initial	iWaitLink.iSpare3	/**< @internalComponent */
   479 #define	i_NThread_Initial	iInitial			/**< @internalComponent */
       
   480 
   381 
   481 #endif
   382 #endif
   482 
   383 
   483 /** @internalComponent */
   384 /** @internalComponent */
   484 #define	i_NThread_BasePri		iWaitLink.iSpare1
   385 #define	i_NThread_BasePri	iWaitLink.iSpare1
   485 #define	i_NThread_NominalPri	iWaitLink.iSpare3
       
   486 
   386 
   487 /** @internalComponent */
   387 /** @internalComponent */
   488 #define	NTHREADBASE_CPU_AFFINITY_MASK	0x80000000
   388 #define	NTHREADBASE_CPU_AFFINITY_MASK	0x80000000
   489 
   389 
   490 /** @internalComponent */
   390 /** @internalComponent */
   505 	{
   405 	{
   506 public:
   406 public:
   507 	NThreadGroup();
   407 	NThreadGroup();
   508 public:
   408 public:
   509 	TInt iThreadCount;										/**< @internalComponent */
   409 	TInt iThreadCount;										/**< @internalComponent */
   510 	TDfc* iDestructionDfc;									/**< @internalComponent */
       
   511 	TPriList<NThreadBase, KNumPriorities> iNThreadList;		/**< @internalComponent */
   410 	TPriList<NThreadBase, KNumPriorities> iNThreadList;		/**< @internalComponent */
   512 	};
   411 	};
   513 
   412 
   514 /********************************************
   413 /********************************************
   515  * Scheduler
   414  * Scheduler
   516  ********************************************/
   415  ********************************************/
   517 
   416 
   518 #include <nk_plat.h>
       
   519 
       
   520 /**
       
   521 @internalComponent
       
   522 */
       
   523 enum
       
   524 	{
       
   525 	EQueueEvent_Kick=1,
       
   526 	EQueueEvent_WakeUp=2,
       
   527 	};
       
   528 
       
   529 /**
   417 /**
   530 @internalComponent
   418 @internalComponent
   531 */
   419 */
   532 class TScheduler;
   420 class TScheduler;
   533 class NThread;
   421 class NThread;
   534 class NIrqHandler;
   422 class NIrqHandler;
   535 struct SIdlePullThread;
   423 class TSubScheduler : public TPriListBase
   536 class TSubScheduler
       
   537 	{
   424 	{
   538 public:
   425 public:
   539 	TSubScheduler();
   426 	TSubScheduler();
   540 	void QueueDfcs();
   427 	void QueueDfcs();
   541 	void RotateReadyList(TInt aPriority);
   428 	void RotateReadyList(TInt aPriority);
   542 	NThread* SelectNextThread();
   429 	NThread* SelectNextThread();
   543 	TInt QueueEvent(NEventHandler* aEvent);
   430 	TBool QueueEvent(NEventHandler* aEvent);
   544 	void QueueEventAndKick(NEventHandler* aEvent);
   431 	void QueueEventAndKick(NEventHandler* aEvent);
   545 	void SaveTimesliceTimer(NThreadBase* aThread);
   432 	void SaveTimesliceTimer(NThreadBase* aThread);
   546 	void UpdateThreadTimes(NThreadBase* aOld, NThreadBase* aNew);
   433 	void UpdateThreadTimes(NThreadBase* aOld, NThreadBase* aNew);
   547 	void SSAddEntry(NSchedulable* aEntry);
       
   548 	void SSAddEntryHead(NSchedulable* aEntry);
       
   549 	void SSRemoveEntry(NSchedulable* aEntry);
       
   550 	void SSChgEntryP(NSchedulable* aEntry, TInt aNewPriority);
       
   551 	void IdlePullSearch(SIdlePullThread& a, TSubScheduler* aDest);
       
   552 	void GetLbThreads(SDblQue& aQ);
       
   553 	TBool Detached();	// platform specific
       
   554 
       
   555 	inline TInt HighestPriority()
       
   556 		{ return iSSList.HighestPriority(); }
       
   557 	inline NSchedulable* EntryAtPriority(TInt aPri)
       
   558 		{ return (NSchedulable*)iSSList.iQueue[aPri]; }
       
   559 private:
   434 private:
   560 	TPriList<NSchedulable, KNumPriorities>	iSSList;
   435 	SDblQueLink*	iExtraQueues[KNumPriorities-1];
   561 public:
   436 public:
   562 	TSpinLock		iExIDfcLock;				// lock to protect exogenous IDFC queue
   437 	TSpinLock		iExIDfcLock;				// lock to protect exogenous IDFC queue
   563 
   438 
   564 	SDblQue			iExIDfcs;					// list of pending exogenous IDFCs (i.e. ones punted over from another CPU)
   439 	SDblQue			iExIDfcs;					// list of pending exogenous IDFCs (i.e. ones punted over from another CPU)
   565 
   440 
   579 	volatile TUint8	iExIDfcPendingFlag;			// TRUE if an exogenous IDFC is pending
   454 	volatile TUint8	iExIDfcPendingFlag;			// TRUE if an exogenous IDFC is pending
   580 	TInt			iKernLockCount;				// how many times the current CPU has locked the kernel
   455 	TInt			iKernLockCount;				// how many times the current CPU has locked the kernel
   581 
   456 
   582 	TUint8			iInIDFC;					// TRUE if IDFCs are currently being run on this CPU
   457 	TUint8			iInIDFC;					// TRUE if IDFCs are currently being run on this CPU
   583 	volatile TUint8	iEventHandlersPending;		// TRUE if an event handler is pending on this CPU
   458 	volatile TUint8	iEventHandlersPending;		// TRUE if an event handler is pending on this CPU
   584 	TUint8			iCCSyncPending;
   459 	TUint8			iSubSchedulerSpare4;
   585 	TUint8			iLbCounter;
   460 	TUint8			iSubSchedulerSpare5;
   586 	TAny*			iAddressSpace;
   461 	TAny*			iAddressSpace;
   587 
   462 
   588 	TUint32			iReschedIPIs;
   463 	TUint32			iReschedIPIs;
   589 	TScheduler*		iScheduler;
   464 	TScheduler*		iScheduler;
   590 
   465 
   591 	TInt			iDeferShutdown;				// counts reasons why this CPU can't shut down
   466 	union
   592 	TInt			iRdyThreadCount;			// number of ready threads excluding idle thread
   467 		{
   593 	TUint16			iPriClassThreadCount[KNumPriClasses];
   468 		TUint64		iLastTimestamp64;			// NKern::Timestamp() value at last reschedule or timestamp sync
   594 
   469 		TUint32		iLastTimestamp32[2];
   595 	TUint64HL		iLastTimestamp;				// timestamp at which last reschedule occurred
   470 		};
   596 	TUint64HL		iReschedCount;
   471 	union
       
   472 		{
       
   473 		TUint64		iReschedCount64;
       
   474 		TUint32		iReschedCount32[2];
       
   475 		};
       
   476 
       
   477 	TAny*			iExtras[24];				// Space for platform-specific extras
   597 
   478 
   598 	TGenericIPI*	iNextIPI;					// next generic IPI to run on this CPU
   479 	TGenericIPI*	iNextIPI;					// next generic IPI to run on this CPU
   599 	NThread*		iInitialThread;				// Initial (idle) thread on this CPU
   480 	NThread*		iInitialThread;				// Initial (idle) thread on this CPU
   600 
   481 
   601 	TSpinLock		iEventHandlerLock;			// lock to protect event handler queue
   482 	TSpinLock		iEventHandlerLock;			// lock to protect event handler queue
   602 
   483 
   603 	SDblQue			iEventHandlers;				// queue of pending event handlers on this CPU
   484 	SDblQue			iEventHandlers;				// queue of pending event handlers on this CPU
   604 
   485 
   605 	TUint64			iSpinLockOrderCheck;		// bitmask showing which spinlock orders currently held
   486 	TUint64			iSpinLockOrderCheck;		// bitmask showing which spinlock orders currently held
   606 
   487 
   607 	TSubSchedulerX	iSSX;						// platform specific extras
   488 	TUint32			iSubSchedulerPadding[8];
   608 
       
   609 	volatile TAny*	iUncached;					// points to platform specific uncached data structure
       
   610 	TUint 			iMadeReadyCounter;			// Number of times this core made a thread ready.
       
   611 
       
   612 	TUint 			iMadeUnReadyCounter;		// Number of times this core made a thread unready.
       
   613 	TUint 			iTimeSliceExpireCounter;	// Number of times this core hass reschedualed due to time slice exireation.
       
   614 
       
   615 	TUint32			iSubSchedulerPadding[70];
       
   616 	SDblQue			iLbQ;						// threads to be considered by subsequent periodic load balance
       
   617 
       
   618 	TAny*			iSubSchedScratch[16];		// For use by code outside NKern
       
   619 	};
   489 	};
   620 
       
   621 const TInt KSubSchedulerShift = 10;				// log2(sizeof(TSubScheduler))
       
   622 
   490 
   623 __ASSERT_COMPILE(!(_FOFF(TSubScheduler,iExIDfcLock)&7));
   491 __ASSERT_COMPILE(!(_FOFF(TSubScheduler,iExIDfcLock)&7));
   624 __ASSERT_COMPILE(!(_FOFF(TSubScheduler,iEventHandlerLock)&7));
   492 __ASSERT_COMPILE(!(_FOFF(TSubScheduler,iEventHandlerLock)&7));
   625 __ASSERT_COMPILE(!(_FOFF(TSubScheduler,iReadyListLock)&7));
   493 __ASSERT_COMPILE(!(_FOFF(TSubScheduler,iReadyListLock)&7));
   626 __ASSERT_COMPILE(!(_FOFF(TSubScheduler,iLastTimestamp)&7));
   494 __ASSERT_COMPILE(!(_FOFF(TSubScheduler,iLastTimestamp64)&7));
   627 __ASSERT_COMPILE(!(_FOFF(TSubScheduler,iReschedCount)&7));
   495 __ASSERT_COMPILE(!(_FOFF(TSubScheduler,iReschedCount64)&7));
   628 __ASSERT_COMPILE(sizeof(TSubSchedulerX)==256);
   496 __ASSERT_COMPILE(sizeof(TSubScheduler)==512);	// make it a nice power of 2 size for easy indexing
   629 __ASSERT_COMPILE(sizeof(TSubScheduler)==(1<<KSubSchedulerShift));	// make it a nice power of 2 size for easy indexing
       
   630 
       
   631 struct SCoreControlAction;
       
   632 struct SVariantInterfaceBlock;
       
   633 
   497 
   634 /**
   498 /**
   635 @internalComponent
   499 @internalComponent
   636 */
   500 */
   637 class TScheduler
   501 class TScheduler
   639 public:
   503 public:
   640 	TScheduler();
   504 	TScheduler();
   641 	static void Reschedule();
   505 	static void Reschedule();
   642 	IMPORT_C static TScheduler* Ptr();
   506 	IMPORT_C static TScheduler* Ptr();
   643 	inline void SetProcessHandler(TLinAddr aHandler) {iProcessHandler=aHandler;}
   507 	inline void SetProcessHandler(TLinAddr aHandler) {iProcessHandler=aHandler;}
   644 	void PeriodicBalance();
       
   645 	TBool ReBalance(SDblQue& aQ, TBool aCC);
       
   646 	void CCReactivate(TUint32 aMore);
       
   647 	void CCIpiReactivate();
       
   648 	void CCRequest();
       
   649 	void GetLbThreads(SDblQue& aQ);
       
   650 	void CCUnDefer();
       
   651 	void ChangeThreadAcceptCpus(TUint32 aNewMask);
       
   652 	TUint32 ReschedInactiveCpus(TUint32 aMask);
       
   653 	void InitCCAction(SCoreControlAction& aA);
       
   654 	TUint32 ModifyCCState(TUint32 aAnd, TUint32 aXor);
       
   655 	TUint32 CpuShuttingDown(TSubScheduler& aSS);
       
   656 	void AllCpusIdle();
       
   657 	void FirstBackFromIdle();
       
   658 
       
   659 	void InitLB();
       
   660 	void StartRebalanceTimer(TBool aRestart);
       
   661 	void StopRebalanceTimer(TBool aTemp);
       
   662 	static void BalanceTimerExpired(TAny*);
       
   663 	static void StartPeriodicBalancing();
       
   664 	static void CCSyncDone(TAny*);
       
   665 	static void CCReactivateDfcFn(TAny*);
       
   666 	static void CCRequestDfcFn(TAny*);
       
   667 	static void CCIpiReactivateFn(TAny*);
       
   668 	static TDfcQue* RebalanceDfcQ();
       
   669 	static NThread* LBThread();
       
   670 	static TBool CoreControlSupported();
       
   671 	static void CCInitiatePowerUp(TUint32 aCores);
       
   672 	static void CCIndirectPowerDown(TAny*);
       
   673 	static void DoFrequencyChanged(TAny*);
       
   674 public:
   508 public:
   675 	TLinAddr		iMonitorExceptionHandler;
   509 	TLinAddr		iMonitorExceptionHandler;
   676 	TLinAddr		iProcessHandler;
   510 	TLinAddr		iProcessHandler;
   677 
   511 
   678 	volatile TUint32 iThreadAcceptCpus;			// bit n set if CPU n is accepting unlocked threads
   512 	TLinAddr		iRescheduleHook;
   679 	volatile TUint32 iIpiAcceptCpus;			// bit n set if CPU n is accepting generic IPIs
   513 	TUint32			iActiveCpus1;				// bit n set if CPU n is accepting unlocked threads
   680 	volatile TUint32 iCpusComingUp;				// bit n set if CPU n is in the process of powering up
   514 
   681 	volatile TUint32 iCpusGoingDown;			// bit n set if CPU n is in the process of powering down and is no longer accepting IPIs
   515 	TUint32			iActiveCpus2;				// bit n set if CPU n is accepting generic IPIs
   682 	volatile TInt	 iCCDeferCount;				// >0 means CPUs on the way down will stop just before the 'point of no return'
       
   683 	volatile TUint32 iCCSyncCpus;				// bit n set if CPU n has not yet observed a change to iThreadAcceptCpus
       
   684 	volatile TUint32 iCCReactivateCpus;
       
   685 	volatile TUint32 iCCState;
       
   686 
       
   687 	TInt			iNumCpus;					// number of CPUs under the kernel's control
   516 	TInt			iNumCpus;					// number of CPUs under the kernel's control
   688 	TLinAddr		iRescheduleHook;
       
   689 
       
   690 	SDblQue			iGenIPIList;				// list of active generic IPIs
       
   691 	TSpinLock		iGenIPILock;				// spin lock protects iGenIPIList, also iIpiAcceptCpus, iCpusComingUp, iCpusGoingDown, iCCDeferCount
       
   692 
   517 
   693 	TSubScheduler*	iSub[KMaxCpus];				// one subscheduler per CPU
   518 	TSubScheduler*	iSub[KMaxCpus];				// one subscheduler per CPU
   694 
   519 
   695 	TAny*			iSchedScratch[16];			// for use by code outside NKern
   520 	TAny*			iExtras[24];				// Space for platform-specific extras
   696 
       
   697 	TSchedulerX		iSX;						// platform specific extras
       
   698 
   521 
   699 	NFastMutex		iLock;						// the 'system lock' fast mutex
   522 	NFastMutex		iLock;						// the 'system lock' fast mutex
   700 
       
   701 	TSpinLock		iIdleBalanceLock;
       
   702 
   523 
   703 	TSpinLock		iIdleSpinLock;				// lock to protect list of DFCs to be run on idle
   524 	TSpinLock		iIdleSpinLock;				// lock to protect list of DFCs to be run on idle
   704 
   525 
   705 	SDblQue			iIdleDfcs;					// list of DFCs to run when all CPUs go idle
   526 	SDblQue			iIdleDfcs;					// list of DFCs to run when all CPUs go idle
   706 
   527 
   707 	TUint32			iCpusNotIdle;				// bitmask - Bit n set => CPU n is not idle
   528 	TUint32			iCpusNotIdle;				// bitmask - Bit n set => CPU n is not idle
   708 	TUint8			iIdleGeneration;			// Toggles between 0 and 1 each time iIdleDfcs list is spilled to a CPU IDFC queue
   529 	TUint8			iIdleGeneration;			// Toggles between 0 and 1 each time iIdleDfcs list is spilled to a CPU IDFC queue
   709 	TUint8			iIdleSpillCpu;				// Which CPU last spilled the iIdleDfcs list to its IDFC queue
   530 	TUint8			iIdleSpillCpu;				// Which CPU last spilled the iIdleDfcs list to its IDFC queue
   710 	TUint8			iLbCounter;
   531 	TUint8			iTSchedulerSpare1;
   711 	volatile TUint8	iNeedBal;
   532 	TUint8			iTSchedulerSpare2;
   712 
   533 
   713 	TUint32			iIdleGenerationCount;		// Incremented each time iIdleDfcs list is spilled to a CPU IDFC queue
   534 	TUint32			iIdleGenerationCount;		// Incremented each time iIdleDfcs list is spilled to a CPU IDFC queue
   714 	TDfcQue*		iRebalanceDfcQ;
   535 	TUint32			i_Scheduler_Padding[3];
   715 
   536 
   716 	TSpinLock		iEnumerateLock;				// lock to protect iAllThreads, iAllGroups
   537 	// For EMI support - HOPEFULLY THIS CAN DIE
   717 	SIterDQ			iAllThreads;				// list of all nanokernel threads in order of creation
   538 	NThread* iSigma;	
   718 	SIterDQ			iAllGroups;					// list of all thread groups in order of creation
   539 	TDfc* iEmiDfc;
   719 	TSpinLock		iBalanceListLock;			// lock to protect iBalanceList
   540 	TUint32 iEmiMask;
   720 	TUint64			iLastBalanceTime;			// time at which last rebalance occurred
   541 	TUint32 iEmiState;
   721 	SDblQue			iBalanceList;				// list of threads/groups for load balancing
   542 	TUint32 iEmiDfcTrigger;
   722 	NTimer			iBalanceTimer;				// triggers periodic rebalancing
   543 	TBool iLogging;
   723 	TDfc			iCCSyncIDFC;				// runs when a change to iThreadAcceptCpus has been observed by all CPUs
   544 	TAny* iBufferStart;
   724 	TDfc			iCCReactivateDfc;			// runs when a reschedule IPI is targeted to an inactive CPU
   545 	TAny* iBufferEnd;
   725 
   546 	TAny* iBufferTail;
   726 	TUint32			iCCRequestLevel;			// Number of active cores last requested
   547 	TAny* iBufferHead;
   727 	volatile TUint32 iCCIpiReactivate;			// Cores to be woken up because of IPIs
       
   728 
       
   729 	TDfc			iCCRequestDfc;				// runs when a request is made to change the number of active cores
       
   730 	TDfc			iCCPowerDownDfc;			// runs when indirect power down of core(s) is required
       
   731 	TDfc			iCCIpiReactIDFC;			// runs when an IPI needs to wake up a core
       
   732 	TDfc			iFreqChgDfc;				// runs when frequency changes required
       
   733 
       
   734 	TSubScheduler*	iPoweringOff;				// CPU last to power off
       
   735 	TUint32			iDetachCount;				// detach count before power off
       
   736 
       
   737 	SVariantInterfaceBlock* iVIB;
       
   738 	TUint32			i_Scheduler_Padding[29];
       
   739 	};
   548 	};
   740 
   549 
   741 __ASSERT_COMPILE(!(_FOFF(TScheduler,iGenIPILock)&7));
       
   742 __ASSERT_COMPILE(!(_FOFF(TScheduler,iIdleSpinLock)&7));
   550 __ASSERT_COMPILE(!(_FOFF(TScheduler,iIdleSpinLock)&7));
   743 __ASSERT_COMPILE(!(_FOFF(TScheduler,iIdleBalanceLock)&7));
   551 __ASSERT_COMPILE(sizeof(TScheduler)==512);
   744 __ASSERT_COMPILE(!(_FOFF(TScheduler,iEnumerateLock)&7));
       
   745 __ASSERT_COMPILE(!(_FOFF(TScheduler,iBalanceListLock)&7));
       
   746 __ASSERT_COMPILE(sizeof(TSchedulerX)==32*4);
       
   747 __ASSERT_COMPILE(sizeof(TScheduler)==1024);
       
   748 
   552 
   749 extern TScheduler TheScheduler;
   553 extern TScheduler TheScheduler;
   750 extern TSubScheduler TheSubSchedulers[KMaxCpus];
   554 extern TSubScheduler TheSubSchedulers[KMaxCpus];
   751 
   555 
   752 #ifdef __USE_BTRACE_LOCK__
   556 #ifdef __USE_BTRACE_LOCK__
   768 extern "C" TSubScheduler& SubScheduler();
   572 extern "C" TSubScheduler& SubScheduler();
   769 
   573 
   770 /**
   574 /**
   771 @internalComponent
   575 @internalComponent
   772 */
   576 */
       
   577 extern "C" void send_resched_ipis(TUint32 aMask);
       
   578 
       
   579 /**
       
   580 @internalComponent
       
   581 */
   773 extern "C" void send_resched_ipi(TInt aCpu);
   582 extern "C" void send_resched_ipi(TInt aCpu);
   774 
   583 
   775 /**
   584 /**
   776 @internalComponent
   585 @internalComponent
   777 */
   586 */
   778 extern "C" void send_resched_ipi_and_wait(TInt aCpu);
   587 extern "C" void send_resched_ipi_and_wait(TInt aCpu);
       
   588 
       
   589 
       
   590 #include <nk_plat.h>
   779 
   591 
   780 /**
   592 /**
   781 Call with kernel locked
   593 Call with kernel locked
   782 
   594 
   783 @internalComponent
   595 @internalComponent
   803 inline TBool CheckCpuAgainstAffinity(TInt aCpu, TUint32 aAffinity)
   615 inline TBool CheckCpuAgainstAffinity(TInt aCpu, TUint32 aAffinity)
   804 	{
   616 	{
   805 	if (aAffinity & NTHREADBASE_CPU_AFFINITY_MASK)
   617 	if (aAffinity & NTHREADBASE_CPU_AFFINITY_MASK)
   806 		return aAffinity & (1<<aCpu);
   618 		return aAffinity & (1<<aCpu);
   807 	return aAffinity==(TUint32)aCpu;
   619 	return aAffinity==(TUint32)aCpu;
   808 	}
       
   809 
       
   810 /** @internalComponent */
       
   811 inline TBool CheckCpuAgainstAffinity(TInt aCpu, TUint32 aAffinity, TUint32 aActive)
       
   812 	{
       
   813 	if (aAffinity & NTHREADBASE_CPU_AFFINITY_MASK)
       
   814 		return aActive & aAffinity & (1<<aCpu);
       
   815 	return (aAffinity==(TUint32)aCpu) && (aActive & (1<<aCpu));
       
   816 	}
       
   817 
       
   818 /** @internalComponent */
       
   819 inline TUint32 AffinityToMask(TUint32 aAffinity)
       
   820 	{
       
   821 	return (aAffinity & NTHREADBASE_CPU_AFFINITY_MASK) ? (aAffinity & ~NTHREADBASE_CPU_AFFINITY_MASK) : (1u<<aAffinity);
       
   822 	}
   620 	}
   823 
   621 
   824 /**
   622 /**
   825 @internalComponent
   623 @internalComponent
   826 */
   624 */
   894 	void Add(NTimer* aTimer);
   692 	void Add(NTimer* aTimer);
   895 	void AddFinal(NTimer* aTimer);
   693 	void AddFinal(NTimer* aTimer);
   896 public:
   694 public:
   897 	STimerQ			iTickQ[ENumTimerQueues];	/**< @internalComponent */	// NOTE: the order of member data is important
   695 	STimerQ			iTickQ[ENumTimerQueues];	/**< @internalComponent */	// NOTE: the order of member data is important
   898 	TUint32			iPresent;					/**< @internalComponent */	// The assembler code relies on it
   696 	TUint32			iPresent;					/**< @internalComponent */	// The assembler code relies on it
   899 
   697 	TUint32			iMsCount;					/**< @internalComponent */
   900 	/**
       
   901 	This member is intended for use by ASSP/variant interrupt code as a convenient
       
   902 	location to store the value of a free running counter at the point where the
       
   903 	system tick is started.
       
   904 	@publishedPartner
       
   905 	@prototype
       
   906 	*/
       
   907 	TUint32			iFRCOffset;
       
   908 
       
   909 	union {
       
   910 		TUint32			iMsCount;				/**< @internalComponent */
       
   911 		TUint64			iMsCount64;				/**< @internalComponent */
       
   912 		};
       
   913 	SDblQue			iHoldingQ;					/**< @internalComponent */
   698 	SDblQue			iHoldingQ;					/**< @internalComponent */
   914 	SDblQue			iOrderedQ;					/**< @internalComponent */
   699 	SDblQue			iOrderedQ;					/**< @internalComponent */
   915 	SDblQue			iCompletedQ;				/**< @internalComponent */
   700 	SDblQue			iCompletedQ;				/**< @internalComponent */
   916 	TDfc			iDfc;						/**< @internalComponent */
   701 	TDfc			iDfc;						/**< @internalComponent */
   917 	TUint8			iTransferringCancelled;		/**< @internalComponent */
   702 	TUint8			iTransferringCancelled;		/**< @internalComponent */
   966 
   751 
   967 
   752 
   968 /**
   753 /**
   969 @internalComponent
   754 @internalComponent
   970 */
   755 */
       
   756 class TGenIPIList : public SDblQue
       
   757 	{
       
   758 public:
       
   759 	TGenIPIList();
       
   760 public:
       
   761 	TSpinLock			iGenIPILock;
       
   762 	};
       
   763 
       
   764 /**
       
   765 @internalComponent
       
   766 */
   971 class TCancelIPI : public TGenericIPI
   767 class TCancelIPI : public TGenericIPI
   972 	{
   768 	{
   973 public:
   769 public:
   974 	void Send(TDfc* aDfc, TInt aCpu);
   770 	void Send(TDfc* aDfc, TInt aCpu);
   975 	static void Isr(TGenericIPI*);
   771 	static void Isr(TGenericIPI*);
   999 #ifdef _DEBUG
   795 #ifdef _DEBUG
  1000 
   796 
  1001 /**
   797 /**
  1002 @internalComponent
   798 @internalComponent
  1003 */
   799 */
  1004 #define	MASK_NO_FAST_MUTEX			0x1
   800 #define MASK_NO_FAST_MUTEX 0x1
  1005 #define	MASK_CRITICAL				0x2
   801 #define MASK_CRITICAL 0x2
  1006 #define	MASK_NO_CRITICAL			0x4
   802 #define MASK_NO_CRITICAL 0x4
  1007 #define	MASK_KERNEL_LOCKED			0x8
   803 #define MASK_KERNEL_LOCKED 0x8
  1008 #define	MASK_KERNEL_UNLOCKED		0x10
   804 #define MASK_KERNEL_UNLOCKED 0x10
  1009 #define	MASK_KERNEL_LOCKED_ONCE		0x20
   805 #define MASK_KERNEL_LOCKED_ONCE 0x20
  1010 #define	MASK_INTERRUPTS_ENABLED		0x40
   806 #define MASK_INTERRUPTS_ENABLED 0x40
  1011 #define	MASK_INTERRUPTS_DISABLED	0x80
   807 #define MASK_INTERRUPTS_DISABLED 0x80
  1012 #define	MASK_SYSTEM_LOCKED			0x100
   808 #define MASK_SYSTEM_LOCKED 0x100
  1013 #define	MASK_NOT_ISR				0x400
   809 #define MASK_NOT_ISR 0x400
  1014 #define	MASK_NOT_IDFC				0x800 
   810 #define MASK_NOT_IDFC 0x800 
  1015 #define	MASK_NOT_THREAD				0x1000
   811 #define MASK_NOT_THREAD 0x1000
  1016 #define	MASK_NO_CRITICAL_IF_USER	0x2000
   812 #define MASK_NO_CRITICAL_IF_USER 0x2000
  1017 #define	MASK_ALWAYS_FAIL			0x4000
   813 #define MASK_ALWAYS_FAIL 0x4000
  1018 #define	MASK_NO_RESCHED				0x8000
   814 #define	MASK_NO_RESCHED 0x8000
  1019 #define	MASK_NO_KILL_OR_SUSPEND		0x10000
   815 #define MASK_NO_KILL_OR_SUSPEND	0x10000
  1020 #define	MASK_THREAD_STANDARD		( MASK_NO_FAST_MUTEX | MASK_KERNEL_UNLOCKED | MASK_INTERRUPTS_ENABLED | MASK_NOT_ISR | MASK_NOT_IDFC )
   816 
  1021 #define	MASK_THREAD_CRITICAL		( MASK_THREAD_STANDARD | MASK_CRITICAL )
   817 #define MASK_THREAD_STANDARD ( MASK_NO_FAST_MUTEX | MASK_KERNEL_UNLOCKED | MASK_INTERRUPTS_ENABLED | MASK_NOT_ISR | MASK_NOT_IDFC )
       
   818 #define MASK_THREAD_CRITICAL ( MASK_THREAD_STANDARD | MASK_CRITICAL )
  1022 
   819 
  1023 #if defined(__STANDALONE_NANOKERNEL__) || (!defined (__KERNEL_APIS_CONTEXT_CHECKS_WARNING__)&&!defined (__KERNEL_APIS_CONTEXT_CHECKS_FAULT__))
   820 #if defined(__STANDALONE_NANOKERNEL__) || (!defined (__KERNEL_APIS_CONTEXT_CHECKS_WARNING__)&&!defined (__KERNEL_APIS_CONTEXT_CHECKS_FAULT__))
  1024 #define CHECK_PRECONDITIONS(mask,function)
   821 #define CHECK_PRECONDITIONS(mask,function)
  1025 #define __ASSERT_WITH_MESSAGE_DEBUG(cond,message,function)
   822 #define __ASSERT_WITH_MESSAGE_DEBUG(cond,message,function)
  1026 
   823