Power management information, Name, Synopsis – Comtrol eCos User Manual

Page 661: Accessing power controllers

Advertising
background image

Power Management Information

Name

Obtaining Power Management Information

— finding out about the various power controllers in the

system

Synopsis

#include

<

cyg/power/power.h

>

extern PowerController __POWER__[], __POWER_END__;

extern PowerController power_controller_cpu;

extern cyg_handle_t

power_thread_handle;

PowerMode power_get_mode (void);

PowerMode power_get_desired_mode (void);

PowerMode power_get_controller_mode ( PowerController* controller );

PowerMode power_get_controller_desired_mode ( PowerController* controller );

const char* power_get_controller_id ( PowerController* controller );

Accessing Power Controllers

All the power controllers in a system are held in a table, filled in at link-time. The symbols

__POWER__

and

__POWER_END

can be used to iterate through this table, for example:

PowerController* controller;

for (controller

= &(__POWER__[0]);

controller != &(__POWER_END__);

controller++) {

...

}

Each controller has an associated priority, controlling the order in which they appear in the table. Typically a
software-only component such as a TCP/IP stack would use a small number for the priority, so that it appears near
the start of the table, whereas a device driver would be nearer the back of the table. When switching to a lower-
powered mode the power management package will iterate through this table from front to back, thus ensuring that
for example the TCP/IP stack gets a chance to shut down before the underlying ethernet or other hardware that the
stack depends on. Similarly when switching to a higher-powered mode the power management package will iterate
through this table from back to front.

In most systems there will be one special controller,

power_controller_cpu

, which should be provided by one

of the architectural, variant or platform HAL packages. This controller will always be the last entry in the table. It is
responsible for the final power down operation when switching to off mode. Other packages such as device drivers
may or may not declare variable identifiers for their power controllers, allowing those controllers to be accessed by
name as well as by their entries in the global table.

557

Advertising