]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
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. | |
11 | * | |
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 | |
18 | * under the License. | |
19 | * | |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | #ifdef KERNEL_PRIVATE | |
23 | #ifndef _I386_PMCPU_H_ | |
24 | #define _I386_PMCPU_H_ | |
25 | ||
26 | #include <kern/pms.h> | |
27 | ||
28 | #ifndef ASSEMBLER | |
29 | ||
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 */ | |
46 | } pmStats_t; | |
47 | ||
48 | #define MAX_PSTATES 32 /* architectural limit */ | |
49 | ||
50 | typedef enum { Cn1, Cn2, Cn3, Cn4, Cnmax } Cstate_number_t; | |
51 | typedef struct { | |
52 | Cstate_number_t number; | |
53 | uint32_t hint; | |
54 | } Cstate_hint_t; | |
55 | ||
56 | ||
57 | struct pmData { | |
58 | uint8_t pad[93]; | |
59 | }; | |
60 | typedef struct pmData pmData_t; | |
61 | ||
62 | #define pmNapHalt 0x00000010 | |
63 | #define pmNapC1 0x00000008 | |
64 | #define pmNapC2 0x00000004 | |
65 | #define pmNapC3 0x00000002 | |
66 | #define pmNapC4 0x00000001 | |
67 | #define pmNapMask 0x000000FF | |
68 | ||
69 | #define cfgAdr 0xCF8 | |
70 | #define cfgDat 0xCFC | |
71 | #define lpcCfg (0x80000000 | (0 << 16) | (31 << 11) | (0 << 8)) | |
72 | ||
73 | /* | |
74 | * Dispatch table for functions that get installed when the power | |
75 | * management KEXT loads. | |
76 | */ | |
77 | typedef struct | |
78 | { | |
79 | /* | |
80 | * The following are the stepper table interfaces. | |
81 | */ | |
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); | |
93 | ||
94 | /* | |
95 | * The following are the 'C' State interfaces. | |
96 | */ | |
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); | |
101 | } pmDispatch_t; | |
102 | ||
103 | typedef struct { | |
104 | uint32_t PState; | |
105 | uint32_t PLimit; | |
106 | uint16_t VIDTable[MAX_PSTATES]; | |
107 | uint32_t VIDTableCount; | |
108 | Cstate_hint_t CStates[Cnmax]; | |
109 | uint32_t CStatesCount; | |
110 | } pmInitState_t; | |
111 | ||
112 | typedef struct { | |
113 | void (*Park)(void); | |
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; | |
123 | void (*resetPop)(void); | |
124 | } pmCallBacks_t; | |
125 | ||
126 | extern pmDispatch_t *pmDispatch; | |
127 | ||
128 | extern uint32_t maxBusDelay; | |
129 | extern uint32_t C4C2SnoopDelay; | |
130 | extern uint32_t forcenap; | |
131 | ||
132 | void power_management_init(void); | |
133 | void machine_nap_policy(void); | |
134 | kern_return_t Cstate_table_set(Cstate_hint_t *tablep, unsigned int nstates); | |
135 | void machine_idle_cstate(void); | |
136 | void pmRegister(pmDispatch_t *cpuFuncs, pmCallBacks_t *callbacks); | |
137 | void pmUnRegister(pmDispatch_t *cpuFuncs); | |
138 | ||
139 | #endif /* ASSEMBLER */ | |
140 | #endif /* _I386_PMCPU_H_ */ | |
141 | #endif /* KERNEL_PRIVATE */ |