]> git.saurik.com Git - apple/xnu.git/blame - osfmk/i386/pmCPU.h
xnu-1504.9.37.tar.gz
[apple/xnu.git] / osfmk / i386 / pmCPU.h
CommitLineData
0c530ab8 1/*
d1ecb069 2 * Copyright (c) 2006-2010 Apple Inc. All rights reserved.
0c530ab8 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0c530ab8 5 *
2d21ac55
A
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.
0c530ab8 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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
0c530ab8
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
0c530ab8 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
0c530ab8
A
27 */
28#ifdef KERNEL_PRIVATE
29#ifndef _I386_PMCPU_H_
30#define _I386_PMCPU_H_
31
2d21ac55 32#include <i386/cpu_topology.h>
7e4a7d39 33#include <i386/rtclock.h>
0c530ab8
A
34
35#ifndef ASSEMBLER
36
2d21ac55
A
37/*
38 * This value should be changed each time that pmDsipatch_t or pmCallBacks_t
39 * changes.
40 */
0b4c1975 41#define PM_DISPATCH_VERSION 21
2d21ac55 42
0c530ab8
A
43/*
44 * Dispatch table for functions that get installed when the power
45 * management KEXT loads.
b0d623f7
A
46 *
47 * pmDispatch_t is the set of functions that the kernel can use to call
48 * into the power management KEXT.
49 *
50 * pmCallBacks_t is the set of functions that the power management kext
51 * can call to get at specific kernel functions.
0c530ab8
A
52 */
53typedef struct
54{
d1ecb069 55 kern_return_t (*pmCPUStateInit)(void);
2d21ac55 56 void (*cstateInit)(void);
b7266188 57 uint64_t (*MachineIdle)(uint64_t maxIdleDuration);
2d21ac55
A
58 uint64_t (*GetDeadline)(x86_lcpu_t *lcpu);
59 uint64_t (*SetDeadline)(x86_lcpu_t *lcpu, uint64_t);
60 void (*Deadline)(x86_lcpu_t *lcpu);
61 boolean_t (*exitIdle)(x86_lcpu_t *lcpu);
62 void (*markCPURunning)(x86_lcpu_t *lcpu);
2d21ac55
A
63 int (*pmCPUControl)(uint32_t cmd, void *datap);
64 void (*pmCPUHalt)(void);
65 uint64_t (*getMaxSnoop)(void);
66 void (*setMaxBusDelay)(uint64_t time);
67 uint64_t (*getMaxBusDelay)(void);
593a1d5f
A
68 void (*setMaxIntDelay)(uint64_t time);
69 uint64_t (*getMaxIntDelay)(void);
2d21ac55 70 void (*pmCPUSafeMode)(x86_lcpu_t *lcpu, uint32_t flags);
593a1d5f
A
71 void (*pmTimerStateSave)(void);
72 void (*pmTimerStateRestore)(void);
73 kern_return_t (*exitHalt)(x86_lcpu_t *lcpu);
e2fac8b1 74 kern_return_t (*exitHaltToOff)(x86_lcpu_t *lcpu);
593a1d5f 75 void (*markAllCPUsOff)(void);
c910b4d9
A
76 void (*pmSetRunCount)(uint32_t count);
77 boolean_t (*pmIsCPUUnAvailable)(x86_lcpu_t *lcpu);
b7266188 78 int (*pmChooseCPU)(int startCPU, int endCPU, int preferredCPU);
b0d623f7 79 int (*pmIPIHandler)(void *state);
0c530ab8
A
80} pmDispatch_t;
81
b0d623f7 82
0c530ab8 83typedef struct {
2d21ac55 84 int (*setRTCPop)(uint64_t time);
c910b4d9 85 void (*resyncDeadlines)(int cpu);
2d21ac55
A
86 void (*initComplete)(void);
87 x86_lcpu_t *(*GetLCPU)(int cpu);
88 x86_core_t *(*GetCore)(int cpu);
593a1d5f 89 x86_die_t *(*GetDie)(int cpu);
2d21ac55
A
90 x86_pkg_t *(*GetPackage)(int cpu);
91 x86_lcpu_t *(*GetMyLCPU)(void);
92 x86_core_t *(*GetMyCore)(void);
593a1d5f 93 x86_die_t *(*GetMyDie)(void);
2d21ac55 94 x86_pkg_t *(*GetMyPackage)(void);
2d21ac55
A
95 x86_pkg_t *(*GetPkgRoot)(void);
96 void (*LockCPUTopology)(int lock);
97 boolean_t (*GetHibernate)(int cpu);
98 processor_t (*LCPUtoProcessor)(int lcpu);
593a1d5f 99 processor_t (*ThreadBind)(processor_t proc);
c910b4d9 100 uint32_t (*GetSavedRunCount)(void);
b0d623f7 101 void (*pmSendIPI)(int cpu);
7e4a7d39 102 rtc_nanotime_t *(*GetNanotimeInfo)(void);
0b4c1975 103 void (*RTCClockAdjust)(uint64_t adjustment);
593a1d5f 104 x86_topology_parameters_t *topoParms;
0c530ab8
A
105} pmCallBacks_t;
106
107extern pmDispatch_t *pmDispatch;
108
0c530ab8 109void power_management_init(void);
2d21ac55
A
110void pmKextRegister(uint32_t version, pmDispatch_t *cpuFuncs,
111 pmCallBacks_t *callbacks);
0c530ab8 112void pmUnRegister(pmDispatch_t *cpuFuncs);
2d21ac55
A
113void pmCPUStateInit(void);
114uint64_t pmCPUGetDeadline(struct cpu_data *cpu);
115uint64_t pmCPUSetDeadline(struct cpu_data *cpu, uint64_t deadline);
116void pmCPUDeadline(struct cpu_data *cpu);
117boolean_t pmCPUExitIdle(struct cpu_data *cpu);
118void pmCPUMarkRunning(struct cpu_data *cpu);
593a1d5f 119void pmMarkAllCPUsOff(void);
2d21ac55
A
120int pmCPUControl(uint32_t cmd, void *datap);
121void pmCPUHalt(uint32_t reason);
593a1d5f
A
122void pmTimerSave(void);
123void pmTimerRestore(void);
124kern_return_t pmCPUExitHalt(int cpu);
e2fac8b1 125kern_return_t pmCPUExitHaltToOff(int cpu);
2d21ac55
A
126
127#define PM_HALT_NORMAL 0 /* normal halt path */
128#define PM_HALT_DEBUG 1 /* debug code wants to halt */
129#define PM_HALT_PANIC 2 /* panic code wants to halt */
593a1d5f 130#define PM_HALT_SLEEP 3 /* sleep code wants to halt */
2d21ac55
A
131
132void pmSafeMode(x86_lcpu_t *lcpu, uint32_t flags);
133
134#define PM_SAFE_FL_NORMAL 0x00000001 /* put CPU into "normal" power mode */
135#define PM_SAFE_FL_SAFE 0x00000002 /* put CPU into a "safe" power mode */
136#define PM_SAFE_FL_PAUSE 0x00000010 /* pause execution on the CPU */
137#define PM_SAFE_FL_RESUME 0x00000020 /* resume execution on the CPU */
138
139extern int pmsafe_debug;
593a1d5f
A
140extern int idlehalt;
141
142/******************************************************************************
143 *
144 * All of the following are deprecated interfaces and no longer used.
145 *
146 ******************************************************************************/
147
0c530ab8
A
148
149#endif /* ASSEMBLER */
2d21ac55 150
0c530ab8
A
151#endif /* _I386_PMCPU_H_ */
152#endif /* KERNEL_PRIVATE */