os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/inc/template_power.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // template\template_variant\inc\template_power.inl
    15 // Template Power Management Inline file
    16 // -/-/-/-/-/-/-/-/-/ class TTemplatePowerController /-/-/-/-/-/-/-/-/-/
    17 // 
    18 //
    19 
    20 inline void TTemplatePowerController::RegisterPowerController(DTemplatePowerController* aPowerController)
    21 	{iPowerController = aPowerController;}
    22 
    23 //-/-/-/-/-/-/-/-/-/ class TemplateResourceManager /-/-/-/-/-/-/-/-/-/
    24 
    25 inline TemplateResourceManager::TSleepModes TemplateResourceManager::MapSleepMode(TInt aSleepPeriod)
    26 	{
    27 	//
    28 	// TO DO: (optional)
    29 	//
    30 	// Investigate what resources are On or Off, or used at what level and with the expected duration
    31 	// of Sleep map this to platform-specific Sleep mode
    32 	//
    33 	return Snooze;
    34 	}
    35 
    36 inline void TemplateResourceManager::Modify(TResource aResource, TBool aOnOff)
    37 	{
    38 	//
    39 	// TO DO: (optional)
    40 	//
    41 	// This function is used to modify non-shared binary resources 
    42 	// The following is an EXAMPLE ONLY:
    43 	//
    44 	switch(aResource)
    45 		{
    46 	case SynchBinResourceUsedByZOnly:
    47 		NKern::Lock();
    48 		//
    49 		// TO DO: (optional)
    50 		//
    51 		// Modify hardware register bit or bits to switch the resource On or Off as defined by aOnOff
    52 		// If the resource is only accessed by a driver and not from an ISR, there's no need to stop
    53 		// preemption. If it can be accessed from an ISR need to disable/enable interrupts around it.
    54 		//
    55 		NKern::Unlock();
    56 		break;
    57 
    58 	case AsynchBinResourceUsedByZOnly:
    59 		//
    60 		// TO DO: (optional)
    61 		//
    62 		// Modify hardware register bit or bits to switch the resource On or Off as defined by aOnOff
    63 		// and then wait until it has been modified.
    64 		// If the waits is only a few uS you could consider spinning, If it is considerable larger then
    65 		// you may need to use Kern::PollingWait passing a polling function, a pointer to a owning
    66 		// object a poll period in milliseconds and a maximum number of attempts. This will sleep
    67 		// the driver thread so if your driver is multithreaded and the resource can be accessed
    68 		// from more than one thread you may need to lock accesses to it with a fast Mutex.
    69 		// The completion of the change may be indicated by an interrupt: you still need to guarantee
    70 		// that the resource is not accessed until the change takes place.
    71 		//
    72 		break;
    73 	default:
    74 		break;
    75 		}
    76 	}
    77 
    78 inline void TemplateResourceManager::ModifyToLevel(TResource aResource, TInt aLevel)
    79 	{
    80 	//
    81 	// TO DO: (optional)
    82 	//
    83 	// This function is used to modify non-shared multilevel resources
    84 	// The following is an EXAMPLE ONLY:
    85 	//
    86 	switch(aResource)
    87 		{
    88 	case SynchMlResourceUsedByXOnly:
    89 		NKern::Lock();
    90 		//
    91 		// TO DO: (optional)
    92 		//
    93 		// Modify hardware register bits to set the level of the resource to aLevel
    94 		// If the resource is only accessed by a driver and not from an ISR, there's no need to stop
    95 		// preemption. If it can be accessed from an ISR need to disable/enable interrupts around it.
    96 		//
    97 		NKern::Unlock();
    98 		break;
    99 
   100 	case AsynchMlResourceUsedByXOnly:
   101 		//
   102 		// TO DO: (optional)
   103 		//
   104 		// Modify hardware register bits to set the level of the resource to aLevel
   105 		// and then wait until it has been modified.
   106 		// If the waits is only a few uS you could consider spinning, If it is considerable larger then
   107 		// you may need to use Kern::PollingWait passing a polling function, a pointer to a owning
   108 		// object a poll period in milliseconds and a maximum number of attempts. This will sleep
   109 		// the driver thread so if your driver is multithreaded and the resource can be accessed
   110 		// from more than one thread you may need to lock accesses to it with a fast Mutex.
   111 		// The completion of the change may be indicated by an interrupt: you still need to guarantee
   112 		// that the resource is not accessed until the change takes place.
   113 		//
   114 		break;
   115 	default:
   116 		break;
   117 		}
   118 	}
   119 
   120 inline TBool TemplateResourceManager::GetResourceState(TResource aResource)
   121 	{
   122 	//
   123 	// TO DO: (optional)
   124 	//
   125 	// Read from hardware (or from follower variable) and return the state of non-shared binary resource
   126 	// EXAMPLE ONLY
   127 	//
   128 	return(EFalse);
   129 	}
   130 
   131 
   132 inline TUint TemplateResourceManager::GetResourceLevel(TResource aResource)
   133 	{
   134 	//
   135 	// TO DO: (optional)
   136 	//
   137 	// Read from hardware (or from follower variable) and return the level of non-shared multilevel resource
   138 	//
   139 	// EXAMPLE ONLY
   140 	//
   141 	return(0);
   142 	}
   143 
   144 inline SharedBinaryResource1* TemplateResourceManager::SharedBResource1()
   145 	{return &iSharedBResource1;}
   146 
   147 inline SharedMultilevelResource1* TemplateResourceManager::SharedMlResource1()
   148 	{return &iSharedMlResource1;}