528 } |
528 } |
529 |
529 |
530 |
530 |
531 TInt DRomMemoryManager::ReadPages(DMemoryObject* aMemory, TUint aIndex, TUint aCount, TPhysAddr* aPages, DPageReadRequest* aRequest) |
531 TInt DRomMemoryManager::ReadPages(DMemoryObject* aMemory, TUint aIndex, TUint aCount, TPhysAddr* aPages, DPageReadRequest* aRequest) |
532 { |
532 { |
533 __NK_ASSERT_DEBUG(aRequest->CheckUse(aMemory,aIndex,aCount)); |
533 __NK_ASSERT_DEBUG(aRequest->CheckUseContiguous(aMemory,aIndex,aCount)); |
|
534 __ASSERT_CRITICAL; |
534 |
535 |
535 TLinAddr linAddr = aRequest->MapPages(aIndex,aCount,aPages); |
536 TLinAddr linAddr = aRequest->MapPages(aIndex,aCount,aPages); |
536 TInt r = KErrNone; |
537 TInt r = KErrNone; |
|
538 TThreadMessage message; |
537 |
539 |
538 const TInt readUnitShift = iDevice->iReadUnitShift; |
540 const TInt readUnitShift = iDevice->iReadUnitShift; |
539 |
541 |
540 for(; aCount; ++aIndex, --aCount, linAddr+=KPageSize) |
542 for(; aCount; ++aIndex, --aCount, linAddr+=KPageSize) |
541 { |
543 { |
|
544 |
542 START_PAGING_BENCHMARK; |
545 START_PAGING_BENCHMARK; |
543 if(!iRomPageIndex) |
546 if(!iRomPageIndex) |
544 { |
547 { |
545 // ROM not broken into pages, so just read it in directly. |
548 // ROM not broken into pages, so just read it in directly. |
546 // KPageShift > readUnitShift so page size is exact multiple of read |
549 // KPageShift > readUnitShift so page size is exact multiple of read |
547 // units. Therefore it is ok to just shift offset and KPageSize |
550 // units. Therefore it is ok to just shift offset and KPageSize |
548 // by readUnitShift. |
551 // by readUnitShift. |
549 const TInt dataOffset = aIndex << KPageShift; |
552 const TInt dataOffset = aIndex << KPageShift; |
550 START_PAGING_BENCHMARK; |
553 START_PAGING_BENCHMARK; |
551 r = iDevice->Read( const_cast<TThreadMessage*>(&aRequest->iMessage), |
554 r = iDevice->Read( &message, |
552 linAddr, dataOffset >> readUnitShift, |
555 linAddr, dataOffset >> readUnitShift, |
553 KPageSize >> readUnitShift, DPagingDevice::EDriveRomPaging); |
556 KPageSize >> readUnitShift, DPagingDevice::EDriveRomPaging); |
554 __NK_ASSERT_DEBUG(r!=KErrNoMemory); // not allowed to allocated memory, therefore can't fail with KErrNoMemory |
557 __NK_ASSERT_DEBUG(r!=KErrNoMemory); // not allowed to allocated memory, therefore can't fail with KErrNoMemory |
555 END_PAGING_BENCHMARK(EPagingBmReadMedia); |
558 END_PAGING_BENCHMARK(EPagingBmReadMedia); |
556 } |
559 } |
569 else |
572 else |
570 { |
573 { |
571 __NK_ASSERT_ALWAYS(romPageInfo->iPagingAttributes & SRomPageInfo::EPageable); |
574 __NK_ASSERT_ALWAYS(romPageInfo->iPagingAttributes & SRomPageInfo::EPageable); |
572 |
575 |
573 // Read data for page... |
576 // Read data for page... |
574 TThreadMessage* msg = const_cast<TThreadMessage*>(&aRequest->iMessage); |
|
575 const TLinAddr buffer = aRequest->iBuffer; |
577 const TLinAddr buffer = aRequest->iBuffer; |
576 const TUint readStart = dataOffset >> readUnitShift; |
578 const TUint readStart = dataOffset >> readUnitShift; |
577 const TUint readSize = ((dataOffset + dataSize - 1) >> readUnitShift) - readStart + 1; |
579 const TUint readSize = ((dataOffset + dataSize - 1) >> readUnitShift) - readStart + 1; |
578 __NK_ASSERT_DEBUG((readSize << readUnitShift) <= (DPageReadRequest::EMaxPages << KPageShift)); |
580 __NK_ASSERT_DEBUG((readSize << readUnitShift) <= (DPageReadRequest::EMaxPages << KPageShift)); |
579 START_PAGING_BENCHMARK; |
581 START_PAGING_BENCHMARK; |
580 r = iDevice->Read(msg, buffer, readStart, readSize, DPagingDevice::EDriveRomPaging); |
582 r = iDevice->Read(&message, buffer, readStart, readSize, DPagingDevice::EDriveRomPaging); |
581 __NK_ASSERT_DEBUG(r!=KErrNoMemory); // not allowed to allocated memory, therefore can't fail with KErrNoMemory |
583 __NK_ASSERT_DEBUG(r!=KErrNoMemory); // not allowed to allocated memory, therefore can't fail with KErrNoMemory |
582 END_PAGING_BENCHMARK(EPagingBmReadMedia); |
584 END_PAGING_BENCHMARK(EPagingBmReadMedia); |
583 if(r==KErrNone) |
585 if(r==KErrNone) |
584 { |
586 { |
585 // Decompress data, remembering that the data to decompress may be offset from |
587 // Decompress data, remembering that the data to decompress may be offset from |