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