xref: /xnu-8020.140.41/iokit/IOKit/IOPMGR.h (revision 27b03b360a988dfd3dfdf34262bb0042026747cc)
1*27b03b36SApple OSS Distributions /*
2*27b03b36SApple OSS Distributions  * Copyright (c) 2019 Apple Computer, Inc. All rights reserved.
3*27b03b36SApple OSS Distributions  *
4*27b03b36SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*27b03b36SApple OSS Distributions  *
6*27b03b36SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*27b03b36SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*27b03b36SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*27b03b36SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*27b03b36SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*27b03b36SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*27b03b36SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*27b03b36SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*27b03b36SApple OSS Distributions  *
15*27b03b36SApple OSS Distributions  * Please obtain a copy of the License at
16*27b03b36SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*27b03b36SApple OSS Distributions  *
18*27b03b36SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*27b03b36SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*27b03b36SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*27b03b36SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*27b03b36SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*27b03b36SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*27b03b36SApple OSS Distributions  * limitations under the License.
25*27b03b36SApple OSS Distributions  *
26*27b03b36SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*27b03b36SApple OSS Distributions  */
28*27b03b36SApple OSS Distributions 
29*27b03b36SApple OSS Distributions #pragma once
30*27b03b36SApple OSS Distributions 
31*27b03b36SApple OSS Distributions #include <machine/machine_routines.h>
32*27b03b36SApple OSS Distributions 
33*27b03b36SApple OSS Distributions #include <stdint.h>
34*27b03b36SApple OSS Distributions #include <IOKit/IOService.h>
35*27b03b36SApple OSS Distributions 
36*27b03b36SApple OSS Distributions /*!
37*27b03b36SApple OSS Distributions  * @class      IOPMGR
38*27b03b36SApple OSS Distributions  * @abstract   The base class for power managers, such as ApplePMGR.
39*27b03b36SApple OSS Distributions  */
40*27b03b36SApple OSS Distributions class IOPMGR : public IOService
41*27b03b36SApple OSS Distributions {
42*27b03b36SApple OSS Distributions 	OSDeclareAbstractStructors(IOPMGR);
43*27b03b36SApple OSS Distributions 
44*27b03b36SApple OSS Distributions public:
45*27b03b36SApple OSS Distributions 	/*!
46*27b03b36SApple OSS Distributions 	 * @function        enableCPUCore
47*27b03b36SApple OSS Distributions 	 * @abstract        Enable a single CPU core.
48*27b03b36SApple OSS Distributions 	 * @discussion      Release a secondary CPU core from reset, and enable
49*27b03b36SApple OSS Distributions 	 *                  external IRQ delivery to the core.  XNU will not
50*27b03b36SApple OSS Distributions 	 *                  invoke this method on the boot CPU's cpu_id.
51*27b03b36SApple OSS Distributions 	 * @param cpu_id    Logical CPU ID of the core.
52*27b03b36SApple OSS Distributions 	 * @param entry_pa  Physical address to use as the reset vector on the
53*27b03b36SApple OSS Distributions 	 *                  secondary CPU.  Not all platforms will honor this
54*27b03b36SApple OSS Distributions 	 *                  parameter; on Apple Silicon RVBAR_EL1 is programmed
55*27b03b36SApple OSS Distributions 	 *                  by iBoot.
56*27b03b36SApple OSS Distributions 	 */
57*27b03b36SApple OSS Distributions 	virtual void enableCPUCore(unsigned int cpu_id, uint64_t entry_pa);
58*27b03b36SApple OSS Distributions 
59*27b03b36SApple OSS Distributions 	/*!
60*27b03b36SApple OSS Distributions 	 * @function      enableCPUCore
61*27b03b36SApple OSS Distributions 	 * @abstract      Deprecated - Enable a single CPU core.
62*27b03b36SApple OSS Distributions 	 */
63*27b03b36SApple OSS Distributions 	virtual void enableCPUCore(unsigned int cpu_id);
64*27b03b36SApple OSS Distributions 
65*27b03b36SApple OSS Distributions 	/*!
66*27b03b36SApple OSS Distributions 	 * @function      disableCPUCore
67*27b03b36SApple OSS Distributions 	 * @abstract      Disable a single CPU core.
68*27b03b36SApple OSS Distributions 	 * @discussion    Prepare a secondary CPU core for power down, and
69*27b03b36SApple OSS Distributions 	 *                disable external IRQ delivery to the core.  XNU
70*27b03b36SApple OSS Distributions 	 *                will not invoke this method on the boot CPU's cpu_id.
71*27b03b36SApple OSS Distributions 	 *                Note that the enable and disable operations are not
72*27b03b36SApple OSS Distributions 	 *                symmetric, as disableCPUCore doesn't actually cut
73*27b03b36SApple OSS Distributions 	 *                power to the core.
74*27b03b36SApple OSS Distributions 	 * @param cpu_id  Logical CPU ID of the core.
75*27b03b36SApple OSS Distributions 	 */
76*27b03b36SApple OSS Distributions 	virtual void disableCPUCore(unsigned int cpu_id) = 0;
77*27b03b36SApple OSS Distributions 
78*27b03b36SApple OSS Distributions 	/*!
79*27b03b36SApple OSS Distributions 	 * @function          enableCPUCluster
80*27b03b36SApple OSS Distributions 	 * @abstract          Enable power to a cluster of CPUs.
81*27b03b36SApple OSS Distributions 	 * @discussion        Called to power up a CPU cluster if the cluster-wide
82*27b03b36SApple OSS Distributions 	 *                    voltage rails are disabled (i.e. PIO to the cluster
83*27b03b36SApple OSS Distributions 	 *                    isn't even working).
84*27b03b36SApple OSS Distributions 	 * @param cluster_id  Cluster ID.
85*27b03b36SApple OSS Distributions 	 */
86*27b03b36SApple OSS Distributions 	virtual void enableCPUCluster(unsigned int cluster_id) = 0;
87*27b03b36SApple OSS Distributions 
88*27b03b36SApple OSS Distributions 	/*!
89*27b03b36SApple OSS Distributions 	 * @function          disableCPUCluster
90*27b03b36SApple OSS Distributions 	 * @abstract          Disable power to a cluster of CPUs.
91*27b03b36SApple OSS Distributions 	 * @discussion        Called to disable the voltage rails on a CPU
92*27b03b36SApple OSS Distributions 	 *                    cluster.  This will only be invoked if all CPUs
93*27b03b36SApple OSS Distributions 	 *                    in the cluster are already disabled.  It is
94*27b03b36SApple OSS Distributions 	 *                    presumed that after this operation completes,
95*27b03b36SApple OSS Distributions 	 *                    PIO operations to the cluster will cause a
96*27b03b36SApple OSS Distributions 	 *                    fatal bus error.
97*27b03b36SApple OSS Distributions 	 * @param cluster_id  Cluster ID.
98*27b03b36SApple OSS Distributions 	 */
99*27b03b36SApple OSS Distributions 	virtual void disableCPUCluster(unsigned int cluster_id) = 0;
100*27b03b36SApple OSS Distributions 
101*27b03b36SApple OSS Distributions 	/*!
102*27b03b36SApple OSS Distributions 	 * @function                   initCPUIdle
103*27b03b36SApple OSS Distributions 	 * @abstract                   Initialize idle-related parameters.
104*27b03b36SApple OSS Distributions 	 * @param info                 Pointer to the ml_processor_info_t struct that is
105*27b03b36SApple OSS Distributions 	 *                             being initialized (and hasn't been registered yet).
106*27b03b36SApple OSS Distributions 	 */
107*27b03b36SApple OSS Distributions 	virtual void initCPUIdle(ml_processor_info_t *info) = 0;
108*27b03b36SApple OSS Distributions 
109*27b03b36SApple OSS Distributions 	/*!
110*27b03b36SApple OSS Distributions 	 * @function                   enterCPUIdle
111*27b03b36SApple OSS Distributions 	 * @abstract                   Called from cpu_idle() prior to entering the idle state on
112*27b03b36SApple OSS Distributions 	 *                             the current CPU.
113*27b03b36SApple OSS Distributions 	 * @param newIdleTimeoutTicks  If non-NULL, will be overwritten with a new idle timeout value,
114*27b03b36SApple OSS Distributions 	 *                             in ticks.  If the value is 0, XNU will disable the idle timer.
115*27b03b36SApple OSS Distributions 	 */
116*27b03b36SApple OSS Distributions 	virtual void enterCPUIdle(UInt64 *newIdleTimeoutTicks) = 0;
117*27b03b36SApple OSS Distributions 
118*27b03b36SApple OSS Distributions 	/*!
119*27b03b36SApple OSS Distributions 	 * @function                   exitCPUIdle
120*27b03b36SApple OSS Distributions 	 * @abstract                   Called from cpu_idle_exit() after leaving the idle state on
121*27b03b36SApple OSS Distributions 	 *                             the current CPU.
122*27b03b36SApple OSS Distributions 	 * @param newIdleTimeoutTicks  If non-NULL, will be overwritten with a new idle timeout value,
123*27b03b36SApple OSS Distributions 	 *                             in ticks.  If the value is 0, XNU will disable the idle timer.
124*27b03b36SApple OSS Distributions 	 */
125*27b03b36SApple OSS Distributions 	virtual void exitCPUIdle(UInt64 *newIdleTimeoutTicks) = 0;
126*27b03b36SApple OSS Distributions 
127*27b03b36SApple OSS Distributions 	/*!
128*27b03b36SApple OSS Distributions 	 * @function                   updateCPUIdle
129*27b03b36SApple OSS Distributions 	 * @abstract                   Called from timer_intr() to ask when to schedule the next idle
130*27b03b36SApple OSS Distributions 	 *                             timeout on the current CPU.
131*27b03b36SApple OSS Distributions 	 * @param newIdleTimeoutTicks  If non-NULL, will be overwritten with a new idle timeout value,
132*27b03b36SApple OSS Distributions 	 *                             in ticks.  If the value is 0, XNU will disable the idle timer.
133*27b03b36SApple OSS Distributions 	 */
134*27b03b36SApple OSS Distributions 	virtual void updateCPUIdle(UInt64 *newIdleTimeoutTicks) = 0;
135*27b03b36SApple OSS Distributions };
136