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

📄 power-change.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>Changing Power Modes</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="Power Management Information"HREF="power-info.html"><LINKREL="NEXT"TITLE="Support for Policy Modules"HREF="power-policy.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-info.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="power-policy.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><H1><ANAME="POWER-CHANGE">Changing Power Modes</H1><DIVCLASS="REFNAMEDIV"><ANAME="AEN15752"></A><H2>Name</H2>Changing Power Modes&nbsp;--&nbsp;reducing or increasing power consumption as needed</DIV><DIVCLASS="REFSYNOPSISDIV"><ANAME="AEN15755"><H2>Synopsis</H2><DIVCLASS="FUNCSYNOPSIS"><ANAME="AEN15756"><P></P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="FUNCSYNOPSISINFO">#include &lt;cyg/power/power.h&gt;</PRE></TD></TR></TABLE><P><CODE><CODECLASS="FUNCDEF">    void power_set_mode  </CODE>(    PowerMode new_mode  );</CODE></P><P><CODE><CODECLASS="FUNCDEF">    void power_set_controller_mode  </CODE>(    PowerController* controller  ,     PowerMode new_mode  );</CODE></P><P><CODE><CODECLASS="FUNCDEF">    void power_set_controller_mode_now  </CODE>(    PowerController* controller  ,     PowerMode new_mode  );</CODE></P><P></P></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="POWER-CHANGE-GLOBAL"></A><H2>Changing the Global Power Mode</H2><P>The primary functionality supported by the power management package isto change the system's global power mode. This is achieved by callingthe function <TTCLASS="FUNCTION">power_set_mode</TT> with a singleargument, which should be one of <TTCLASS="LITERAL">PowerMode_Active</TT>,<TTCLASS="LITERAL">PowerMode_Idle</TT>, <TTCLASS="LITERAL">PowerMode_Sleep</TT>or <TTCLASS="LITERAL">PowerMode_Off</TT>. Typically this function will onlybe invoked in certain scenarios:</P><P></P><OLTYPE="1"><LI><P>A typical system will contain a policy module which is primarilyresponsible for initiating power mode changes, and a thread inside thepower management package. The policy module will call<TTCLASS="FUNCTION">power_set_mode</TT>, which has the effect ofmanipulating some internal state in the power management package andwaking up its thread. When this thread gets scheduled to run (itspriority is controlled by a configuration option), it will iterateover the power controllers and invoke each controller to change itspower mode. There is support for a <AHREF="power-policy.html#POWER-POLICY-CALLBACK">callback function</A>, and for<AHREF="power-attached.html">detached</A> power controllers.</P></LI><LI><P>After a call to <TTCLASS="FUNCTION">power_set_mode</TT> but before thepower management thread has had a chance to iterate over all thecontrollers, or even before the thread has been rescheduled at all,the policy module may decide that a different power mode would be moreappropriate for the current situation and calls<TTCLASS="FUNCTION">power_set_mode</TT> again. This has the effect ofaborting the previous mode change, followed by the power managementthread iterating over the power controllers again for the new mode.</P></LI><LI><P>If there is no single policy module responsible for power modechanges, any code can call <TTCLASS="FUNCTION">power_set_mode</TT>. Ifthere are multiple calls in quick succession, earlier calls willbe aborted and the system should end up in the power modecorresponding to the last call</P></LI><LI><P>As a special case, it is possible for a power controller to call<TTCLASS="FUNCTION">power_set_mode</TT> when invoked by the powermanagement thread. For example a power controller could decide that itis inappropriate for the system to go to sleep because the device itis associated with is still busy. The effect is as if the policymodule had called <TTCLASS="FUNCTION">power_set_mode</TT> again before the mode change had completed.</P></LI></OL><P>If the power management package has been configured not to use aseparate thread then obviously the behaviour is somewhat different.The call to <TTCLASS="FUNCTION">power_set_mode</TT> will now iterate overthe various power controllers immediately, rather than leaving this toa separate thread, and the whole mode change completes before<TTCLASS="FUNCTION">power_set_mode</TT> returns. If some other thread or aDSR calls <TTCLASS="FUNCTION">power_set_mode</TT> concurrently thebehaviour of the system is undefined. However, it is still legal for apower controller to call <TTCLASS="FUNCTION">power_set_mode</TT>:effectively this is a recursive call; it is detected by the system,and internal state is updated; the recursive<TTCLASS="FUNCTION">power_set_mode</TT> call now returns, and when thepower controller returns back to the original<TTCLASS="FUNCTION">power_set_mode</TT> call it detects what has happened,aborts the previous mode change, and starts a new mode change asrequested by the controller.</P><P><TTCLASS="FUNCTION">power_set_mode</TT> is normally invoked from threadcontext. If a separate power management thread is used it can beinvoked safely from DSR context. If the system is configured not touse such a thread, it may or may not be safe to invoke this functionfrom DSR context: essentially the function just iterates throughthe various power controllers, and the documentation or source code ofeach controller present in the current system will have to be examinedto determine whether or not this can happen safely in DSR context.<TTCLASS="FUNCTION">power_set_mode</TT> should never be invoked fromISR context.</P></DIV><DIVCLASS="REFSECT1"><ANAME="POWER-CHANGE-CONTROLLER"></A><H2>Manipulating an Individual Power Controller</H2><P>In some cases it is desirable to set the power mode of an individualcontroller separately from the mode for the system as a whole. Forexample if a device is not currently being used then the associatedpower controller could be set to <TTCLASS="LITERAL">PowerMode_Off</TT>,even while the system as a whole is still active. This can be achievedby calling the function<TTCLASS="FUNCTION">power_set_controller_mode</TT>. It takes twoarguments: the first identifies a particular controller; the secondspecifies the desired new power mode for that controller. The functionoperates in much the same way as <TTCLASS="FUNCTION">power_set_mode</TT>,for example if a separate power management thread is being used then<TTCLASS="FUNCTION">power_set_controller_mode</TT> operates bymanipulating some internal state and waking up that thread. Thelimitations are also much the same as for<TTCLASS="FUNCTION">power_set_mode</TT>, so for example<TTCLASS="FUNCTION">power_set_controller_mode</TT> should not be invokedfrom inside ISRs.</P><P>Manipulating individual controllers is often used in conjunction withthe function <AHREF="power-attached.html"><TTCLASS="FUNCTION">power_set_controller_attached</TT></A>,allowing the policy module to specify which controllers are affectedby global mode changes.</P></DIV><DIVCLASS="REFSECT1"><ANAME="POWER-CHANGE-CONTROLLER-NOW"></A><H2>Direct Manipulation of a Power Controller</H2><P>In exceptional circumstances it may be necessary to invoke a powercontroller directly, bypassing the power management thread andhigher-level functionality such as <AHREF="power-policy.html#POWER-POLICY-CALLBACK">callback functions</A>. Thefunction <TTCLASS="FUNCTION">power_set_controller_mode_now</TT> allowsthis. It takes two arguments, a controller and a mode, just like<TTCLASS="FUNCTION">power_set_controller_mode</TT>.</P><P>Use of <TTCLASS="FUNCTION">power_set_controller_mode_now</TT> isdangerous. For example no attempt is made to synchronise with anyother power mode changes that might be happening concurrently. Apossible use is when the system gets woken up out of<SPANCLASS="TYPE">sleep</SPAN> mode: depending on the hardware, on which powercontrollers are present, and on the application code it may benecessary to wake up some power controllers immediately before thesystem as a whole is ready to run again.</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-info.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-policy.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Power Management Information</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="services-power.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Support for Policy Modules</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

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