kernel/eka/include/e32rom.h
changeset 0 a41df078684a
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\e32rom.h
       
    15 // 
       
    16 // WARNING: This file contains some APIs which are internal and are subject
       
    17 //          to change without notice. Such APIs should therefore not be used
       
    18 //          outside the Kernel and Hardware Services package.
       
    19 //
       
    20 
       
    21 #ifndef __E32ROM_H__
       
    22 #define __E32ROM_H__
       
    23 #include <e32cmn.h>
       
    24 #include <e32def_private.h>
       
    25 
       
    26 //
       
    27 
       
    28 #ifndef __SECURITY_INFO_DEFINED__
       
    29 #define __SECURITY_INFO_DEFINED__
       
    30 /**
       
    31 @internalTechnology
       
    32 */
       
    33 //This struct must be identical in size and offset to the one in e32cmn.h
       
    34 //Functions need not be duplicated.  But must be same structurally.
       
    35 struct SCapabilitySet
       
    36 	{
       
    37 	enum {ENCapW=2};
       
    38 	TUint32 iCaps[ENCapW];
       
    39 	inline const TUint32& operator[] (TInt aIndex) const { return iCaps[aIndex]; }
       
    40 	inline TUint32& operator[] (TInt aIndex) { return iCaps[aIndex]; }
       
    41 	};
       
    42 
       
    43 /**
       
    44 @internalTechnology
       
    45 */
       
    46 //This struct must be identical in size and offset to the one in e32cmn.h
       
    47 //Functions need not be duplicated.  But must be same structurally.
       
    48 struct SSecurityInfo
       
    49 	{
       
    50 	TUint32	iSecureId;
       
    51 	TUint32	iVendorId;
       
    52 	SCapabilitySet iCaps;	
       
    53 	};
       
    54 #endif
       
    55 
       
    56 /**
       
    57 @internalTechnology
       
    58 @prototype
       
    59 */
       
    60 struct SDemandPagingConfig
       
    61 	{
       
    62 	TUint16 iMinPages;
       
    63 	TUint16 iMaxPages;
       
    64 	TUint16 iYoungOldRatio;
       
    65 	TUint16 iSpare[3];		// iSpare[0:1] are used for emulated rom paging, 
       
    66 							// iSpare[2] is used for the old to oldest ratio.
       
    67 	};
       
    68 
       
    69 /**
       
    70 @internalTechnology
       
    71 @prototype
       
    72 */
       
    73 struct SRomPageInfo
       
    74 	{
       
    75 	enum TAttributes
       
    76 		{
       
    77 		EPageable = 1<<0
       
    78 		};
       
    79 	enum TCompression  // todo: compression type not exclusive to rom pages
       
    80 		{
       
    81 		ENoCompression,
       
    82 		EBytePair,
       
    83 		};
       
    84 	TUint32 iDataStart;
       
    85 	TUint16 iDataSize;
       
    86 	TUint8  iCompressionType;
       
    87 	TUint8  iPagingAttributes;
       
    88 	};
       
    89 
       
    90 /**
       
    91 @publishedPartner
       
    92 @released
       
    93 
       
    94 Defines the size of the header for a ROM image.
       
    95 
       
    96 @see TRomHeader
       
    97 */
       
    98 const TUint KRomHeaderSize=0x200;
       
    99 //
       
   100 
       
   101 
       
   102 /**
       
   103 @publishedPartner
       
   104 @released
       
   105 
       
   106 The format of the header for a ROM image.
       
   107 
       
   108 This is retained as part of the ROM image.
       
   109 It is generated by the rombuild tool, and is used by the Bootstrap and
       
   110 the kernel.
       
   111 */
       
   112 class TRomHeader
       
   113 	{
       
   114 public:
       
   115 	enum { KDefaultDebugPort = -1 };
       
   116 	enum { KNumTraceMask = 8 };  // this is also defined in e23const.h
       
   117 
       
   118 __ASSERT_COMPILE(KNumTraceMask==KNumTraceMaskWords);
       
   119 
       
   120 public:
       
   121     /**
       
   122     Reserved for a small amount of Bootstrap code, if required.
       
   123     The first 4 bytes of the binary image typically contains
       
   124     a branch instruction which jumps to code at offset 0x100.
       
   125     */
       
   126 	TUint8 iJump[124]; 
       
   127 	
       
   128 	                                     
       
   129     /**
       
   130     The restart vector.
       
   131     */	                                     
       
   132 	TLinAddr iRestartVector;
       
   133 	
       
   134 	
       
   135 	/**
       
   136 	The date and time that the ROM image was built, in microseconds.
       
   137 	*/
       
   138 	TInt64 iTime;
       
   139 	
       
   140 	
       
   141 	/**
       
   142 	The high order 32 bits of the ROM image build date & time.
       
   143 	*/
       
   144 	TUint32 iTimeHi;
       
   145 	
       
   146 	
       
   147 	/**
       
   148 	The virtual address of the base of the ROM.
       
   149 	*/
       
   150 	TLinAddr iRomBase;
       
   151 	
       
   152 	
       
   153 	/**
       
   154 	The size of the ROM image, in bytes.
       
   155 	
       
   156 	This includes the second section for sectioned ROMs.
       
   157 	*/
       
   158 	TUint32 iRomSize;
       
   159 	
       
   160 	
       
   161 	/**
       
   162 	The virtual address of the TRomRootDirectoryList structure.
       
   163 
       
   164     @see TRomRootDirectoryList 
       
   165 	*/
       
   166 	TLinAddr iRomRootDirectoryList;
       
   167 	
       
   168 	
       
   169 	/**
       
   170 	The virtual address of kernel data, when in RAM.
       
   171 	*/
       
   172 	TLinAddr iKernDataAddress;
       
   173 	
       
   174 	
       
   175 	/**
       
   176 	The virtual address of the top of the kernel region, when in RAM.
       
   177 	*/
       
   178 	TLinAddr iKernelLimit;
       
   179 	
       
   180 	
       
   181 	/**
       
   182 	The virtual address of the primarys ROM file image header.
       
   183 
       
   184     @see TRomImageHeader 
       
   185 	*/
       
   186 	TLinAddr iPrimaryFile;
       
   187 	
       
   188 	
       
   189 	/**
       
   190 	The virtual address of the secondarys ROM file image header.
       
   191 	
       
   192 	@see TRomImageHeader 
       
   193 	*/
       
   194 	TLinAddr iSecondaryFile;
       
   195 	
       
   196 	
       
   197 	/**
       
   198 	A computed constant that causes the 32-bit checksum of the image to equal
       
   199 	the value specified by the "romchecksum" keyword.
       
   200 	*/
       
   201 	TUint iCheckSum;
       
   202 	
       
   203 	
       
   204 	/**
       
   205 	A unique number identifying the hardware for which this ROM image
       
   206 	has been built.
       
   207 
       
   208     Note that this is only used for testing purposes.
       
   209 	*/
       
   210 	TUint32 iHardware;
       
   211 	
       
   212 	
       
   213 	/**
       
   214 	A bitmask identifying which of the languages are supported by the ROM image,
       
   215 	as specified by the "languages" keyword.
       
   216 
       
   217     Note that this is only used for testing purposes.
       
   218 	*/
       
   219 	TInt64 iLanguage;
       
   220 	
       
   221 	
       
   222 	/**
       
   223 	Contains the flags that define the security options in force.
       
   224 	
       
   225 	@see TKernelConfigFlags
       
   226 	*/
       
   227 	TUint32 iKernelConfigFlags;
       
   228 
       
   229 	/**
       
   230 	The virtual address of the TRomExceptionSearchTable structure.
       
   231 
       
   232 	@see TRomExceptionSearchTable
       
   233 	*/
       
   234 	TLinAddr iRomExceptionSearchTable;
       
   235 	
       
   236 	/**
       
   237 	Current size of ROM header (Previously iUnused3)
       
   238 	If value is 0x69966996 then header size = 0x100
       
   239 	*/
       
   240 	TUint32 iRomHeaderSize;
       
   241 	
       
   242 	
       
   243 	/**
       
   244 	The virtual address of the ROM section header, if the ROM is sectioned.
       
   245 	
       
   246 	@see TRomSectionHeader
       
   247 	*/
       
   248 	TLinAddr iRomSectionHeader;
       
   249 	
       
   250 	
       
   251 	/**
       
   252 	The total supervisor data size, i.e. the amount of memory mapped for
       
   253 	the kernel data chunk.
       
   254 	*/
       
   255 	TInt iTotalSvDataSize;
       
   256 	
       
   257 	
       
   258 	/**
       
   259 	The virtual address of the TRomEntry for the Variant file.
       
   260 	
       
   261 	@see TRomEntry
       
   262 	*/
       
   263 	TLinAddr iVariantFile;
       
   264 
       
   265 	
       
   266 	/**
       
   267 	The virtual address of TRomEntry for the first extension file, if it exists.
       
   268 	
       
   269 	If there is more than one extension, then the next extension field in
       
   270 	the extensions TRomImageHeader points to the TRomEntry for
       
   271 	that next extension.
       
   272 	
       
   273     @see TRomImageHeader::iNextExtension
       
   274    	@see TRomImageHeader
       
   275 	@see TRomEntry
       
   276 	*/
       
   277 	TLinAddr iExtensionFile;
       
   278 	
       
   279 	
       
   280 	/**
       
   281 	The virtual adress of the first area to be relocated into RAM, as defined
       
   282 	using the "area" keyword.
       
   283 	*/
       
   284 	TLinAddr iRelocInfo;
       
   285 	
       
   286 	
       
   287 	/**
       
   288 	The old position of the kernel trace mask, see iTraceMask below
       
   289 	*/
       
   290 	TUint32  iOldTraceMask;		// The old location of the kernel tracemask
       
   291 	
       
   292 	
       
   293 	/**
       
   294 	The virtual address of the user data area.
       
   295 	*/
       
   296 	TLinAddr iUserDataAddress;	// non-MMU stuff
       
   297 
       
   298 	
       
   299 	/**
       
   300 	The total size of the user data.
       
   301 	*/
       
   302 	TInt iTotalUserDataSize;	// non-MMU stuff
       
   303 	
       
   304 	
       
   305 	/**
       
   306 	A value that is interpreted by the Bootstrap and kernel as the debug port
       
   307 	to be used.
       
   308 	*/
       
   309 	TUint32 iDebugPort;			// semantic is ASSP-specific
       
   310 	
       
   311 	
       
   312 	/**
       
   313 	The ROM version number.
       
   314 	*/
       
   315 	TVersion iVersion;
       
   316 	
       
   317 	
       
   318 	/**
       
   319 	The type of compression used for the image.
       
   320 	
       
   321 	This is a UID, or 0 if there is no compression.
       
   322 	*/
       
   323 	TUint32 iCompressionType;	// compression type used
       
   324 	
       
   325 	
       
   326 	/**
       
   327 	The size of the image after compression.
       
   328 	*/
       
   329 	TUint32 iCompressedSize;	// Size after compression
       
   330 	
       
   331 	
       
   332 	/**
       
   333 	The size of the image before compression.
       
   334 	*/
       
   335 	TUint32 iUncompressedSize;	// Size before compression
       
   336 	
       
   337 	
       
   338 	/**
       
   339 	*/
       
   340 	TUint32 iDisabledCapabilities[2];   // 2==SSecurityInfo::ENCapW
       
   341 
       
   342 
       
   343 	/**
       
   344 	The initial value for the kernel trace masks.
       
   345 	*/
       
   346 	TUint32  iTraceMask[KNumTraceMask];  // The kernel debug trace masks
       
   347 
       
   348 	/**
       
   349 	Initial values for fast-trace filter.
       
   350 	*/
       
   351 	TUint32 iInitialBTraceFilter[8];
       
   352 
       
   353 	/**
       
   354 	Initial value for size of fast-trace buffer.
       
   355 	*/
       
   356 	TInt iInitialBTraceBuffer;
       
   357 
       
   358 	/**
       
   359 	Initial value for size of fast-trace mode.
       
   360 	*/
       
   361 	TInt iInitialBTraceMode;
       
   362 
       
   363 	/**
       
   364 	Offset, in bytes from ROM start, for the start of the pageable ROM area.
       
   365 	*/
       
   366 	TInt iPageableRomStart;
       
   367 
       
   368 	/**
       
   369 	Size, in bytes, of the pageable ROM area.
       
   370 	*/
       
   371 	TInt iPageableRomSize;
       
   372 
       
   373 	/**
       
   374 	Offset, in bytes from ROM start, for the page index. (Array of SRomPageInfo objects.)
       
   375 	@internalTechnology
       
   376 	@prototype
       
   377 	*/
       
   378 	TInt iRomPageIndex;
       
   379 
       
   380 	/**
       
   381 	@internalTechnology
       
   382 	@prototype
       
   383 	*/
       
   384 	SDemandPagingConfig iDemandPagingConfig;
       
   385 
       
   386 	/**
       
   387 	Offset, in bytes from ROM start, for the start of compressed un-paged ROM area
       
   388 	@internalTechnology
       
   389 	@prototype
       
   390 	*/
       
   391 	TUint32 iCompressedUnpagedStart;
       
   392 	
       
   393 	
       
   394 	/**
       
   395 	Size, in bytes of the un-paged part of image after compression.
       
   396 	@internalTechnology
       
   397 	@prototype
       
   398 	*/
       
   399 	TUint32 iUnpagedCompressedSize;
       
   400 	
       
   401 	
       
   402 	/**
       
   403 	Size, in bytes of the un-paged part of image before compression.
       
   404 	@internalTechnology
       
   405 	@prototype
       
   406 	*/
       
   407 	TUint32 iUnpagedUncompressedSize;
       
   408 	
       
   409 	/**
       
   410 	The virtual address at which the start of the HCR repository file is located in the unpaged part of the Core ROM Image.
       
   411 	@internalTechnology
       
   412 	@prototype
       
   413 	*/
       
   414 	TUint32 iHcrFileAddress;
       
   415 	
       
   416 	/**
       
   417 	@internalComponent
       
   418 	*/
       
   419 	TUint32 iSpare[36];   // spare : force size to be correct
       
   420 
       
   421 	};
       
   422 
       
   423 __ASSERT_COMPILE(sizeof(TRomHeader)==KRomHeaderSize);
       
   424 __ASSERT_COMPILE(SCapabilitySet::ENCapW==2); // TRomHeader::iDisabledCapabilities has hard coded 2 because h2inc.pl does not parse scoped identifiers
       
   425 
       
   426 
       
   427 
       
   428 
       
   429 /**
       
   430 @publishedPartner
       
   431 @released
       
   432 
       
   433 Contains information about a root directory.
       
   434 
       
   435 A variable number of these are contained in a TRomRootDirectoryList structure.
       
   436 
       
   437 @see TRomRootDirectoryList
       
   438 */
       
   439 class TRootDirInfo
       
   440 	{
       
   441 public:
       
   442     /**
       
   443     The hardware variant for this root directory entry.
       
   444     */
       
   445 	TUint iHardwareVariant;
       
   446 	
       
   447 	
       
   448 	/**
       
   449 	The virtual address of the root directory.
       
   450 	
       
   451 	@see TRomDir
       
   452 	*/
       
   453 	TLinAddr iAddressLin;
       
   454 	};
       
   455 
       
   456 
       
   457 
       
   458 
       
   459 /**
       
   460 @publishedPartner
       
   461 @released
       
   462 
       
   463 A structure that allows you to find the root directories for each hardware
       
   464 Variant supported by the ROM.
       
   465 
       
   466 Usually, there is only one Variant and one root directory. However, a ROM can
       
   467 have multiple root directories and directory trees, one for each hardware Variant
       
   468 supported by the ROM. This ensures that the file server only sees the files
       
   469 that are relevant to the hardware on which it is running. In this case, there
       
   470 are multiple entries in the table describing each root directory.
       
   471 */
       
   472 class TRomRootDirectoryList
       
   473 	{
       
   474 public:
       
   475     /**
       
   476     The number of root directory entries.
       
   477     */
       
   478 	TInt iNumRootDirs;
       
   479 	
       
   480 	
       
   481 	/**
       
   482 	The root directory entries.
       
   483 
       
   484     The number of entries is defined by iNumRootDirs.
       
   485 	*/
       
   486 	TRootDirInfo iRootDir[1];
       
   487 	};
       
   488 
       
   489 
       
   490 
       
   491 
       
   492 /**
       
   493 @publishedPartner
       
   494 @released
       
   495 
       
   496 The format of a ROM section header.
       
   497 */
       
   498 class TRomSectionHeader
       
   499 	{
       
   500 public:
       
   501 
       
   502     /**
       
   503     The ROM version number.
       
   504     */
       
   505 	TVersion iVersion;
       
   506 	
       
   507 	
       
   508 	/**
       
   509 	A computed constant that causes the 32-bit checksum of the upper
       
   510 	section to equal zero.
       
   511 
       
   512 	Upper sections checksum to zero so that the overall ROM checksum in
       
   513 	the TRomHeader is unaffected by changes to this section.
       
   514 	
       
   515 	@see TRomHeader
       
   516 	*/
       
   517 	TUint iCheckSum;
       
   518 	
       
   519 	
       
   520 	/**
       
   521 	The date and time that the ROM image was built, in microseconds.
       
   522 	*/
       
   523 	TInt64 iTime;
       
   524 
       
   525 	
       
   526 	/**
       
   527 	A bitmask identifying which of the languages are supported by the ROM image,
       
   528 	as specified by the "languages" keyword.
       
   529     */
       
   530 	TInt64 iLanguage;
       
   531 	};
       
   532 //
       
   533 
       
   534 
       
   535 
       
   536 
       
   537 /**
       
   538 @publishedPartner
       
   539 @released
       
   540 
       
   541 A structure that describes a file or a directory.
       
   542 */
       
   543 class TRomEntry
       
   544 	{
       
   545 public:
       
   546     
       
   547      
       
   548     /**
       
   549     The size of the file.
       
   550     */
       
   551 	TInt iSize;
       
   552 	
       
   553 	
       
   554 	/**
       
   555 	The virtual address of the file, or of a TRomDir structure if this entry
       
   556 	describes another directory.
       
   557 	
       
   558 	@see TRomDir
       
   559 	*/
       
   560 	TUint32 iAddressLin;
       
   561 
       
   562 
       
   563 	/**
       
   564 	Attributes.
       
   565 	*/
       
   566 	TUint8 iAtt;
       
   567 
       
   568 
       
   569 	/**
       
   570 	The length of the file or directory name.
       
   571 	*/
       
   572 	TUint8 iNameLength;
       
   573 
       
   574 
       
   575 	/**
       
   576 	A variable length field containing the file or directory name.
       
   577 	*/
       
   578 	TUint8 iName[2];
       
   579 	};
       
   580 
       
   581 
       
   582 
       
   583 
       
   584 /**
       
   585 @publishedPartner
       
   586 @released
       
   587 
       
   588 The size of the fixed part of a TRomEntry structure.
       
   589 */
       
   590 const TInt KRomEntrySize=(sizeof(TRomEntry)-2);
       
   591 
       
   592 
       
   593 
       
   594 
       
   595 //
       
   596 class TRomDirSortInfo;
       
   597 
       
   598 /**
       
   599 @publishedPartner
       
   600 @released
       
   601 
       
   602 A structure that describes the first part of a ROM directory.
       
   603 
       
   604 This part of a ROM directory is a sequence of variable length entries,
       
   605 each describing a file or a subdirectory, in the order that the members
       
   606 were specified in the original obey file; the variable length entries are
       
   607 the TRomEntry structures that follow the iSize member.
       
   608 
       
   609 This part of the ROM directory is followed by a structure defined
       
   610 by TRomDirSortInfo, which contains a pair of sorted tables suitable for
       
   611 a binary search.
       
   612 
       
   613 @see TRomDirSortInfo
       
   614 */
       
   615 class TRomDir
       
   616 	{
       
   617 public:
       
   618 	inline const TRomDirSortInfo* SortInfo() const;
       
   619 	inline const TRomEntry* SortedEntry(TInt aIndex) const;
       
   620 	inline TInt SubDirCount() const;
       
   621 	inline TInt FileCount() const;
       
   622 	inline TInt EntryCount() const;
       
   623 	TInt BinarySearch(const TDesC& aName, TInt aLengthLimit, TInt aMode, TBool aDir) const;
       
   624 	const TRomDir* FindLeafDir(const TDesC& aPath) const;
       
   625 public:
       
   626 
       
   627     /**
       
   628     The number of bytes occupied by the set of TRomEntry structures
       
   629     that follow this field.
       
   630     
       
   631     @see TRomDir::iEntry
       
   632     */
       
   633 	TInt iSize;
       
   634 
       
   635 	
       
   636 	/**
       
   637 	A variable number of entries, each of which describes a file or a directory.
       
   638 	
       
   639 	Each entry is 4-byte aligned, and may have padding to ensure that the entry
       
   640 	is 4-bye aligned.
       
   641 	*/
       
   642 	TRomEntry iEntry;
       
   643 	};
       
   644 
       
   645 
       
   646 
       
   647 
       
   648 /**
       
   649 @publishedPartner
       
   650 @released
       
   651 
       
   652 A structure that describes the second part of a ROM directory.
       
   653 
       
   654 It contains a pair of sorted tables suitable for
       
   655 a binary search. The sorted tables contain unsigned 16-bit scaled offsets,
       
   656 which point to the start of the corresponding TRomEntry in the TRomDir.
       
   657 
       
   658 @see TRomDir
       
   659 */
       
   660 class TRomDirSortInfo
       
   661 	{
       
   662 public:
       
   663 
       
   664 	/**
       
   665     The number of subdirectories in this directory.
       
   666 	*/
       
   667 	TUint16	iSubDirCount;		// number of subdirectories in this directory
       
   668 	
       
   669 	
       
   670 	/**
       
   671 	The number of files in this directory.
       
   672 	*/
       
   673 	TUint16 iFileCount;			// number of non-directory files in this directory
       
   674 	
       
   675 	
       
   676 	/**
       
   677 	The two sorted tables:
       
   678 	
       
   679 	1. First one is a table of 16-bit scaled offsets to the directory entries.
       
   680 	
       
   681 	2. Second one is a table of 16-bit scaled ofsets to the file entries.
       
   682 	   This table starts at offset 2*iSubDirCount from the start of the first table.
       
   683 	   
       
   684 	If the offset is X, then the corresponding TRomEntry is at address:
       
   685 	@code
       
   686 	4*X +(char*)address of the first TRomEntry
       
   687 	@endcode
       
   688 	For example, the first entry is at offset zero.
       
   689 	
       
   690 	The entries are sorted in the order of the UTF-8 representation of
       
   691 	the names in a case insensitive way (compare the C function stricmp()).
       
   692 	In effect, this folds upper and lowercase ASCII characters but leaves all
       
   693 	other Unicode characters unchanged.
       
   694 	*/
       
   695 	TUint16 iEntryOffset[1];	// offsets of each entry from TRomDir::iEntry; extend
       
   696 								// order of offsets is directories first, then files, lexicographic order within each group
       
   697 	};
       
   698 
       
   699 
       
   700 /**
       
   701 Gets a pointer to the start of the second part of the ROM directory,
       
   702 as described by the TRomDirSortInfo structure.
       
   703 
       
   704 @return The pointer to the start of the second part of the ROM directory.
       
   705 */
       
   706 inline const TRomDirSortInfo* TRomDir::SortInfo() const
       
   707 	{ return (const TRomDirSortInfo*)( ((TLinAddr)&iEntry) + ( (iSize+sizeof(TUint32)-1) &~ (sizeof(TUint32)-1) )); }
       
   708 
       
   709 
       
   710 
       
   711 
       
   712 /**
       
   713 Gets the TRomEntry corresponding to the file or directory located at
       
   714 the specified index position within the sorted tables.
       
   715 
       
   716 @param aIndex The index of the entry within the sorted tables.
       
   717               Note that for the purpose of this function, the two tables
       
   718               are treated as one single table.
       
   719               
       
   720 @return The required TRomEntry              
       
   721 */
       
   722 inline const TRomEntry* TRomDir::SortedEntry(TInt aIndex) const
       
   723 	{
       
   724 	const TRomDirSortInfo* s = SortInfo();
       
   725 	return (const TRomEntry*)(((TLinAddr)&iEntry) + s->iEntryOffset[aIndex] * sizeof(TUint32));
       
   726 	}
       
   727 
       
   728 
       
   729 
       
   730 
       
   731 /**
       
   732 Gets the number of subdirectories in the directory.
       
   733 
       
   734 @return The number of subdirectories.
       
   735 */
       
   736 inline TInt TRomDir::SubDirCount() const
       
   737 	{ return SortInfo()->iSubDirCount; }
       
   738 
       
   739 	
       
   740 	
       
   741 	
       
   742 /**
       
   743 Gets the number of files in the directory.
       
   744 
       
   745 @return The number of files.
       
   746 */	
       
   747 inline TInt TRomDir::FileCount() const
       
   748 	{ return SortInfo()->iFileCount; }
       
   749 
       
   750 
       
   751 
       
   752 
       
   753 /**
       
   754 Gets the total number of files and subdirectories in the directory.
       
   755 
       
   756 @return The total number of files and subdirectories.
       
   757 */	
       
   758 inline TInt TRomDir::EntryCount() const
       
   759 	{
       
   760 	const TRomDirSortInfo* s = SortInfo();
       
   761 	return s->iSubDirCount + s->iFileCount;
       
   762 	}
       
   763 
       
   764 
       
   765 
       
   766 
       
   767 //
       
   768 // Header of ROM image files under the new scheme. (dlls & exes)
       
   769 //
       
   770 /**
       
   771 @publishedPartner
       
   772 @released
       
   773 */
       
   774 const TUint32 KRomImageFlagPrimary			=0x80000000u;
       
   775 
       
   776 /**
       
   777 @publishedPartner
       
   778 @released
       
   779 */
       
   780 const TUint32 KRomImageFlagVariant			=0x40000000u;
       
   781 
       
   782 /**
       
   783 @publishedPartner
       
   784 @released
       
   785 */
       
   786 const TUint32 KRomImageFlagExtension		=0x20000000u;
       
   787 
       
   788 /**
       
   789 @publishedPartner
       
   790 @released
       
   791 */
       
   792 const TUint32 KRomImageFlagDevice			=0x10000000u;
       
   793 
       
   794 /**
       
   795 @publishedPartner
       
   796 @released
       
   797 */
       
   798 const TUint32 KRomImageFlagsKernelMask		=0xf0000000u;
       
   799 
       
   800 /**
       
   801 @publishedPartner
       
   802 @released
       
   803 */
       
   804 const TUint32 KRomImageFlagSecondary		=0x08000000u;
       
   805 
       
   806 /**
       
   807 @publishedPartner
       
   808 @released
       
   809 */
       
   810 const TUint32 KRomImageFlagData				=0x04000000u;	// image has data and is not extension or variant
       
   811 
       
   812 /**
       
   813 @publishedPartner
       
   814 @released
       
   815 */
       
   816 const TUint32 KRomImageFlagDataInit			=0x02000000u;	// image or non-EXE dependencies would require data initialisation
       
   817 
       
   818 /**
       
   819 @publishedPartner
       
   820 @released
       
   821 */
       
   822 const TUint32 KRomImageFlagDataPresent		=0x01000000u;	// image or any dependencies have data
       
   823 
       
   824 /**
       
   825 @publishedPartner
       
   826 @released
       
   827 */
       
   828 const TUint32 KRomImageFlagExeInTree		=0x00800000u;	// image depends on EXE
       
   829 
       
   830 /**
       
   831 @publishedPartner
       
   832 @released
       
   833 */
       
   834 const TUint32 KRomImageFlagDll				=0x00000001u;
       
   835 
       
   836 /**
       
   837 @publishedPartner
       
   838 @released
       
   839 */
       
   840 const TUint32 KRomImageFlagFixedAddressExe	=0x00000004u;
       
   841 
       
   842 /**
       
   843 @publishedPartner
       
   844 @released
       
   845 */
       
   846 const TUint32 KRomImageABIMask				=0x00000018u;
       
   847 
       
   848 /**
       
   849 @publishedPartner
       
   850 @released
       
   851 */
       
   852 const TUint32 KRomImageABI_GCC98r2			=0x00000000u;	// for ARM
       
   853 
       
   854 /**
       
   855 @publishedPartner
       
   856 @released
       
   857 */
       
   858 const TUint32 KRomImageABI_EABI				=0x00000008u;	// for ARM
       
   859 
       
   860 /**
       
   861 @publishedPartner
       
   862 @released
       
   863 */
       
   864 const TUint32 KRomImageEptMask				=0x000000e0u;	// entry point type
       
   865 
       
   866 /**
       
   867 @publishedPartner
       
   868 @released
       
   869 */
       
   870 const TInt	  KRomImageEptShift				=5;
       
   871 
       
   872 /**
       
   873 @publishedPartner
       
   874 @released
       
   875 */
       
   876 const TUint32 KRomImageEpt_Eka1				=0x00000000u;
       
   877 
       
   878 /**
       
   879 @publishedPartner
       
   880 @released
       
   881 */
       
   882 const TUint32 KRomImageEpt_Eka2				=0x00000020u;
       
   883 
       
   884 /**
       
   885 Flag to indicate the image should not be code paged.
       
   886 @internalTechnology
       
   887 @released
       
   888 */
       
   889 const TUint KRomImageFlagCodeUnpaged			=0x00000100u;
       
   890 
       
   891 
       
   892 /**
       
   893 Flag to indicate the image should be code paged.
       
   894 @internalTechnology
       
   895 @released
       
   896 */
       
   897 const TUint KRomImageFlagCodePaged				=0x00000200u;
       
   898 
       
   899 
       
   900 /**
       
   901 @internalTechnology
       
   902 @released
       
   903 Flag to indicate when named symbol export data present in image
       
   904 */
       
   905 const TUint KRomImageNmdExpData				=0x00000400u;
       
   906 
       
   907 /**
       
   908 @internalTechnology
       
   909 @released
       
   910 Flag to indicate debuggability of this image.
       
   911 */
       
   912 const TUint KRomImageDebuggable				=0x00000800u;
       
   913 
       
   914 /**
       
   915 Flag to indicate the image will default to not be data paged,
       
   916 this can be overridden when creating chunks, threads and user heaps.
       
   917 @internalTechnology
       
   918 @released
       
   919 */
       
   920 const TUint KRomImageFlagDataUnpaged			= 0x00001000u;
       
   921 
       
   922 /**
       
   923 Flag to indicate the image will default to be data paged,
       
   924 this can be overridden when creating chunks, threads and user heaps.
       
   925 @internalTechnology
       
   926 @released
       
   927 */
       
   928 const TUint KRomImageFlagDataPaged			= 0x00002000u;
       
   929 
       
   930 /**
       
   931 Mask for the data paging flag bits.
       
   932 @internalTechnology
       
   933 @released
       
   934 */
       
   935 const TUint KRomImageDataPagingMask	= KRomImageFlagDataUnpaged | KRomImageFlagDataPaged;
       
   936 
       
   937 /**
       
   938 @released
       
   939 Flag to indicate SMP safety of this image.
       
   940 */
       
   941 const TUint KRomImageSMPSafe			=0x00004000u;
       
   942 
       
   943 class TDllRefTable;
       
   944 
       
   945 /**
       
   946 @publishedPartner
       
   947 @released
       
   948 
       
   949 The format of the header for a ROM file image.
       
   950 
       
   951 The structure of a file image is based on the native image file format,
       
   952 but this can be compressed in the ROM image, as the relocation information
       
   953 and the .idata section are discarded once the file is fixed up.
       
   954 
       
   955 The Import Address Table (IAT) is also removed and each reference to
       
   956 an IAT entry is converted into a reference to the associated Export Directory
       
   957 entry in the corresponding DLL.
       
   958 
       
   959 ROM file images have the following sections:
       
   960 
       
   961 @code
       
   962 The header (as described by this structure)
       
   963 .text  - code
       
   964 .rdata - constant (read-only) data
       
   965 .edata - the export directory
       
   966 .data  - initialised data that is copied to RAM when the executable runs.
       
   967 The DLL reference table (a TDllRefTable structure), which is a list of DLLs
       
   968 used by the executable.
       
   969 @endcode
       
   970 
       
   971 @see TRomImageHeader::iDllRefTable
       
   972 @see TDllRefTable
       
   973 */
       
   974 class TRomImageHeader
       
   975 	{
       
   976 public:
       
   977 
       
   978     /**
       
   979     The UID1 for the file.
       
   980     
       
   981     @see TUidType
       
   982     */
       
   983 	TUint32	iUid1;
       
   984 
       
   985 	
       
   986     /**
       
   987     The UID2 for the file.
       
   988 
       
   989     @see TUidType
       
   990     */
       
   991 	TUint32	iUid2;
       
   992 
       
   993 	
       
   994     /**
       
   995     The UID3 for the file.
       
   996 
       
   997     @see TUidType
       
   998     */
       
   999 	TUint32	iUid3;
       
  1000 	
       
  1001 	
       
  1002 	/**
       
  1003 	The checksum of the UIDs
       
  1004 	*/
       
  1005 	TUint32	iUidChecksum;
       
  1006 	
       
  1007 	
       
  1008 	/**
       
  1009 	The entrypoint of this executable, i.e. the offset within this file.
       
  1010 	*/
       
  1011 	TUint32 iEntryPoint;
       
  1012 	
       
  1013 	
       
  1014 	/**
       
  1015 	This executables code address.
       
  1016 	*/
       
  1017 	TUint32 iCodeAddress;
       
  1018 
       
  1019 
       
  1020 	/**
       
  1021 	This executables data address.
       
  1022 	*/
       
  1023 	TUint32 iDataAddress;
       
  1024 
       
  1025 	
       
  1026 	/**
       
  1027 	The size of the code.
       
  1028 	
       
  1029 	This includes the size of the constant data.
       
  1030 	*/
       
  1031 	TInt iCodeSize;
       
  1032 	
       
  1033 	
       
  1034 	/**
       
  1035 	The size of the executable code.
       
  1036 	
       
  1037 	This is the value of (iCodeSize - the size of the constant data).
       
  1038 	*/
       
  1039 	TInt iTextSize;
       
  1040 	
       
  1041 	
       
  1042 	/**
       
  1043 	The data size.
       
  1044 	*/
       
  1045 	TInt iDataSize;
       
  1046 	
       
  1047 	
       
  1048 	/**
       
  1049 	The size of the .bss (the zero-filled data)
       
  1050 	*/
       
  1051 	TInt iBssSize;
       
  1052 	
       
  1053 	
       
  1054 	/**
       
  1055 	The minimum size of the heap.
       
  1056 	*/
       
  1057 	TInt iHeapSizeMin;
       
  1058 	
       
  1059 	
       
  1060 	/**
       
  1061 	The maximum size of the heap.
       
  1062 	*/
       
  1063 	TInt iHeapSizeMax;
       
  1064 	
       
  1065 	
       
  1066 	/**
       
  1067 	The size of the stack.
       
  1068 	*/
       
  1069 	TInt iStackSize;
       
  1070 	
       
  1071 	
       
  1072 	/**
       
  1073 	The address of the DLL reference table.
       
  1074 	
       
  1075 	@see TDllRefTable
       
  1076 	*/
       
  1077 	TDllRefTable* iDllRefTable;
       
  1078 	
       
  1079 	
       
  1080 	/**
       
  1081 	The number of functions exported by this executable.
       
  1082 	*/
       
  1083 	TInt iExportDirCount;
       
  1084 	
       
  1085 	
       
  1086 	/**
       
  1087 	The address of the export directory, which is a simple list of functions
       
  1088 	that can be indexed by ordinal.
       
  1089 	*/
       
  1090 	TUint32 iExportDir;
       
  1091 	
       
  1092 	
       
  1093 	/**
       
  1094 	Security information, details of which are internal to Symbian.
       
  1095 	*/
       
  1096 	SSecurityInfo iS;
       
  1097 	
       
  1098 	
       
  1099 	/**
       
  1100 	The version number of the tools used to generate this file image.
       
  1101 	*/
       
  1102 	TVersion iToolsVersion;
       
  1103 	
       
  1104 	
       
  1105 	/**
       
  1106 	Flags field.
       
  1107 	*/
       
  1108 	TUint32 iFlags;
       
  1109 	
       
  1110 	
       
  1111 	/**
       
  1112 	The priority of the process.
       
  1113 	*/
       
  1114 	TProcessPriority iPriority;
       
  1115 	
       
  1116 	
       
  1117 	/**
       
  1118 	The virtual base address of the data and .bss, where the process expects
       
  1119 	its data chunk to be when it runs.
       
  1120 	*/
       
  1121 	TUint32 iDataBssLinearBase;
       
  1122 	
       
  1123 	
       
  1124 	/**
       
  1125 	The address of the TRomEntry for the next extension file.
       
  1126 	
       
  1127 	This field is only used if there is more than one extension.
       
  1128 	The first extension is found using the TRomHeader.
       
  1129 	
       
  1130 	@see TRomEntry
       
  1131 	@see TRomHeader
       
  1132 	*/
       
  1133 	TLinAddr iNextExtension;
       
  1134 	
       
  1135 	
       
  1136 	/**
       
  1137 	A number denoting the hardware Variant.
       
  1138 	
       
  1139 	It is used to determine whether this executable can run
       
  1140 	on a given system.
       
  1141 	*/
       
  1142 	TUint32 iHardwareVariant;
       
  1143 	
       
  1144 	
       
  1145 	/**
       
  1146 	The total data size, including space reserved for DLLs
       
  1147 	*/
       
  1148 	TInt iTotalDataSize;	// data+bss + space reserved for DLLs
       
  1149 	
       
  1150 	
       
  1151 	/**
       
  1152 	The module version.
       
  1153 	*/
       
  1154 	TUint32 iModuleVersion;
       
  1155 
       
  1156 	/**
       
  1157 	The address of the Exception Descriptor if present.
       
  1158 	0 if no Exception descriptor
       
  1159 	*/
       
  1160 	TLinAddr iExceptionDescriptor;
       
  1161 	};	
       
  1162 	
       
  1163 	
       
  1164 	
       
  1165 	
       
  1166 //
       
  1167 // Header for extension ROMs
       
  1168 // Equivalent to TRomHeader
       
  1169 //
       
  1170 
       
  1171 /**
       
  1172 @publishedPartner
       
  1173 @released
       
  1174 
       
  1175 The format of a ROM extension header.
       
  1176 */
       
  1177 class TExtensionRomHeader
       
  1178 	{	
       
  1179 public:
       
  1180     
       
  1181     /**
       
  1182     The extension ROM image version number.
       
  1183     */
       
  1184 	TVersion iVersion;
       
  1185 	
       
  1186 	
       
  1187 	/**
       
  1188 	The virtual address of the base of the extension ROM.
       
  1189 	*/
       
  1190 	TLinAddr iRomBase;
       
  1191 	
       
  1192 	
       
  1193 	/**
       
  1194 	The size of the extension ROM image.
       
  1195 	*/
       
  1196 	TUint32 iRomSize;
       
  1197 	
       
  1198 	
       
  1199 	/**
       
  1200 	The virtual address of the TRomRootDirList structure for
       
  1201 	the combined kernel+extension ROM image.
       
  1202 	
       
  1203 	@see TRomRootDirList
       
  1204 	*/
       
  1205 	TLinAddr iRomRootDirectoryList;
       
  1206 	
       
  1207 	
       
  1208 	/**
       
  1209 	The date and time that the extension ROM image was built, in microseconds.
       
  1210 	*/
       
  1211 	TInt64 iTime;
       
  1212 	
       
  1213 	
       
  1214 	/**
       
  1215 	The extension ROM image checksum
       
  1216 	*/
       
  1217 	TUint iCheckSum;
       
  1218 
       
  1219 
       
  1220 	//
       
  1221 	/**
       
  1222 	Copy of the kernel ROM image version number.
       
  1223 	*/
       
  1224 	TVersion iKernelVersion;
       
  1225 	
       
  1226 	
       
  1227 	/**
       
  1228 	Copy of the kernel ROM image build date & time.
       
  1229 	*/
       
  1230 	TInt64 iKernelTime;
       
  1231 	
       
  1232 	
       
  1233 	/**
       
  1234 	Copy of the kernel ROM image checksum.
       
  1235 	*/
       
  1236 	TUint iKernelCheckSum;
       
  1237 	//
       
  1238 
       
  1239 
       
  1240 	/**
       
  1241 	The type of compression used for the image.
       
  1242 	
       
  1243 	This is a UID, or 0 if there is no compression.
       
  1244 	*/
       
  1245 	TUint32 iCompressionType;	// compression type used
       
  1246 	
       
  1247 	
       
  1248 	/**
       
  1249 	The size of the image after compression.
       
  1250 	*/
       
  1251 	TUint32 iCompressedSize;	// Size after compression
       
  1252 	
       
  1253 	
       
  1254 	/**
       
  1255 	The size of the image before compression.
       
  1256 	*/
       
  1257 	TUint32 iUncompressedSize;	// Size before compression
       
  1258 	
       
  1259 	
       
  1260 	/**
       
  1261 	The virtual address of the TRomExceptionSearchTable structure.
       
  1262 
       
  1263 	@see TRomExceptionSearchTable
       
  1264 	*/
       
  1265 	TLinAddr iRomExceptionSearchTable;
       
  1266 
       
  1267 	
       
  1268 	/**
       
  1269 	Reserved for future use.
       
  1270 	*/
       
  1271 	TUint32 iPad[32-15]; // sizeof(TExtensionRomHeader)=128
       
  1272 	};
       
  1273 
       
  1274 
       
  1275 
       
  1276 
       
  1277 
       
  1278 /**
       
  1279 @publishedPartner
       
  1280 @released
       
  1281 
       
  1282 A list of DLLs that an executable needs in order to run.
       
  1283 
       
  1284 Each DLL referenced in this list has a pointer to a TRomImageHeader structure
       
  1285 that describes that DLL. This allows the DLL loader to search
       
  1286 a dependency chain, and ensure that all required DLLs are loaded.
       
  1287 
       
  1288 @see TRomImageHeader
       
  1289 */
       
  1290 class TDllRefTable
       
  1291 	{
       
  1292 public:
       
  1293 
       
  1294     /**
       
  1295     Flags field.
       
  1296     */
       
  1297 	TUint16 iFlags;
       
  1298 	
       
  1299 	
       
  1300 	/**
       
  1301 	The number of referenced DLLs in this list.
       
  1302 	*/
       
  1303 	TUint16 iNumberOfEntries;
       
  1304 	
       
  1305 	
       
  1306 	/**
       
  1307 	A set of pointers to the TRomImageHeader structures for each referenced DLL.
       
  1308 	*/
       
  1309 	TRomImageHeader* iEntry[1];
       
  1310 	};
       
  1311 
       
  1312 #endif
       
  1313