]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2DeviceRefCodePkg/AcpiTablesPCAT/Lpit/Lpit.aslc
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
[mirror_edk2.git] / Vlv2DeviceRefCodePkg / AcpiTablesPCAT / Lpit / Lpit.aslc
1 /*++
2
3 Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved
4
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13
14
15 --*/
16
17 //
18 // Include files
19 //
20
21 #include <PiDxe.h>
22 #include <IndustryStandard/Acpi50.h>
23
24
25
26 //
27 // LPIT Definitions
28 //
29
30 #define EFI_ACPI_LOW_POWER_IDLE_TABLE_REVISION 0x1
31
32 //
33 // Ensure proper structure formats
34 //
35 #pragma pack(1)
36
37 typedef union _EFI_ACPI_LPI_STATE_FLAGS {
38 struct {
39 UINT32 Disabled :1;
40 UINT32 CounterUnavailable :1;
41 UINT32 Reserved :30;
42 };
43 UINT32 AsUlong;
44 } EFI_ACPI_LPI_STATE_FLAGS, *PEFI_ACPI_LPI_STATE_FLAGS;
45
46 // Only Mwait LPI here:
47
48 typedef struct _EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR {
49 UINT32 Type; // offset: 0
50 UINT32 Length; // offset: 4
51 UINT16 UniqueId; // offset: 8
52 UINT8 Reserved[2]; // offset: 9
53 EFI_ACPI_LPI_STATE_FLAGS Flags; // offset: 12
54 EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE EntryTrigger; // offset: 16
55 UINT32 Residency; // offset: 28
56 UINT32 Latency; // offset: 32
57 EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE ResidencyCounter; // offset: 36
58 UINT64 ResidencyCounterFrequency; //offset: 48
59 } EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR;
60
61
62 //
63 // Defines for LPIT table, some are VLV specific
64 //
65
66
67 // signature "LPIT"
68 #define EFI_ACPI_LOW_POWER_IDLE_TABLE_SIGNATURE 0x5449504c
69
70 #define EFI_ACPI_OEM_LPIT_REVISION 0x00000000
71
72 #define EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE 0x0
73 #define EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG 0x0
74 #define EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K 0x8000 // 32768
75
76 //
77 // LPI state count (4 on VLV: S0ir, S0i1, S0i2, S0i3)
78 //
79
80 #define EFI_ACPI_VLV_LPI_STATE_COUNT 0x4
81
82 //
83 // LPI TRIGGER (HW C7 on VLV),
84 // TOFIX!!!
85 //
86 #define EFI_ACPI_VLV_LPI_TRIGGER {0x7F,0x1,0x2,0x0,0x64}
87
88 //
89 // LPI residency counter (MMIO)
90 //
91 #define EFI_ACPI_VLV_LPI_RES_COUNTER0 {0x0,32,0x0,0x03,0xFED03080}
92 #define EFI_ACPI_VLV_LPI_RES_COUNTER1 {0x0,32,0x0,0x03,0xFED03084}
93 #define EFI_ACPI_VLV_LPI_RES_COUNTER2 {0x0,32,0x0,0x03,0xFED03088}
94 #define EFI_ACPI_VLV_LPI_RES_COUNTER3 {0x0,32,0x0,0x03,0xFED0308C}
95
96 //
97 // LPI break-even residency in us - all match S0i3 residency
98 // Residency estimate: Latency x 3
99 //
100 #define EFI_ACPI_VLV_LPI_MIN_RES0 15000
101 #define EFI_ACPI_VLV_LPI_MIN_RES1 15000
102 #define EFI_ACPI_VLV_LPI_MIN_RES2 15000
103 #define EFI_ACPI_VLV_LPI_MIN_RES3 15000
104
105 //
106 // LPI latency in us - all match S0i3 latency
107 //
108 #define EFI_ACPI_VLV_LPI_LATENCY0 5000
109 #define EFI_ACPI_VLV_LPI_LATENCY1 5000
110 #define EFI_ACPI_VLV_LPI_LATENCY2 5000
111 #define EFI_ACPI_VLV_LPI_LATENCY3 5000
112
113
114 //
115 // LPI ID
116 //
117 #define EFI_ACPI_VLV_LPI_UNIQUE_ID0 0
118 #define EFI_ACPI_VLV_LPI_UNIQUE_ID1 1
119 #define EFI_ACPI_VLV_LPI_UNIQUE_ID2 2
120 #define EFI_ACPI_VLV_LPI_UNIQUE_ID3 3
121
122 //
123 // LPI ACPI table header
124 //
125
126
127 typedef struct _EFI_ACPI_LOW_POWER_IDLE_TABLE {
128 EFI_ACPI_DESCRIPTION_HEADER Header;
129 EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR LpiStates[EFI_ACPI_VLV_LPI_STATE_COUNT];
130 } EFI_ACPI_LOW_POWER_IDLE_TABLE;
131
132 #pragma pack()
133
134 EFI_ACPI_LOW_POWER_IDLE_TABLE Lpit = {
135
136 //
137 // Header
138 //
139
140
141 EFI_ACPI_LOW_POWER_IDLE_TABLE_SIGNATURE,
142 sizeof (EFI_ACPI_LOW_POWER_IDLE_TABLE),
143 EFI_ACPI_LOW_POWER_IDLE_TABLE_REVISION ,
144
145 //
146 // Checksum will be updated at runtime
147 //
148 0x00,
149
150 //
151 // It is expected that these values will be updated at runtime
152 //
153 ' ', ' ', ' ', ' ', ' ', ' ',
154
155 0,
156 EFI_ACPI_OEM_LPIT_REVISION,
157 0,
158 0,
159
160
161
162 //
163 // Descriptor
164 //
165 {
166 {
167 EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,
168 sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),
169 EFI_ACPI_VLV_LPI_UNIQUE_ID0,
170 {0,0},
171 {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags
172 EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger
173 EFI_ACPI_VLV_LPI_MIN_RES0, //Residency
174 EFI_ACPI_VLV_LPI_LATENCY0, //Latency
175 EFI_ACPI_VLV_LPI_RES_COUNTER0, //ResidencyCounter
176 EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency
177 },
178 {
179 EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,
180 sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),
181 EFI_ACPI_VLV_LPI_UNIQUE_ID1,
182 {0,0},
183 {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags
184 EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger
185 EFI_ACPI_VLV_LPI_MIN_RES1, //Residency
186 EFI_ACPI_VLV_LPI_LATENCY1, //Latency
187 EFI_ACPI_VLV_LPI_RES_COUNTER1, //ResidencyCounter
188 EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency
189 },
190 {
191 EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,
192 sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),
193 EFI_ACPI_VLV_LPI_UNIQUE_ID2,
194 {0,0},
195 {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags
196 EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger
197 EFI_ACPI_VLV_LPI_MIN_RES2, //Residency
198 EFI_ACPI_VLV_LPI_LATENCY2, //Latency
199 EFI_ACPI_VLV_LPI_RES_COUNTER2, //ResidencyCounter
200 EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency
201 },
202 {
203 EFI_ACPI_LOW_POWER_IDLE_MWAIT_TYPE,
204 sizeof(EFI_ACPI_MWAIT_LPI_STATE_DESCRIPTOR),
205 EFI_ACPI_VLV_LPI_UNIQUE_ID3,
206 {0,0},
207 {EFI_ACPI_LOW_POWER_IDLE_DEFAULT_FLAG}, // Flags
208 EFI_ACPI_VLV_LPI_TRIGGER, //EntryTrigger
209 EFI_ACPI_VLV_LPI_MIN_RES3, //Residency
210 EFI_ACPI_VLV_LPI_LATENCY3, //Latency
211 EFI_ACPI_VLV_LPI_RES_COUNTER3, //ResidencyCounter
212 EFI_ACPI_LOW_POWER_IDLE_RES_FREQ_8K //Residency counter frequency
213 }
214 }
215
216 };
217
218
219 VOID*
220 ReferenceAcpiTable (
221 VOID
222 )
223 {
224 //
225 // Reference the table being generated to prevent the optimizer from
226 // removing the data structure from the executable
227 //
228 return (VOID*)&Lpit;
229 }