PowerParameter()
Get or set a power parameter
Synopsis:
#include <neutrino.h>
int PowerParameter(unsigned __id,
unsigned __struct_len,
const struct nto_power_parameter *__new,
struct nto_power_parameter *__old);
Arguments:
- id
- If the id argument is zero, the kernel will return a new number that can be used as an ID to refer to the power parameter in the future.
- struct_len
- The length of the nto_power_parameter data structure, in bytes.
- new
- A pointer to an nto_power_parameter structure with the new power characteristics to apply.
- old
- A pointer to an nto_power_parameter structure with the old power characteristics.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The PowerParameter() function either gets or sets power characteristics, based on the values set for id, new, and old, as follows:
- If id is zero, PowerParameter() returns a new power parameter ID.
- If id is non-zero, PowerParameter() replaces the power parameter with the ID specified by id with the values in the nto_power_parameter structure referenced by new; in this case the new argument must be non-NULL.
- If id is non-zero and its value is ORed with _NTO_PP_ID_NEXT, the kernel will return the information for the next power parameter with an ID higher than the value specified in id; in this case, the new argument must be set to NULL.
- If new is NULL, don't set the power characteristics.
- If new is non-NULL, set the power parameters to the values in the nto_power_parameter data structure referenced by new. The characteristics PowerParameter() sets depend on the value in this data structure's parameter_type member.
- If old is non-NULL, get the power parameters for the power characterisitic specified by id.
Enumerated values and constants
The PowerParameter() function makes use of the _NTO_PP_ID_NEXT value defined in the neutrino.h header file:
- _NTO_PP_ID_NEXT
#define _NTO_PP_ID_NEXT 0x80000000uOR the value for the id parameter with _NTO_PP_ID_NEXT to have the kernel return the powere parameter with the next higher ID value.
Example
The code sample below creates a CPU cluster, adds all the CPUs to that cluster, and adds all the CPUs on the board to that cluster, specifying power-management characteristics for them:
parm.parameter_type = _NTO_PPT_DEFINE_CLUSTER;
parm.clusterid = -1;
parm.u.cluster.frequency_mask = 0;
cluster = PowerParameter(0, sizeof(parm), &parm, NULL);
printf("PowerParm (cluster) got %d, %d\n", cluster, errno);
for(i = 0; i < _syspage_ptr->num_cpu; ++i) {
parm.parameter_type = _NTO_PPT_DEFINE_CPU;
parm.clusterid = cluster;
parm.u.cpu.cpuid = i;
parm.u.cpu.unloaded = 75;
parm.u.cpu.loaded.nonburst = 97;
parm.u.cpu.loaded.burst = 20;
pp[0] = PowerParameter(0, sizeof(parm), &parm, NULL);
printf("PowerParm (cpu%d) got %d, %d\n", i, pp[0], errno);
}
Returns:
- >0
- Success. The call returns the power characteristic ID. If id was non-zero, the returned ID will be the same as the passed-in argument. If id was zero, the call returns a new ID that can then be used to refer to the power parameter.
- -1
- An error occurred (errno is set).
Classification:
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | No |
| Thread | No |
Page updated:
