os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/inc/template_power.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/inc/template_power.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,177 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// template\template_variant\inc\template_power.h
    1.18 +// Template Power Management Header
    1.19 +// (see also assp.cpp for a discussion on Sleep modes and xyin.cpp for example
    1.20 +// of usage of Resource Manager and Peripheral self power down and interaction
    1.21 +// with Power Controller for Wakeup Events)
    1.22 +// 
    1.23 +//
    1.24 +
    1.25 +#ifndef __PM_STD_H__
    1.26 +#define __PM_STD_H__
    1.27 +#include <kernel/kpower.h>
    1.28 +#include "variant.h"
    1.29 +
    1.30 +//
    1.31 +// TO DO: (mandatory)
    1.32 +//
    1.33 +// Definition of the DPowerController derived class
    1.34 +//
    1.35 +NONSHARABLE_CLASS(DTemplatePowerController) : public DPowerController
    1.36 +	{
    1.37 +public: // from DPowerController
    1.38 +	void CpuIdle();
    1.39 +	void EnableWakeupEvents();
    1.40 +	void AbsoluteTimerExpired();
    1.41 +	void DisableWakeupEvents();
    1.42 +	void PowerDown(TTimeK aWakeupTime);
    1.43 +public:
    1.44 +	DTemplatePowerController();
    1.45 +private:
    1.46 +	void DoStandby(TBool aTimed, TUint32 aWakeupRTC);
    1.47 +public:
    1.48 +	TBool iWakeupEventsOn;
    1.49 +	};
    1.50 +
    1.51 +//
    1.52 +// TO DO: (optional)
    1.53 +//
    1.54 +// If you need to access to the Power Controller from Drivers/Extensions/Variant 
    1.55 +// or access to Resource Manager then define an accessor class as below
    1.56 +//
    1.57 +
    1.58 +class TemplateResourceManager;
    1.59 +
    1.60 +class TTemplatePowerController
    1.61 +	{
    1.62 +public:
    1.63 +	// to allow Variant/Drivers/Extensions access to Resource Manager
    1.64 +	IMPORT_C static TemplateResourceManager* ResourceManager();
    1.65 +	// used by drivers/extensions to signal a wakeup event to Power Controller
    1.66 +	IMPORT_C static void WakeupEvent();
    1.67 +
    1.68 +	inline static void RegisterPowerController(DTemplatePowerController* aPowerController);
    1.69 +private:
    1.70 +	static DTemplatePowerController* iPowerController;
    1.71 +	};
    1.72 +
    1.73 +NONSHARABLE_CLASS(SharedBinaryResource1) : public MPowerInput
    1.74 +	{
    1.75 +public: // from MPowerInput
    1.76 +	void Use();
    1.77 +	void Release();
    1.78 +public:
    1.79 +	TUint GetCount();		// gets current usage count
    1.80 +private:
    1.81 +	TUint	iCount;
    1.82 +	};
    1.83 +
    1.84 +// Prototype class for Multilevel resources
    1.85 +
    1.86 +class MSharedMultilevelResource			// Multilevel Shared Input
    1.87 +	{
    1.88 +public:
    1.89 +	virtual void IncreaseToLevel(TUint aLevel, TInt aRequester) = 0;
    1.90 +	virtual void ReduceToLevel(TUint aLevel, TInt aRequester) = 0;
    1.91 +	virtual TUint GetResourceLevel() = 0;
    1.92 +	};
    1.93 +
    1.94 +// EXAMPLE ONLY
    1.95 +const TUint KSharers = 3;
    1.96 +
    1.97 +NONSHARABLE_CLASS(SharedMultilevelResource1) : public MSharedMultilevelResource
    1.98 +	{
    1.99 +public:
   1.100 +	enum TRequesterId
   1.101 +		{
   1.102 +		//
   1.103 +		// Identify all possible users of this resource
   1.104 +		//
   1.105 +		ERequesterX = 0,
   1.106 +		ERequesterY = 1,
   1.107 +		ERequesterZ = 2
   1.108 +		};
   1.109 +	SharedMultilevelResource1();
   1.110 +public:	// from MSharedMultilevelResource
   1.111 +	void IncreaseToLevel(TUint aLevel, TInt aRequester);
   1.112 +	void ReduceToLevel(TUint aLevel, TInt aRequester);
   1.113 +	TUint GetResourceLevel();
   1.114 +private:
   1.115 +	void FindMaxLevel(TUint* aLevel, TInt* aId);
   1.116 +private:
   1.117 +	TUint	Levels[KSharers];		// one element per user of resource
   1.118 +	TUint	iCurrentLevel;
   1.119 +	TInt	iCurrentLevelOwnerId;
   1.120 +	};
   1.121 +
   1.122 +//
   1.123 +// TO DO: (optional)
   1.124 +//
   1.125 +// The Resource Manager class
   1.126 +//
   1.127 +NONSHARABLE_CLASS(TemplateResourceManager)
   1.128 +	{
   1.129 +public:
   1.130 +	enum TResource			// a list of controllable resources (e.g clocks, voltages, power lines)
   1.131 +		{
   1.132 +		SynchBinResourceUsedByZOnly,
   1.133 +		AsynchBinResourceUsedByZOnly,
   1.134 +		//	... other non-shared binary resources, synchronous or asynchronous
   1.135 +		BinResourceSharedByZAndY,
   1.136 +		//	...	other shared binary resources, synchronous or asynchronous
   1.137 +		SynchMlResourceUsedByXOnly,
   1.138 +		AsynchMlResourceUsedByXOnly,
   1.139 +		//	... other non-shared multilevel resources, synchronous or asynchronous
   1.140 +		MlResourceSharedByXAndW,
   1.141 +		//	...	other shared multilevel resources, synchronous or asynchronous
   1.142 +		};
   1.143 +	enum TSleepModes
   1.144 +		{
   1.145 +		Snooze,
   1.146 +		// ...
   1.147 +		Sleep,
   1.148 +		// ...
   1.149 +		DeepSleep,
   1.150 +		// ...
   1.151 +		Coma
   1.152 +		};
   1.153 +
   1.154 +	void InitResources();									// initialises power Resources not initialised by Bootstrap
   1.155 +
   1.156 +	inline TSleepModes MapSleepMode(TInt aSleepPeriod);
   1.157 +
   1.158 +	// interface for non-shared shared resources
   1.159 +
   1.160 +	inline void Modify(TResource aResource, TBool aOnOff);			// for non-shared binary resources
   1.161 +	inline void ModifyToLevel(TResource aResource, TInt aLevel);	// for non-shared multilevel resources
   1.162 +	// the following functions may be used by Drivers/Extensions or the Idle routine to 
   1.163 +	// determine what resources are On or Off or their levels
   1.164 +	inline TBool GetResourceState(TResource aResource);			// for non-shared binary resources
   1.165 +	inline TUint GetResourceLevel(TResource aResource);			// for non-shared multilevel resources 
   1.166 +public:
   1.167 +	// interface for shared resources
   1.168 +
   1.169 +	SharedBinaryResource1 iSharedBResource1;
   1.170 +	//	...	other shared Binary resources, synchronous or asynchronous
   1.171 +	inline SharedBinaryResource1* SharedBResource1();
   1.172 +
   1.173 +	SharedMultilevelResource1 iSharedMlResource1;
   1.174 +	//	...	other shared Multilevel resources
   1.175 +	inline SharedMultilevelResource1* SharedMlResource1();
   1.176 +	};
   1.177 +
   1.178 +#include "template_power.inl"
   1.179 +
   1.180 +#endif