sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\resourceman\resourceman_psl\rescontrol_psl.h sl@0: // sl@0: // sl@0: sl@0: #ifndef __RESCONTROL_PSL_H__ sl@0: #define __RESCONTROL_PSL_H__ sl@0: #include sl@0: #include sl@0: #include sl@0: #define E_ON 0x1 sl@0: #define E_OFF 0x0 sl@0: sl@0: //Specifies the number of pre-allocate the PIL data structures. sl@0: #define KERNEL_CLIENTS 0x32 sl@0: #define USER_CLIENTS 0x10 sl@0: #define CLIENT_LEVELS 0x32 sl@0: #define REQUESTS 0x19 sl@0: sl@0: #define MAX_RESOURCE_COUNT 30 sl@0: #define MAX_DEPENDENT_RESOURCE_COUNT 10 sl@0: sl@0: #define MAX_BLOCK_TIME 200 //Maximum block time sl@0: #define MIN_BLOCK_TIME 50 //Guaranteed minimum block sl@0: sl@0: #define CLEAN_AND_RETURN(resCount, resArray, error) \ sl@0: { \ sl@0: for(TUint count = 0; count < resCount; count++) \ sl@0: delete resArray[count]; \ sl@0: delete resArray; \ sl@0: return error; \ sl@0: } sl@0: sl@0: const TUint KBinary = 0x0; sl@0: const TUint KMultiLevel = 0x1; sl@0: sl@0: _LIT(KResmanName, "DSimulatedResMan"); sl@0: /** Simulated resource controller class */ sl@0: NONSHARABLE_CLASS(DSimulatedPowerResourceController): public DPowerResourceController sl@0: { sl@0: public: sl@0: DSimulatedPowerResourceController(); sl@0: ~DSimulatedPowerResourceController(); sl@0: TInt DoInitController(); sl@0: TInt DoInitResources(); sl@0: TInt DoRegisterStaticResources(DStaticPowerResource**& aStaticResourceArray, TUint16& aStaticResourceCount); sl@0: // Function to process instantaneous resources sl@0: TInt ProcessInstantaneousResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel); sl@0: // Function to procces polled resources sl@0: TInt ProcessPolledResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel, TInt aBlockTime = 0); sl@0: // Function to change the state of the resource sl@0: TInt ChangeResource(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel); sl@0: // Function to process event driven resources sl@0: TInt ProcessEventResources(TPowerRequest& req, TInt& aClientLevel, TInt aMaxLevel, TInt aMinLevel, TInt aDefaultLevel, TInt aBlockTime = 0); sl@0: IMPORT_C static TInt CaptureIdleResourcesInfo(TUint aControllerId, TUint aNumResources, TPtr* aPtr); sl@0: IMPORT_C static TInt CompleteResourceControllerInitialisation(); sl@0: #ifdef PRM_ENABLE_EXTENDED_VERSION sl@0: TInt DoRegisterStaticResourcesDependency(DStaticPowerResourceD**& aStaticResourceDArray, TUint16& aStaticResourceDCount); sl@0: TInt CreateResourceDependency(DStaticPowerResourceD** pResArray); sl@0: #endif sl@0: private: sl@0: static void TimerIsrFunc(TAny* ptr); //ISR Function called when specfied timer expires. This is for even driven resources sl@0: static void EventDfcFunc(TAny* ptr); //Function to wakeup the fast semphore. This is called from timer ISR. sl@0: DStaticPowerResource** iResources; sl@0: TUint16 iStaticResourceCount; sl@0: NFastSemaphore iEventFastSem; //Semphore to block the PIL of resource controller for event driven resource operations. sl@0: TDfc iEventDfc; //Dfc to run to signal the event semaphore when the timer expires. Queued from timer ISR sl@0: #ifdef PRM_ENABLE_EXTENDED_VERSION sl@0: DStaticPowerResourceD** iDependencyResources; sl@0: TUint16 iStaticResDependencyCount; sl@0: SNode* iNodeArray; sl@0: TUint16 iNodeCount; sl@0: #endif sl@0: }; sl@0: sl@0: #ifdef PRM_ENABLE_EXTENDED_VERSION sl@0: DSimulatedPowerResourceController* GetControllerPtr(); sl@0: #endif sl@0: //class definition for Binary Single Instantaneous Positive resource sl@0: NONSHARABLE_CLASS(DBSIGISPResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DBSIGISPResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: }; sl@0: sl@0: //class definition for multilevel single instantaneous positive resource sl@0: NONSHARABLE_CLASS(DMLSIGISPResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DMLSIGISPResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: }; sl@0: sl@0: //class definition for binary single instantaneous negative resource sl@0: NONSHARABLE_CLASS(DBSIGISNResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DBSIGISNResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: }; sl@0: sl@0: //class definition for multilevel single instantaneous negative resource sl@0: NONSHARABLE_CLASS(DMLSIGISNResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DMLSIGISNResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: }; sl@0: sl@0: //class definition for binary single long latency positive resource sl@0: NONSHARABLE_CLASS(DBSLGLSPResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DBSLGLSPResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: TBool iPolled; sl@0: TInt iBlockTime; //Time duration the thread will be blocked. sl@0: }; sl@0: sl@0: //class definition for multilevel single long latency positive resource sl@0: NONSHARABLE_CLASS(DMLSLGLSPResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DMLSLGLSPResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: TBool iPolled; sl@0: TInt iBlockTime; //Time duration the thread will be blocked. sl@0: }; sl@0: sl@0: //class definition for binary single long latency get & instantaneous set negative resource sl@0: NONSHARABLE_CLASS(DBSLGISNResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DBSLGISNResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: TBool iPolled; sl@0: TInt iBlockTime; //Time duration the thread will be blocked. sl@0: }; sl@0: sl@0: //class definition for multilevel single long latency get & instantaneous set negative resource sl@0: NONSHARABLE_CLASS(DMLSLGISNResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DMLSLGISNResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: TBool iPolled; sl@0: TInt iBlockTime; //Time duration the thread will be blocked. sl@0: }; sl@0: sl@0: //class definition for binary single instantaneous get & long latency set positive resource sl@0: NONSHARABLE_CLASS(DBSIGLSPResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DBSIGLSPResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: TBool iPolled; sl@0: TInt iBlockTime; //Time duration the thread will be blocked. sl@0: }; sl@0: sl@0: //class definition for multilevel single instantaneous get & long latency get positive resource sl@0: NONSHARABLE_CLASS(DMLSIGLSPResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DMLSIGLSPResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: TBool iPolled; sl@0: TInt iBlockTime; //Time duration the thread will be blocked. sl@0: }; sl@0: sl@0: //class definition for Binary Shared Instantaneous Positive resource sl@0: NONSHARABLE_CLASS(DBSHIGISPResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DBSHIGISPResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: }; sl@0: sl@0: //class definition for multilevel shared instantaneous positive resource sl@0: NONSHARABLE_CLASS(DMLSHIGISPResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DMLSHIGISPResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: }; sl@0: sl@0: //class definition for binary shared instantaneous negative resource sl@0: NONSHARABLE_CLASS(DBSHIGISNResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DBSHIGISNResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: }; sl@0: sl@0: //class definition for multilevel shared instantaneous negative resource sl@0: NONSHARABLE_CLASS(DMLSHIGISNResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DMLSHIGISNResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: }; sl@0: sl@0: //class definition for binary shared long latency positive resource sl@0: NONSHARABLE_CLASS(DBSHLGLSPResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DBSHLGLSPResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type sl@0: TInt iBlockTime; //Time duration the thread will be blocked. sl@0: }; sl@0: sl@0: //class definition for multilevel shared long latency positive resource sl@0: NONSHARABLE_CLASS(DMLSHLGLSPResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DMLSHLGLSPResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type sl@0: TInt iBlockTime; //Time duration the thread will be blocked. sl@0: }; sl@0: sl@0: //class definition for binary shared long latency get & instantaneous set negative resource sl@0: NONSHARABLE_CLASS(DBSHLGISNResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DBSHLGISNResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type sl@0: TInt iBlockTime; //Time duration the thread will be blocked. sl@0: }; sl@0: sl@0: //class definition for multilevel shared long latency get & instantaneous set negative resource sl@0: NONSHARABLE_CLASS(DMLSHLGISNResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DMLSHLGISNResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type sl@0: TInt iBlockTime; //Time duration the thread will be blocked. sl@0: }; sl@0: sl@0: //class definition for binary shared instantaneous get & long latency set positive resource sl@0: NONSHARABLE_CLASS(DBSHIGLSPResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DBSHIGLSPResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type sl@0: TInt iBlockTime; //Time duration the thread will be blocked. sl@0: }; sl@0: sl@0: //class definition for multilevel shared instantaneous get & long latency get positive resource sl@0: NONSHARABLE_CLASS(DMLSHIGLSPResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DMLSHIGLSPResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type sl@0: TInt iBlockTime; //Time duration the thread will be blocked. sl@0: }; sl@0: sl@0: //class definition for binary shared long latency get & set custom resource sl@0: NONSHARABLE_CLASS(DBSHLGLSCResource) : public DStaticPowerResource sl@0: { sl@0: public: sl@0: DBSHLGLSCResource(); sl@0: TInt DoRequest(TPowerRequest &req); sl@0: TInt GetInfo(TDes8* aInfo) const; sl@0: static TBool CustomFunction(TInt &aClientId, const TDesC8& aClientName, sl@0: TUint aResourceId, sl@0: TCustomOperation aCustomOperation, TInt &aLevel, sl@0: TAny* aLevelList, TAny* aReserved); sl@0: sl@0: private: sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iCurrentLevel; sl@0: TBool iPolled; //ETrue if this is a polled resource, otherwise event driven type sl@0: TInt iBlockTime; //Time duration the thread will be blocked. sl@0: }; sl@0: sl@0: #endif //__RESCONTROL_PSL_H__