kernel/eka/drivers/medmmc/medmmc.cpp
changeset 33 0173bcd7697c
parent 0 a41df078684a
child 39 5d2844f35677
equal deleted inserted replaced
31:56f325a607ea 33:0173bcd7697c
   522 		/** 
   522 		/** 
   523 		 * If Double-Buffering is enabled then the cache should not be greater than the maximum addressable range of the DMA controller,
   523 		 * If Double-Buffering is enabled then the cache should not be greater than the maximum addressable range of the DMA controller,
   524 		 * otherwise Double buffering will never be utilised because all transfers will fit into the cache.
   524 		 * otherwise Double buffering will never be utilised because all transfers will fit into the cache.
   525 		 */
   525 		 */
   526 		const TUint32 maxDbBlocks = iSocket->MaxDataTransferLength() >> iBlkLenLog2;
   526 		const TUint32 maxDbBlocks = iSocket->MaxDataTransferLength() >> iBlkLenLog2;
   527 		__ASSERT_DEBUG(iBlocksInBuffer <= (TInt)maxDbBlocks, Panic(EDBNotOptimal));
   527         if (maxDbBlocks)
       
   528             {
       
   529             __ASSERT_DEBUG(iBlocksInBuffer <= (TInt)maxDbBlocks, Panic(EDBNotOptimal));
       
   530             }
   528 #endif		
   531 #endif		
   529 		}
   532 		}
   530 
   533 
   531 	iMaxBufSize = iBlocksInBuffer << iBlkLenLog2;
   534 	iMaxBufSize = iBlocksInBuffer << iBlkLenLog2;
   532 
   535 
  1127 				//  - Only if PSL supports double buffering and the request length 
  1130 				//  - Only if PSL supports double buffering and the request length 
  1128 				//	  is greater than the maximum PSL buffer size.
  1131 				//	  is greater than the maximum PSL buffer size.
  1129 				//
  1132 				//
  1130 				iDoPhysicalAddress = iCurrentReq->IsPhysicalAddress();
  1133 				iDoPhysicalAddress = iCurrentReq->IsPhysicalAddress();
  1131 								
  1134 								
  1132 				const TInt64 medEnd = aStart + aLength;
  1135 				TInt64 medEnd = aStart + aLength;
  1133 		
  1136 		
  1134 				TInt64 maxPslEnd = medEnd;
  1137 				TInt64 maxPslEnd = medEnd;
  1135 				const TUint32 maxDbLength = iSocket->MaxDataTransferLength();
  1138 				const TUint32 maxDbLength = iSocket->MaxDataTransferLength();
  1136 				
  1139 				
  1137 				if(maxDbLength)
  1140 				if(maxDbLength)
  1178 						// the first and last blocks prior to initiating data transfer.
  1181 						// the first and last blocks prior to initiating data transfer.
  1179 						//
  1182 						//
  1180 						iIntBuf = ReserveWriteBlocks(aStart, iDbEnd, &iWtRBM);
  1183 						iIntBuf = ReserveWriteBlocks(aStart, iDbEnd, &iWtRBM);
  1181 						}
  1184 						}
  1182 					else
  1185 					else
  1183 						{
  1186 						{				
  1184 						//
  1187 						if ( (iPhysEnd - iPhysStart) > iMaxBufSize)
  1185 						// reserve buffers to end of first write group, or end of request range,
  1188 						    {
  1186 						// whichever is lower.  Note that if the range already exists in the buffer,
  1189 		                    //
  1187 						// e.g. because of a previous RBM, the same range will be returned.  This
  1190                             // reserve buffers to end of first write group, or end of request range,
  1188 						// means that iWtRBM can be set to zero in the callback DFC, and this code
  1191                             // whichever is lower.  Note that if the range already exists in the buffer,
  1189 						// will retrieve the reserved range.
  1192                             // e.g. because of a previous RBM, the same range will be returned.  This
  1190 						//
  1193                             // means that iWtRBM can be set to zero in the callback DFC, and this code
  1191 						const TInt64 wtGpEnd = (iPhysStart + iPrWtGpLen) & ~iPrWtGpMsk;
  1194                             // will retrieve the reserved range.
  1192 						const TInt64 medEnd = UMin(wtGpEnd, aStart + aLength);
  1195                             //  
  1193 						iPhysEnd = (medEnd + iBlkMsk) & ~iBlkMsk;
  1196 						    const TInt64 wtGpEnd = (iPhysStart + iPrWtGpLen) & ~iPrWtGpMsk;
       
  1197 						    medEnd = UMin(wtGpEnd, aStart + aLength);
       
  1198 						    iPhysEnd = (medEnd + iBlkMsk) & ~iBlkMsk;
       
  1199 						    }
       
  1200 						
  1194 						iIntBuf = ReserveWriteBlocks(aStart, medEnd, &iWtRBM);
  1201 						iIntBuf = ReserveWriteBlocks(aStart, medEnd, &iWtRBM);
  1195 						}
  1202 						}
  1196 					} //if (!iDoPhysicalAddress)
  1203 					} //if (!iDoPhysicalAddress)
  1197 				} //if(iDoDoubleBuffer == EFalse)
  1204 				} //if(iDoDoubleBuffer == EFalse)
  1198 			} //if (iWtRBM == 0)
  1205 			} //if (iWtRBM == 0)
  1550 			{
  1557 			{
  1551 			// Already sorted
  1558 			// Already sorted
  1552 			}
  1559 			}
  1553 
  1560 
  1554 		// FAT partition ?
  1561 		// FAT partition ?
  1555 		else if (pe->IsValidDosPartition() || pe->IsValidFAT32Partition())
  1562 		else if (pe->IsValidDosPartition() || pe->IsValidFAT32Partition() || pe->IsValidExFATPartition())
  1556 			{
  1563 			{
  1557 			SetPartitionEntry(&iPartitionInfo->iEntry[partitionCount],pe->iFirstSector,pe->iNumSectors);
  1564 			SetPartitionEntry(&iPartitionInfo->iEntry[partitionCount],pe->iFirstSector,pe->iNumSectors);
  1558 			__KTRACE_OPT(KLOCDPAGING, Kern::Printf("Mmc: FAT partition found at sector #%u", pe->iFirstSector));
  1565 			__KTRACE_OPT(KLOCDPAGING, Kern::Printf("Mmc: FAT partition found at sector #%u", pe->iFirstSector));
  1559 			partitionCount++;
  1566 			partitionCount++;
  1560 			}
  1567 			}
  2556 
  2563 
  2557 TInt DMmcMediaDriverFlash::Caps(TLocDrv& aDrive, TLocalDriveCapsV6& aInfo)
  2564 TInt DMmcMediaDriverFlash::Caps(TLocDrv& aDrive, TLocalDriveCapsV6& aInfo)
  2558 	{
  2565 	{
  2559 	// Fill buffer with current media caps.
  2566 	// Fill buffer with current media caps.
  2560 	aInfo.iType = EMediaHardDisk;
  2567 	aInfo.iType = EMediaHardDisk;
  2561 	aInfo.iBattery = EBatNotSupported;
  2568 	aInfo.iConnectionBusType = EConnectionBusInternal;
  2562 	aInfo.iDriveAtt = KDriveAttLocal;
  2569 	aInfo.iDriveAtt = KDriveAttLocal;
  2563 	aInfo.iMediaAtt	= KMediaAttFormattable;
  2570 	aInfo.iMediaAtt	= KMediaAttFormattable;
  2564 
  2571 
  2565 	if(iCard->iFlags & KMMCardIsLockable)
  2572 	if(iCard->iFlags & KMMCardIsLockable)
  2566 		aInfo.iMediaAtt |= KMediaAttLockable;
  2573 		aInfo.iMediaAtt |= KMediaAttLockable;
  2663 // This function is linear in the number of blocks in the cache.
  2670 // This function is linear in the number of blocks in the cache.
  2664 //
  2671 //
  2665 	{
  2672 	{
  2666 	__KTRACE_OPT(KPBUSDRV, Kern::Printf(">mmd:rdc:%x,%x", iReqCur, iReqEnd));
  2673 	__KTRACE_OPT(KPBUSDRV, Kern::Printf(">mmd:rdc:%x,%x", iReqCur, iReqEnd));
  2667 	
  2674 	
       
  2675 	if ( iCurrentReq->IsPhysicalAddress()
  2668 #if defined(__DEMAND_PAGING__) && !defined(__WINS__)
  2676 #if defined(__DEMAND_PAGING__) && !defined(__WINS__)
  2669 	if (DMediaPagingDevice::PageInRequest(*iCurrentReq))
  2677 	     || DMediaPagingDevice::PageInRequest(*iCurrentReq)
       
  2678 #endif //DEMAND_PAGING 
       
  2679         )
  2670 		{
  2680 		{
  2671 		*aAllDone = EFalse;
  2681 		*aAllDone = EFalse;
  2672 		return KErrNone;
  2682 		return KErrNone;
  2673 		}
  2683 		}
  2674 #endif //DEMAND_PAGING	
       
  2675 	
  2684 	
  2676 	TInt64 physStart = iReqCur & ~iBlkMsk;
  2685 	TInt64 physStart = iReqCur & ~iBlkMsk;
  2677 	TInt64 physEnd = Min(physStart + iMaxBufSize, (iReqEnd + iBlkMsk) & ~iBlkMsk);
  2686 	TInt64 physEnd = Min(physStart + iMaxBufSize, (iReqEnd + iBlkMsk) & ~iBlkMsk);
  2678 	BuildGammaArray(physStart, physEnd);
  2687 	BuildGammaArray(physStart, physEnd);
  2679 
  2688