]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOPMPowerSourceList.cpp
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/IOPMPowerSourceList.h>
30 #include <IOKit/pwr_mgt/IOPMPowerSource.h>
32 #define super OSObject
33 OSDefineMetaClassAndStructors(IOPMPowerSourceList
, OSObject
)
35 //******************************************************************************
38 //******************************************************************************
40 IOPMPowerSourceList::initialize( void )
46 //******************************************************************************
49 //******************************************************************************
52 IOPMPowerSourceList::addToList(IOPMPowerSource
*newPowerSource
)
54 IOPMPowerSource
* nextPowerSource
;
56 // Is new object already in the list?
57 nextPowerSource
= firstItem
;
58 while (nextPowerSource
!= NULL
) {
59 if (nextPowerSource
== newPowerSource
) {
63 nextPowerSource
= nextInList(nextPowerSource
);
67 newPowerSource
->nextInList
= firstItem
;
68 firstItem
= newPowerSource
;
74 //******************************************************************************
77 //******************************************************************************
80 IOPMPowerSourceList::firstInList( void )
85 //******************************************************************************
88 //******************************************************************************
91 IOPMPowerSourceList::nextInList(IOPMPowerSource
*currentItem
)
93 if (currentItem
!= NULL
) {
94 return currentItem
->nextInList
;
99 //******************************************************************************
102 //******************************************************************************
105 IOPMPowerSourceList::numberOfItems( void )
110 //******************************************************************************
113 // Find the item in the list, unlink it, and free it.
114 //******************************************************************************
117 IOPMPowerSourceList::removeFromList( IOPMPowerSource
* theItem
)
119 IOPMPowerSource
* item
= firstItem
;
120 IOPMPowerSource
* temp
;
126 if (item
== theItem
) {
127 firstItem
= item
->nextInList
;
132 while (item
->nextInList
!= NULL
) {
133 if (item
->nextInList
== theItem
) {
134 temp
= item
->nextInList
;
135 item
->nextInList
= temp
->nextInList
;
140 item
= item
->nextInList
;
148 //******************************************************************************
151 // Free all items in the list, and then free the list itself
152 //******************************************************************************
155 IOPMPowerSourceList::free(void )
157 IOPMPowerSource
* next
= firstItem
;
159 while (next
!= NULL
) {
160 firstItem
= next
->nextInList
;