kernel/eka/memmodel/epoc/flexible/mmu/mrom.cpp
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
equal deleted inserted replaced
43:c1f20ce4abcf 44:3e88ff8f41d5
   556 			r = iDevice->Read(	&message, 
   556 			r = iDevice->Read(	&message, 
   557 								linAddr, dataOffset >> readUnitShift, 
   557 								linAddr, dataOffset >> readUnitShift, 
   558 								KPageSize >> readUnitShift, DPagingDevice::EDriveRomPaging);
   558 								KPageSize >> readUnitShift, DPagingDevice::EDriveRomPaging);
   559 			__NK_ASSERT_DEBUG(r!=KErrNoMemory); // not allowed to allocated memory, therefore can't fail with KErrNoMemory
   559 			__NK_ASSERT_DEBUG(r!=KErrNoMemory); // not allowed to allocated memory, therefore can't fail with KErrNoMemory
   560 			END_PAGING_BENCHMARK(EPagingBmReadMedia);
   560 			END_PAGING_BENCHMARK(EPagingBmReadMedia);
   561 			if (r != KErrNone)
       
   562 				{
       
   563 				__KTRACE_OPT(KPANIC, Kern::Printf("DRomMemoryManager::ReadPage: error reading media at %08x + %x: %d", dataOffset, KPageSize, r));
       
   564 				}
       
   565 			r = ThePager.EmbedErrorContext(EPagingErrorContextRomRead, r);
       
   566 			}
   561 			}
   567 		else
   562 		else
   568 			{
   563 			{
   569 			// Work out where data for page is located
   564 			// Work out where data for page is located
   570 			SRomPageInfo* romPageInfo = iRomPageIndex + aIndex;
   565 			SRomPageInfo* romPageInfo = iRomPageIndex + aIndex;
   587 				__NK_ASSERT_DEBUG((readSize << readUnitShift) <= (DPageReadRequest::EMaxPages << KPageShift));
   582 				__NK_ASSERT_DEBUG((readSize << readUnitShift) <= (DPageReadRequest::EMaxPages << KPageShift));
   588 				START_PAGING_BENCHMARK;
   583 				START_PAGING_BENCHMARK;
   589 				r = iDevice->Read(&message, buffer, readStart, readSize, DPagingDevice::EDriveRomPaging);
   584 				r = iDevice->Read(&message, buffer, readStart, readSize, DPagingDevice::EDriveRomPaging);
   590 				__NK_ASSERT_DEBUG(r!=KErrNoMemory); // not allowed to allocated memory, therefore can't fail with KErrNoMemory
   585 				__NK_ASSERT_DEBUG(r!=KErrNoMemory); // not allowed to allocated memory, therefore can't fail with KErrNoMemory
   591 				END_PAGING_BENCHMARK(EPagingBmReadMedia);
   586 				END_PAGING_BENCHMARK(EPagingBmReadMedia);
   592 				if(r!=KErrNone)
       
   593 					__KTRACE_OPT(KPANIC, Kern::Printf("DRomMemoryManager::ReadPage: error reading media at %08x + %x: %d", dataOffset, dataSize, r));
       
   594 				r = ThePager.EmbedErrorContext(EPagingErrorContextRomRead, r);
       
   595 				if(r==KErrNone)
   587 				if(r==KErrNone)
   596 					{
   588 					{
   597 					// Decompress data, remembering that the data to decompress may be offset from 
   589 					// Decompress data, remembering that the data to decompress may be offset from 
   598 					// the start of the data just read in, due to reads having to be aligned by 
   590 					// the start of the data just read in, due to reads having to be aligned by 
   599 					// readUnitShift.
   591 					// readUnitShift.
   600 					const TLinAddr data = buffer + dataOffset - (readStart << readUnitShift);
   592 					const TLinAddr data = buffer + dataOffset - (readStart << readUnitShift);
   601 					__ASSERT_COMPILE(SRomPageInfo::ENoCompression==0); // decompress assumes this
   593 					__ASSERT_COMPILE(SRomPageInfo::ENoCompression==0); // decompress assumes this
   602 					r = Decompress(romPageInfo->iCompressionType, linAddr, KPageSize, data, dataSize);
   594 					r = Decompress(romPageInfo->iCompressionType, linAddr, KPageSize, data, dataSize);
   603 					if (r >= 0)
   595 					if(r >= 0)
   604 						r = (r == KPageSize) ? KErrNone : KErrCorrupt;
   596 						{
   605 					if (r != KErrNone)
   597 						if (r != KPageSize)
   606 						__KTRACE_OPT(KPANIC, Kern::Printf("DRomMemoryManager::ReadPage: error decompressing page at %08x + %x: %d", dataOffset, dataSize, r));
   598 							__KTRACE_OPT(KPANIC, Kern::Printf("DRomMemoryManager::ReadPage: error decompressing page at %08x + %x: %d", dataOffset, dataSize, r));
   607 					__NK_ASSERT_DEBUG(r == KErrNone);
   599 						__NK_ASSERT_ALWAYS(r == KPageSize);
   608 					r = ThePager.EmbedErrorContext(EPagingErrorContextRomDecompress, r);
   600 						r = KErrNone;
       
   601 						}
   609 					}
   602 					}
       
   603 				else
       
   604 					__KTRACE_OPT(KPANIC, Kern::Printf("DRomMemoryManager::ReadPage: error reading media at %08x + %x: %d", dataOffset, dataSize, r));
   610 				}
   605 				}
   611 			}
   606 			}
   612 		END_PAGING_BENCHMARK(EPagingBmReadRomPage);
   607 		END_PAGING_BENCHMARK(EPagingBmReadRomPage);
   613 
   608 
   614 		if(r!=KErrNone)
   609 		if(r!=KErrNone)
   615 			break;
   610 			break;
   616 		}
   611 		}
   617 
   612 
   618 	aRequest->UnmapPages(true);
   613 	aRequest->UnmapPages(true);
   619 	
   614 
   620 	return r;
   615 	return r;
   621 	}
   616 	}
   622 
   617 
   623 
   618 
   624 TBool DRomMemoryManager::IsAllocated(DMemoryObject* aMemory, TUint aIndex, TUint aCount)
   619 TBool DRomMemoryManager::IsAllocated(DMemoryObject* aMemory, TUint aIndex, TUint aCount)