]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/pwr_mgt/IOPMPowerSource.h
xnu-201.42.3.tar.gz
[apple/xnu.git] / iokit / IOKit / pwr_mgt / IOPMPowerSource.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22#include <libkern/c++/OSObject.h>
23#include <IOKit/IOTypes.h>
24#include <IOKit/IOReturn.h>
d52fe63f 25#include "IOPM.h"
1c79356b
A
26
27class ApplePMU;
28
1c79356b
A
29const unsigned long kSecondsPerHour = (60*60);
30const unsigned long kTenMinutesInSeconds = (10 * 60);
31
32// our battery (power source) object
33
34class IOPMPowerSource : public OSObject
35{
36 OSDeclareDefaultStructors(IOPMPowerSource)
37
38 protected:
39
40 UInt32 bFlags;
41 UInt32 bTimeRemaining;
42 UInt16 bCurCapacity;
43 UInt16 bMaxCapacity;
44 SInt16 bCurrent;
45 UInt16 bVoltage;
46 UInt16 bBatteryIndex;
47
48 public:
49
50 IOPMPowerSource * nextInList;
51
52 bool init (unsigned short whichBatteryIndex);
53 unsigned long capacityPercentRemaining (void);
54 bool atWarnLevel (void);
55 bool depleted (void);
56
57 // accessors
58
59 bool isInstalled (void);
60 bool isCharging (void);
61 bool acConnected (void);
62 unsigned long timeRemaining (void);
63 unsigned long maxCapacity (void);
64 unsigned long curCapacity (void);
65 long currentDrawn (void);
66 unsigned long voltage (void);
67
68 // calculations
69
70 // function updateStatus is called whenever the system needs
71 // to obtain the latest power source state...must be overridden
72 // by subclasses.
73 virtual void updateStatus (void);
74};
75
76
77