113 } |
113 } |
114 |
114 |
115 RamAllocLock::Lock(); |
115 RamAllocLock::Lock(); |
116 |
116 |
117 // Move the page to any RAM zone. |
117 // Move the page to any RAM zone. |
118 r = M::MovePage(aOld, aNew, KRamZoneInvalidId, EFalse); |
118 r = M::MovePage(aOld, aNew, KRamZoneInvalidId, 0); |
119 |
119 |
120 RamAllocLock::Unlock(); |
120 RamAllocLock::Unlock(); |
121 return r; |
121 return r; |
122 } |
122 } |
123 |
123 |
124 |
124 |
125 TInt M::MovePage(TPhysAddr aOld, TPhysAddr& aNew, TUint aBlockZoneId, TBool aBlockRest) |
125 TInt M::MovePage(TPhysAddr aOld, TPhysAddr& aNew, TUint aBlockZoneId, TUint aMoveDisFlags) |
126 { |
126 { |
127 // Returns this when page is not paged or managed or free but is a real RAM page. |
127 // Returns this when page is not paged or managed or free but is a real RAM page. |
128 TInt r = KErrNotSupported; |
128 TInt r = KErrNotSupported; |
129 |
129 |
130 // get memory object corresponding to the page... |
130 // get memory object corresponding to the page... |
131 DMemoryObject* memory = 0; |
131 DMemoryObject* memory = 0; |
132 MmuLock::Lock(); |
132 MmuLock::Lock(); |
133 SPageInfo* pi = SPageInfo::SafeFromPhysAddr(aOld&~KPageMask); |
133 SPageInfo* pi = SPageInfo::SafeFromPhysAddr(aOld & ~KPageMask); |
134 if(pi) |
134 if (pi) |
135 { |
135 { |
136 if (pi->PagedState() != SPageInfo::EUnpaged) |
136 if (pi->PagedState() != SPageInfo::EUnpaged) |
137 {// The page is paged so let the pager handle it. |
137 {// The page is paged so let the pager handle it. |
138 return ThePager.DiscardPage(pi, aBlockZoneId, aBlockRest); |
138 return ThePager.DiscardPage(pi, aBlockZoneId, aMoveDisFlags); |
139 } |
139 } |
140 switch (pi->Type()) |
140 switch (pi->Type()) |
141 { |
141 { |
142 case SPageInfo::EManaged: |
142 case SPageInfo::EManaged: |
143 memory = pi->Owner(); |
143 memory = pi->Owner(); |
144 // Note, whilst we hold the RamAllocLock the page can't change it's use |
144 memory->Open(); |
145 // and we can safely assume that it still belongs to the memory object |
145 // move page, this will release the mmu lock. |
146 // at a fixed page index. |
146 r = memory->iManager->MovePage( memory, pi, aNew, aBlockZoneId, |
147 // Also, as memory objects can't be destroyed whilst they still own pages |
147 (aMoveDisFlags & M::EMoveDisBlockRest)!=0); |
148 // we can safely access this object without taking an explicit reference, |
148 memory->AsyncClose(); |
149 // i.e. we don't need to Open() the memory object. |
|
150 MmuLock::Unlock(); |
|
151 // move page... |
|
152 r = memory->iManager->MovePage(memory, pi, aNew, aBlockZoneId, aBlockRest); |
|
153 break; |
149 break; |
154 case SPageInfo::EUnused: |
150 case SPageInfo::EUnused: |
155 r = KErrNotFound; // This page is free so nothing to do. |
151 r = KErrNotFound; // This page is free so nothing to do. |
156 // Fall through.. |
152 // Fall through.. |
157 default: |
153 default: |
184 } |
180 } |
185 switch (pi->Type()) |
181 switch (pi->Type()) |
186 { |
182 { |
187 case SPageInfo::EManaged: |
183 case SPageInfo::EManaged: |
188 memory = pi->Owner(); |
184 memory = pi->Owner(); |
189 // Note, whilst we hold the RamAllocLock the page can't change it's use |
185 memory->Open(); |
190 // and we can safely assume that it still belongs to the memory object |
186 // move page, this will release the mmu lock. |
191 // at a fixed page index. |
|
192 // Also, as memory objects can't be destroyed whilst they still own pages |
|
193 // we can safely access this object without taking an explicit referernce, |
|
194 // i.e. we don't need to Open() the memory object. |
|
195 MmuLock::Unlock(); |
|
196 // move page... |
|
197 r = memory->iManager->MoveAndAllocPage(memory, pi, aPageType); |
187 r = memory->iManager->MoveAndAllocPage(memory, pi, aPageType); |
|
188 memory->AsyncClose(); |
198 break; |
189 break; |
199 case SPageInfo::EUnused: |
190 case SPageInfo::EUnused: |
200 r = KErrNone; // This page is free so nothing to do. |
191 r = KErrNone; // This page is free so nothing to do. |
201 // Fall through.. |
192 // Fall through.. |
202 default: |
193 default: |