]>
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_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/IOPMPowerSource.h>
25 #define super OSObject
27 OSDefineMetaClassAndStructors(IOPMPowerSource
, OSObject
)
29 // **********************************************************************************
32 // **********************************************************************************
33 bool IOPMPowerSource::init (unsigned short whichBatteryIndex
)
38 bBatteryIndex
= whichBatteryIndex
;
44 // **********************************************************************************
45 // capacityPercentRemaining
47 // **********************************************************************************
48 unsigned long IOPMPowerSource::capacityPercentRemaining (void)
50 unsigned long percentage
= 0;
53 percentage
= (bCurCapacity
* 100) / bMaxCapacity
;
55 // always return a non-zero value unless the real capacity IS zero.
56 if (percentage
== 0 && bCurCapacity
> 0)
62 // **********************************************************************************
65 // **********************************************************************************
66 bool IOPMPowerSource::atWarnLevel (void)
68 return bFlags
& kBatteryAtWarn
;
71 // **********************************************************************************
74 // **********************************************************************************
75 bool IOPMPowerSource::acConnected (void)
77 return bFlags
& kACInstalled
;
80 // **********************************************************************************
83 // **********************************************************************************
84 bool IOPMPowerSource::depleted (void)
86 return bFlags
& kBatteryDepleted
;
89 // **********************************************************************************
92 // **********************************************************************************
93 bool IOPMPowerSource::isInstalled (void)
95 return bFlags
& kBatteryInstalled
;
98 // **********************************************************************************
101 // **********************************************************************************
102 bool IOPMPowerSource::isCharging (void)
104 return bFlags
& kBatteryCharging
;
107 // **********************************************************************************
110 // **********************************************************************************
111 unsigned long IOPMPowerSource::timeRemaining (void)
113 return bTimeRemaining
;
116 // **********************************************************************************
119 // **********************************************************************************
120 unsigned long IOPMPowerSource::maxCapacity (void)
125 // **********************************************************************************
128 // **********************************************************************************
129 unsigned long IOPMPowerSource::curCapacity (void)
134 // **********************************************************************************
137 // **********************************************************************************
138 long IOPMPowerSource::currentDrawn (void)
143 // **********************************************************************************
146 // **********************************************************************************
148 unsigned long IOPMPowerSource::voltage (void)
153 // **********************************************************************************
156 // **********************************************************************************
158 void IOPMPowerSource::updateStatus (void)