2 * Copyright (c) 2006-2009 Apple 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 #ifndef _I386_PMCPU_H_
30 #define _I386_PMCPU_H_
32 #include <i386/cpu_topology.h>
37 * This value should be changed each time that pmDsipatch_t or pmCallBacks_t
40 #define PM_DISPATCH_VERSION 17
43 * Dispatch table for functions that get installed when the power
44 * management KEXT loads.
46 * pmDispatch_t is the set of functions that the kernel can use to call
47 * into the power management KEXT.
49 * pmCallBacks_t is the set of functions that the power management kext
50 * can call to get at specific kernel functions.
54 int (*pmCPUStateInit
)(void);
55 void (*cstateInit
)(void);
56 uint64_t (*cstateMachineIdle
)(uint64_t maxIdleDuration
);
57 uint64_t (*GetDeadline
)(x86_lcpu_t
*lcpu
);
58 uint64_t (*SetDeadline
)(x86_lcpu_t
*lcpu
, uint64_t);
59 void (*Deadline
)(x86_lcpu_t
*lcpu
);
60 boolean_t (*exitIdle
)(x86_lcpu_t
*lcpu
);
61 void (*markCPURunning
)(x86_lcpu_t
*lcpu
);
62 int (*pmCPUControl
)(uint32_t cmd
, void *datap
);
63 void (*pmCPUHalt
)(void);
64 uint64_t (*getMaxSnoop
)(void);
65 void (*setMaxBusDelay
)(uint64_t time
);
66 uint64_t (*getMaxBusDelay
)(void);
67 void (*setMaxIntDelay
)(uint64_t time
);
68 uint64_t (*getMaxIntDelay
)(void);
69 void (*pmCPUSafeMode
)(x86_lcpu_t
*lcpu
, uint32_t flags
);
70 void (*pmTimerStateSave
)(void);
71 void (*pmTimerStateRestore
)(void);
72 kern_return_t (*exitHalt
)(x86_lcpu_t
*lcpu
);
73 kern_return_t (*exitHaltToOff
)(x86_lcpu_t
*lcpu
);
74 void (*markAllCPUsOff
)(void);
75 void (*pmSetRunCount
)(uint32_t count
);
76 boolean_t (*pmIsCPUUnAvailable
)(x86_lcpu_t
*lcpu
);
77 int (*pmIPIHandler
)(void *state
);
82 int (*setRTCPop
)(uint64_t time
);
83 void (*resyncDeadlines
)(int cpu
);
84 void (*initComplete
)(void);
85 x86_lcpu_t
*(*GetLCPU
)(int cpu
);
86 x86_core_t
*(*GetCore
)(int cpu
);
87 x86_die_t
*(*GetDie
)(int cpu
);
88 x86_pkg_t
*(*GetPackage
)(int cpu
);
89 x86_lcpu_t
*(*GetMyLCPU
)(void);
90 x86_core_t
*(*GetMyCore
)(void);
91 x86_die_t
*(*GetMyDie
)(void);
92 x86_pkg_t
*(*GetMyPackage
)(void);
93 x86_pkg_t
*(*GetPkgRoot
)(void);
94 void (*LockCPUTopology
)(int lock
);
95 boolean_t (*GetHibernate
)(int cpu
);
96 processor_t (*LCPUtoProcessor
)(int lcpu
);
97 processor_t (*ThreadBind
)(processor_t proc
);
98 uint32_t (*GetSavedRunCount
)(void);
99 void (*pmSendIPI
)(int cpu
);
100 x86_topology_parameters_t
*topoParms
;
103 extern pmDispatch_t
*pmDispatch
;
105 void power_management_init(void);
106 void pmKextRegister(uint32_t version
, pmDispatch_t
*cpuFuncs
,
107 pmCallBacks_t
*callbacks
);
108 void pmUnRegister(pmDispatch_t
*cpuFuncs
);
109 void pmCPUStateInit(void);
110 uint64_t pmCPUGetDeadline(struct cpu_data
*cpu
);
111 uint64_t pmCPUSetDeadline(struct cpu_data
*cpu
, uint64_t deadline
);
112 void pmCPUDeadline(struct cpu_data
*cpu
);
113 boolean_t
pmCPUExitIdle(struct cpu_data
*cpu
);
114 void pmCPUMarkRunning(struct cpu_data
*cpu
);
115 void pmMarkAllCPUsOff(void);
116 int pmCPUControl(uint32_t cmd
, void *datap
);
117 void pmCPUHalt(uint32_t reason
);
118 void pmTimerSave(void);
119 void pmTimerRestore(void);
120 kern_return_t
pmCPUExitHalt(int cpu
);
121 kern_return_t
pmCPUExitHaltToOff(int cpu
);
123 #define PM_HALT_NORMAL 0 /* normal halt path */
124 #define PM_HALT_DEBUG 1 /* debug code wants to halt */
125 #define PM_HALT_PANIC 2 /* panic code wants to halt */
126 #define PM_HALT_SLEEP 3 /* sleep code wants to halt */
128 void pmSafeMode(x86_lcpu_t
*lcpu
, uint32_t flags
);
130 #define PM_SAFE_FL_NORMAL 0x00000001 /* put CPU into "normal" power mode */
131 #define PM_SAFE_FL_SAFE 0x00000002 /* put CPU into a "safe" power mode */
132 #define PM_SAFE_FL_PAUSE 0x00000010 /* pause execution on the CPU */
133 #define PM_SAFE_FL_RESUME 0x00000020 /* resume execution on the CPU */
135 extern int pmsafe_debug
;
138 /******************************************************************************
140 * All of the following are deprecated interfaces and no longer used.
142 ******************************************************************************/
145 #endif /* ASSEMBLER */
147 #endif /* _I386_PMCPU_H_ */
148 #endif /* KERNEL_PRIVATE */