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 "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\include\e32rom.h
23 #ifndef __SECURITY_INFO_DEFINED__
24 #define __SECURITY_INFO_DEFINED__
28 //This struct must be identical in size and offset to the one in e32cmn.h
29 //Functions need not be duplicated. But must be same structurally.
33 TUint32 iCaps[ENCapW];
34 inline const TUint32& operator[] (TInt aIndex) const { return iCaps[aIndex]; }
35 inline TUint32& operator[] (TInt aIndex) { return iCaps[aIndex]; }
41 //This struct must be identical in size and offset to the one in e32cmn.h
42 //Functions need not be duplicated. But must be same structurally.
55 struct SDemandPagingConfig
59 TUint16 iYoungOldRatio;
80 TUint8 iCompressionType;
81 TUint8 iPagingAttributes;
88 Defines the size of the header for a ROM image.
92 const TUint KRomHeaderSize=0x200;
100 The format of the header for a ROM image.
102 This is retained as part of the ROM image.
103 It is generated by the rombuild tool, and is used by the Bootstrap and
109 enum { KDefaultDebugPort = -1 };
110 enum { KNumTraceMask = 8 }; // this is also defined in e23const.h
112 __ASSERT_COMPILE(KNumTraceMask==KNumTraceMaskWords);
116 Reserved for a small amount of Bootstrap code, if required.
117 The first 4 bytes of the binary image typically contains
118 a branch instruction which jumps to code at offset 0x100.
126 TLinAddr iRestartVector;
130 The date and time that the ROM image was built, in microseconds.
136 The high order 32 bits of the ROM image build date & time.
142 The virtual address of the base of the ROM.
148 The size of the ROM image, in bytes.
150 This includes the second section for sectioned ROMs.
156 The virtual address of the TRomRootDirectoryList structure.
158 @see TRomRootDirectoryList
160 TLinAddr iRomRootDirectoryList;
164 The virtual address of kernel data, when in RAM.
166 TLinAddr iKernDataAddress;
170 The virtual address of the top of the kernel region, when in RAM.
172 TLinAddr iKernelLimit;
176 The virtual address of the primarys ROM file image header.
180 TLinAddr iPrimaryFile;
184 The virtual address of the secondarys ROM file image header.
188 TLinAddr iSecondaryFile;
192 A computed constant that causes the 32-bit checksum of the image to equal
193 the value specified by the "romchecksum" keyword.
199 A unique number identifying the hardware for which this ROM image
202 Note that this is only used for testing purposes.
208 A bitmask identifying which of the languages are supported by the ROM image,
209 as specified by the "languages" keyword.
211 Note that this is only used for testing purposes.
217 Contains the flags that define the security options in force.
219 @see TKernelConfigFlags
221 TUint32 iKernelConfigFlags;
224 The virtual address of the TRomExceptionSearchTable structure.
226 @see TRomExceptionSearchTable
228 TLinAddr iRomExceptionSearchTable;
231 Current size of ROM header (Previously iUnused3)
232 If value is 0x69966996 then header size = 0x100
234 TUint32 iRomHeaderSize;
238 The virtual address of the ROM section header, if the ROM is sectioned.
240 @see TRomSectionHeader
242 TLinAddr iRomSectionHeader;
246 The total supervisor data size, i.e. the amount of memory mapped for
247 the kernel data chunk.
249 TInt iTotalSvDataSize;
253 The virtual address of the TRomEntry for the Variant file.
257 TLinAddr iVariantFile;
261 The virtual address of TRomEntry for the first extension file, if it exists.
263 If there is more than one extension, then the next extension field in
264 the extensions TRomImageHeader points to the TRomEntry for
267 @see TRomImageHeader::iNextExtension
271 TLinAddr iExtensionFile;
275 The virtual adress of the first area to be relocated into RAM, as defined
276 using the "area" keyword.
282 The old position of the kernel trace mask, see iTraceMask below
284 TUint32 iOldTraceMask; // The old location of the kernel tracemask
288 The virtual address of the user data area.
290 TLinAddr iUserDataAddress; // non-MMU stuff
294 The total size of the user data.
296 TInt iTotalUserDataSize; // non-MMU stuff
300 A value that is interpreted by the Bootstrap and kernel as the debug port
303 TUint32 iDebugPort; // semantic is ASSP-specific
307 The ROM version number.
313 The type of compression used for the image.
315 This is a UID, or 0 if there is no compression.
317 TUint32 iCompressionType; // compression type used
321 The size of the image after compression.
323 TUint32 iCompressedSize; // Size after compression
327 The size of the image before compression.
329 TUint32 iUncompressedSize; // Size before compression
334 TUint32 iDisabledCapabilities[2]; // 2==SSecurityInfo::ENCapW
338 The initial value for the kernel trace masks.
340 TUint32 iTraceMask[KNumTraceMask]; // The kernel debug trace masks
343 Initial values for fast-trace filter.
345 TUint32 iInitialBTraceFilter[8];
348 Initial value for size of fast-trace buffer.
350 TInt iInitialBTraceBuffer;
353 Initial value for size of fast-trace mode.
355 TInt iInitialBTraceMode;
358 Offset, in bytes from ROM start, for the start of the pageable ROM area.
360 TInt iPageableRomStart;
363 Size, in bytes, of the pageable ROM area.
365 TInt iPageableRomSize;
368 Offset, in bytes from ROM start, for the page index. (Array of SRomPageInfo objects.)
378 SDemandPagingConfig iDemandPagingConfig;
383 TUint32 iSpare[40]; // spare : force size to be correct
387 __ASSERT_COMPILE(sizeof(TRomHeader)==KRomHeaderSize);
388 __ASSERT_COMPILE(SCapabilitySet::ENCapW==2); // TRomHeader::iDisabledCapabilities has hard coded 2 because h2inc.pl does not parse scoped identifiers
397 Contains information about a root directory.
399 A variable number of these are contained in a TRomRootDirectoryList structure.
401 @see TRomRootDirectoryList
407 The hardware variant for this root directory entry.
409 TUint iHardwareVariant;
413 The virtual address of the root directory.
417 TLinAddr iAddressLin;
427 A structure that allows you to find the root directories for each hardware
428 Variant supported by the ROM.
430 Usually, there is only one Variant and one root directory. However, a ROM can
431 have multiple root directories and directory trees, one for each hardware Variant
432 supported by the ROM. This ensures that the file server only sees the files
433 that are relevant to the hardware on which it is running. In this case, there
434 are multiple entries in the table describing each root directory.
436 class TRomRootDirectoryList
440 The number of root directory entries.
446 The root directory entries.
448 The number of entries is defined by iNumRootDirs.
450 TRootDirInfo iRootDir[1];
460 The format of a ROM section header.
462 class TRomSectionHeader
467 The ROM version number.
473 A computed constant that causes the 32-bit checksum of the upper
474 section to equal zero.
476 Upper sections checksum to zero so that the overall ROM checksum in
477 the TRomHeader is unaffected by changes to this section.
485 The date and time that the ROM image was built, in microseconds.
491 A bitmask identifying which of the languages are supported by the ROM image,
492 as specified by the "languages" keyword.
505 A structure that describes a file or a directory.
513 The size of the file.
519 The virtual address of the file, or of a TRomDir structure if this entry
520 describes another directory.
534 The length of the file or directory name.
540 A variable length field containing the file or directory name.
552 The size of the fixed part of a TRomEntry structure.
554 const TInt KRomEntrySize=(sizeof(TRomEntry)-2);
560 class TRomDirSortInfo;
566 A structure that describes the first part of a ROM directory.
568 This part of a ROM directory is a sequence of variable length entries,
569 each describing a file or a subdirectory, in the order that the members
570 were specified in the original obey file; the variable length entries are
571 the TRomEntry structures that follow the iSize member.
573 This part of the ROM directory is followed by a structure defined
574 by TRomDirSortInfo, which contains a pair of sorted tables suitable for
582 inline const TRomDirSortInfo* SortInfo() const;
583 inline const TRomEntry* SortedEntry(TInt aIndex) const;
584 inline TInt SubDirCount() const;
585 inline TInt FileCount() const;
586 inline TInt EntryCount() const;
587 TInt BinarySearch(const TDesC& aName, TInt aLengthLimit, TInt aMode, TBool aDir) const;
588 const TRomDir* FindLeafDir(const TDesC& aPath) const;
592 The number of bytes occupied by the set of TRomEntry structures
593 that follow this field.
601 A variable number of entries, each of which describes a file or a directory.
603 Each entry is 4-byte aligned, and may have padding to ensure that the entry
616 A structure that describes the second part of a ROM directory.
618 It contains a pair of sorted tables suitable for
619 a binary search. The sorted tables contain unsigned 16-bit scaled offsets,
620 which point to the start of the corresponding TRomEntry in the TRomDir.
624 class TRomDirSortInfo
629 The number of subdirectories in this directory.
631 TUint16 iSubDirCount; // number of subdirectories in this directory
635 The number of files in this directory.
637 TUint16 iFileCount; // number of non-directory files in this directory
641 The two sorted tables:
643 1. First one is a table of 16-bit scaled offsets to the directory entries.
645 2. Second one is a table of 16-bit scaled ofsets to the file entries.
646 This table starts at offset 2*iSubDirCount from the start of the first table.
648 If the offset is X, then the corresponding TRomEntry is at address:
650 4*X +(char*)address of the first TRomEntry
652 For example, the first entry is at offset zero.
654 The entries are sorted in the order of the UTF-8 representation of
655 the names in a case insensitive way (compare the C function stricmp()).
656 In effect, this folds upper and lowercase ASCII characters but leaves all
657 other Unicode characters unchanged.
659 TUint16 iEntryOffset[1]; // offsets of each entry from TRomDir::iEntry; extend
660 // order of offsets is directories first, then files, lexicographic order within each group
665 Gets a pointer to the start of the second part of the ROM directory,
666 as described by the TRomDirSortInfo structure.
668 @return The pointer to the start of the second part of the ROM directory.
670 inline const TRomDirSortInfo* TRomDir::SortInfo() const
671 { return (const TRomDirSortInfo*)( ((TLinAddr)&iEntry) + ( (iSize+sizeof(TUint32)-1) &~ (sizeof(TUint32)-1) )); }
677 Gets the TRomEntry corresponding to the file or directory located at
678 the specified index position within the sorted tables.
680 @param aIndex The index of the entry within the sorted tables.
681 Note that for the purpose of this function, the two tables
682 are treated as one single table.
684 @return The required TRomEntry
686 inline const TRomEntry* TRomDir::SortedEntry(TInt aIndex) const
688 const TRomDirSortInfo* s = SortInfo();
689 return (const TRomEntry*)(((TLinAddr)&iEntry) + s->iEntryOffset[aIndex] * sizeof(TUint32));
696 Gets the number of subdirectories in the directory.
698 @return The number of subdirectories.
700 inline TInt TRomDir::SubDirCount() const
701 { return SortInfo()->iSubDirCount; }
707 Gets the number of files in the directory.
709 @return The number of files.
711 inline TInt TRomDir::FileCount() const
712 { return SortInfo()->iFileCount; }
718 Gets the total number of files and subdirectories in the directory.
720 @return The total number of files and subdirectories.
722 inline TInt TRomDir::EntryCount() const
724 const TRomDirSortInfo* s = SortInfo();
725 return s->iSubDirCount + s->iFileCount;
732 // Header of ROM image files under the new scheme. (dlls & exes)
738 const TUint32 KRomImageFlagPrimary =0x80000000u;
744 const TUint32 KRomImageFlagVariant =0x40000000u;
750 const TUint32 KRomImageFlagExtension =0x20000000u;
756 const TUint32 KRomImageFlagDevice =0x10000000u;
762 const TUint32 KRomImageFlagsKernelMask =0xf0000000u;
768 const TUint32 KRomImageFlagSecondary =0x08000000u;
774 const TUint32 KRomImageFlagData =0x04000000u; // image has data and is not extension or variant
780 const TUint32 KRomImageFlagDataInit =0x02000000u; // image or non-EXE dependencies would require data initialisation
786 const TUint32 KRomImageFlagDataPresent =0x01000000u; // image or any dependencies have data
792 const TUint32 KRomImageFlagExeInTree =0x00800000u; // image depends on EXE
798 const TUint32 KRomImageFlagDll =0x00000001u;
804 const TUint32 KRomImageFlagFixedAddressExe =0x00000004u;
810 const TUint32 KRomImageABIMask =0x00000018u;
816 const TUint32 KRomImageABI_GCC98r2 =0x00000000u; // for ARM
822 const TUint32 KRomImageABI_EABI =0x00000008u; // for ARM
828 const TUint32 KRomImageEptMask =0x000000e0u; // entry point type
834 const TInt KRomImageEptShift =5;
840 const TUint32 KRomImageEpt_Eka1 =0x00000000u;
846 const TUint32 KRomImageEpt_Eka2 =0x00000020u;
852 const TUint KRomImageFlagUnpaged =0x00000100u;
859 const TUint KRomImageFlagPaged =0x00000200u;
865 Flag to indicate when named symbol export data present in image
867 const TUint KRomImageNmdExpData =0x00000400u;
872 Flag to indicate debuggability of this image.
874 const TUint KRomImageDebuggable =0x00000800u;
882 The format of the header for a ROM file image.
884 The structure of a file image is based on the native image file format,
885 but this can be compressed in the ROM image, as the relocation information
886 and the .idata section are discarded once the file is fixed up.
888 The Import Address Table (IAT) is also removed and each reference to
889 an IAT entry is converted into a reference to the associated Export Directory
890 entry in the corresponding DLL.
892 ROM file images have the following sections:
895 The header (as described by this structure)
897 .rdata - constant (read-only) data
898 .edata - the export directory
899 .data - initialised data that is copied to RAM when the executable runs.
900 The DLL reference table (a TDllRefTable structure), which is a list of DLLs
901 used by the executable.
904 @see TRomImageHeader::iDllRefTable
907 class TRomImageHeader
912 The UID1 for the file.
920 The UID2 for the file.
928 The UID3 for the file.
936 The checksum of the UIDs
938 TUint32 iUidChecksum;
942 The entrypoint of this executable, i.e. the offset within this file.
948 This executables code address.
950 TUint32 iCodeAddress;
954 This executables data address.
956 TUint32 iDataAddress;
960 The size of the code.
962 This includes the size of the constant data.
968 The size of the executable code.
970 This is the value of (iCodeSize - the size of the constant data).
982 The size of the .bss (the zero-filled data)
988 The minimum size of the heap.
994 The maximum size of the heap.
1000 The size of the stack.
1006 The address of the DLL reference table.
1010 TDllRefTable* iDllRefTable;
1014 The number of functions exported by this executable.
1016 TInt iExportDirCount;
1020 The address of the export directory, which is a simple list of functions
1021 that can be indexed by ordinal.
1027 Security information, details of which are internal to Symbian.
1033 The version number of the tools used to generate this file image.
1035 TVersion iToolsVersion;
1045 The priority of the process.
1047 TProcessPriority iPriority;
1051 The virtual base address of the data and .bss, where the process expects
1052 its data chunk to be when it runs.
1054 TUint32 iDataBssLinearBase;
1058 The address of the TRomEntry for the next extension file.
1060 This field is only used if there is more than one extension.
1061 The first extension is found using the TRomHeader.
1066 TLinAddr iNextExtension;
1070 A number denoting the hardware Variant.
1072 It is used to determine whether this executable can run
1075 TUint32 iHardwareVariant;
1079 The total data size, including space reserved for DLLs
1081 TInt iTotalDataSize; // data+bss + space reserved for DLLs
1087 TUint32 iModuleVersion;
1090 The address of the Exception Descriptor if present.
1091 0 if no Exception descriptor
1093 TLinAddr iExceptionDescriptor;
1100 // Header for extension ROMs
1101 // Equivalent to TRomHeader
1108 The format of a ROM extension header.
1110 class TExtensionRomHeader
1115 The extension ROM image version number.
1121 The virtual address of the base of the extension ROM.
1127 The size of the extension ROM image.
1133 The virtual address of the TRomRootDirList structure for
1134 the combined kernel+extension ROM image.
1136 @see TRomRootDirList
1138 TLinAddr iRomRootDirectoryList;
1142 The date and time that the extension ROM image was built, in microseconds.
1148 The extension ROM image checksum
1155 Copy of the kernel ROM image version number.
1157 TVersion iKernelVersion;
1161 Copy of the kernel ROM image build date & time.
1167 Copy of the kernel ROM image checksum.
1169 TUint iKernelCheckSum;
1174 The type of compression used for the image.
1176 This is a UID, or 0 if there is no compression.
1178 TUint32 iCompressionType; // compression type used
1182 The size of the image after compression.
1184 TUint32 iCompressedSize; // Size after compression
1188 The size of the image before compression.
1190 TUint32 iUncompressedSize; // Size before compression
1194 The virtual address of the TRomExceptionSearchTable structure.
1196 @see TRomExceptionSearchTable
1198 TLinAddr iRomExceptionSearchTable;
1202 Reserved for future use.
1204 TUint32 iPad[32-15]; // sizeof(TExtensionRomHeader)=128
1215 A list of DLLs that an executable needs in order to run.
1217 Each DLL referenced in this list has a pointer to a TRomImageHeader structure
1218 that describes that DLL. This allows the DLL loader to search
1219 a dependency chain, and ensure that all required DLLs are loaded.
1221 @see TRomImageHeader
1234 The number of referenced DLLs in this list.
1236 TUint16 iNumberOfEntries;
1240 A set of pointers to the TRomImageHeader structures for each referenced DLL.
1242 TRomImageHeader* iEntry[1];