504 TUint numPts = aNumPages>>(KChunkShift-KPageShift); |
504 TUint numPts = aNumPages>>(KChunkShift-KPageShift); |
505 DPageTables* self = (DPageTables*)Kern::AllocZ(sizeof(DPageTables)+(numPts-1)*sizeof(TPte*)); |
505 DPageTables* self = (DPageTables*)Kern::AllocZ(sizeof(DPageTables)+(numPts-1)*sizeof(TPte*)); |
506 if(self) |
506 if(self) |
507 { |
507 { |
508 new (self) DPageTables(aMemory,numPts,aPteType); |
508 new (self) DPageTables(aMemory,numPts,aPteType); |
|
509 // Add this page tables object to the memory object before we update any |
|
510 // page table entries. To ensure that if any of aMemory's pages with |
|
511 // corresponding page table entries in self are moved during Construct(), |
|
512 // DCoarseMemory::RemapPage() will be able to find the page table entries |
|
513 // to update via iPageTables. |
|
514 __NK_ASSERT_DEBUG(!aMemory->iPageTables[aPteType]); |
|
515 aMemory->iPageTables[aPteType] = self; |
509 TInt r = self->Construct(); |
516 TInt r = self->Construct(); |
510 if(r!=KErrNone) |
517 if(r!=KErrNone) |
511 { |
518 { |
|
519 aMemory->iPageTables[aPteType] = 0; |
512 self->Close(); |
520 self->Close(); |
513 self = 0; |
521 self = 0; |
514 } |
522 } |
515 } |
523 } |
516 TRACE2(("DCoarseMemory::DPageTables::New(0x%08x,0x%x,0x%08x) returns 0x%08x",aMemory, aNumPages, aPteType, self)); |
524 TRACE2(("DCoarseMemory::DPageTables::New(0x%08x,0x%x,0x%08x) returns 0x%08x",aMemory, aNumPages, aPteType, self)); |
577 } |
585 } |
578 |
586 |
579 |
587 |
580 void DCoarseMemory::DPageTables::AsyncClose() |
588 void DCoarseMemory::DPageTables::AsyncClose() |
581 { |
589 { |
582 __NK_ASSERT_DEBUG(CheckAsyncCloseIsSafe()); |
590 __ASSERT_CRITICAL |
|
591 #ifdef _DEBUG |
|
592 NFastMutex* fm = NKern::HeldFastMutex(); |
|
593 if(fm) |
|
594 { |
|
595 Kern::Printf("DCoarseMemory::DPageTables::[0x%08x]::AsyncClose() fast mutex violation %M",this,fm); |
|
596 __NK_ASSERT_DEBUG(0); |
|
597 } |
|
598 #endif |
|
599 |
583 MmuLock::Lock(); |
600 MmuLock::Lock(); |
584 if (__e32_atomic_tas_ord32(&iReferenceCount, 1, -1, 0) != 1) |
601 if (__e32_atomic_tas_ord32(&iReferenceCount, 1, -1, 0) != 1) |
585 { |
602 { |
586 MmuLock::Unlock(); |
603 MmuLock::Unlock(); |
587 return; |
604 return; |