kernel/eka/include/drivers/resourceman.inl
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2007-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 // e32\include\drivers\resourceman.inl
       
    15 // 
       
    16 // WARNING: This file contains some APIs which are internal and are subject
       
    17 //          to change without noticed. Such APIs should therefore not be used
       
    18 //          outside the Kernel and Hardware Services package.
       
    19 //
       
    20 
       
    21 /**
       
    22  
       
    23  @publishedPartner
       
    24  @released 9.5
       
    25  
       
    26  Request to get the resource controller version
       
    27  
       
    28  @param aClientId	ID of the client which is requesting the resource controller version.
       
    29  @param aVersion		On Success, returns the version of PRM
       
    30  
       
    31  @return KErrNone			if successful
       
    32  KErrAccessDenied	if the client ID could not be found in the list of registered clients or
       
    33  if the client was registered to be thread relative and this API is not 
       
    34  called from the same thread.
       
    35  
       
    36  @pre Interrupts must be enabled
       
    37  @pre Kernel must be unlocked
       
    38  @pre No fast mutex can be held
       
    39  @pre Call in a thread context but not from null thread or DFC thread1
       
    40  @pre Can be used in a device driver.
       
    41 */
       
    42 inline TInt PowerResourceManager::GetResourceControllerVersion(TUint aClientId, TUint& aVersion)
       
    43 	{
       
    44 	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::ResourceControllerVersion"));
       
    45 	return ControlIO(aClientId, KResManControlIoGetVersion, (TAny*)&aVersion, NULL);
       
    46 	}
       
    47 #ifdef PRM_ENABLE_EXTENDED_VERSION
       
    48 
       
    49 /**
       
    50 @publishedPartner
       
    51 @released 9.5
       
    52 
       
    53 Request to register dynamic resource. This is also used to register dynamic resource with dependency
       
    54 
       
    55 @param aClientId	ID of the client which is requesting the dynamic resource registration.
       
    56 @param aResource	Dynamic resource to register.
       
    57 @param aResourceId	On success, updates with resource id corresponding to this resource
       
    58 
       
    59 @return KErrNone			if successful
       
    60 		KErrAccessDenied	if the client ID could not be found in the list of registered clients or
       
    61 							if the client was registered to be thread relative and this API is not 
       
    62 							called from the same thread or if ID is user side client id.
       
    63 		KErrNotSupported	if this API is called before PRM is fully intialised or if the resource ID does not
       
    64 		                    correspond to dynamic resource or dynamic resource which support depedency
       
    65 		KErrAlreadyExists	if resource is already registered.
       
    66 
       
    67 
       
    68 @pre Interrupts must be enabled
       
    69 @pre Kernel must be unlocked
       
    70 @pre No fast mutex can be held
       
    71 @pre Call in a thread context but not from null thread or DFC thread1
       
    72 @pre Can be used in a device driver.
       
    73 */
       
    74 inline TInt PowerResourceManager::RegisterDynamicResource(TUint aClientId, DDynamicPowerResource* aResource, 
       
    75 																						TUint& aResourceId)
       
    76 	{
       
    77 	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::RegisterDynamicResource"));
       
    78 	return ControlIO(aClientId, KResManControlIoRegisterDynamicResource, (TAny*)aResource, (TAny*)&aResourceId);
       
    79 	}
       
    80 
       
    81 /**
       
    82 @publishedPartner
       
    83 @released 9.5
       
    84 
       
    85 Request to deregister dynamic resource. This is also used to deregister dynamic resource with dependency
       
    86 
       
    87 @param aClientId	ID of the client which is requesting the dynamic resource deregistration.
       
    88 @param aResourceId	Id of dynamic resource to deregister.
       
    89 @param aState		Pointer to the required final state. This is optional and if left NULL, resource
       
    90 					will be moved to its default state.
       
    91 
       
    92 @return KErrNone			if successful
       
    93 		KErrAccessDenied	if the client ID could not be found in the list of registered clients or
       
    94 							if the client was registered to be thread relative and this API is not 
       
    95 							called from the same thread or if ID is user side client id or if the client
       
    96 							is not the same that registered the resource.
       
    97 		KErrNotSupported	if this API is called before PRM is fully intialised or if the resource ID does not 
       
    98 		                    correspond to dynamic resource or dynamic resource which support depedency
       
    99 		KErrNotFound		if the resource could not found in the resource list. 
       
   100 		KErrInUse			if the some other operation is in progress or if the resource is shared and
       
   101 							another client holds requirement on this resource
       
   102 
       
   103 
       
   104 @pre Interrupts must be enabled
       
   105 @pre Kernel must be unlocked
       
   106 @pre No fast mutex can be held
       
   107 @pre Call in a thread context but not from null thread or DFC thread1
       
   108 @pre Can be used in a device driver.
       
   109 */
       
   110 inline TInt PowerResourceManager::DeRegisterDynamicResource(TUint aClientId, TUint aResourceId, TInt* aState)
       
   111 	{
       
   112 	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::DeRegisterDynamicResource"));
       
   113 	return ControlIO(aClientId, KResManControlIoDeregisterDynamicResource, (TAny*)aResourceId, (TAny*)aState);
       
   114 	}
       
   115 
       
   116 /**
       
   117 @publishedPartner
       
   118 @released 9.5
       
   119 
       
   120 Request to register resource dependency. This could be between 2 dynamic resource or between
       
   121 dynamic and static resource.
       
   122 
       
   123 @param aClientId	ID of the client which is requesting the resource dependency registration.
       
   124 @param aResDependencyInfo1 Dependency information about the first resource in the dependency link.
       
   125 @param aResDependencyInfo2 Dependency information about the second resource in the dependency link.
       
   126 
       
   127 @return KErrNone			if successful
       
   128 		KErrAccessDenied	if the client ID could not be found in the list of registered clients or
       
   129 							if the client was registered to be thread relative and this API is not 
       
   130 							called from the same thread or if ID is user side client id 
       
   131 		KErrNotSupported	if any of the specified resource is not dynamic resource with depedency or 
       
   132 		                    is not dependency resource or is instantaneous
       
   133 		KErrNotFound		if any of the specified resource could not found in the resource list. 
       
   134 
       
   135 
       
   136 @pre Interrupts must be enabled
       
   137 @pre Kernel must be unlocked
       
   138 @pre No fast mutex can be held
       
   139 @pre Call in a thread context but not from null thread or DFC thread1
       
   140 @pre Can be used in a device driver.
       
   141 */
       
   142 inline TInt PowerResourceManager::RegisterResourceDependency(TUint aClientId, SResourceDependencyInfo* aResDependencyInfo1, 
       
   143 																			SResourceDependencyInfo* aResDependencyInfo2)
       
   144 	{
       
   145 	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::RegisterResourceDependency"));
       
   146 	return ControlIO(aClientId, KResManControlIoRegisterDependency, (TAny*)aResDependencyInfo1, (TAny*)aResDependencyInfo2);
       
   147 	}
       
   148 
       
   149 /**
       
   150 @publishedPartner
       
   151 @released 9.5
       
   152 
       
   153 Request to deregister resource dependency.
       
   154  
       
   155 @param aClientId	ID of the client which is requesting the resource dependency deregistration.
       
   156 @param aResId1 Id of the first resource in the dependency link that is being deregistered.
       
   157 @param aResId2 Id of the second resource in the dependency link that is being deregistered.
       
   158 
       
   159 @return KErrNone			if successful
       
   160 		KErrAccessDenied	if the client ID could not be found in the list of registered clients or
       
   161 							if the client was registered to be thread relative and this API is not 
       
   162 							called from the same thread or if ID is user side client id 
       
   163 							or if any of the specified resource does not support dependency.
       
   164 		KErrNotFound		if any of the specified resource could not found in the resource list or 
       
   165 		                    dependency link does not exist between the specified resources.
       
   166 
       
   167 @pre Interrupts must be enabled
       
   168 @pre Kernel must be unlocked
       
   169 @pre No fast mutex can be held
       
   170 @pre Call in a thread context but not from null thread or DFC thread1
       
   171 @pre Can be used in a device driver.
       
   172 */
       
   173 inline TInt PowerResourceManager::DeRegisterResourceDependency(TUint aClientId, TUint aResourceId1, TUint aResourceId2)
       
   174 	{
       
   175 	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::DeRegisterResourceDependency"));
       
   176 	return ControlIO(aClientId, KResManControlIoDeregisterDependency, (TAny*)aResourceId1, (TAny*)aResourceId2);
       
   177 	}
       
   178 
       
   179 /**
       
   180 @internalComponent
       
   181 @released 9.5
       
   182 
       
   183 Request to update with number of dependent resources for the specified resource. 
       
   184 
       
   185 @param aResourceId Id of the resource whose number of dependents is requested
       
   186 @param aNumDepResources On success will be updated with number of dependent resources.
       
   187 
       
   188 @return KErrNone			if successful
       
   189 		KErrAccessDenied	if the client ID could not be found in the list of registered clients or
       
   190 							if the client was registered to be thread relative and this API is not 
       
   191 							called from the same thread or if ID is user side client id 
       
   192 		KErrNotSupported	if this API is called before PRM is fully intialised or if the resource ID 
       
   193 		                    does not correspond to dependency resource 
       
   194 		KErrNotFound		if the resource could not be found in the resource list. 
       
   195 
       
   196 @pre Interrupts must be enabled
       
   197 @pre Kernel must be unlocked
       
   198 @pre No fast mutex can be held
       
   199 @pre Call in a thread context but not from null thread or DFC thread1
       
   200 @pre Can be used in a device driver.
       
   201 */
       
   202 inline TInt PowerResourceManager::GetNumDependentsForResource(TUint aClientId, TUint aResourceId, TUint& aNumDepResource)
       
   203 	{
       
   204 	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::GetNumDependentsForResource"));
       
   205 	return ControlIO(aClientId, KResManControlIoGetNumDependents, (TAny*)aResourceId, (TAny*)&aNumDepResource);
       
   206 	}
       
   207 
       
   208 /**
       
   209 @internalComponent
       
   210 @released 9.5
       
   211 
       
   212 Request to update the specified array with dependent resource Id's of the specified resource. 
       
   213 
       
   214 @param aResourceId Id of the resource whose dependent resource Id's are requested.
       
   215 @param aResIdArray On success array will be updated with the dependent resource information. Client need to 
       
   216 					create the array in kernel heap or data space.
       
   217 @param aNumDepResources Specifies the size of array. On success, updated with actual number of dependent resources.
       
   218 
       
   219 @return KErrNone			if successful
       
   220 		KErrAccessDenied	if the client ID could not be found in the list of registered clients or
       
   221 							if the client was registered to be thread relative and this API is not 
       
   222 							called from the same thread or if ID is user side client id 
       
   223 		KErrNotSupported	if this API is called before PRM is fully initialised or if the resource ID 
       
   224 		                    does not correspond to dependency resource 
       
   225 		KErrNotFound		if the resource could not be found in the resource list. 
       
   226 		KErrArgument		if passed array is null or pass dependent resource number is 0.
       
   227 
       
   228 @pre Interrupts must be enabled
       
   229 @pre Kernel must be unlocked
       
   230 @pre No fast mutex can be held
       
   231 @pre Call in a thread context but not from null thread or DFC thread1
       
   232 @pre Can be used in a device driver.
       
   233 */
       
   234 inline TInt PowerResourceManager::GetDependentsIdForResource(TUint aClientId, TUint aResourceId, TAny* aResIdArray, 
       
   235 																							TUint& aNumDepResources)
       
   236 	{
       
   237 	__KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::GetDependentsIdForResource"));
       
   238 	return ControlIO(aClientId, KResManControlIoGetDependentsId, (TAny*)aResourceId, (TAny*)aResIdArray, 
       
   239 																							(TAny*)&aNumDepResources);
       
   240 	}
       
   241 
       
   242 #endif