]>
Commit | Line | Data |
---|---|---|
0c530ab8 | 1 | /* |
593a1d5f | 2 | * Copyright (c) 2006-2008 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> |
0c530ab8 A |
33 | |
34 | #ifndef ASSEMBLER | |
35 | ||
2d21ac55 A |
36 | /* |
37 | * This value should be changed each time that pmDsipatch_t or pmCallBacks_t | |
38 | * changes. | |
39 | */ | |
593a1d5f | 40 | #define PM_DISPATCH_VERSION 12 |
2d21ac55 | 41 | |
0c530ab8 A |
42 | /* |
43 | * Dispatch table for functions that get installed when the power | |
44 | * management KEXT loads. | |
45 | */ | |
46 | typedef struct | |
47 | { | |
2d21ac55 | 48 | int (*pmCPUStateInit)(void); |
2d21ac55 | 49 | |
0c530ab8 A |
50 | /* |
51 | * The following are the 'C' State interfaces. | |
52 | */ | |
2d21ac55 A |
53 | void (*cstateInit)(void); |
54 | uint64_t (*cstateMachineIdle)(uint64_t maxIdleDuration); | |
2d21ac55 A |
55 | uint64_t (*GetDeadline)(x86_lcpu_t *lcpu); |
56 | uint64_t (*SetDeadline)(x86_lcpu_t *lcpu, uint64_t); | |
57 | void (*Deadline)(x86_lcpu_t *lcpu); | |
58 | boolean_t (*exitIdle)(x86_lcpu_t *lcpu); | |
59 | void (*markCPURunning)(x86_lcpu_t *lcpu); | |
2d21ac55 A |
60 | int (*pmCPUControl)(uint32_t cmd, void *datap); |
61 | void (*pmCPUHalt)(void); | |
62 | uint64_t (*getMaxSnoop)(void); | |
63 | void (*setMaxBusDelay)(uint64_t time); | |
64 | uint64_t (*getMaxBusDelay)(void); | |
593a1d5f A |
65 | void (*setMaxIntDelay)(uint64_t time); |
66 | uint64_t (*getMaxIntDelay)(void); | |
2d21ac55 | 67 | void (*pmCPUSafeMode)(x86_lcpu_t *lcpu, uint32_t flags); |
593a1d5f A |
68 | void (*pmTimerStateSave)(void); |
69 | void (*pmTimerStateRestore)(void); | |
70 | kern_return_t (*exitHalt)(x86_lcpu_t *lcpu); | |
71 | void (*markAllCPUsOff)(void); | |
0c530ab8 A |
72 | } pmDispatch_t; |
73 | ||
74 | typedef struct { | |
2d21ac55 A |
75 | int (*setRTCPop)(uint64_t time); |
76 | void (*resyncDeadlines)(void); | |
77 | void (*initComplete)(void); | |
78 | x86_lcpu_t *(*GetLCPU)(int cpu); | |
79 | x86_core_t *(*GetCore)(int cpu); | |
593a1d5f | 80 | x86_die_t *(*GetDie)(int cpu); |
2d21ac55 A |
81 | x86_pkg_t *(*GetPackage)(int cpu); |
82 | x86_lcpu_t *(*GetMyLCPU)(void); | |
83 | x86_core_t *(*GetMyCore)(void); | |
593a1d5f | 84 | x86_die_t *(*GetMyDie)(void); |
2d21ac55 | 85 | x86_pkg_t *(*GetMyPackage)(void); |
2d21ac55 A |
86 | x86_pkg_t *(*GetPkgRoot)(void); |
87 | void (*LockCPUTopology)(int lock); | |
88 | boolean_t (*GetHibernate)(int cpu); | |
89 | processor_t (*LCPUtoProcessor)(int lcpu); | |
593a1d5f A |
90 | processor_t (*ThreadBind)(processor_t proc); |
91 | x86_topology_parameters_t *topoParms; | |
0c530ab8 A |
92 | } pmCallBacks_t; |
93 | ||
94 | extern pmDispatch_t *pmDispatch; | |
95 | ||
0c530ab8 | 96 | void power_management_init(void); |
2d21ac55 A |
97 | void pmKextRegister(uint32_t version, pmDispatch_t *cpuFuncs, |
98 | pmCallBacks_t *callbacks); | |
0c530ab8 | 99 | void pmUnRegister(pmDispatch_t *cpuFuncs); |
2d21ac55 A |
100 | void pmCPUStateInit(void); |
101 | uint64_t pmCPUGetDeadline(struct cpu_data *cpu); | |
102 | uint64_t pmCPUSetDeadline(struct cpu_data *cpu, uint64_t deadline); | |
103 | void pmCPUDeadline(struct cpu_data *cpu); | |
104 | boolean_t pmCPUExitIdle(struct cpu_data *cpu); | |
105 | void pmCPUMarkRunning(struct cpu_data *cpu); | |
593a1d5f | 106 | void pmMarkAllCPUsOff(void); |
2d21ac55 A |
107 | int pmCPUControl(uint32_t cmd, void *datap); |
108 | void pmCPUHalt(uint32_t reason); | |
593a1d5f A |
109 | void pmTimerSave(void); |
110 | void pmTimerRestore(void); | |
111 | kern_return_t pmCPUExitHalt(int cpu); | |
2d21ac55 A |
112 | |
113 | #define PM_HALT_NORMAL 0 /* normal halt path */ | |
114 | #define PM_HALT_DEBUG 1 /* debug code wants to halt */ | |
115 | #define PM_HALT_PANIC 2 /* panic code wants to halt */ | |
593a1d5f | 116 | #define PM_HALT_SLEEP 3 /* sleep code wants to halt */ |
2d21ac55 A |
117 | |
118 | void pmSafeMode(x86_lcpu_t *lcpu, uint32_t flags); | |
119 | ||
120 | #define PM_SAFE_FL_NORMAL 0x00000001 /* put CPU into "normal" power mode */ | |
121 | #define PM_SAFE_FL_SAFE 0x00000002 /* put CPU into a "safe" power mode */ | |
122 | #define PM_SAFE_FL_PAUSE 0x00000010 /* pause execution on the CPU */ | |
123 | #define PM_SAFE_FL_RESUME 0x00000020 /* resume execution on the CPU */ | |
124 | ||
125 | extern int pmsafe_debug; | |
593a1d5f A |
126 | extern int idlehalt; |
127 | ||
128 | /****************************************************************************** | |
129 | * | |
130 | * All of the following are deprecated interfaces and no longer used. | |
131 | * | |
132 | ******************************************************************************/ | |
133 | ||
0c530ab8 A |
134 | |
135 | #endif /* ASSEMBLER */ | |
2d21ac55 | 136 | |
0c530ab8 A |
137 | #endif /* _I386_PMCPU_H_ */ |
138 | #endif /* KERNEL_PRIVATE */ |