]>
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@
23 #include <IOKit/pwr_mgt/IOPM.h>
24 #include <IOKit/pwr_mgt/IOPMinformeeList.h>
25 #include <IOKit/pwr_mgt/IOPMinformee.h>
27 #define super OSObject
28 OSDefineMetaClassAndStructors(IOPMinformeeList
,OSObject
)
30 //*********************************************************************************
33 //*********************************************************************************
34 void IOPMinformeeList::initialize ( void )
40 //*********************************************************************************
43 //*********************************************************************************
45 IOReturn
IOPMinformeeList::addToList ( IOPMinformee
* newInformee
)
47 IOPMinformee
* nextInformee
;
48 nextInformee
= firstItem
; // Is new object already in the list?
49 while ( nextInformee
!= NULL
) {
50 if ( nextInformee
->whatObject
== newInformee
->whatObject
) {
51 return IOPMNoErr
; // yes, just return
53 nextInformee
= nextInList(nextInformee
);
55 newInformee
->nextInList
= firstItem
; // add it to list
56 firstItem
= newInformee
;
62 //*********************************************************************************
65 //*********************************************************************************
67 IOPMinformee
* IOPMinformeeList::firstInList ( void )
72 //*********************************************************************************
75 //*********************************************************************************
77 IOPMinformee
* IOPMinformeeList::nextInList ( IOPMinformee
* currentItem
)
79 if ( currentItem
!= NULL
) {
80 return (currentItem
->nextInList
);
85 //*********************************************************************************
88 //*********************************************************************************
90 unsigned long IOPMinformeeList::numberOfItems ( void )
95 //*********************************************************************************
98 // Look through the list for the one which points to the object identified
99 // by the parameter. Return a pointer to the list item or NULL.
100 //*********************************************************************************
102 IOPMinformee
* IOPMinformeeList::findItem ( IOService
* driverOrChild
)
104 IOPMinformee
* nextObject
;
106 nextObject
= firstInList();
107 while ( nextObject
!= NULL
) {
108 if ( nextObject
->whatObject
== driverOrChild
) {
111 nextObject
= nextInList(nextObject
);
117 //*********************************************************************************
120 // Find the item in the list, unlink it, and free it.
121 //*********************************************************************************
123 IOReturn
IOPMinformeeList::removeFromList ( IOService
* theItem
)
125 IOPMinformee
* item
= firstItem
;
128 if ( item
!= NULL
) {
129 if ( item
->whatObject
== theItem
) {
130 firstItem
= item
->nextInList
;
135 while ( item
->nextInList
!= NULL
) {
136 if ( item
->nextInList
->whatObject
== theItem
) {
137 temp
= item
->nextInList
;
138 item
->nextInList
= temp
->nextInList
;
143 item
= item
->nextInList
;
150 //*********************************************************************************
153 // Free all items in the list, and then free the list itself
154 //*********************************************************************************
156 void IOPMinformeeList::free (void )
158 IOPMinformee
* next
= firstItem
;
160 while ( next
!= NULL
) {
161 firstItem
= next
->nextInList
;