]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Kernel/IOPMPowerSource.cpp
b9db0f649e0830282f6978f8e9045c8e845495f9
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 #include <IOKit/pwr_mgt/IOPMPowerSource.h>
28 #define super OSObject
30 OSDefineMetaClassAndStructors(IOPMPowerSource
, OSObject
)
32 // **********************************************************************************
35 // **********************************************************************************
36 bool IOPMPowerSource::init (unsigned short whichBatteryIndex
)
41 bBatteryIndex
= whichBatteryIndex
;
47 // **********************************************************************************
48 // capacityPercentRemaining
50 // **********************************************************************************
51 unsigned long IOPMPowerSource::capacityPercentRemaining (void)
53 unsigned long percentage
= 0;
56 percentage
= (bCurCapacity
* 100) / bMaxCapacity
;
58 // always return a non-zero value unless the real capacity IS zero.
59 if (percentage
== 0 && bCurCapacity
> 0)
65 // **********************************************************************************
68 // **********************************************************************************
69 bool IOPMPowerSource::atWarnLevel (void)
71 return bFlags
& kBatteryAtWarn
;
74 // **********************************************************************************
77 // **********************************************************************************
78 bool IOPMPowerSource::acConnected (void)
80 return bFlags
& kACInstalled
;
83 // **********************************************************************************
86 // **********************************************************************************
87 bool IOPMPowerSource::depleted (void)
89 return bFlags
& kBatteryDepleted
;
92 // **********************************************************************************
95 // **********************************************************************************
96 bool IOPMPowerSource::isInstalled (void)
98 return bFlags
& kBatteryInstalled
;
101 // **********************************************************************************
104 // **********************************************************************************
105 bool IOPMPowerSource::isCharging (void)
107 return bFlags
& kBatteryCharging
;
110 // **********************************************************************************
113 // **********************************************************************************
114 unsigned long IOPMPowerSource::timeRemaining (void)
116 return bTimeRemaining
;
119 // **********************************************************************************
122 // **********************************************************************************
123 unsigned long IOPMPowerSource::maxCapacity (void)
128 // **********************************************************************************
131 // **********************************************************************************
132 unsigned long IOPMPowerSource::curCapacity (void)
137 // **********************************************************************************
140 // **********************************************************************************
141 long IOPMPowerSource::currentDrawn (void)
146 // **********************************************************************************
149 // **********************************************************************************
151 unsigned long IOPMPowerSource::voltage (void)
156 // **********************************************************************************
159 // **********************************************************************************
161 void IOPMPowerSource::updateStatus (void)