21 #include <d32locd.h> |
21 #include <d32locd.h> |
22 |
22 |
23 #if defined(_DEBUG) && defined(__DEMAND_PAGING__) |
23 #if defined(_DEBUG) && defined(__DEMAND_PAGING__) |
24 #define __CONCURRENT_PAGING_INSTRUMENTATION__ |
24 #define __CONCURRENT_PAGING_INSTRUMENTATION__ |
25 #endif |
25 #endif |
26 #if defined(_DEBUG) && defined(__DEMAND_PAGING__) |
26 #ifdef __DEMAND_PAGING__ |
27 #define __DEMAND_PAGING_BENCHMARKS__ |
27 #define __DEMAND_PAGING_BENCHMARKS__ |
28 #endif |
28 #endif |
29 |
29 |
30 #ifdef __WINS__ |
30 #ifdef __WINS__ |
31 #define __EMULATOR_DMA_SUMULATION__ |
31 #define __EMULATOR_DMA_SUMULATION__ |
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 }; |
388 }; |
346 public: |
389 public: |
347 |
390 |
348 /** |
391 /** |
349 Gets a reference to the object containing the request information. |
392 Gets a reference to the object containing the request information. |
645 TLocDrv(TInt aDriveNumber); |
688 TLocDrv(TInt aDriveNumber); |
646 public: |
689 public: |
647 inline TInt Connect(DLocalDrive* aLocalDrive); |
690 inline TInt Connect(DLocalDrive* aLocalDrive); |
648 inline void Disconnect(DLocalDrive* aLocalDrive); |
691 inline void Disconnect(DLocalDrive* aLocalDrive); |
649 inline TInt Request(TLocDrvRequest& aRequest); |
692 inline TInt Request(TLocDrvRequest& aRequest); |
|
693 static TInt MediaChangeCallback(TAny* aLocDrv, TInt aNotifyType); |
650 public: |
694 public: |
651 TInt iDriveNumber; |
695 TInt iDriveNumber; |
652 DMedia* iMedia; |
696 DMedia* iMedia; |
653 DPrimaryMediaBase* iPrimaryMedia; |
697 DPrimaryMediaBase* iPrimaryMedia; |
654 TInt iPartitionNumber; |
698 TInt iPartitionNumber; |
825 KForceMediaChangeReOpenMediaDriver = 0x80000000 |
877 KForceMediaChangeReOpenMediaDriver = 0x80000000 |
826 }; |
878 }; |
827 |
879 |
828 public: |
880 public: |
829 IMPORT_C DPrimaryMediaBase(); |
881 IMPORT_C DPrimaryMediaBase(); |
830 public: |
882 |
831 // provided by implementation |
883 // provided by implementation |
832 IMPORT_C virtual TInt Create(TMediaDevice aDevice, TInt aMediaId, TInt aLastMediaId); |
884 IMPORT_C virtual TInt Create(TMediaDevice aDevice, TInt aMediaId, TInt aLastMediaId); |
833 IMPORT_C virtual TInt Connect(DLocalDrive* aLocalDrive); |
885 IMPORT_C virtual TInt Connect(DLocalDrive* aLocalDrive); |
834 IMPORT_C virtual void Disconnect(DLocalDrive* aLocalDrive); |
886 IMPORT_C virtual void Disconnect(DLocalDrive* aLocalDrive); |
835 IMPORT_C virtual TInt Request(TLocDrvRequest& aRequest); |
887 IMPORT_C virtual TInt Request(TLocDrvRequest& aRequest); |
839 IMPORT_C virtual TInt DoInCritical(); |
891 IMPORT_C virtual TInt DoInCritical(); |
840 IMPORT_C virtual void DoEndInCritical(); |
892 IMPORT_C virtual void DoEndInCritical(); |
841 IMPORT_C virtual void DeltaCurrentConsumption(TInt aCurrent); |
893 IMPORT_C virtual void DeltaCurrentConsumption(TInt aCurrent); |
842 IMPORT_C virtual void DefaultDriveCaps(TLocalDriveCapsV2& aCaps); |
894 IMPORT_C virtual void DefaultDriveCaps(TLocalDriveCapsV2& aCaps); |
843 IMPORT_C virtual TBool IsRemovableDevice(TInt& aSocketNum); |
895 IMPORT_C virtual TBool IsRemovableDevice(TInt& aSocketNum); |
844 public: |
896 |
845 // used by implementation |
897 // used by implementation |
846 IMPORT_C void NotifyMediaChange(); |
898 IMPORT_C void NotifyMediaChange(); |
847 IMPORT_C void NotifyPowerDown(); |
899 IMPORT_C void NotifyPowerDown(); |
848 IMPORT_C void NotifyEmergencyPowerDown(); |
900 IMPORT_C void NotifyEmergencyPowerDown(); |
849 IMPORT_C void NotifyPsuFault(TInt anError); |
901 IMPORT_C void NotifyPsuFault(TInt anError); |
850 IMPORT_C void NotifyMediaPresent(); |
902 IMPORT_C void NotifyMediaPresent(); |
851 IMPORT_C void PowerUpComplete(TInt anError); |
903 IMPORT_C void PowerUpComplete(TInt anError); |
852 public: |
904 |
853 IMPORT_C virtual void HandleMsg(TLocDrvRequest& aRequest); |
905 IMPORT_C virtual void HandleMsg(TLocDrvRequest& aRequest); |
854 IMPORT_C virtual TInt DoRequest(TLocDrvRequest& aRequest); |
906 IMPORT_C virtual TInt DoRequest(TLocDrvRequest& aRequest); |
855 TInt OpenMediaDriver(); |
907 TInt OpenMediaDriver(); |
856 void CloseMediaDrivers(DMedia* aMedia = NULL); |
908 void CloseMediaDrivers(DMedia* aMedia = NULL); |
857 void StartOpenMediaDrivers(); |
909 void StartOpenMediaDrivers(); |
860 void DoPartitionInfoComplete(TInt anError); |
912 void DoPartitionInfoComplete(TInt anError); |
861 void CompleteCurrent(TInt anError); |
913 void CompleteCurrent(TInt anError); |
862 void CompleteRequest(TLocDrvRequest& aMsg, TInt aResult); |
914 void CompleteRequest(TLocDrvRequest& aMsg, TInt aResult); |
863 IMPORT_C void RunDeferred(); |
915 IMPORT_C void RunDeferred(); |
864 void SetClosed(TInt anError); |
916 void SetClosed(TInt anError); |
865 void NotifyClients(TBool aMediaChange,TLocDrv* aLocDrv=NULL); |
917 |
|
918 enum TNotifyType {EMediaChange, EMediaPresent}; |
|
919 void NotifyClients(TNotifyType aNotifyType, TLocDrv* aLocDrv=NULL); |
|
920 |
866 TInt InCritical(); |
921 TInt InCritical(); |
867 void EndInCritical(); |
922 void EndInCritical(); |
868 void UpdatePartitionInfo(); |
923 void UpdatePartitionInfo(); |
869 void MediaReadyHandleRequest(); |
924 void MediaReadyHandleRequest(); |
870 TInt SendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress = NULL); |
925 TInt SendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress = NULL); |
879 |
934 |
880 #ifdef __DEMAND_PAGING__ |
935 #ifdef __DEMAND_PAGING__ |
881 void RequestCountInc(); |
936 void RequestCountInc(); |
882 void RequestCountDec(); |
937 void RequestCountDec(); |
883 #endif |
938 #endif |
|
939 |
|
940 // called by LocDrv::RegisterMediaDevice() for media extensions |
|
941 TInt Connect(TLocDrv* aLocDrv); |
|
942 |
|
943 void MediaChange(); |
|
944 TInt HandleMediaNotPresent(TLocDrvRequest& aReq); |
|
945 |
884 |
946 |
885 public: |
947 public: |
886 TInt iLastMediaId; /**< @internalComponent */ |
948 TInt iLastMediaId; /**< @internalComponent */ |
887 TMessageQue iMsgQ; |
949 TMessageQue iMsgQ; |
888 TDfcQue* iDfcQ; |
950 TDfcQue* iDfcQ; |
1146 This function must be implemented by the media driver. |
1208 This function must be implemented by the media driver. |
1147 */ |
1209 */ |
1148 virtual void NotifyEmergencyPowerDown()=0; |
1210 virtual void NotifyEmergencyPowerDown()=0; |
1149 public: |
1211 public: |
1150 IMPORT_C void SetTotalSizeInBytes(Int64 aTotalSizeInBytes, TLocDrv* aLocDrv=NULL); |
1212 IMPORT_C void SetTotalSizeInBytes(Int64 aTotalSizeInBytes, TLocDrv* aLocDrv=NULL); |
|
1213 IMPORT_C void SetTotalSizeInBytes(TLocalDriveCapsV4& aCaps); |
1151 IMPORT_C Int64 TotalSizeInBytes(); |
1214 IMPORT_C Int64 TotalSizeInBytes(); |
1152 IMPORT_C void SetCurrentConsumption(TInt aValue); |
1215 IMPORT_C void SetCurrentConsumption(TInt aValue); |
1153 IMPORT_C TInt InCritical(); |
1216 IMPORT_C TInt InCritical(); |
1154 IMPORT_C void EndInCritical(); |
1217 IMPORT_C void EndInCritical(); |
1155 IMPORT_C void Complete(TLocDrvRequest& aRequest, TInt aResult); |
1218 IMPORT_C void Complete(TLocDrvRequest& aRequest, TInt aResult); |
1160 Int64 iTotalSizeInBytes; /**< @internalComponent */ |
1223 Int64 iTotalSizeInBytes; /**< @internalComponent */ |
1161 TInt iCurrentConsumption; /**< @internalComponent */ |
1224 TInt iCurrentConsumption; /**< @internalComponent */ |
1162 DPrimaryMediaBase* iPrimaryMedia;/**< @internalComponent */ |
1225 DPrimaryMediaBase* iPrimaryMedia;/**< @internalComponent */ |
1163 TBool iCritical; /**< @internalComponent */ |
1226 TBool iCritical; /**< @internalComponent */ |
1164 TMountInfoData* iMountInfo; /**< @internalComponent */ |
1227 TMountInfoData* iMountInfo; /**< @internalComponent */ |
|
1228 }; |
|
1229 |
|
1230 |
|
1231 /** |
|
1232 @internalTechnology |
|
1233 @prototype |
|
1234 |
|
1235 An abstract base class for media driver 'extensions' within the local media subsystem |
|
1236 */ |
|
1237 class DMediaDriverExtension : public DMediaDriver |
|
1238 { |
|
1239 public: |
|
1240 IMPORT_C DMediaDriverExtension(TInt aMediaId); |
|
1241 IMPORT_C virtual ~DMediaDriverExtension(); |
|
1242 IMPORT_C virtual void Close(); |
|
1243 |
|
1244 virtual TInt Request(TLocDrvRequest& aRequest) = 0; |
|
1245 |
|
1246 virtual TInt PartitionInfo(TPartitionInfo &anInfo) = 0; |
|
1247 |
|
1248 IMPORT_C virtual void NotifyPowerDown(); |
|
1249 |
|
1250 IMPORT_C virtual void NotifyEmergencyPowerDown(); |
|
1251 |
|
1252 /** |
|
1253 Retrieve partition info from all the attached drives |
|
1254 */ |
|
1255 IMPORT_C TInt DoDrivePartitionInfo(TPartitionInfo &anInfo); |
|
1256 /** |
|
1257 Forward a request to the next attached drive |
|
1258 */ |
|
1259 IMPORT_C TInt ForwardRequest(TLocDrvRequest& aRequest); |
|
1260 |
|
1261 /** |
|
1262 Read from the specified attached drive |
|
1263 */ |
|
1264 IMPORT_C TInt Read(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen); |
|
1265 |
|
1266 /** |
|
1267 Write to the specified attached drive |
|
1268 */ |
|
1269 IMPORT_C TInt Write(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen); |
|
1270 |
|
1271 /** |
|
1272 Get the Caps from the specified attached drive |
|
1273 */ |
|
1274 IMPORT_C TInt Caps(TInt aDriveNumber, TDes8& aCaps); |
|
1275 |
|
1276 /** |
|
1277 Return whether the media is busy i.e. if it has any pending requests or DFCs |
|
1278 */ |
|
1279 IMPORT_C TBool MediaBusy(TInt aDriveNumber); |
|
1280 |
|
1281 #ifdef __DEMAND_PAGING__ |
|
1282 /** |
|
1283 Send a paging read request to the specified attached drive |
|
1284 */ |
|
1285 IMPORT_C TInt ReadPaged(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen); |
|
1286 |
|
1287 /** |
|
1288 Send a paging write request to the specified attached drive |
|
1289 */ |
|
1290 IMPORT_C TInt WritePaged(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen); |
|
1291 #endif |
|
1292 |
|
1293 private: |
|
1294 TInt SendRequest(TInt aReqId, TBool aPagingRequest, TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen); |
|
1295 |
1165 }; |
1296 }; |
1166 |
1297 |
1167 |
1298 |
1168 |
1299 |
1169 |
1300 |