| Updated: October 28, 2024 |
Get or set a power parameter
#include <neutrino.h>
int PowerParameter(unsigned __id,
unsigned __struct_len,
const struct nto_power_parameter *__new,
struct nto_power_parameter *__old);
If the id argument is non-zero, the kernel will replace the existing parameter identified by id with new information. In this case, if _NTO_PP_ID_NEXT is ORed into the value, the kernel will return the information for the next parameter with a higher ID than the value specified for id.
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The PowerParameter() function either gets or sets power characteristics, based on the values set for id, new, and old, as follows:
The PowerParameter() function makes use of the _NTO_PP_ID_NEXT value defined in the neutrino.h header file:
#define _NTO_PP_ID_NEXT 0x80000000u
OR 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.
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);
}
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | No |
| Thread | No |