kernel/eka/include/nkernsmp/nkern.h
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
equal deleted inserted replaced
43:c1f20ce4abcf 44:3e88ff8f41d5
    35 
    35 
    36 extern "C" {
    36 extern "C" {
    37 /** @internalComponent */
    37 /** @internalComponent */
    38 IMPORT_C void NKFault(const char* file, TInt line);
    38 IMPORT_C void NKFault(const char* file, TInt line);
    39 /** @internalComponent */
    39 /** @internalComponent */
    40 void NKIdle(TUint32 aStage);
    40 void NKIdle(TInt aStage);
    41 }
    41 }
    42 
    42 
    43 /**
    43 /**
    44 @publishedPartner
    44 @publishedPartner
    45 @released
    45 @released
   142 		EOrderReadyList			=0x88u,		// Per-CPU ready list lock
   142 		EOrderReadyList			=0x88u,		// Per-CPU ready list lock
   143 		EOrderThreadGroup		=0x90u,		// Thread group locks
   143 		EOrderThreadGroup		=0x90u,		// Thread group locks
   144 		EOrderThread			=0x91u,		// Thread locks
   144 		EOrderThread			=0x91u,		// Thread locks
   145 		EOrderFastMutex			=0x98u,		// Fast mutex locks
   145 		EOrderFastMutex			=0x98u,		// Fast mutex locks
   146 		EOrderEventHandlerTied	=0x9Cu,		// Event handler tied lock
   146 		EOrderEventHandlerTied	=0x9Cu,		// Event handler tied lock
   147 		EOrderEnumerate			=0x9Du,		// Thread/Group enumeration lists
       
   148 		EOrderGenericPreHigh0	=0x9Eu,		// Device driver spin locks, high range
   147 		EOrderGenericPreHigh0	=0x9Eu,		// Device driver spin locks, high range
   149 		EOrderGenericPreHigh1	=0x9Fu,		// Device driver spin locks, high range
   148 		EOrderGenericPreHigh1	=0x9Fu,		// Device driver spin locks, high range
   150 
   149 
   151 		EOrderNone				=0xFFu		// No order check required (e.g. for dynamic ordering)
   150 		EOrderNone				=0xFFu		// No order check required (e.g. for dynamic ordering)
   152 		};
   151 		};
   809 	TLinAddr iPreprocessHandler;	// used for handle lookups
   808 	TLinAddr iPreprocessHandler;	// used for handle lookups
   810 	SSlowExecEntry iEntries[1];		// first entry is for call number 0
   809 	SSlowExecEntry iEntries[1];		// first entry is for call number 0
   811 	};
   810 	};
   812 
   811 
   813 // Thread iAttributes Constants
   812 // Thread iAttributes Constants
   814 const TUint8 KThreadAttImplicitSystemLock=1;		/**< @internalComponent */
   813 const TUint8 KThreadAttImplicitSystemLock=1;	/**< @internalComponent */
   815 const TUint8 KThreadAttAddressSpace=2;				/**< @internalComponent */
   814 const TUint8 KThreadAttAddressSpace=2;			/**< @internalComponent */
   816 const TUint8 KThreadAttLoggable=4;					/**< @internalComponent */
   815 const TUint8 KThreadAttLoggable=4;				/**< @internalComponent */
   817 
   816 
   818 
   817 
   819 // Thread CPU
   818 // Thread CPU
   820 const TUint32 KCpuAffinityAny=0xffffffffu;			/**< @internalComponent */
   819 const TUint32 KCpuAffinityAny=0xffffffffu;		/**< @internalComponent */
   821 const TUint32 KCpuAffinityPref=0x40000000u;			/**< @internalComponent */
       
   822 const TUint32 KCpuAffinityTransient=0x20000000u;	/**< @internalComponent */
       
   823 
   820 
   824 /** Information needed for creating a nanothread.
   821 /** Information needed for creating a nanothread.
   825 
   822 
   826 	@publishedPartner
   823 	@publishedPartner
   827 	@prototype
   824 	@prototype
   850 	@prototype
   847 	@prototype
   851 */
   848 */
   852 struct SNThreadGroupCreateInfo
   849 struct SNThreadGroupCreateInfo
   853 	{
   850 	{
   854 	TUint32 iCpuAffinity;
   851 	TUint32 iCpuAffinity;
   855 	TDfc* iDestructionDfc;
       
   856 	};
   852 	};
   857 
   853 
   858 /**	Constant for use with NKern:: functions which release a fast mutex as well
   854 /**	Constant for use with NKern:: functions which release a fast mutex as well
   859 	as performing some other operations.
   855 	as performing some other operations.
   860 
   856 
   861 	@publishedPartner
   857 	@publishedPartner
   862 	@released
   858 	@released
   863 */
   859 */
   864 #define	SYSTEM_LOCK		(NFastMutex*)0
   860 #define	SYSTEM_LOCK		(NFastMutex*)0
   865 
   861 
       
   862 
   866 /** Idle handler function
   863 /** Idle handler function
   867 	Pointer to a function which is called whenever a CPU goes idle
   864 	Pointer to a function which is called whenever a CPU goes idle
   868 
   865 
   869 	@param	aPtr	The iPtr stored in the SCpuIdleHandler structure
   866 	@param	aPtr	The iPtr stored in the SCpuIdleHandler structure
   870 	@param	aStage	Bits 0-7 give a bitmask of CPUs now active, i.e. 0 means all processors now idle
   867 	@param	aStage	If positive, the number of processors still active
   871 					Bit 31 set indicates that the current core can now be powered down
   868 					If zero, indicates all processors are now idle
   872 					Bit 30 set indicates that other cores still remain to be retired
   869 					-1 indicates that postamble processing is required after waking up
   873 					Bit 29 set indicates that postamble processing is required after waking up
   870 
   874 	@param	aU		Points to some per-CPU uncached memory used for handshaking during power down/power up
   871 	@publishedPartner
   875 
   872 	@prototype
   876 	@internalComponent
   873 */
   877 */
   874 typedef void (*TCpuIdleHandlerFn)(TAny* aPtr, TInt aStage);
   878 typedef void (*TCpuIdleHandlerFn)(TAny* aPtr, TUint32 aStage, volatile TAny* aU);
       
   879 
   875 
   880 /** Idle handler structure
   876 /** Idle handler structure
   881 
   877 
   882 	@internalComponent
   878 	@publishedPartner
       
   879 	@prototype
   883 */
   880 */
   884 struct SCpuIdleHandler
   881 struct SCpuIdleHandler
   885 	{
   882 	{
   886 	/**
       
   887 	Defined flag bits in aStage parameter
       
   888 	*/
       
   889 	enum
       
   890 		{
       
   891 		EActiveCpuMask=0xFFu,
       
   892 		EPostamble=1u<<29,		// postamble needed
       
   893 		EMore=1u<<30,			// more cores still to be retired
       
   894 		ERetire=1u<<31,			// this core can now be retired
       
   895 		};
       
   896 
       
   897 	TCpuIdleHandlerFn	iHandler;
   883 	TCpuIdleHandlerFn	iHandler;
   898 	TAny*				iPtr;
   884 	TAny*				iPtr;
   899 	volatile TBool		iPostambleRequired;
   885 	volatile TBool		iPostambleRequired;
   900 	};
   886 	};
   901 
   887 
  1000 	IMPORT_C static TBool ThreadForceResume(NThread* aThread, NFastMutex* aMutex);
   986 	IMPORT_C static TBool ThreadForceResume(NThread* aThread, NFastMutex* aMutex);
  1001 	IMPORT_C static void ThreadRelease(NThread* aThread, TInt aReturnValue);
   987 	IMPORT_C static void ThreadRelease(NThread* aThread, TInt aReturnValue);
  1002 	IMPORT_C static void ThreadRelease(NThread* aThread, TInt aReturnValue, NFastMutex* aMutex);
   988 	IMPORT_C static void ThreadRelease(NThread* aThread, TInt aReturnValue, NFastMutex* aMutex);
  1003 	IMPORT_C static void ThreadSetPriority(NThread* aThread, TInt aPriority);
   989 	IMPORT_C static void ThreadSetPriority(NThread* aThread, TInt aPriority);
  1004 	IMPORT_C static void ThreadSetPriority(NThread* aThread, TInt aPriority, NFastMutex* aMutex);
   990 	IMPORT_C static void ThreadSetPriority(NThread* aThread, TInt aPriority, NFastMutex* aMutex);
  1005 	static void ThreadSetNominalPriority(NThread* aThread, TInt aPriority);
       
  1006 	IMPORT_C static void ThreadRequestSignal(NThread* aThread);
   991 	IMPORT_C static void ThreadRequestSignal(NThread* aThread);
  1007 	IMPORT_C static void ThreadRequestSignal(NThread* aThread, NFastMutex* aMutex);
   992 	IMPORT_C static void ThreadRequestSignal(NThread* aThread, NFastMutex* aMutex);
  1008 	IMPORT_C static void ThreadRequestSignal(NThread* aThread, TInt aCount);
   993 	IMPORT_C static void ThreadRequestSignal(NThread* aThread, TInt aCount);
  1009 	IMPORT_C static void ThreadKill(NThread* aThread);
   994 	IMPORT_C static void ThreadKill(NThread* aThread);
  1010 	IMPORT_C static void ThreadKill(NThread* aThread, NFastMutex* aMutex);
   995 	IMPORT_C static void ThreadKill(NThread* aThread, NFastMutex* aMutex);
  1026 	IMPORT_C static TUint64 ThreadCpuTime(NThread* aThread);							/**< @internalComponent */
  1011 	IMPORT_C static TUint64 ThreadCpuTime(NThread* aThread);							/**< @internalComponent */
  1027 	IMPORT_C static TUint32 CpuTimeMeasFreq();											/**< @internalComponent */
  1012 	IMPORT_C static TUint32 CpuTimeMeasFreq();											/**< @internalComponent */
  1028 	static TInt QueueUserModeCallback(NThreadBase* aThread, TUserModeCallback* aCallback);	/**< @internalComponent */
  1013 	static TInt QueueUserModeCallback(NThreadBase* aThread, TUserModeCallback* aCallback);	/**< @internalComponent */
  1029 	static void MoveUserModeCallbacks(NThreadBase* aSrcThread, NThreadBase* aDestThread);	/**< @internalComponent */
  1014 	static void MoveUserModeCallbacks(NThreadBase* aSrcThread, NThreadBase* aDestThread);	/**< @internalComponent */
  1030 	static void CancelUserModeCallbacks();												/**< @internalComponent */
  1015 	static void CancelUserModeCallbacks();												/**< @internalComponent */
  1031 	static void JumpTo(TInt aCpu);														/**< @internalComponent */
       
  1032 
  1016 
  1033 	// Thread Groups
  1017 	// Thread Groups
  1034 	IMPORT_C static TInt GroupCreate(NThreadGroup* aGroup, SNThreadGroupCreateInfo& aInfo);
  1018 	IMPORT_C static TInt GroupCreate(NThreadGroup* aGroup, SNThreadGroupCreateInfo& aInfo);
  1035 	IMPORT_C static void GroupDestroy(NThreadGroup* aGroup);
  1019 	IMPORT_C static void GroupDestroy(NThreadGroup* aGroup);
  1036 	IMPORT_C static NThreadGroup* CurrentGroup();
  1020 	IMPORT_C static NThreadGroup* CurrentGroup();
  1118 
  1102 
  1119 	// Miscellaneous
  1103 	// Miscellaneous
  1120 	IMPORT_C static NThread* CurrentThread();
  1104 	IMPORT_C static NThread* CurrentThread();
  1121 	IMPORT_C static TInt CurrentCpu();										/**< @internalComponent */
  1105 	IMPORT_C static TInt CurrentCpu();										/**< @internalComponent */
  1122 	IMPORT_C static TInt NumberOfCpus();									/**< @internalComponent */
  1106 	IMPORT_C static TInt NumberOfCpus();									/**< @internalComponent */
  1123 	IMPORT_C static void SetNumberOfActiveCpus(TInt aNumber);
       
  1124 	IMPORT_C static void LockSystem();
  1107 	IMPORT_C static void LockSystem();
  1125 	IMPORT_C static void UnlockSystem();
  1108 	IMPORT_C static void UnlockSystem();
  1126 	IMPORT_C static TBool FlashSystem();
  1109 	IMPORT_C static TBool FlashSystem();
  1127 	IMPORT_C static void WaitForAnyRequest();
  1110 	IMPORT_C static void WaitForAnyRequest();
  1128 	IMPORT_C static void Sleep(TUint32 aTime);
  1111 	IMPORT_C static void Sleep(TUint32 aTime);
  1145 	static void Init0(TAny* aVariantData);
  1128 	static void Init0(TAny* aVariantData);
  1146 	static void Init(NThread* aThread, SNThreadCreateInfo& aInfo);
  1129 	static void Init(NThread* aThread, SNThreadCreateInfo& aInfo);
  1147 	static TInt BootAP(volatile SAPBootInfo* aInfo);
  1130 	static TInt BootAP(volatile SAPBootInfo* aInfo);
  1148 	IMPORT_C static TBool KernelLocked(TInt aCount=0);						/**< @internalTechnology */
  1131 	IMPORT_C static TBool KernelLocked(TInt aCount=0);						/**< @internalTechnology */
  1149 	IMPORT_C static NFastMutex* HeldFastMutex();							/**< @internalTechnology */
  1132 	IMPORT_C static NFastMutex* HeldFastMutex();							/**< @internalTechnology */
  1150 	static void Idle();
  1133 	static void Idle();	
  1151 	static void DoIdle();
       
  1152 	IMPORT_C static SCpuIdleHandler* CpuIdleHandler();						/**< @internalTechnology */
  1134 	IMPORT_C static SCpuIdleHandler* CpuIdleHandler();						/**< @internalTechnology */
  1153 	static void NotifyCrash(const TAny* a0, TInt a1);						/**< @internalTechnology */
  1135 	static void NotifyCrash(const TAny* a0, TInt a1);						/**< @internalTechnology */
  1154 	IMPORT_C static TBool Crashed();
  1136 	IMPORT_C static TBool Crashed();
  1155 	static TUint32 IdleGenerationCount();
  1137 	static TUint32 IdleGenerationCount();
  1156 
  1138 
  1241 @internalComponent
  1223 @internalComponent
  1242 */
  1224 */
  1243 class TStopIPI : public TGenericIPI
  1225 class TStopIPI : public TGenericIPI
  1244 	{
  1226 	{
  1245 public:
  1227 public:
  1246 	TUint32 StopCPUs();
  1228 	void StopCPUs();
  1247 	void ReleaseCPUs();
  1229 	void ReleaseCPUs();
  1248 	static void Isr(TGenericIPI*);
  1230 	static void Isr(TGenericIPI*);
  1249 public:
  1231 public:
  1250 	volatile TInt iFlag;
  1232 	volatile TInt iFlag;
  1251 	};
  1233 	};
  1252 
  1234 
  1253 
       
  1254 /**
       
  1255 @internalComponent
       
  1256 */
       
  1257 class TCoreCycler
       
  1258 	{
       
  1259 public:
       
  1260 	TCoreCycler();
       
  1261 	TInt Next();
       
  1262 private:
       
  1263 	void Init();
       
  1264 private:
       
  1265 	TUint32			iCores;
       
  1266 	TUint32			iRemain;
       
  1267 	TInt			iInitialCpu;
       
  1268 	TInt			iCurrentCpu;
       
  1269 	NThreadGroup*	iG;
       
  1270 	TInt			iFrz;
       
  1271 	};
       
  1272 
       
  1273 
       
  1274 
       
  1275 #include <ncern.h>
  1235 #include <ncern.h>
  1276 #endif
  1236 #endif