equal
deleted
inserted
replaced
106 { |
106 { |
107 return KErrNotSupported; |
107 return KErrNotSupported; |
108 } |
108 } |
109 |
109 |
110 |
110 |
111 TInt DMemoryManager::CleanPage(DMemoryObject* aMemory, SPageInfo* aPageInfo, TPhysAddr*& /*aPageArrayEntry*/) |
111 void DMemoryManager::CleanPages(TUint aPageCount, SPageInfo** aPageInfos, TBool /*aBackground*/) |
112 { |
112 { |
113 if(aPageInfo->IsDirty()==false) |
113 for (TUint i = 0 ; i < aPageCount ; ++i) |
114 return KErrNone; |
114 __NK_ASSERT_DEBUG(!aPageInfos[i]->IsDirty()); |
115 __NK_ASSERT_DEBUG(0); |
|
116 return KErrNotSupported; |
|
117 } |
115 } |
118 |
116 |
119 |
117 |
120 TInt DMemoryManager::HandleFault( DMemoryObject* aMemory, TUint aIndex, DMemoryMapping* aMapping, |
118 TInt DMemoryManager::HandleFault( DMemoryObject* aMemory, TUint aIndex, DMemoryMapping* aMapping, |
121 TUint aMapInstanceCount, TUint aAccessPermissions) |
119 TUint aMapInstanceCount, TUint aAccessPermissions) |
133 TInt DMemoryManager::MovePage( DMemoryObject* aMemory, SPageInfo* aOldPageInfo, |
131 TInt DMemoryManager::MovePage( DMemoryObject* aMemory, SPageInfo* aOldPageInfo, |
134 TPhysAddr& aNewPage, TUint aBlockZoneId, TBool aBlockRest) |
132 TPhysAddr& aNewPage, TUint aBlockZoneId, TBool aBlockRest) |
135 { |
133 { |
136 return KErrNotSupported; |
134 return KErrNotSupported; |
137 } |
135 } |
|
136 |
|
137 |
|
138 TInt DMemoryManager::MoveAndAllocPage(DMemoryObject*, SPageInfo*, TZonePageType) |
|
139 { |
|
140 return KErrNotSupported; |
|
141 } |
|
142 |
138 |
143 |
139 TZonePageType DMemoryManager::PageType() |
144 TZonePageType DMemoryManager::PageType() |
140 {// 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 |
141 // AllocPages() and FreePages(). |
146 // AllocPages() and FreePages(). |
142 __NK_ASSERT_DEBUG(0); |
147 __NK_ASSERT_DEBUG(0); |
721 class DMovableMemoryManager : public DUnpagedMemoryManager |
726 class DMovableMemoryManager : public DUnpagedMemoryManager |
722 { |
727 { |
723 public: |
728 public: |
724 // from DMemoryManager... |
729 // from DMemoryManager... |
725 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); |
726 virtual TInt HandleFault( DMemoryObject* aMemory, TUint aIndex, DMemoryMapping* aMapping, |
732 virtual TInt HandleFault( DMemoryObject* aMemory, TUint aIndex, DMemoryMapping* aMapping, |
727 TUint aMapInstanceCount, TUint aAccessPermissions); |
733 TUint aMapInstanceCount, TUint aAccessPermissions); |
728 virtual TZonePageType PageType(); |
734 virtual TZonePageType PageType(); |
729 public: |
735 public: |
730 /** |
736 /** |
887 |
893 |
888 return r; |
894 return r; |
889 } |
895 } |
890 |
896 |
891 |
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 |
892 TInt DMovableMemoryManager::HandleFault(DMemoryObject* aMemory, TUint aIndex, DMemoryMapping* aMapping, |
910 TInt DMovableMemoryManager::HandleFault(DMemoryObject* aMemory, TUint aIndex, DMemoryMapping* aMapping, |
893 TUint aMapInstanceCount, TUint aAccessPermissions) |
911 TUint aMapInstanceCount, TUint aAccessPermissions) |
894 { |
912 { |
895 TInt r = KErrNotFound; |
913 TInt r = KErrNotFound; |
896 SPageInfo* pageInfo; |
914 SPageInfo* pageInfo; |
1037 TRACE2(("DDiscardableMemoryManager::StealPage(0x%08x,0x%08x)",aMemory,aPageInfo)); |
1055 TRACE2(("DDiscardableMemoryManager::StealPage(0x%08x,0x%08x)",aMemory,aPageInfo)); |
1038 __NK_ASSERT_DEBUG(RamAllocLock::IsHeld()); |
1056 __NK_ASSERT_DEBUG(RamAllocLock::IsHeld()); |
1039 __NK_ASSERT_DEBUG(MmuLock::IsHeld()); |
1057 __NK_ASSERT_DEBUG(MmuLock::IsHeld()); |
1040 __UNLOCK_GUARD_START(MmuLock); |
1058 __UNLOCK_GUARD_START(MmuLock); |
1041 |
1059 |
|
1060 // must always hold the PageCleaningLock if the page needs to be cleaned |
|
1061 __NK_ASSERT_DEBUG(!aPageInfo->IsDirty() || PageCleaningLock::IsHeld()); |
|
1062 |
1042 TUint index = aPageInfo->Index(); |
1063 TUint index = aPageInfo->Index(); |
1043 TInt r; |
1064 TInt r; |
1044 |
1065 |
1045 RPageArray::TIter pageList; |
1066 RPageArray::TIter pageList; |
1046 TPhysAddr* p = aMemory->iPages.StealPageStart(index,pageList); |
1067 TPhysAddr* p = aMemory->iPages.StealPageStart(index,pageList); |
1094 else |
1115 else |
1095 { |
1116 { |
1096 // page successfully unmapped... |
1117 // page successfully unmapped... |
1097 aPageInfo->SetReadOnly(); // page not mapped, so must be read-only |
1118 aPageInfo->SetReadOnly(); // page not mapped, so must be read-only |
1098 |
1119 |
1099 // if the page can be made clean... |
1120 // attempt to clean the page if it is dirty... |
1100 r = aMemory->iManager->CleanPage(aMemory,aPageInfo,p); |
1121 if (aPageInfo->IsDirty()) |
1101 |
1122 aMemory->iManager->CleanPages(1, &aPageInfo, EFalse); |
1102 if(r==KErrNone) |
1123 |
|
1124 if(aPageInfo) |
1103 { |
1125 { |
1104 // page successfully stolen... |
1126 // page successfully stolen... |
1105 __NK_ASSERT_DEBUG((*p^page)<(TUint)KPageSize); // sanity check, page should still be allocated to us |
1127 __NK_ASSERT_DEBUG((*p^page)<(TUint)KPageSize); // sanity check, page should still be allocated to us |
1106 __NK_ASSERT_DEBUG(aPageInfo->IsDirty()==false); |
1128 __NK_ASSERT_DEBUG(aPageInfo->IsDirty()==false); |
1107 __NK_ASSERT_DEBUG(aPageInfo->IsWritable()==false); |
1129 __NK_ASSERT_DEBUG(aPageInfo->IsWritable()==false); |
1109 TPhysAddr pagerInfo = aPageInfo->PagingManagerData(); |
1131 TPhysAddr pagerInfo = aPageInfo->PagingManagerData(); |
1110 *p = pagerInfo; |
1132 *p = pagerInfo; |
1111 __NK_ASSERT_ALWAYS((pagerInfo&(RPageArray::EFlagsMask|RPageArray::EStateMask)) == RPageArray::ENotPresent); |
1133 __NK_ASSERT_ALWAYS((pagerInfo&(RPageArray::EFlagsMask|RPageArray::EStateMask)) == RPageArray::ENotPresent); |
1112 |
1134 |
1113 TheMmu.PageFreed(aPageInfo); |
1135 TheMmu.PageFreed(aPageInfo); |
|
1136 r = KErrNone; |
1114 } |
1137 } |
1115 else |
1138 else |
1116 { |
1139 r = KErrInUse; |
1117 // only legitimate reason for failing the clean is if the page state was changed |
|
1118 // by a page fault or by pinning, this should return KErrInUse... |
|
1119 __NK_ASSERT_DEBUG(r==KErrInUse); |
|
1120 } |
|
1121 } |
1140 } |
1122 } |
1141 } |
1123 |
1142 |
1124 aMemory->iPages.StealPageEnd(index,r==KErrNone ? 1 : 0); |
1143 aMemory->iPages.StealPageEnd(index,r==KErrNone ? 1 : 0); |
1125 |
1144 |
2028 TInt DPagedMemoryManager::AcquirePageWriteRequest(DPageWriteRequest*& aRequest, DMemoryObject* aMemory, TUint aIndex, TUint aCount) |
2047 TInt DPagedMemoryManager::AcquirePageWriteRequest(DPageWriteRequest*& aRequest, DMemoryObject* aMemory, TUint aIndex, TUint aCount) |
2029 { |
2048 { |
2030 __NK_ASSERT_ALWAYS(0); |
2049 __NK_ASSERT_ALWAYS(0); |
2031 return KErrNotSupported; |
2050 return KErrNotSupported; |
2032 } |
2051 } |
2033 |
|
2034 |
|
2035 TInt DPagedMemoryManager::WritePages(DMemoryObject* aMemory, TUint aIndex, TUint aCount, TPhysAddr* aPages, DPageWriteRequest* aRequest) |
|
2036 { |
|
2037 __NK_ASSERT_ALWAYS(0); |
|
2038 return KErrNotSupported; |
|
2039 } |
|
2040 |
|
2041 TZonePageType DPagedMemoryManager::PageType() |
2052 TZonePageType DPagedMemoryManager::PageType() |
2042 {// Paged manager's pages should be discardable and will actaully be freed by |
2053 {// Paged manager's pages should be discardable and will actaully be freed by |
2043 // the pager so this value won't be used. |
2054 // the pager so this value won't be used. |
2044 return EPageDiscard; |
2055 return EPageDiscard; |
2045 } |
2056 } |