os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/inc/template_power.inl
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/inc/template_power.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,148 @@
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.inl
1.18 +// Template Power Management Inline file
1.19 +// -/-/-/-/-/-/-/-/-/ class TTemplatePowerController /-/-/-/-/-/-/-/-/-/
1.20 +//
1.21 +//
1.22 +
1.23 +inline void TTemplatePowerController::RegisterPowerController(DTemplatePowerController* aPowerController)
1.24 + {iPowerController = aPowerController;}
1.25 +
1.26 +//-/-/-/-/-/-/-/-/-/ class TemplateResourceManager /-/-/-/-/-/-/-/-/-/
1.27 +
1.28 +inline TemplateResourceManager::TSleepModes TemplateResourceManager::MapSleepMode(TInt aSleepPeriod)
1.29 + {
1.30 + //
1.31 + // TO DO: (optional)
1.32 + //
1.33 + // Investigate what resources are On or Off, or used at what level and with the expected duration
1.34 + // of Sleep map this to platform-specific Sleep mode
1.35 + //
1.36 + return Snooze;
1.37 + }
1.38 +
1.39 +inline void TemplateResourceManager::Modify(TResource aResource, TBool aOnOff)
1.40 + {
1.41 + //
1.42 + // TO DO: (optional)
1.43 + //
1.44 + // This function is used to modify non-shared binary resources
1.45 + // The following is an EXAMPLE ONLY:
1.46 + //
1.47 + switch(aResource)
1.48 + {
1.49 + case SynchBinResourceUsedByZOnly:
1.50 + NKern::Lock();
1.51 + //
1.52 + // TO DO: (optional)
1.53 + //
1.54 + // Modify hardware register bit or bits to switch the resource On or Off as defined by aOnOff
1.55 + // If the resource is only accessed by a driver and not from an ISR, there's no need to stop
1.56 + // preemption. If it can be accessed from an ISR need to disable/enable interrupts around it.
1.57 + //
1.58 + NKern::Unlock();
1.59 + break;
1.60 +
1.61 + case AsynchBinResourceUsedByZOnly:
1.62 + //
1.63 + // TO DO: (optional)
1.64 + //
1.65 + // Modify hardware register bit or bits to switch the resource On or Off as defined by aOnOff
1.66 + // and then wait until it has been modified.
1.67 + // If the waits is only a few uS you could consider spinning, If it is considerable larger then
1.68 + // you may need to use Kern::PollingWait passing a polling function, a pointer to a owning
1.69 + // object a poll period in milliseconds and a maximum number of attempts. This will sleep
1.70 + // the driver thread so if your driver is multithreaded and the resource can be accessed
1.71 + // from more than one thread you may need to lock accesses to it with a fast Mutex.
1.72 + // The completion of the change may be indicated by an interrupt: you still need to guarantee
1.73 + // that the resource is not accessed until the change takes place.
1.74 + //
1.75 + break;
1.76 + default:
1.77 + break;
1.78 + }
1.79 + }
1.80 +
1.81 +inline void TemplateResourceManager::ModifyToLevel(TResource aResource, TInt aLevel)
1.82 + {
1.83 + //
1.84 + // TO DO: (optional)
1.85 + //
1.86 + // This function is used to modify non-shared multilevel resources
1.87 + // The following is an EXAMPLE ONLY:
1.88 + //
1.89 + switch(aResource)
1.90 + {
1.91 + case SynchMlResourceUsedByXOnly:
1.92 + NKern::Lock();
1.93 + //
1.94 + // TO DO: (optional)
1.95 + //
1.96 + // Modify hardware register bits to set the level of the resource to aLevel
1.97 + // If the resource is only accessed by a driver and not from an ISR, there's no need to stop
1.98 + // preemption. If it can be accessed from an ISR need to disable/enable interrupts around it.
1.99 + //
1.100 + NKern::Unlock();
1.101 + break;
1.102 +
1.103 + case AsynchMlResourceUsedByXOnly:
1.104 + //
1.105 + // TO DO: (optional)
1.106 + //
1.107 + // Modify hardware register bits to set the level of the resource to aLevel
1.108 + // and then wait until it has been modified.
1.109 + // If the waits is only a few uS you could consider spinning, If it is considerable larger then
1.110 + // you may need to use Kern::PollingWait passing a polling function, a pointer to a owning
1.111 + // object a poll period in milliseconds and a maximum number of attempts. This will sleep
1.112 + // the driver thread so if your driver is multithreaded and the resource can be accessed
1.113 + // from more than one thread you may need to lock accesses to it with a fast Mutex.
1.114 + // The completion of the change may be indicated by an interrupt: you still need to guarantee
1.115 + // that the resource is not accessed until the change takes place.
1.116 + //
1.117 + break;
1.118 + default:
1.119 + break;
1.120 + }
1.121 + }
1.122 +
1.123 +inline TBool TemplateResourceManager::GetResourceState(TResource aResource)
1.124 + {
1.125 + //
1.126 + // TO DO: (optional)
1.127 + //
1.128 + // Read from hardware (or from follower variable) and return the state of non-shared binary resource
1.129 + // EXAMPLE ONLY
1.130 + //
1.131 + return(EFalse);
1.132 + }
1.133 +
1.134 +
1.135 +inline TUint TemplateResourceManager::GetResourceLevel(TResource aResource)
1.136 + {
1.137 + //
1.138 + // TO DO: (optional)
1.139 + //
1.140 + // Read from hardware (or from follower variable) and return the level of non-shared multilevel resource
1.141 + //
1.142 + // EXAMPLE ONLY
1.143 + //
1.144 + return(0);
1.145 + }
1.146 +
1.147 +inline SharedBinaryResource1* TemplateResourceManager::SharedBResource1()
1.148 + {return &iSharedBResource1;}
1.149 +
1.150 +inline SharedMultilevelResource1* TemplateResourceManager::SharedMlResource1()
1.151 + {return &iSharedMlResource1;}