KasperskyOS Community Edition 1.3

Power management (pm_api.h)

This API is defined in the header file sysroot-*-kos/include/coresrv/pm/pm_api.h from the KasperskyOS SDK.

The API changes the power mode of the hardware platform (for example, shutdown or restart), and enables and disables processors (processor cores).

Information about API functions is provided in the table below.

Using the API

To make a request to change the power mode of the hardware platform, call the KnPmRequest() function.

The KnPmSetCpusOnline() and KnPmGetCpusOnline() functions have the mask parameter, which is used to pass the processor mask. A processor mask is a bit mask indicating the set of processors (processor cores). A flag set in the ith bit indicates that a processor with the i index is included in the set (numbering starts at zero). To work with a processor mask, you must use the functions defined in the header file sysroot-*-kos/include/rtl/cpuset.h.

To enable and/or disable processors, call the KnPmSetCpusOnline() function while specifying the processor mask indicating the required set of active processors. The flag corresponding to the bootstrap processor must be set in this mask, otherwise the function will end with an error. To get the bootstrap processor index, call the KnPmGetBootstrapCpuNum() function.

To find out which processors are in the active state, call the KnPmGetCpusOnline() function. The output parameter of this function is the processor mask indicating the actual set of active processors.

If the KnPmSetCpusOnline() function ended with an error, this could lead to an unpredictable change in the set of active processors. To make a repeated attempt to configure the set of active processors, you must find out which processors are in the active state by calling the KnPmGetCpusOnline() function and use this information to adjust the required set of active processors during the subsequent KnPmSetCpusOnline() function call.

Information about API functions

pm_api.h functions

Function

Information about the function

KnPmRequest()

Purpose

Requests to change the power mode of a hardware platform.

Parameters

  • [in] request – value defining the necessary power mode of the hardware platform. The parameter type is defined in the header file sysroot-*-kos/include/pm/pmstate.h from the KasperskyOS SDK.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

KnPmSetCpusOnline()

Purpose

Requests to enable and/or disable processors.

Parameters

  • [in] mask – pointer to the processor mask indicating the required set of active processors. The type of processor mask is defined in the header file sysroot-*-kos/include/rtl/cpuset.h from the KasperskyOS SDK.
  • [in] timeoutMs – fictitious parameter (obsolete).

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

KnPmGetCpusOnline()

Purpose

Gets information regarding which processors are in the active state.

Parameters

  • [out] mask – pointer to the processor mask indicating the actual set of active processors. The type of processor mask is defined in the header file sysroot-*-kos/include/rtl/cpuset.h from the KasperskyOS SDK.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.

KnPmGetBootstrapCpuNum()

Purpose

Gets the index of the bootstrap processor.

Parameters

  • [out] num – pointer to the bootstrap processor index. The type of processor index is defined in the header file sysroot-*-kos/include/rtl/cpuset.h from the KasperskyOS SDK.

Returned values

If successful, the function returns rcOk, otherwise it returns an error code.