kernel/eka/drivers/locmedia/locmedia.cpp
changeset 201 43365a9b78a3
parent 200 73ea206103e6
child 259 57b9594f5772
equal deleted inserted replaced
200:73ea206103e6 201:43365a9b78a3
    76 	TInt iPhysDevIndex;
    76 	TInt iPhysDevIndex;
    77 	TInt iRequestCount;
    77 	TInt iRequestCount;
    78 #ifdef __DEMAND_PAGING__
    78 #ifdef __DEMAND_PAGING__
    79 	DMediaPagingDevice* iPagingDevice;
    79 	DMediaPagingDevice* iPagingDevice;
    80 	TInt iPageSizeMsk;			// Mask of page size (e.g. 4096-1 -> 4095)
    80 	TInt iPageSizeMsk;			// Mask of page size (e.g. 4096-1 -> 4095)
       
    81 	TInt iPageSizeLog2;        // LOG2 of page size (i.e. 4096 -> 12)
    81 	TInt iMediaChanges;
    82 	TInt iMediaChanges;
    82 #endif
    83 #endif
    83 
    84 
    84 	// This bit mask indicates which local drives the media is attached to
    85 	// This bit mask indicates which local drives the media is attached to
    85 	TUint32 iRegisteredDriveMask;
    86 	TUint32 iRegisteredDriveMask;
  1527 	Pos()=d.iPos;
  1528 	Pos()=d.iPos;
  1528 	Length()=d.iLength;
  1529 	Length()=d.iLength;
  1529 	RemoteDes()=(TAny*)d.iPtr;
  1530 	RemoteDes()=(TAny*)d.iPtr;
  1530 	RemoteDesOffset()=d.iOffset;
  1531 	RemoteDesOffset()=d.iOffset;
  1531 	DriverFlags()=d.iFlags;
  1532 	DriverFlags()=d.iFlags;
       
  1533 	
       
  1534 	// EPhysAddrOnly should not be set for client requests
       
  1535 	Flags() &= ~TLocDrvRequest::EPhysAddrOnly;
       
  1536 	
  1532 	if (Pos()<0 || Length()<0)
  1537 	if (Pos()<0 || Length()<0)
  1533 	    {
  1538 	    {
  1534 		OstTraceFunctionExitExt( TLOCDRVREQUEST_PROCESSMESSAGEDATA_EXIT2, this, KErrArgument );
  1539 		OstTraceFunctionExitExt( TLOCDRVREQUEST_PROCESSMESSAGEDATA_EXIT2, this, KErrArgument );
  1535 		return KErrArgument;
  1540 		return KErrArgument;
  1536 	    }
  1541 	    }
  1826 		}
  1831 		}
  1827 
  1832 
  1828 #ifdef __DEMAND_PAGING__
  1833 #ifdef __DEMAND_PAGING__
  1829 	TInt pageSize = Kern::RoundToPageSize(1);
  1834 	TInt pageSize = Kern::RoundToPageSize(1);
  1830 	iBody->iPageSizeMsk = pageSize-1;
  1835 	iBody->iPageSizeMsk = pageSize-1;
       
  1836 	iBody->iPageSizeLog2 = __e32_find_ms1_32(pageSize);
  1831 #endif
  1837 #endif
  1832 
  1838 
  1833 	iLastMediaId=aLastMediaId;
  1839 	iLastMediaId=aLastMediaId;
  1834 	if (r==KErrNone && iDfcQ)
  1840 	if (r==KErrNone && iDfcQ)
  1835 		{
  1841 		{
  4068 	
  4074 	
  4069 	TLinAddr addr = (TLinAddr) m.RemoteDes();
  4075 	TLinAddr addr = (TLinAddr) m.RemoteDes();
  4070 	TInt len = I64LOW(m.Length());
  4076 	TInt len = I64LOW(m.Length());
  4071 
  4077 
  4072 	TBool needSyncAfterRead = EFalse;
  4078 	TBool needSyncAfterRead = EFalse;
  4073 	if (m.Drive()->iDmaHelper)
  4079     if (m.Drive()->iDmaHelper)
  4074 		{
  4080         {        
  4075 		m.Flags() |= TLocDrvRequest::EPhysAddr;
  4081         m.Flags() |= TLocDrvRequest::EPhysAddr;
  4076 		if (m.Id() == DLocalDrive::EWrite)
  4082         // don't cache sync for zero mapping...
  4077 			{
  4083         if (!(m.Flags() & TLocDrvRequest::EPhysAddrOnly))
  4078 			Cache::SyncMemoryBeforeDmaWrite(addr, len);
  4084             {
  4079 			}
  4085             if (m.Id() == DLocalDrive::EWrite)
  4080 		else
  4086                 {
  4081 			{
  4087                 Cache::SyncMemoryBeforeDmaWrite(addr, len);
  4082 			Cache::SyncMemoryBeforeDmaRead(addr, len);
  4088                 }
  4083 			needSyncAfterRead = ETrue;
  4089             else
  4084 			}
  4090                 {
  4085 		}
  4091                 Cache::SyncMemoryBeforeDmaRead(addr, len);
       
  4092                 needSyncAfterRead = ETrue;
       
  4093                 }
       
  4094             }
       
  4095 	    }
  4086 
  4096 
  4087 	// Count the number of outstanding requests if this is the data-paging media, so that
  4097 	// Count the number of outstanding requests if this is the data-paging media, so that
  4088 	// we can call DPagingDevice::NotifyBusy() / DPagingDevice::NotifyIdle()
  4098 	// we can call DPagingDevice::NotifyBusy() / DPagingDevice::NotifyIdle()
  4089 	if ((m.Flags() & TLocDrvRequest::EBackgroundPaging) == 0)
  4099 	if ((m.Flags() & TLocDrvRequest::EBackgroundPaging) == 0)
  4090 		iPrimaryMedia->RequestCountInc();
  4100 		iPrimaryMedia->RequestCountInc();
  4137 	iPrimaryMedia->CompleteRequest(*((TLocDrvRequest*) aMsg), aResult);
  4147 	iPrimaryMedia->CompleteRequest(*((TLocDrvRequest*) aMsg), aResult);
  4138 	OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_COMPLETEREQUEST_EXIT, this );
  4148 	OstTraceFunctionExit1( DMEDIAPAGINGDEVICE_COMPLETEREQUEST_EXIT, this );
  4139 	}
  4149 	}
  4140 
  4150 
  4141 TInt DMediaPagingDevice::Read(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize,TInt aDrvNumber)
  4151 TInt DMediaPagingDevice::Read(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize,TInt aDrvNumber)
       
  4152     {
       
  4153     return BaseRead(aReq,(TUint32)aBuffer,aOffset,aSize,aDrvNumber,EFalse);
       
  4154     }
       
  4155 
       
  4156 TInt DMediaPagingDevice::ReadPhysical(TThreadMessage* aReq, TPhysAddr* aPageArray, TUint aPageCount, TUint aOffset, TInt aDrvNumber)
       
  4157     {    
       
  4158     TUint adjSize = (aPageCount << iPrimaryMedia->iBody->iPageSizeLog2) >> iReadUnitShift; // translate to Read Units
       
  4159     return BaseRead(aReq,(TUint32)aPageArray,aOffset,adjSize,aDrvNumber,ETrue);
       
  4160     }
       
  4161 
       
  4162 TInt DMediaPagingDevice::BaseRead(TThreadMessage* aReq,TUint32 aBuffer,TUint aOffset,TUint aSize,TInt aDrvNumber, TBool aPhysAddr)
  4142 	{
  4163 	{
  4143 	OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_READ_ENTRY, this );
  4164 	OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_READ_ENTRY, this );
  4144 	__ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT());	// that would lock up the system, thus better die now
  4165 	__ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT());	// that would lock up the system, thus better die now
  4145 	__ASSERT_ALWAYS(aReq,LOCM_FAULT());
  4166 	__ASSERT_ALWAYS(aReq,LOCM_FAULT());
  4146 	__ASSERT_CRITICAL
  4167 	__ASSERT_CRITICAL
  4285 		m.RemoteThread()=NULL;
  4306 		m.RemoteThread()=NULL;
  4286 		m.Pos()=offset;
  4307 		m.Pos()=offset;
  4287 		m.Length()=Int64(size);
  4308 		m.Length()=Int64(size);
  4288 		m.RemoteDes()=(TAny*)aBuffer;
  4309 		m.RemoteDes()=(TAny*)aBuffer;
  4289 		m.RemoteDesOffset()=0;		// pre-aligned
  4310 		m.RemoteDesOffset()=0;		// pre-aligned
  4290 		m.DriverFlags()=0;
  4311 		m.DriverFlags() = 0;
       
  4312 		if (aPhysAddr)
       
  4313 		    m.Flags() |= TLocDrvRequest::EPhysAddrOnly;
       
  4314 
  4291 		__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("ReqId=%d, Pos=0x%lx, Len=0x%lx, remote Des 0x%x",m.Id(),m.Pos(),m.Length(),m.RemoteDes()));
  4315 		__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("ReqId=%d, Pos=0x%lx, Len=0x%lx, remote Des 0x%x",m.Id(),m.Pos(),m.Length(),m.RemoteDes()));
  4292 		OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_READ2, "reqId=%d; remote Des=0x%x", (TInt) m.Id(), (TUint) m.RemoteDes());
  4316 		OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_READ2, "reqId=%d; remote Des=0x%x", (TInt) m.Id(), (TUint) m.RemoteDes());
  4293 		OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_READ3, "length=%x:%x, pos=%x:%x", (TUint) I64HIGH(m.Length()), (TUint) I64LOW(m.Length()), (TUint) I64HIGH(m.Pos()), (TUint) I64LOW(m.Pos()));
  4317 		OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_READ3, "length=%x:%x, pos=%x:%x", (TUint) I64HIGH(m.Length()), (TUint) I64LOW(m.Length()), (TUint) I64HIGH(m.Pos()), (TUint) I64LOW(m.Pos()));
  4294 		
  4318 		
  4295 		__ASSERT_DEBUG(iPrimaryMedia->iBody, LOCM_FAULT());
  4319 		__ASSERT_DEBUG(iPrimaryMedia->iBody, LOCM_FAULT());
  4334 	OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_READ_EXIT2, this, retVal );
  4358 	OstTraceFunctionExitExt( DMEDIAPAGINGDEVICE_READ_EXIT2, this, retVal );
  4335 	return retVal;
  4359 	return retVal;
  4336 	}
  4360 	}
  4337 
  4361 
  4338 TInt DMediaPagingDevice::Write(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize,TBool aBackground)
  4362 TInt DMediaPagingDevice::Write(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize,TBool aBackground)
  4339 	{
  4363     {
       
  4364     return BaseWrite(aReq,(TUint32)aBuffer,aOffset,aSize,aBackground,EFalse);
       
  4365     }
       
  4366 
       
  4367 TInt DMediaPagingDevice::WritePhysical(TThreadMessage* aReq, TPhysAddr* aPageArray, TUint aPageCount, TUint aOffset, TBool aBackground)
       
  4368 	{
       
  4369     TUint adjSize = (aPageCount << iPrimaryMedia->iBody->iPageSizeLog2) >> iReadUnitShift; // translate to Read Units
       
  4370     return BaseWrite(aReq,(TUint32)aPageArray,aOffset,adjSize,aBackground,ETrue);
       
  4371 	}
       
  4372 
       
  4373 TInt DMediaPagingDevice::BaseWrite(TThreadMessage* aReq,TUint32 aBuffer,TUint aOffset,TUint aSize,TBool aBackground, TBool aPhysAddr)
       
  4374     {
  4340 	OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_WRITE_ENTRY, this );
  4375 	OstTraceFunctionEntry1( DMEDIAPAGINGDEVICE_WRITE_ENTRY, this );
  4341 	__ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT());	// that would lock up the system, thus better die now
  4376 	__ASSERT_ALWAYS(NKern::CurrentThread()!=iPrimaryMedia->iDfcQ->iThread,LOCM_FAULT());	// that would lock up the system, thus better die now
  4342 	__ASSERT_ALWAYS(aReq,LOCM_FAULT());
  4377 	__ASSERT_ALWAYS(aReq,LOCM_FAULT());
  4343 	__ASSERT_CRITICAL
  4378 	__ASSERT_CRITICAL
  4344 
  4379 
  4394 	// Write to the media and allow for retries in the unlikely event of an error.
  4429 	// Write to the media and allow for retries in the unlikely event of an error.
  4395 	const TInt KPageOutRetries = 5;
  4430 	const TInt KPageOutRetries = 5;
  4396 	TInt retVal = KErrGeneral;
  4431 	TInt retVal = KErrGeneral;
  4397 	for (TInt i=0; retVal != KErrNone && i < KPageOutRetries; i++)
  4432 	for (TInt i=0; retVal != KErrNone && i < KPageOutRetries; i++)
  4398 		{
  4433 		{
  4399 		m.Flags() = TLocDrvRequest::EKernelBuffer | TLocDrvRequest::EPaging | TLocDrvRequest::EDataPaging | (aBackground ? TLocDrvRequest::EBackgroundPaging : 0);
  4434 		m.Flags() = TLocDrvRequest::EKernelBuffer |
       
  4435 					TLocDrvRequest::EPaging | 
       
  4436                     TLocDrvRequest::EDataPaging | 
       
  4437                     (aBackground ? TLocDrvRequest::EBackgroundPaging : 0) |
       
  4438                     (aPhysAddr ? TLocDrvRequest::EPhysAddrOnly : 0);
  4400 
  4439 
  4401 		m.Id() = DLocalDrive::EWrite;
  4440 		m.Id() = DLocalDrive::EWrite;
  4402 		m.Drive() = TheDrives[iDataPagingDriveNumber];
  4441 		m.Drive() = TheDrives[iDataPagingDriveNumber];
  4403 
  4442 
  4404 		m.RemoteThread()=NULL;
  4443 		m.RemoteThread()=NULL;
  4405 		m.Pos()=offset;
  4444 		m.Pos()=offset;
  4406 		m.Length()=Int64(size);
  4445 		m.Length()=Int64(size);
  4407 		m.RemoteDes()=(TAny*)aBuffer;
  4446 		m.RemoteDes()=(TAny*)aBuffer;
  4408 		m.RemoteDesOffset()=0;		// pre-aligned
  4447 		m.RemoteDesOffset()=0;		// pre-aligned
  4409 		m.DriverFlags()=0;
  4448 		m.DriverFlags() = 0;        
       
  4449 
  4410 		__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("ReqId=%d, Pos=0x%lx, Len=0x%lx, remote Des 0x%x",m.Id(),m.Pos(),m.Length(),m.RemoteDes()));
  4450 		__KTRACE_OPT2(KLOCDRV,KLOCDPAGING,Kern::Printf("ReqId=%d, Pos=0x%lx, Len=0x%lx, remote Des 0x%x",m.Id(),m.Pos(),m.Length(),m.RemoteDes()));
  4411 		OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_WRITE2, "reqId=%d; remote Des=0x%x", (TInt) m.Id(), (TUint) m.RemoteDes());
  4451 		OstTraceDefExt2(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_WRITE2, "reqId=%d; remote Des=0x%x", (TInt) m.Id(), (TUint) m.RemoteDes());
  4412 		OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_WRITE3, "length=%x:%x, pos=%x:%x", (TUint) I64HIGH(m.Length()), (TUint) I64LOW(m.Length()),  (TUint) I64HIGH(m.Pos()), (TUint) I64LOW(m.Pos()));
  4452 		OstTraceDefExt4(OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, DMEDIAPAGINGDEVICE_WRITE3, "length=%x:%x, pos=%x:%x", (TUint) I64HIGH(m.Length()), (TUint) I64LOW(m.Length()),  (TUint) I64HIGH(m.Pos()), (TUint) I64LOW(m.Pos()));
  4413 		
  4453 		
  4414 		__ASSERT_DEBUG(iPrimaryMedia->iBody, LOCM_FAULT());
  4454 		__ASSERT_DEBUG(iPrimaryMedia->iBody, LOCM_FAULT());
  5265 	TInt firstLocalDriveNumber = KErrNotFound; 
  5305 	TInt firstLocalDriveNumber = KErrNotFound; 
  5266 	TInt romPagingDriveNumber = KErrNotFound;
  5306 	TInt romPagingDriveNumber = KErrNotFound;
  5267 
  5307 
  5268 	TInt dataPagingDriveNumber = KErrNotFound;
  5308 	TInt dataPagingDriveNumber = KErrNotFound;
  5269 	TInt swapSize = 0;
  5309 	TInt swapSize = 0;
       
  5310 	TInt blockSize = 0;
       
  5311 	TUint16 flags = 0;
  5270 
  5312 
  5271 	// find the local drive assocated with the primary media
  5313 	// find the local drive assocated with the primary media
  5272 	for (i=0; i<KMaxLocalDrives; ++i)
  5314 	for (i=0; i<KMaxLocalDrives; ++i)
  5273 		{
  5315 		{
  5274 		if(TheDrives[i] && TheDrives[i]->iPrimaryMedia == aPrimaryMedia)
  5316 		if(TheDrives[i] && TheDrives[i]->iPrimaryMedia == aPrimaryMedia)
  5299 			return KErrNotReady;
  5341 			return KErrNotReady;
  5300 			}
  5342 			}
  5301 
  5343 
  5302 
  5344 
  5303 		TLocDrvRequest m;
  5345 		TLocDrvRequest m;
       
  5346         TBuf8<KMaxLocalDriveCapsLength> capsBuf;
       
  5347         
  5304 		memclr(&m, sizeof(m));
  5348 		memclr(&m, sizeof(m));
  5305 		
  5349 		
  5306 
       
  5307 		// Get the Caps from the device. NB for MMC/SD we may need to retry as some PSLs start up
  5350 		// Get the Caps from the device. NB for MMC/SD we may need to retry as some PSLs start up
  5308 		// in "door open" or "media not present" state which can result in the cancellation of requests
  5351 		// in "door open" or "media not present" state which can result in the cancellation of requests
  5309 		TInt i;
  5352 		TInt i;
  5310 		const TInt KRetries = 5;
  5353 		const TInt KRetries = 5;
  5311 		TInt r = KErrNotReady;
  5354 		TInt r = KErrNotReady;
  5312 		for (i=0; r == KErrNotReady && i < KRetries; i++)
  5355 		for (i=0; r == KErrNotReady && i < KRetries; i++)
  5313 			{
  5356 			{
  5314 			TBuf8<KMaxLocalDriveCapsLength> capsBuf;
       
  5315 			capsBuf.SetMax();
  5357 			capsBuf.SetMax();
  5316 			capsBuf.FillZ();
  5358 			capsBuf.FillZ();
  5317 			m.Drive() = TheDrives[firstLocalDriveNumber];
  5359 			m.Drive() = TheDrives[firstLocalDriveNumber];
  5318 			m.Id() = DLocalDrive::ECaps;
  5360 			m.Id() = DLocalDrive::ECaps;
  5319 			m.RemoteDes() = (TAny*)capsBuf.Ptr();	// overload this
  5361 			m.RemoteDes() = (TAny*)capsBuf.Ptr();	// overload this
  5331             // Media driver failure; media maybe recoverable after boot.
  5373             // Media driver failure; media maybe recoverable after boot.
  5332             // Can't register any page drives so return not supported.
  5374             // Can't register any page drives so return not supported.
  5333 			return KErrNotSupported;
  5375 			return KErrNotSupported;
  5334 		    }
  5376 		    }
  5335 
  5377 
       
  5378 		TLocalDriveCapsV6& caps = *(TLocalDriveCapsV6*)capsBuf.Ptr();
       
  5379 		blockSize = caps.iBlockSize;
       
  5380 		__ASSERT_DEBUG(blockSize,LOCM_FAULT());
       
  5381 		__ASSERT_DEBUG(__e32_bit_count_32(blockSize)==1,LOCM_FAULT());
       
  5382 		
  5336 		TLocDrv* drive;
  5383 		TLocDrv* drive;
  5337 		for (i=0; i<KMaxLocalDrives; ++i)
  5384 		for (i=0; i<KMaxLocalDrives; ++i)
  5338 			{
  5385 			{
  5339 			drive = TheDrives[i];
  5386 			drive = TheDrives[i];
  5340 			if(drive && drive->iPrimaryMedia == aPrimaryMedia)
  5387 			if(drive && drive->iPrimaryMedia == aPrimaryMedia)
  5357 					__KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("Found swap partition on local drive %d, size %x", i, I64LOW(drive->iPartitionLen)));
  5404 					__KTRACE_OPT2(KBOOT,KLOCDPAGING, Kern::Printf("Found swap partition on local drive %d, size %x", i, I64LOW(drive->iPartitionLen)));
  5358 					OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE6, "Found SWAP partition on local drive=%d; size=0x%x", (TInt) i, (TUint) I64LOW(drive->iPartitionLen) );			
  5405 					OstTraceDefExt2( OST_TRACE_CATEGORY_RND, TRACE_DEMANDPAGING, LOCDRV_REGISTERPAGINGDEVICE6, "Found SWAP partition on local drive=%d; size=0x%x", (TInt) i, (TUint) I64LOW(drive->iPartitionLen) );			
  5359 					dataPagingDriveNumber = i;
  5406 					dataPagingDriveNumber = i;
  5360 					TheDataPagingDrive = drive;
  5407 					TheDataPagingDrive = drive;
  5361 					swapSize = drive->iPartitionLen >> aReadShift;
  5408 					swapSize = drive->iPartitionLen >> aReadShift;
       
  5409 					
       
  5410 			        // Mark Paging Device capable of utilising physical addresss only accesses
       
  5411 			        if (drive->iDmaHelper)
       
  5412 			            flags |= DPagingDevice::ESupportsPhysicalAccess;  
  5362 					}
  5413 					}
  5363 				}
  5414 				}
  5364 			}
  5415 			}
  5365 
  5416 
  5366 		if (swapSize == 0)
  5417 		if (swapSize == 0)
  5391 	pagingDevice->iFirstLocalDriveNumber = firstLocalDriveNumber;
  5442 	pagingDevice->iFirstLocalDriveNumber = firstLocalDriveNumber;
  5392 	pagingDevice->iRomPagingDriveNumber = romPagingDriveNumber;
  5443 	pagingDevice->iRomPagingDriveNumber = romPagingDriveNumber;
  5393 
  5444 
  5394 	pagingDevice->iDataPagingDriveNumber = dataPagingDriveNumber;
  5445 	pagingDevice->iDataPagingDriveNumber = dataPagingDriveNumber;
  5395 	pagingDevice->iSwapSize = swapSize;
  5446 	pagingDevice->iSwapSize = swapSize;
       
  5447 		
       
  5448 	pagingDevice->iPreferredWriteShift = (blockSize) ? __e32_find_ms1_32(blockSize) : 0;
  5396 
  5449 
  5397 #ifdef __DEBUG_DEMAND_PAGING__
  5450 #ifdef __DEBUG_DEMAND_PAGING__
  5398 	Kern::Printf("PagingDevice :");
  5451 	Kern::Printf("PagingDevice :");
  5399 	Kern::Printf("Name %S", firstLocalDriveNumber >= 0 && DriveNames[firstLocalDriveNumber] ? DriveNames[firstLocalDriveNumber] : &KNullDesC8);
  5452 	Kern::Printf("Name %S", firstLocalDriveNumber >= 0 && DriveNames[firstLocalDriveNumber] ? DriveNames[firstLocalDriveNumber] : &KNullDesC8);
  5400 	Kern::Printf("iType 0x%x", pagingDevice->iType);
  5453 	Kern::Printf("iType 0x%x", pagingDevice->iType);
       
  5454 	Kern::Printf("iFlags 0x%x\n", pagingDevice->iFlags);
  5401 	Kern::Printf("iReadUnitShift 0x%x", pagingDevice->iReadUnitShift);
  5455 	Kern::Printf("iReadUnitShift 0x%x", pagingDevice->iReadUnitShift);
  5402 	Kern::Printf("iFirstLocalDriveNumber 0x%x", pagingDevice->iFirstLocalDriveNumber);
  5456 	Kern::Printf("iFirstLocalDriveNumber 0x%x", pagingDevice->iFirstLocalDriveNumber);
  5403 	Kern::Printf("iRomPagingDriveNumber 0x%x", pagingDevice->iRomPagingDriveNumber);
  5457 	Kern::Printf("iRomPagingDriveNumber 0x%x", pagingDevice->iRomPagingDriveNumber);
  5404 	Kern::Printf("iDataPagingDriveNumber 0x%x", pagingDevice->iDataPagingDriveNumber);
  5458 	Kern::Printf("iDataPagingDriveNumber 0x%x", pagingDevice->iDataPagingDriveNumber);
  5405 	Kern::Printf("iSwapSize 0x%x", pagingDevice->iSwapSize);
  5459 	Kern::Printf("iSwapSize 0x%x", pagingDevice->iSwapSize);
       
  5460 	Kern::Printf("iPreferredWriteShift 0x%x\n", pagingDevice->iPreferredWriteShift);
  5406 #endif
  5461 #endif
  5407 
  5462 
  5408 
  5463 
  5409 	// This table is indexed by DPagingDevice::TType
  5464 	// This table is indexed by DPagingDevice::TType
  5410 	const char* DeviceName[] = 
  5465 	const char* DeviceName[] =