]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOPMchangeNoteList.cpp
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 #include <IOKit/pwr_mgt/IOPM.h>
23 #include <IOKit/pwr_mgt/IOPMchangeNoteList.h>
25 #define super OSObject
26 OSDefineMetaClassAndStructors(IOPMchangeNoteList
,OSObject
)
28 //*********************************************************************************
31 //*********************************************************************************
32 void IOPMchangeNoteList::initialize ( void )
38 for ( i
= 0; i
< IOPMMaxChangeNotes
; i
++ ) {
39 changeNote
[i
].flags
= IOPMNotInUse
;
43 //*********************************************************************************
46 //*********************************************************************************
48 long IOPMchangeNoteList::createChangeNote ( void )
52 i
= increment(firstUnused
);
53 if ( firstInList
== i
) {
62 //*********************************************************************************
65 // Return the ordinal of the first change note in the list.
66 // If the list is empty, return -1.
67 //*********************************************************************************
69 long IOPMchangeNoteList::currentChange ( void )
71 if ( firstUnused
== firstInList
) {
79 //*********************************************************************************
82 // Return the ordinal of the last change note in the list.
83 // If the list is empty, return -1.
84 //*********************************************************************************
86 long IOPMchangeNoteList::latestChange ( void )
88 if ( firstUnused
== firstInList
) {
92 return decrement(firstUnused
);
96 //*********************************************************************************
97 // releaseHeadChangeNote
99 // Mark the head node unused.
100 // This happens when the first change in the list is completely processed.
101 // That is, all interested parties have acknowledged it, and power is settled
103 //*********************************************************************************
105 IOReturn
IOPMchangeNoteList::releaseHeadChangeNote ( void )
107 changeNote
[firstInList
].flags
= IOPMNotInUse
;
108 firstInList
= increment(firstInList
);
112 //*********************************************************************************
113 // releaseTailChangeNote
115 // Mark the tail node unused.
116 // This happens when a power change is queued up after another which has
117 // not yet been started, and the second one supercedes the first. The data in
118 // the second is copied into the first and the the second is released. This
119 // collapses the first change out of the list.
120 //*********************************************************************************
122 IOReturn
IOPMchangeNoteList::releaseTailChangeNote ( void )
124 firstUnused
= decrement(firstUnused
);
125 changeNote
[firstUnused
].flags
= IOPMNotInUse
;
129 //*********************************************************************************
132 //*********************************************************************************
134 bool IOPMchangeNoteList::changeNoteInUse ( unsigned long ordinal
)
136 if ( changeNote
[ordinal
].flags
== IOPMNotInUse
) {
144 //*********************************************************************************
147 // If the parameter corresponds to the most recent power change notification
148 // passed to drivers and children, return -1. Otherwise, return the array
149 // position of the next notification in the circular list.
150 //*********************************************************************************
152 long IOPMchangeNoteList::nextChangeNote ( unsigned long ordinal
)
156 i
= increment(ordinal
);
157 if ( i
== firstUnused
) {
163 //*********************************************************************************
166 // Increment the parameter mod the circular list size and return it.
167 //*********************************************************************************
169 unsigned long IOPMchangeNoteList::increment ( unsigned long ordinal
)
171 if ( ordinal
== (IOPMMaxChangeNotes
- 1) ) {
179 //*********************************************************************************
182 // Decrement the parameter mod the circular list size and return it.
183 //*********************************************************************************
185 unsigned long IOPMchangeNoteList::decrement ( unsigned long ordinal
)
187 if ( ordinal
== 0 ) {
188 return IOPMMaxChangeNotes
- 1;
195 //*********************************************************************************
196 // previousChangeNote
198 // If the parameter corresponds to the oldest power change notification
199 // passed to drivers and children, return -1. Otherwise, return the array
200 // position of the previous notification in the circular list.
201 //*********************************************************************************
203 long IOPMchangeNoteList::previousChangeNote ( unsigned long ordinal
)
205 if ( ordinal
== firstInList
) {
208 return decrement(ordinal
);
211 //*********************************************************************************
214 //*********************************************************************************
216 bool IOPMchangeNoteList::listEmpty ( void )
218 return ( firstInList
== firstUnused
) ;