]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOPMinformeeList.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/IOPMinformeeList.h>
24 #include <IOKit/pwr_mgt/IOPMinformee.h>
26 #define super OSObject
27 OSDefineMetaClassAndStructors(IOPMinformeeList
,OSObject
)
29 //*********************************************************************************
32 //*********************************************************************************
33 void IOPMinformeeList::initialize ( void )
39 //*********************************************************************************
42 //*********************************************************************************
44 IOReturn
IOPMinformeeList::addToList ( IOPMinformee
* newInformee
)
46 IOPMinformee
* nextInformee
;
47 nextInformee
= firstItem
; // Is new object already in the list?
48 while ( nextInformee
!= NULL
) {
49 if ( nextInformee
->whatObject
== newInformee
->whatObject
) {
50 return IOPMNoErr
; // yes, just return
52 nextInformee
= nextInList(nextInformee
);
54 newInformee
->nextInList
= firstItem
; // add it to list
55 firstItem
= newInformee
;
61 //*********************************************************************************
64 //*********************************************************************************
66 IOPMinformee
* IOPMinformeeList::firstInList ( void )
71 //*********************************************************************************
74 //*********************************************************************************
76 IOPMinformee
* IOPMinformeeList::nextInList ( IOPMinformee
* currentItem
)
78 if ( currentItem
!= NULL
) {
79 return (currentItem
->nextInList
);
84 //*********************************************************************************
87 //*********************************************************************************
89 unsigned long IOPMinformeeList::numberOfItems ( void )
94 //*********************************************************************************
97 // Look through the list for the one which points to the object identified
98 // by the parameter. Return a pointer to the list item or NULL.
99 //*********************************************************************************
101 IOPMinformee
* IOPMinformeeList::findItem ( IOService
* driverOrChild
)
103 IOPMinformee
* nextObject
;
105 nextObject
= firstInList();
106 while ( nextObject
!= NULL
) {
107 if ( nextObject
->whatObject
== driverOrChild
) {
110 nextObject
= nextInList(nextObject
);
116 //*********************************************************************************
119 // Find the item in the list, unlink it, and free it.
120 //*********************************************************************************
122 IOReturn
IOPMinformeeList::removeFromList ( IOService
* theItem
)
124 IOPMinformee
* item
= firstItem
;
127 if ( item
!= NULL
) {
128 if ( item
->whatObject
== theItem
) {
129 firstItem
= item
->nextInList
;
134 while ( item
->nextInList
!= NULL
) {
135 if ( item
->nextInList
->whatObject
== theItem
) {
136 temp
= item
->nextInList
;
137 item
->nextInList
= temp
->nextInList
;
142 item
= item
->nextInList
;
149 //*********************************************************************************
152 // Free all items in the list, and then free the list itself
153 //*********************************************************************************
155 void IOPMinformeeList::free (void )
157 IOPMinformee
* next
= firstItem
;
159 while ( next
!= NULL
) {
160 firstItem
= next
->nextInList
;