kernel/eka/include/drivers/locmedia.h
branchRCL_3
changeset 42 a179b74831c9
parent 28 5b5d147c7838
--- a/kernel/eka/include/drivers/locmedia.h	Thu Jul 15 20:11:42 2010 +0300
+++ b/kernel/eka/include/drivers/locmedia.h	Thu Aug 19 11:14:22 2010 +0300
@@ -166,6 +166,46 @@
 class TLocDrvRequest;
 class DPrimaryMediaBase;
 
+/* 
+TCallBackLink
+
+@internalComponent
+
+Internal class which allows a list of callbacks to be linked together.
+*/
+
+NONSHARABLE_CLASS(TCallBackLink)
+	{
+public:
+	enum TObjectType
+		{
+		EDLocalDriveObject, // object containing this TCallBackLink is a DLocalDrive
+		ETLocDrvObject,		// object containing this TCallBackLink is a TLocDrv
+		};
+
+public:
+	TCallBackLink();
+	TCallBackLink(TInt (*aFunction)(TAny* aPtr, TInt aParam),TAny* aPtr, TObjectType aObjectType);
+	TInt CallBack(TInt aParam) const;
+public:
+	/**
+	A pointer to the callback function.
+	*/
+	TInt (*iFunction)(TAny* aPtr, TInt aParam);
+	
+	
+	/**
+	A pointer that is passed to the callback function when
+	the function is called.
+	*/
+	TAny* iPtr;
+
+	TObjectType iObjectType;
+
+	SDblQueLink iLink;
+	};
+
+
 /**
 @publishedPartner
 @released
@@ -275,19 +315,22 @@
 		Query device 
 		*/
 		EQueryDevice=32,
-
 		};
 public:
 	DLocalDrive(); 
 	~DLocalDrive();
-public:
+
 	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); /**< @internalComponent */
 	virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);                      /**< @internalComponent */
-public:
-	void NotifyChange(DPrimaryMediaBase& aPrimaryMedia, TBool aMediaChange);
-public:
+
+	void NotifyChange();
+
 	inline void Deque();                 /**< @internalComponent */
 
+	static TInt MediaChangeCallback(TAny* aLocalDrive, TInt aNotifyType);	/**< @internalComponent */
+
+	IMPORT_C static TInt Caps(TInt aDriveNumber, TDes8& aCaps);
+
 private:
 #ifdef __DEMAND_PAGING__
 	TInt LockMountInfo(DPrimaryMediaBase& aPrimaryMedia, TLocDrvRequest& aReq);
@@ -296,10 +339,10 @@
 	TInt ReadPasswordData(TLocDrvRequest& aReq, TLocalDrivePasswordData& aPswData, TMediaPassword& aOldPasswd, TMediaPassword& aNewPasswd);
 
 public:
-	TLocDrv* iDrive;							/**< @internalComponent */
-	SDblQueLink iLink;							/**< @internalComponent */
+	TLocDrv* iDrive;									/**< @internalComponent */
+	TCallBackLink iMediaChangeObserver;					/**< @internalComponent */
 	TClientDataRequest<TBool>* iNotifyChangeRequest;	/**< @internalComponent */
-	TLocalDriveCleanup iCleanup;				 /**< @internalComponent */
+	TLocalDriveCleanup iCleanup;						/**< @internalComponent */
 	};
 
 /**
@@ -341,7 +384,7 @@
 		ECodePaging=0x20,			// a code paging request
 		EDataPaging=0x40,			// a data paging request
 		ETClientBuffer=0x80,		// RemoteDes() points to a TClientBuffer
-		EKernelBuffer=0x100,		// RemoteDes() points to a kernel-side buffer
+		EKernelBuffer=0x100,		// RemoteDes() points to a kernel-side buffer : set for all paging requests and media extension requests
 		EPhysAddrOnly=0x200,        // No virtual address is available. Data Paging requests Only. 
 		};
 public:
@@ -494,7 +537,7 @@
 @internalComponent
 */
 inline void DLocalDrive::Deque()
-	{ iLink.Deque(); }
+	{ iMediaChangeObserver.iLink.Deque(); }
 
 
 
@@ -648,6 +691,7 @@
 	inline TInt Connect(DLocalDrive* aLocalDrive);
 	inline void Disconnect(DLocalDrive* aLocalDrive);
 	inline TInt Request(TLocDrvRequest& aRequest);
+	static TInt MediaChangeCallback(TAny* aLocDrv, TInt aNotifyType);
 public:
 	TInt iDriveNumber;
 	DMedia* iMedia;
@@ -662,6 +706,14 @@
 	TUint8 iSpare3;
 #endif
 	DDmaHelper* iDmaHelper;
