sl@0: // Copyright (c) 1998-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: // template\template_variant\inc\template_power.inl sl@0: // Template Power Management Inline file sl@0: // -/-/-/-/-/-/-/-/-/ class TTemplatePowerController /-/-/-/-/-/-/-/-/-/ sl@0: // sl@0: // sl@0: sl@0: inline void TTemplatePowerController::RegisterPowerController(DTemplatePowerController* aPowerController) sl@0: {iPowerController = aPowerController;} sl@0: sl@0: //-/-/-/-/-/-/-/-/-/ class TemplateResourceManager /-/-/-/-/-/-/-/-/-/ sl@0: sl@0: inline TemplateResourceManager::TSleepModes TemplateResourceManager::MapSleepMode(TInt aSleepPeriod) sl@0: { sl@0: // sl@0: // TO DO: (optional) sl@0: // sl@0: // Investigate what resources are On or Off, or used at what level and with the expected duration sl@0: // of Sleep map this to platform-specific Sleep mode sl@0: // sl@0: return Snooze; sl@0: } sl@0: sl@0: inline void TemplateResourceManager::Modify(TResource aResource, TBool aOnOff) sl@0: { sl@0: // sl@0: // TO DO: (optional) sl@0: // sl@0: // This function is used to modify non-shared binary resources sl@0: // The following is an EXAMPLE ONLY: sl@0: // sl@0: switch(aResource) sl@0: { sl@0: case SynchBinResourceUsedByZOnly: sl@0: NKern::Lock(); sl@0: // sl@0: // TO DO: (optional) sl@0: // sl@0: // Modify hardware register bit or bits to switch the resource On or Off as defined by aOnOff sl@0: // If the resource is only accessed by a driver and not from an ISR, there's no need to stop sl@0: // preemption. If it can be accessed from an ISR need to disable/enable interrupts around it. sl@0: // sl@0: NKern::Unlock(); sl@0: break; sl@0: sl@0: case AsynchBinResourceUsedByZOnly: sl@0: // sl@0: // TO DO: (optional) sl@0: // sl@0: // Modify hardware register bit or bits to switch the resource On or Off as defined by aOnOff sl@0: // and then wait until it has been modified. sl@0: // If the waits is only a few uS you could consider spinning, If it is considerable larger then sl@0: // you may need to use Kern::PollingWait passing a polling function, a pointer to a owning sl@0: // object a poll period in milliseconds and a maximum number of attempts. This will sleep sl@0: // the driver thread so if your driver is multithreaded and the resource can be accessed sl@0: // from more than one thread you may need to lock accesses to it with a fast Mutex. sl@0: // The completion of the change may be indicated by an interrupt: you still need to guarantee sl@0: // that the resource is not accessed until the change takes place. sl@0: // sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: } sl@0: sl@0: inline void TemplateResourceManager::ModifyToLevel(TResource aResource, TInt aLevel) sl@0: { sl@0: // sl@0: // TO DO: (optional) sl@0: // sl@0: // This function is used to modify non-shared multilevel resources sl@0: // The following is an EXAMPLE ONLY: sl@0: // sl@0: switch(aResource) sl@0: { sl@0: case SynchMlResourceUsedByXOnly: sl@0: NKern::Lock(); sl@0: // sl@0: // TO DO: (optional) sl@0: // sl@0: // Modify hardware register bits to set the level of the resource to aLevel sl@0: // If the resource is only accessed by a driver and not from an ISR, there's no need to stop sl@0: // preemption. If it can be accessed from an ISR need to disable/enable interrupts around it. sl@0: // sl@0: NKern::Unlock(); sl@0: break; sl@0: sl@0: case AsynchMlResourceUsedByXOnly: sl@0: // sl@0: // TO DO: (optional) sl@0: // sl@0: // Modify hardware register bits to set the level of the resource to aLevel sl@0: // and then wait until it has been modified. sl@0: // If the waits is only a few uS you could consider spinning, If it is considerable larger then sl@0: // you may need to use Kern::PollingWait passing a polling function, a pointer to a owning sl@0: // object a poll period in milliseconds and a maximum number of attempts. This will sleep sl@0: // the driver thread so if your driver is multithreaded and the resource can be accessed sl@0: // from more than one thread you may need to lock accesses to it with a fast Mutex. sl@0: // The completion of the change may be indicated by an interrupt: you still need to guarantee sl@0: // that the resource is not accessed until the change takes place. sl@0: // sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: } sl@0: sl@0: inline TBool TemplateResourceManager::GetResourceState(TResource aResource) sl@0: { sl@0: // sl@0: // TO DO: (optional) sl@0: // sl@0: // Read from hardware (or from follower variable) and return the state of non-shared binary resource sl@0: // EXAMPLE ONLY sl@0: // sl@0: return(EFalse); sl@0: } sl@0: sl@0: sl@0: inline TUint TemplateResourceManager::GetResourceLevel(TResource aResource) sl@0: { sl@0: // sl@0: // TO DO: (optional) sl@0: // sl@0: // Read from hardware (or from follower variable) and return the level of non-shared multilevel resource sl@0: // sl@0: // EXAMPLE ONLY sl@0: // sl@0: return(0); sl@0: } sl@0: sl@0: inline SharedBinaryResource1* TemplateResourceManager::SharedBResource1() sl@0: {return &iSharedBResource1;} sl@0: sl@0: inline SharedMultilevelResource1* TemplateResourceManager::SharedMlResource1() sl@0: {return &iSharedMlResource1;}