131 TInt DMemoryManager::MovePage( DMemoryObject* aMemory, SPageInfo* aOldPageInfo, |
131 TInt DMemoryManager::MovePage( DMemoryObject* aMemory, SPageInfo* aOldPageInfo, |
132 TPhysAddr& aNewPage, TUint aBlockZoneId, TBool aBlockRest) |
132 TPhysAddr& aNewPage, TUint aBlockZoneId, TBool aBlockRest) |
133 { |
133 { |
134 return KErrNotSupported; |
134 return KErrNotSupported; |
135 } |
135 } |
|
136 |
|
137 |
|
138 TInt DMemoryManager::MoveAndAllocPage(DMemoryObject*, SPageInfo*, TZonePageType) |
|
139 { |
|
140 return KErrNotSupported; |
|
141 } |
|
142 |
136 |
143 |
137 TZonePageType DMemoryManager::PageType() |
144 TZonePageType DMemoryManager::PageType() |
138 {// This should not be invoked on memory managers that do not use the methods |
145 {// This should not be invoked on memory managers that do not use the methods |
139 // AllocPages() and FreePages(). |
146 // AllocPages() and FreePages(). |
140 __NK_ASSERT_DEBUG(0); |
147 __NK_ASSERT_DEBUG(0); |
719 class DMovableMemoryManager : public DUnpagedMemoryManager |
726 class DMovableMemoryManager : public DUnpagedMemoryManager |
720 { |
727 { |
721 public: |
728 public: |
722 // from DMemoryManager... |
729 // from DMemoryManager... |
723 virtual TInt MovePage(DMemoryObject* aMemory, SPageInfo* aOldPageInfo, TPhysAddr& aNewPage, TUint aBlockZoneId, TBool aBlockRest); |
730 virtual TInt MovePage(DMemoryObject* aMemory, SPageInfo* aOldPageInfo, TPhysAddr& aNewPage, TUint aBlockZoneId, TBool aBlockRest); |
|
731 virtual TInt MoveAndAllocPage(DMemoryObject* aMemory, SPageInfo* aPageInfo, TZonePageType aPageType); |
724 virtual TInt HandleFault( DMemoryObject* aMemory, TUint aIndex, DMemoryMapping* aMapping, |
732 virtual TInt HandleFault( DMemoryObject* aMemory, TUint aIndex, DMemoryMapping* aMapping, |
725 TUint aMapInstanceCount, TUint aAccessPermissions); |
733 TUint aMapInstanceCount, TUint aAccessPermissions); |
726 virtual TZonePageType PageType(); |
734 virtual TZonePageType PageType(); |
727 public: |
735 public: |
728 /** |
736 /** |
885 |
893 |
886 return r; |
894 return r; |
887 } |
895 } |
888 |
896 |
889 |
897 |
|
898 TInt DMovableMemoryManager::MoveAndAllocPage(DMemoryObject* aMemory, SPageInfo* aPageInfo, TZonePageType aPageType) |
|
899 { |
|
900 TPhysAddr newPage; |
|
901 TInt r = MovePage(aMemory, aPageInfo, newPage, KRamZoneInvalidId, EFalse); |
|
902 if (r == KErrNone) |
|
903 { |
|
904 TheMmu.MarkPageAllocated(aPageInfo->PhysAddr(), aPageType); |
|
905 } |
|
906 return r; |
|
907 } |
|
908 |
|
909 |
890 TInt DMovableMemoryManager::HandleFault(DMemoryObject* aMemory, TUint aIndex, DMemoryMapping* aMapping, |
910 TInt DMovableMemoryManager::HandleFault(DMemoryObject* aMemory, TUint aIndex, DMemoryMapping* aMapping, |
891 TUint aMapInstanceCount, TUint aAccessPermissions) |
911 TUint aMapInstanceCount, TUint aAccessPermissions) |
892 { |
912 { |
893 TInt r = KErrNotFound; |
913 TInt r = KErrNotFound; |
894 SPageInfo* pageInfo; |
914 SPageInfo* pageInfo; |
1159 class DHardwareMemoryManager : public DMemoryManager |
1179 class DHardwareMemoryManager : public DMemoryManager |
1160 { |
1180 { |
1161 public: |
1181 public: |
1162 // from DMemoryManager... |
1182 // from DMemoryManager... |
1163 virtual void Destruct(DMemoryObject* aMemory); |
1183 virtual void Destruct(DMemoryObject* aMemory); |
1164 virtual TInt AddPages(DMemoryObject* aMemory, TUint aIndex, TUint aCount, TPhysAddr* aPages); |
1184 virtual TInt AddPages(DMemoryObject* aMemory, TUint aIndex, TUint aCount, const TPhysAddr* aPages); |
1165 virtual TInt AddContiguous(DMemoryObject* aMemory, TUint aIndex, TUint aCount, TPhysAddr aPhysAddr); |
1185 virtual TInt AddContiguous(DMemoryObject* aMemory, TUint aIndex, TUint aCount, TPhysAddr aPhysAddr); |
1166 virtual TInt RemovePages(DMemoryObject* aMemory, TUint aIndex, TUint aCount, TPhysAddr* aPages); |
1186 virtual TInt RemovePages(DMemoryObject* aMemory, TUint aIndex, TUint aCount, TPhysAddr* aPages); |
1167 virtual TInt Pin(DMemoryObject* aMemory, DMemoryMappingBase* aMapping, TPinArgs& aPinArgs); |
1187 virtual TInt Pin(DMemoryObject* aMemory, DMemoryMappingBase* aMapping, TPinArgs& aPinArgs); |
1168 virtual void Unpin(DMemoryObject* aMemory, DMemoryMappingBase* aMapping, TPinArgs& aPinArgs); |
1188 virtual void Unpin(DMemoryObject* aMemory, DMemoryMappingBase* aMapping, TPinArgs& aPinArgs); |
1169 |
1189 |
1224 MemoryObjectLock::Unlock(aMemory); |
1244 MemoryObjectLock::Unlock(aMemory); |
1225 aMemory->Close(); |
1245 aMemory->Close(); |
1226 } |
1246 } |
1227 |
1247 |
1228 |
1248 |
1229 TInt DHardwareMemoryManager::AddPages(DMemoryObject* aMemory, TUint aIndex, TUint aCount, TPhysAddr* aPages) |
1249 TInt DHardwareMemoryManager::AddPages(DMemoryObject* aMemory, TUint aIndex, TUint aCount, const TPhysAddr* aPages) |
1230 { |
1250 { |
1231 TRACE2(("DHardwareMemoryManager::AddPages(0x%08x,0x%x,0x%x,?)",aMemory, aIndex, aCount)); |
1251 TRACE2(("DHardwareMemoryManager::AddPages(0x%08x,0x%x,0x%x,?)",aMemory, aIndex, aCount)); |
1232 __NK_ASSERT_DEBUG(MemoryObjectLock::IsHeld(aMemory)); |
1252 __NK_ASSERT_DEBUG(MemoryObjectLock::IsHeld(aMemory)); |
1233 |
1253 |
1234 // validate arguments... |
1254 // validate arguments... |
1235 TPhysAddr* pages = aPages; |
1255 const TPhysAddr* pages = aPages; |
1236 TPhysAddr* pagesEnd = aPages+aCount; |
1256 const TPhysAddr* pagesEnd = aPages+aCount; |
1237 TPhysAddr checkMask = 0; |
1257 TPhysAddr checkMask = 0; |
1238 do checkMask |= *pages++; |
1258 do checkMask |= *pages++; |
1239 while(pages<pagesEnd); |
1259 while(pages<pagesEnd); |
1240 if(checkMask&KPageMask) |
1260 if(checkMask&KPageMask) |
1241 return KErrArgument; |
1261 return KErrArgument; |