+
+	// Media extension stuff:
+
+	/** ptr to the next TLocDrv object in the chain. Null if not a media extension */
+	TLocDrv* iNextDrive;
+
+	/** media change callback - called when the next media in the chain has a media change */
+	TCallBackLink iMediaChangeObserver;
 	};
 
 /**
@@ -828,7 +880,7 @@
 
 public:
 	IMPORT_C DPrimaryMediaBase();
-public:
+
 	// provided by implementation
 	IMPORT_C virtual TInt Create(TMediaDevice aDevice, TInt aMediaId, TInt aLastMediaId);
 	IMPORT_C virtual TInt Connect(DLocalDrive* aLocalDrive);
@@ -842,7 +894,7 @@
 	IMPORT_C virtual void DeltaCurrentConsumption(TInt aCurrent);
 	IMPORT_C virtual void DefaultDriveCaps(TLocalDriveCapsV2& aCaps);
 	IMPORT_C virtual TBool IsRemovableDevice(TInt& aSocketNum);
-public:
+
 	// used by implementation
 	IMPORT_C void NotifyMediaChange();
 	IMPORT_C void NotifyPowerDown();
@@ -850,7 +902,7 @@
 	IMPORT_C void NotifyPsuFault(TInt anError);
 	IMPORT_C void NotifyMediaPresent();
 	IMPORT_C void PowerUpComplete(TInt anError);
-public:
+
 	IMPORT_C virtual void HandleMsg(TLocDrvRequest& aRequest);
 	IMPORT_C virtual TInt DoRequest(TLocDrvRequest& aRequest);
 	TInt OpenMediaDriver();
@@ -863,7 +915,10 @@
 	void CompleteRequest(TLocDrvRequest& aMsg, TInt aResult);
 	IMPORT_C void RunDeferred();
 	void SetClosed(TInt anError);
-	void NotifyClients(TBool aMediaChange,TLocDrv* aLocDrv=NULL);
+	
+	enum TNotifyType {EMediaChange, EMediaPresent};
+	void NotifyClients(TNotifyType aNotifyType, TLocDrv* aLocDrv=NULL);
+
 	TInt InCritical();
 	void EndInCritical();
 	void UpdatePartitionInfo();
@@ -883,6 +938,13 @@
 	void RequestCountDec();
 #endif
 
+	// called by LocDrv::RegisterMediaDevice() for media extensions
+	TInt Connect(TLocDrv* aLocDrv);
+
+	void MediaChange();
+	TInt HandleMediaNotPresent(TLocDrvRequest& aReq);
+
+
 public:
 	TInt iLastMediaId;					/**< @internalComponent */
 	TMessageQue iMsgQ;
@@ -1155,6 +1217,7 @@
 	virtual void NotifyEmergencyPowerDown()=0;
 public:
 	IMPORT_C void SetTotalSizeInBytes(Int64 aTotalSizeInBytes, TLocDrv* aLocDrv=NULL);
+	IMPORT_C void SetTotalSizeInBytes(TLocalDriveCapsV4& aCaps);
 	IMPORT_C Int64 TotalSizeInBytes();
 	IMPORT_C void SetCurrentConsumption(TInt aValue);
 	IMPORT_C TInt InCritical();
@@ -1172,6 +1235,74 @@
 	};
 
 
+/**
+@internalTechnology
+@prototype
+
+An abstract base class for media driver 'extensions' within the local media subsystem
+*/
+class DMediaDriverExtension : public DMediaDriver
+	{
+public:
+	IMPORT_C DMediaDriverExtension(TInt aMediaId);
+	IMPORT_C virtual ~DMediaDriverExtension();
+	IMPORT_C virtual void Close();
+
+	virtual TInt Request(TLocDrvRequest& aRequest) = 0;
+	
+	virtual TInt PartitionInfo(TPartitionInfo &anInfo) = 0;
+
+	IMPORT_C virtual void NotifyPowerDown();
+
+	IMPORT_C virtual void NotifyEmergencyPowerDown();
+
+	/**
+	Retrieve partition info from all the attached drives
+	*/
+	IMPORT_C TInt DoDrivePartitionInfo(TPartitionInfo &anInfo);
+	/**
+	Forward a request to the next attached drive
+	*/
+	IMPORT_C TInt ForwardRequest(TLocDrvRequest& aRequest);
+
+	/**
+	Read from the specified attached drive
+	*/
+	IMPORT_C TInt Read(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen);
+
+	/**
+	Write to the specified attached drive
+	*/
+	IMPORT_C TInt Write(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen);
+
+	/**
+	Get the Caps from the specified attached drive
+	*/
+	IMPORT_C TInt Caps(TInt aDriveNumber, TDes8& aCaps);
+
+	/**
+	Return whether the media is busy i.e. if it has any pending requests or DFCs
+	*/
+	IMPORT_C TBool MediaBusy(TInt aDriveNumber);
+
+#ifdef __DEMAND_PAGING__
+	/**
+	Send a paging read request to the specified attached drive
+	*/
+	IMPORT_C TInt ReadPaged(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen);
+
+	/**
+	Send a paging write request to the specified attached drive
+	*/
+	IMPORT_C TInt WritePaged(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen);
+#endif
+
+private:
+	TInt SendRequest(TInt aReqId, TBool aPagingRequest, TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen);
+
+	};
+
+
 
 
 /**