Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\drivers\resourceman\resourceman.cpp
18 #include <drivers/resourcecontrol.h>
19 #include <drivers/resourceman.h>
24 Register a client with the resource manager
26 @param aClientId A reference to a client ID: returns a unique handle if registration was
27 successful, 0 otherwise.
28 @param aName Descriptor with name for client. The descriptor is created by the client
29 in kernel heap or in kernel stack.
30 NOTE: Name should ideally relate to component name and should take care
31 of name uniqueness as this is not checked by resource manager unless
32 DEBUG_VERSION macro is enabled.
33 @param aType Defines ownership
34 EOwnerProcess - The client ID can be used by all thread in the process to
35 call the resource manager API's
36 EOwnerThread - The client ID can only be used by the thread that registered
37 the client to resource manager to call the PRM API's
38 By default this is set to EOwnerProcess.
40 @return KErrNone if the operation was successful,
41 KErrNoMemory if a new client link was needed but could not be created and
42 added to the client list,
43 KErrTooBig if the length of the descriptor passed is greater than 32.
44 KErrAlreadyExists if the specified name already exists. This is valid only if
45 DEBUG_VERSION macro is enabled.
46 KErrNotSupported if the number of expected kernel side clients is set to zero
47 by PSL during initialisation.
49 @pre Interrupts must be enabled.
50 @pre Kernel must be unlocked.
51 @pre No fast mutex can be held.
52 @pre Call in a thread context, but not from null thread or DFC thread1.
53 @pre Can be used in a device driver
55 EXPORT_C TInt PowerResourceManager::RegisterClient(TUint& aClientId, const TDesC8& aName, TOwnerType aType)
57 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::RegisterClient"));
58 __KTRACE_OPT(KRESMANAGER, Kern::Printf("Client Name %S", &aName));
59 __KTRACE_OPT(KRESMANAGER, Kern::Printf("OwnerType %d", aType));
60 return TInterface::RegisterClient(aClientId, aName, aType);
67 Deregister a client with the resource manager
69 @param aClientId The ID of the client which is being deregistered
71 @return KErrNone if the operation was successful
72 KErrNotFound if this client ID could not be found in the current
74 KErrArgument if user side client ID is specified or client ID to be used
75 by Power Controller is specified.
76 KErrAccessDenied if client was registered to be thread relative and this API
77 is not called from the same thread.
80 @pre Interrupts must be enabled
81 @pre Kernel must be unlocked
82 @pre No fast mutex can be held
83 @pre Call in a thread context but not from null thread or DFC thread1
84 @pre Can be used in a device driver
86 EXPORT_C TInt PowerResourceManager::DeRegisterClient(TUint aClientId)
88 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::DeRegisterClient"));
89 __KTRACE_OPT(KRESMANAGER, Kern::Printf("Client ID %d", aClientId));
90 return TInterface::DeRegisterClient(aClientId);
97 Obtain the name of a registered client of the resource manager
99 @param aClientId The ID of the client which is requesting the name of
100 another client whose ID is specified in aTargetClientId.
101 @param aTargetClientId The ID of the client whose name is being requested.
102 @param aName Descriptor to be filled with the name of the client.
103 The descriptor is created by the client in kernel stack or heap.
105 @return KErrNone if the operation was successful
106 KErrNotFound if this client ID (aTargetClientId) could not be
107 found in the current list of registered clients.
108 KErrAccessDenied if the client ID (aClientId) could not be found
109 in the current list of registered clients or if the client was
110 registered to be thread relative and this API is not called from
113 @pre Interrupts must be enabled
114 @pre Kernel must be unlocked
115 @pre No fast mutex can be held
116 @pre Call in a thread context but not from null thread or DFC thread1
117 @pre Can be used in a device driver
119 EXPORT_C TInt PowerResourceManager::GetClientName(TUint aClientId, TUint aTargetClientId, TDes8&
122 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::GetClientName"));
123 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
124 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aTargetClientId 0x%08x", aTargetClientId));
125 return TInterface::GetClientName(aClientId, aTargetClientId, aName);
132 Obtain the Id of registered client of the resource manager
134 @param aClientId ID of the client which is requesting the ID of the another
135 client whose name is specified in aClientName
136 @param aClientName Descriptor containing the name of the client whose ID is being
137 requested. The client must create the descriptor in kernel stack
139 NOTE: Resource manager does not check for uniqueness of client
140 name during registration, so if there are multiple clients registered
141 to PRM with same name it will return the ID of the first client encountered
142 with the specified name (order is not guaranteed).
143 @param aTargetClientId Updates with ID of the requested client on success
145 @return KErrNone if the operation was successful
146 KErrNotFound if this client name could not be found in the current list
147 of registered client.
148 KErrAccessDenied if the client ID (aClientId) could not be found in the current
149 list of registered client or if the client was registered to
150 be thread relative and this API is not called from the same thread.
151 KErrTooBig if the length of the descriptor passed is greater than 32.
153 @pre Interrupts must be enabled
154 @pre Kernel must be unlocked
155 @pre No fast mutex can be held
156 @pre Call in a thread context but not from null thread or DFC thread1
157 @pre Can be used in a device driver
159 EXPORT_C TInt PowerResourceManager::GetClientId(TUint aClientId, TDesC8& aClientName, TUint& aTargetClientId)
161 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::GetClientId"));
162 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
163 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientName %S", &aClientName));
164 return TInterface::GetClientId(aClientId, aClientName, aTargetClientId);
171 Obtain the ID of registered resource of the resource manager.
172 NOTE: ID of the first matching name found in the resource list will be returned
174 @param aClientId ID of the client which is requesting the ID of the
175 resource, by specifying its name.
176 @param aResourceName Descriptor containing the name of the resource whose
177 ID is being requested.The client must create descriptor in
178 kernel stack or heap.
179 @param aResourceId Updates with ID of the requested resource on success
181 @return KErrNone if the operation was successful
182 KErrAccessDenied if the ID of the client could not be found in the
183 current list of registered clients or if the client was
184 registered to be thread relative and this API is not called
185 from the same thread.
186 KErrNotFound if this resource name could not be found in the current
187 list of registered resources.
188 KErrTooBig if the length of the descriptor passed is greater than 32.
190 @pre Interrupts must be enabled
191 @pre Kernel must be unlocked
192 @pre No fast mutex can be held
193 @pre Call in a thread context but not from null thread or DFC thread1
194 @pre Can be used in a device driver
196 EXPORT_C TInt PowerResourceManager::GetResourceId(TUint aClientId, TDesC8& aResourceName, TUint& aResourceId)
198 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::GetResourceId"));
199 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
200 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aResourceName %S", &aResourceName));
201 return TInterface::GetResourceId(aClientId, aResourceName, aResourceId);
208 Request a structure containing information on a resource.
210 @param aClientId ID of the client which is requesting the resource information
211 @param aResourceId ID of the resource whose information is being requested.
212 @param aInfo A pointer to descriptor containing resource information
213 structure (TPowerResourceInfoV01) to be filled in
214 with the requested resource information. The client must
215 create the descriptor in kernel stack or heap.
217 @return KErrNone if the operation was successful
218 KErrAccessDenied if the client ID could not be found in the current list
219 of registered clients or if the client was registered to be
220 thread relative and this API is not called from the same thread.
221 KErrNotFound if this resource ID could not be found in the current list
222 of controllable resource.
223 KErrArgument if aInfo is NULL or size of descriptor passed is less than size of
224 TPowerResourceInfoV01.
226 @pre Interrupts must be enabled
227 @pre Kernel must be unlocked
228 @pre No fast mutex can be held
229 @pre Call in a thread context but not from null thread or DFC thread1
230 @pre Can be used in a device driver
232 EXPORT_C TInt PowerResourceManager::GetResourceInfo(TUint aClientId, TUint aResourceId, TAny* aInfo)
234 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::GetResourceInfo"));
235 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
236 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aResourceId 0x%08x", aResourceId));
237 return TInterface::GetResourceInfo(aClientId, aResourceId, aInfo);
245 Request number of resources that the specified client (aTargetClientId) has
246 requirement on resource level. Client ID starts from 1, so if 0 is specified in
247 aTargetClientId, returns the total number of controllable resources registered with PRM.
249 @param aClientId ID of the client that is requesting the number of resources for which
250 the specified client (aTargetClientId) holds requirement on the
251 resource level change.
252 @param aTargetClientId ID of the client for which the number of resources that it
253 has requested a level on is to be returned.
254 @param aNumResource Updated with the number of resources that the specified client
255 has requirement on resource level change, if valid client
256 ID is passed. If client ID is 0, updates the total number
257 of resources registered with resource manager.
259 @return KErrNone if the operation was successful.
260 KErrAccessDenied if the client ID (aClientId) could not be found in the
261 current list of registered clients or if the client was registered
262 to be thread relative and this API is not called from the same thread.
263 KErrNotFound if the client ID (aTargetClientId) could not be found in the
264 current list of registered clients and is not 0.
266 @pre Interrupts must be enabled
267 @pre Kernel must be unlocked
268 @pre No fast mutex can be held
269 @pre Call in a thread context but not from null thread or DFC thread1
270 @pre Can be used in a device driver
272 EXPORT_C TInt PowerResourceManager::GetNumResourcesInUseByClient(TUint aClientId, TUint aTargetClientId,
275 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::GetNumResourcesInUseByClient"));
276 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
277 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aTargetClientId 0x%08x", aTargetClientId));
278 return TInterface::GetNumResourcesInUseByClient(aClientId, aTargetClientId, aNumResource);
285 Request information on resources.
286 If client ID (aTargetClientId) is valid, aInfo is updated with the information
287 of the resources that this client requested a resource level.
288 If client ID (aTargetClientId) is 0, aInfo is updated with the information of all the resources
289 registered with resource controller.
290 The number of resources for which information will be provided will be equal or less than
291 the number specified in aNumResources.
293 @param aClientId ID of the client which is requesting the resource information.
294 @param aTargetClientId ID of the client. The information of all the resources on
295 which it has requirement on resource level change is requested.
296 Client ID starts from 1, so calling this API with client ID 0 will
297 fill the details of all the controllable resource registered with
298 resource manager starting from resource ID 1.
299 @param aNumResources Number of resource whose information needs to be filled in aInfo i.e,
300 it specifies the size of aInfo array.
301 @param aInfo A pointer to an array of descriptor containing an information structure
302 (TPowerResourceInfoV01) to be filled in with the information
303 on the resources. It will be assumed that array allocated will be equal
304 to the number passed in aNumResources. The client must create the array
305 in Kernel stack or heap.
307 @return KErrNone if the operation was successful
308 KErrAccessDenied if client ID (aClientId) could not be found in the registered
309 client list or if the client was registered to be thread relative
310 and this API is not called from the same thread.
311 KErrNotFound if client ID (aTargetClientId) could not be found in the current list
312 of registered client and is also not 0.
313 KErrArgument if aNumResources is 0 or aInfo is NULL or if size of aInfo is not
314 sufficient to hold the resource information of number of resources
315 specified in aNumResource.
317 @pre Interrupts must be enabled
318 @pre Kernel must be unlocked
319 @pre No fast mutex can be held
320 @pre Call in a thread context but not from null thread or DFC thread1
321 @pre Can be used in a device driver
323 EXPORT_C TInt PowerResourceManager::GetInfoOnResourcesInUseByClient(TUint aClientId, TUint aTargetClientId,
324 TUint& aNumResource, TAny* aInfo)
326 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::GetInfoOnResourcesInUseByClient"));
327 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
328 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aTargetClientId 0x%08x", aTargetClientId));
329 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aNumResource 0x%08x", aNumResource));
330 return TInterface::GetInfoOnResourcesInUseByClient(aClientId, aTargetClientId, aNumResource, aInfo);
337 Request number of clients which has requirements on the resource level change of the specified
338 resource. Resource ID starts from 1, so 0 can be used to get the number of clients
339 registered with resource manager.
341 @param aClientId ID of the client which is requesting number of clients
342 holding requirement on specified resource.
343 @param aResourceId ID of the resource.
344 @param aNumClient Upon success, updated with number of clients having a requirement
345 on resource level for the specified resource, if valid resource ID is specified.
346 If resource ID is 0, then it is updated with number of clients
349 @return KErrNone if the operation was successful
350 KErrAccessDenied if the client ID could not found in the current list of
351 registered clients or if the client was registered to be thread
352 relative and this API is not called from the same thread.
353 KErrNotFound If this resource ID could not be found in the current list
354 of registered resource and is also not 0.
356 @pre Interrupts must be enabled
357 @pre Kernel must be unlocked
358 @pre No fast mutex can be held
359 @pre Call in a thread context but not from null thread or DFC thread1
360 @pre Can be used in a device driver
362 EXPORT_C TInt PowerResourceManager::GetNumClientsUsingResource(TUint aClientId, TUint aResourceId, TUint& aNumClients)
364 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::GetNumClientsUsingResource"));
365 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
366 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aResourceId 0x%08x", aResourceId));
367 return TInterface::GetNumClientsUsingResource(aClientId, aResourceId, aNumClients);
374 Request information on clients
375 If resource ID is valid, aInfo is updated with the information of the clients
376 which have a requirements on the resource level for the specified resource
377 If resource ID is 0, aInfo is updated with the information of the clients registered
378 with resource manager, starting from client ID 1.
379 The number of clients for which information will be provided will be equal to or less
380 than the number specified in a NumClients.
382 @param aClientId ID of the client which is requesting the information
383 @param aResourceId Id of the resource.
384 @param aNumClients Number of clients whose information needs to be filled in aInfo
385 ie, it specifies the size of aInfo array.
386 @param aInfo A pointer to an array of descriptor containing an information
387 structure (TPowerClientInfoV01) to be filled in with
388 the information on the client. It will be assumed that array
389 allocated will be equal to the number passed in aNumClients.
390 The Client must create the array of descriptors in kernel stack
393 @return KErrNone if the operation was successful.
394 KErrNotFound if resource ID could not be found in the registered resource list and is
396 KErrAccessDenied if client ID (aClientId) could not be found in the registered client list
397 or if the client was registered to be thread relative and this API is not
398 called from the same thread.
399 KErrArgument if aNumClients is 0 or aInfo is NULL or if size of aInfo is not sufficient
400 to hold client information of specified client number in aNumClients.
402 @pre Interrupts must be enabled
403 @pre Kernel must be unlocked
404 @pre No fast mutex can be held
405 @pre Call in a thread context but not from null thread or DFC thread1
406 @pre Can be used in a device driver
408 EXPORT_C TInt PowerResourceManager::GetInfoOnClientsUsingResource(TUint aClientId, TUint aResourceId,
409 TUint& aNumClients, TAny* aInfo)
411 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::GetInfoOnClientsUsingResource"));
412 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
413 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aResourceId 0x%08x", aResourceId));
414 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aNumClients 0x%08x", aNumClients));
415 return TInterface::GetInfoOnClientsUsingResource(aClientId, aResourceId, aNumClients, aInfo);
422 Request changing the state of a resource
423 NOTE: If a resource callback is specified for instantaneous resource, then callback
424 will be called after resource change and will be executed in the context of the
426 If a resource callback is specified for long latency reosurces, then it will be
427 executed asynchronously.
428 When the request is accepted the API returns immediately and the calling thread
429 is unblocked: the callback (called in the client's context) will be invoked when
430 the resource change finally takes place.
431 If aCb is not specified (NULL by default) the API executes synchronously and will
432 only return when the resource change has taken place for long latency resource.
433 The client thread is blocked throughout
434 When state change for a shared resource is requested, only minimum state that
435 satisfy the requirement is guaranteed and it is not guaranteed for the absolute
438 @param aClientId ID of the client which is requesting the resource change.
439 @param aResourceId ID of the resource whose state is to be changed.
440 @param aNewState The new state of the resource. This could be a binary value for a
441 binary resource, an integer level for a multilevel resource or some
442 platform specific token for a multi-property resource.
443 @param aCb For Long latency resource
444 A pointer to a resource callback object which encapsulates a
445 callback function to be called whenever the resource state change
446 happens (if left NULL the API will execute synchrounously).
447 For Instantaneous resource
448 A pointer to a resource callback object which encapsulates a callback
449 function to be called after resource change. This executes in the
450 context of the client thread.
452 @return KErrNone If the API is to be executed synchronously it indicates the change was
453 successful, if the API is to be executed asynchronously it indicates
454 the request to change the resource state has been accepted.
455 KErrNotFound if the resource ID could not be found in the current list of
456 controllable resources.
457 KErrAccessDenied if the client ID could not be found in the list of
458 registered clients or if the client was registered to be thread
459 relative and this API is not called from the same thread.
460 KErrNotReady if the request is issued before the resource controller completes its
461 internal initialisation.
462 KErrUnderflow if the client has exceeded the reserved number of
463 SPowerResourceClientLevel and the free pool is empty or if it is
464 an asynchronous operation on long latency resource and the client has exceeded
465 the reserved number of TPowerRequest and the free pool is empty.
466 KErrArgument if requested level is out of range (outside of min and max levels)
467 KErrPermissionDenied if the requested state of the resource is not accepted by its dependents.
468 This error is valid only for dependent resource state change in extened
471 @pre Interrupts must be enabled
472 @pre Kernel must be unlocked
473 @pre No fast mutex can be held
474 @pre Call in a thread context but not from null thread or DFC thread1
475 @pre Can be used in a device driver
476 @pre Do not call synchronous version from DFC thread 0 for long latency resource
478 EXPORT_C TInt PowerResourceManager::ChangeResourceState(TUint aClientId , TUint aResourceId,
479 TInt aNewState, TPowerResourceCb* aCb)
481 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::ChangeResourceState"));
482 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
483 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aResourceId 0x%08x", aResourceId));
484 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aNewState 0x%08x", aNewState));
485 return TInterface::ChangeResourceState(aClientId, aResourceId, aNewState, aCb);
492 Request the state of the resource synchronously. Client thread will be blocked throughout.
494 @param aClientId ID of the client which is requesting the resource state.
495 @param aResourceId ID of the resource whose state is being requested.
496 @param aCached If ETrue, cached value will be updated in aState.
497 If EFalse, aState will be updated after the resource
498 state is read from resource.
499 @param aState Returns the resource state if operation was successful. This
500 could be a binary value for a binary resource, an integer level
501 for a multilevel resource or some platform specific tolen for a
502 multi-property resource.
503 @param aLevelOwnerId Returns the Id of the client that is currently the owner of the resource.
504 -1 is returned when no client is owner of the resource.
506 @return KErrNone if operation was successful
507 KErrAccessDenied if the client ID could not be found in the current list
508 of registered clients or if the client was registered to be thread
509 relative and this API is not called from the same thread.
510 KErrNotFound if this resource ID could not be found in the current list
511 of controllable resources.
512 KErrNotReady if the request is issued before the resource controller completes
513 its internal initialization.
515 @pre Interrupts must be enabled
516 @pre Kernel must be unlocked
517 @pre No fast mutex can be held
518 @pre Call in a thread context but not from null thread or DFC thread1
519 @pre Can be used in a device driver
520 @pre Do not call from DFC thread 0 for long latency resource with caching disabled.
522 EXPORT_C TInt PowerResourceManager::GetResourceState(TUint aClientId, TUint aResourceId, TBool aCached,
523 TInt& aState, TInt& aLevelOwnerId)
525 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::GetResourceState"));
526 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
527 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aResourceId 0x%08x", aResourceId));
528 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aCached 0x%08x", aCached));
529 return TInterface::GetResourceState(aClientId, aResourceId, aCached, aState, aLevelOwnerId);
536 Request the state of the resource asynchrounously.
538 @param aClientId ID of the client which is requesting the resource state.
539 @param aResourceId ID of the resource whose state is being requested.
540 @param aCached If ETrue, cached value will be updated in aState
541 If EFalse, will be updated after the resource state is read from resource
542 @param aCb For long latency resource:
543 A pointer to a resource callback object which encapsulates a callback function
544 to be called whenever the state of the resource is available for the long
545 latency resource (executes in the context of resource manager)
546 For instantaneous resource:
547 A pointer to a resource callback object which encapsulates a callback
548 function to be called after the resource state is read. This is executed
549 synchronously in the context of the calling thread.
550 NOTE: The client must create the callback object in kernel heap or
553 @return KErrNone if the operation was successful
554 KErrAccessDenied if the client ID could not be found in the current list
555 of registered clients or if the client was registered to be
556 thread relative and this API is not called from the same thread.
557 KErrNotFound if this resource ID could not be found in the current list
558 of controllable resources.
559 KErrNotReady if the request is issued before the resource controller completes
560 its internal initialisation
561 KErrUnderflow if the client has exceeded the reserved number of TPowerRequest
562 and the TPowerRequest free pool is empty for long latency resource.
563 KErrArgument if callback object is NULL.
565 @pre Interrupts must be enabled
566 @pre Kernel must be unlocked
567 @pre No fast mutex can be held
568 @pre Call in a thread context but not from null thread or DFC thread1
569 @pre Can be used in a device driver
571 EXPORT_C TInt PowerResourceManager::GetResourceState(TUint aClientId, TUint aResourceId, TBool aCached, TPowerResourceCb& aCb)
573 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::GetResourceState"));
574 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
575 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aResourceId 0x%08x", aResourceId));
576 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aCached 0x%08x", aCached));
577 return TInterface::GetResourceState(aClientId, aResourceId, aCached, aCb);
584 Cancel an asynchronous request(or its callback).
586 @param aClientId ID of the client which is requesting the cancellation of the request.
587 @param aResourceId ID for the resource which the request that is being cancelled operates
589 @param aCb A reference to the resource callback object specified with the request
590 that is being cancelled.
592 @return KErrCancel if the request was cancelled.
593 KErrNotFound if this resource ID could not be found in the current list of
594 controllable resources.
595 KErrCompletion if request is no longer pending.
596 KErrAccessDenied if the client ID could not be found in the current list of registered
597 clients or if the client was registered to be thread relative and this API
598 is not called from the same thread or if client is not the same that
599 requested the resource state change.
600 KErrInUse if the request cannot be cancelled as processing of the request already started
601 and will run to completion.
603 @pre Interrupts must be enabled
604 @pre Kernel must be unlocked
605 @pre No fast mutex can be held
606 @pre Call in a thread context but not from null thread or DFC thread1
607 @pre Can be used in a device driver
609 EXPORT_C TInt PowerResourceManager::CancelAsyncRequestCallBack(TUint aClientId, TUint aResourceId, TPowerResourceCb& aCb)
611 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::CancelAsyncRequestCallback"));
612 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
613 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aResourceId 0x%08x", aResourceId));
614 return TInterface::CancelAsyncRequestCallBack(aClientId, aResourceId, aCb);
621 Request notification of changes to the state of a resource.
623 NOTE: This API should return immediately; however the notification will
624 only happen when a resource change occurs.Notification request is idempotent,
625 if the same notification has already been requested for this resource ID,
626 the API returns with no further action. Notifications remain queued until
629 @param aClientId ID of the client which is requesting the notification.
630 @param aResourceId ID of the resource for which notification of state changes
632 @param aN A reference to a notification object which encapsulates a callback
633 function to be called whenever a resource state change takes place.
634 NOTE: The client must create the notification object in kernel heap
637 @return KErrNone if the operation of requesting a notification was successful.
638 KErrNotFound if this resource ID could not be found in the current list
639 of controllable resources.
640 KErrAccessDenied if the client ID could not be found in the current
641 list of registered clients or if the client was registered to be thread
642 relative and this API is not called from the same thread.
643 KErrInUse if the passed notification object is used already.
645 @pre Interrupts must be enabled
646 @pre Kernel must be unlocked
647 @pre No fast mutex can be held
648 @pre Call in a thread context but not from null thread or DFC thread1
649 @pre Can be used in a device driver
651 EXPORT_C TInt PowerResourceManager::RequestNotification(TUint aClientId, TUint aResourceId, DPowerResourceNotification& aN)
653 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::RequestNotification"));
654 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
655 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aResourceId 0x%08x", aResourceId));
656 return TInterface::RequestNotification(aClientId, aResourceId, aN);
663 Request notification when the state of a resource reaches a specified threshold or
664 goes above or below that threshold (for multilevel resource only) based on direction.
665 In other words it is issued when a threshold on the specified resource state is crossed
666 in the direction specified.
668 NOTE:This API should return immediately; however the notification will only
669 happen when a resource change occurs. Notification request is idempotent,
670 if the same notification has already been requested for this resource ID,
671 the API returns with no further action. Notification remain queued until
674 @param aClientId ID of the client which is requesting the notification.
675 @param aResourceId ID for the resource whose notification of state changes is
677 @param aN A reference to a notification object which encapsulates a callback
678 function to be called whenever the conditions to issue the notification
679 (specified in the API) are met.
680 NOTE: The client must create the notification object in kernel heap
682 @param aThreshold The level of the resource state that will trigger the notification
684 @param aDirection Specifies the direction of change of the resource state that will
685 trigger a notification. EFalse means the notification will be issued
686 when the resource state change to a specified threshold value or below
687 the specified threshold, ETrue means the notification will be issued
688 when the resource state change to a specified threshold value or above
689 the specified threshold.
691 @return KErrNone if the operation of requesting a notification was successful.
692 KErrNotFound if this resource ID could not be found in the current list
693 of controllable reosurces.
694 KErrAccessDenied if the client ID could not be found in the list of
695 registered clients or if the client was registered to be
696 thread relative and this API is not called from the same thread.
697 KErrInUse if the passed notification object is used already.
698 KErrArgument if the specified threshold is out of range.
700 @pre Interrupts must be enabled
701 @pre Kernel must be unlocked
702 @pre No fast mutex can be held
703 @pre Call in a thread context but not from null thread or DFC thread1
704 @pre Can be used in a device driver
706 EXPORT_C TInt PowerResourceManager::RequestNotification(TUint aClientId, TUint aResourceId, DPowerResourceNotification& aN,
707 TInt aThreshold, TBool aDirection)
709 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::RequestNotification"));
710 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
711 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aResourceId 0x%08x", aResourceId));
712 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aThreshold 0x%08x", aThreshold));
713 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aDirection 0x%08x", aDirection));
714 return TInterface::RequestNotification(aClientId, aResourceId, aN, aThreshold, aDirection);
721 Cancel and remove from queue a previously issued request for notification on a
722 resource state change.
724 @param aClientId ID of the client which is requesting to cancel the notification
725 @param aResourceId ID of the resource whose pending notification of state changes
727 @param aN A reference to the notification object that was associated with
728 the notification request that is being cancelled. This will be
729 used to identify the notification that is being cancelled.
731 @return KErrCancel if the notification request was successfully cancelled.
732 KErrNotFound if the specified notification object is not found in the current list
733 of notification objects for the specified resource.
734 KErrAccessDenied if the client requesting the cancellation is not the same
735 which registered the notification or if the resource id does not
736 match or if the client ID could not be found in the list of
737 registered clients or if the client was registered to be
738 thread relative and this API is not called from the same thread.
740 @pre Interrupts must be enabled
741 @pre Kernel must be unlocked
742 @pre No fast mutex can be held
743 @pre Call in a thread context but not from null thread or DFC thread1
744 @pre Can be used in a device driver
746 EXPORT_C TInt PowerResourceManager::CancelNotification(TUint aClientId, TUint aResourceId, DPowerResourceNotification& aN)
748 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::CancelNotification"));
749 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
750 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aResourceId 0x%08x", aResourceId));
751 return TInterface::CancelNotification(aClientId, aResourceId, aN);
758 Request pre-allocation of specified number of client level and request message objects.
760 @param aClientId ID of the client which is requesting the pre-allocation.
761 @param aNumCl Number of client level objects that needs to be pre-allocated
763 @param aNumRm Number of request message objects that needs to be pre-allocated
766 @return KErrNone if the allocation was successful
767 KErrAccessDenied if the client ID could not be found in the list of
768 registered clients or if the client was registered to be
769 thread relative and this API is not called from the same thread.
770 KErrNoMemory if there is no sufficient memory for allocation of requested
773 @pre Interrupts must be enabled
774 @pre Kernel must be unlocked
775 @pre No fast mutex can be held
776 @pre Call in a thread context but not from null thread or DFC thread1
777 @pre Can be used in a device driver
779 EXPORT_C TInt PowerResourceManager::AllocReserve(TUint aClientId, TUint8 aNumCl, TUint8 aNumRm)
781 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::AllocReserve"));
782 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
783 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aNumCl 0x%02x", aNumCl));
784 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aNumRm 0x%02x", aNumRm));
785 return TInterface::AllocReserve(aClientId, aNumCl, aNumRm);
792 Request to deregister client level from the specified resource for the specified client.
794 @param aClientId ID of the client which is requesting the deregistration of client level.
795 @param aResourceId ID of the resource from which to remove the specified clients 'client level'.
797 @return KErrNone if successful
798 KErrAccessDenied if the client ID could not be found in the list of registered clients or
799 if the client was registered to be thread relative and this API is not
800 called from the same thread.
801 KErrNotFound if the resource ID could not be found in the current list of controllable
802 resources or if the client is not holding any level with the specified
803 resource (no client level found for the specified client).
805 @pre Interrupts must be enabled
806 @pre Kernel must be unlocked
807 @pre No fast mutex can be held
808 @pre Call in a thread context but not from null thread or DFC thread1
809 @pre Can be used in a device driver.
811 EXPORT_C TInt PowerResourceManager::DeRegisterClientLevelFromResource(TUint aClientId, TUint aResourceId)
813 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::DeRegisterClientLevelFromResource"));
814 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
815 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aResourceId 0x%08x", aResourceId));
816 return TInterface::DeRegisterClientLevelFromResource(aClientId, aResourceId);
823 Interface to provide extended functionality.This provides support
824 to register and deregister dynamic resources and handling of resource dependency, registering
825 and deregistering resource dependency.
826 This is not supported in basic version
827 It is used for getting version (supported in both version).
829 @pre Interrupts must be enabled
830 @pre Kernel must be unlocked
831 @pre No fast mutex can be held
832 @pre Call in a thread context but not from null thread or DFC thread1
833 @pre Can be used in a device driver.
835 EXPORT_C TInt PowerResourceManager::ControlIO(TUint aClientId, TUint aFunction, TAny* aParam1, TAny* aParam2,
838 __KTRACE_OPT(KRESMANAGER, Kern::Printf(">PowerResourceManager::ControlIO"));
839 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aClientId 0x%08x", aClientId));
840 __KTRACE_OPT(KRESMANAGER, Kern::Printf("aFunction %d", aFunction));
841 return TInterface::ControlIO(aClientId, aFunction, aParam1, aParam2, aParam3);