📄 power management.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0060)http://www.geocities.com/marco_corvi/games/lkpe/pm/index.htm -->
<HTML><HEAD><TITLE>Power Management</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"><LINK
href="Power Management_file/style.css" rel=stylesheet>
<META content="MSHTML 6.00.2800.1170" name=GENERATOR></HEAD>
<BODY>
<H2>Power Management</H2>
<P>
<DIV>The Power Management (PM) subsystem is </DIV>
<DIV>The power management is compiled in the kernel with the
<CODE>CONFIG_PM</CODE> option. </DIV>
<DIV>Power Management aware drivers rely on this subsystem in order to perform
safely with a power managed hardware.
<UL>
<LI>The driver should first <CODE>pm_register</CODE> with the PM subsytem.
<LI>Next it must call <CODE>pm_access</CODE> before each hardware access.
<LI>Request or packet-driven drivers should call <CODE>pm_dev_idle</CODE> when
the device is not being used.
<LI>When unloaded, the driver must <CODE>pm_unregister</CODE> from the PM
subsystem. </LI></UL></DIV>
<DIV><CODE>pm_register</CODE> returns a pointer to a <CODE>pm_dev</CODE> (used
thereon by the driver to communicate with the PM), on NULL if it fails. It takes
three parameters,
<UL>
<LI><CODE>pm_dev_t type</CODE>, (actually an int). This specifies the type of
the driver that is registering with the PM. Several types are defined in the
header pm.h: PM_UNKNOWN_DEV, PM_SYS_DEV, PM_PCI_DEV, and a few others.
<LI><CODE>unsigned long id</CODE>, an identificator of the driver.
<LI><CODE>pm_callback callback</CODE>, the callback driver' method invoked by
the PM to perform requests on the driver. For example in case of a suspend or
a resume. </LI></UL></DIV>
<DIV>The structure <CODE>pm_dev</CODE> contains
<UL>
<LI><CODE>type</CODE>, the driver' type;
<LI><CODE>id</CODE>, the driver' id;
<LI><CODE>callback</CODE>, pointer to the driver' callback;
<LI><CODE>data</CODE>, a void * (private data ???);
<LI><CODE>flags</CODE>, (not used);
<LI><CODE>state</CODE> holds the driver PM D-state;
<LI><CODE>prev_state</CODE>, is used to rollback a failed callback;
<LI>and a list_head used for internal management by the PM subsystem.
</LI></UL><CODE>data</CODE>, <CODE>flags</CODE> and states are set to 0 by
<CODE>pm_register</CODE>. </DIV>
<DIV>The <CODE>pm_callback()</CODE> takes three parameters,
<UL>
<LI><CODE>dev</CODE>, pointer to the pm_dev (associated to the driver);
<LI><CODE>pm_request_t rqst</CODE>, the request code. The possible codes are
listed in pm.h:
<UL>
<LI>PM_SUSPEND, enter state D1 or D2 or D3
<LI>PM_RESUME, enter state D0
<LI>PM_SAVE_STATE, save driver' state to memory
<LI>PM_SET_WAKEUP, enable wake-on
<LI>PM_GET_RESOURCES, and PM_SET_RESOURCES, for bus resource management
<LI>PM_EJECT, PM_LOCK </LI></UL>
<LI><CODE>void * data</CODE>, for PM_SUSPEND contains the ACPI D-state.
</LI></UL>This function is called by the PM subsystem in a process context and
may sleep. The drivers returns 0 on success. After a successful PM_SUSPEND the
driver should not process request or access hardware until a call to
<CODE>pm_access</CODE> is made. </DIV>
<DIV>The driver calls <CODE>pm_access</CODE> and <CODE>pm_dev_idle</CODE> with
the pm_dev pointer returned by the <CODE>pm_register</CODE>. </DIV>
<DIV>The kernel interface of the PM subsystem comprises
<UL>
<LI><CODE>pm_send</CODE>, sends a request to a driver;
<LI><CODE>pm_send_all</CODE>, sends a request to all drivers;
<LI><CODE>pm_find</CODE>, finds a device of the specified type.
</LI></UL>Finally the internal functions are
<UL>
<LI><CODE>pm_undo_all</CODE>, rollback;
<LI><CODE>__pm_unregister</CODE>; </LI></UL></DIV>
<P><B>Exercise</B><BR>
<DIV>Write a simple driver that registers with the PM susbsystem. Verify that
the callback is invoked. You can force a suspend/resume with apmsleep,
<CENTER><CODE>apmsleep +00:01 </CODE></CENTER>see apmsleep.1 for more
informations. <BR>Here is a solution: <A
href="http://www.geocities.com/marco_corvi/games/lkpe/pm/example.c">example.c</A>
and the <A
href="http://www.geocities.com/marco_corvi/games/lkpe/pm/Makefile">Makefile</A>.
</DIV>
<P><BR clear=all><FONT size=-1>Marco Corvi - 2003</FONT> <!-- text below generated by server. PLEASE REMOVE --></OBJECT></LAYER>
<DIV></DIV></SPAN></STYLE></NOSCRIPT></TABLE></SCRIPT></APPLET>
<SCRIPT
language=JavaScript>var PUpage="76001084"; var PUprop="geocities"; </SCRIPT>
<SCRIPT language=JavaScript src="Power Management_file/pu5geo.js"></SCRIPT>
<SCRIPT language=JavaScript src="Power Management_file/ygIELib9.js"></SCRIPT>
<SCRIPT language=JavaScript>var yviContents='http://us.toto.geo.yahoo.com/toto?s=76001084&l=NE&b=1&t=1057746830';yviR='us';yfiEA(0);</SCRIPT>
<SCRIPT language=JavaScript src="Power Management_file/mc.js"></SCRIPT>
<SCRIPT language=JavaScript src="Power Management_file/geov2.js"></SCRIPT>
<SCRIPT language=javascript>geovisit();</SCRIPT>
<NOSCRIPT><IMG height=1 alt=setstats src="Power Management_file/visit.gif"
width=1 border=0></NOSCRIPT> <IMG height=1 alt=1
src="Power Management_file/serv.gif" width=1> <!-- w7.geo.scd.yahoo.com compressed/chunked Wed Jul 9 03:33:50 PDT 2003 --></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -