Update contrib.
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // template\template_variant\inc\template_power.h
15 // Template Power Management Header
16 // (see also assp.cpp for a discussion on Sleep modes and xyin.cpp for example
17 // of usage of Resource Manager and Peripheral self power down and interaction
18 // with Power Controller for Wakeup Events)
24 #include <kernel/kpower.h>
30 // Definition of the DPowerController derived class
32 NONSHARABLE_CLASS(DTemplatePowerController) : public DPowerController
34 public: // from DPowerController
36 void EnableWakeupEvents();
37 void AbsoluteTimerExpired();
38 void DisableWakeupEvents();
39 void PowerDown(TTimeK aWakeupTime);
41 DTemplatePowerController();
43 void DoStandby(TBool aTimed, TUint32 aWakeupRTC);
45 TBool iWakeupEventsOn;
51 // If you need to access to the Power Controller from Drivers/Extensions/Variant
52 // or access to Resource Manager then define an accessor class as below
55 class TemplateResourceManager;
57 class TTemplatePowerController
60 // to allow Variant/Drivers/Extensions access to Resource Manager
61 IMPORT_C static TemplateResourceManager* ResourceManager();
62 // used by drivers/extensions to signal a wakeup event to Power Controller
63 IMPORT_C static void WakeupEvent();
65 inline static void RegisterPowerController(DTemplatePowerController* aPowerController);
67 static DTemplatePowerController* iPowerController;
70 NONSHARABLE_CLASS(SharedBinaryResource1) : public MPowerInput
72 public: // from MPowerInput
76 TUint GetCount(); // gets current usage count
81 // Prototype class for Multilevel resources
83 class MSharedMultilevelResource // Multilevel Shared Input
86 virtual void IncreaseToLevel(TUint aLevel, TInt aRequester) = 0;
87 virtual void ReduceToLevel(TUint aLevel, TInt aRequester) = 0;
88 virtual TUint GetResourceLevel() = 0;
92 const TUint KSharers = 3;
94 NONSHARABLE_CLASS(SharedMultilevelResource1) : public MSharedMultilevelResource
100 // Identify all possible users of this resource
106 SharedMultilevelResource1();
107 public: // from MSharedMultilevelResource
108 void IncreaseToLevel(TUint aLevel, TInt aRequester);
109 void ReduceToLevel(TUint aLevel, TInt aRequester);
110 TUint GetResourceLevel();
112 void FindMaxLevel(TUint* aLevel, TInt* aId);
114 TUint Levels[KSharers]; // one element per user of resource
116 TInt iCurrentLevelOwnerId;
122 // The Resource Manager class
124 NONSHARABLE_CLASS(TemplateResourceManager)
127 enum TResource // a list of controllable resources (e.g clocks, voltages, power lines)
129 SynchBinResourceUsedByZOnly,
130 AsynchBinResourceUsedByZOnly,
131 // ... other non-shared binary resources, synchronous or asynchronous
132 BinResourceSharedByZAndY,
133 // ... other shared binary resources, synchronous or asynchronous
134 SynchMlResourceUsedByXOnly,
135 AsynchMlResourceUsedByXOnly,
136 // ... other non-shared multilevel resources, synchronous or asynchronous
137 MlResourceSharedByXAndW,
138 // ... other shared multilevel resources, synchronous or asynchronous
151 void InitResources(); // initialises power Resources not initialised by Bootstrap
153 inline TSleepModes MapSleepMode(TInt aSleepPeriod);
155 // interface for non-shared shared resources
157 inline void Modify(TResource aResource, TBool aOnOff); // for non-shared binary resources
158 inline void ModifyToLevel(TResource aResource, TInt aLevel); // for non-shared multilevel resources
159 // the following functions may be used by Drivers/Extensions or the Idle routine to
160 // determine what resources are On or Off or their levels
161 inline TBool GetResourceState(TResource aResource); // for non-shared binary resources
162 inline TUint GetResourceLevel(TResource aResource); // for non-shared multilevel resources
164 // interface for shared resources
166 SharedBinaryResource1 iSharedBResource1;
167 // ... other shared Binary resources, synchronous or asynchronous
168 inline SharedBinaryResource1* SharedBResource1();
170 SharedMultilevelResource1 iSharedMlResource1;
171 // ... other shared Multilevel resources
172 inline SharedMultilevelResource1* SharedMlResource1();
175 #include "template_power.inl"