os/kernelhwsrv/kernel/eka/include/u32std.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/u32std.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,822 @@
     1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\include\u32std.h
    1.18 +//
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @internalComponent
    1.24 + @released
    1.25 +*/
    1.26 +
    1.27 +#ifndef __U32STD_H__
    1.28 +#define __U32STD_H__
    1.29 +#include <e32cmn.h>
    1.30 +#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
    1.31 +#include <e32cmn_private.h>
    1.32 +#endif
    1.33 +#include <e32hal.h>
    1.34 +#include <e32lmsg.h>
    1.35 +#include <e32event.h>
    1.36 +#include <e32ldr.h>
    1.37 +#include <e32ldr_private.h>
    1.38 +#include <e32power.h>
    1.39 +#include <e32shbufcmn.h>
    1.40 +#include <e32property.h>
    1.41 +#include <u32property.h>
    1.42 +#include <u32hal.h>
    1.43 +
    1.44 +#include <cpudefs.h>
    1.45 +
    1.46 +#ifdef __MARM__
    1.47 +#define	EKA2_ENTRY_POINT_VERSION_IDENTIFIER	\
    1.48 +	asm("tst pc, #%a0" : : "i" ((TInt)0) )
    1.49 +#endif
    1.50 +
    1.51 +struct TUnicodeDataSet;                 // forward declaration
    1.52 +struct TCollationDataSet;               // forward declaration
    1.53 +
    1.54 +/*
    1.55 +The LCharSet structure is used in Unicode builds to supply locale-specific
    1.56 +character attribute and collation data.
    1.57 +
    1.58 +The structure is defined in both builds to avoid having to have a dummy ExecHandler::GetLocaleCharSet function
    1.59 +with a different signature in the 8-bit build.
    1.60 +*/
    1.61 +struct LCharSet
    1.62 +	{
    1.63 +	const TUnicodeDataSet* iCharDataSet;			// if non-null, character data overriding standard Unicode data
    1.64 +	const TCollationDataSet* iCollationDataSet;		// if non-null, locale-specific collation data
    1.65 +	};
    1.66 +
    1.67 +extern const LCharSet* GetLocaleCharSet();
    1.68 +
    1.69 +/** @internalTechnology */
    1.70 +const TInt KNumLocaleExports = 22;
    1.71 +
    1.72 +//
    1.73 +// The bits in the type table (non-Unicode build only)
    1.74 +//
    1.75 +#ifndef _UNICODE
    1.76 +
    1.77 +/** @internalTechnology */
    1.78 +const TUint __U=0x01; // Uppercase letter
    1.79 +
    1.80 +/** @internalTechnology */
    1.81 +const TUint __L=0x02; // Lowercase letter
    1.82 +
    1.83 +/** @internalTechnology */
    1.84 +const TUint __D=0x04; // Decimal digit
    1.85 +
    1.86 +/** @internalTechnology */
    1.87 +const TUint __S=0x08; // Space
    1.88 +
    1.89 +/** @internalTechnology */
    1.90 +const TUint __P=0x10; // Punctuation
    1.91 +
    1.92 +/** @internalTechnology */
    1.93 +const TUint __C=0x20; // Control character
    1.94 +
    1.95 +/** @internalTechnology */
    1.96 +const TUint __X=0x40; // Hex digit
    1.97 +
    1.98 +/** @internalTechnology */
    1.99 +const TUint __B=0x80; // A blank character
   1.100 +
   1.101 +#endif
   1.102 +
   1.103 +//
   1.104 +// Time set mode parameters for setting system time and offset
   1.105 +//
   1.106 +enum TTimeSetMode
   1.107 +	{
   1.108 +	ETimeSetTime = 1,    // set the time to the value given, else leave it unchanged
   1.109 +	ETimeSetOffset = 2,  // set the offset to the value given, else leave it unchanged
   1.110 +	ETimeSetAllowTimeReversal = 4,  // allow time to go backwards
   1.111 +	ETimeSetNoTimeUpdate = 8,       // Don't restart second queue or notify changes - not valid with ESetTime, used early in boot only
   1.112 +	ETimeSetLocalTime = 16,			// Set time in local time, instead of UTC
   1.113 +	ETimeSetSecure = 32,  // use when setting the secure hardware clock
   1.114 +	};
   1.115 +
   1.116 +//
   1.117 +enum TMatchType {EMatchNormal,EMatchFolded,EMatchCollated};
   1.118 +
   1.119 +//
   1.120 +// Constants for descriptor implementation code
   1.121 +//
   1.122 +enum TDesType {EBufC,EPtrC,EPtr,EBuf,EBufCPtr};
   1.123 +const TUint KMaskDesLength=0xfffffff;
   1.124 +const TInt KShiftDesType=28;
   1.125 +
   1.126 +//
   1.127 +// Constants for iFlags in DProcess and DThread
   1.128 +//
   1.129 +const TUint KThreadFlagProcessCritical		= 0x00000001;	// thread panic panics process
   1.130 +const TUint KThreadFlagProcessPermanent		= 0x00000002;	// thread exit of any kind causes process to exit (=main)
   1.131 +const TUint KThreadFlagSystemCritical		= 0x00000004;	// thread panic reboots entire system
   1.132 +const TUint KThreadFlagSystemPermanent		= 0x00000008;	// thread exit of any kind reboots entire system
   1.133 +const TUint KThreadFlagOriginal				= 0x00000010;
   1.134 +const TUint KThreadFlagLastChance			= 0x00000020;
   1.135 +const TUint KThreadFlagRealtime				= 0x00000040;	// thread will be panicked when using some non-realtime functions
   1.136 +const TUint KThreadFlagRealtimeTest			= 0x00000080;	// non-realtime functions only warn rather than panic
   1.137 +const TUint KThreadFlagLocalThreadDataValid	= 0x00000100;	// thread has valid local thread data
   1.138 +const TUint KProcessFlagPriorityControl		= 0x40000000;
   1.139 +const TUint KProcessFlagJustInTime			= 0x80000000;
   1.140 +const TUint KProcessFlagSystemCritical		= KThreadFlagSystemCritical;	// process panic reboots entire system
   1.141 +const TUint KProcessFlagSystemPermanent		= KThreadFlagSystemPermanent;	// process exit of any kind reboots entire system
   1.142 +//
   1.143 +const TUint KThreadHandle=0x40000000;
   1.144 +//
   1.145 +struct SPtrC8 {TInt length;const TUint8 *ptr;};
   1.146 +struct SBufC8 {TInt length;TUint8 buf[1];};
   1.147 +struct SPtr8 {TInt length;TInt maxLength;TUint8 *ptr;};
   1.148 +struct SBuf8 {TInt length;TInt maxLength;TUint8 buf[1];};
   1.149 +struct SBufCPtr8 {TInt length;TInt maxLength;SBufC8 *ptr;};
   1.150 +
   1.151 +struct SPtrC16 {TInt length;const TUint16 *ptr;};
   1.152 +struct SBufC16 {TInt length;TUint16 buf[1];};
   1.153 +struct SPtr16 {TInt length;TInt maxLength;TUint16 *ptr;};
   1.154 +struct SBuf16 {TInt length;TInt maxLength;TUint16 buf[1];};
   1.155 +struct SBufCPtr16 {TInt length;TInt maxLength;SBufC16 *ptr;};
   1.156 +
   1.157 +//
   1.158 +// Flags used for IPC copy functions
   1.159 +//
   1.160 +const TInt KChunkShiftBy0=0;
   1.161 +const TInt KChunkShiftBy1=KMinTInt;
   1.162 +const TInt KIpcDirRead=0;
   1.163 +const TInt KIpcDirWrite=0x10000000;
   1.164 +
   1.165 +class TChunkCreate
   1.166 +	{
   1.167 +public:
   1.168 +	// Attributes for chunk creation that are used by both euser and the kernel
   1.169 +	// by classes TChunkCreateInfo and SChunkCreateInfo, respectively.
   1.170 +	enum TChunkCreateAtt
   1.171 +		{
   1.172 +		ENormal				= 0x00000000,
   1.173 +		EDoubleEnded		= 0x00000001,
   1.174 +		EDisconnected		= 0x00000002,
   1.175 +		ECache				= 0x00000003,
   1.176 +		EMappingMask		= 0x0000000f,
   1.177 +		ELocal				= 0x00000000,
   1.178 +		EGlobal				= 0x00000010,
   1.179 +		EData				= 0x00000000,
   1.180 +		ECode				= 0x00000020,
   1.181 +		EMemoryNotOwned		= 0x00000040,
   1.182 +
   1.183 +		// Force local chunk to be named.  Only required for thread heap
   1.184 +		// chunks, all other local chunks should be nameless.
   1.185 +		ELocalNamed 		= 0x000000080,
   1.186 +
   1.187 +		// Make global chunk read only to all processes but the controlling owner
   1.188 +		EReadOnly			= 0x000000100,
   1.189 +
   1.190 +		// Paging attributes for chunks.
   1.191 +		EPagingUnspec		= 0x00000000,
   1.192 +		EPaged				= 0x80000000,
   1.193 +		EUnpaged			= 0x40000000,
   1.194 +		EPagingMask 		= EPaged | EUnpaged,
   1.195 +
   1.196 +		EChunkCreateAttMask =	EMappingMask | EGlobal | ECode |
   1.197 +								ELocalNamed | EReadOnly | EPagingMask,
   1.198 +		};
   1.199 +public:
   1.200 +	TUint iAtt;
   1.201 +	TBool iForceFixed;
   1.202 +	TInt iInitialBottom;
   1.203 +	TInt iInitialTop;
   1.204 +	TInt iMaxSize;
   1.205 +	TUint8 iClearByte;
   1.206 +	};
   1.207 +
   1.208 +enum TChunkRestrictions
   1.209 +	{
   1.210 +	// Keep this in sync with definitions in RChunk
   1.211 +	EChunkPreventAdjust = 0x01,  // Disallow Adjust, Commit, Allocate and Decommit
   1.212 +	};
   1.213 +
   1.214 +class TChannelDoCreate
   1.215 +	{
   1.216 +public:
   1.217 +	TVersion iVer;
   1.218 +	const TDesC *iName;
   1.219 +	const TDesC *iPhysicalDevice;
   1.220 +	const TDesC8 *iInfo;
   1.221 +	};
   1.222 +
   1.223 +class TCreateSession
   1.224 +	{
   1.225 +public:
   1.226 +	TVersion iVer;
   1.227 +	TInt iMessageSlots;
   1.228 +	};
   1.229 +
   1.230 +enum TObjectType
   1.231 +	{
   1.232 +	EThread=0,
   1.233 +	EProcess,
   1.234 +	EChunk,
   1.235 +	ELibrary,
   1.236 +	ESemaphore,
   1.237 +	EMutex,
   1.238 +	ETimer,
   1.239 +	EServer,
   1.240 +	ESession,
   1.241 +	ELogicalDevice,
   1.242 +	EPhysicalDevice,
   1.243 +	ELogicalChannel,
   1.244 +	EChangeNotifier,
   1.245 +	EUndertaker,
   1.246 +	EMsgQueue,
   1.247 +	EPropertyRef,
   1.248 +	ECondVar,
   1.249 +	EShPool,
   1.250 +	EShBuf,
   1.251 +	ENumObjectTypes,	// number of DObject-derived types
   1.252 +	EObjectTypeAny=-1,
   1.253 +
   1.254 +	EIpcMessageD=0x20,	// lookup IPC message handle, allow disconnect
   1.255 +	EIpcMessage=0x21,	// lookup IPC message handle, don't allow disconnect
   1.256 +	EIpcClient=0x22,	// lookup IPC message client, don't allow disconnect
   1.257 +	};
   1.258 +
   1.259 +class TObjectOpenInfo
   1.260 +	{
   1.261 +public:
   1.262 +	TObjectType iObjType;
   1.263 +	TBool isReadOnly;
   1.264 +	};
   1.265 +
   1.266 +class TChannelCreateInfo
   1.267 +	{
   1.268 +public:
   1.269 +	TVersion iVersion;
   1.270 +	TInt iUnit;
   1.271 +	const TDesC* iPhysicalDevice;
   1.272 +	const TDesC8* iInfo;
   1.273 +	};
   1.274 +
   1.275 +#if defined(_UNICODE) && !defined(__KERNEL_MODE__)
   1.276 +class TChannelCreateInfo8
   1.277 +	{
   1.278 +public:
   1.279 +	TVersion iVersion;
   1.280 +	TInt iUnit;
   1.281 +	const TDesC8* iPhysicalDevice;
   1.282 +	const TDesC8* iInfo;
   1.283 +	};
   1.284 +#else
   1.285 +typedef TChannelCreateInfo TChannelCreateInfo8;
   1.286 +#endif
   1.287 +
   1.288 +const TInt KMaxThreadCreateInfo = 256;
   1.289 +struct SThreadCreateInfo
   1.290 +	{
   1.291 +	TAny* iHandle;
   1.292 +	TInt iType;
   1.293 +	TThreadFunction iFunction;
   1.294 +	TAny* iPtr;
   1.295 +	TAny* iSupervisorStack;
   1.296 +	TInt iSupervisorStackSize;
   1.297 +	TAny* iUserStack;
   1.298 +	TInt iUserStackSize;
   1.299 +	TInt iInitialThreadPriority;
   1.300 +	TPtrC iName;
   1.301 +	TInt iTotalSize;	// Size including any extras (must be a multiple of 8 bytes)
   1.302 +	};
   1.303 +
   1.304 +enum TThreadCreationFlags
   1.305 +	{
   1.306 +	ETraceHeapAllocs 				= 0x00000001,
   1.307 +	EMonitorHeapMemory				= 0x00000002,
   1.308 +
   1.309 +	EThreadCreateFlagPaged			= 0x00000004,
   1.310 +	EThreadCreateFlagUnpaged		= 0x00000008,
   1.311 +	EThreadCreateFlagPagingUnspec	= 0x00000000,
   1.312 +	EThreadCreateFlagPagingMask	= EThreadCreateFlagPaged | EThreadCreateFlagUnpaged,
   1.313 +
   1.314 +	EThreadCreateFlagMask = ETraceHeapAllocs | EMonitorHeapMemory | EThreadCreateFlagPagingMask,
   1.315 +	};
   1.316 +
   1.317 +struct SStdEpocThreadCreateInfo : public SThreadCreateInfo
   1.318 +	{
   1.319 +	SStdEpocThreadCreateInfo()
   1.320 +		: iFlags(0)	// Must be clear on creation.
   1.321 +		{
   1.322 +		};
   1.323 +	RAllocator* iAllocator;
   1.324 +	TInt iHeapInitialSize;
   1.325 +	TInt iHeapMaxSize;
   1.326 +	TUint iFlags;
   1.327 +	};
   1.328 +
   1.329 +#if defined(_UNICODE) && !defined(__KERNEL_MODE__)
   1.330 +struct SThreadCreateInfo8
   1.331 +	{
   1.332 +	TAny* iHandle;
   1.333 +	TInt iType;
   1.334 +	TThreadFunction iFunction;
   1.335 +	TAny* iPtr;
   1.336 +	TAny* iSupervisorStack;
   1.337 +	TInt iSupervisorStackSize;
   1.338 +	TAny* iUserStack;
   1.339 +	TInt iUserStackSize;
   1.340 +	TInt iInitialThreadPriority;
   1.341 +	TPtrC8 iName;
   1.342 +	TInt iTotalSize;	// size including any extras
   1.343 +	};
   1.344 +
   1.345 +struct SStdEpocThreadCreateInfo8 : public SThreadCreateInfo8
   1.346 +	{
   1.347 +	SStdEpocThreadCreateInfo8()
   1.348 +		: iFlags(0) // Must be clear on creation.
   1.349 +		{
   1.350 +		};
   1.351 +	RAllocator* iAllocator;
   1.352 +	TInt iHeapInitialSize;
   1.353 +	TInt iHeapMaxSize;
   1.354 +	TUint iFlags;
   1.355 +	};
   1.356 +#else
   1.357 +typedef SThreadCreateInfo SThreadCreateInfo8;
   1.358 +typedef SStdEpocThreadCreateInfo SStdEpocThreadCreateInfo8;
   1.359 +#endif
   1.360 +
   1.361 +struct SIpcCopyInfo
   1.362 +	{
   1.363 +	TUint8* iLocalPtr;
   1.364 +	TInt iLocalLen;
   1.365 +	TInt iFlags;
   1.366 +	};
   1.367 +
   1.368 +enum TChunkAdjust
   1.369 +	{
   1.370 +	EChunkAdjust=0,
   1.371 +	EChunkAdjustDoubleEnded=1,
   1.372 +	EChunkCommit=2,
   1.373 +	EChunkDecommit=3,
   1.374 +	EChunkAllocate=4,
   1.375 +	EChunkUnlock=5,
   1.376 +	EChunkLock=6
   1.377 +	};
   1.378 +
   1.379 +enum TMemModelAttributes
   1.380 +	{
   1.381 +	EMemModelTypeMask=0xf,					// bottom 4 bits give type of memory model
   1.382 +	EMemModelTypeDirect=0,					// direct memory model on hardware
   1.383 +	EMemModelTypeMoving=1,					// moving memory model on hardware
   1.384 +	EMemModelTypeMultiple=2,				// multiple memory model on hardware
   1.385 +	EMemModelTypeEmul=3,					// emulation using single host process
   1.386 +	EMemModelTypeFlexible=4,				// flexible memory model on hardware
   1.387 +
   1.388 +	EMemModelAttrRomPaging=0x10,			// Demand paging of XIP ROM
   1.389 +	EMemModelAttrCodePaging=0x20,			// Demand paging of RAM loaded code
   1.390 +	EMemModelAttrDataPaging=0x40,			// Demand paging of all RAM
   1.391 +	EMemModelAttrPagingMask=0xf0,			// Mask for demand paging attributes
   1.392 +
   1.393 +	EMemModelAttrNonExProt=(TInt)0x80000000,// accesses to nonexistent addresses are trapped
   1.394 +	EMemModelAttrKernProt=0x40000000,		// accesses to kernel memory from user mode are trapped
   1.395 +	EMemModelAttrWriteProt=0x20000000,		// addresses can be marked as read-only; writes to these are trapped
   1.396 +	EMemModelAttrVA=0x10000000,				// system supports virtual addresses
   1.397 +	EMemModelAttrProcessProt=0x08000000,	// accesses to other processes' memory are trapped
   1.398 +	EMemModelAttrSameVA=0x04000000,			// different processes map the same virtual address to different physical addresses
   1.399 +	EMemModelAttrSupportFixed=0x02000000,	// 'fixed' processes are supported
   1.400 +	EMemModelAttrSvKernProt=0x01000000,		// unexpected accesses to kernel memory within an executive call are trapped
   1.401 +	EMemModelAttrIPCKernProt=0x00800000,	// accesses to kernel memory via IPC are trapped
   1.402 +	EMemModelAttrIPCFullProt=0x00400000,	// accesses via IPC have same protection as user mode
   1.403 +	EMemModelAttrRamCodeProt=0x00200000,	// RAM-loaded code is only visible to processes which have loaded it
   1.404 +	};
   1.405 +
   1.406 +/** @test */
   1.407 +enum TKernelHeapDebugFunction {EDbgMarkStart,EDbgMarkCheck,EDbgMarkEnd,EDbgSetAllocFail,EDbgSetBurstAllocFail,EDbgCheckFailure};
   1.408 +
   1.409 +/** @test */
   1.410 +class TKernelHeapMarkCheckInfo
   1.411 +	{
   1.412 +public:
   1.413 +	TBool iCountAll;
   1.414 +	const TDesC8* iFileName;
   1.415 +	TInt iLineNum;
   1.416 +	};
   1.417 +//
   1.418 +class TTrapHandler;
   1.419 +class CActiveScheduler;
   1.420 +class TLocale;
   1.421 +
   1.422 +//
   1.423 +//
   1.424 +//
   1.425 +// Handler below is used by test prints to trucate rather than panic the caller.
   1.426 +//
   1.427 +#if defined(_UNICODE) && !defined(__KERNEL_MODE__)
   1.428 +NONSHARABLE_CLASS(TestOverflowTruncate) : public TDes16Overflow
   1.429 +	{
   1.430 +public:
   1.431 +	virtual void Overflow(TDes16 &aDes);
   1.432 +	};
   1.433 +#else
   1.434 +NONSHARABLE_CLASS(TestOverflowTruncate) : public TDes8Overflow
   1.435 +	{
   1.436 +public:
   1.437 +	virtual void Overflow(TDes8 &aDes);
   1.438 +	};
   1.439 +#endif
   1.440 +//
   1.441 +
   1.442 +/********************************************
   1.443 + * Thread local storage entry
   1.444 + ********************************************/
   1.445 +struct STls
   1.446 +	{
   1.447 +	TInt	iHandle;
   1.448 +	TInt	iDllUid;
   1.449 +	TAny*	iPtr;
   1.450 +	};
   1.451 +
   1.452 +const TInt KDllUid_Default = 0;		// for ROM DLLs and direct calls to UserSvr::DllTls
   1.453 +const TInt KDllUid_Special = -1;	// used on emulator to instruct the kernel to get the DLL UID from the module handle
   1.454 +
   1.455 +/********************************************
   1.456 + * Entry point call values
   1.457 + ********************************************/
   1.458 +const TInt	KModuleEntryReasonProcessInit		=0;		// Process start
   1.459 +const TInt	KModuleEntryReasonThreadInit		=1;		// Start new thread
   1.460 +const TInt	KModuleEntryReasonProcessAttach		=2;		// Process attach (init static data)
   1.461 +const TInt	KModuleEntryReasonProcessDetach		=3;		// Process detach (destroy static data)
   1.462 +const TInt	KModuleEntryReasonException			=4;		// Handle exception
   1.463 +const TInt	KModuleEntryReasonVariantInit0		=-3;	// Call variant static constructors
   1.464 +
   1.465 +/** @publishedPartner
   1.466 +	@released
   1.467 +*/
   1.468 +const TInt	KModuleEntryReasonExtensionInit0	=-2;	// Extension early initialisation check
   1.469 +
   1.470 +/** @publishedPartner
   1.471 +	@released
   1.472 +*/
   1.473 +const TInt	KModuleEntryReasonExtensionInit1	=-1;	// Extension initialisation
   1.474 +
   1.475 +/**
   1.476 +	Flags returned by Exec::KernelConfigFlags()
   1.477 +*/
   1.478 +enum TKernelConfigFlags
   1.479 +	{
   1.480 +	EKernelConfigIpcV1Available = 1<<0,
   1.481 +	EKernelConfigPlatSecEnforcement = 1<<1,
   1.482 +	EKernelConfigPlatSecDiagnostics = 1<<2,
   1.483 +	EKernelConfigPlatSecProcessIsolation = 1<<3,
   1.484 +	EKernelConfigPlatSecEnforceSysBin = 1<<4,
   1.485 +
   1.486 +	// paging policy values use by 2-bit code and data paging policy enums...
   1.487 +	EKernelConfigPagingPolicyNoPaging = 0,
   1.488 +	EKernelConfigPagingPolicyAlwaysPage = 1,
   1.489 +	EKernelConfigPagingPolicyDefaultUnpaged = 2,
   1.490 +	EKernelConfigPagingPolicyDefaultPaged = 3,
   1.491 +
   1.492 +	EKernelConfigCodePagingPolicyShift			= 5,
   1.493 +	EKernelConfigCodePagingPolicyMask			= 3<<5,
   1.494 +	EKernelConfigCodePagingPolicyNoPaging		= EKernelConfigPagingPolicyNoPaging<<5,
   1.495 +	EKernelConfigCodePagingPolicyAlwaysPage		= EKernelConfigPagingPolicyAlwaysPage<<5,
   1.496 +	EKernelConfigCodePagingPolicyDefaultUnpaged	= EKernelConfigPagingPolicyDefaultUnpaged<<5,
   1.497 +	EKernelConfigCodePagingPolicyDefaultPaged	= EKernelConfigPagingPolicyDefaultPaged<<5,
   1.498 +
   1.499 +	EKernelConfigPlatSecLocked = 1<<7,					// Primarily used by __PLATSEC_UNLOCKED__ (q.v.) test code
   1.500 +
   1.501 +	EKernelConfigCrazyScheduling = 1<<8,				// Enables thread priority/timeslice craziness
   1.502 +
   1.503 +	EKernelConfigDataPagingPolicyShift			= 9,
   1.504 +	EKernelConfigDataPagingPolicyMask			= 3<<9,
   1.505 +	EKernelConfigDataPagingPolicyNoPaging		= EKernelConfigPagingPolicyNoPaging<<9,
   1.506 +	EKernelConfigDataPagingPolicyAlwaysPage		= EKernelConfigPagingPolicyAlwaysPage<<9,
   1.507 +	EKernelConfigDataPagingPolicyDefaultUnpaged	= EKernelConfigPagingPolicyDefaultUnpaged<<9,
   1.508 +	EKernelConfigDataPagingPolicyDefaultPaged	= EKernelConfigPagingPolicyDefaultPaged<<9,
   1.509 +
   1.510 +	EKernelConfigSMPUnsafeCompat = 1<<12,				// Enables compatibility mode for SMP-unsafe processes
   1.511 +	EKernelConfigSMPUnsafeCPU0   = 1<<13,				// Slow compatibility mode: all SMP-unsafe processes run on CPU 0 only
   1.512 +	EKernelConfigSMPCrazyInterrupts = 1<<14,			// Enables CPU target rotation for HW Interrupts.
   1.513 +
   1.514 +	EKernelConfigDisableAPs = 1u<<30,
   1.515 +
   1.516 +	EKernelConfigTest = 1u<<31,							// Only used by test code for __PLATSEC_UNLOCKED__
   1.517 +	};
   1.518 +
   1.519 +/**
   1.520 +	If __PLATSEC_UNLOCKED__ is not defined, these flags must always
   1.521 +	be considered to be set.  See KernelConfigFlags() in kern_priv.h.
   1.522 +
   1.523 +	@see KernelConfigFlags()
   1.524 +
   1.525 +	@internalTechnology
   1.526 +*/
   1.527 +#ifdef __PLATSEC_UNLOCKED__
   1.528 +#define __PLATSEC_FORCED_FLAGS__	 0
   1.529 +#else
   1.530 +#define __PLATSEC_FORCED_FLAGS__	(EKernelConfigPlatSecEnforcement|EKernelConfigPlatSecProcessIsolation|EKernelConfigPlatSecEnforceSysBin)
   1.531 +#endif
   1.532 +
   1.533 +/**
   1.534 +@internalTechnology
   1.535 +*/
   1.536 +enum TGlobalUserData
   1.537 +	{
   1.538 +	ELocaleDefaultCharSet,
   1.539 +	ELocalePreferredCharSet,
   1.540 +	EMaxGlobalUserData
   1.541 +	};
   1.542 +
   1.543 +typedef void (*TGlobalDestructorFunc)(void);
   1.544 +
   1.545 +// This must not conflict with any possible valid TLS keys
   1.546 +const TInt KGlobalDestructorTlsKey = -1;
   1.547 +
   1.548 +GLREF_C void ExitCurrentThread(TExitType, TInt, const TDesC8*);
   1.549 +
   1.550 +#ifndef __REMOVE_PLATSEC_DIAGNOSTICS__
   1.551 +/**
   1.552 +@internalTechnology
   1.553 +*/
   1.554 +class TPlatSecDiagnostic
   1.555 +	{
   1.556 +public:
   1.557 +	enum TType
   1.558 +		{
   1.559 +		ELoaderCapabilityViolation1,
   1.560 +		ELoaderCapabilityViolation2,
   1.561 +		EThreadCapabilityCheckFail,
   1.562 +		EProcessCapabilityCheckFail,
   1.563 +		EKernelSecureIdCheckFail,
   1.564 +		EKernelObjectPolicyCheckFail,
   1.565 +		EHandleCapabilityCheckFail,
   1.566 +		ECreatorCapabilityCheckFail,
   1.567 +		EMessageCapabilityCheckFail,
   1.568 +		EKernelProcessIsolationFail,
   1.569 +		EKernelProcessIsolationIPCFail,
   1.570 +		ECreatorPolicyCheckFail,
   1.571 +		};
   1.572 +public:
   1.573 +	inline TPlatSecDiagnostic();
   1.574 +	inline TPlatSecDiagnostic(TType aType);
   1.575 +	inline TPlatSecDiagnostic(TType aType, TInt aInt1, TInt aInt2, const SCapabilitySet& aCaps);
   1.576 +	inline TPlatSecDiagnostic(TType aType, TInt aInt1, const SSecurityInfo& aCaps);
   1.577 +	inline TPlatSecDiagnostic(TType aType, TInt aInt, const TDesC8& aString, const SCapabilitySet& aCaps);
   1.578 +	inline TPlatSecDiagnostic(TType aType, const TDesC8& aString1, const TDesC8& aString2, const SCapabilitySet& aCaps);
   1.579 +	inline TPlatSecDiagnostic(TType aType, TInt aInt1, TInt aInt2);
   1.580 +	inline TPlatSecDiagnostic(TType aType, TInt aInt1);
   1.581 +	inline const TDesC8* String1();
   1.582 +	inline const TDesC8* String2();
   1.583 +public:
   1.584 +	TType iType;
   1.585 +	TInt iArg1;
   1.586 +	TInt iArg2;
   1.587 +	const char* iContextText;
   1.588 +	TInt iContextTextLength;
   1.589 +	SSecurityInfo iSecurityInfo;
   1.590 +	};
   1.591 +
   1.592 +inline TPlatSecDiagnostic::TPlatSecDiagnostic()
   1.593 +	{}
   1.594 +
   1.595 +inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType)
   1.596 +	: iType(aType)
   1.597 +	{}
   1.598 +
   1.599 +inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType,TInt aInt1)
   1.600 +	: iType(aType), iArg1(aInt1)
   1.601 +	{}
   1.602 +
   1.603 +inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType, TInt aInt1, TInt aInt2, const SCapabilitySet& aCaps)
   1.604 +	: iType(aType), iArg1(aInt1), iArg2(aInt2), iContextText(0)
   1.605 +	{
   1.606 +	iSecurityInfo.iSecureId = 0;
   1.607 +	iSecurityInfo.iVendorId = 0;
   1.608 +	iSecurityInfo.iCaps = aCaps;
   1.609 +	};
   1.610 +inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType, TInt aInt1, const SSecurityInfo& aInfo)
   1.611 +	: iType(aType), iArg1(aInt1), iArg2(ECapability_None), iContextText(0), iSecurityInfo(aInfo)
   1.612 +	{
   1.613 +	};
   1.614 +
   1.615 +inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType, TInt aInt, const TDesC8& aString, const SCapabilitySet& aCaps)
   1.616 +	: iType(aType), iArg1(aInt), iArg2((TInt)&aString), iContextText(0)
   1.617 +	{
   1.618 +	iSecurityInfo.iSecureId = 0;
   1.619 +	iSecurityInfo.iVendorId = 0;
   1.620 +	iSecurityInfo.iCaps = aCaps;
   1.621 +	};
   1.622 +
   1.623 +inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType, const TDesC8& aString1, const TDesC8& aString2, const SCapabilitySet& aCaps)
   1.624 +	: iType(aType), iArg1((TInt)&aString1), iArg2((TInt)&aString2), iContextText(0)
   1.625 +	{
   1.626 +	iSecurityInfo.iSecureId = 0;
   1.627 +	iSecurityInfo.iVendorId = 0;
   1.628 +	iSecurityInfo.iCaps = aCaps;
   1.629 +	};
   1.630 +
   1.631 +inline TPlatSecDiagnostic::TPlatSecDiagnostic(TType aType, TInt aInt1, TInt aInt2)
   1.632 +	: iType(aType), iArg1(aInt1), iArg2(aInt2)
   1.633 +	{
   1.634 +	iSecurityInfo.iSecureId = 0;
   1.635 +	iSecurityInfo.iVendorId = 0;
   1.636 +	iSecurityInfo.iCaps[0] = 0;
   1.637 +	iSecurityInfo.iCaps[1] = 0;
   1.638 +	};
   1.639 +
   1.640 +inline const TDesC8* TPlatSecDiagnostic::String1()
   1.641 +	{ return (const TDesC8*)iArg1; }
   1.642 +
   1.643 +inline const TDesC8* TPlatSecDiagnostic::String2()
   1.644 +	{ return (const TDesC8*)iArg2; }
   1.645 +
   1.646 +inline TInt PlatSec::LoaderCapabilityViolation(const TDesC8& aImporterName, const TDesC8& aFileName, const SCapabilitySet& aMissingCaps)
   1.647 +	{
   1.648 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::ELoaderCapabilityViolation2,aImporterName,aFileName,aMissingCaps);
   1.649 +	return EmitDiagnostic(d, NULL);
   1.650 +	}
   1.651 +
   1.652 +#ifdef __KERNEL_MODE__
   1.653 +
   1.654 +inline TInt PlatSec::CapabilityCheckFail(const DProcess* aViolatingProcess, TCapability aCapability, const char* aContextText)
   1.655 +	{
   1.656 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::EProcessCapabilityCheckFail,(TInt)aViolatingProcess,(TInt)aCapability);
   1.657 +	return EmitDiagnostic(d,aContextText);
   1.658 +	}
   1.659 +
   1.660 +inline TInt PlatSec::CapabilityCheckFail(const DThread* aViolatingThread, TCapability aCapability, const char* aContextText)
   1.661 +	{
   1.662 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::EThreadCapabilityCheckFail,(TInt)aViolatingThread,(TInt)aCapability);
   1.663 +	return EmitDiagnostic(d,aContextText);
   1.664 +	}
   1.665 +
   1.666 +inline TInt PlatSec::SecureIdCheckFail(const DProcess* aViolatingProcess, TSecureId aSid, const char* aContextText)
   1.667 +	{
   1.668 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::EKernelSecureIdCheckFail,(TInt)aViolatingProcess,(TInt)aSid);
   1.669 +	return EmitDiagnostic(d,aContextText);
   1.670 +	}
   1.671 +
   1.672 +inline TInt PlatSec::PolicyCheckFail(const DProcess* aProcess, const SSecurityInfo& aMissingSecurityInfo, const char* aContextText)
   1.673 +	{
   1.674 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::EKernelObjectPolicyCheckFail,(TInt)aProcess,(const SSecurityInfo&)aMissingSecurityInfo);
   1.675 +	return EmitDiagnostic(d,aContextText);
   1.676 +	}
   1.677 +
   1.678 +inline TInt PlatSec::PolicyCheckFail(const DThread* aThread, const SSecurityInfo& aMissingSecurityInfo, const char* aContextText)
   1.679 +	{
   1.680 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::EKernelObjectPolicyCheckFail,(TInt)aThread,(const SSecurityInfo&)aMissingSecurityInfo);
   1.681 +	return EmitDiagnostic(d,aContextText);
   1.682 +	}
   1.683 +
   1.684 +inline TInt PlatSec::ProcessIsolationFail(const char* aContextText)
   1.685 +	{
   1.686 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::EKernelProcessIsolationFail);
   1.687 +	return EmitDiagnostic(d,aContextText);
   1.688 +	}
   1.689 +
   1.690 +inline TInt PlatSec::ProcessIsolationIPCFail(RMessageK* aMessage, const char* aContextText)
   1.691 +	{
   1.692 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::EKernelProcessIsolationIPCFail,(TInt)aMessage);
   1.693 +	return EmitDiagnostic(d,aContextText);
   1.694 +	}
   1.695 +
   1.696 +#else // !__KERNEL_MODE__
   1.697 +
   1.698 +inline TInt PlatSec::LoaderCapabilityViolation(RProcess aLoadingProcess, const TDesC8& aFileName, const SCapabilitySet& aMissingCaps)
   1.699 +	{
   1.700 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::ELoaderCapabilityViolation1,aLoadingProcess.Handle(),aFileName,aMissingCaps);
   1.701 +	return EmitDiagnostic(d, NULL);
   1.702 +	}
   1.703 +
   1.704 +inline TInt PlatSec::CreatorCapabilityCheckFail(TCapability aCapability, const char* aContextText)
   1.705 +	{
   1.706 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::ECreatorCapabilityCheckFail,(TInt)0,aCapability);
   1.707 +	return EmitDiagnostic(d,aContextText);
   1.708 +	}
   1.709 +
   1.710 +inline TInt PlatSec::CreatorCapabilityCheckFail(const TCapabilitySet& aMissingCaps, const char* aContextText)
   1.711 +	{
   1.712 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::ECreatorCapabilityCheckFail,(TInt)0,ECapability_None,(const SCapabilitySet&)aMissingCaps);
   1.713 +	return EmitDiagnostic(d,aContextText);
   1.714 +	}
   1.715 +
   1.716 +inline TInt PlatSec::CapabilityCheckFail(TInt aHandle, TCapability aCapability, const char* aContextText)
   1.717 +	{
   1.718 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::EHandleCapabilityCheckFail,aHandle,aCapability);
   1.719 +	return EmitDiagnostic(d,aContextText);
   1.720 +	}
   1.721 +
   1.722 +inline TInt PlatSec::CapabilityCheckFail(TInt aHandle, const TCapabilitySet& aMissingCaps, const char* aContextText)
   1.723 +	{
   1.724 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::EHandleCapabilityCheckFail,aHandle,ECapability_None,(const SCapabilitySet&)aMissingCaps);
   1.725 +	return EmitDiagnostic(d,aContextText);
   1.726 +	}
   1.727 +
   1.728 +inline TInt PlatSec::PolicyCheckFail(TInt aHandle, const SSecurityInfo& aMissingSecurityInfo, const char* aContextText)
   1.729 +	{
   1.730 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::EHandleCapabilityCheckFail,aHandle,(const SSecurityInfo&)aMissingSecurityInfo);
   1.731 +	return EmitDiagnostic(d,aContextText);
   1.732 +	}
   1.733 +
   1.734 +inline TInt PlatSec::CapabilityCheckFail(RMessagePtr2 aMessage, TCapability aCapability, const char* aContextText)
   1.735 +	{
   1.736 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::EMessageCapabilityCheckFail,(TInt)aMessage.Handle(),aCapability);
   1.737 +	return EmitDiagnostic(d,aContextText);
   1.738 +	}
   1.739 +
   1.740 +inline TInt PlatSec::CapabilityCheckFail(RMessagePtr2 aMessage, const TCapabilitySet& aMissingCaps, const char* aContextText)
   1.741 +	{
   1.742 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::EMessageCapabilityCheckFail,(TInt)aMessage.Handle(),ECapability_None,(const SCapabilitySet&)aMissingCaps);
   1.743 +	return EmitDiagnostic(d,aContextText);
   1.744 +	}
   1.745 +
   1.746 +inline TInt PlatSec::PolicyCheckFail(RMessagePtr2 aMessage, const SSecurityInfo& aMissing, const char* aContextText)
   1.747 +	{
   1.748 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::EMessageCapabilityCheckFail,(TInt)aMessage.Handle(),(const SSecurityInfo&)aMissing);
   1.749 +	return EmitDiagnostic(d,aContextText);
   1.750 +	}
   1.751 +
   1.752 +inline TInt PlatSec::CreatorPolicyCheckFail(const SSecurityInfo& aMissing, const char* aContextText)
   1.753 +	{
   1.754 +	TPlatSecDiagnostic d(TPlatSecDiagnostic::ECreatorPolicyCheckFail,(TInt)0,(const SSecurityInfo&)aMissing);
   1.755 +	return EmitDiagnostic(d,aContextText);
   1.756 +	}
   1.757 +
   1.758 +#endif //__KERNEL_MODE__
   1.759 +#endif // !__REMOVE_PLATSEC_DIAGNOSTICS__
   1.760 +
   1.761 +const TInt KTlsArrayGranularity=2;
   1.762 +
   1.763 +#ifdef __CPU_HAS_CP15_THREAD_ID_REG
   1.764 +
   1.765 +#define __USERSIDE_THREAD_DATA__
   1.766 +
   1.767 +class TLocalThreadData
   1.768 +	{
   1.769 +public:
   1.770 +	void Close();
   1.771 +#ifndef __KERNEL_MODE__
   1.772 +	TAny* DllTls(TInt aHandle, TInt aDllUid);
   1.773 +	TInt DllSetTls(TInt aHandle, TInt aDllUid, TAny* aPtr);
   1.774 +	void DllFreeTls(TInt aHandle);
   1.775 +#endif
   1.776 +public:
   1.777 +	RAllocator* iHeap;				///< The thread's current heap
   1.778 +	CActiveScheduler* iScheduler;	///< The thread's current active scheduler
   1.779 +	TTrapHandler* iTrapHandler;		///< The thread's current trap handler
   1.780 +private:
   1.781 +	RAllocator* iTlsHeap; 			///< The heap that the DLL TLS data is stored on
   1.782 +	RArray<STls> iTls; 				///< DLL TLS data
   1.783 +	};
   1.784 +
   1.785 +const TInt KLocalThreadDataSize = _ALIGN_UP(sizeof(TLocalThreadData), 8);
   1.786 +
   1.787 +#endif
   1.788 +
   1.789 +#ifdef __WINS__
   1.790 +
   1.791 +enum TWin32RuntimeReason
   1.792 +	{
   1.793 +	// Same values as passed to DllMain
   1.794 +	EWin32RuntimeProcessAttach = 1,
   1.795 +	EWin32RuntimeThreadAttach = 2,
   1.796 +	EWin32RuntimeThreadDetach = 3,
   1.797 +	EWin32RuntimeProcessDetach = 4,
   1.798 +	};
   1.799 +
   1.800 +typedef TBool (*TWin32RuntimeHook)(TWin32RuntimeReason);
   1.801 +
   1.802 +#endif
   1.803 +
   1.804 +struct SAtomicOpInfo64
   1.805 +	{
   1.806 +	TAny*		iA;
   1.807 +	TAny*		iQ;
   1.808 +	TUint64		i1;
   1.809 +	TUint64		i2;
   1.810 +	TUint64		i3;
   1.811 +	};
   1.812 +
   1.813 +struct SAtomicOpInfo32
   1.814 +	{
   1.815 +	TAny*		iA;
   1.816 +	union
   1.817 +		{
   1.818 +		TAny*	iQ;
   1.819 +		TUint32	i0;
   1.820 +		};
   1.821 +	TUint32		i1;
   1.822 +	TUint32		i2;
   1.823 +	};
   1.824 +
   1.825 +#endif //__U32STD_H__