tbfadt.c revision 1.1.1.21 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: tbfadt - FADT table utilities
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.1.1.21 christos /******************************************************************************
8 1.1.1.21 christos *
9 1.1.1.21 christos * 1. Copyright Notice
10 1.1.1.21 christos *
11 1.1.1.21 christos * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
12 1.1 jruoho * All rights reserved.
13 1.1 jruoho *
14 1.1.1.21 christos * 2. License
15 1.1.1.21 christos *
16 1.1.1.21 christos * 2.1. This is your license from Intel Corp. under its intellectual property
17 1.1.1.21 christos * rights. You may have additional license terms from the party that provided
18 1.1.1.21 christos * you this software, covering your right to use that party's intellectual
19 1.1.1.21 christos * property rights.
20 1.1.1.21 christos *
21 1.1.1.21 christos * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 1.1.1.21 christos * copy of the source code appearing in this file ("Covered Code") an
23 1.1.1.21 christos * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 1.1.1.21 christos * base code distributed originally by Intel ("Original Intel Code") to copy,
25 1.1.1.21 christos * make derivatives, distribute, use and display any portion of the Covered
26 1.1.1.21 christos * Code in any form, with the right to sublicense such rights; and
27 1.1.1.21 christos *
28 1.1.1.21 christos * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 1.1.1.21 christos * license (with the right to sublicense), under only those claims of Intel
30 1.1.1.21 christos * patents that are infringed by the Original Intel Code, to make, use, sell,
31 1.1.1.21 christos * offer to sell, and import the Covered Code and derivative works thereof
32 1.1.1.21 christos * solely to the minimum extent necessary to exercise the above copyright
33 1.1.1.21 christos * license, and in no event shall the patent license extend to any additions
34 1.1.1.21 christos * to or modifications of the Original Intel Code. No other license or right
35 1.1.1.21 christos * is granted directly or by implication, estoppel or otherwise;
36 1.1.1.21 christos *
37 1.1.1.21 christos * The above copyright and patent license is granted only if the following
38 1.1.1.21 christos * conditions are met:
39 1.1.1.21 christos *
40 1.1.1.21 christos * 3. Conditions
41 1.1.1.21 christos *
42 1.1.1.21 christos * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 1.1.1.21 christos * Redistribution of source code of any substantial portion of the Covered
44 1.1.1.21 christos * Code or modification with rights to further distribute source must include
45 1.1.1.21 christos * the above Copyright Notice, the above License, this list of Conditions,
46 1.1.1.21 christos * and the following Disclaimer and Export Compliance provision. In addition,
47 1.1.1.21 christos * Licensee must cause all Covered Code to which Licensee contributes to
48 1.1.1.21 christos * contain a file documenting the changes Licensee made to create that Covered
49 1.1.1.21 christos * Code and the date of any change. Licensee must include in that file the
50 1.1.1.21 christos * documentation of any changes made by any predecessor Licensee. Licensee
51 1.1.1.21 christos * must include a prominent statement that the modification is derived,
52 1.1.1.21 christos * directly or indirectly, from Original Intel Code.
53 1.1.1.21 christos *
54 1.1.1.21 christos * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 1.1.1.21 christos * Redistribution of source code of any substantial portion of the Covered
56 1.1.1.21 christos * Code or modification without rights to further distribute source must
57 1.1.1.21 christos * include the following Disclaimer and Export Compliance provision in the
58 1.1.1.21 christos * documentation and/or other materials provided with distribution. In
59 1.1.1.21 christos * addition, Licensee may not authorize further sublicense of source of any
60 1.1.1.21 christos * portion of the Covered Code, and must include terms to the effect that the
61 1.1.1.21 christos * license from Licensee to its licensee is limited to the intellectual
62 1.1.1.21 christos * property embodied in the software Licensee provides to its licensee, and
63 1.1.1.21 christos * not to intellectual property embodied in modifications its licensee may
64 1.1.1.21 christos * make.
65 1.1.1.21 christos *
66 1.1.1.21 christos * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 1.1.1.21 christos * substantial portion of the Covered Code or modification must reproduce the
68 1.1.1.21 christos * above Copyright Notice, and the following Disclaimer and Export Compliance
69 1.1.1.21 christos * provision in the documentation and/or other materials provided with the
70 1.1.1.21 christos * distribution.
71 1.1.1.21 christos *
72 1.1.1.21 christos * 3.4. Intel retains all right, title, and interest in and to the Original
73 1.1.1.21 christos * Intel Code.
74 1.1.1.21 christos *
75 1.1.1.21 christos * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 1.1.1.21 christos * Intel shall be used in advertising or otherwise to promote the sale, use or
77 1.1.1.21 christos * other dealings in products derived from or relating to the Covered Code
78 1.1.1.21 christos * without prior written authorization from Intel.
79 1.1.1.21 christos *
80 1.1.1.21 christos * 4. Disclaimer and Export Compliance
81 1.1.1.21 christos *
82 1.1.1.21 christos * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 1.1.1.21 christos * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 1.1.1.21 christos * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 1.1.1.21 christos * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 1.1.1.21 christos * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 1.1.1.21 christos * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 1.1.1.21 christos * PARTICULAR PURPOSE.
89 1.1.1.21 christos *
90 1.1.1.21 christos * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 1.1.1.21 christos * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 1.1.1.21 christos * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 1.1.1.21 christos * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 1.1.1.21 christos * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 1.1.1.21 christos * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 1.1.1.21 christos * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 1.1.1.21 christos * LIMITED REMEDY.
98 1.1.1.21 christos *
99 1.1.1.21 christos * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 1.1.1.21 christos * software or system incorporating such software without first obtaining any
101 1.1.1.21 christos * required license or other approval from the U. S. Department of Commerce or
102 1.1.1.21 christos * any other agency or department of the United States Government. In the
103 1.1.1.21 christos * event Licensee exports any such software from the United States or
104 1.1.1.21 christos * re-exports any such software from a foreign destination, Licensee shall
105 1.1.1.21 christos * ensure that the distribution and export/re-export of the software is in
106 1.1.1.21 christos * compliance with all laws, regulations, orders, or other restrictions of the
107 1.1.1.21 christos * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 1.1.1.21 christos * any of its subsidiaries will export/re-export any technical data, process,
109 1.1.1.21 christos * software, or service, directly or indirectly, to any country for which the
110 1.1.1.21 christos * United States government or any agency thereof requires an export license,
111 1.1.1.21 christos * other governmental approval, or letter of assurance, without first obtaining
112 1.1.1.21 christos * such license, approval or letter.
113 1.1.1.21 christos *
114 1.1.1.21 christos *****************************************************************************
115 1.1.1.21 christos *
116 1.1.1.21 christos * Alternatively, you may choose to be licensed under the terms of the
117 1.1.1.21 christos * following license:
118 1.1.1.21 christos *
119 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without
120 1.1.1.2 jruoho * modification, are permitted provided that the following conditions
121 1.1.1.2 jruoho * are met:
122 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright
123 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer,
124 1.1.1.2 jruoho * without modification.
125 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
127 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
128 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further
129 1.1.1.2 jruoho * binary redistribution.
130 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
131 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived
132 1.1.1.2 jruoho * from this software without specific prior written permission.
133 1.1.1.2 jruoho *
134 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 1.1.1.15 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 1.1.1.21 christos * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 1.1.1.21 christos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 1.1.1.21 christos * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 1.1.1.21 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 1.1.1.21 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 1.1.1.21 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 1.1.1.21 christos * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 1.1.1.21 christos *
146 1.1.1.21 christos * Alternatively, you may choose to be licensed under the terms of the
147 1.1.1.21 christos * GNU General Public License ("GPL") version 2 as published by the Free
148 1.1.1.21 christos * Software Foundation.
149 1.1.1.21 christos *
150 1.1.1.21 christos *****************************************************************************/
151 1.1 jruoho
152 1.1 jruoho #include "acpi.h"
153 1.1 jruoho #include "accommon.h"
154 1.1 jruoho #include "actables.h"
155 1.1 jruoho
156 1.1 jruoho #define _COMPONENT ACPI_TABLES
157 1.1 jruoho ACPI_MODULE_NAME ("tbfadt")
158 1.1 jruoho
159 1.1 jruoho /* Local prototypes */
160 1.1 jruoho
161 1.1.1.3 christos static void
162 1.1 jruoho AcpiTbInitGenericAddress (
163 1.1 jruoho ACPI_GENERIC_ADDRESS *GenericAddress,
164 1.1 jruoho UINT8 SpaceId,
165 1.1 jruoho UINT8 ByteWidth,
166 1.1.1.3 christos UINT64 Address,
167 1.1.1.8 christos const char *RegisterName,
168 1.1.1.4 christos UINT8 Flags);
169 1.1 jruoho
170 1.1 jruoho static void
171 1.1 jruoho AcpiTbConvertFadt (
172 1.1 jruoho void);
173 1.1 jruoho
174 1.1 jruoho static void
175 1.1 jruoho AcpiTbSetupFadtRegisters (
176 1.1 jruoho void);
177 1.1 jruoho
178 1.1.1.3 christos static UINT64
179 1.1.1.3 christos AcpiTbSelectAddress (
180 1.1.1.3 christos char *RegisterName,
181 1.1.1.3 christos UINT32 Address32,
182 1.1.1.3 christos UINT64 Address64);
183 1.1.1.3 christos
184 1.1 jruoho
185 1.1 jruoho /* Table for conversion of FADT to common internal format and FADT validation */
186 1.1 jruoho
187 1.1 jruoho typedef struct acpi_fadt_info
188 1.1 jruoho {
189 1.1.1.8 christos const char *Name;
190 1.1.1.3 christos UINT16 Address64;
191 1.1.1.3 christos UINT16 Address32;
192 1.1.1.3 christos UINT16 Length;
193 1.1 jruoho UINT8 DefaultLength;
194 1.1.1.4 christos UINT8 Flags;
195 1.1 jruoho
196 1.1 jruoho } ACPI_FADT_INFO;
197 1.1 jruoho
198 1.1.1.3 christos #define ACPI_FADT_OPTIONAL 0
199 1.1 jruoho #define ACPI_FADT_REQUIRED 1
200 1.1 jruoho #define ACPI_FADT_SEPARATE_LENGTH 2
201 1.1.1.4 christos #define ACPI_FADT_GPE_REGISTER 4
202 1.1 jruoho
203 1.1 jruoho static ACPI_FADT_INFO FadtInfoTable[] =
204 1.1 jruoho {
205 1.1 jruoho {"Pm1aEventBlock",
206 1.1 jruoho ACPI_FADT_OFFSET (XPm1aEventBlock),
207 1.1 jruoho ACPI_FADT_OFFSET (Pm1aEventBlock),
208 1.1 jruoho ACPI_FADT_OFFSET (Pm1EventLength),
209 1.1 jruoho ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
210 1.1 jruoho ACPI_FADT_REQUIRED},
211 1.1 jruoho
212 1.1 jruoho {"Pm1bEventBlock",
213 1.1 jruoho ACPI_FADT_OFFSET (XPm1bEventBlock),
214 1.1 jruoho ACPI_FADT_OFFSET (Pm1bEventBlock),
215 1.1 jruoho ACPI_FADT_OFFSET (Pm1EventLength),
216 1.1 jruoho ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
217 1.1.1.3 christos ACPI_FADT_OPTIONAL},
218 1.1 jruoho
219 1.1 jruoho {"Pm1aControlBlock",
220 1.1 jruoho ACPI_FADT_OFFSET (XPm1aControlBlock),
221 1.1 jruoho ACPI_FADT_OFFSET (Pm1aControlBlock),
222 1.1 jruoho ACPI_FADT_OFFSET (Pm1ControlLength),
223 1.1 jruoho ACPI_PM1_REGISTER_WIDTH,
224 1.1 jruoho ACPI_FADT_REQUIRED},
225 1.1 jruoho
226 1.1 jruoho {"Pm1bControlBlock",
227 1.1 jruoho ACPI_FADT_OFFSET (XPm1bControlBlock),
228 1.1 jruoho ACPI_FADT_OFFSET (Pm1bControlBlock),
229 1.1 jruoho ACPI_FADT_OFFSET (Pm1ControlLength),
230 1.1 jruoho ACPI_PM1_REGISTER_WIDTH,
231 1.1.1.3 christos ACPI_FADT_OPTIONAL},
232 1.1 jruoho
233 1.1 jruoho {"Pm2ControlBlock",
234 1.1 jruoho ACPI_FADT_OFFSET (XPm2ControlBlock),
235 1.1 jruoho ACPI_FADT_OFFSET (Pm2ControlBlock),
236 1.1 jruoho ACPI_FADT_OFFSET (Pm2ControlLength),
237 1.1 jruoho ACPI_PM2_REGISTER_WIDTH,
238 1.1 jruoho ACPI_FADT_SEPARATE_LENGTH},
239 1.1 jruoho
240 1.1 jruoho {"PmTimerBlock",
241 1.1 jruoho ACPI_FADT_OFFSET (XPmTimerBlock),
242 1.1 jruoho ACPI_FADT_OFFSET (PmTimerBlock),
243 1.1 jruoho ACPI_FADT_OFFSET (PmTimerLength),
244 1.1 jruoho ACPI_PM_TIMER_WIDTH,
245 1.1.1.3 christos ACPI_FADT_SEPARATE_LENGTH}, /* ACPI 5.0A: Timer is optional */
246 1.1 jruoho
247 1.1 jruoho {"Gpe0Block",
248 1.1 jruoho ACPI_FADT_OFFSET (XGpe0Block),
249 1.1 jruoho ACPI_FADT_OFFSET (Gpe0Block),
250 1.1 jruoho ACPI_FADT_OFFSET (Gpe0BlockLength),
251 1.1 jruoho 0,
252 1.1.1.4 christos ACPI_FADT_SEPARATE_LENGTH | ACPI_FADT_GPE_REGISTER},
253 1.1 jruoho
254 1.1 jruoho {"Gpe1Block",
255 1.1 jruoho ACPI_FADT_OFFSET (XGpe1Block),
256 1.1 jruoho ACPI_FADT_OFFSET (Gpe1Block),
257 1.1 jruoho ACPI_FADT_OFFSET (Gpe1BlockLength),
258 1.1 jruoho 0,
259 1.1.1.4 christos ACPI_FADT_SEPARATE_LENGTH | ACPI_FADT_GPE_REGISTER}
260 1.1 jruoho };
261 1.1 jruoho
262 1.1 jruoho #define ACPI_FADT_INFO_ENTRIES \
263 1.1 jruoho (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO))
264 1.1 jruoho
265 1.1 jruoho
266 1.1 jruoho /* Table used to split Event Blocks into separate status/enable registers */
267 1.1 jruoho
268 1.1 jruoho typedef struct acpi_fadt_pm_info
269 1.1 jruoho {
270 1.1 jruoho ACPI_GENERIC_ADDRESS *Target;
271 1.1.1.3 christos UINT16 Source;
272 1.1 jruoho UINT8 RegisterNum;
273 1.1 jruoho
274 1.1 jruoho } ACPI_FADT_PM_INFO;
275 1.1 jruoho
276 1.1 jruoho static ACPI_FADT_PM_INFO FadtPmInfoTable[] =
277 1.1 jruoho {
278 1.1 jruoho {&AcpiGbl_XPm1aStatus,
279 1.1 jruoho ACPI_FADT_OFFSET (XPm1aEventBlock),
280 1.1 jruoho 0},
281 1.1 jruoho
282 1.1 jruoho {&AcpiGbl_XPm1aEnable,
283 1.1 jruoho ACPI_FADT_OFFSET (XPm1aEventBlock),
284 1.1 jruoho 1},
285 1.1 jruoho
286 1.1 jruoho {&AcpiGbl_XPm1bStatus,
287 1.1 jruoho ACPI_FADT_OFFSET (XPm1bEventBlock),
288 1.1 jruoho 0},
289 1.1 jruoho
290 1.1 jruoho {&AcpiGbl_XPm1bEnable,
291 1.1 jruoho ACPI_FADT_OFFSET (XPm1bEventBlock),
292 1.1 jruoho 1}
293 1.1 jruoho };
294 1.1 jruoho
295 1.1 jruoho #define ACPI_FADT_PM_INFO_ENTRIES \
296 1.1 jruoho (sizeof (FadtPmInfoTable) / sizeof (ACPI_FADT_PM_INFO))
297 1.1 jruoho
298 1.1 jruoho
299 1.1 jruoho /*******************************************************************************
300 1.1 jruoho *
301 1.1 jruoho * FUNCTION: AcpiTbInitGenericAddress
302 1.1 jruoho *
303 1.1 jruoho * PARAMETERS: GenericAddress - GAS struct to be initialized
304 1.1 jruoho * SpaceId - ACPI Space ID for this register
305 1.1.1.3 christos * ByteWidth - Width of this register
306 1.1 jruoho * Address - Address of the register
307 1.1.1.3 christos * RegisterName - ASCII name of the ACPI register
308 1.1 jruoho *
309 1.1 jruoho * RETURN: None
310 1.1 jruoho *
311 1.1 jruoho * DESCRIPTION: Initialize a Generic Address Structure (GAS)
312 1.1 jruoho * See the ACPI specification for a full description and
313 1.1 jruoho * definition of this structure.
314 1.1 jruoho *
315 1.1 jruoho ******************************************************************************/
316 1.1 jruoho
317 1.1.1.3 christos static void
318 1.1 jruoho AcpiTbInitGenericAddress (
319 1.1 jruoho ACPI_GENERIC_ADDRESS *GenericAddress,
320 1.1 jruoho UINT8 SpaceId,
321 1.1 jruoho UINT8 ByteWidth,
322 1.1.1.3 christos UINT64 Address,
323 1.1.1.8 christos const char *RegisterName,
324 1.1.1.4 christos UINT8 Flags)
325 1.1 jruoho {
326 1.1.1.3 christos UINT8 BitWidth;
327 1.1.1.3 christos
328 1.1.1.3 christos
329 1.1.1.4 christos /*
330 1.1.1.4 christos * Bit width field in the GAS is only one byte long, 255 max.
331 1.1.1.4 christos * Check for BitWidth overflow in GAS.
332 1.1.1.4 christos */
333 1.1.1.3 christos BitWidth = (UINT8) (ByteWidth * 8);
334 1.1.1.4 christos if (ByteWidth > 31) /* (31*8)=248, (32*8)=256 */
335 1.1.1.3 christos {
336 1.1.1.4 christos /*
337 1.1.1.4 christos * No error for GPE blocks, because we do not use the BitWidth
338 1.1.1.4 christos * for GPEs, the legacy length (ByteWidth) is used instead to
339 1.1.1.4 christos * allow for a large number of GPEs.
340 1.1.1.4 christos */
341 1.1.1.4 christos if (!(Flags & ACPI_FADT_GPE_REGISTER))
342 1.1.1.4 christos {
343 1.1.1.4 christos ACPI_ERROR ((AE_INFO,
344 1.1.1.4 christos "%s - 32-bit FADT register is too long (%u bytes, %u bits) "
345 1.1.1.4 christos "to convert to GAS struct - 255 bits max, truncating",
346 1.1.1.4 christos RegisterName, ByteWidth, (ByteWidth * 8)));
347 1.1.1.4 christos }
348 1.1.1.3 christos
349 1.1.1.3 christos BitWidth = 255;
350 1.1.1.3 christos }
351 1.1 jruoho
352 1.1 jruoho /*
353 1.1 jruoho * The 64-bit Address field is non-aligned in the byte packed
354 1.1 jruoho * GAS struct.
355 1.1 jruoho */
356 1.1 jruoho ACPI_MOVE_64_TO_64 (&GenericAddress->Address, &Address);
357 1.1 jruoho
358 1.1 jruoho /* All other fields are byte-wide */
359 1.1 jruoho
360 1.1 jruoho GenericAddress->SpaceId = SpaceId;
361 1.1.1.3 christos GenericAddress->BitWidth = BitWidth;
362 1.1 jruoho GenericAddress->BitOffset = 0;
363 1.1 jruoho GenericAddress->AccessWidth = 0; /* Access width ANY */
364 1.1 jruoho }
365 1.1 jruoho
366 1.1 jruoho
367 1.1 jruoho /*******************************************************************************
368 1.1 jruoho *
369 1.1.1.3 christos * FUNCTION: AcpiTbSelectAddress
370 1.1.1.3 christos *
371 1.1.1.3 christos * PARAMETERS: RegisterName - ASCII name of the ACPI register
372 1.1.1.3 christos * Address32 - 32-bit address of the register
373 1.1.1.3 christos * Address64 - 64-bit address of the register
374 1.1.1.3 christos *
375 1.1.1.3 christos * RETURN: The resolved 64-bit address
376 1.1.1.3 christos *
377 1.1.1.3 christos * DESCRIPTION: Select between 32-bit and 64-bit versions of addresses within
378 1.1.1.3 christos * the FADT. Used for the FACS and DSDT addresses.
379 1.1.1.3 christos *
380 1.1.1.3 christos * NOTES:
381 1.1.1.3 christos *
382 1.1.1.3 christos * Check for FACS and DSDT address mismatches. An address mismatch between
383 1.1.1.3 christos * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
384 1.1.1.3 christos * DSDT/X_DSDT) could be a corrupted address field or it might indicate
385 1.1.1.3 christos * the presence of two FACS or two DSDT tables.
386 1.1.1.3 christos *
387 1.1.1.3 christos * November 2013:
388 1.1.1.3 christos * By default, as per the ACPICA specification, a valid 64-bit address is
389 1.1.1.3 christos * used regardless of the value of the 32-bit address. However, this
390 1.1.1.3 christos * behavior can be overridden via the AcpiGbl_Use32BitFadtAddresses flag.
391 1.1.1.3 christos *
392 1.1.1.3 christos ******************************************************************************/
393 1.1.1.3 christos
394 1.1.1.3 christos static UINT64
395 1.1.1.3 christos AcpiTbSelectAddress (
396 1.1.1.3 christos char *RegisterName,
397 1.1.1.3 christos UINT32 Address32,
398 1.1.1.3 christos UINT64 Address64)
399 1.1.1.3 christos {
400 1.1.1.3 christos
401 1.1.1.3 christos if (!Address64)
402 1.1.1.3 christos {
403 1.1.1.3 christos /* 64-bit address is zero, use 32-bit address */
404 1.1.1.3 christos
405 1.1.1.3 christos return ((UINT64) Address32);
406 1.1.1.3 christos }
407 1.1.1.3 christos
408 1.1.1.3 christos if (Address32 &&
409 1.1.1.3 christos (Address64 != (UINT64) Address32))
410 1.1.1.3 christos {
411 1.1.1.3 christos /* Address mismatch between 32-bit and 64-bit versions */
412 1.1.1.3 christos
413 1.1.1.3 christos ACPI_BIOS_WARNING ((AE_INFO,
414 1.1.1.3 christos "32/64X %s address mismatch in FADT: "
415 1.1.1.3 christos "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
416 1.1.1.3 christos RegisterName, Address32, ACPI_FORMAT_UINT64 (Address64),
417 1.1.1.3 christos AcpiGbl_Use32BitFadtAddresses ? 32 : 64));
418 1.1.1.3 christos
419 1.1.1.3 christos /* 32-bit address override */
420 1.1.1.3 christos
421 1.1.1.3 christos if (AcpiGbl_Use32BitFadtAddresses)
422 1.1.1.3 christos {
423 1.1.1.3 christos return ((UINT64) Address32);
424 1.1.1.3 christos }
425 1.1.1.3 christos }
426 1.1.1.3 christos
427 1.1.1.3 christos /* Default is to use the 64-bit address */
428 1.1.1.3 christos
429 1.1.1.3 christos return (Address64);
430 1.1.1.3 christos }
431 1.1.1.3 christos
432 1.1.1.3 christos
433 1.1.1.3 christos /*******************************************************************************
434 1.1.1.3 christos *
435 1.1 jruoho * FUNCTION: AcpiTbParseFadt
436 1.1 jruoho *
437 1.1.1.7 christos * PARAMETERS: None
438 1.1 jruoho *
439 1.1 jruoho * RETURN: None
440 1.1 jruoho *
441 1.1 jruoho * DESCRIPTION: Initialize the FADT, DSDT and FACS tables
442 1.1 jruoho * (FADT contains the addresses of the DSDT and FACS)
443 1.1 jruoho *
444 1.1 jruoho ******************************************************************************/
445 1.1 jruoho
446 1.1 jruoho void
447 1.1 jruoho AcpiTbParseFadt (
448 1.1.1.7 christos void)
449 1.1 jruoho {
450 1.1 jruoho UINT32 Length;
451 1.1 jruoho ACPI_TABLE_HEADER *Table;
452 1.1.1.10 christos ACPI_TABLE_DESC *FadtDesc;
453 1.1.1.10 christos ACPI_STATUS Status;
454 1.1 jruoho
455 1.1 jruoho
456 1.1 jruoho /*
457 1.1 jruoho * The FADT has multiple versions with different lengths,
458 1.1 jruoho * and it contains pointers to both the DSDT and FACS tables.
459 1.1 jruoho *
460 1.1 jruoho * Get a local copy of the FADT and convert it to a common format
461 1.1 jruoho * Map entire FADT, assumed to be smaller than one page.
462 1.1 jruoho */
463 1.1.1.10 christos FadtDesc = &AcpiGbl_RootTableList.Tables[AcpiGbl_FadtIndex];
464 1.1.1.10 christos Status = AcpiTbGetTable (FadtDesc, &Table);
465 1.1.1.10 christos if (ACPI_FAILURE (Status))
466 1.1 jruoho {
467 1.1 jruoho return;
468 1.1 jruoho }
469 1.1.1.10 christos Length = FadtDesc->Length;
470 1.1 jruoho
471 1.1 jruoho /*
472 1.1 jruoho * Validate the FADT checksum before we copy the table. Ignore
473 1.1 jruoho * checksum error as we want to try to get the DSDT and FACS.
474 1.1 jruoho */
475 1.1.1.18 christos (void) AcpiUtVerifyChecksum (Table, Length);
476 1.1 jruoho
477 1.1 jruoho /* Create a local copy of the FADT in common ACPI 2.0+ format */
478 1.1 jruoho
479 1.1 jruoho AcpiTbCreateLocalFadt (Table, Length);
480 1.1 jruoho
481 1.1 jruoho /* All done with the real FADT, unmap it */
482 1.1 jruoho
483 1.1.1.10 christos AcpiTbPutTable (FadtDesc);
484 1.1 jruoho
485 1.1 jruoho /* Obtain the DSDT and FACS tables via their addresses within the FADT */
486 1.1 jruoho
487 1.1.1.9 christos AcpiTbInstallStandardTable (
488 1.1.1.9 christos (ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt,
489 1.1.1.16 christos ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, NULL, FALSE, TRUE,
490 1.1.1.9 christos &AcpiGbl_DsdtIndex);
491 1.1 jruoho
492 1.1.1.20 christos if (AcpiGbl_FADT.Facs)
493 1.1.1.3 christos {
494 1.1.1.20 christos AcpiTbInstallStandardTable (
495 1.1.1.20 christos (ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.Facs,
496 1.1.1.20 christos ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, NULL, FALSE, TRUE,
497 1.1.1.20 christos &AcpiGbl_FacsIndex);
498 1.1.1.20 christos }
499 1.1.1.20 christos if (AcpiGbl_FADT.XFacs)
500 1.1.1.20 christos {
501 1.1.1.20 christos AcpiTbInstallStandardTable (
502 1.1.1.20 christos (ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs,
503 1.1.1.20 christos ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, NULL, FALSE, TRUE,
504 1.1.1.20 christos &AcpiGbl_XFacsIndex);
505 1.1.1.3 christos }
506 1.1 jruoho }
507 1.1 jruoho
508 1.1 jruoho
509 1.1 jruoho /*******************************************************************************
510 1.1 jruoho *
511 1.1 jruoho * FUNCTION: AcpiTbCreateLocalFadt
512 1.1 jruoho *
513 1.1 jruoho * PARAMETERS: Table - Pointer to BIOS FADT
514 1.1 jruoho * Length - Length of the table
515 1.1 jruoho *
516 1.1 jruoho * RETURN: None
517 1.1 jruoho *
518 1.1 jruoho * DESCRIPTION: Get a local copy of the FADT and convert it to a common format.
519 1.1 jruoho * Performs validation on some important FADT fields.
520 1.1 jruoho *
521 1.1 jruoho * NOTE: We create a local copy of the FADT regardless of the version.
522 1.1 jruoho *
523 1.1 jruoho ******************************************************************************/
524 1.1 jruoho
525 1.1 jruoho void
526 1.1 jruoho AcpiTbCreateLocalFadt (
527 1.1 jruoho ACPI_TABLE_HEADER *Table,
528 1.1 jruoho UINT32 Length)
529 1.1 jruoho {
530 1.1 jruoho
531 1.1 jruoho /*
532 1.1 jruoho * Check if the FADT is larger than the largest table that we expect
533 1.1.1.8 christos * (typically the current ACPI specification version). If so, truncate
534 1.1.1.8 christos * the table, and issue a warning.
535 1.1 jruoho */
536 1.1 jruoho if (Length > sizeof (ACPI_TABLE_FADT))
537 1.1 jruoho {
538 1.1.1.3 christos ACPI_BIOS_WARNING ((AE_INFO,
539 1.1.1.8 christos "FADT (revision %u) is longer than %s length, "
540 1.1 jruoho "truncating length %u to %u",
541 1.1.1.8 christos Table->Revision, ACPI_FADT_CONFORMANCE, Length,
542 1.1.1.8 christos (UINT32) sizeof (ACPI_TABLE_FADT)));
543 1.1 jruoho }
544 1.1 jruoho
545 1.1 jruoho /* Clear the entire local FADT */
546 1.1 jruoho
547 1.1.1.6 christos memset (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT));
548 1.1 jruoho
549 1.1 jruoho /* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */
550 1.1 jruoho
551 1.1.1.6 christos memcpy (&AcpiGbl_FADT, Table,
552 1.1 jruoho ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT)));
553 1.1 jruoho
554 1.1.1.3 christos /* Take a copy of the Hardware Reduced flag */
555 1.1 jruoho
556 1.1.1.3 christos AcpiGbl_ReducedHardware = FALSE;
557 1.1.1.3 christos if (AcpiGbl_FADT.Flags & ACPI_FADT_HW_REDUCED)
558 1.1.1.3 christos {
559 1.1.1.3 christos AcpiGbl_ReducedHardware = TRUE;
560 1.1.1.3 christos }
561 1.1 jruoho
562 1.1.1.3 christos /* Convert the local copy of the FADT to the common internal format */
563 1.1 jruoho
564 1.1.1.3 christos AcpiTbConvertFadt ();
565 1.1 jruoho
566 1.1 jruoho /* Initialize the global ACPI register structures */
567 1.1 jruoho
568 1.1 jruoho AcpiTbSetupFadtRegisters ();
569 1.1 jruoho }
570 1.1 jruoho
571 1.1 jruoho
572 1.1 jruoho /*******************************************************************************
573 1.1 jruoho *
574 1.1 jruoho * FUNCTION: AcpiTbConvertFadt
575 1.1 jruoho *
576 1.1.1.3 christos * PARAMETERS: None - AcpiGbl_FADT is used.
577 1.1 jruoho *
578 1.1 jruoho * RETURN: None
579 1.1 jruoho *
580 1.1 jruoho * DESCRIPTION: Converts all versions of the FADT to a common internal format.
581 1.1.1.3 christos * Expand 32-bit addresses to 64-bit as necessary. Also validate
582 1.1.1.3 christos * important fields within the FADT.
583 1.1 jruoho *
584 1.1.1.3 christos * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT), and must
585 1.1.1.3 christos * contain a copy of the actual BIOS-provided FADT.
586 1.1 jruoho *
587 1.1 jruoho * Notes on 64-bit register addresses:
588 1.1 jruoho *
589 1.1 jruoho * After this FADT conversion, later ACPICA code will only use the 64-bit "X"
590 1.1 jruoho * fields of the FADT for all ACPI register addresses.
591 1.1 jruoho *
592 1.1.1.3 christos * The 64-bit X fields are optional extensions to the original 32-bit FADT
593 1.1 jruoho * V1.0 fields. Even if they are present in the FADT, they are optional and
594 1.1 jruoho * are unused if the BIOS sets them to zero. Therefore, we must copy/expand
595 1.1.1.11 christos * 32-bit V1.0 fields to the 64-bit X fields if the 64-bit X field is originally
596 1.1.1.11 christos * zero.
597 1.1 jruoho *
598 1.1.1.3 christos * For ACPI 1.0 FADTs (that contain no 64-bit addresses), all 32-bit address
599 1.1.1.3 christos * fields are expanded to the corresponding 64-bit X fields in the internal
600 1.1.1.3 christos * common FADT.
601 1.1 jruoho *
602 1.1 jruoho * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded
603 1.1.1.3 christos * to the corresponding 64-bit X fields, if the 64-bit field is originally
604 1.1.1.3 christos * zero. Adhering to the ACPI specification, we completely ignore the 32-bit
605 1.1.1.3 christos * field if the 64-bit field is valid, regardless of whether the host OS is
606 1.1.1.3 christos * 32-bit or 64-bit.
607 1.1.1.3 christos *
608 1.1.1.3 christos * Possible additional checks:
609 1.1.1.3 christos * (AcpiGbl_FADT.Pm1EventLength >= 4)
610 1.1.1.3 christos * (AcpiGbl_FADT.Pm1ControlLength >= 2)
611 1.1.1.3 christos * (AcpiGbl_FADT.PmTimerLength >= 4)
612 1.1.1.3 christos * Gpe block lengths must be multiple of 2
613 1.1 jruoho *
614 1.1 jruoho ******************************************************************************/
615 1.1 jruoho
616 1.1 jruoho static void
617 1.1 jruoho AcpiTbConvertFadt (
618 1.1 jruoho void)
619 1.1 jruoho {
620 1.1.1.8 christos const char *Name;
621 1.1 jruoho ACPI_GENERIC_ADDRESS *Address64;
622 1.1 jruoho UINT32 Address32;
623 1.1.1.3 christos UINT8 Length;
624 1.1.1.4 christos UINT8 Flags;
625 1.1 jruoho UINT32 i;
626 1.1 jruoho
627 1.1 jruoho
628 1.1 jruoho /*
629 1.1.1.10 christos * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
630 1.1 jruoho * should be zero are indeed zero. This will workaround BIOSs that
631 1.1 jruoho * inadvertently place values in these fields.
632 1.1 jruoho *
633 1.1 jruoho * The ACPI 1.0 reserved fields that will be zeroed are the bytes located
634 1.1 jruoho * at offset 45, 55, 95, and the word located at offset 109, 110.
635 1.1.1.2 jruoho *
636 1.1.1.10 christos * Note: The FADT revision value is unreliable. Only the length can be
637 1.1.1.10 christos * trusted.
638 1.1 jruoho */
639 1.1.1.10 christos if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE)
640 1.1 jruoho {
641 1.1 jruoho AcpiGbl_FADT.PreferredProfile = 0;
642 1.1 jruoho AcpiGbl_FADT.PstateControl = 0;
643 1.1 jruoho AcpiGbl_FADT.CstControl = 0;
644 1.1 jruoho AcpiGbl_FADT.BootFlags = 0;
645 1.1 jruoho }
646 1.1 jruoho
647 1.1 jruoho /*
648 1.1.1.3 christos * Now we can update the local FADT length to the length of the
649 1.1.1.3 christos * current FADT version as defined by the ACPI specification.
650 1.1.1.3 christos * Thus, we will have a common FADT internally.
651 1.1 jruoho */
652 1.1.1.3 christos AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT);
653 1.1 jruoho
654 1.1 jruoho /*
655 1.1.1.6 christos * Expand the 32-bit DSDT addresses to 64-bit as necessary.
656 1.1.1.3 christos * Later ACPICA code will always use the X 64-bit field.
657 1.1 jruoho */
658 1.1.1.3 christos AcpiGbl_FADT.XDsdt = AcpiTbSelectAddress ("DSDT",
659 1.1.1.3 christos AcpiGbl_FADT.Dsdt, AcpiGbl_FADT.XDsdt);
660 1.1 jruoho
661 1.1.1.3 christos /* If Hardware Reduced flag is set, we are all done */
662 1.1 jruoho
663 1.1.1.3 christos if (AcpiGbl_ReducedHardware)
664 1.1.1.3 christos {
665 1.1.1.3 christos return;
666 1.1 jruoho }
667 1.1 jruoho
668 1.1 jruoho /* Examine all of the 64-bit extended address fields (X fields) */
669 1.1 jruoho
670 1.1 jruoho for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
671 1.1 jruoho {
672 1.1 jruoho /*
673 1.1.1.3 christos * Get the 32-bit and 64-bit addresses, as well as the register
674 1.1.1.3 christos * length and register name.
675 1.1 jruoho */
676 1.1.1.3 christos Address32 = *ACPI_ADD_PTR (UINT32,
677 1.1.1.3 christos &AcpiGbl_FADT, FadtInfoTable[i].Address32);
678 1.1.1.3 christos
679 1.1 jruoho Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS,
680 1.1.1.3 christos &AcpiGbl_FADT, FadtInfoTable[i].Address64);
681 1.1.1.3 christos
682 1.1 jruoho Length = *ACPI_ADD_PTR (UINT8,
683 1.1.1.3 christos &AcpiGbl_FADT, FadtInfoTable[i].Length);
684 1.1.1.3 christos
685 1.1 jruoho Name = FadtInfoTable[i].Name;
686 1.1.1.4 christos Flags = FadtInfoTable[i].Flags;
687 1.1 jruoho
688 1.1 jruoho /*
689 1.1.1.3 christos * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
690 1.1.1.3 christos * generic address structures as necessary. Later code will always use
691 1.1.1.3 christos * the 64-bit address structures.
692 1.1.1.3 christos *
693 1.1.1.3 christos * November 2013:
694 1.1.1.3 christos * Now always use the 64-bit address if it is valid (non-zero), in
695 1.1.1.3 christos * accordance with the ACPI specification which states that a 64-bit
696 1.1.1.3 christos * address supersedes the 32-bit version. This behavior can be
697 1.1.1.3 christos * overridden by the AcpiGbl_Use32BitFadtAddresses flag.
698 1.1.1.3 christos *
699 1.1.1.3 christos * During 64-bit address construction and verification,
700 1.1.1.3 christos * these cases are handled:
701 1.1.1.3 christos *
702 1.1.1.3 christos * Address32 zero, Address64 [don't care] - Use Address64
703 1.1.1.3 christos *
704 1.1.1.9 christos * No override: if AcpiGbl_Use32BitFadtAddresses is FALSE, and:
705 1.1.1.3 christos * Address32 non-zero, Address64 zero - Copy/use Address32
706 1.1.1.3 christos * Address32 non-zero == Address64 non-zero - Use Address64
707 1.1.1.3 christos * Address32 non-zero != Address64 non-zero - Warning, use Address64
708 1.1.1.3 christos *
709 1.1.1.3 christos * Override: if AcpiGbl_Use32BitFadtAddresses is TRUE, and:
710 1.1.1.9 christos * Address32 non-zero, Address64 zero - Copy/use Address32
711 1.1.1.9 christos * Address32 non-zero == Address64 non-zero - Copy/use Address32
712 1.1.1.3 christos * Address32 non-zero != Address64 non-zero - Warning, copy/use Address32
713 1.1.1.3 christos *
714 1.1.1.3 christos * Note: SpaceId is always I/O for 32-bit legacy address fields
715 1.1.1.3 christos */
716 1.1.1.3 christos if (Address32)
717 1.1.1.3 christos {
718 1.1.1.9 christos if (Address64->Address)
719 1.1.1.3 christos {
720 1.1.1.9 christos if (Address64->Address != (UINT64) Address32)
721 1.1.1.9 christos {
722 1.1.1.9 christos /* Address mismatch */
723 1.1.1.3 christos
724 1.1.1.9 christos ACPI_BIOS_WARNING ((AE_INFO,
725 1.1.1.9 christos "32/64X address mismatch in FADT/%s: "
726 1.1.1.9 christos "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
727 1.1.1.9 christos Name, Address32,
728 1.1.1.9 christos ACPI_FORMAT_UINT64 (Address64->Address),
729 1.1.1.9 christos AcpiGbl_Use32BitFadtAddresses ? 32 : 64));
730 1.1.1.9 christos }
731 1.1.1.3 christos
732 1.1.1.9 christos /*
733 1.1.1.9 christos * For each extended field, check for length mismatch
734 1.1.1.9 christos * between the legacy length field and the corresponding
735 1.1.1.9 christos * 64-bit X length field.
736 1.1.1.9 christos * Note: If the legacy length field is > 0xFF bits, ignore
737 1.1.1.9 christos * this check. (GPE registers can be larger than the
738 1.1.1.13 christos * 64-bit GAS structure can accommodate, 0xFF bits).
739 1.1.1.9 christos */
740 1.1.1.9 christos if ((ACPI_MUL_8 (Length) <= ACPI_UINT8_MAX) &&
741 1.1.1.9 christos (Address64->BitWidth != ACPI_MUL_8 (Length)))
742 1.1.1.3 christos {
743 1.1.1.9 christos ACPI_BIOS_WARNING ((AE_INFO,
744 1.1.1.9 christos "32/64X length mismatch in FADT/%s: %u/%u",
745 1.1.1.9 christos Name, ACPI_MUL_8 (Length), Address64->BitWidth));
746 1.1.1.3 christos }
747 1.1.1.3 christos }
748 1.1.1.3 christos
749 1.1.1.9 christos /*
750 1.1.1.9 christos * Hardware register access code always uses the 64-bit fields.
751 1.1.1.9 christos * So if the 64-bit field is zero or is to be overridden,
752 1.1.1.9 christos * initialize it with the 32-bit fields.
753 1.1.1.9 christos * Note that when the 32-bit address favor is specified, the
754 1.1.1.9 christos * 64-bit fields are always re-initialized so that
755 1.1.1.9 christos * AccessSize/BitWidth/BitOffset fields can be correctly
756 1.1.1.9 christos * configured to the values to trigger a 32-bit compatible
757 1.1.1.9 christos * access mode in the hardware register access code.
758 1.1.1.9 christos */
759 1.1.1.9 christos if (!Address64->Address || AcpiGbl_Use32BitFadtAddresses)
760 1.1.1.9 christos {
761 1.1.1.9 christos AcpiTbInitGenericAddress (Address64,
762 1.1.1.9 christos ACPI_ADR_SPACE_SYSTEM_IO, Length,
763 1.1.1.9 christos (UINT64) Address32, Name, Flags);
764 1.1.1.9 christos }
765 1.1 jruoho }
766 1.1 jruoho
767 1.1.1.4 christos if (FadtInfoTable[i].Flags & ACPI_FADT_REQUIRED)
768 1.1 jruoho {
769 1.1 jruoho /*
770 1.1.1.3 christos * Field is required (PM1aEvent, PM1aControl).
771 1.1 jruoho * Both the address and length must be non-zero.
772 1.1 jruoho */
773 1.1 jruoho if (!Address64->Address || !Length)
774 1.1 jruoho {
775 1.1.1.3 christos ACPI_BIOS_ERROR ((AE_INFO,
776 1.1.1.3 christos "Required FADT field %s has zero address and/or length: "
777 1.1.1.3 christos "0x%8.8X%8.8X/0x%X",
778 1.1 jruoho Name, ACPI_FORMAT_UINT64 (Address64->Address), Length));
779 1.1 jruoho }
780 1.1 jruoho }
781 1.1.1.4 christos else if (FadtInfoTable[i].Flags & ACPI_FADT_SEPARATE_LENGTH)
782 1.1 jruoho {
783 1.1 jruoho /*
784 1.1 jruoho * Field is optional (PM2Control, GPE0, GPE1) AND has its own
785 1.1 jruoho * length field. If present, both the address and length must
786 1.1 jruoho * be valid.
787 1.1 jruoho */
788 1.1 jruoho if ((Address64->Address && !Length) ||
789 1.1 jruoho (!Address64->Address && Length))
790 1.1 jruoho {
791 1.1.1.3 christos ACPI_BIOS_WARNING ((AE_INFO,
792 1.1.1.8 christos "Optional FADT field %s has valid %s but zero %s: "
793 1.1.1.8 christos "0x%8.8X%8.8X/0x%X", Name,
794 1.1.1.8 christos (Length ? "Length" : "Address"),
795 1.1.1.8 christos (Length ? "Address": "Length"),
796 1.1.1.8 christos ACPI_FORMAT_UINT64 (Address64->Address), Length));
797 1.1 jruoho }
798 1.1 jruoho }
799 1.1 jruoho }
800 1.1 jruoho }
801 1.1 jruoho
802 1.1 jruoho
803 1.1 jruoho /*******************************************************************************
804 1.1 jruoho *
805 1.1 jruoho * FUNCTION: AcpiTbSetupFadtRegisters
806 1.1 jruoho *
807 1.1 jruoho * PARAMETERS: None, uses AcpiGbl_FADT.
808 1.1 jruoho *
809 1.1 jruoho * RETURN: None
810 1.1 jruoho *
811 1.1 jruoho * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally,
812 1.1 jruoho * force FADT register definitions to their default lengths.
813 1.1 jruoho *
814 1.1 jruoho ******************************************************************************/
815 1.1 jruoho
816 1.1 jruoho static void
817 1.1 jruoho AcpiTbSetupFadtRegisters (
818 1.1 jruoho void)
819 1.1 jruoho {
820 1.1 jruoho ACPI_GENERIC_ADDRESS *Target64;
821 1.1 jruoho ACPI_GENERIC_ADDRESS *Source64;
822 1.1 jruoho UINT8 Pm1RegisterByteWidth;
823 1.1 jruoho UINT32 i;
824 1.1 jruoho
825 1.1 jruoho
826 1.1 jruoho /*
827 1.1 jruoho * Optionally check all register lengths against the default values and
828 1.1 jruoho * update them if they are incorrect.
829 1.1 jruoho */
830 1.1 jruoho if (AcpiGbl_UseDefaultRegisterWidths)
831 1.1 jruoho {
832 1.1 jruoho for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
833 1.1 jruoho {
834 1.1 jruoho Target64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
835 1.1 jruoho FadtInfoTable[i].Address64);
836 1.1 jruoho
837 1.1 jruoho /*
838 1.1 jruoho * If a valid register (Address != 0) and the (DefaultLength > 0)
839 1.1 jruoho * (Not a GPE register), then check the width against the default.
840 1.1 jruoho */
841 1.1 jruoho if ((Target64->Address) &&
842 1.1 jruoho (FadtInfoTable[i].DefaultLength > 0) &&
843 1.1 jruoho (FadtInfoTable[i].DefaultLength != Target64->BitWidth))
844 1.1 jruoho {
845 1.1.1.3 christos ACPI_BIOS_WARNING ((AE_INFO,
846 1.1.1.3 christos "Invalid length for FADT/%s: %u, using default %u",
847 1.1 jruoho FadtInfoTable[i].Name, Target64->BitWidth,
848 1.1 jruoho FadtInfoTable[i].DefaultLength));
849 1.1 jruoho
850 1.1 jruoho /* Incorrect size, set width to the default */
851 1.1 jruoho
852 1.1 jruoho Target64->BitWidth = FadtInfoTable[i].DefaultLength;
853 1.1 jruoho }
854 1.1 jruoho }
855 1.1 jruoho }
856 1.1 jruoho
857 1.1 jruoho /*
858 1.1 jruoho * Get the length of the individual PM1 registers (enable and status).
859 1.1 jruoho * Each register is defined to be (event block length / 2). Extra divide
860 1.1 jruoho * by 8 converts bits to bytes.
861 1.1 jruoho */
862 1.1 jruoho Pm1RegisterByteWidth = (UINT8)
863 1.1 jruoho ACPI_DIV_16 (AcpiGbl_FADT.XPm1aEventBlock.BitWidth);
864 1.1 jruoho
865 1.1 jruoho /*
866 1.1 jruoho * Calculate separate GAS structs for the PM1x (A/B) Status and Enable
867 1.1 jruoho * registers. These addresses do not appear (directly) in the FADT, so it
868 1.1 jruoho * is useful to pre-calculate them from the PM1 Event Block definitions.
869 1.1 jruoho *
870 1.1 jruoho * The PM event blocks are split into two register blocks, first is the
871 1.1 jruoho * PM Status Register block, followed immediately by the PM Enable
872 1.1 jruoho * Register block. Each is of length (Pm1EventLength/2)
873 1.1 jruoho *
874 1.1 jruoho * Note: The PM1A event block is required by the ACPI specification.
875 1.1 jruoho * However, the PM1B event block is optional and is rarely, if ever,
876 1.1 jruoho * used.
877 1.1 jruoho */
878 1.1 jruoho
879 1.1 jruoho for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++)
880 1.1 jruoho {
881 1.1 jruoho Source64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
882 1.1 jruoho FadtPmInfoTable[i].Source);
883 1.1 jruoho
884 1.1 jruoho if (Source64->Address)
885 1.1 jruoho {
886 1.1 jruoho AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target,
887 1.1 jruoho Source64->SpaceId, Pm1RegisterByteWidth,
888 1.1 jruoho Source64->Address +
889 1.1.1.3 christos (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth),
890 1.1.1.4 christos "PmRegisters", 0);
891 1.1 jruoho }
892 1.1 jruoho }
893 1.1 jruoho }
894