]> git.saurik.com Git - apple/xnu.git/blame - iokit/Kernel/IOPMPowerSource.cpp
xnu-344.21.73.tar.gz
[apple/xnu.git] / iokit / Kernel / IOPMPowerSource.cpp
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
d7e50217 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
d7e50217
A
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
13 * file.
14 *
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
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
d7e50217
A
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.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26#include <IOKit/pwr_mgt/IOPMPowerSource.h>
27
28#define super OSObject
29
30OSDefineMetaClassAndStructors(IOPMPowerSource, OSObject)
31
32// **********************************************************************************
33// init
34//
35// **********************************************************************************
36bool IOPMPowerSource::init (unsigned short whichBatteryIndex)
37{
38 if (!super::init ())
39 return false;
40
41 bBatteryIndex = whichBatteryIndex;
42 nextInList = 0;
43
44 return true;
45}
46
47// **********************************************************************************
48// capacityPercentRemaining
49//
50// **********************************************************************************
51unsigned long IOPMPowerSource::capacityPercentRemaining (void)
52{
53 unsigned long percentage = 0;
54
55 if (bMaxCapacity > 0)
56 percentage = (bCurCapacity * 100) / bMaxCapacity;
57
58 // always return a non-zero value unless the real capacity IS zero.
59 if (percentage == 0 && bCurCapacity > 0)
60 percentage = 1;
61
62 return percentage;
63}
64
65// **********************************************************************************
66// atWarnLevel
67//
68// **********************************************************************************
69bool IOPMPowerSource::atWarnLevel (void)
70{
71 return bFlags & kBatteryAtWarn;
72}
73
74// **********************************************************************************
75// acConnected
76//
77// **********************************************************************************
78bool IOPMPowerSource::acConnected (void)
79{
80 return bFlags & kACInstalled;
81}
82
83// **********************************************************************************
84// depleted
85//
86// **********************************************************************************
87bool IOPMPowerSource::depleted (void)
88{
89 return bFlags & kBatteryDepleted;
90}
91
92// **********************************************************************************
93// isInstalled
94//
95// **********************************************************************************
96bool IOPMPowerSource::isInstalled (void)
97{
98 return bFlags & kBatteryInstalled;
99}
100
101// **********************************************************************************
102// isCharging
103//
104// **********************************************************************************
105bool IOPMPowerSource::isCharging (void)
106{
107 return bFlags & kBatteryCharging;
108}
109
110// **********************************************************************************
111// timeRemaining
112//
113// **********************************************************************************
114unsigned long IOPMPowerSource::timeRemaining (void)
115{
116 return bTimeRemaining;
117}
118
119// **********************************************************************************
120// maxCapacity
121//
122// **********************************************************************************
123unsigned long IOPMPowerSource::maxCapacity (void)
124{
125 return bMaxCapacity;
126}
127
128// **********************************************************************************
129// curCapacity
130//
131// **********************************************************************************
132unsigned long IOPMPowerSource::curCapacity (void)
133{
134 return bCurCapacity;
135}
136
137// **********************************************************************************
138// currentDrawn
139//
140// **********************************************************************************
141long IOPMPowerSource::currentDrawn (void)
142{
143 return bCurrent;
144}
145
146// **********************************************************************************
147// voltage
148//
149// **********************************************************************************
150
151unsigned long IOPMPowerSource::voltage (void)
152{
153 return bVoltage;
154}
155
156// **********************************************************************************
157// updateStatus
158//
159// **********************************************************************************
160
161void IOPMPowerSource::updateStatus (void)
162{
163
164}
165
166
167
168
169