PowerParameter()

Updated: April 19, 2023

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.

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.

Note: If id is ORed with _NTO_PP_ID_NEXT, new must be set to NULL.
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.
If new is NULL, don't set new power characteristics.
old
A pointer to an nto_power_parameter structure with the old power characteristics.
If old is non-NULL, return the previous power parameter for the parameter specified by id.

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:

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 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.

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:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread No