]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOPMinformeeList.cpp
2ba440a145087c2f5bc51f54c831bd925042870c
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 #include <IOKit/pwr_mgt/IOPM.h>
29 #include <IOKit/pwr_mgt/IOPMinformeeList.h>
30 #include <IOKit/pwr_mgt/IOPMinformee.h>
32 #define super OSObject
33 OSDefineMetaClassAndStructors(IOPMinformeeList
,OSObject
)
35 //*********************************************************************************
38 //*********************************************************************************
39 void IOPMinformeeList::initialize ( void )
45 //*********************************************************************************
48 //*********************************************************************************
50 IOReturn
IOPMinformeeList::addToList ( IOPMinformee
* newInformee
)
52 IOPMinformee
* nextInformee
;
53 nextInformee
= firstItem
; // Is new object already in the list?
54 while ( nextInformee
!= NULL
) {
55 if ( nextInformee
->whatObject
== newInformee
->whatObject
) {
56 return IOPMNoErr
; // yes, just return
58 nextInformee
= nextInList(nextInformee
);
60 newInformee
->nextInList
= firstItem
; // add it to list
61 firstItem
= newInformee
;
67 //*********************************************************************************
70 //*********************************************************************************
72 IOPMinformee
* IOPMinformeeList::firstInList ( void )
77 //*********************************************************************************
80 //*********************************************************************************
82 IOPMinformee
* IOPMinformeeList::nextInList ( IOPMinformee
* currentItem
)
84 if ( currentItem
!= NULL
) {
85 return (currentItem
->nextInList
);
90 //*********************************************************************************
93 //*********************************************************************************
95 unsigned long IOPMinformeeList::numberOfItems ( void )
100 //*********************************************************************************
103 // Look through the list for the one which points to the object identified
104 // by the parameter. Return a pointer to the list item or NULL.
105 //*********************************************************************************
107 IOPMinformee
* IOPMinformeeList::findItem ( IOService
* driverOrChild
)
109 IOPMinformee
* nextObject
;
111 nextObject
= firstInList();
112 while ( nextObject
!= NULL
) {
113 if ( nextObject
->whatObject
== driverOrChild
) {
116 nextObject
= nextInList(nextObject
);
122 //*********************************************************************************
125 // Find the item in the list, unlink it, and free it.
126 //*********************************************************************************
128 IOReturn
IOPMinformeeList::removeFromList ( IOService
* theItem
)
130 IOPMinformee
* item
= firstItem
;
133 if ( item
!= NULL
) {
134 if ( item
->whatObject
== theItem
) {
135 firstItem
= item
->nextInList
;
140 while ( item
->nextInList
!= NULL
) {
141 if ( item
->nextInList
->whatObject
== theItem
) {
142 temp
= item
->nextInList
;
143 item
->nextInList
= temp
->nextInList
;
148 item
= item
->nextInList
;
155 //*********************************************************************************
158 // Free all items in the list, and then free the list itself
159 //*********************************************************************************
161 void IOPMinformeeList::free (void )
163 IOPMinformee
* next
= firstItem
;
165 while ( next
!= NULL
) {
166 firstItem
= next
->nextInList
;