]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/pmCPU.h
b107551fecc6ef31c34ebb74c40a2fc44e60451d
2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 #ifndef _I386_PMCPU_H_
24 #define _I386_PMCPU_H_
30 typedef enum { C1
, C2
, C3
, C4
, Hlt
, C3Res
, All
, Cnum
} pm_Cstate_t
;
31 typedef struct pmStats
{
32 uint64_t pmNapCnt
[Cnum
]; /* Total nap calls for states */
33 uint64_t pmNapTime
[Cnum
]; /* Total nap time for states */
34 uint64_t pmNapC2HPET
; /* Total nap time for C2 using HPET for stats */
35 uint64_t pmNapC4HPET
; /* Total nap time for C4 using HPET for stats */
36 uint64_t pmNapHPETPops
; /* Number of times we detect HPET popping */
37 uint64_t pmHPETRupt
; /* Number of HPET interruptions */
38 uint32_t pmCurC3Res
; /* Current value of the C3 residency timer */
39 uint32_t pmLastApic
; /* Last value of apic timer */
40 uint32_t pmNewApic
; /* New value of apic timer */
41 uint64_t pmHpetTim
; /* Time to next interrupt in HPET ticks */
42 uint64_t pmHpetCmp
; /* HPET comparator */
43 uint64_t pmHpetCfg
; /* HPET configuration */
44 uint64_t pmLSNs
; /* (TEST) Last set nanotime */
45 uint64_t pmLLHpet
; /* (TEST) Last loaded HPET */
48 #define MAX_PSTATES 32 /* architectural limit */
50 typedef enum { Cn1
, Cn2
, Cn3
, Cn4
, Cnmax
} Cstate_number_t
;
52 Cstate_number_t number
;
60 typedef struct pmData pmData_t
;
62 #define pmNapHalt 0x00000010
63 #define pmNapC1 0x00000008
64 #define pmNapC2 0x00000004
65 #define pmNapC3 0x00000002
66 #define pmNapC4 0x00000001
67 #define pmNapMask 0x000000FF
71 #define lpcCfg (0x80000000 | (0 << 16) | (31 << 11) | (0 << 8))
74 * Dispatch table for functions that get installed when the power
75 * management KEXT loads.
80 * The following are the stepper table interfaces.
82 void (*pmsCPUMachineInit
)(void);
83 void (*pmsCPUInit
)(void);
84 void (*pmsCPUSet
)(uint32_t sel
);
85 void (*pmsCPUConf
)(void);
86 void (*pmsCPURun
)(uint32_t nstep
);
87 uint32_t (*pmsCPUQuery
)(void);
88 uint32_t (*pmsCPUPackageQuery
)(void);
89 void (*pmsCPUYellowFlag
)(void);
90 void (*pmsCPUGreenFlag
)(void);
91 kern_return_t (*pmsCPULoadVIDTable
)(uint16_t *tablep
, int nstates
);
92 kern_return_t (*pmsCPUSetPStateLimit
)(uint32_t limit
);
95 * The following are the 'C' State interfaces.
97 void (*cstateInit
)(void);
98 void (*cstateMachineIdle
)(uint32_t napCtl
);
99 kern_return_t (*cstateTableSet
)(Cstate_hint_t
*tablep
, unsigned int nstates
);
100 uint32_t (*cstateNapPolicy
)(uint32_t forcenap
, uint32_t napCtl
);
106 uint16_t VIDTable
[MAX_PSTATES
];
107 uint32_t VIDTableCount
;
108 Cstate_hint_t CStates
[Cnmax
];
109 uint32_t CStatesCount
;
114 void (*Run
)(uint32_t nstep
);
115 void (*RunLocal
)(uint32_t nstep
);
116 void (*SetStep
)(uint32_t nstep
, int dir
);
117 void (*NapPolicy
)(void);
118 kern_return_t (*Build
)(pmsDef
*pd
, uint32_t pdsize
, pmsSetFunc_t
*functab
, uint32_t platformData
, pmsQueryFunc_t queryFunc
);
119 pmStats_t
*(*Stats
)(void);
120 pmsd
*(*StepperData
)(void);
121 uint64_t *(*HPETAddr
)(void);
122 pmInitState_t
*InitState
;
125 extern pmDispatch_t
*pmDispatch
;
127 extern uint32_t maxBusDelay
;
128 extern uint32_t C4C2SnoopDelay
;
129 extern uint32_t forcenap
;
131 void power_management_init(void);
132 void machine_nap_policy(void);
133 kern_return_t
Cstate_table_set(Cstate_hint_t
*tablep
, unsigned int nstates
);
134 void machine_idle_cstate(void);
135 void pmRegister(pmDispatch_t
*cpuFuncs
, pmCallBacks_t
*callbacks
);
136 void pmUnRegister(pmDispatch_t
*cpuFuncs
);
138 #endif /* ASSEMBLER */
139 #endif /* _I386_PMCPU_H_ */
140 #endif /* KERNEL_PRIVATE */