]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOPMchangeNoteList.cpp
5d8d94c8bc20041cad01b4c75f07ff364364fee9
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 #include <IOKit/pwr_mgt/IOPM.h>
26 #include <IOKit/pwr_mgt/IOPMchangeNoteList.h>
28 #define super OSObject
29 OSDefineMetaClassAndStructors(IOPMchangeNoteList
,OSObject
)
31 //*********************************************************************************
34 //*********************************************************************************
35 void IOPMchangeNoteList::initialize ( void )
41 for ( i
= 0; i
< IOPMMaxChangeNotes
; i
++ ) {
42 changeNote
[i
].flags
= IOPMNotInUse
;
46 //*********************************************************************************
49 //*********************************************************************************
51 long IOPMchangeNoteList::createChangeNote ( void )
55 i
= increment(firstUnused
);
56 if ( firstInList
== i
) {
65 //*********************************************************************************
68 // Return the ordinal of the first change note in the list.
69 // If the list is empty, return -1.
70 //*********************************************************************************
72 long IOPMchangeNoteList::currentChange ( void )
74 if ( firstUnused
== firstInList
) {
82 //*********************************************************************************
85 // Return the ordinal of the last change note in the list.
86 // If the list is empty, return -1.
87 //*********************************************************************************
89 long IOPMchangeNoteList::latestChange ( void )
91 if ( firstUnused
== firstInList
) {
95 return decrement(firstUnused
);
99 //*********************************************************************************
100 // releaseHeadChangeNote
102 // Mark the head node unused.
103 // This happens when the first change in the list is completely processed.
104 // That is, all interested parties have acknowledged it, and power is settled
106 //*********************************************************************************
108 IOReturn
IOPMchangeNoteList::releaseHeadChangeNote ( void )
110 changeNote
[firstInList
].flags
= IOPMNotInUse
;
111 firstInList
= increment(firstInList
);
115 //*********************************************************************************
116 // releaseTailChangeNote
118 // Mark the tail node unused.
119 // This happens when a power change is queued up after another which has
120 // not yet been started, and the second one supercedes the first. The data in
121 // the second is copied into the first and the the second is released. This
122 // collapses the first change out of the list.
123 //*********************************************************************************
125 IOReturn
IOPMchangeNoteList::releaseTailChangeNote ( void )
127 firstUnused
= decrement(firstUnused
);
128 changeNote
[firstUnused
].flags
= IOPMNotInUse
;
132 //*********************************************************************************
135 //*********************************************************************************
137 bool IOPMchangeNoteList::changeNoteInUse ( unsigned long ordinal
)
139 if ( changeNote
[ordinal
].flags
== IOPMNotInUse
) {
147 //*********************************************************************************
150 // If the parameter corresponds to the most recent power change notification
151 // passed to drivers and children, return -1. Otherwise, return the array
152 // position of the next notification in the circular list.
153 //*********************************************************************************
155 long IOPMchangeNoteList::nextChangeNote ( unsigned long ordinal
)
159 i
= increment(ordinal
);
160 if ( i
== firstUnused
) {
166 //*********************************************************************************
169 // Increment the parameter mod the circular list size and return it.
170 //*********************************************************************************
172 unsigned long IOPMchangeNoteList::increment ( unsigned long ordinal
)
174 if ( ordinal
== (IOPMMaxChangeNotes
- 1) ) {
182 //*********************************************************************************
185 // Decrement the parameter mod the circular list size and return it.
186 //*********************************************************************************
188 unsigned long IOPMchangeNoteList::decrement ( unsigned long ordinal
)
190 if ( ordinal
== 0 ) {
191 return IOPMMaxChangeNotes
- 1;
198 //*********************************************************************************
199 // previousChangeNote
201 // If the parameter corresponds to the oldest power change notification
202 // passed to drivers and children, return -1. Otherwise, return the array
203 // position of the previous notification in the circular list.
204 //*********************************************************************************
206 long IOPMchangeNoteList::previousChangeNote ( unsigned long ordinal
)
208 if ( ordinal
== firstInList
) {
211 return decrement(ordinal
);
214 //*********************************************************************************
217 //*********************************************************************************
219 bool IOPMchangeNoteList::listEmpty ( void )
221 return ( firstInList
== firstUnused
) ;