<!-- Copyright (C) 2001 Red Hat, Inc. -->
|
<!-- Copyright (C) 2001 Red Hat, Inc. -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- Distribution of substantively modified versions of this -->
|
<!-- Distribution of substantively modified versions of this -->
|
<!-- document is prohibited without the explicit permission of the -->
|
<!-- document is prohibited without the explicit permission of the -->
|
<!-- copyright holder. -->
|
<!-- copyright holder. -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- permission is obtained from the copyright holder. -->
|
<!-- permission is obtained from the copyright holder. -->
|
<HTML
|
<HTML
|
><HEAD
|
><HEAD
|
><TITLE
|
><TITLE
|
>Introduction</TITLE
|
>Introduction</TITLE
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
<META
|
<META
|
NAME="GENERATOR"
|
NAME="GENERATOR"
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
|
"><LINK
|
"><LINK
|
REL="HOME"
|
REL="HOME"
|
TITLE="eCos Power Management Support"
|
TITLE="eCos Power Management Support"
|
HREF="services-power.html"><LINK
|
HREF="services-power.html"><LINK
|
REL="PREVIOUS"
|
REL="PREVIOUS"
|
TITLE="eCos Power Management Support"
|
TITLE="eCos Power Management Support"
|
HREF="services-power.html"><LINK
|
HREF="services-power.html"><LINK
|
REL="NEXT"
|
REL="NEXT"
|
TITLE="Power Management Information"
|
TITLE="Power Management Information"
|
HREF="power-info.html"></HEAD
|
HREF="power-info.html"></HEAD
|
><BODY
|
><BODY
|
CLASS="REFENTRY"
|
CLASS="REFENTRY"
|
BGCOLOR="#FFFFFF"
|
BGCOLOR="#FFFFFF"
|
TEXT="#000000"
|
TEXT="#000000"
|
LINK="#0000FF"
|
LINK="#0000FF"
|
VLINK="#840084"
|
VLINK="#840084"
|
ALINK="#0000FF"
|
ALINK="#0000FF"
|
><DIV
|
><DIV
|
CLASS="NAVHEADER"
|
CLASS="NAVHEADER"
|
><TABLE
|
><TABLE
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TH
|
><TH
|
COLSPAN="3"
|
COLSPAN="3"
|
ALIGN="center"
|
ALIGN="center"
|
>eCos Power Management Support</TH
|
>eCos Power Management Support</TH
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="services-power.html"
|
HREF="services-power.html"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="80%"
|
WIDTH="80%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="power-info.html"
|
HREF="power-info.html"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"></DIV
|
WIDTH="100%"></DIV
|
><H1
|
><H1
|
><A
|
><A
|
NAME="POWER-INTRO"
|
NAME="POWER-INTRO"
|
>Introduction</A
|
>Introduction</A
|
></H1
|
></H1
|
><DIV
|
><DIV
|
CLASS="REFNAMEDIV"
|
CLASS="REFNAMEDIV"
|
><A
|
><A
|
NAME="AEN6"
|
NAME="AEN6"
|
></A
|
></A
|
><H2
|
><H2
|
>Name</H2
|
>Name</H2
|
>Introduction -- eCos support for Power Management</DIV
|
>Introduction -- eCos support for Power Management</DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="POWER-INTRO-INTRO"
|
NAME="POWER-INTRO-INTRO"
|
></A
|
></A
|
><H2
|
><H2
|
>Introduction</H2
|
>Introduction</H2
|
><P
|
><P
|
>The eCos Power Management package provides a framework for
|
>The eCos Power Management package provides a framework for
|
incorporating power management facilities in an embedded application.
|
incorporating power management facilities in an embedded application.
|
However its functionality is deliberately limited.</P
|
However its functionality is deliberately limited.</P
|
><P
|
><P
|
></P
|
></P
|
><OL
|
><OL
|
TYPE="1"
|
TYPE="1"
|
><LI
|
><LI
|
><P
|
><P
|
>The package does not contain any support for controlling the current
|
>The package does not contain any support for controlling the current
|
power mode of any given processor, device or board. Instead it is the
|
power mode of any given processor, device or board. Instead it is the
|
responsibility of the appropriate HAL or device driver package to
|
responsibility of the appropriate HAL or device driver package to
|
implement such support, by implementing <I
|
implement such support, by implementing <I
|
CLASS="FIRSTTERM"
|
CLASS="FIRSTTERM"
|
>power
|
>power
|
controllers</I
|
controllers</I
|
>. The power management package groups these
|
>. The power management package groups these
|
power controllers together and provides an interface for manipulating
|
power controllers together and provides an interface for manipulating
|
them.</P
|
them.</P
|
></LI
|
></LI
|
><LI
|
><LI
|
><P
|
><P
|
>The package does not contain any power management policy support.
|
>The package does not contain any power management policy support.
|
Specifically, including this package in an application does not by
|
Specifically, including this package in an application does not by
|
itself ever cause the system to go into low-power mode. Instead it is
|
itself ever cause the system to go into low-power mode. Instead it is
|
the responsibility of a separate policy module, provided by
|
the responsibility of a separate policy module, provided by
|
higher-level application code or by some other package, to decide when
|
higher-level application code or by some other package, to decide when
|
it would be appropriate to switch from one power mode to another. The
|
it would be appropriate to switch from one power mode to another. The
|
power management package then provides the mechanisms for making it
|
power management package then provides the mechanisms for making it
|
happen.</P
|
happen.</P
|
></LI
|
></LI
|
></OL
|
></OL
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="POWER-INTRO-INCLUDE"
|
NAME="POWER-INTRO-INCLUDE"
|
></A
|
></A
|
><H2
|
><H2
|
>Including Power Management</H2
|
>Including Power Management</H2
|
><P
|
><P
|
>The power management package is never included automatically in an
|
>The power management package is never included automatically in an
|
eCos configuration: it is not part of any target specification or of
|
eCos configuration: it is not part of any target specification or of
|
any template. Instead it must be added explicitly to a configuration
|
any template. Instead it must be added explicitly to a configuration
|
if the intended application requires power management functionality.
|
if the intended application requires power management functionality.
|
When using the command-line <B
|
When using the command-line <B
|
CLASS="COMMAND"
|
CLASS="COMMAND"
|
>ecosconfig</B
|
>ecosconfig</B
|
> tool this
|
> tool this
|
can be achieved using a command such as:</P
|
can be achieved using a command such as:</P
|
><TABLE
|
><TABLE
|
BORDER="0"
|
BORDER="0"
|
BGCOLOR="#E0E0E0"
|
BGCOLOR="#E0E0E0"
|
WIDTH="100%"
|
WIDTH="100%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="SCREEN"
|
CLASS="SCREEN"
|
>$ ecosconfig add power</PRE
|
>$ ecosconfig add power</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>The generic eCos user documentation should be consulted for more
|
>The generic eCos user documentation should be consulted for more
|
information on how to use the various tools. The functionality
|
information on how to use the various tools. The functionality
|
provided by the power management package is defined in the header file
|
provided by the power management package is defined in the header file
|
<TT
|
<TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>cyg/power/power.h</TT
|
>cyg/power/power.h</TT
|
>. This header
|
>. This header
|
file can be used by both C and C++ code.</P
|
file can be used by both C and C++ code.</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="POWER-INTRO-MODES"
|
NAME="POWER-INTRO-MODES"
|
></A
|
></A
|
><H2
|
><H2
|
>Power Modes</H2
|
>Power Modes</H2
|
><P
|
><P
|
>There are four defined modes of operation:</P
|
>There are four defined modes of operation:</P
|
><P
|
><P
|
></P
|
></P
|
><DIV
|
><DIV
|
CLASS="VARIABLELIST"
|
CLASS="VARIABLELIST"
|
><DL
|
><DL
|
><DT
|
><DT
|
>active</DT
|
>active</DT
|
><DD
|
><DD
|
><P
|
><P
|
>The system is fully operational, and power consumption is expected to
|
>The system is fully operational, and power consumption is expected to
|
be high.</P
|
be high.</P
|
></DD
|
></DD
|
><DT
|
><DT
|
>idle</DT
|
>idle</DT
|
><DD
|
><DD
|
><P
|
><P
|
>There has been little or no activity for a short period of time. It is
|
>There has been little or no activity for a short period of time. It is
|
up to the policy module to determine what constitutes a short period
|
up to the policy module to determine what constitutes a short period
|
of time, but typically it will be some tenths of a second or some
|
of time, but typically it will be some tenths of a second or some
|
small number of seconds. A possible action when entering idle mode is
|
small number of seconds. A possible action when entering idle mode is
|
to reduce the system's clock speed, thus reducing the power drawn by
|
to reduce the system's clock speed, thus reducing the power drawn by
|
the cpu.</P
|
the cpu.</P
|
><P
|
><P
|
>Note that typically this power mode is not entered automatically
|
>Note that typically this power mode is not entered automatically
|
whenever the idle thread starts running. Instead it is entered when
|
whenever the idle thread starts running. Instead it is entered when
|
the policy module discovers that for a certain period of time the
|
the policy module discovers that for a certain period of time the
|
system has been spending most of its time in the idle thread.
|
system has been spending most of its time in the idle thread.
|
Theoretically it is possible to implement a policy module that would
|
Theoretically it is possible to implement a policy module that would
|
cause a switch to idle mode as soon as the idle thread starts running,
|
cause a switch to idle mode as soon as the idle thread starts running,
|
but that could result in a great many power mode changes for no
|
but that could result in a great many power mode changes for no
|
immediate benefit.</P
|
immediate benefit.</P
|
></DD
|
></DD
|
><DT
|
><DT
|
>sleep</DT
|
>sleep</DT
|
><DD
|
><DD
|
><P
|
><P
|
>The system has been idle for a significant period of time, perhaps
|
>The system has been idle for a significant period of time, perhaps
|
some tens of seconds. It is desirable to shut down any hardware that
|
some tens of seconds. It is desirable to shut down any hardware that
|
is drawing a significant amount of power, for example a screen
|
is drawing a significant amount of power, for example a screen
|
backlight.</P
|
backlight.</P
|
></DD
|
></DD
|
><DT
|
><DT
|
>off</DT
|
>off</DT
|
><DD
|
><DD
|
><P
|
><P
|
>The system is powered down. Power consumption should be minimized.
|
>The system is powered down. Power consumption should be minimized.
|
Some special action may be needed before the system comes back up, for
|
Some special action may be needed before the system comes back up, for
|
example the user may need to press a specific button.</P
|
example the user may need to press a specific button.</P
|
></DD
|
></DD
|
></DL
|
></DL
|
></DIV
|
></DIV
|
><P
|
><P
|
>The exact transitions that will happen are decided by the policy
|
>The exact transitions that will happen are decided by the policy
|
module. One policy module might include transitions from active to
|
module. One policy module might include transitions from active to
|
idle, from idle to sleep, from sleep to off, and from any of idle,
|
idle, from idle to sleep, from sleep to off, and from any of idle,
|
sleep or off directly back to active. Another policy module might
|
sleep or off directly back to active. Another policy module might
|
only use the active and off states, bypassing the intermediate ones.</P
|
only use the active and off states, bypassing the intermediate ones.</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="POWER-INTRO-CONTROLLERS"
|
NAME="POWER-INTRO-CONTROLLERS"
|
></A
|
></A
|
><H2
|
><H2
|
>Power Controllers</H2
|
>Power Controllers</H2
|
><P
|
><P
|
>The power management package operates primarily on power controllers.
|
>The power management package operates primarily on power controllers.
|
The main functionality provided by a power controller is to switch the
|
The main functionality provided by a power controller is to switch the
|
power mode for some part of the system, for example the lcd display or
|
power mode for some part of the system, for example the lcd display or
|
the cpu. A power controller consists primarily of a function which
|
the cpu. A power controller consists primarily of a function which
|
will be invoked to switch the power mode for the part of the overall
|
will be invoked to switch the power mode for the part of the overall
|
system being controlled, plus some auxiliary data. A typical system
|
system being controlled, plus some auxiliary data. A typical system
|
will include a number of different power controllers:</P
|
will include a number of different power controllers:</P
|
><P
|
><P
|
></P
|
></P
|
><OL
|
><OL
|
TYPE="1"
|
TYPE="1"
|
><LI
|
><LI
|
><P
|
><P
|
>Usually there will be one power controller
|
>Usually there will be one power controller
|
<TT
|
<TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>power_controller_cpu</TT
|
>power_controller_cpu</TT
|
> associated with the processor
|
> associated with the processor
|
or with the target platform, and provided by the corresponding HAL
|
or with the target platform, and provided by the corresponding HAL
|
package. It is this controller which is responsible for switching off
|
package. It is this controller which is responsible for switching off
|
the system when entering the <SPAN
|
the system when entering the <SPAN
|
CLASS="TYPE"
|
CLASS="TYPE"
|
>off</SPAN
|
>off</SPAN
|
> mode, which makes it
|
> mode, which makes it
|
somewhat special: attempting to switch off the cpu before other
|
somewhat special: attempting to switch off the cpu before other
|
devices like the lcd display does not make sense because the cpu would
|
devices like the lcd display does not make sense because the cpu would
|
no longer be executing any instructions for the latter operation.
|
no longer be executing any instructions for the latter operation.
|
Therefore this power controller has to be invoked last when switching
|
Therefore this power controller has to be invoked last when switching
|
to a lower-power mode, and similarly when switching back to a
|
to a lower-power mode, and similarly when switching back to a
|
higher-power mode it will be invoked first.</P
|
higher-power mode it will be invoked first.</P
|
><P
|
><P
|
>It should be noted that providing power management support is not a
|
>It should be noted that providing power management support is not a
|
hard requirement when porting eCos to a new processor or platform, and
|
hard requirement when porting eCos to a new processor or platform, and
|
many eCos ports predate the availability of power management support.
|
many eCos ports predate the availability of power management support.
|
Therefore for any given platform it is distinctly possible that
|
Therefore for any given platform it is distinctly possible that
|
<TT
|
<TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>power_controller_cpu</TT
|
>power_controller_cpu</TT
|
> is not yet provided, and if
|
> is not yet provided, and if
|
full power management functionality is desired then the appropriate
|
full power management functionality is desired then the appropriate
|
HAL package would have to be extended first. System developers should
|
HAL package would have to be extended first. System developers should
|
examine the relevant HAL documentation and sources to determine what
|
examine the relevant HAL documentation and sources to determine what
|
is actually available.</P
|
is actually available.</P
|
></LI
|
></LI
|
><LI
|
><LI
|
><P
|
><P
|
>Some or all of the device drivers will supply their own power
|
>Some or all of the device drivers will supply their own power
|
controllers, as part of the device driver package. It is not required
|
controllers, as part of the device driver package. It is not required
|
that all device drivers provide power controllers. In some cases,
|
that all device drivers provide power controllers. In some cases,
|
especially for devices that are integrated with the processor,
|
especially for devices that are integrated with the processor,
|
<TT
|
<TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>power_controller_cpu</TT
|
>power_controller_cpu</TT
|
> will take care of the
|
> will take care of the
|
integrated devices as a side effect. In other cases the hardware may
|
integrated devices as a side effect. In other cases the hardware may
|
not provide any functionality that allows power consumption to be
|
not provide any functionality that allows power consumption to be
|
controlled. For any given device driver it is also possible that no
|
controlled. For any given device driver it is also possible that no
|
power controller exists either because it was not required when the
|
power controller exists either because it was not required when the
|
driver was written, or because the driver predates the availability of
|
driver was written, or because the driver predates the availability of
|
power management. Again the relevant documentation and sources should
|
power management. Again the relevant documentation and sources should
|
be consulted for further information.</P
|
be consulted for further information.</P
|
></LI
|
></LI
|
><LI
|
><LI
|
><P
|
><P
|
>There may be power controllers which are not associated directly with
|
>There may be power controllers which are not associated directly with
|
any specific hardware. For example a TCP/IP stack could provide a
|
any specific hardware. For example a TCP/IP stack could provide a
|
power controller so that it gets informed when the system has been
|
power controller so that it gets informed when the system has been
|
reactivated: by looking at the system clock it can determine for how
|
reactivated: by looking at the system clock it can determine for how
|
long the system has been switched off; using this information it can
|
long the system has been switched off; using this information it can
|
then recover from expired dhcp leases, or even to shut down any stream
|
then recover from expired dhcp leases, or even to shut down any stream
|
connections that may have become invalid (although arguably the stack
|
connections that may have become invalid (although arguably the stack
|
should have refused to go to <SPAN
|
should have refused to go to <SPAN
|
CLASS="TYPE"
|
CLASS="TYPE"
|
>off</SPAN
|
>off</SPAN
|
> mode while there were
|
> mode while there were
|
open connections).</P
|
open connections).</P
|
></LI
|
></LI
|
></OL
|
></OL
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="REFSECT1"
|
CLASS="REFSECT1"
|
><A
|
><A
|
NAME="POWER-INTRO-OPERATION"
|
NAME="POWER-INTRO-OPERATION"
|
></A
|
></A
|
><H2
|
><H2
|
>Basic Operation</H2
|
>Basic Operation</H2
|
><P
|
><P
|
>By default the Power Management package creates a thread during
|
>By default the Power Management package creates a thread during
|
initialization. It is also possible for the package to be used without
|
initialization. It is also possible for the package to be used without
|
such a thread, for example in configurations which do not include a
|
such a thread, for example in configurations which do not include a
|
full kernel, and this alternative is described below. When a separate
|
full kernel, and this alternative is described below. When a separate
|
thread is used the stacksize and priority for this thread can be
|
thread is used the stacksize and priority for this thread can be
|
controlled by configuration options
|
controlled by configuration options
|
<TT
|
<TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>CYGNUM_POWER_THREAD_STACKSIZE</TT
|
>CYGNUM_POWER_THREAD_STACKSIZE</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>CYGNUM_POWER_THREAD_PRIORITY</TT
|
>CYGNUM_POWER_THREAD_PRIORITY</TT
|
>. Typically the thread
|
>. Typically the thread
|
will just wait on a semaphore internal to the package, and will do
|
will just wait on a semaphore internal to the package, and will do
|
nothing until some other part of the system requests a change to the
|
nothing until some other part of the system requests a change to the
|
power mode.</P
|
power mode.</P
|
><P
|
><P
|
>At some point the policy module will decide that the system should
|
>At some point the policy module will decide that the system should
|
move into a lower-power mode, for example from active to idle. This is
|
move into a lower-power mode, for example from active to idle. This is
|
achieved by calling the function <TT
|
achieved by calling the function <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>power_set_mode</TT
|
>power_set_mode</TT
|
>,
|
>,
|
provided by the power management package and declared in <TT
|
provided by the power management package and declared in <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>cyg/power/power.h</TT
|
>cyg/power/power.h</TT
|
>, with a single
|
>, with a single
|
argument, <TT
|
argument, <TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>PowerMode_Idle</TT
|
>PowerMode_Idle</TT
|
>. This function manipulates
|
>. This function manipulates
|
some internal state and posts the semaphore, thus waking up the power
|
some internal state and posts the semaphore, thus waking up the power
|
management thread. Note that the function returns before the mode
|
management thread. Note that the function returns before the mode
|
change has completed, and in fact depending on thread priorities this
|
change has completed, and in fact depending on thread priorities this
|
return may happen before any power controller has been invoked.</P
|
return may happen before any power controller has been invoked.</P
|
><P
|
><P
|
>When the power management thread wakes up it examines the internal
|
>When the power management thread wakes up it examines the internal
|
state to figure out what it should be doing. In this case it is
|
state to figure out what it should be doing. In this case it is
|
supposed to change the global power mode, so it will iterate over all
|
supposed to change the global power mode, so it will iterate over all
|
the power controllers requesting each one to switch to the
|
the power controllers requesting each one to switch to the
|
<SPAN
|
<SPAN
|
CLASS="TYPE"
|
CLASS="TYPE"
|
>idle</SPAN
|
>idle</SPAN
|
> mode. It is up to each power controller to handle
|
> mode. It is up to each power controller to handle
|
this request appropriately. Optionally the thread will invoke a
|
this request appropriately. Optionally the thread will invoke a
|
callback function after processing each power controller, so that
|
callback function after processing each power controller, so that
|
higher-level code such as the policy module can more easily keep
|
higher-level code such as the policy module can more easily keep
|
track of the actual state of each controller. Once the thread has
|
track of the actual state of each controller. Once the thread has
|
iterated through all the power controllers it will again wait on the
|
iterated through all the power controllers it will again wait on the
|
internal semaphore for the next request to arrive.</P
|
internal semaphore for the next request to arrive.</P
|
><DIV
|
><DIV
|
CLASS="NOTE"
|
CLASS="NOTE"
|
><BLOCKQUOTE
|
><BLOCKQUOTE
|
CLASS="NOTE"
|
CLASS="NOTE"
|
><P
|
><P
|
><B
|
><B
|
>Note: </B
|
>Note: </B
|
>At present the power management thread always runs at a single
|
>At present the power management thread always runs at a single
|
priority, which defaults to a low priority. A possible future
|
priority, which defaults to a low priority. A possible future
|
enhancement would be to support two separate priorities. When
|
enhancement would be to support two separate priorities. When
|
switching to a lower-powered mode the thread would run at a low
|
switching to a lower-powered mode the thread would run at a low
|
priority as before, thus allowing other threads to run and get a
|
priority as before, thus allowing other threads to run and get a
|
chance to cancel this mode change. When switching to a higher-powered
|
chance to cancel this mode change. When switching to a higher-powered
|
mode the thread would run at a high priority. This could be especially
|
mode the thread would run at a high priority. This could be especially
|
important when moving out of the <SPAN
|
important when moving out of the <SPAN
|
CLASS="TYPE"
|
CLASS="TYPE"
|
>off</SPAN
|
>off</SPAN
|
> state: for example
|
> state: for example
|
it would ensure that all device drivers get a chance to wake up before
|
it would ensure that all device drivers get a chance to wake up before
|
ordinary application threads get to run again and possibly attempt I/O
|
ordinary application threads get to run again and possibly attempt I/O
|
operations.</P
|
operations.</P
|
></BLOCKQUOTE
|
></BLOCKQUOTE
|
></DIV
|
></DIV
|
><P
|
><P
|
>Although usually calls to <TT
|
>Although usually calls to <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>power_set_mode</TT
|
>power_set_mode</TT
|
> will
|
> will
|
come from just one place in the policy module, this is not a hard
|
come from just one place in the policy module, this is not a hard
|
requirement. It is possible for multiple threads to call this
|
requirement. It is possible for multiple threads to call this
|
function, with no need for any synchronization. If the power
|
function, with no need for any synchronization. If the power
|
management thread is in the middle of performing a mode change and a
|
management thread is in the middle of performing a mode change and a
|
new request comes in, the thread will detect this, abort the current
|
new request comes in, the thread will detect this, abort the current
|
operation, and start iterating through the power controllers again
|
operation, and start iterating through the power controllers again
|
with the new mode. This check happens between every power controller
|
with the new mode. This check happens between every power controller
|
invocation. Usefully this makes it possible for power controllers
|
invocation. Usefully this makes it possible for power controllers
|
themselves to manipulate power modes: a power controller is invoked to
|
themselves to manipulate power modes: a power controller is invoked to
|
change mode; for some reason it determines that the new mode is
|
change mode; for some reason it determines that the new mode is
|
inappropriate; it calls <TT
|
inappropriate; it calls <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>power_set_mode</TT
|
>power_set_mode</TT
|
> to move
|
> to move
|
the system back to another mode; when the power controller returns
|
the system back to another mode; when the power controller returns
|
this event will be detected; the power management thread will abort
|
this event will be detected; the power management thread will abort
|
the current mode change, and start the new one.</P
|
the current mode change, and start the new one.</P
|
><P
|
><P
|
>In addition to changing the power mode for the system as a whole,
|
>In addition to changing the power mode for the system as a whole,
|
individual controllers can be manipulated using the function
|
individual controllers can be manipulated using the function
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>power_set_controller_mode</TT
|
>power_set_controller_mode</TT
|
>. For example, while the
|
>. For example, while the
|
system as a whole might be in <SPAN
|
system as a whole might be in <SPAN
|
CLASS="TYPE"
|
CLASS="TYPE"
|
>active</SPAN
|
>active</SPAN
|
> mode certain devices
|
> mode certain devices
|
might be kept in <SPAN
|
might be kept in <SPAN
|
CLASS="TYPE"
|
CLASS="TYPE"
|
>sleep</SPAN
|
>sleep</SPAN
|
> mode until they are explicitly
|
> mode until they are explicitly
|
activated. It is possible to mix concurrent calls to
|
activated. It is possible to mix concurrent calls to
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>power_set_mode</TT
|
>power_set_mode</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>power_set_controller_mode</TT
|
>power_set_controller_mode</TT
|
>, and when a power
|
>, and when a power
|
controller is invoked it may use
|
controller is invoked it may use
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>power_set_controller_mode</TT
|
>power_set_controller_mode</TT
|
> to request further
|
> to request further
|
changes to its own or to another controller's mode as required.</P
|
changes to its own or to another controller's mode as required.</P
|
><P
|
><P
|
>There are some scenarios where the power management package should not
|
>There are some scenarios where the power management package should not
|
use its own thread. One scenario is if the configuration is
|
use its own thread. One scenario is if the configuration is
|
specifically for a single-threaded application such as RedBoot.
|
specifically for a single-threaded application such as RedBoot.
|
Another scenario is if the policy module already involves a separate
|
Another scenario is if the policy module already involves a separate
|
thread: it may make more sense if the various power management
|
thread: it may make more sense if the various power management
|
operations are synchronous with respect to the calling thread. The use
|
operations are synchronous with respect to the calling thread. The use
|
of a separate thread inside the power management package is controlled
|
of a separate thread inside the power management package is controlled
|
by the configuration option <TT
|
by the configuration option <TT
|
CLASS="VARNAME"
|
CLASS="VARNAME"
|
>CYGPKG_POWER_THREAD</TT
|
>CYGPKG_POWER_THREAD</TT
|
>,
|
>,
|
which is active only if the kernel package is present and enabled by
|
which is active only if the kernel package is present and enabled by
|
default.</P
|
default.</P
|
><P
|
><P
|
>If no separate power management thread is used then obviously the
|
>If no separate power management thread is used then obviously the
|
implementations of <TT
|
implementations of <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>power_set_mode</TT
|
>power_set_mode</TT
|
> and
|
> and
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>power_set_controller_mode</TT
|
>power_set_controller_mode</TT
|
> will be somewhat
|
> will be somewhat
|
different: instead of waking up a separate thread to do the work,
|
different: instead of waking up a separate thread to do the work,
|
these functions will now manipulate the power controllers directly. If
|
these functions will now manipulate the power controllers directly. If
|
the system does still involve multiple threads then only one thread
|
the system does still involve multiple threads then only one thread
|
may call <TT
|
may call <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>power_set_mode</TT
|
>power_set_mode</TT
|
> or
|
> or
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>power_set_controller_mode</TT
|
>power_set_controller_mode</TT
|
> at a time: the power
|
> at a time: the power
|
management package will not provide any synchronization, that must
|
management package will not provide any synchronization, that must
|
happen at a higher level. However when a power controller is invoked
|
happen at a higher level. However when a power controller is invoked
|
it can still call these functions as required.</P
|
it can still call these functions as required.</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="NAVFOOTER"
|
CLASS="NAVFOOTER"
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"><TABLE
|
WIDTH="100%"><TABLE
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="services-power.html"
|
HREF="services-power.html"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="services-power.html"
|
HREF="services-power.html"
|
>Home</A
|
>Home</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="power-info.html"
|
HREF="power-info.html"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
>eCos Power Management Support</TD
|
>eCos Power Management Support</TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
> </TD
|
> </TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
>Power Management Information</TD
|
>Power Management Information</TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
></BODY
|
></BODY
|
></HTML
|
></HTML
|
|
|