|
1 // Copyright (c) 1998-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\memmodel\epoc\direct\memmodel.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 __MEMMODEL_H__ |
|
22 #define __MEMMODEL_H__ |
|
23 #include <plat_priv.h> |
|
24 |
|
25 /******************************************** |
|
26 * Process Control Block |
|
27 ********************************************/ |
|
28 |
|
29 class DMemModelChunk; |
|
30 |
|
31 /** |
|
32 @internalComponent |
|
33 */ |
|
34 class DMemModelProcess : public DEpocProcess |
|
35 { |
|
36 public: |
|
37 void Destruct(); |
|
38 public: |
|
39 virtual TInt DoCreate(TBool aKernelProcess, TProcessCreateInfo& aInfo); |
|
40 virtual TInt NewChunk(DChunk*& aChunk, SChunkCreateInfo& anInfo, TLinAddr& aRunAddr); |
|
41 virtual TInt AddChunk(DChunk* aChunk,TBool isReadOnly); |
|
42 virtual TInt NewShPool(DShPool*& aPool, TShPoolCreateInfo& aInfo); |
|
43 virtual TInt CreateDataBssStackArea(TProcessCreateInfo& aInfo); |
|
44 virtual TInt MapCodeSeg(DCodeSeg* aCodeSeg); |
|
45 virtual void UnmapCodeSeg(DCodeSeg* aCodeSeg); |
|
46 virtual void RemoveDllData(); |
|
47 virtual void FinalRelease(); |
|
48 public: |
|
49 friend class Monitor; |
|
50 }; |
|
51 |
|
52 /******************************************** |
|
53 * Chunk Control Block |
|
54 ********************************************/ |
|
55 |
|
56 /** |
|
57 @internalComponent |
|
58 */ |
|
59 class DMemModelChunk : public DChunk |
|
60 { |
|
61 public: |
|
62 enum TMemModelChunkAttributes |
|
63 { |
|
64 EPrivate=0x10000000, |
|
65 |
|
66 EMMChunkAttributesMask = EPrivate, |
|
67 }; |
|
68 |
|
69 public: |
|
70 ~DMemModelChunk(); |
|
71 public: |
|
72 // virtual TInt Close(TAny* aPtr); |
|
73 virtual TInt DoCreate(SChunkCreateInfo& anInfo); |
|
74 virtual TInt Adjust(TInt aNewSize); |
|
75 virtual TInt AdjustDoubleEnded(TInt aBottom, TInt aTop); |
|
76 virtual TInt CheckAccess(); |
|
77 virtual TInt Commit(TInt anOffset, TInt aSize, TCommitType aCommitType=DChunk::ECommitDiscontiguous, TUint32* aExtraArg=0); |
|
78 virtual TInt Allocate(TInt aSize, TInt aGuard=0, TInt aAlign=0); |
|
79 virtual TInt Decommit(TInt anOffset, TInt aSize); |
|
80 virtual TInt Lock(TInt anOffset, TInt aSize); |
|
81 virtual TInt Unlock(TInt anOffset, TInt aSize); |
|
82 virtual TInt Address(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress); |
|
83 virtual TInt PhysicalAddress(TInt aOffset, TInt aSize, TLinAddr& aKernelAddress, TUint32& aPhysicalAddress, TUint32* aPhysicalPageList=NULL); |
|
84 virtual void BTracePrime(TInt aCategory); |
|
85 virtual void Substitute(TInt aOffset, TPhysAddr aOldAddr, TPhysAddr aNewAddr); |
|
86 virtual TUint8* Base(DProcess* aProcess); |
|
87 inline TUint8* Base() const { return DChunk::Base(); } |
|
88 public: |
|
89 void SetFixedAddress(TLinAddr anAddr, TInt aSize); |
|
90 public: |
|
91 TLinAddr iRegionBase; |
|
92 TInt iRegionSize; |
|
93 public: |
|
94 friend class Monitor; |
|
95 }; |
|
96 |
|
97 /******************************************** |
|
98 * Code segment |
|
99 ********************************************/ |
|
100 |
|
101 /** |
|
102 @internalComponent |
|
103 */ |
|
104 class DMemModelCodeSegMemory : public DEpocCodeSegMemory |
|
105 { |
|
106 public: |
|
107 DMemModelCodeSegMemory(DEpocCodeSeg* aCodeSeg); |
|
108 }; |
|
109 |
|
110 /** |
|
111 @internalComponent |
|
112 */ |
|
113 class DMemModelCodeSeg: public DEpocCodeSeg |
|
114 { |
|
115 public: |
|
116 DMemModelCodeSeg(); |
|
117 virtual ~DMemModelCodeSeg(); |
|
118 virtual TInt DoCreateRam(TCodeSegCreateInfo& aInfo, DProcess* aProcess); |
|
119 virtual TInt DoCreateXIP(DProcess* aProcess); |
|
120 virtual TInt Loaded(TCodeSegCreateInfo& aInfo); |
|
121 virtual void ReadExportDir(TUint32* aDest); |
|
122 virtual TBool FindCheck(DProcess* aProcess); |
|
123 virtual TBool OpenCheck(DProcess* aProcess); |
|
124 public: |
|
125 TLinAddr iDataAlloc; |
|
126 TAny* iKernelData; // only for kernel modules |
|
127 }; |
|
128 |
|
129 /******************************************** |
|
130 * Functions/Data defined in memory model |
|
131 ********************************************/ |
|
132 |
|
133 /** |
|
134 @internalComponent |
|
135 */ |
|
136 class MM |
|
137 { |
|
138 public: |
|
139 enum TMemModelPanic |
|
140 { |
|
141 ERamAllocCreateFailed=0, |
|
142 ERamAllocMutexCreateFailed=1, |
|
143 EFreeInvalidRegion=2, |
|
144 ECodeSegCheckInconsistent=3, |
|
145 ESecAllocCreateFailed=4, |
|
146 EUnsupportedOperation=5, |
|
147 }; |
|
148 |
|
149 static void Panic(TMemModelPanic aPanic); |
|
150 public: |
|
151 static void Init1(); |
|
152 static void StartCrashDebugger(); |
|
153 static void WaitRamAlloc(); |
|
154 static void SignalRamAlloc(); |
|
155 static TUint32 RoundToBlockSize(TUint32 aSize); |
|
156 static void FreeRegion(TLinAddr aBase, TInt aSize); |
|
157 static TInt AllocRegion(TLinAddr& aBase, TInt aSize, TInt aAlign=0); |
|
158 static TInt ClaimRegion(TLinAddr aBase, TInt aSize); |
|
159 static TInt AllocContiguousRegion(TLinAddr& aBase, TInt aSize, TInt aAlign=0); |
|
160 static TInt BlockNumber(TPhysAddr aAddr); |
|
161 public: |
|
162 static TLinAddr UserDataSectionBase; |
|
163 static TLinAddr UserRomDataSectionEnd; |
|
164 static TLinAddr UserDataSectionEnd; |
|
165 static TLinAddr RomLinearBase; |
|
166 static DMutex* RamAllocatorMutex; |
|
167 static TBitMapAllocator* RamAllocator; |
|
168 static TBitMapAllocator* SecondaryAllocator; |
|
169 static TInt RamBlockSize; |
|
170 static TInt RamBlockShift; |
|
171 static TInt InitialFreeMemory; |
|
172 static TBool AllocFailed; |
|
173 }; |
|
174 |
|
175 #endif |