omap3530/beagle_drivers/medwb/medwb.cpp
author arunabha
Wed, 03 Mar 2010 13:10:32 +0000
changeset 27 117faf51deac
child 35 2905910218db
permissions -rw-r--r--
Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver this storage driver is for the West Bridge Astoria chipset. This device has a USB, SD and processor port for communication with a baseband processor. In our port, we connected this device DVK to the Beagleboard through the SPI interface of the OMAP3. After driver installation, the Symbian OS can see an external device or D: drive represented by the SD card. In this driver, the USB interface is not used directly, though this may be the subject of future contributions. The appropriate way to test the driver is to access the external volume and do file read and write to it, pretty much the same way you would test a thumb drive on your PC
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     1
/* Cypress West Bridge API source file 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     2
## ===========================
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     3
##
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     4
##  Copyright Cypress Semiconductor Corporation, 2006-2009,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     5
##  All Rights Reserved
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     6
##  UNPUBLISHED, LICENSED SOFTWARE.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     7
##
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     8
##  CONFIDENTIAL AND PROPRIETARY INFORMATION
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
     9
##  WHICH IS THE PROPERTY OF CYPRESS.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    10
##
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    11
##  Use of this file is governed
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    12
##  by the license agreement included in the file
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    13
##
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    14
##     <install>/license/license.txt
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    15
##
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    16
##  where <install> is the Cypress software
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    17
##  installation root directory path.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    18
##
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    19
## ===========================
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    20
*/
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    21
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    22
#include "locmedia.h"
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    23
#include "platform.h"
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    24
//#include "variantmediadef.h"
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    25
#include <assp\omap3530_assp\CyAsSymbianStorageDriver.h>
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    26
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    27
//#define REGIST_MEDIA_USE_MMC
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    28
#define _MEDWB_DEBUG_1_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    29
//#define _MEDWB_DEBUG_2_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    30
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    31
//#define INTERVAL_FOR_WB 15 // 15 -- OK
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    32
#define WB_BUFFER_SIZE	2*(65536 + 512)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    33
#define WB_RETRY_COUNT 2
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    34
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    35
//const TInt KStackNumber = 0;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    36
const TInt KDiskSectorSize=512;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    37
const TInt KDiskSectorShift=9;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    38
//const TInt KIdleCurrentInMilliAmps = 1;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    39
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    40
const TInt KMBRFirstPartitionEntry=0x1BE;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    41
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    42
TUint8	ptrWBBuffer[WB_BUFFER_SIZE];
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    43
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    44
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    45
template <class T>
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    46
inline T UMin(T aLeft,T aRight)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    47
	{return(aLeft<aRight ? aLeft : aRight);}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    48
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    49
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    50
class DPhysicalDeviceMediaWB : public DPhysicalDevice
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    51
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    52
public:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    53
	DPhysicalDeviceMediaWB();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    54
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    55
	virtual TInt Install();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    56
	virtual void GetCaps(TDes8& aDes) const;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    57
	virtual TInt Create(DBase*& aChannel, TInt aMediaId, const TDesC8* aInfo, const TVersion& aVer);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    58
	virtual TInt Validate(TInt aDeviceType, const TDesC8* aInfo, const TVersion& aVer);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    59
	virtual TInt Info(TInt aFunction, TAny* a1);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    60
	};
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    61
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    62
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    63
class DMediaDriverWB : public DMediaDriver
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    64
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    65
public:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    66
	DMediaDriverWB(TInt aMediaId);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    67
	~DMediaDriverWB();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    68
	// ...from DMediaDriver
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    69
	virtual void Close();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    70
	// replacing pure virtual
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    71
	virtual void Disconnect(DLocalDrive* aLocalDrive, TThreadMessage*);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    72
	virtual TInt Request(TLocDrvRequest& aRequest);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    73
	virtual TInt PartitionInfo(TPartitionInfo& anInfo);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    74
	virtual void NotifyPowerDown();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    75
	virtual void NotifyEmergencyPowerDown();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    76
	// For creation by DPhysicalDeviceMediaMmcFlash
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    77
	TInt DoCreate(TInt aMediaId);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    78
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    79
private:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    80
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    81
private:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    82
	// MMC device specific stuff
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    83
	TInt DoRead(TLocDrvRequest&);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    84
	TInt DoWrite(TLocDrvRequest&);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    85
	TInt DoFormat(TLocDrvRequest&);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    86
	TInt Caps(TLocDrv& aDrive, TLocalDriveCapsV6& aInfo);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    87
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    88
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    89
	TInt DecodePartitionInfo();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    90
	TInt WritePartitionInfo();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    91
	TInt GetDefaultPartitionInfo(TMBRPartitionEntry& aPartitionEntry);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    92
	TInt CreateDefaultPartition();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    93
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    94
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    95
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    96
	static void SetPartitionEntry(TPartitionEntry* aEntry, TUint aFirstSector, TUint aNumSectors);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    97
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    98
	TInt CheckDevice(int aReqType);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
    99
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   100
	void Reset();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   101
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   102
private:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   103
	TInt iMediaId;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   104
	TPartitionInfo* iPartitionInfo;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   105
	TBool iMbrMissing;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   106
	TUint iHiddenSectors;						// bootup / password
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   107
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   108
	TUint8* ptrWriteBuf;							// start of current buffer region
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   109
	TUint8* ptrReadBuf;							// start of current buffer region
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   110
	TInt	read_size;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   111
	TInt	read_pos;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   112
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   113
	TInt 	iUnitSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   114
	TInt	iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   115
	};
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   116
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   117
// ======== DPhysicalDeviceMediaMmcFlash ========
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   118
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   119
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   120
DPhysicalDeviceMediaWB::DPhysicalDeviceMediaWB()
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   121
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   122
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   123
	Kern::Printf("=mmd:ctr");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   124
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   125
	iUnitsMask = 0x01;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   126
	iVersion = TVersion(KMediaDriverInterfaceMajorVersion,KMediaDriverInterfaceMinorVersion,KMediaDriverInterfaceBuildVersion);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   127
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   128
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   129
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   130
TInt DPhysicalDeviceMediaWB::Install()
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   131
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   132
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   133
	Kern::Printf("=mmd:ins");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   134
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   135
	_LIT(KDrvNm, "Media.WB");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   136
	return SetName(&KDrvNm);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   137
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   138
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   139
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   140
void DPhysicalDeviceMediaWB::GetCaps(TDes8& /* aDes */) const
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   141
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   142
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   143
	Kern::Printf("=mmd:cap");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   144
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   145
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   146
								 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   147
									 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   148
