]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOPMPowerSource.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@
29 #include <IOKit/pwr_mgt/IOPMPowerSource.h>
31 #define super OSObject
33 OSDefineMetaClassAndStructors(IOPMPowerSource
, OSObject
)
35 // **********************************************************************************
38 // **********************************************************************************
39 bool IOPMPowerSource::init (unsigned short whichBatteryIndex
)
44 bBatteryIndex
= whichBatteryIndex
;
50 // **********************************************************************************
51 // capacityPercentRemaining
53 // **********************************************************************************
54 unsigned long IOPMPowerSource::capacityPercentRemaining (void)
56 unsigned long percentage
= 0;
59 percentage
= (bCurCapacity
* 100) / bMaxCapacity
;
61 // always return a non-zero value unless the real capacity IS zero.
62 if (percentage
== 0 && bCurCapacity
> 0)
68 // **********************************************************************************
71 // **********************************************************************************
72 bool IOPMPowerSource::atWarnLevel (void)
74 return bFlags
& kBatteryAtWarn
;
77 // **********************************************************************************
80 // **********************************************************************************
81 bool IOPMPowerSource::acConnected (void)
83 return bFlags
& kACInstalled
;
86 // **********************************************************************************
89 // **********************************************************************************
90 bool IOPMPowerSource::depleted (void)
92 return bFlags
& kBatteryDepleted
;
95 // **********************************************************************************
98 // **********************************************************************************
99 bool IOPMPowerSource::isInstalled (void)
101 return bFlags
& kBatteryInstalled
;
104 // **********************************************************************************
107 // **********************************************************************************
108 bool IOPMPowerSource::isCharging (void)
110 return bFlags
& kBatteryCharging
;
113 // **********************************************************************************
116 // **********************************************************************************
117 unsigned long IOPMPowerSource::timeRemaining (void)
119 return bTimeRemaining
;
122 // **********************************************************************************
125 // **********************************************************************************
126 unsigned long IOPMPowerSource::maxCapacity (void)
131 // **********************************************************************************
134 // **********************************************************************************
135 unsigned long IOPMPowerSource::curCapacity (void)
140 // **********************************************************************************
143 // **********************************************************************************
144 long IOPMPowerSource::currentDrawn (void)
149 // **********************************************************************************
152 // **********************************************************************************
154 unsigned long IOPMPowerSource::voltage (void)
159 // **********************************************************************************
162 // **********************************************************************************
164 void IOPMPowerSource::updateStatus (void)