kernel/eka/include/u32std.h
changeset 0 a41df078684a
child 31 56f325a607ea
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1995-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\u32std.h
       
    15 //
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21  @released
       
    22 */
       
    23 
       
    24 #ifndef __U32STD_H__
       
    25 #define __U32STD_H__
       
    26 #include <e32cmn.h>
       
    27 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    28 #include <e32cmn_private.h>
       
    29 #endif
       
    30 #include <e32hal.h>
       
    31 #include <e32lmsg.h>
       
    32 #include <e32event.h>
       
    33 #include <e32ldr.h>
       
    34 #include <e32power.h>
       
    35 #include <e32shbufcmn.h>
       
    36 #include <e32property.h>
       
    37 #include <u32property.h>
       
    38 #include <u32hal.h>
       
    39 
       
    40 #include <cpudefs.h>
       
    41 
       
    42 #ifdef __MARM__
       
    43 #define	EKA2_ENTRY_POINT_VERSION_IDENTIFIER	\
       
    44 	asm("tst pc, #%a0" : : "i" ((TInt)0) )
       
    45 #endif
       
    46 
       
    47 struct TUnicodeDataSet;                 // forward declaration
       
    48 struct TCollationDataSet;               // forward declaration
       
    49 
       
    50 /*
       
    51 The LCharSet structure is used in Unicode builds to supply locale-specific
       
    52 character attribute and collation data.
       
    53 
       
    54 The structure is defined in both builds to avoid having to have a dummy ExecHandler::GetLocaleCharSet function
       
    55 with a different signature in the 8-bit build.
       
    56 */
       
    57 struct LCharSet
       
    58 	{
       
    59 	const TUnicodeDataSet* iCharDataSet;			// if non-null, character data overriding standard Unicode data
       
    60 	const TCollationDataSet* iCollationDataSet;		// if non-null, locale-specific collation data
       
    61 	};
       
    62 
       
    63 extern const LCharSet* GetLocaleCharSet();
       
    64 
       
    65 /** @internalTechnology */
       
    66 const TInt KNumLocaleExports = 22;
       
    67 
       
    68 //
       
    69 // The bits in the type table (non-Unicode build only)
       
    70 //
       
    71 #ifndef _UNICODE
       
    72 
       
    73 /** @internalTechnology */
       
    74 const TUint __U=0x01; // Uppercase letter
       
    75 
       
    76 /** @internalTechnology */
       
    77 const TUint __L=0x02; // Lowercase letter
       
    78 
       
    79 /** @internalTechnology */
       
    80 const TUint __D=0x04; // Decimal digit
       
    81 
       
    82 /** @internalTechnology */
       
    83 const TUint __S=0x08; // Space
       
    84 
       
    85 /** @internalTechnology */
       
    86 const TUint __P=0x10; // Punctuation
       
    87 
       
    88 /** @internalTechnology */
       
    89 const TUint __C=0x20; // Control character
       
    90 
       
    91 /** @internalTechnology */
       
    92 const TUint __X=0x40; // Hex digit
       
    93 
       
    94 /** @internalTechnology */
       
    95 const TUint __B=0x80; // A blank character
       
    96 
       
    97 #endif
       
    98 
       
    99 //
       
   100 // Time set mode parameters for setting system time and offset
       
   101 //
       
   102 enum TTimeSetMode
       
   103 	{
       
   104 	ETimeSetTime = 1,    // set the time to the value given, else leave it unchanged
       
   105 	ETimeSetOffset = 2,  // set the offset to the value given, else leave it unchanged
       
   106 	ETimeSetAllowTimeReversal = 4,  // allow time to go backwards
       
   107 	ETimeSetNoTimeUpdate = 8,       // Don't restart second queue or notify changes - not valid with ESetTime, used early in boot only
       
   108 	ETimeSetLocalTime = 16,			// Set time in local time, instead of UTC
       
   109 	ETimeSetSecure = 32,  // use when setting the secure hardware clock
       
   110 	};
       
   111 
       
   112 //
       
   113 enum TMatchType {EMatchNormal,EMatchFolded,EMatchCollated};
       
   114 
       
   115 //
       
   116 // Constants for descriptor implementation code
       
   117 //
       
   118 enum TDesType {EBufC,EPtrC,EPtr,EBuf,EBufCPtr};
       
   119 const TUint KMaskDesLength=0xfffffff;
       
   120 const TInt KShiftDesType=28;
       
   121 
       
   122 //
       
   123 // Constants for iFlags in DProcess and DThread
       
   124 //
       
   125 const TUint KThreadFlagProcessCritical		= 0x00000001;	// thread panic panics process
       
   126 const TUint KThreadFlagProcessPermanent		= 0x00000002;	// thread exit of any kind causes process to exit (=main)
       
   127 const TUint KThreadFlagSystemCritical		= 0x00000004;	// thread panic reboots entire system
       
   128 const TUint KThreadFlagSystemPermanent		= 0x00000008;	// thread exit of any kind reboots entire system
       
   129 const TUint KThreadFlagOriginal				= 0x00000010;
       
   130 const TUint KThreadFlagLastChance			= 0x00000020;
       
   131 const TUint KThreadFlagRealtime				= 0x00000040;	// thread will be panicked when using some non-realtime functions
       
   132 const TUint KThreadFlagRealtimeTest			= 0x00000080;	// non-realtime functions only warn rather than panic
       
   133 const TUint KThreadFlagLocalThreadDataValid	= 0x00000100;	// thread has valid local thread data
       
   134 const TUint KProcessFlagPriorityControl		= 0x40000000;
       
   135 const TUint KProcessFlagJustInTime			= 0x80000000;
       
   136 const TUint KProcessFlagSystemCritical		= KThreadFlagSystemCritical;	// process panic reboots entire system
       
   137 const TUint KProcessFlagSystemPermanent		= KThreadFlagSystemPermanent;	// process exit of any kind reboots entire system
       
   138 //
       
   139 const TUint KThreadHandle=0x40000000;
       
   140 //
       
   141 struct SPtrC8 {TInt length;const TUint8 *ptr;};
       
   142 struct SBufC8 {TInt length;TUint8 buf[1];};
       
   143 struct SPtr8 {TInt length;TInt maxLength;TUint8 *ptr;};
       
   144 struct SBuf8 {TInt length;TInt maxLength;TUint8 buf[1];};
       
   145 struct SBufCPtr8 {TInt length;TInt maxLength;SBufC8 *ptr;};
       
   146 
       
   147 struct SPtrC16 {TInt length;const TUint16 *ptr;};
       
   148 struct SBufC16 {TInt length;TUint16 buf[1];};
       
   149 struct SPtr16 {TInt length;TInt maxLength;TUint16 *ptr;};
       
   150 struct SBuf16 {TInt length;TInt maxLength;TUint16 buf[1];};
       
   151 struct SBufCPtr16 {TInt length;TInt maxLength;SBufC16 *ptr;};
       
   152 
       
   153 //
       
   154 // Flags used for IPC copy functions
       
   155 //
       
   156 const TInt KChunkShiftBy0=0;
       
   157 const TInt KChunkShiftBy1=KMinTInt;
       
   158 const TInt KIpcDirRead=0;
       
   159 const TInt KIpcDirWrite=0x10000000;
       
   160 
       
   161 class TChunkCreate
       
   162 	{
       
   163 public:
       
   164 	// Attributes for chunk creation that are used by both euser and the kernel
       
   165 	// by classes TChunkCreateInfo and SChunkCreateInfo, respectively.
       
   166 	enum TChunkCreateAtt
       
   167 		{
       
   168 		ENormal				= 0x00000000,
       
   169 		EDoubleEnded		= 0x00000001,
       
   170 		EDisconnected		= 0x00000002,
       
   171 		ECache				= 0x00000003,
       
   172 		EMappingMask		= 0x0000000f,
       
   173 		ELocal				= 0x00000000,
       
   174 		EGlobal				= 0x00000010,
       
   175 		EData				= 0x00000000,
       
   176 		ECode				= 0x00000020,
       
   177 		EMemoryNotOwned		= 0x00000040,
       
   178 
       
   179 		// Force local chunk to be named.  Only required for thread heap
       
   180 		// chunks, all other local chunks should be nameless.
       
   181 		ELocalNamed 		= 0x000000080,
       
   182 
       
   183 		// Paging attributes for chunks.
       
   184 		EPagingUnspec		= 0x00000000,
       
   185 		EPaged				= 0x80000000,
       
   186 		EUnpaged			= 0x40000000,
       
   187 		EPagingMask 		= EPaged | EUnpaged,
       
   188 
       
   189 		EChunkCreateAttMask =	EMappingMask | EGlobal | ECode |
       
   190 								ELocalNamed | EPagingMask,
       
   191 		};
       
   192 public:
       
   193 	TUint iAtt;
       
   194 	TBool iForceFixed;
       
   195 	TInt iInitialBottom;
       
   196 	TInt iInitialTop;
       
   197 	TInt iMaxSize;
       
   198 	TUint8 iClearByte;
       
   199 	};
       
   200 
       
   201 enum TChunkRestrictions
       
   202 	{
       
   203 	// Keep this in sync with definitions in RChunk
       
   204 	EChunkPreventAdjust = 0x01,  // Disallow Adjust, Commit, Allocate and Decommit
       
   205 	};
       
   206 
       
   207 class TChannelDoCreate
       
   208 	{
       
   209 public:
       
   210 	TVersion iVer;
       
   211 	const TDesC *iName;
       
   212 	const TDesC *iPhysicalDevice;
       
   213 	const TDesC8 *iInfo;
       
   214 	};
       
   215 
       
   216 class TCreateSession
       
   217 	{
       
   218 public:
       
   219 	TVersion iVer;
       
   220 	TInt iMessageSlots;
       
   221 	};
       
   222 
       
   223 enum TObjectType
       
   224 	{
       
   225 	EThread=0,
       
   226 	EProcess,
       
   227 	EChunk,
       
   228 	ELibrary,
       
   229 	ESemaphore,
       
   230 	EMutex,
       
   231 	ETimer,
       
   232 	EServer,
       
   233 	ESession,
       
   234 	ELogicalDevice,
       
   235 	EPhysicalDevice,
       
   236 	ELogicalChannel,
       
   237 	EChangeNotifier,
       
   238 	EUndertaker,
       
   239 	EMsgQueue,
       
   240 	EPropertyRef,
       
   241 	ECondVar,
       
   242 	EShPool,
       
   243 	EShBuf,
       
   244 	ENumObjectTypes,	// number of DObject-derived types
       
   245 	EObjectTypeAny=-1,
       
   246 
       
   247 	EIpcMessageD=0x20,	// lookup IPC message handle, allow disconnect
       
   248 	EIpcMessage=0x21,	// lookup IPC message handle, don't allow disconnect
       
   249 	EIpcClient=0x22,	// lookup IPC message client, don't allow disconnect
       
   250 	};
       
   251 
       
   252 class TObjectOpenInfo
       
   253 	{
       
   254 public:
       
   255 	TObjectType iObjType;
       
   256 	TBool isReadOnly;
       
   257 	};
       
   258 
       
   259 class TChannelCreateInfo
       
   260 	{
       
   261 public:
       
   262 	TVersion iVersion;
       
   263 	TInt iUnit;
       
   264 	const TDesC* iPhysicalDevice;
       
   265 	const TDesC8* iInfo;
       
   266 	};
       
   267 
       
   268 #if defined(_UNICODE) && !defined(__KERNEL_MODE__)
       
   269 class TChannelCreateInfo8
       
   270 	{
       
   271 public:
       
   272 	TVersion iVersion;
       
   273 	TInt iUnit;
       
   274 	const TDesC8* iPhysicalDevice;
       
   275 	const TDesC8* iInfo;
       
   276 	};
       
   277 #else
       
   278 typedef TChannelCreateInfo TChannelCreateInfo8;
       
   279 #endif
       
   280 
       
   281 const TInt KMaxThreadCreateInfo = 256;
       
   282 struct SThreadCreateInfo
       
   283 	{
       
   284 	TAny* iHandle;
       
   285 	TInt iType;
       
   286 	TThreadFunction iFunction;
       
   287 	TAny* iPtr;
       
   288 	TAny* iSupervisorStack;
       
   289 	TInt iSupervisorStackSize;
       
   290 	TAny* iUserStack;
       
   291 	TInt iUserStackSize;
       
   292 	TInt iInitialThreadPriority;
       
   293 	TPtrC iName;
       
   294 	TInt iTotalSize;	// Size including any extras (must be a multiple of 8 bytes)
       
   295 	};
       
   296 
       
   297 enum TThreadCreationFlags
       
   298 	{
       
   299 	ETraceHeapAllocs 				= 0x00000001,
       
   300 	EMonitorHeapMemory				= 0x00000002,
       
   301 
       
   302 	EThreadCreateFlagPaged			= 0x00000004,
       
   303 	EThreadCreateFlagUnpaged		= 0x00000008,
       
   304 	EThreadCreateFlagPagingUnspec	= 0x00000000,
       
   305 	EThreadCreateFlagPagingMask	= EThreadCreateFlagPaged | EThreadCreateFlagUnpaged,
       
   306 
       
   307 	EThreadCreateFlagMask = ETraceHeapAllocs | EMonitorHeapMemory | EThreadCreateFlagPagingMask,
       
   308 	};
       
   309 
       
   310 struct SStdEpocThreadCreateInfo : public SThreadCreateInfo
       
   311 	{
       
   312 	SStdEpocThreadCreateInfo()
       
   313 		: iFlags(0)	// Must be clear on creation.
       
   314 		{
       
   315 		};
       
   316 	RAllocator* iAllocator;
       
   317 	TInt iHeapInitialSize;
       
   318 	TInt iHeapMaxSize;
       
   319 	TUint iFlags;
       
   320 	};
       
   321 
       
   322 #if defined(_UNICODE) && !defined(__KERNEL_MODE__)
       
   323 struct SThreadCreateInfo8
       
   324 	{
       
   325 	TAny* iHandle;
       
   326 	TInt iType;
       
   327 	TThreadFunction iFunction;
       
   328 	TAny* iPtr;
       
   329 	TAny* iSupervisorStack;
       
   330 	TInt iSupervisorStackSize;
       
   331 	TAny* iUserStack;
       
   332 	TInt iUserStackSize;
       
   333 	TInt iInitialThreadPriority;
       
   334 	TPtrC8 iName;
       
   335 	TInt iTotalSize;	// size including any extras
       
   336 	};
       
   337 
       
   338 struct SStdEpocThreadCreateInfo8 : public SThreadCreateInfo8
       
   339 	{
       
   340 	SStdEpocThreadCreateInfo8()
       
   341 		: iFlags(0) // Must be clear on creation.
       
   342 		{
       
   343 		};
       
   344 	RAllocator* iAllocator;
       
   345 	TInt iHeapInitialSize;
       
   346 	TInt iHeapMaxSize;
       
   347 	TUint iFlags;
       
   348 	};
       
   349 #else
       
   350 typedef SThreadCreateInfo SThreadCreateInfo8;
       
   351 typedef SStdEpocThreadCreateInfo SStdEpocThreadCreateInfo8;
       
   352 #endif
       
   353 
       
   354 struct SIpcCopyInfo
       
   355 	{
       
   356 	TUint8* iLocalPtr;
       
   357 	TInt iLocalLen;
       
   358 	TInt iFlags;
       
   359 	};
       
   360 
       
   361 enum TChunkAdjust
       
   362 	{
       
   363 	EChunkAdjust=0,
       
   364 	EChunkAdjustDoubleEnded=1,
       
   365 	EChunkCommit=2,
       
   366 	EChunkDecommit=3,
       
   367 	EChunkAllocate=4,
       
   368 	EChunkUnlock=5,
       
   369 	EChunkLock=6
       
   370 	};
       
   371 
       
   372 enum TMemModelAttributes
       
   373 	{
       
   374 	EMemModelTypeMask=0xf,					// bottom 4 bits give type of memory model
       
   375 	EMemModelTypeDirect=0,					// direct memory model on hardware
       
   376 	EMemModelTypeMoving=1,					// moving memory model on hardware
       
   377 	EMemModelTypeMultiple=2,				// multiple memory model on hardware
       
   378 	EMemModelTypeEmul=3,					// emulation using single host process
       
   379 	EMemModelTypeFlexible=4,				// flexible memory model on hardware
       
   380 
       
   381 	EMemModelAttrRomPaging=0x10,			// Demand paging of XIP ROM
       
   382 	EMemModelAttrCodePaging=0x20,			// Demand paging of RAM loaded code
       
   383 	EMemModelAttrDataPaging=0x40,			// Demand paging of all RAM
       
   384 	EMemModelAttrPagingMask=0xf0,			// Mask for demand paging attributes
       
   385 
       
   386 	EMemModelAttrNonExProt=(TInt)0x80000000,// accesses to nonexistent addresses are trapped
       
   387 	EMemModelAttrKernProt=0x40000000,		// accesses to kernel memory from user mode are trapped
       
   388 	EMemModelAttrWriteProt=0x20000000,		// addresses can be marked as read-only; writes to these are trapped
       
   389 	EMemModelAttrVA=0x10000000,				// system supports virtual addresses
       
   390 	EMemModelAttrProcessProt=0x08000000,	// accesses to other processes' memory are trapped
       
   391 	EMemModelAttrSameVA=0x04000000,			// different processes map the same virtual address to different physical addresses
       
   392 	EMemModelAttrSupportFixed=0x02000000,	// 'fixed' processes are supported
       
   393 	EMemModelAttrSvKernProt=0x01000000,		// unexpected accesses to kernel memory within an executive call are trapped
       
   394 	EMemModelAttrIPCKernProt=0x00800000,	// accesses to kernel memory via IPC are trapped
       
   395 	EMemModelAttrIPCFullProt=0x00400000,	// accesses via IPC have same protection as user mode
       
   396 	EMemModelAttrRamCodeProt=0x00200000,	// RAM-loaded code is only visible to processes which have loaded it
       
   397 	};
       
   398 
       
   399 /** @test */
       
   400 enum TKernelHeapDebugFunction {EDbgMarkStart,EDbgMarkCheck,EDbgMarkEnd,EDbgSetAllocFail,EDbgSetBurstAllocFail,EDbgCheckFailure};
       
   401 
       
   402 /** @test */
       
   403 class TKernelHeapMarkCheckInfo
       
   404 	{
       
   405 public:
       
   406 	TBool iCountAll;
       
   407 	const TDesC8* iFileName;
       
   408 	TInt iLineNum;
       
   409 	};
       
   410 //
       
   411 class TTrapHandler;
       
   412 class CActiveScheduler;
       
   413 class TLocale;
       
   414 
       
   415 //
       
   416 //
       
   417 //
       
   418 // Handler below is used by test prints to trucate rather than panic the caller.
       
   419 //
       
   420 #if defined(_UNICODE) && !defined(__KERNEL_MODE__)
       
   421 NONSHARABLE_CLASS(TestOverflowTruncate) : public TDes16Overflow
       
   422 	{
       
   423 public:
       
   424 	virtual void Overflow(TDes16 &aDes);
       
   425 	};
       
   426 #else
       
   427 NONSHARABLE_CLASS(TestOverflowTruncate) : public TDes8Overflow
       
   428 	{
       
   429 public:
       
   430 	virtual void Overflow(TDes8 &aDes);
       
   431 	};
       
   432 #endif
       
   433 //
       
   434 
       
   435 /********************************************
       
   436  * Thread local storage entry
       
   437  ********************************************/
       
   438 struct STls
       
   439 	{
       
   440 	TInt	iHandle;
       
   441 	TInt	iDllUid;
       
   442 	TAny*	iPtr;
       
   443 	};
       
   444 
       
   445 const TInt KDllUid_Default = 0;		// for ROM DLLs and direct calls to UserSvr::DllTls
       
   446 const TInt KDllUid_Special = -1;	// used on emulator to instruct the kernel to get the DLL UID from the module handle
       
   447 
       
   448 /********************************************
       
   449  * Entry point call values
       
   450  ********************************************/
       
   451 const TInt	KModuleEntryReasonProcessInit		=0;		// Process start
       
   452 const TInt	KModuleEntryReasonThreadInit		=1;		// Start new thread
       
   453 const TInt	KModuleEntryReasonProcessAttach		=2;		// Process attach (init static data)
       
   454 const TInt	KModuleEntryReasonProcessDetach		=3;		// Process detach (destroy static data)
       
   455 const TInt	KModuleEntryReasonException			=4;		// Handle exception
       
   456 const TInt	KModuleEntryReasonVariantInit0		=-3;	// Call variant static constructors
       
   457 
       
   458 /** @publishedPartner
       
   459 	@released
       
   460 */
       
   461 const TInt	KModuleEntryReasonExtensionInit0	=-2;	// Extension early initialisation check
       
   462 
       
   463 /** @publishedPartner
       
   464 	@released
       
   465 */
       
   466 const TInt	KModuleEntryReasonExtensionInit1	=-1;	// Extension initialisation
       
   467 
       
   468 /**
       
   469 	Flags returned by Exec::KernelConfigFlags()
       
   470 */
       
   471 enum TKernelConfigFlags
       
   472 	{
       
   473 	EKernelConfigIpcV1Available = 1<<0,
       
   474 	EKernelConfigPlatSecEnforcement = 1<<1,
       
   475 	EKernelConfigPlatSecDiagnostics = 1<<2,
       
   476 	EKernelConfigPlatSecProcessIsolation = 1<<3,
       
   477 	EKernelConfigPlatSecEnforceSysBin = 1<<4,
       
   478 
       
   479 	// paging policy values use by 2-bit code and data paging policy enums...
       
   480 	EKernelConfigPagingPolicyNoPaging = 0,
       
   481 	EKernelConfigPagingPolicyAlwaysPage = 1,
       
   482 	EKernelConfigPagingPolicyDefaultUnpaged = 2,
       
   483 	EKernelConfigPagingPolicyDefaultPaged = 3,
       
   484 
       
   485 	EKernelConfigCodePagingPolicyShift			= 5,
       
   486 	EKernelConfigCodePagingPolicyMask			= 3<<5,
       
   487 	EKernelConfigCodePagingPolicyNoPaging		= EKernelConfigPagingPolicyNoPaging<<5,
       
   488 	EKernelConfigCodePagingPolicyAlwaysPage		= EKernelConfigPagingPolicyAlwaysPage<<5,
       
   489 	EKernelConfigCodePagingPolicyDefaultUnpaged	= EKernelConfigPagingPolicyDefaultUnpaged<<5,
       
   490 	EKernelConfigCodePagingPolicyDefaultPaged	= EKernelConfigPagingPolicyDefaultPaged<<5,
       
   491 
       
   492 	EKernelConfigPlatSecLocked = 1<<7,					// Primarily used by __PLATSEC_UNLOCKED__ (q.v.) test code
       
   493 
       
   494 	EKernelConfigCrazyScheduling = 1<<8,				// Enables thread priority/timeslice craziness
       
   495 
       
   496 	EKernelConfigDataPagingPolicyShift			= 9,
       
   497 	EKernelConfigDataPagingPolicyMask			= 3<<9,
       
   498 	EKernelConfigDataPagingPolicyNoPaging		= EKernelConfigPagingPolicyNoPaging<<9,
       
   499 	EKernelConfigDataPagingPolicyAlwaysPage		= EKernelConfigPagingPolicyAlwaysPage<<9,
       
   500 	EKernelConfigDataPagingPolicyDefaultUnpaged	= EKernelConfigPagingPolicyDefaultUnpaged<<9,
       
   501 	EKernelConfigDataPagingPolicyDefaultPaged	= EKernelConfigPagingPolicyDefaultPaged<<9,
       
   502 
       
   503 	EKernelConfigSMPUnsafeCompat = 1<<12,				// Enables compatibility mode for SMP-unsafe processes
       
   504 	EKernelConfigSMPUnsafeCPU0   = 1<<13,				// Slow compatibility mode: all SMP-unsafe processes run on CPU 0 only
       
   505 	EKernelConfigSMPCrazyInterrupts = 1<<14,			// Enables CPU target rotation for HW Interrupts.
       
   506 
       
   507 	EKernelConfigDisableAPs = 1u<<30,
       
   508 
       
   509 	EKernelConfigTest = 1u<<31,							// Only used by test code for __PLATSEC_UNLOCKED__
       
   510 	};
       
   511 
       
   512 /**
       
   513 	If __PLATSEC_UNLOCKED__ is not defined, these flags must always
       
   514 	be considered to be set.  See KernelConfigFlags() in kern_priv.h.
       
   515 
       
   516 	@see KernelConfigFlags()
       
   517 
       
   518 	@internalTechnology
       
   519 */
       
   520 #ifdef __PLATSEC_UNLOCKED__
       
   521 #define __PLATSEC_FORCED_FLAGS__	 0
       
   522 #else
       
   523 #define __PLATSEC_FORCED_FLAGS__	(EKernelConfigPlatSecEnforcement|EKernelConfigPlatSecProcessIsolation|EKernelConfigPlatSecEnforceSysBin)
       
   524 #endif
       
   525 
       
   526 /**
       
   527 @internalTechnology
       
   528 */
       
   529 enum TGlobalUserData
       
   530 	{
       
   531 	ELocaleDefaultCharSet,
       
   532 	ELocalePreferredCharSet,
       
   533 	EMaxGlobalUserData
       
   534 	};
       
   535 
       
   536 typedef void (*TGlobalDestructorFunc)(void);
       
   537 
       
   538 // This must not conflict with any possible valid TLS keys
       
   539 const TInt KGlobalDestructorTlsKey = -1;
       
   540 
       
   541 GLREF_C void ExitCurrentThread(TExitType, TInt, const TDesC8*);
       
   542 
       
   543 #ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
       
   544 /**
       
   545 @internalTechnology
       
   546 */
       
   547 class TPlatSecDiagnostic
       
   548 	{
       
   549 public:
       
   550 	enum TType
       
   551 		{
       
   552 		ELoaderCapabilityViolation1,
       
   553 		ELoaderCapabilityViolation2,
       
   554 		EThreadCapabilityCheckFail,
       
   555 		EProcessCapabilityCheckFail,
       
   556 		EKernelSecureIdCheckFail,
       
   557 		EKernelObjectPolicyCheckFail,
       
   558 		EHandleCapabilityCheckFail,
       
   559 		ECreatorCapabilityCheckFail,
       
   560 		EMessageCapabilityCheckFail,
       
   561 		EKernelProcessIsolationFail,
       
   562 		EKernelProcessIsolationIPCFail,
       
   563 		ECreatorPolicyCheckFail,
       
   564 		};
       
   565 public:
       
   566 	inline TPlatSecDiagnostic();
       
   567 	inline TPlatSecDiagnostic(TType aType);
       
   568 	inline TPlatSecDiagnostic(TType aType, TInt aInt1, TInt aInt2, const SCapabilitySet& aCaps);
       
   569 	inline TPlatSecDiagnostic(TType aType, TInt aInt1, const SSecurityInfo& aCaps);
       
   570 	inline TPlatSecDiagnostic(TType aType, TInt aInt, const TDesC8& aString, const SCapabilitySet& aCaps);
       
   571 	inline TPlatSecDiagnostic(TType aType, const TDesC8& aString1, const TDesC8& aString2, const SCapabilitySet& aCaps);
       
   572 	inline TPlatSecDiagnostic(TType aType, TInt aInt1, TInt aInt2);
       
   573 	inline TPlatSecDiagnostic(TType aType, TInt aInt1);
       
   574 	inline const TDesC8* String1();
       
   575 	inline const TDesC8* String2();
       
   576 public:
       
   577 	TType iType;
       
   578 	TInt iArg1;
       
   579 	TInt iArg2;
       
   580 	const char* iContextText;
       
   581 	TInt iContextTextLength;
       
   582 	SSecurityInfo iSecurityInfo;
       
   583 	};
       
   584 
       
   585 inline TPlatSecDiagnostic::TPlatSecDiagnostic()
       
   586 	{}
       
   587 
       
   588 inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType)
       
   589 	: iType(aType)
       
   590 	{}
       
   591 
       
   592 inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType,TInt aInt1)
       
   593 	: iType(aType), iArg1(aInt1)
       
   594 	{}
       
   595 
       
   596 inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType, TInt aInt1, TInt aInt2, const SCapabilitySet& aCaps)
       
   597 	: iType(aType), iArg1(aInt1), iArg2(aInt2), iContextText(0)
       
   598 	{
       
   599 	iSecurityInfo.iSecureId = 0;
       
   600 	iSecurityInfo.iVendorId = 0;
       
   601 	iSecurityInfo.iCaps = aCaps;
       
   602 	};
       
   603 inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType, TInt aInt1, const SSecurityInfo& aInfo)
       
   604 	: iType(aType), iArg1(aInt1), iArg2(ECapability_None), iContextText(0), iSecurityInfo(aInfo)
       
   605 	{
       
   606 	};
       
   607 
       
   608 inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType, TInt aInt, const TDesC8& aString, const SCapabilitySet& aCaps)
       
   609 	: iType(aType), iArg1(aInt), iArg2((TInt)&aString), iContextText(0)
       
   610 	{
       
   611 	iSecurityInfo.iSecureId = 0;
       
   612 	iSecurityInfo.iVendorId = 0;
       
   613 	iSecurityInfo.iCaps = aCaps;
       
   614 	};
       
   615 
       
   616 inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType, const TDesC8& aString1, const TDesC8& aString2, const SCapabilitySet& aCaps)
       
   617 	: iType(aType), iArg1((TInt)&aString1), iArg2((TInt)&aString2), iContextText(0)
       
   618 	{
       
   619 	iSecurityInfo.iSecureId = 0;
       
   620 	iSecurityInfo.iVendorId = 0;
       
   621 	iSecurityInfo.iCaps = aCaps;
       
   622 	};
       
   623 
       
   624 inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType, TInt aInt1, TInt aInt2)
       
   625 	: iType(aType), iArg1(aInt1), iArg2(aInt2)
       
   626 	{
       
   627 	iSecurityInfo.iSecureId = 0;
       
   628 	iSecurityInfo.iVendorId = 0;
       
   629 	iSecurityInfo.iCaps[0] = 0;
       
   630 	iSecurityInfo.iCaps[1] = 0;
       
   631 	};
       
   632 
       
   633 inline const TDesC8* TPlatSecDiagnostic::String1()
       
   634 	{ return (const TDesC8*)iArg1; }
       
   635 
       
   636 inline const TDesC8* TPlatSecDiagnostic::String2()
       
   637 	{ return (const TDesC8*)iArg2; }
       
   638 
       
   639 inline TInt PlatSec::LoaderCapabilityViolation(const TDesC8& aImporterName, const TDesC8& aFileName, const SCapabilitySet& aMissingCaps)
       
   640 	{
       
   641 	TPlatSecDiagnostic d(TPlatSecDiagnostic::ELoaderCapabilityViolation2,aImporterName,aFileName,aMissingCaps);
       
   642 	return EmitDiagnostic(d, NULL);
       
   643 	}
       
   644 
       
   645 #ifdef __KERNEL_MODE__
       
   646 
       
   647 inline TInt PlatSec::CapabilityCheckFail(const DProcess* aViolatingProcess, TCapability aCapability, const char* aContextText)
       
   648 	{
       
   649 	TPlatSecDiagnostic d(TPlatSecDiagnostic::EProcessCapabilityCheckFail,(TInt)aViolatingProcess,(TInt)aCapability);
       
   650 	return EmitDiagnostic(d,aContextText);
       
   651 	}
       
   652 
       
   653 inline TInt PlatSec::CapabilityCheckFail(const DThread* aViolatingThread, TCapability aCapability, const char* aContextText)
       
   654 	{
       
   655 	TPlatSecDiagnostic d(TPlatSecDiagnostic::EThreadCapabilityCheckFail,(TInt)aViolatingThread,(TInt)aCapability);
       
   656 	return EmitDiagnostic(d,aContextText);
       
   657 	}
       
   658 
       
   659 inline TInt PlatSec::SecureIdCheckFail(const DProcess* aViolatingProcess, TSecureId aSid, const char* aContextText)
       
   660 	{
       
   661 	TPlatSecDiagnostic d(TPlatSecDiagnostic::EKernelSecureIdCheckFail,(TInt)aViolatingProcess,(TInt)aSid);
       
   662 	return EmitDiagnostic(d,aContextText);
       
   663 	}
       
   664 
       
   665 inline TInt PlatSec::PolicyCheckFail(const DProcess* aProcess, const SSecurityInfo& aMissingSecurityInfo, const char* aContextText)
       
   666 	{
       
   667 	TPlatSecDiagnostic d(TPlatSecDiagnostic::EKernelObjectPolicyCheckFail,(TInt)aProcess,(const SSecurityInfo&)aMissingSecurityInfo);
       
   668 	return EmitDiagnostic(d,aContextText);
       
   669 	}
       
   670 
       
   671 inline TInt PlatSec::PolicyCheckFail(const DThread* aThread, const SSecurityInfo& aMissingSecurityInfo, const char* aContextText)
       
   672 	{
       
   673 	TPlatSecDiagnostic d(TPlatSecDiagnostic::EKernelObjectPolicyCheckFail,(TInt)aThread,(const SSecurityInfo&)aMissingSecurityInfo);
       
   674 	return EmitDiagnostic(d,aContextText);
       
   675 	}
       
   676 
       
   677 inline TInt PlatSec::ProcessIsolationFail(const char* aContextText)
       
   678 	{
       
   679 	TPlatSecDiagnostic d(TPlatSecDiagnostic::EKernelProcessIsolationFail);
       
   680 	return EmitDiagnostic(d,aContextText);
       
   681 	}
       
   682 
       
   683 inline TInt PlatSec::ProcessIsolationIPCFail(RMessageK* aMessage, const char* aContextText)
       
   684 	{
       
   685 	TPlatSecDiagnostic d(TPlatSecDiagnostic::EKernelProcessIsolationIPCFail,(TInt)aMessage);
       
   686 	return EmitDiagnostic(d,aContextText);
       
   687 	}
       
   688 
       
   689 #else // !__KERNEL_MODE__
       
   690 
       
   691 inline TInt PlatSec::LoaderCapabilityViolation(RProcess aLoadingProcess, const TDesC8& aFileName, const SCapabilitySet& aMissingCaps)
       
   692 	{
       
   693 	TPlatSecDiagnostic d(TPlatSecDiagnostic::ELoaderCapabilityViolation1,aLoadingProcess.Handle(),aFileName,aMissingCaps);
       
   694 	return EmitDiagnostic(d, NULL);
       
   695 	}
       
   696 
       
   697 inline TInt PlatSec::CreatorCapabilityCheckFail(TCapability aCapability, const char* aContextText)
       
   698 	{
       
   699 	TPlatSecDiagnostic d(TPlatSecDiagnostic::ECreatorCapabilityCheckFail,(TInt)0,aCapability);
       
   700 	return EmitDiagnostic(d,aContextText);
       
   701 	}
       
   702 
       
   703 inline TInt PlatSec::CreatorCapabilityCheckFail(const TCapabilitySet& aMissingCaps, const char* aContextText)
       
   704 	{
       
   705 	TPlatSecDiagnostic d(TPlatSecDiagnostic::ECreatorCapabilityCheckFail,(TInt)0,ECapability_None,(const SCapabilitySet&)aMissingCaps);
       
   706 	return EmitDiagnostic(d,aContextText);
       
   707 	}
       
   708 
       
   709 inline TInt PlatSec::CapabilityCheckFail(TInt aHandle, TCapability aCapability, const char* aContextText)
       
   710 	{
       
   711 	TPlatSecDiagnostic d(TPlatSecDiagnostic::EHandleCapabilityCheckFail,aHandle,aCapability);
       
   712 	return EmitDiagnostic(d,aContextText);
       
   713 	}
       
   714 
       
   715 inline TInt PlatSec::CapabilityCheckFail(TInt aHandle, const TCapabilitySet& aMissingCaps, const char* aContextText)
       
   716 	{
       
   717 	TPlatSecDiagnostic d(TPlatSecDiagnostic::EHandleCapabilityCheckFail,aHandle,ECapability_None,(const SCapabilitySet&)aMissingCaps);
       
   718 	return EmitDiagnostic(d,aContextText);
       
   719 	}
       
   720 
       
   721 inline TInt PlatSec::PolicyCheckFail(TInt aHandle, const SSecurityInfo& aMissingSecurityInfo, const char* aContextText)
       
   722 	{
       
   723 	TPlatSecDiagnostic d(TPlatSecDiagnostic::EHandleCapabilityCheckFail,aHandle,(const SSecurityInfo&)aMissingSecurityInfo);
       
   724 	return EmitDiagnostic(d,aContextText);
       
   725 	}
       
   726 
       
   727 inline TInt PlatSec::CapabilityCheckFail(RMessagePtr2 aMessage, TCapability aCapability, const char* aContextText)
       
   728 	{
       
   729 	TPlatSecDiagnostic d(TPlatSecDiagnostic::EMessageCapabilityCheckFail,(TInt)aMessage.Handle(),aCapability);
       
   730 	return EmitDiagnostic(d,aContextText);
       
   731 	}
       
   732 
       
   733 inline TInt PlatSec::CapabilityCheckFail(RMessagePtr2 aMessage, const TCapabilitySet& aMissingCaps, const char* aContextText)
       
   734 	{
       
   735 	TPlatSecDiagnostic d(TPlatSecDiagnostic::EMessageCapabilityCheckFail,(TInt)aMessage.Handle(),ECapability_None,(const SCapabilitySet&)aMissingCaps);
       
   736 	return EmitDiagnostic(d,aContextText);
       
   737 	}
       
   738 
       
   739 inline TInt PlatSec::PolicyCheckFail(RMessagePtr2 aMessage, const SSecurityInfo& aMissing, const char* aContextText)
       
   740 	{
       
   741 	TPlatSecDiagnostic d(TPlatSecDiagnostic::EMessageCapabilityCheckFail,(TInt)aMessage.Handle(),(const SSecurityInfo&)aMissing);
       
   742 	return EmitDiagnostic(d,aContextText);
       
   743 	}
       
   744 
       
   745 inline TInt PlatSec::CreatorPolicyCheckFail(const SSecurityInfo& aMissing, const char* aContextText)
       
   746 	{
       
   747 	TPlatSecDiagnostic d(TPlatSecDiagnostic::ECreatorPolicyCheckFail,(TInt)0,(const SSecurityInfo&)aMissing);
       
   748 	return EmitDiagnostic(d,aContextText);
       
   749 	}
       
   750 
       
   751 #endif //__KERNEL_MODE__
       
   752 #endif // !__REMOVE_PLATSEC_DIAGNOSTICS__
       
   753 
       
   754 const TInt KTlsArrayGranularity=2;
       
   755 
       
   756 #ifdef __CPU_HAS_CP15_THREAD_ID_REG
       
   757 
       
   758 #define __USERSIDE_THREAD_DATA__
       
   759 
       
   760 class TLocalThreadData
       
   761 	{
       
   762 public:
       
   763 	void Close();
       
   764 #ifndef __KERNEL_MODE__
       
   765 	TAny* DllTls(TInt aHandle, TInt aDllUid);
       
   766 	TInt DllSetTls(TInt aHandle, TInt aDllUid, TAny* aPtr);
       
   767 	void DllFreeTls(TInt aHandle);
       
   768 #endif
       
   769 public:
       
   770 	RAllocator* iHeap;				///< The thread's current heap
       
   771 	CActiveScheduler* iScheduler;	///< The thread's current active scheduler
       
   772 	TTrapHandler* iTrapHandler;		///< The thread's current trap handler
       
   773 private:
       
   774 	RAllocator* iTlsHeap; 			///< The heap that the DLL TLS data is stored on
       
   775 	RArray<STls> iTls; 				///< DLL TLS data
       
   776 	};
       
   777 
       
   778 const TInt KLocalThreadDataSize = _ALIGN_UP(sizeof(TLocalThreadData), 8);
       
   779 
       
   780 #endif
       
   781 
       
   782 #ifdef __WINS__
       
   783 
       
   784 enum TWin32RuntimeReason
       
   785 	{
       
   786 	// Same values as passed to DllMain
       
   787 	EWin32RuntimeProcessAttach = 1,
       
   788 	EWin32RuntimeThreadAttach = 2,
       
   789 	EWin32RuntimeThreadDetach = 3,
       
   790 	EWin32RuntimeProcessDetach = 4,
       
   791 	};
       
   792 
       
   793 typedef TBool (*TWin32RuntimeHook)(TWin32RuntimeReason);
       
   794 
       
   795 #endif
       
   796 
       
   797 struct SAtomicOpInfo64
       
   798 	{
       
   799 	TAny*		iA;
       
   800 	TAny*		iQ;
       
   801 	TUint64		i1;
       
   802 	TUint64		i2;
       
   803 	TUint64		i3;
       
   804 	};
       
   805 
       
   806 struct SAtomicOpInfo32
       
   807 	{
       
   808 	TAny*		iA;
       
   809 	union
       
   810 		{
       
   811 		TAny*	iQ;
       
   812 		TUint32	i0;
       
   813 		};
       
   814 	TUint32		i1;
       
   815 	TUint32		i2;
       
   816 	};
       
   817 
       
   818 #endif //__U32STD_H__