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