OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [power/] [common/] [v2_0/] [doc/] [power-intro.html] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
<!-- Copyright (C) 2001 Red Hat, Inc.                                -->
2
<!-- This material may be distributed only subject to the terms      -->
3
<!-- and conditions set forth in the Open Publication License, v1.0  -->
4
<!-- or later (the latest version is presently available at          -->
5
<!-- http://www.opencontent.org/openpub/).                           -->
6
<!-- Distribution of substantively modified versions of this         -->
7
<!-- document is prohibited without the explicit permission of the   -->
8
<!-- copyright holder.                                               -->
9
<!-- Distribution of the work or derivative of the work in any       -->
10
<!-- standard (paper) book form is prohibited unless prior           -->
11
<!-- permission is obtained from the copyright holder.               -->
12
<HTML
13
><HEAD
14
><TITLE
15
>Introduction</TITLE
16
><meta name="MSSmartTagsPreventParsing" content="TRUE">
17
<META
18
NAME="GENERATOR"
19
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
20
"><LINK
21
REL="HOME"
22
TITLE="eCos Power Management Support"
23
HREF="services-power.html"><LINK
24
REL="PREVIOUS"
25
TITLE="eCos Power Management Support"
26
HREF="services-power.html"><LINK
27
REL="NEXT"
28
TITLE="Power Management Information"
29
HREF="power-info.html"></HEAD
30
><BODY
31
CLASS="REFENTRY"
32
BGCOLOR="#FFFFFF"
33
TEXT="#000000"
34
LINK="#0000FF"
35
VLINK="#840084"
36
ALINK="#0000FF"
37
><DIV
38
CLASS="NAVHEADER"
39
><TABLE
40
WIDTH="100%"
41
BORDER="0"
42
CELLPADDING="0"
43
CELLSPACING="0"
44
><TR
45
><TH
46
COLSPAN="3"
47
ALIGN="center"
48
>eCos Power Management Support</TH
49
></TR
50
><TR
51
><TD
52
WIDTH="10%"
53
ALIGN="left"
54
VALIGN="bottom"
55
><A
56
HREF="services-power.html"
57
>Prev</A
58
></TD
59
><TD
60
WIDTH="80%"
61
ALIGN="center"
62
VALIGN="bottom"
63
></TD
64
><TD
65
WIDTH="10%"
66
ALIGN="right"
67
VALIGN="bottom"
68
><A
69
HREF="power-info.html"
70
>Next</A
71
></TD
72
></TR
73
></TABLE
74
><HR
75
ALIGN="LEFT"
76
WIDTH="100%"></DIV
77
><H1
78
><A
79
NAME="POWER-INTRO"
80
>Introduction</A
81
></H1
82
><DIV
83
CLASS="REFNAMEDIV"
84
><A
85
NAME="AEN6"
86
></A
87
><H2
88
>Name</H2
89
>Introduction&nbsp;--&nbsp;eCos support for Power Management</DIV
90
><DIV
91
CLASS="REFSECT1"
92
><A
93
NAME="POWER-INTRO-INTRO"
94
></A
95
><H2
96
>Introduction</H2
97
><P
98
>The eCos Power Management package provides a framework for
99
incorporating power management facilities in an embedded application.
100
However its functionality is deliberately limited.</P
101
><P
102
></P
103
><OL
104
TYPE="1"
105
><LI
106
><P
107
>The package does not contain any support for controlling the current
108
power mode of any given processor, device or board. Instead it is the
109
responsibility of the appropriate HAL or device driver package to
110
implement such support, by implementing <I
111
CLASS="FIRSTTERM"
112
>power
113
controllers</I
114
>. The power management package groups these
115
power controllers together and provides an interface for manipulating
116
them.</P
117
></LI
118
><LI
119
><P
120
>The package does not contain any power management policy support.
121
Specifically, including this package in an application does not by
122
itself ever cause the system to go into low-power mode. Instead it is
123
the responsibility of a separate policy module, provided by
124
higher-level application code or by some other package, to decide when
125
it would be appropriate to switch from one power mode to another. The
126
power management package then provides the mechanisms for making it
127
happen.</P
128
></LI
129
></OL
130
></DIV
131
><DIV
132
CLASS="REFSECT1"
133
><A
134
NAME="POWER-INTRO-INCLUDE"
135
></A
136
><H2
137
>Including Power Management</H2
138
><P
139
>The power management package is never included automatically in an
140
eCos configuration: it is not part of any target specification or of
141
any template. Instead it must be added explicitly to a configuration
142
if the intended application requires power management functionality.
143
When using the command-line <B
144
CLASS="COMMAND"
145
>ecosconfig</B
146
> tool this
147
can be achieved using a command such as:</P
148
><TABLE
149
BORDER="0"
150
BGCOLOR="#E0E0E0"
151
WIDTH="100%"
152
><TR
153
><TD
154
><PRE
155
CLASS="SCREEN"
156
>$ ecosconfig add power</PRE
157
></TD
158
></TR
159
></TABLE
160
><P
161
>The generic eCos user documentation should be consulted for more
162
information on how to use the various tools. The functionality
163
provided by the power management package is defined in the header file
164
<TT
165
CLASS="FILENAME"
166
>cyg/power/power.h</TT
167
>. This header
168
file can be used by both C and C++ code.</P
169
></DIV
170
><DIV
171
CLASS="REFSECT1"
172
><A
173
NAME="POWER-INTRO-MODES"
174
></A
175
><H2
176
>Power Modes</H2
177
><P
178
>There are four defined modes of operation:</P
179
><P
180
></P
181
><DIV
182
CLASS="VARIABLELIST"
183
><DL
184
><DT
185
>active</DT
186
><DD
187
><P
188
>The system is fully operational, and power consumption is expected to
189
be high.</P
190
></DD
191
><DT
192
>idle</DT
193
><DD
194
><P
195
>There has been little or no activity for a short period of time. It is
196
up to the policy module to determine what constitutes a short period
197
of time, but typically it will be some tenths of a second or some
198
small number of seconds. A possible action when entering idle mode is
199
to reduce the system's clock speed, thus reducing the power drawn by
200
the cpu.</P
201
><P
202
>Note that typically this power mode is not entered automatically
203
whenever the idle thread starts running. Instead it is entered when
204
the policy module discovers that for a certain period of time the
205
system has been spending most of its time in the idle thread.
206
Theoretically it is possible to implement a policy module that would
207
cause a switch to idle mode as soon as the idle thread starts running,
208
but that could result in a great many power mode changes for no
209
immediate benefit.</P
210
></DD
211
><DT
212
>sleep</DT
213
><DD
214
><P
215
>The system has been idle for a significant period of time, perhaps
216
some tens of seconds. It is desirable to shut down any hardware that
217
is drawing a significant amount of power, for example a screen
218
backlight.</P
219
></DD
220
><DT
221
>off</DT
222
><DD
223
><P
224
>The system is powered down. Power consumption should be minimized.
225
Some special action may be needed before the system comes back up, for
226
example the user may need to press a specific button.</P
227
></DD
228
></DL
229
></DIV
230
><P
231
>The exact transitions that will happen are decided by the policy
232
module. One policy module might include transitions from active to
233
idle, from idle to sleep, from sleep to off, and from any of idle,
234
sleep or off directly back to active. Another policy module might
235
only use the active and off states, bypassing the intermediate ones.</P
236
></DIV
237
><DIV
238
CLASS="REFSECT1"
239
><A
240
NAME="POWER-INTRO-CONTROLLERS"
241
></A
242
><H2
243
>Power Controllers</H2
244
><P
245
>The power management package operates primarily on power controllers.
246
The main functionality provided by a power controller is to switch the
247
power mode for some part of the system, for example the lcd display or
248
the cpu. A power controller consists primarily of a function which
249
will be invoked to switch the power mode for the part of the overall
250
system being controlled, plus some auxiliary data. A typical system
251
will include a number of different power controllers:</P
252
><P
253
></P
254
><OL
255
TYPE="1"
256
><LI
257
><P
258
>Usually there will be one power controller
259
<TT
260
CLASS="VARNAME"
261
>power_controller_cpu</TT
262
> associated with the processor
263
or with the target platform, and provided by the corresponding HAL
264
package. It is this controller which is responsible for switching off
265
the system when entering the <SPAN
266
CLASS="TYPE"
267
>off</SPAN
268
> mode, which makes it
269
somewhat special: attempting to switch off the cpu before other
270
devices like the lcd display does not make sense because the cpu would
271
no longer be executing any instructions for the latter operation.
272
Therefore this power controller has to be invoked last when switching
273
to a lower-power mode, and similarly when switching back to a
274
higher-power mode it will be invoked first.</P
275
><P
276
>It should be noted that providing power management support is not a
277
hard requirement when porting eCos to a new processor or platform, and
278
many eCos ports predate the availability of power management support.
279
Therefore for any given platform it is distinctly possible that
280
<TT
281
CLASS="VARNAME"
282
>power_controller_cpu</TT
283
> is not yet provided, and if
284
full power management functionality is desired then the appropriate
285
HAL package would have to be extended first. System developers should
286
examine the relevant HAL documentation and sources to determine what
287
is actually available.</P
288
></LI
289
><LI
290
><P
291
>Some or all of the device drivers will supply their own power
292
controllers, as part of the device driver package. It is not required
293
that all device drivers provide power controllers. In some cases,
294
especially for devices that are integrated with the processor,
295
<TT
296
CLASS="VARNAME"
297
>power_controller_cpu</TT
298
> will take care of the
299
integrated devices as a side effect. In other cases the hardware may
300
not provide any functionality that allows power consumption to be
301
controlled. For any given device driver it is also possible that no
302
power controller exists either because it was not required when the
303
driver was written, or because the driver predates the availability of
304
power management. Again the relevant documentation and sources should
305
be consulted for further information.</P
306
></LI
307
><LI
308
><P
309
>There may be power controllers which are not associated directly with
310
any specific hardware. For example a TCP/IP stack could provide a
311
power controller so that it gets informed when the system has been
312
reactivated: by looking at the system clock it can determine for how
313
long the system has been switched off; using this information it can
314
then recover from expired dhcp leases, or even to shut down any stream
315
connections that may have become invalid (although arguably the stack
316
should have refused to go to <SPAN
317
CLASS="TYPE"
318
>off</SPAN
319
> mode while there were
320
open connections).</P
321
></LI
322
></OL
323
></DIV
324
><DIV
325
CLASS="REFSECT1"
326
><A
327
NAME="POWER-INTRO-OPERATION"
328
></A
329
><H2
330
>Basic Operation</H2
331
><P
332
>By default the Power Management package creates a thread during
333
initialization. It is also possible for the package to be used without
334
such a thread, for example in configurations which do not include a
335
full kernel, and this alternative is described below. When a separate
336
thread is used the stacksize and priority for this thread can be
337
controlled by configuration options
338
<TT
339
CLASS="VARNAME"
340
>CYGNUM_POWER_THREAD_STACKSIZE</TT
341
> and
342
<TT
343
CLASS="VARNAME"
344
>CYGNUM_POWER_THREAD_PRIORITY</TT
345
>. Typically the thread
346
will just wait on a semaphore internal to the package, and will do
347
nothing until some other part of the system requests a change to the
348
power mode.</P
349
><P
350
>At some point the policy module will decide that the system should
351
move into a lower-power mode, for example from active to idle. This is
352
achieved by calling the function <TT
353
CLASS="FUNCTION"
354
>power_set_mode</TT
355
>,
356
provided by the power management package and declared in <TT
357
CLASS="FILENAME"
358
>cyg/power/power.h</TT
359
>, with a single
360
argument, <TT
361
CLASS="LITERAL"
362
>PowerMode_Idle</TT
363
>. This function manipulates
364
some internal state and posts the semaphore, thus waking up the power
365
management thread. Note that the function returns before the mode
366
change has completed, and in fact depending on thread priorities this
367
return may happen before any power controller has been invoked.</P
368
><P
369
>When the power management thread wakes up it examines the internal
370
state to figure out what it should be doing. In this case it is
371
supposed to change the global power mode, so it will iterate over all
372
the power controllers requesting each one to switch to the
373
<SPAN
374
CLASS="TYPE"
375
>idle</SPAN
376
> mode. It is up to each power controller to handle
377
this request appropriately. Optionally the thread will invoke a
378
callback function after processing each power controller, so that
379
higher-level code such as the policy module can more easily keep
380
track of the actual state of each controller. Once the thread has
381
iterated through all the power controllers it will again wait on the
382
internal semaphore for the next request to arrive.</P
383
><DIV
384
CLASS="NOTE"
385
><BLOCKQUOTE
386
CLASS="NOTE"
387
><P
388
><B
389
>Note: </B
390
>At present the power management thread always runs at a single
391
priority, which defaults to a low priority. A possible future
392
enhancement would be to support two separate priorities. When
393
switching to a lower-powered mode the thread would run at a low
394
priority as before, thus allowing other threads to run and get a
395
chance to cancel this mode change. When switching to a higher-powered
396
mode the thread would run at a high priority. This could be especially
397
important when moving out of the <SPAN
398
CLASS="TYPE"
399
>off</SPAN
400
> state: for example
401
it would ensure that all device drivers get a chance to wake up before
402
ordinary application threads get to run again and possibly attempt I/O
403
operations.</P
404
></BLOCKQUOTE
405
></DIV
406
><P
407
>Although usually calls to <TT
408
CLASS="FUNCTION"
409
>power_set_mode</TT
410
> will
411
come from just one place in the policy module, this is not a hard
412
requirement. It is possible for multiple threads to call this
413
function, with no need for any synchronization. If the power
414
management thread is in the middle of performing a mode change and a
415
new request comes in, the thread will detect this, abort the current
416
operation, and start iterating through the power controllers again
417
with the new mode. This check happens between every power controller
418
invocation. Usefully this makes it possible for power controllers
419
themselves to manipulate power modes: a power controller is invoked to
420
change mode; for some reason it determines that the new mode is
421
inappropriate; it calls <TT
422
CLASS="FUNCTION"
423
>power_set_mode</TT
424
> to move
425
the system back to another mode; when the power controller returns
426
this event will be detected; the power management thread will abort
427
the current mode change, and start the new one.</P
428
><P
429
>In addition to changing the power mode for the system as a whole,
430
individual controllers can be manipulated using the function
431
<TT
432
CLASS="FUNCTION"
433
>power_set_controller_mode</TT
434
>. For example, while the
435
system as a whole might be in <SPAN
436
CLASS="TYPE"
437
>active</SPAN
438
> mode certain devices
439
might be kept in <SPAN
440
CLASS="TYPE"
441
>sleep</SPAN
442
> mode until they are explicitly
443
activated. It is possible to mix concurrent calls to
444
<TT
445
CLASS="FUNCTION"
446
>power_set_mode</TT
447
> and
448
<TT
449
CLASS="FUNCTION"
450
>power_set_controller_mode</TT
451
>, and when a power
452
controller is invoked it may use
453
<TT
454
CLASS="FUNCTION"
455
>power_set_controller_mode</TT
456
> to request further
457
changes to its own or to another controller's mode as required.</P
458
><P
459
>There are some scenarios where the power management package should not
460
use its own thread. One scenario is if the configuration is
461
specifically for a single-threaded application such as RedBoot.
462
Another scenario is if the policy module already involves a separate
463
thread: it may make more sense if the various power management
464
operations are synchronous with respect to the calling thread. The use
465
of a separate thread inside the power management package is controlled
466
by the configuration option <TT
467
CLASS="VARNAME"
468
>CYGPKG_POWER_THREAD</TT
469
>,
470
which is active only if the kernel package is present and enabled by
471
default.</P
472
><P
473
>If no separate power management thread is used then obviously the
474
implementations of <TT
475
CLASS="FUNCTION"
476
>power_set_mode</TT
477
> and
478
<TT
479
CLASS="FUNCTION"
480
>power_set_controller_mode</TT
481
> will be somewhat
482
different: instead of waking up a separate thread to do the work,
483
these functions will now manipulate the power controllers directly. If
484
the system does still involve multiple threads then only one thread
485
may call <TT
486
CLASS="FUNCTION"
487
>power_set_mode</TT
488
> or
489
<TT
490
CLASS="FUNCTION"
491
>power_set_controller_mode</TT
492
> at a time: the power
493
management package will not provide any synchronization, that must
494
happen at a higher level. However when a power controller is invoked
495
it can still call these functions as required.</P
496
></DIV
497
><DIV
498
CLASS="NAVFOOTER"
499
><HR
500
ALIGN="LEFT"
501
WIDTH="100%"><TABLE
502
WIDTH="100%"
503
BORDER="0"
504
CELLPADDING="0"
505
CELLSPACING="0"
506
><TR
507
><TD
508
WIDTH="33%"
509
ALIGN="left"
510
VALIGN="top"
511
><A
512
HREF="services-power.html"
513
>Prev</A
514
></TD
515
><TD
516
WIDTH="34%"
517
ALIGN="center"
518
VALIGN="top"
519
><A
520
HREF="services-power.html"
521
>Home</A
522
></TD
523
><TD
524
WIDTH="33%"
525
ALIGN="right"
526
VALIGN="top"
527
><A
528
HREF="power-info.html"
529
>Next</A
530
></TD
531
></TR
532
><TR
533
><TD
534
WIDTH="33%"
535
ALIGN="left"
536
VALIGN="top"
537
>eCos Power Management Support</TD
538
><TD
539
WIDTH="34%"
540
ALIGN="center"
541
VALIGN="top"
542
>&nbsp;</TD
543
><TD
544
WIDTH="33%"
545
ALIGN="right"
546
VALIGN="top"
547
>Power Management Information</TD
548
></TR
549
></TABLE
550
></DIV
551
></BODY
552
></HTML
553
>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.