kernel/eka/include/drivers/locmedia.h
branchRCL_3
changeset 42 a179b74831c9
parent 28 5b5d147c7838
equal deleted inserted replaced
41:0ffb4e86fcc9 42:a179b74831c9
   164 
   164 
   165 
   165 
   166 class TLocDrvRequest;
   166 class TLocDrvRequest;
   167 class DPrimaryMediaBase;
   167 class DPrimaryMediaBase;
   168 
   168 
       
   169 /* 
       
   170 TCallBackLink
       
   171 
       
   172 @internalComponent
       
   173 
       
   174 Internal class which allows a list of callbacks to be linked together.
       
   175 */
       
   176 
       
   177 NONSHARABLE_CLASS(TCallBackLink)
       
   178 	{
       
   179 public:
       
   180 	enum TObjectType
       
   181 		{
       
   182 		EDLocalDriveObject, // object containing this TCallBackLink is a DLocalDrive
       
   183 		ETLocDrvObject,		// object containing this TCallBackLink is a TLocDrv
       
   184 		};
       
   185 
       
   186 public:
       
   187 	TCallBackLink();
       
   188 	TCallBackLink(TInt (*aFunction)(TAny* aPtr, TInt aParam),TAny* aPtr, TObjectType aObjectType);
       
   189 	TInt CallBack(TInt aParam) const;
       
   190 public:
       
   191 	/**
       
   192 	A pointer to the callback function.
       
   193 	*/
       
   194 	TInt (*iFunction)(TAny* aPtr, TInt aParam);
       
   195 	
       
   196 	
       
   197 	/**
       
   198 	A pointer that is passed to the callback function when
       
   199 	the function is called.
       
   200 	*/
       
   201 	TAny* iPtr;
       
   202 
       
   203 	TObjectType iObjectType;
       
   204 
       
   205 	SDblQueLink iLink;
       
   206 	};
       
   207 
       
   208 
   169 /**
   209 /**
   170 @publishedPartner
   210 @publishedPartner
   171 @released
   211 @released
   172 
   212 
   173 This class is strictly internal to Symbian; the only part of this class that
   213 This class is strictly internal to Symbian; the only part of this class that
   273 
   313 
   274 		/**
   314 		/**
   275 		Query device 
   315 		Query device 
   276 		*/
   316 		*/
   277 		EQueryDevice=32,
   317 		EQueryDevice=32,
   278 
       
   279 		};
   318 		};
   280 public:
   319 public:
   281 	DLocalDrive(); 
   320 	DLocalDrive(); 
   282 	~DLocalDrive();
   321 	~DLocalDrive();
   283 public:
   322 
   284 	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); /**< @internalComponent */
   323 	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); /**< @internalComponent */
   285 	virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);                      /**< @internalComponent */
   324 	virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);                      /**< @internalComponent */
   286 public:
   325 
   287 	void NotifyChange(DPrimaryMediaBase& aPrimaryMedia, TBool aMediaChange);
   326 	void NotifyChange();
   288 public:
   327 
   289 	inline void Deque();                 /**< @internalComponent */
   328 	inline void Deque();                 /**< @internalComponent */
       
   329 
       
   330 	static TInt MediaChangeCallback(TAny* aLocalDrive, TInt aNotifyType);	/**< @internalComponent */
       
   331 
       
   332 	IMPORT_C static TInt Caps(TInt aDriveNumber, TDes8& aCaps);
   290 
   333 
   291 private:
   334 private:
   292 #ifdef __DEMAND_PAGING__
   335 #ifdef __DEMAND_PAGING__
   293 	TInt LockMountInfo(DPrimaryMediaBase& aPrimaryMedia, TLocDrvRequest& aReq);
   336 	TInt LockMountInfo(DPrimaryMediaBase& aPrimaryMedia, TLocDrvRequest& aReq);
   294 	void UnlockMountInfo(DPrimaryMediaBase& aPrimaryMedia);
   337 	void UnlockMountInfo(DPrimaryMediaBase& aPrimaryMedia);
   295 #endif
   338 #endif
   296 	TInt ReadPasswordData(TLocDrvRequest& aReq, TLocalDrivePasswordData& aPswData, TMediaPassword& aOldPasswd, TMediaPassword& aNewPasswd);
   339 	TInt ReadPasswordData(TLocDrvRequest& aReq, TLocalDrivePasswordData& aPswData, TMediaPassword& aOldPasswd, TMediaPassword& aNewPasswd);
   297 
   340 
   298 public:
   341 public:
   299 	TLocDrv* iDrive;							/**< @internalComponent */
   342 	TLocDrv* iDrive;									/**< @internalComponent */
   300 	SDblQueLink iLink;							/**< @internalComponent */
   343 	TCallBackLink iMediaChangeObserver;					/**< @internalComponent */
   301 	TClientDataRequest<TBool>* iNotifyChangeRequest;	/**< @internalComponent */
   344 	TClientDataRequest<TBool>* iNotifyChangeRequest;	/**< @internalComponent */
   302 	TLocalDriveCleanup iCleanup;				 /**< @internalComponent */
   345 	TLocalDriveCleanup iCleanup;						/**< @internalComponent */
   303 	};
   346 	};
   304 
   347 
   305 /**
   348 /**
   306 @internalComponent
   349 @internalComponent
   307 */
   350 */
   339 		EPaging=0x08,				// a paging request
   382 		EPaging=0x08,				// a paging request
   340 		EBackgroundPaging=0x10,		// a background paging request. @see DMediaPagingDevice::Write()
   383 		EBackgroundPaging=0x10,		// a background paging request. @see DMediaPagingDevice::Write()
   341 		ECodePaging=0x20,			// a code paging request
   384 		ECodePaging=0x20,			// a code paging request
   342 		EDataPaging=0x40,			// a data paging request
   385 		EDataPaging=0x40,			// a data paging request
   343 		ETClientBuffer=0x80,		// RemoteDes() points to a TClientBuffer
   386 		ETClientBuffer=0x80,		// RemoteDes() points to a TClientBuffer
   344 		EKernelBuffer=0x100,		// RemoteDes() points to a kernel-side buffer
   387 		EKernelBuffer=0x100,		// RemoteDes() points to a kernel-side buffer : set for all paging requests and media extension requests
   345 		EPhysAddrOnly=0x200,        // No virtual address is available. Data Paging requests Only. 
   388 		EPhysAddrOnly=0x200,        // No virtual address is available. Data Paging requests Only. 
   346 		};
   389 		};
   347 public:
   390 public:
   348     
   391     
   349     /**
   392     /**
   492 
   535 
   493 /**
   536 /**
   494 @internalComponent
   537 @internalComponent
   495 */
   538 */
   496 inline void DLocalDrive::Deque()
   539 inline void DLocalDrive::Deque()
   497 	{ iLink.Deque(); }
   540 	{ iMediaChangeObserver.iLink.Deque(); }
   498 
   541 
   499 
   542 
   500 
   543 
   501 
   544 
   502 /**
   545 /**
   646 	TLocDrv(TInt aDriveNumber);
   689 	TLocDrv(TInt aDriveNumber);
   647 public:
   690 public:
   648 	inline TInt Connect(DLocalDrive* aLocalDrive);
   691 	inline TInt Connect(DLocalDrive* aLocalDrive);
   649 	inline void Disconnect(DLocalDrive* aLocalDrive);
   692 	inline void Disconnect(DLocalDrive* aLocalDrive);
   650 	inline TInt Request(TLocDrvRequest& aRequest);
   693 	inline TInt Request(TLocDrvRequest& aRequest);
       
   694 	static TInt MediaChangeCallback(TAny* aLocDrv, TInt aNotifyType);
   651 public:
   695 public:
   652 	TInt iDriveNumber;
   696 	TInt iDriveNumber;
   653 	DMedia* iMedia;
   697 	DMedia* iMedia;
   654 	DPrimaryMediaBase* iPrimaryMedia;
   698 	DPrimaryMediaBase* iPrimaryMedia;
   655 	TInt iPartitionNumber;
   699 	TInt iPartitionNumber;
   660 	TUint8 iSpare1;
   704 	TUint8 iSpare1;
   661 	TUint8 iSpare2;
   705 	TUint8 iSpare2;
   662 	TUint8 iSpare3;
   706 	TUint8 iSpare3;
   663 #endif
   707 #endif
   664 	DDmaHelper* iDmaHelper;
   708 	DDmaHelper* iDmaHelper;
       
   709 
       
   710 	// Media extension stuff:
       
   711 
       
   712 	/** ptr to the next TLocDrv object in the chain. Null if not a media extension */
       
   713 	TLocDrv* iNextDrive;
       
   714 
       
   715 	/** media change callback - called when the next media in the chain has a media change */
       
   716 	TCallBackLink iMediaChangeObserver;
   665 	};
   717 	};
   666 
   718 
   667 /**
   719 /**
   668 @publishedPartner
   720 @publishedPartner
   669 @released
   721 @released
   826 		KForceMediaChangeReOpenMediaDriver = 0x80000000
   878 		KForceMediaChangeReOpenMediaDriver = 0x80000000
   827 		};
   879 		};
   828 
   880 
   829 public:
   881 public:
   830 	IMPORT_C DPrimaryMediaBase();
   882 	IMPORT_C DPrimaryMediaBase();
   831 public:
   883 
   832 	// provided by implementation
   884 	// provided by implementation
   833 	IMPORT_C virtual TInt Create(TMediaDevice aDevice, TInt aMediaId, TInt aLastMediaId);
   885 	IMPORT_C virtual TInt Create(TMediaDevice aDevice, TInt aMediaId, TInt aLastMediaId);
   834 	IMPORT_C virtual TInt Connect(DLocalDrive* aLocalDrive);
   886 	IMPORT_C virtual TInt Connect(DLocalDrive* aLocalDrive);
   835 	IMPORT_C virtual void Disconnect(DLocalDrive* aLocalDrive);
   887 	IMPORT_C virtual void Disconnect(DLocalDrive* aLocalDrive);
   836 	IMPORT_C virtual TInt Request(TLocDrvRequest& aRequest);
   888 	IMPORT_C virtual TInt Request(TLocDrvRequest& aRequest);
   840 	IMPORT_C virtual TInt DoInCritical();
   892 	IMPORT_C virtual TInt DoInCritical();
   841 	IMPORT_C virtual void DoEndInCritical();
   893 	IMPORT_C virtual void DoEndInCritical();
   842 	IMPORT_C virtual void DeltaCurrentConsumption(TInt aCurrent);
   894 	IMPORT_C virtual void DeltaCurrentConsumption(TInt aCurrent);
   843 	IMPORT_C virtual void DefaultDriveCaps(TLocalDriveCapsV2& aCaps);
   895 	IMPORT_C virtual void DefaultDriveCaps(TLocalDriveCapsV2& aCaps);
   844 	IMPORT_C virtual TBool IsRemovableDevice(TInt& aSocketNum);
   896 	IMPORT_C virtual TBool IsRemovableDevice(TInt& aSocketNum);
   845 public:
   897 
   846 	// used by implementation
   898 	// used by implementation
   847 	IMPORT_C void NotifyMediaChange();
   899 	IMPORT_C void NotifyMediaChange();
   848 	IMPORT_C void NotifyPowerDown();
   900 	IMPORT_C void NotifyPowerDown();
   849 	IMPORT_C void NotifyEmergencyPowerDown();
   901 	IMPORT_C void NotifyEmergencyPowerDown();
   850 	IMPORT_C void NotifyPsuFault(TInt anError);
   902 	IMPORT_C void NotifyPsuFault(TInt anError);
   851 	IMPORT_C void NotifyMediaPresent();
   903 	IMPORT_C void NotifyMediaPresent();
   852 	IMPORT_C void PowerUpComplete(TInt anError);
   904 	IMPORT_C void PowerUpComplete(TInt anError);
   853 public:
   905 
   854 	IMPORT_C virtual void HandleMsg(TLocDrvRequest& aRequest);
   906 	IMPORT_C virtual void HandleMsg(TLocDrvRequest& aRequest);
   855 	IMPORT_C virtual TInt DoRequest(TLocDrvRequest& aRequest);
   907 	IMPORT_C virtual TInt DoRequest(TLocDrvRequest& aRequest);
   856 	TInt OpenMediaDriver();
   908 	TInt OpenMediaDriver();
   857 	void CloseMediaDrivers(DMedia* aMedia = NULL);
   909 	void CloseMediaDrivers(DMedia* aMedia = NULL);
   858 	void StartOpenMediaDrivers();
   910 	void StartOpenMediaDrivers();
   861 	void DoPartitionInfoComplete(TInt anError);
   913 	void DoPartitionInfoComplete(TInt anError);
   862 	void CompleteCurrent(TInt anError);
   914 	void CompleteCurrent(TInt anError);
   863 	void CompleteRequest(TLocDrvRequest& aMsg, TInt aResult);
   915 	void CompleteRequest(TLocDrvRequest& aMsg, TInt aResult);
   864 	IMPORT_C void RunDeferred();
   916 	IMPORT_C void RunDeferred();
   865 	void SetClosed(TInt anError);
   917 	void SetClosed(TInt anError);
   866 	void NotifyClients(TBool aMediaChange,TLocDrv* aLocDrv=NULL);
   918 	
       
   919 	enum TNotifyType {EMediaChange, EMediaPresent};
       
   920 	void NotifyClients(TNotifyType aNotifyType, TLocDrv* aLocDrv=NULL);
       
   921 
   867 	TInt InCritical();
   922 	TInt InCritical();
   868 	void EndInCritical();
   923 	void EndInCritical();
   869 	void UpdatePartitionInfo();
   924 	void UpdatePartitionInfo();
   870 	void MediaReadyHandleRequest();
   925 	void MediaReadyHandleRequest();
   871 	TInt SendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress = NULL);
   926 	TInt SendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress = NULL);
   880 
   935 
   881 #ifdef __DEMAND_PAGING__
   936 #ifdef __DEMAND_PAGING__
   882 	void RequestCountInc();
   937 	void RequestCountInc();
   883 	void RequestCountDec();
   938 	void RequestCountDec();
   884 #endif
   939 #endif
       
   940 
       
   941 	// called by LocDrv::RegisterMediaDevice() for media extensions
       
   942 	TInt Connect(TLocDrv* aLocDrv);
       
   943 
       
   944 	void MediaChange();
       
   945 	TInt HandleMediaNotPresent(TLocDrvRequest& aReq);
       
   946 
   885 
   947 
   886 public:
   948 public:
   887 	TInt iLastMediaId;					/**< @internalComponent */
   949 	TInt iLastMediaId;					/**< @internalComponent */
   888 	TMessageQue iMsgQ;
   950 	TMessageQue iMsgQ;
   889 	TDfcQue* iDfcQ;
   951 	TDfcQue* iDfcQ;
  1153     This function must be implemented by the media driver.
  1215     This function must be implemented by the media driver.
  1154 	*/
  1216 	*/
  1155 	virtual void NotifyEmergencyPowerDown()=0;
  1217 	virtual void NotifyEmergencyPowerDown()=0;
  1156 public:
  1218 public:
  1157 	IMPORT_C void SetTotalSizeInBytes(Int64 aTotalSizeInBytes, TLocDrv* aLocDrv=NULL);
  1219 	IMPORT_C void SetTotalSizeInBytes(Int64 aTotalSizeInBytes, TLocDrv* aLocDrv=NULL);
       
  1220 	IMPORT_C void SetTotalSizeInBytes(TLocalDriveCapsV4& aCaps);
  1158 	IMPORT_C Int64 TotalSizeInBytes();
  1221 	IMPORT_C Int64 TotalSizeInBytes();
  1159 	IMPORT_C void SetCurrentConsumption(TInt aValue);
  1222 	IMPORT_C void SetCurrentConsumption(TInt aValue);
  1160 	IMPORT_C TInt InCritical();
  1223 	IMPORT_C TInt InCritical();
  1161 	IMPORT_C void EndInCritical();
  1224 	IMPORT_C void EndInCritical();
  1162 	IMPORT_C void Complete(TLocDrvRequest& aRequest, TInt aResult);
  1225 	IMPORT_C void Complete(TLocDrvRequest& aRequest, TInt aResult);
  1167 	Int64 iTotalSizeInBytes;         /**< @internalComponent */
  1230 	Int64 iTotalSizeInBytes;         /**< @internalComponent */
  1168     TInt iCurrentConsumption;        /**< @internalComponent */
  1231     TInt iCurrentConsumption;        /**< @internalComponent */
  1169 	DPrimaryMediaBase* iPrimaryMedia;/**< @internalComponent */
  1232 	DPrimaryMediaBase* iPrimaryMedia;/**< @internalComponent */
  1170 	TBool iCritical;                 /**< @internalComponent */
  1233 	TBool iCritical;                 /**< @internalComponent */
  1171 	TMountInfoData* iMountInfo;      /**< @internalComponent */
  1234 	TMountInfoData* iMountInfo;      /**< @internalComponent */
       
  1235 	};
       
  1236 
       
  1237 
       
  1238 /**
       
  1239 @internalTechnology
       
  1240 @prototype
       
  1241 
       
  1242 An abstract base class for media driver 'extensions' within the local media subsystem
       
  1243 */
       
  1244 class DMediaDriverExtension : public DMediaDriver
       
  1245 	{
       
  1246 public:
       
  1247 	IMPORT_C DMediaDriverExtension(TInt aMediaId);
       
  1248 	IMPORT_C virtual ~DMediaDriverExtension();
       
  1249 	IMPORT_C virtual void Close();
       
  1250 
       
  1251 	virtual TInt Request(TLocDrvRequest& aRequest) = 0;
       
  1252 	
       
  1253 	virtual TInt PartitionInfo(TPartitionInfo &anInfo) = 0;
       
  1254 
       
  1255 	IMPORT_C virtual void NotifyPowerDown();
       
  1256 
       
  1257 	IMPORT_C virtual void NotifyEmergencyPowerDown();
       
  1258 
       
  1259 	/**
       
  1260 	Retrieve partition info from all the attached drives
       
  1261 	*/
       
  1262 	IMPORT_C TInt DoDrivePartitionInfo(TPartitionInfo &anInfo);
       
  1263 	/**
       
  1264 	Forward a request to the next attached drive
       
  1265 	*/
       
  1266 	IMPORT_C TInt ForwardRequest(TLocDrvRequest& aRequest);
       
  1267 
       
  1268 	/**
       
  1269 	Read from the specified attached drive
       
  1270 	*/
       
  1271 	IMPORT_C TInt Read(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen);
       
  1272 
       
  1273 	/**
       
  1274 	Write to the specified attached drive
       
  1275 	*/
       
  1276 	IMPORT_C TInt Write(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen);
       
  1277 
       
  1278 	/**
       
  1279 	Get the Caps from the specified attached drive
       
  1280 	*/
       
  1281 	IMPORT_C TInt Caps(TInt aDriveNumber, TDes8& aCaps);
       
  1282 
       
  1283 	/**
       
  1284 	Return whether the media is busy i.e. if it has any pending requests or DFCs
       
  1285 	*/
       
  1286 	IMPORT_C TBool MediaBusy(TInt aDriveNumber);
       
  1287 
       
  1288 #ifdef __DEMAND_PAGING__
       
  1289 	/**
       
  1290 	Send a paging read request to the specified attached drive
       
  1291 	*/
       
  1292 	IMPORT_C TInt ReadPaged(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen);
       
  1293 
       
  1294 	/**
       
  1295 	Send a paging write request to the specified attached drive
       
  1296 	*/
       
  1297 	IMPORT_C TInt WritePaged(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen);
       
  1298 #endif
       
  1299 
       
  1300 private:
       
  1301 	TInt SendRequest(TInt aReqId, TBool aPagingRequest, TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen);
       
  1302 
  1172 	};
  1303 	};
  1173 
  1304 
  1174 
  1305 
  1175 
  1306 
  1176 
  1307