TInt DPhysicalDeviceMediaWB::Info(TInt aFunction, TAny* /*a1*/)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   149
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   150
// Return the priority of this media driver
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   151
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   152
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   153
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   154
	Kern::Printf("=mmd:info");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   155
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   156
	if (aFunction==EPriority)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   157
		return KMediaDriverPriorityNormal;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   158
	// Don't close media driver when peripheral bus powers down. This avoids the need for Caps() to power up the stack.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   159
	if (aFunction==EMediaDriverPersistent)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   160
		return KErrNone;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   161
	return KErrNotSupported;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   162
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   163
								 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   164
TInt DPhysicalDeviceMediaWB::Validate(TInt aDeviceType, const TDesC8* /*aInfo*/, const TVersion& aVer)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   165
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   166
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   167
	Kern::Printf("=mmd:validate aDeviceType %d\n", aDeviceType);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   168
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   169
	if (!Kern::QueryVersionSupported(iVersion,aVer))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   170
	{	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   171
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   172
		Kern::Printf("Validate -> KErrNotSupported\n");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   173
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   174
		return KErrNotSupported;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   175
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   176
	if (aDeviceType!=MEDIA_DEVICE_MMC)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   177
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   178
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   179
		Kern::Printf("Validate -> Wrong DeviceType\n");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   180
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   181
		return KErrNotSupported;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   182
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   183
	return KErrNone;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   184
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   185
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   186
								 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   187
TInt DPhysicalDeviceMediaWB::Create(DBase*& aChannel, TInt aMediaId, const TDesC8* /*aInfo*/, const TVersion& aVer)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   188
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   189
// Create an MMC Card media driver.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   190
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   191
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   192
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   193
	Kern::Printf("=mmd:crt");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   194
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   195
	if (!Kern::QueryVersionSupported(iVersion,aVer))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   196
		return KErrNotSupported;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   197
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   198
	DMediaDriverWB* pD = new DMediaDriverWB(aMediaId);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   199
	aChannel=pD;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   200
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   201
	TInt r=KErrNoMemory;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   202
	if (pD)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   203
		r=pD->DoCreate(aMediaId);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   204
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   205
	#ifdef REGIST_MEDIA_USE_MMC
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   206
	if (r==KErrNone)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   207
		pD->OpenMediaDriverComplete(KErrNone);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   208
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   209
	__KTRACE_OPT(KPBUSDRV, Kern::Printf("<mmd:mdf"));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   210
	return r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   211
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   212
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   213
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   214
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   215
// Helper
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   216
template <class T>
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   217
inline T* KernAlloc(const TUint32 n)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   218
	{ return static_cast<T*>(Kern::Alloc(n * sizeof(T))); }
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   219
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   220
// ---- ctor, open, close, dtor ----
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   221
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   222
#pragma warning( disable : 4355 )	// this used in initializer list
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   223
DMediaDriverWB::DMediaDriverWB(TInt aMediaId)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   224
   :DMediaDriver(aMediaId),
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   225
	iMediaId(iPrimaryMedia->iNextMediaId)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   226
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   227
	#ifdef _MEDWB_DEBUG_2_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   228
	Kern::Printf("=mmd:wb");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   229
	// NB aMedia Id = the media ID of the primary media, iMediaId = the media ID of this media
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   230
	Kern::Printf("DMediaDriverWB(), iMediaId %d, aMediaId %d\n", iMediaId, aMediaId);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   231
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   232
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   233
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   234
#pragma warning( default : 4355 )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   235
TInt DMediaDriverWB::DoCreate(TInt /*aMediaId*/)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   236
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   237
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   238
	Kern::Printf(">mmd:opn");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   239
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   240
	iUnitSize = CyAsSymbianStorageDriver::GetUnitSize();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   241
	iBlockSize = CyAsSymbianStorageDriver::GetBlockSize();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   242
	if( iBlockSize == 0 )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   243
		iBlockSize = 1;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   244
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   245
	read_pos = 0x7FFFFFFF;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   246
	read_size = 0;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   247
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   248
	// get card characteristics
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   249
	SetTotalSizeInBytes(CyAsSymbianStorageDriver::GetMediaSize());
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   250
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   251
	// get buffer memory from EPBUS
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   252
	ptrReadBuf = ptrWBBuffer;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   253
	ptrWriteBuf = &ptrWBBuffer[65536+512];
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   254
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   255
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   256
	Kern::Printf("<mmd:opn");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   257
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   258
	return(KErrNone);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   259
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   260
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   261
void DMediaDriverWB::Close()
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   262
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   263
// Close the media driver - also called on media change
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   264
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   265
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   266
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   267
	Kern::Printf("=mmd:cls");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   268
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   269
	EndInCritical();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   270
	//CompleteRequest(KErrNotReady);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   271
	DMediaDriver::Close();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   272
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   273
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   274
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   275
DMediaDriverWB::~DMediaDriverWB()
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   276
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   277
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   278
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   279
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   280
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   281
// ---- media access ----
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   282
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   283
TInt DMediaDriverWB::DoRead(TLocDrvRequest& iCurrentReq)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   284
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   285
// set up iReqStart, iReqEnd and iReqCur and launch first read.  Subsequent reads
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   286
// will be launched from the callback DFC.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   287
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   288
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   289
	Int64 pos=iCurrentReq.Pos();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   290
	Int64 length=iCurrentReq.Length();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   291
	TInt r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   292
	if (length<0 || pos<0 || (pos+length)>KMaxTInt)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   293
		return KErrGeneral;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   294
	TInt p=(TInt)pos;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   295
	TInt l=(TInt)length;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   296
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   297
	if (p+l>CyAsSymbianStorageDriver::GetMediaSize())
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   298
		return KErrGeneral;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   299
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   300
	TInt pos_block = p / iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   301
	TInt pos_offset =  p % iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   302
	TInt size_block = l / iBlockSize; 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   303
	TInt size_offset = l % iBlockSize; 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   304
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   305
	TUint buf_offset = 0;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   306
	TInt	local_pos;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   307
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   308
	#ifdef _MEDWB_DEBUG_2_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   309
	Kern::Printf("WB::Read> real (%d@%d)", l, p);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   310
	Kern::Printf("WB::Read> pos_block - %d", pos_block) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   311
	Kern::Printf("WB::Read> pos_offset - %d", pos_offset) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   312
	Kern::Printf("WB::Read> size_block - %d", size_block) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   313
	Kern::Printf("WB::Read> size_offset - %d", size_offset) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   314
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   315
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   316
	#ifdef INTERVAL_FOR_WB
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   317
	NKern::Sleep(INTERVAL_FOR_WB);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   318
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   319
	if( pos_block == read_pos )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   320
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   321
		if( read_size < l )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   322
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   323
			buf_offset = read_size;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   324
			size_block = (l-read_size) / iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   325
			size_offset = (l-read_size) % iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   326
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   327
			local_pos = pos_block + (read_size /iBlockSize);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   328
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   329
		else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   330
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   331
			TPtrC8 des((ptrReadBuf+pos_offset), l);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   332
				
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   333
			r = iCurrentReq.WriteRemote(&des, 0);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   334
			
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   335
			return r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   336
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   337
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   338
	#if 0
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   339
	else if( (read_pos + (read_size/iBlockSize)) > pos_block )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   340
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   341
		TInt adjust_offset;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   342
		TInt adjust_size;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   343
		adjust_offset = (read_pos - pos_block) * iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   344
		adjust_size = read_size - adjust_offset;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   345
		
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   346
		memcpy(ptrReadBuf, &ptrReadBuf[adjust_offset], adjust_size );
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   347
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   348
		read_pos = pos_block;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   349
		read_size = adjust_size;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   350
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   351
		if( read_size < l )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   352
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   353
			buf_offset = read_size;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   354
			size_block = (l-read_size) / iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   355
			size_offset = (l-read_size) % iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   356
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   357
			local_pos = pos_block + (read_size /iBlockSize);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   358
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   359
		else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   360
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   361
			TPtrC8 des((ptrReadBuf+pos_offset), l);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   362
				
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   363
			r = iCurrentReq.WriteRemote(&des, 0);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   364
			
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   365
			return r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   366
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   367
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   368
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   369
	else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   370
		local_pos = read_pos = pos_block;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   371
		
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   372
	#ifdef _MEDWB_DEBUG_2_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   373
	Kern::Printf("WB::Read> local_pos - %d", local_pos) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   374
	Kern::Printf("WB::Read> buf_offset - %d", buf_offset) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   375
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   376
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   377
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   378
	if( size_block )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   379
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   380
		CyAsSymbianStorageDriver::Read(local_pos, size_block, (void *)(ptrReadBuf+buf_offset));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   381
		local_pos += size_block;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   382
		buf_offset += (size_block*iBlockSize);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   383
	#ifdef INTERVAL_FOR_WB
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   384
		NKern::Sleep(INTERVAL_FOR_WB);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   385
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   386
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   387
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   388
	if( pos_offset || size_offset )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   389
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   390
		CyAsSymbianStorageDriver::Read(local_pos, 1, (void *)(ptrReadBuf+buf_offset) );
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   391
		local_pos += size_block;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   392
		buf_offset += iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   393
	#ifdef INTERVAL_FOR_WB
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   394
		NKern::Sleep(INTERVAL_FOR_WB);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   395
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   396
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   397
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   398
	read_size = buf_offset;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   399
		
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   400
	TPtrC8 des((ptrReadBuf+pos_offset), l);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   401
		
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   402
	r = iCurrentReq.WriteRemote(&des, 0);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   403
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   404
	return r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   405
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   406
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   407
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   408
TInt DMediaDriverWB::DoWrite(TLocDrvRequest& iCurrentReq)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   409
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   410
// set up iReqStart, iReqEnd, and iReqCur, and launch first write.  Any subsequent
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   411
// writes are launched from the session end DFC.  LaunchWrite() handles pre-reading
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   412
// any sectors that are only partially modified.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   413
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   414
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   415
	Int64 pos = iCurrentReq.Pos();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   416
	Int64 length = iCurrentReq.Length();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   417
	TInt r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   418
	if (length<0 || pos<0 || (pos+length)>KMaxTInt)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   419
		return KErrGeneral;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   420
	TInt p=(TInt)pos;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   421
	TInt l=(TInt)length;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   422
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   423
	if (p+l>CyAsSymbianStorageDriver::GetMediaSize())
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   424
		return KErrGeneral;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   425
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   426
	#ifdef _MEDWB_DEBUG_2_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   427
	Kern::Printf("WB::Write> (%d@%d)", l, p);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   428
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   429
	#ifdef INTERVAL_FOR_WB
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   430
	NKern::Sleep(INTERVAL_FOR_WB);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   431
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   432
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   433
	TInt pos_block = p / iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   434
	TInt pos_offset =  p % iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   435
	TInt size_block = l / iBlockSize; 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   436
	TInt size_offset = l % iBlockSize; 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   437
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   438
	TUint buf_offset = 0;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   439
	TInt	local_pos;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   440
	TInt	w_block_size = 0;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   441
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   442
	local_pos = pos_block;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   443
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   444
	if( size_block )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   445
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   446
		CyAsSymbianStorageDriver::Read(local_pos, size_block, (void *)(ptrWriteBuf+buf_offset));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   447
		local_pos += size_block;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   448
		buf_offset += (size_block*iBlockSize);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   449
		w_block_size += size_block;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   450
	#ifdef INTERVAL_FOR_WB
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   451
		NKern::Sleep(INTERVAL_FOR_WB);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   452
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   453
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   454
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   455
	if( pos_offset || size_offset )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   456
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   457
		CyAsSymbianStorageDriver::Read(local_pos, 1, (void *)(ptrWriteBuf+buf_offset) );
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   458
		local_pos += size_block;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   459
		buf_offset += iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   460
		w_block_size ++;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   461
	#ifdef INTERVAL_FOR_WB
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   462
		NKern::Sleep(INTERVAL_FOR_WB);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   463
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   464
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   465
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   466
	#ifdef _MEDWB_DEBUG_2_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   467
	Kern::Printf("WB::Write> pos_block - %d", pos_block) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   468
	Kern::Printf("WB::Write> pos_offset - %d", pos_offset) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   469
	Kern::Printf("WB::Write> size_block - %d", size_block) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   470
	Kern::Printf("WB::Write> size_offset - %d", size_offset) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   471
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   472
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   473
	TPtr8 des((ptrWriteBuf+pos_offset), l);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   474
		
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   475
	if ( (r = iCurrentReq.ReadRemote(&des,0)) !=KErrNone)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   476
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   477
		return r;			
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   478
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   479
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   480
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   481
	#ifdef _MEDWB_DEBUG_2_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   482
	Kern::Printf("WB::Write> local_pos - %d", local_pos) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   483
	Kern::Printf("WB::Write> w_block_size - %d", w_block_size) ;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   484
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   485
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   486
	CyAsSymbianStorageDriver::Write(local_pos, w_block_size, ptrWriteBuf);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   487
	#ifdef INTERVAL_FOR_WB
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   488
	NKern::Sleep(INTERVAL_FOR_WB);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   489
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   490
	return r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   491
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   492
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   493
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   494
TInt DMediaDriverWB::DoFormat(TLocDrvRequest& iCurrentReq)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   495
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   496
	Int64 pos = iCurrentReq.Pos();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   497
	Int64 length = iCurrentReq.Length();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   498
	TInt r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   499
	if (length<0 || pos<0 || (pos+length)>KMaxTInt)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   500
		return KErrGeneral;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   501
	TInt p=(TInt)pos;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   502
	TInt l=(TInt)length;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   503
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   504
	if (p+l>CyAsSymbianStorageDriver::GetMediaSize())
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   505
		return KErrGeneral;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   506
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   507
	#ifdef _MEDWB_DEBUG_1_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   508
	Kern::Printf("WB::Format> (%d@%d)", l, p);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   509
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   510
	#ifdef INTERVAL_FOR_WB
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   511
	NKern::Sleep(INTERVAL_FOR_WB);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   512
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   513
	TInt pos_block = p / iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   514
	TInt pos_offset =  p % iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   515
	TInt size_block = l / iBlockSize; 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   516
	TInt size_offset = l % iBlockSize; 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   517
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   518
	TUint buf_offset = 0;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   519
	TInt	local_pos;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   520
	TInt	w_block_size = 0;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   521
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   522
	local_pos = pos_block;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   523
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   524
	if( size_block )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   525
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   526
		CyAsSymbianStorageDriver::Read(local_pos, size_block, (void *)(ptrWriteBuf+buf_offset));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   527
		local_pos += size_block;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   528
		buf_offset += (size_block*iBlockSize);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   529
		w_block_size += size_block;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   530
	#ifdef INTERVAL_FOR_WB
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   531
		NKern::Sleep(INTERVAL_FOR_WB);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   532
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   533
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   534
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   535
	if( pos_offset || size_offset )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   536
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   537
		CyAsSymbianStorageDriver::Read(local_pos, 1, (void *)(ptrWriteBuf+buf_offset) );
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   538
		local_pos += size_block;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   539
		buf_offset += iBlockSize;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   540
		w_block_size ++;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   541
	#ifdef INTERVAL_FOR_WB
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   542
		NKern::Sleep(INTERVAL_FOR_WB);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   543
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   544
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   545
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   546
	memclr(ptrWriteBuf + pos_offset, l);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   547
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   548
	CyAsSymbianStorageDriver::Write(local_pos, w_block_size, ptrWriteBuf);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   549
	#ifdef INTERVAL_FOR_WB
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   550
	NKern::Sleep(INTERVAL_FOR_WB);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   551
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   552
	return r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   553
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   554
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   555
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   556
TInt DMediaDriverWB::PartitionInfo(TPartitionInfo& anInfo)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   557
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   558
// Read the partition information for the media.  If the user supplied a password,
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   559
// then unlock the card before trying to read the first sector.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   560
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   561
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   562
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   563
	Kern::Printf(">mmd:rpi");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   564
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   565
	iPartitionInfo = &anInfo;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   566
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   567
	// Assume MBR will be present or is not required
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   568
	iMbrMissing = EFalse;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   569
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   570
	TInt r = DecodePartitionInfo();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   571
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   572
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   573
	if(r == KErrLocked)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   574
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   575
		// If the media is locked, we present a default partition entry to the local
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   576
		// media subsystem, which will be updated when the media is finally unlocked.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   577
		r = CreateDefaultPartition();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   578
		if (r != KErrNone)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   579
			return r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   580
		return KErrLocked;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   581
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   582
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   583
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   584
	Kern::Printf("<mmd:rpi:%d", r);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   585
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   586
	// KErrNone indicates asynchronous completion
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   587
	return r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   588
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   589
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   590
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   591
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   592
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   593
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   594
TInt DMediaDriverWB::DecodePartitionInfo()
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   595
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   596
// decode partition info that was read into internal buffer 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   597
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   598
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   599
	TInt partitionCount=iPartitionInfo->iPartitionCount=0;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   600
	TInt defaultPartitionNumber=-1;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   601
	TMBRPartitionEntry* pe;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   602
	const TUint KMBRFirstPartitionOffsetAligned = KMBRFirstPartitionOffset & ~3;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   603
	TInt i;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   604
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   605
	CyAsSymbianStorageDriver::Read(0, 1, (void *)ptrReadBuf);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   606
	read_pos = 0;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   607
	read_size = 512;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   608
	// Read of the first sector successful so check for a Master Boot Record
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   609
	if (*(TUint16*)(&ptrReadBuf[KMBRSignatureOffset])!=0xAA55)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   610
		goto mbr_done;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   611
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   612
	__ASSERT_COMPILE(KMBRFirstPartitionOffsetAligned + KMBRMaxPrimaryPartitions * sizeof(TMBRPartitionEntry) <= KMBRSignatureOffset);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   613
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   614
	memmove(&ptrReadBuf[0], &ptrReadBuf[2],
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   615
		KMBRFirstPartitionOffsetAligned + KMBRMaxPrimaryPartitions * sizeof(TMBRPartitionEntry)); 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   616
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   617
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   618
	for (i=0, pe = (TMBRPartitionEntry*)(&ptrReadBuf[KMBRFirstPartitionOffsetAligned]);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   619
		pe->iPartitionType != 0 && i < KMBRMaxPrimaryPartitions;i++,pe++)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   620
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   621
		if (pe->IsDefaultBootPartition())
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   622
			{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   623
			SetPartitionEntry(&iPartitionInfo->iEntry[0],pe->iFirstSector,pe->iNumSectors);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   624
			defaultPartitionNumber=i;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   625
			partitionCount++;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   626
			break;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   627
			}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   628
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   629
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   630
	// Now add any other partitions
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   631
	for (i=0, pe = (TMBRPartitionEntry*)(&ptrReadBuf[KMBRFirstPartitionOffsetAligned]);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   632
		pe->iPartitionType != 0 && i < KMBRMaxPrimaryPartitions;i++,pe++)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   633
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   634
		TBool validPartition = ETrue;	// assume partition valid
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   635
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   636
		if (defaultPartitionNumber==i)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   637
			{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   638
			// Already sorted
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   639
			}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   640
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   641
		// FAT partition ?
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   642
		else if (pe->IsValidDosPartition() || pe->IsValidFAT32Partition())
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   643
			{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   644
			SetPartitionEntry(&iPartitionInfo->iEntry[partitionCount],pe->iFirstSector,pe->iNumSectors);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   645
			#ifdef _MEDWB_DEBUG_1_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   646
			Kern::Printf("WB: FAT partition found at sector #%u", pe->iFirstSector);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   647
			#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   648
			partitionCount++;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   649
			}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   650
		else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   651
			{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   652
			validPartition = EFalse;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   653
			}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   654
		
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   655
		if (validPartition && partitionCount == 1)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   656
			iHiddenSectors = pe->iFirstSector;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   657
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   658
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   659
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   660
	// Check the validity of the partition address boundaries
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   661
	// If there is any
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   662
	if(partitionCount > 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   663
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   664
		const TInt64 deviceSize = CyAsSymbianStorageDriver::GetMediaSize();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   665
		TPartitionEntry& part = iPartitionInfo->iEntry[partitionCount - 1];
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   666
		// Check that the card address space boundary is not exceeded by the last partition
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   667
		// In case of only 1 partition in the media check also it
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   668
		if(part.iPartitionBaseAddr + part.iPartitionLen > deviceSize)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   669
			{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   670
			Kern::Printf("WB: MBR partition exceeds card memory space");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   671
			// Adjust the partition length to card address boundary
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   672
			part.iPartitionLen = (deviceSize - part.iPartitionBaseAddr);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   673
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   674
			// Check that the base address contained valid information
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   675
			if(part.iPartitionLen <= 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   676
				{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   677
				Kern::Printf("WB: Invalid base address");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   678
				// Invalid MBR - assume the boot sector is in the first sector
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   679
				defaultPartitionNumber =-1; 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   680
				partitionCount=0;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   681
				}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   682
			}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   683
		// More than one partition. Go through all of them
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   684
		if (partitionCount > 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   685
			{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   686
			for(i=partitionCount-1; i>0; i--)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   687
				{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   688
				const TPartitionEntry& curr = iPartitionInfo->iEntry[i];
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   689
				TPartitionEntry& prev = iPartitionInfo->iEntry[i-1];
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   690
				// Check if partitions overlap
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   691
				if(curr.iPartitionBaseAddr < (prev.iPartitionBaseAddr + prev.iPartitionLen))
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   692
					{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   693
					Kern::Printf("WB: Overlapping partitions");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   694
					// Adjust the partition length to not overlap the next partition
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   695
					prev.iPartitionLen = (curr.iPartitionBaseAddr - prev.iPartitionBaseAddr);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   696
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   697
					// Check that the base address contained valid information
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   698
					if(prev.iPartitionLen <= 0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   699
						{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   700
						Kern::Printf("WB: Invalid base address");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   701
						// Invalid MBR - assume the boot sector is in the first sector
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   702
						defaultPartitionNumber=(-1); 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   703
						partitionCount=0;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   704
						}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   705
					}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   706
				}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   707
			}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   708
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   709
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   710
mbr_done:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   711
	if (defaultPartitionNumber==(-1) && partitionCount==0)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   712
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   713
		Kern::Printf("WB:PartitionInfo no MBR");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   714
			{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   715
			// Assume it has no MBR, and the Boot Sector is in the 1st sector
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   716
			SetPartitionEntry(&iPartitionInfo->iEntry[0],0,I64LOW(CyAsSymbianStorageDriver::GetMediaSize()>>KDiskSectorShift));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   717
			iHiddenSectors=0;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   718
			}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   719
		partitionCount=1;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   720
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   721
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   722
	iPartitionInfo->iPartitionCount=partitionCount;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   723
	iPartitionInfo->iMediaSizeInBytes=TotalSizeInBytes();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   724
	#ifdef _MEDWB_DEBUG_1_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   725
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   726
	Kern::Printf("<Mmc:PartitionInfo (C:%d)",iPartitionInfo->iPartitionCount);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   727
	Kern::Printf("     Partition1 (B:%xH L:%xH)",I64LOW(iPartitionInfo->iEntry[0].iPartitionBaseAddr),I64LOW(iPartitionInfo->iEntry[0].iPartitionLen));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   728
	Kern::Printf("     Partition2 (B:%xH L:%xH)",I64LOW(iPartitionInfo->iEntry[1].iPartitionBaseAddr),I64LOW(iPartitionInfo->iEntry[1].iPartitionLen));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   729
	Kern::Printf("     Partition3 (B:%xH L:%xH)",I64LOW(iPartitionInfo->iEntry[2].iPartitionBaseAddr),I64LOW(iPartitionInfo->iEntry[2].iPartitionLen));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   730
	Kern::Printf("     Partition4 (B:%xH L:%xH)",I64LOW(iPartitionInfo->iEntry[3].iPartitionBaseAddr),I64LOW(iPartitionInfo->iEntry[3].iPartitionLen));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   731
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   732
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   733
	Kern::Printf("     iMediaSizeInBytes (%d)",iPartitionInfo->iMediaSizeInBytes);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   734
	Kern::Printf("     iHiddenSectors (%d)",iHiddenSectors);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   735
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   736
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   737
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   738
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   739
	TMBRPartitionEntry cPe;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   740
	if(GetDefaultPartitionInfo(cPe) == KErrNone)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   741
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   742
		pe = (TMBRPartitionEntry*)(&ptrReadBuf[0]);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   743
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   744
		Kern::Printf("-------------------------------------------");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   745
		Kern::Printf("-- Partition Entry Validation/Comparison --");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   746
		Kern::Printf("-------------------------------------------");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   747
		Kern::Printf("-- iX86BootIndicator [%02x:%02x] %c       -", pe->iX86BootIndicator, cPe.iX86BootIndicator, pe->iX86BootIndicator == cPe.iX86BootIndicator ? ' ' : 'X');
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   748
		Kern::Printf("--        iStartHead [%02x:%02x] %c       -", pe->iStartHead,        cPe.iStartHead,        pe->iStartHead        == cPe.iStartHead        ? ' ' : 'X');
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   749
		Kern::Printf("--      iStartSector [%02x:%02x] %c       -", pe->iStartSector,      cPe.iStartSector,      pe->iStartSector      == cPe.iStartSector      ? ' ' : 'X');
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   750
		Kern::Printf("--    iStartCylinder [%02x:%02x] %c       -", pe->iStartCylinder,    cPe.iStartCylinder,    pe->iStartCylinder    == cPe.iStartCylinder    ? ' ' : 'X');
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   751
		Kern::Printf("--    iPartitionType [%02x:%02x] %c       -", pe->iPartitionType,    cPe.iPartitionType,    pe->iPartitionType    == cPe.iPartitionType    ? ' ' : 'X');
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   752
		Kern::Printf("--          iEndHead [%02x:%02x] %c       -", pe->iEndHead,          cPe.iEndHead,          pe->iEndHead          == cPe.iEndHead          ? ' ' : 'X');
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   753
		Kern::Printf("--        iEndSector [%02x:%02x] %c       -", pe->iEndSector,        cPe.iEndSector,        pe->iEndSector        == cPe.iEndSector        ? ' ' : 'X');
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   754
		Kern::Printf("--      iEndCylinder [%02x:%02x] %c       -", pe->iEndCylinder,      cPe.iEndCylinder,      pe->iEndCylinder      == cPe.iEndCylinder      ? ' ' : 'X');
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   755
		Kern::Printf("--      iFirstSector [%08x:%08x] %c       -", pe->iFirstSector,      cPe.iFirstSector,      pe->iFirstSector      == cPe.iFirstSector      ? ' ' : 'X');
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   756
		Kern::Printf("--       iNumSectors [%08x:%08x] %c       -", pe->iNumSectors,       cPe.iNumSectors,       pe->iNumSectors       == cPe.iNumSectors       ? ' ' : 'X');
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   757
		Kern::Printf("-------------------------------------------");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   758
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   759
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   760
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   761
	return(KErrNone);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   762
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   763
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   764
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   765
TInt DMediaDriverWB::WritePartitionInfo()
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   766
/**
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   767
	Write the default partition table to freshly formatted media
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   768
	@return Standard Symbian OS Error Code
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   769
 */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   770
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   771
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   772
	Kern::Printf(">mmd:wpi");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   773
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   774
	TMBRPartitionEntry partitionEntry;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   775
	TInt err = GetDefaultPartitionInfo(partitionEntry);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   776
	if(err == KErrNone)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   777
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   778
		TUint8	*iPartitionBuf;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   779
		
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   780
		iPartitionBuf = new TUint8[KDiskSectorSize];
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   781
		
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   782
		#ifdef _MEDWB_DEBUG_2_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   783
		Kern::Printf("mmd:MBR/Partition Table");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   784
		Kern::Printf("    Boot ID          : %02xh", partitionEntry.iX86BootIndicator);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   785
		Kern::Printf("    Start Head       : %02xh", partitionEntry.iStartHead);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   786
		Kern::Printf("    Start Sector     : %02xh", partitionEntry.iStartSector);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   787
		Kern::Printf("    Start Cyclinder  : %02xh", partitionEntry.iStartCylinder);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   788
		Kern::Printf("    System ID        : %02xh", partitionEntry.iPartitionType);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   789
		Kern::Printf("    End Head         : %02xh", partitionEntry.iEndHead);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   790
		Kern::Printf("    End Sector       : %02xh", partitionEntry.iEndSector);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   791
		Kern::Printf("    End Cyclinder    : %02xh", partitionEntry.iEndCylinder);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   792
		Kern::Printf("    Relative Sector  : %08xh", partitionEntry.iFirstSector);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   793
		Kern::Printf("    Number of Sectors: %08xh", partitionEntry.iNumSectors);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   794
		#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   795
		//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   796
		// Clear all other partition entries and align the partition info into the minor buffer for writing...
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   797
		//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   798
		memclr(iPartitionBuf, KDiskSectorSize);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   799
		memcpy(&iPartitionBuf[KMBRFirstPartitionEntry], &partitionEntry, sizeof(TMBRPartitionEntry));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   800
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   801
		*(TUint16*)(&iPartitionBuf[KMBRSignatureOffset]) = 0xAA55;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   802
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   803
		err = CyAsSymbianStorageDriver::Write(0, 1, iPartitionBuf);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   804
		
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   805
		//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   806
		// Write the partition table and engage the read to validate and complete the mount process
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   807
		//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   808
		delete iPartitionBuf;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   809
		iMbrMissing = EFalse;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   810
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   811
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   812
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   813
	__KTRACE_OPT(KPBUSDRV, Kern::Printf("<mmd:wpi:%d", err));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   814
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   815
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   816
	return(err);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   817
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   818
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   819
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   820
TInt DMediaDriverWB::CreateDefaultPartition()
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   821
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   822
	TMBRPartitionEntry defPartition;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   823
	TInt r = GetDefaultPartitionInfo(defPartition);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   824
	if (r == KErrNone)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   825
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   826
		SetPartitionEntry(&iPartitionInfo->iEntry[0], defPartition.iFirstSector, defPartition.iNumSectors);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   827
		iHiddenSectors = defPartition.iFirstSector;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   828
		iPartitionInfo->iPartitionCount   = 1;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   829
		iPartitionInfo->iMediaSizeInBytes = TotalSizeInBytes();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   830
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   831
	return r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   832
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   833
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   834
TInt DMediaDriverWB::GetDefaultPartitionInfo(TMBRPartitionEntry& aPartitionEntry)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   835
/**
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   836
	Calculates the default patition information for an specific card.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   837
	@param aPartitionEntry The TMBRPartitionEntry to be filled in with the format parameters
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   838
	@return Standard Symbian OS Error Code
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   839
 */
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   840
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   841
	memclr(&aPartitionEntry, sizeof(TMBRPartitionEntry));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   842
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   843
	const TUint32 KTotalSectors = I64LOW(CyAsSymbianStorageDriver::GetMediaSize() >> KDiskSectorShift);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   844
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   845
	aPartitionEntry.iFirstSector = (CyAsSymbianStorageDriver::GetEraseBlockSize()>> KDiskSectorShift);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   846
	aPartitionEntry.iNumSectors  = KTotalSectors - aPartitionEntry.iFirstSector;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   847
	aPartitionEntry.iX86BootIndicator = 0x00;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   848
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   849
	if(aPartitionEntry.iNumSectors < 32680)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   850
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   851
		aPartitionEntry.iPartitionType = KPartitionTypeFAT12;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   852
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   853
	else if(aPartitionEntry.iNumSectors < 65536)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   854
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   855
		aPartitionEntry.iPartitionType = KPartitionTypeFAT16small;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   856
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   857
	else if (aPartitionEntry.iNumSectors < 1048576)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   858
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   859
		aPartitionEntry.iPartitionType = KPartitionTypeFAT16;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   860
 		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   861
	else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   862
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   863
		aPartitionEntry.iPartitionType = KPartitionTypeWin95FAT32;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   864
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   865
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   866
	return(KErrNone);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   867
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   868
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   869
void DMediaDriverWB::SetPartitionEntry(TPartitionEntry* aEntry, TUint aFirstSector, TUint aNumSectors)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   870
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   871
// auxiliary static function to record partition information in TPartitionEntry object
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   872
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   873
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   874
	aEntry->iPartitionBaseAddr=aFirstSector;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   875
	aEntry->iPartitionBaseAddr<<=KDiskSectorShift;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   876
	aEntry->iPartitionLen=aNumSectors;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   877
	aEntry->iPartitionLen<<=KDiskSectorShift;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   878
	aEntry->iPartitionType=KPartitionTypeFAT12;	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   879
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   880
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   881
// ---- device status, callback DFC ----
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   882
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   883
TInt DMediaDriverWB::CheckDevice(int aReqType)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   884
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   885
// Check the device before initiating a command
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   886
//
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   887
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   888
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   889
	__KTRACE_OPT(KPBUSDRV, Kern::Printf(">wb:cd:%d",aReqType));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   890
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   891
	TInt r=KErrNone;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   892
#if 0
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   893
	if (!iCard->IsReady())
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   894
		r=KErrNotReady;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   895
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   896
	// The card must be locked if attempting to unlock during RPI, and
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   897
	// unlocked at all other times.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   898
	else if (aReqType!=EMReqTypeUnlockPswd && iCard->IsLocked())
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   899
		r=KErrLocked;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   900
	// Don't perform Password setting for WriteProtected cards, 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   901
	// unable to recover (ForcedErase) if password lost.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   902
	else if (aReqType==EMReqTypeChangePswd)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   903
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   904
		if (iCard->MediaType()==EMultiMediaROM)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   905
			{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   906
			r=KErrAccessDenied;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   907
			}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   908
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   909
	else if (iMbrMissing && aReqType==EMReqTypeNormalRd)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   910
		r=KErrCorrupt;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   911
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   912
	// Don't perform write operations when the mechanical write protect switch is set
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   913
	else if (aReqType==EMReqTypeNormalWr && iCard->IsWriteProtected())
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   914
		r=KErrAccessDenied;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   915
	// Don't perform write/format operations on MMC ROM cards
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   916
	else if (iMediaType==EMultiMediaROM && aReqType == EMReqTypeNormalWr)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   917
		r=KErrAccessDenied;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   918
#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   919
	__KTRACE_OPT(KPBUSDRV, Kern::Printf("<wb:cd:%d", r));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   920
	return(r);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   921
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   922
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   923
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   924
// ---- request management ----
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   925
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   926
TInt DMediaDriverWB::Caps(TLocDrv& aDrive, TLocalDriveCapsV6& aInfo)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   927
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   928
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   929
	Kern::Printf(">WB::Caps ");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   930
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   931
	// Fill buffer with current media caps.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   932
	aInfo.iType = EMediaHardDisk;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   933
	aInfo.iBattery = EBatNotSupported;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   934
	aInfo.iDriveAtt = KDriveAttLocal;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   935
	aInfo.iMediaAtt	= KMediaAttFormattable;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   936
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   937
	//if(CyAsSymbianStorageDriver::GetIsLocked())
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   938
	//	aInfo.iMediaAtt |= KMediaAttLockable;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   939
	//if (iCard->HasPassword())
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   940
		//aInfo.iMediaAtt |= KMediaAttHasPassword;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   941
		
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   942
	if ( !CyAsSymbianStorageDriver::GetIsWriteable())
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   943
		aInfo.iMediaAtt |= KMediaAttWriteProtected;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   944
	if (CyAsSymbianStorageDriver::GetIsLocked())
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   945
		aInfo.iMediaAtt |= KMediaAttLocked;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   946
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   947
	aInfo.iFileSystemId = KDriveFileSysFAT;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   948
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   949
	// Format is performed in multiples of the erase sector (or multiple block) size
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   950
	aInfo.iMaxBytesPerFormat =  CyAsSymbianStorageDriver::GetBlockSize();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   951
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   952
    // Set serial number to CID
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   953
    aInfo.iSerialNumLength = 16;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   954
    for (TUint i=0; i<16; i++)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   955
        aInfo.iSerialNum[i] = 0;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   956
    
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   957
	// Get block size & erase block size to allow the file system to align first usable cluster correctly
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   958
	aInfo.iBlockSize = CyAsSymbianStorageDriver::GetBlockSize();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   959
	aInfo.iEraseBlockSize = CyAsSymbianStorageDriver::GetEraseBlockSize();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   960
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   961
	if ( CyAsSymbianStorageDriver::GetIsRemovable())
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   962
		aInfo.iDriveAtt|= KDriveAttRemovable;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   963
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   964
	// Must return KErrCompletion to indicate that this 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   965
	// is a synchronous version of the function
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   966
	return KErrNone;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   967
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   968
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   969
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   970
void DMediaDriverWB::NotifyPowerDown()
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   971
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   972
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   973
	Kern::Printf(">Mmc:NotifyPowerDown");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   974
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   975
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   976
	EndInCritical();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   977
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   978
	//CompleteRequest(KErrNotReady);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   979
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   980
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   981
void DMediaDriverWB::NotifyEmergencyPowerDown()
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   982
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   983
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   984
	Kern::Printf(">Ata:NotifyEmergencyPowerDown");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   985
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   986
	//TInt r=KErrNotReady;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   987
	//if (iCritical)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   988
	//	r=KErrAbort;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   989
	EndInCritical();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   990
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   991
	// need to cancel the session as the stack doesn't take too kindly to having the same session engaged more than once.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   992
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   993
	//CompleteRequest(r);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   994
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   995
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   996
TInt DMediaDriverWB::Request(TLocDrvRequest& aRequest)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   997
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   998
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
   999
	Kern::Printf("MmcMd:Req %08x id %d",&aRequest,aRequest.Id());
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1000
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1001
	TInt r=KErrNotSupported;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1002
	TInt id=aRequest.Id();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1003
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1004
	NKern::ThreadEnterCS();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1005
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1006
	TUint partitionType = aRequest.Drive()->iPartitionType;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1007
	TBool readOnly = (partitionType == KPartitionTypeRofs || partitionType == KPartitionTypeROM);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1008
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1009
	switch (id)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1010
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1011
		case DLocalDrive::ECaps:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1012
			{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1013
				TLocalDriveCapsV6& c = *(TLocalDriveCapsV6*)aRequest.RemoteDes();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1014
				TLocDrv& drive = *aRequest.Drive();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1015
				r = Caps(drive, c);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1016
				c.iSize = drive.iPartitionLen;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1017
				c.iPartitionType = drive.iPartitionType;	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1018
				c.iHiddenSectors = (TUint) (drive.iPartitionBaseAddr >> KDiskSectorShift);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1019
				#ifdef _MEDWB_DEBUG_2_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1020
				Kern::Printf("caps : c.iSize = %d ", c.iSize);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1021
				Kern::Printf("caps : c.iPartitionType = %d ", c.iPartitionType);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1022
				Kern::Printf("caps : c.iHiddenSectors = %d ", c.iHiddenSectors);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1023
				#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1024
			}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1025
			break;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1026
		case DLocalDrive::EQueryDevice:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1027
			Kern::Printf(">WB::EQueryDevice ");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1028
			r = KErrNotSupported;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1029
			break;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1030
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1031
		case DLocalDrive::ERead:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1032
			r=DoRead(aRequest);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1033
			break;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1034
		case DLocalDrive::EWrite:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1035
			if (readOnly)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1036
				return KErrNotSupported;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1037
			r=DoWrite(aRequest);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1038
			break;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1039
		case DLocalDrive::EFormat:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1040
			if (readOnly)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1041
				return KErrNotSupported;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1042
			r=DoFormat(aRequest);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1043
			break;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1044
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1045
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1046
		case DLocalDrive::EPasswordUnlock:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1047
		case DLocalDrive::EPasswordLock:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1048
		case DLocalDrive::EPasswordClear:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1049
		case DLocalDrive::EPasswordErase:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1050
		case DLocalDrive::EWritePasswordStore:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1051
				Kern::Printf(">WB::EPassword ");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1052
		break;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1053
		case DLocalDrive::EEnlarge:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1054
		case DLocalDrive::EReduce:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1055
			Kern::Printf(">WB::EReduce ");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1056
		default:
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1057
			Kern::Printf(">WB::default ");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1058
			r=KErrNotSupported;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1059
			break;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1060
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1061
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1062
	NKern::ThreadLeaveCS();
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1063
	#ifdef _MEDWB_DEBUG_3_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1064
	Kern::Printf("MmcMd:Req %08x cmp %d",&aRequest,r);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1065
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1066
	return r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1067
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1068
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1069
void DMediaDriverWB::Disconnect(DLocalDrive* aLocalDrive, TThreadMessage* aMsg)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1070
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1071
	// Complete using the default implementation
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1072
	DMediaDriver::Disconnect(aLocalDrive, aMsg);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1073
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1074
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1075
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1076
DECLARE_EXTENSION_PDD()
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1077
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1078
	// NB if the media driver has been defined as a kernel extension in the .OBY/.IBY file 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1079
	// i.e the "extension" keyword has been used rather than "device", then an instance of 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1080
	// DPhysicalDeviceMediaMmcFlash will already have been created by InitExtension(). In this 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1081
	// case the kernel will see that an object of the same name already exists and delete the 
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1082
	// new one.
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1083
	return new DPhysicalDeviceMediaWB;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1084
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1085
#ifdef REGIST_MEDIA_USE_MMC
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1086
DECLARE_STANDARD_EXTENSION()
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1087
	{	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1088
	Kern::Printf("Creating WestBridge PDD");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1089
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1090
	DPhysicalDeviceMediaWB* device = new DPhysicalDeviceMediaWB;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1091
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1092
	TInt r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1093
	if (device==NULL)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1094
		r=KErrNoMemory;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1095
	else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1096
		r=Kern::InstallPhysicalDevice(device);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1097
	Kern::Printf("Installing WestBridge PDD in kernel returned %d",r);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1098
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1099
	if( CyAsSymbianStorageDriver::Open() )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1100
		Kern::Printf("**CyAsSymbianStorageDriver::Open() - Success");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1101
	else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1102
		Kern::Printf("**CyAsSymbianStorageDriver::Open() - Fail");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1103
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1104
	Kern::Printf("WestBridge extension entry point drive returns %d",r);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1105
	return r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1106
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1107
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1108
#else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1109
static const TInt WBDriveNumbers[1]={1};	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1110
_LIT(KWBDriveName,"WestBridge");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1111
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1112
DECLARE_STANDARD_EXTENSION()
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1113
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1114
	__KTRACE_OPT(KBOOT,Kern::Printf("Registering WB drive"));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1115
	#ifdef _MEDWB_DEBUG_2_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1116
	Kern::Printf("Registering WB drive");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1117
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1118
	TInt r=KErrNoMemory;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1119
	DPrimaryMediaBase* pM=new DPrimaryMediaBase;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1120
	if (pM)
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1121
		{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1122
		r=LocDrv::RegisterMediaDevice(MEDIA_DEVICE_MMC,1,&WBDriveNumbers[0],pM,1,KWBDriveName);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1123
		}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1124
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1125
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1126
	if( CyAsSymbianStorageDriver::Open() )
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1127
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1128
		#ifdef _MEDWB_DEBUG_1_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1129
		Kern::Printf("**CyAsSymbianStorageDriver::Open() - Success");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1130
		#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1131
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1132
	else
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1133
	{
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1134
		#ifdef _MEDWB_DEBUG_1_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1135
		Kern::Printf("**CyAsSymbianStorageDriver::Open() - Fail");
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1136
		#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1137
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1138
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1139
	__KTRACE_OPT(KBOOT,Kern::Printf("Registering WB drive - return %d",r));
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1140
	#ifdef _MEDWB_DEBUG_2_
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1141
	Kern::Printf("Registering WB drive - return %d",r);
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1142
	#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1143
	
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1144
	return r;
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1145
	}
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1146
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1147
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1148
#endif
117faf51deac Bug 1996 - Contribution for West Bridge Astoria Symbian Storage Driver
arunabha
parents:
diff changeset
  1149