⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 power-info.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
字号:
<!-- Copyright (C) 2003 Red Hat, Inc.                                --><!-- This material may be distributed only subject to the terms      --><!-- and conditions set forth in the Open Publication License, v1.0  --><!-- or later (the latest version is presently available at          --><!-- http://www.opencontent.org/openpub/).                           --><!-- Distribution of the work or derivative of the work in any       --><!-- standard (paper) book form is prohibited unless prior           --><!-- permission is obtained from the copyright holder.               --><HTML><HEAD><TITLE>Power Management Information</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="eCos Power Management Support"HREF="services-power.html"><LINKREL="PREVIOUS"TITLE="Introduction"HREF="power-intro.html"><LINKREL="NEXT"TITLE="Changing Power Modes"HREF="power-change.html"></HEAD><BODYCLASS="REFENTRY"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="power-intro.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="power-change.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><H1><ANAME="POWER-INFO">Power Management Information</H1><DIVCLASS="REFNAMEDIV"><ANAME="AEN15678"></A><H2>Name</H2>Obtaining Power Management Information&nbsp;--&nbsp;finding out about the various power controllers in the system</DIV><DIVCLASS="REFSYNOPSISDIV"><ANAME="AEN15681"><H2>Synopsis</H2><DIVCLASS="FUNCSYNOPSIS"><ANAME="AEN15682"><P></P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="FUNCSYNOPSISINFO">#include &lt;cyg/power/power.h&gt;extern PowerController __POWER__[], __POWER_END__;extern PowerController power_controller_cpu;extern cyg_handle_t    power_thread_handle;</PRE></TD></TR></TABLE><P><CODE><CODECLASS="FUNCDEF">    PowerMode power_get_mode  </CODE>(void);</CODE></P><P><CODE><CODECLASS="FUNCDEF">    PowerMode power_get_desired_mode  </CODE>(void);</CODE></P><P><CODE><CODECLASS="FUNCDEF">    PowerMode power_get_controller_mode  </CODE>(    PowerController* controller  );</CODE></P><P><CODE><CODECLASS="FUNCDEF">    PowerMode power_get_controller_desired_mode  </CODE>(    PowerController* controller  );</CODE></P><P><CODE><CODECLASS="FUNCDEF">    const char* power_get_controller_id  </CODE>(    PowerController* controller  );</CODE></P><P></P></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="POWER-INFO-ACCESS"></A><H2>Accessing Power Controllers</H2><P>All the power controllers in a system are held in a table, filled inat link-time. The symbols <TTCLASS="VARNAME">__POWER__</TT> and<TTCLASS="VARNAME">__POWER_END</TT> can be used to iterate through thistable, for example:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">PowerController* controller;for (controller  = &amp;(__POWER__[0]);     controller != &amp;(__POWER_END__);     controller++) {     &#8230;}</PRE></TD></TR></TABLE><P>Each controller has an associated priority, controlling the order inwhich they appear in the table. Typically a software-only componentsuch as a TCP/IP stack would use a small number for the priority, sothat it appears near the start of the table, whereas a device driverwould be nearer the back of the table. When switching to alower-powered mode the power management package will iterate throughthis table from front to back, thus ensuring that for example theTCP/IP stack gets a chance to shut down before the underlying ethernetor other hardware that the stack depends on. Similarly when switchingto a higher-powered mode the power management package will iteratethrough this table from back to front.</P><P>In most systems there will be one special controller,<TTCLASS="VARNAME">power_controller_cpu</TT>, which should be provided byone of the architectural, variant or platform HAL packages. Thiscontroller will always be the last entry in the table. It isresponsible for the final power down operation when switching to<SPANCLASS="TYPE">off</SPAN> mode. Other packages such as device drivers may ormay not declare variable identifiers for their power controllers,allowing those controllers to be accessed by name as well as by theirentries in the global table.</P></DIV><DIVCLASS="REFSECT1"><ANAME="POWER-INFO-GLOBAL"></A><H2>Global Power Modes</H2><P>The function <TTCLASS="FUNCTION">power_get_mode</TT> can be called at anytime to determine the current power mode for the system as a whole.The return value will be one of <TTCLASS="LITERAL">PowerMode_Active</TT>,<TTCLASS="LITERAL">PowerMode_Idle</TT>, <TTCLASS="LITERAL">PowerMode_Sleep</TT>or <TTCLASS="LITERAL">PowerMode_Off</TT>. In normal circumstances it isunlikely that <TTCLASS="LITERAL">PowerMode_Off</TT> would be returned sincethat mode generally means that the cpu is no longer running.</P><P>The function <TTCLASS="FUNCTION">power_get_desired_mode</TT> returns thepower mode that the system should be running at. Most of the time thiswill be the same value as returned by<TTCLASS="FUNCTION">power_get_mode</TT>. However a different value may bereturned when in the middle of changing power modes. For example, ifthe current thread runs at a higher priority than the power managementthread then the latter may have been pre-empted in the middle of amode change: <TTCLASS="FUNCTION">power_get_mode</TT> will return the modethe system was running at before the mode change started, and<TTCLASS="FUNCTION">power_get_desired_mode</TT> will return the mode thesystem should end up in when the mode change completes, barringfurther calls to <TTCLASS="FUNCTION">power_set_mode</TT>.</P></DIV><DIVCLASS="REFSECT1"><ANAME="POWER-INFO-INDIVIDUAL"></A><H2>Individual Controller Power Modes</H2><P>The power management package keeps track of the current and desiredmodes for each power controller, as well as the modes for the system asa whole. The function <TTCLASS="FUNCTION">power_get_controller_mode</TT>takes a single argument, a pointer to a power controller, and returnsthe power mode that controller is currently running at. Similarly<TTCLASS="FUNCTION">power_get_controller_desired_mode</TT> returns thepower mode that controller should be running at. Most of the time thecurrent and desired modes for a given controller will be the same, andwill also be the same as the global power mode. However if the powermanagement thread is preeempted in the middle of a mode change thensome of the controllers will have been updated to the desired globalmode, whereas others will still be at the old mode. The powermanagement package also provides functionality for manipulating<AHREF="power-change.html#POWER-CHANGE-CONTROLLER">individual controllers</A>, and for <AHREF="power-attached.html">detaching</A> controllers fromglobal mode changes.</P></DIV><DIVCLASS="REFSECT1"><ANAME="POWER-INFO-IDS"></A><H2>Power Controller Identification</H2><P>In some scenarios the power management package will run completelyautomated, and there is no need to identify individual powercontrollers. Any form of identification such as a stringdescription would serve no purpose, but would still consume memory inthe final system. In other scenarios it may be very desirable toprovide some means of identification. For example, while stilldebugging it may be useful to see a simple string when printing thecontents of a power controller structure. Alternatively, if theapplication is expected to provide some sort of user interface thatgives control over which parts of the system are enabled or disabled,a string identifier for each controller would be useful. To cope withthese scenarios the power management package provides a configurationoption <TTCLASS="VARNAME">CYGIMP_POWER_PROVIDE_STRINGS</TT>. When enabled,each power controller will contain a pointer to a constant stringwhich can be accessed via a function<TTCLASS="FUNCTION">power_get_controller_id</TT>. When disabled the systemwill not contain these strings, and the function will not be provided.The following code illustrates how to use this function.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">#include &lt;stdio.h&gt;#include &lt;pkgconf/system.h&gt;#ifndef CYGPKG_POWER# error The power management package is not present.#endif#include &lt;pkgconf/power.h&gt;#ifndef CYGIMP_POWER_PROVIDE_STRINGS# error Power controller identifiers are not available.#endif#include &lt;cyg/power/power.h&gt;static const char*mode_to_string(PowerMode mode){    const char* result;    switch(mode) {      case PowerMode_Active : result = "active"; break;      case PowerMode_Idle   : result = "idle"; break;      case PowerMode_Sleep  : result = "sleep"; break;      case PowerMode_Off    : result = "off"; break;      default               : result = "&lt;unknown&gt;"; break;    }    return result;}intmain(int argc, char** argv){    PowerController* controller;    for (controller = &amp;(__POWER__[0]);         controller != &amp;(__POWER_END__);         controller++) {        printf("Controller @ %p: %s, %s\n", controller,               power_get_controller_id(controller),               mode_to_string(power_get_controller_mode(controller)));    }    return 0;}</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="POWER-INFO-THREAD"></A><H2>The Power Management Thread</H2><P>If the power management package is configured to use a separate threadthen a handle for that thread is made available to higher-level codevia the variable <TTCLASS="VARNAME">power_thread_handle</TT>. This handlecan be used for a variety of purposes, including manipulating thatthread's priority.</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="power-intro.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="power-change.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Introduction</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="services-power.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Changing Power Modes</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -