os/kernelhwsrv/kernel/eka/include/e32ldr_private.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/e32ldr_private.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,401 @@
     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\e32ldr_private.h
    1.18 +// 
    1.19 +
    1.20 +/**
    1.21 + @file
    1.22 + @internalTechnology
    1.23 +*/
    1.24 +
    1.25 +#ifndef __E32LDR_PRIVATE_H__
    1.26 +#define __E32LDR_PRIVATE_H__
    1.27 +
    1.28 +#include <e32ldr.h>
    1.29 +#include <e32cmn.h>
    1.30 +
    1.31 +
    1.32 +const TInt KMaxLibraryEntryPoints=0x100;
    1.33 +
    1.34 +//
    1.35 +// Loader version number.
    1.36 +//
    1.37 +const TInt KLoaderMajorVersionNumber=1;
    1.38 +const TInt KLoaderMinorVersionNumber=0;
    1.39 +
    1.40 +//
    1.41 +// IPC messages to the loader
    1.42 +//
    1.43 +enum TLoaderMsg
    1.44 +	{
    1.45 +	ELoadProcess=1,
    1.46 +	ELoadLibrary=2,
    1.47 +	ELoadLogicalDevice=3,
    1.48 +	ELoadPhysicalDevice=4,
    1.49 +	ELoadLocale=5,
    1.50 +	ELoadFileSystem=6,
    1.51 +	EGetInfo=7,
    1.52 +	ELoaderDebugFunction=8,
    1.53 +	ELoadFSExtension=9,
    1.54 +	EGetInfoFromHeader=10,
    1.55 +	ELoadFSPlugin=11,
    1.56 +	ELoaderCancelLazyDllUnload=12,
    1.57 +	ELdrDelete=13,
    1.58 +	ECheckLibraryHash=14, 
    1.59 +	ELoadFSProxyDrive=15,
    1.60 +    ELoadCodePage=16,
    1.61 +    EMaxLoaderMsg
    1.62 +	};
    1.63 +//
    1.64 +// Loader message arguments:
    1.65 +//		0 = TLdrInfo
    1.66 +//		1 = Filename
    1.67 +//		2 = Command line (process) or path (library)
    1.68 +//
    1.69 +class TLdrInfo
    1.70 +	{
    1.71 +public:
    1.72 +	IMPORT_C TLdrInfo();		// for BC
    1.73 +public:
    1.74 +	TUidType iRequestedUids;
    1.75 +	TOwnerType iOwnerType;
    1.76 +	TInt iHandle;
    1.77 +	TUint32 iSecureId;
    1.78 +	TUint32 iRequestedVersion;
    1.79 +	TInt iMinStackSize;			// Size of new process stack 
    1.80 +	};
    1.81 +	
    1.82 +
    1.83 +#ifndef __KERNEL_MODE__
    1.84 +#include <e32std.h>
    1.85 +//
    1.86 +// Loader client class
    1.87 +//
    1.88 +class RLoader : public RSessionBase
    1.89 +	{
    1.90 +public:
    1.91 +	IMPORT_C TInt Connect();
    1.92 +	TVersion Version() const;
    1.93 +	TInt LoadProcess(TInt& aHandle, const TDesC& aFileName, const TDesC& aCommand, const TUidType& aUidType, TOwnerType aType);
    1.94 +	IMPORT_C TInt LoadLibrary(TInt& aHandle, const TDesC& aFileName, const TDesC& aPath, const TUidType& aType, TUint32 aModuleVersion);
    1.95 +	IMPORT_C TInt GetInfo(const TDesC& aFileName, TDes8& aInfoBuf);
    1.96 +	TInt LoadDeviceDriver(const TDesC& aFileName, TInt aDeviceType);
    1.97 +	IMPORT_C TInt DebugFunction(TInt aFunction, TInt a1, TInt a2, TInt a3);
    1.98 +	TInt LoadLocale(const TDesC& aLocaleDllName, TLibraryFunction* aExportList);
    1.99 +	TInt GetInfoFromHeader(const TDesC8& aHeader, TDes8& aInfoBuf);
   1.100 +	IMPORT_C TInt CancelLazyDllUnload();
   1.101 +	IMPORT_C TInt Delete(const TDesC& aFileName);
   1.102 +    IMPORT_C TInt CheckLibraryHash(const TDesC& aFileName, TBool aValidateHash=EFalse);
   1.103 +	TInt LoadProcess(TInt& aHandle, const TDesC& aFileName, const TDesC& aCommand, const TUidType& aUidType, TInt aMinStackSize, TOwnerType aType);
   1.104 +public:
   1.105 +#ifdef __ARMCC__
   1.106 +	// workaround for possible EDG bug (!!)
   1.107 +	inline TInt SendReceive(TInt aFunction,const TIpcArgs& aArgs) const
   1.108 +	  { return RSessionBase::SendReceive(aFunction, aArgs); }
   1.109 +#else
   1.110 +	using RSessionBase::SendReceive;
   1.111 +#endif
   1.112 +	};
   1.113 +#endif
   1.114 +
   1.115 +//
   1.116 +// Information required to create a new code segment
   1.117 +//
   1.118 +enum TCodeSegAttributes
   1.119 +	{
   1.120 +	ECodeSegAttKernel			=0x00000001,
   1.121 +	ECodeSegAttGlobal			=0x00000002,
   1.122 +	ECodeSegAttFixed			=0x00000004,
   1.123 +	ECodeSegAttABIMask			=0x00000018,	  // same values as in image header
   1.124 +	ECodeSegAttCodePaged		=0x00000200,	  // the code seg is demand paged
   1.125 +	ECodeSegAttDataPaged		=0x00002000,	  // the code seg static data is demand paged
   1.126 +	ECodeSegAttHDll				=(TInt)0x80000000,// Emulator host file type: 1=DLL, 0=EXE
   1.127 +	ECodeSegAttExpVer			=0x40000000,	  // Filename is explicitly versioned
   1.128 +	ECodeSegAttNmdExpData		=0x20000000,	  // Named symbol export data in code seg
   1.129 +	ECodeSegAttSMPSafe			=0x10000000,	  // code seg and its static dependencies are SMP safe
   1.130 +	ECodeSegAttAddrNotUnique	=0x08000000,	  // run address not globally unique (may overlap other codesegs)
   1.131 +	};
   1.132 +
   1.133 +// forward declarations from file server
   1.134 +class RFile;
   1.135 +class RFs;
   1.136 +
   1.137 +/**
   1.138 +A Handle used to identify a file on storage media.
   1.139 +@internalTechnology
   1.140 +*/
   1.141 +class RFileClamp
   1.142 +	{
   1.143 +public:
   1.144 +	inline RFileClamp()
   1.145 +		{
   1.146 +		iCookie[0] = 0;
   1.147 +		iCookie[1] = 0;
   1.148 +		}
   1.149 +	IMPORT_C TInt Clamp(RFile& aFile);
   1.150 +	IMPORT_C TInt Close(RFs& aFs);
   1.151 +
   1.152 +public:
   1.153 +	TInt64 iCookie[2];
   1.154 +	};
   1.155 +
   1.156 +
   1.157 +class TCodeSegCreateInfo
   1.158 +	{
   1.159 +public:
   1.160 +	TBuf8<KMaxFileName> iFileName;		// not including {MMMMmmmm} version info
   1.161 +	TUidType iUids;				// uid1 indicates EXE or DLL
   1.162 +	TUint32 iAttr;
   1.163 +	TInt iCodeSize;
   1.164 +	TInt iTextSize;
   1.165 +	TInt iDataSize;
   1.166 +	TInt iBssSize;
   1.167 +	TInt iTotalDataSize;
   1.168 +	TUint32 iEntryPtVeneer;		// address of first instruction to be called
   1.169 +	TUint32 iFileEntryPoint;	// address of entry point within this code segment
   1.170 +	TInt iDepCount;
   1.171 +	TUint32 iExportDir;
   1.172 +	TInt iExportDirCount;
   1.173 +	TUint32 iCodeLoadAddress;	// 0 for RAM loaded code, else pointer to TRomImageHeader
   1.174 +	TUint32 iCodeRunAddress;
   1.175 +	TUint32 iDataLoadAddress;
   1.176 +	TUint32 iDataRunAddress;
   1.177 +	TUint32 iExceptionDescriptor;
   1.178 +	TInt iRootNameOffset;
   1.179 +	TInt iRootNameLength;
   1.180 +	TInt iExtOffset;
   1.181 +	TUint32 iModuleVersion;
   1.182 +	SSecurityInfo iS;
   1.183 +	TAny* iHandle;				// pointer to kernel-side DCodeSeg object
   1.184 +	TInt iClientProcessHandle;	// handle to client process for user DLL loads
   1.185 +	/** Code relocation information stored on loader heap. */
   1.186 +	TUint32* iCodeRelocTable;
   1.187 +	/** Size of code relocation table in bytes. */
   1.188 +	TInt iCodeRelocTableSize;
   1.189 +	/** Import fixup information stored on loader heap. */
   1.190 +	TUint32* iImportFixupTable;
   1.191 +	/** Size of import fixup table in bytes. */
   1.192 +	TInt iImportFixupTableSize;
   1.193 +	/** Offset to apply to each code address in the image when it is fixed up. */
   1.194 +	TUint32 iCodeDelta;
   1.195 +	/** Offset to apply to each data address in the image when it is fixed up. */
   1.196 +	TUint32 iDataDelta;
   1.197 +	/**
   1.198 +		Whether the code is paged.  If this is set, then
   1.199 +		TCodeSegCreateInfo::iCodeRelocTable[Size] and
   1.200 +		TCodeSegCreateInfo::iImportFixupTable[Size] contain fixup information
   1.201 +		which the kernel uses to fix up each page.
   1.202 +		(They may be null if the binary has no imports or no code section.)
   1.203 +	 */
   1.204 +	TBool iUseCodePaging;
   1.205 +	/** The UID of the compression scheme in use. */
   1.206 +	TUint32 iCompressionType;
   1.207 +	/**
   1.208 +		Start of compressed pages within the file.  The kernel uses
   1.209 +		this to load compressed pages from byte-pair files when demand
   1.210 +		paging.
   1.211 +	 */
   1.212 +	TInt32* iCodePageOffsets;
   1.213 +	/** Where (possibly compressed) object code starts in iFile. */
   1.214 +	TInt iCodeStartInFile;
   1.215 +	/** Length of (possibly compressed) object code in iFile. */
   1.216 +	TInt iCodeLengthInFile;
   1.217 +	/** Information about block map entries in iCodeBlockMapEntries. */
   1.218 +	SBlockMapInfoBase iCodeBlockMapCommon;
   1.219 +	/** Where object code is located on the media. */
   1.220 +	TBlockMapEntryBase* iCodeBlockMapEntries;
   1.221 +	/** Size of block map entry array in bytes. */
   1.222 +	TInt iCodeBlockMapEntriesSize;
   1.223 +	/**
   1.224 +		File clamp cookie, used to delete the file when the
   1.225 +		codeseg is destroyed.
   1.226 +	 */
   1.227 +	RFileClamp iFileClamp;
   1.228 +public:
   1.229 +	IMPORT_C TPtrC8 RootName() const;
   1.230 +	};
   1.231 +
   1.232 +//
   1.233 +// Information required to create a new process
   1.234 +//
   1.235 +class TProcessCreateInfo : public TCodeSegCreateInfo
   1.236 +	{
   1.237 +public:
   1.238 +	enum TDebugAttributes	// must be the same as RLibrary::TInfoV2::TDebugAttributes
   1.239 +		{
   1.240 +		EDebugAllowed = 1<<0, ///< Flags set if executable may be debugged.
   1.241 +		ETraceAllowed = 1<<1 ///< Flags set if executable may be traced.
   1.242 +		};
   1.243 +	/**
   1.244 +	The flags for process's creation.  Will be set by the loader from the images
   1.245 +	header flags ready for the kernel to use.
   1.246 +	*/
   1.247 +	enum TProcessCreateFlags
   1.248 +		{
   1.249 +		EDataPagingUnspecified	= 0x00000000,	///< Use the global data paging default.
   1.250 +		EDataPaged				= 0x00000001,	///< Page the process's data by default.
   1.251 +		EDataUnpaged			= 0x00000002,	///< Don't page the process's data by default.
   1.252 +		EDataPagingMask			= 0x00000003,	///< Bit mask ofr data paging flags.
   1.253 +		};
   1.254 +
   1.255 +	/** Default constructor that ensures flags are clear. */
   1.256 +	TProcessCreateInfo() : iFlags(0) {};
   1.257 +
   1.258 +	TInt iHeapSizeMin;
   1.259 +	TInt iHeapSizeMax;
   1.260 +	TInt iStackSize;
   1.261 +	TInt iClientHandle;			// handle to loader's client
   1.262 +	TInt iProcessHandle;		// handle to new DProcess
   1.263 +	TInt iFinalHandle;			// handle from loader client to new process
   1.264 +	TOwnerType iOwnerType;
   1.265 +	TProcessPriority iPriority;
   1.266 +	TUint iSecurityZone;
   1.267 +	TUint iDebugAttributes;	///< Set with values from TDebugAttributes.
   1.268 +	TRequestStatus* iDestructStat;
   1.269 +	TUint iFlags;	///< Flags for process creation, should set from TProcessCreateFlags.
   1.270 +	};
   1.271 +
   1.272 +const TUint KSecurityZoneUnique = 0u;
   1.273 +const TUint KSecurityZoneLegacyCode = ~0u;
   1.274 +
   1.275 +//
   1.276 +// Information required to attach a code segment to a process
   1.277 +// in the form of a library.
   1.278 +//
   1.279 +class TLibraryCreateInfo
   1.280 +	{
   1.281 +public:
   1.282 +	TAny* iCodeSegHandle;		// pointer to kernel-side DCodeSeg object
   1.283 +	TInt iClientHandle;			// handle to loader's client
   1.284 +	TInt iLibraryHandle;		// handle to new DLibrary
   1.285 +	TOwnerType iOwnerType;
   1.286 +	};
   1.287 +
   1.288 +//
   1.289 +// Information required to find an existing code segment
   1.290 +//
   1.291 +class TFindCodeSeg
   1.292 +	{
   1.293 +public:
   1.294 +	TUidType iUids;				// required UIDs
   1.295 +	const TAny* iRomImgHdr;		// ROM image header if ROM code required, NULL otherwise
   1.296 +	TUint32 iAttrMask;			// mask for attributes
   1.297 +	TUint32 iAttrVal;			// required value for masked attributes
   1.298 +	TInt iProcess;				// handle to process in which code is required to operate
   1.299 +								// not used if kernel only specified
   1.300 +	SSecurityInfo iS;			// required capabilities/SID
   1.301 +	TUint32 iModuleVersion;		// required version
   1.302 +	TBuf8<KMaxLibraryName> iName;	// name to look for - zero length means any
   1.303 +	};
   1.304 +
   1.305 +//
   1.306 +// Information required to by the reaper from the codeseg.
   1.307 +//
   1.308 +struct TCodeSegLoaderCookie
   1.309 +	{
   1.310 +	RFileClamp iFileClamp;
   1.311 +	TInt64 iStartAddress;
   1.312 +	TInt iDriveNumber;
   1.313 +	};
   1.314 +
   1.315 +//
   1.316 +// Loader magic executive functions
   1.317 +//
   1.318 +class E32Loader
   1.319 +	{
   1.320 +public:
   1.321 +	// used by loader only
   1.322 +	IMPORT_C static TInt CodeSegCreate(TCodeSegCreateInfo& aInfo);
   1.323 +	IMPORT_C static TInt CodeSegLoaded(TCodeSegCreateInfo& aInfo);
   1.324 +	IMPORT_C static TInt LibraryCreate(TLibraryCreateInfo& aInfo);
   1.325 +	IMPORT_C static TInt CodeSegOpen(TAny* aHandle, TInt aClientProcessHandle);
   1.326 +	IMPORT_C static void CodeSegClose(TAny* aHandle);
   1.327 +	IMPORT_C static void CodeSegNext(TAny*& aHandle, const TFindCodeSeg& aFind);
   1.328 +	IMPORT_C static void CodeSegInfo(TAny* aHandle, TCodeSegCreateInfo& aInfo);
   1.329 +	IMPORT_C static TInt CodeSegAddDependency(TAny* aImporter, TAny* aExporter);
   1.330 +	IMPORT_C static void CodeSegDeferDeletes();
   1.331 +	IMPORT_C static void CodeSegEndDeferDeletes();
   1.332 +	IMPORT_C static TInt ProcessCreate(TProcessCreateInfo& aInfo, const TDesC8* aCommandLine);
   1.333 +	IMPORT_C static TInt ProcessLoaded(TProcessCreateInfo& aInfo);
   1.334 +	IMPORT_C static TInt CheckClientState(TInt aClientHandle);
   1.335 +	IMPORT_C static TInt DeviceLoad(TAny* aHandle, TInt aType);
   1.336 +	IMPORT_C static TAny* ThreadProcessCodeSeg(TInt aHandle);
   1.337 +	IMPORT_C static void ReadExportDir(TAny* aHandle, TUint32* aDest);
   1.338 +	IMPORT_C static TInt LocaleExports(TAny* aHandle, TLibraryFunction* aExportsList);
   1.339 +
   1.340 +#ifdef __MARM__
   1.341 +	IMPORT_C static void GetV7StubAddresses(TLinAddr& aExe, TLinAddr& aDll);
   1.342 +	static TInt V7ExeEntryStub();
   1.343 +	static TInt V7DllEntryStub(TInt aReason);
   1.344 +#endif
   1.345 +
   1.346 +	IMPORT_C static TUint32 PagingPolicy();
   1.347 +	
   1.348 +	IMPORT_C static TInt NotifyIfCodeSegDestroyed(TRequestStatus& aStatus);
   1.349 +	IMPORT_C static TInt GetDestroyedCodeSegInfo(TCodeSegLoaderCookie& aCookie);
   1.350 +
   1.351 +public:
   1.352 +	// used by client side
   1.353 +	static TInt WaitDllLock();
   1.354 +	static TInt ReleaseDllLock();
   1.355 +	static TInt LibraryAttach(TInt aHandle, TInt& aNumEps, TLinAddr* aEpList);
   1.356 +	static TInt LibraryAttached(TInt aHandle);
   1.357 +	static TInt StaticCallList(TInt& aNumEps, TLinAddr* aEpList);
   1.358 +	static TInt LibraryDetach(TInt& aNumEps, TLinAddr* aEpList);
   1.359 +	static TInt LibraryDetached();
   1.360 +	};
   1.361 +
   1.362 +typedef TInt (*TSupervisorFunction)(TAny*);
   1.363 +
   1.364 +// Relocation types
   1.365 +/**
   1.366 +@internalTechnology
   1.367 +@released
   1.368 +*/
   1.369 +const TUint16 KReservedRelocType        = (TUint16)0x0000;
   1.370 +/**
   1.371 +@internalTechnology
   1.372 +@released
   1.373 +*/
   1.374 +const TUint16 KTextRelocType            = (TUint16)0x1000;
   1.375 +/**
   1.376 +@internalTechnology
   1.377 +@released
   1.378 +*/
   1.379 +const TUint16 KDataRelocType            = (TUint16)0x2000;
   1.380 +/**
   1.381 +@internalTechnology
   1.382 +@released
   1.383 +*/
   1.384 +const TUint16 KInferredRelocType        = (TUint16)0x3000;
   1.385 +
   1.386 +// Compression types
   1.387 +
   1.388 +/**
   1.389 +@internalTechnology
   1.390 +@released
   1.391 +*/
   1.392 +const TUint KFormatNotCompressed=0;
   1.393 +/**
   1.394 +@internalTechnology
   1.395 +@released
   1.396 +*/
   1.397 +const TUint KUidCompressionDeflate=0x101F7AFC;
   1.398 +
   1.399 +
   1.400 +const TUint KUidCompressionBytePair=0x102822AA;
   1.401 +
   1.402 +
   1.403 +#endif // __E32LDR_PRIVATE_H__
   1.404 +