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 |
|
209 /** |
169 /** |
210 @publishedPartner |
170 @publishedPartner |
211 @released |
171 @released |
212 |
172 |
213 This class is strictly internal to Symbian; the only part of this class that |
173 This class is strictly internal to Symbian; the only part of this class that |
313 |
273 |
314 /** |
274 /** |
315 Query device |
275 Query device |
316 */ |
276 */ |
317 EQueryDevice=32, |
277 EQueryDevice=32, |
|
278 |
318 }; |
279 }; |
319 public: |
280 public: |
320 DLocalDrive(); |
281 DLocalDrive(); |
321 ~DLocalDrive(); |
282 ~DLocalDrive(); |
322 |
283 public: |
323 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); /**< @internalComponent */ |
284 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); /**< @internalComponent */ |
324 virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2); /**< @internalComponent */ |
285 virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2); /**< @internalComponent */ |
325 |
286 public: |
326 void NotifyChange(); |
287 void NotifyChange(DPrimaryMediaBase& aPrimaryMedia, TBool aMediaChange); |
327 |
288 public: |
328 inline void Deque(); /**< @internalComponent */ |
289 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); |
|
333 |
290 |
334 private: |
291 private: |
335 #ifdef __DEMAND_PAGING__ |
292 #ifdef __DEMAND_PAGING__ |
336 TInt LockMountInfo(DPrimaryMediaBase& aPrimaryMedia, TLocDrvRequest& aReq); |
293 TInt LockMountInfo(DPrimaryMediaBase& aPrimaryMedia, TLocDrvRequest& aReq); |
337 void UnlockMountInfo(DPrimaryMediaBase& aPrimaryMedia); |
294 void UnlockMountInfo(DPrimaryMediaBase& aPrimaryMedia); |
338 #endif |
295 #endif |
339 TInt ReadPasswordData(TLocDrvRequest& aReq, TLocalDrivePasswordData& aPswData, TMediaPassword& aOldPasswd, TMediaPassword& aNewPasswd); |
296 TInt ReadPasswordData(TLocDrvRequest& aReq, TLocalDrivePasswordData& aPswData, TMediaPassword& aOldPasswd, TMediaPassword& aNewPasswd); |
340 |
297 |
341 public: |
298 public: |
342 TLocDrv* iDrive; /**< @internalComponent */ |
299 TLocDrv* iDrive; /**< @internalComponent */ |
343 TCallBackLink iMediaChangeObserver; /**< @internalComponent */ |
300 SDblQueLink iLink; /**< @internalComponent */ |
344 TClientDataRequest<TBool>* iNotifyChangeRequest; /**< @internalComponent */ |
301 TClientDataRequest<TBool>* iNotifyChangeRequest; /**< @internalComponent */ |
345 TLocalDriveCleanup iCleanup; /**< @internalComponent */ |
302 TLocalDriveCleanup iCleanup; /**< @internalComponent */ |
346 }; |
303 }; |
347 |
304 |
348 /** |
305 /** |
349 @internalComponent |
306 @internalComponent |
350 */ |
307 */ |
382 EPaging=0x08, // a paging request |
339 EPaging=0x08, // a paging request |
383 EBackgroundPaging=0x10, // a background paging request. @see DMediaPagingDevice::Write() |
340 EBackgroundPaging=0x10, // a background paging request. @see DMediaPagingDevice::Write() |
384 ECodePaging=0x20, // a code paging request |
341 ECodePaging=0x20, // a code paging request |
385 EDataPaging=0x40, // a data paging request |
342 EDataPaging=0x40, // a data paging request |
386 ETClientBuffer=0x80, // RemoteDes() points to a TClientBuffer |
343 ETClientBuffer=0x80, // RemoteDes() points to a TClientBuffer |
387 EKernelBuffer=0x100, // RemoteDes() points to a kernel-side buffer : set for all paging requests and media extension requests |
344 EKernelBuffer=0x100, // RemoteDes() points to a kernel-side buffer |
388 EPhysAddrOnly=0x200, // No virtual address is available. Data Paging requests Only. |
345 EPhysAddrOnly=0x200, // No virtual address is available. Data Paging requests Only. |
389 }; |
346 }; |
390 public: |
347 public: |
391 |
348 |
392 /** |
349 /** |
689 TLocDrv(TInt aDriveNumber); |
646 TLocDrv(TInt aDriveNumber); |
690 public: |
647 public: |
691 inline TInt Connect(DLocalDrive* aLocalDrive); |
648 inline TInt Connect(DLocalDrive* aLocalDrive); |
692 inline void Disconnect(DLocalDrive* aLocalDrive); |
649 inline void Disconnect(DLocalDrive* aLocalDrive); |
693 inline TInt Request(TLocDrvRequest& aRequest); |
650 inline TInt Request(TLocDrvRequest& aRequest); |
694 static TInt MediaChangeCallback(TAny* aLocDrv, TInt aNotifyType); |
|
695 public: |
651 public: |
696 TInt iDriveNumber; |
652 TInt iDriveNumber; |
697 DMedia* iMedia; |
653 DMedia* iMedia; |
698 DPrimaryMediaBase* iPrimaryMedia; |
654 DPrimaryMediaBase* iPrimaryMedia; |
699 TInt iPartitionNumber; |
655 TInt iPartitionNumber; |
878 KForceMediaChangeReOpenMediaDriver = 0x80000000 |
826 KForceMediaChangeReOpenMediaDriver = 0x80000000 |
879 }; |
827 }; |
880 |
828 |
881 public: |
829 public: |
882 IMPORT_C DPrimaryMediaBase(); |
830 IMPORT_C DPrimaryMediaBase(); |
883 |
831 public: |
884 // provided by implementation |
832 // provided by implementation |
885 IMPORT_C virtual TInt Create(TMediaDevice aDevice, TInt aMediaId, TInt aLastMediaId); |
833 IMPORT_C virtual TInt Create(TMediaDevice aDevice, TInt aMediaId, TInt aLastMediaId); |
886 IMPORT_C virtual TInt Connect(DLocalDrive* aLocalDrive); |
834 IMPORT_C virtual TInt Connect(DLocalDrive* aLocalDrive); |
887 IMPORT_C virtual void Disconnect(DLocalDrive* aLocalDrive); |
835 IMPORT_C virtual void Disconnect(DLocalDrive* aLocalDrive); |
888 IMPORT_C virtual TInt Request(TLocDrvRequest& aRequest); |
836 IMPORT_C virtual TInt Request(TLocDrvRequest& aRequest); |
892 IMPORT_C virtual TInt DoInCritical(); |
840 IMPORT_C virtual TInt DoInCritical(); |
893 IMPORT_C virtual void DoEndInCritical(); |
841 IMPORT_C virtual void DoEndInCritical(); |
894 IMPORT_C virtual void DeltaCurrentConsumption(TInt aCurrent); |
842 IMPORT_C virtual void DeltaCurrentConsumption(TInt aCurrent); |
895 IMPORT_C virtual void DefaultDriveCaps(TLocalDriveCapsV2& aCaps); |
843 IMPORT_C virtual void DefaultDriveCaps(TLocalDriveCapsV2& aCaps); |
896 IMPORT_C virtual TBool IsRemovableDevice(TInt& aSocketNum); |
844 IMPORT_C virtual TBool IsRemovableDevice(TInt& aSocketNum); |
897 |
845 public: |
898 // used by implementation |
846 // used by implementation |
899 IMPORT_C void NotifyMediaChange(); |
847 IMPORT_C void NotifyMediaChange(); |
900 IMPORT_C void NotifyPowerDown(); |
848 IMPORT_C void NotifyPowerDown(); |
901 IMPORT_C void NotifyEmergencyPowerDown(); |
849 IMPORT_C void NotifyEmergencyPowerDown(); |
902 IMPORT_C void NotifyPsuFault(TInt anError); |
850 IMPORT_C void NotifyPsuFault(TInt anError); |
903 IMPORT_C void NotifyMediaPresent(); |
851 IMPORT_C void NotifyMediaPresent(); |
904 IMPORT_C void PowerUpComplete(TInt anError); |
852 IMPORT_C void PowerUpComplete(TInt anError); |
905 |
853 public: |
906 IMPORT_C virtual void HandleMsg(TLocDrvRequest& aRequest); |
854 IMPORT_C virtual void HandleMsg(TLocDrvRequest& aRequest); |
907 IMPORT_C virtual TInt DoRequest(TLocDrvRequest& aRequest); |
855 IMPORT_C virtual TInt DoRequest(TLocDrvRequest& aRequest); |
908 TInt OpenMediaDriver(); |
856 TInt OpenMediaDriver(); |
909 void CloseMediaDrivers(DMedia* aMedia = NULL); |
857 void CloseMediaDrivers(DMedia* aMedia = NULL); |
910 void StartOpenMediaDrivers(); |
858 void StartOpenMediaDrivers(); |
913 void DoPartitionInfoComplete(TInt anError); |
861 void DoPartitionInfoComplete(TInt anError); |
914 void CompleteCurrent(TInt anError); |
862 void CompleteCurrent(TInt anError); |
915 void CompleteRequest(TLocDrvRequest& aMsg, TInt aResult); |
863 void CompleteRequest(TLocDrvRequest& aMsg, TInt aResult); |
916 IMPORT_C void RunDeferred(); |
864 IMPORT_C void RunDeferred(); |
917 void SetClosed(TInt anError); |
865 void SetClosed(TInt anError); |
918 |
866 void NotifyClients(TBool aMediaChange,TLocDrv* aLocDrv=NULL); |
919 enum TNotifyType {EMediaChange, EMediaPresent}; |
|
920 void NotifyClients(TNotifyType aNotifyType, TLocDrv* aLocDrv=NULL); |
|
921 |
|
922 TInt InCritical(); |
867 TInt InCritical(); |
923 void EndInCritical(); |
868 void EndInCritical(); |
924 void UpdatePartitionInfo(); |
869 void UpdatePartitionInfo(); |
925 void MediaReadyHandleRequest(); |
870 void MediaReadyHandleRequest(); |
926 TInt SendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress = NULL); |
871 TInt SendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress = NULL); |
935 |
880 |
936 #ifdef __DEMAND_PAGING__ |
881 #ifdef __DEMAND_PAGING__ |
937 void RequestCountInc(); |
882 void RequestCountInc(); |
938 void RequestCountDec(); |
883 void RequestCountDec(); |
939 #endif |
884 #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 |
|
947 |
885 |
948 public: |
886 public: |
949 TInt iLastMediaId; /**< @internalComponent */ |
887 TInt iLastMediaId; /**< @internalComponent */ |
950 TMessageQue iMsgQ; |
888 TMessageQue iMsgQ; |
951 TDfcQue* iDfcQ; |
889 TDfcQue* iDfcQ; |
1215 This function must be implemented by the media driver. |
1153 This function must be implemented by the media driver. |
1216 */ |
1154 */ |
1217 virtual void NotifyEmergencyPowerDown()=0; |
1155 virtual void NotifyEmergencyPowerDown()=0; |
1218 public: |
1156 public: |
1219 IMPORT_C void SetTotalSizeInBytes(Int64 aTotalSizeInBytes, TLocDrv* aLocDrv=NULL); |
1157 IMPORT_C void SetTotalSizeInBytes(Int64 aTotalSizeInBytes, TLocDrv* aLocDrv=NULL); |
1220 IMPORT_C void SetTotalSizeInBytes(TLocalDriveCapsV4& aCaps); |
|
1221 IMPORT_C Int64 TotalSizeInBytes(); |
1158 IMPORT_C Int64 TotalSizeInBytes(); |
1222 IMPORT_C void SetCurrentConsumption(TInt aValue); |
1159 IMPORT_C void SetCurrentConsumption(TInt aValue); |
1223 IMPORT_C TInt InCritical(); |
1160 IMPORT_C TInt InCritical(); |
1224 IMPORT_C void EndInCritical(); |
1161 IMPORT_C void EndInCritical(); |
1225 IMPORT_C void Complete(TLocDrvRequest& aRequest, TInt aResult); |
1162 IMPORT_C void Complete(TLocDrvRequest& aRequest, TInt aResult); |
1230 Int64 iTotalSizeInBytes; /**< @internalComponent */ |
1167 Int64 iTotalSizeInBytes; /**< @internalComponent */ |
1231 TInt iCurrentConsumption; /**< @internalComponent */ |
1168 TInt iCurrentConsumption; /**< @internalComponent */ |
1232 DPrimaryMediaBase* iPrimaryMedia;/**< @internalComponent */ |
1169 DPrimaryMediaBase* iPrimaryMedia;/**< @internalComponent */ |
1233 TBool iCritical; /**< @internalComponent */ |
1170 TBool iCritical; /**< @internalComponent */ |
1234 TMountInfoData* iMountInfo; /**< @internalComponent */ |
1171 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 |
|
1303 }; |
1172 }; |
1304 |
1173 |
1305 |
1174 |
1306 |
1175 |
1307 |
1176 |