minor fixes for safecopy & safemap tests
[minix.git] / drivers / acpi / tables / tbfadt.c
blob9ae4669d94aeec5d1f8ec0fb2b2f942e976ae38f
1 /******************************************************************************
3 * Module Name: tbfadt - FADT table utilities
5 *****************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
12 * All rights reserved.
14 * 2. License
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
40 * 3. Conditions
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************/
116 #define __TBFADT_C__
118 #include "acpi.h"
119 #include "accommon.h"
120 #include "actables.h"
122 #define _COMPONENT ACPI_TABLES
123 ACPI_MODULE_NAME ("tbfadt")
125 /* Local prototypes */
127 static inline void
128 AcpiTbInitGenericAddress (
129 ACPI_GENERIC_ADDRESS *GenericAddress,
130 UINT8 SpaceId,
131 UINT8 ByteWidth,
132 UINT64 Address);
134 static void
135 AcpiTbConvertFadt (
136 void);
138 static void
139 AcpiTbValidateFadt (
140 void);
142 static void
143 AcpiTbSetupFadtRegisters (
144 void);
147 /* Table for conversion of FADT to common internal format and FADT validation */
149 typedef struct acpi_fadt_info
151 char *Name;
152 UINT8 Address64;
153 UINT8 Address32;
154 UINT8 Length;
155 UINT8 DefaultLength;
156 UINT8 Type;
158 } ACPI_FADT_INFO;
160 #define ACPI_FADT_REQUIRED 1
161 #define ACPI_FADT_SEPARATE_LENGTH 2
163 static ACPI_FADT_INFO FadtInfoTable[] =
165 {"Pm1aEventBlock",
166 ACPI_FADT_OFFSET (XPm1aEventBlock),
167 ACPI_FADT_OFFSET (Pm1aEventBlock),
168 ACPI_FADT_OFFSET (Pm1EventLength),
169 ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
170 ACPI_FADT_REQUIRED},
172 {"Pm1bEventBlock",
173 ACPI_FADT_OFFSET (XPm1bEventBlock),
174 ACPI_FADT_OFFSET (Pm1bEventBlock),
175 ACPI_FADT_OFFSET (Pm1EventLength),
176 ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
179 {"Pm1aControlBlock",
180 ACPI_FADT_OFFSET (XPm1aControlBlock),
181 ACPI_FADT_OFFSET (Pm1aControlBlock),
182 ACPI_FADT_OFFSET (Pm1ControlLength),
183 ACPI_PM1_REGISTER_WIDTH,
184 ACPI_FADT_REQUIRED},
186 {"Pm1bControlBlock",
187 ACPI_FADT_OFFSET (XPm1bControlBlock),
188 ACPI_FADT_OFFSET (Pm1bControlBlock),
189 ACPI_FADT_OFFSET (Pm1ControlLength),
190 ACPI_PM1_REGISTER_WIDTH,
193 {"Pm2ControlBlock",
194 ACPI_FADT_OFFSET (XPm2ControlBlock),
195 ACPI_FADT_OFFSET (Pm2ControlBlock),
196 ACPI_FADT_OFFSET (Pm2ControlLength),
197 ACPI_PM2_REGISTER_WIDTH,
198 ACPI_FADT_SEPARATE_LENGTH},
200 {"PmTimerBlock",
201 ACPI_FADT_OFFSET (XPmTimerBlock),
202 ACPI_FADT_OFFSET (PmTimerBlock),
203 ACPI_FADT_OFFSET (PmTimerLength),
204 ACPI_PM_TIMER_WIDTH,
205 ACPI_FADT_REQUIRED},
207 {"Gpe0Block",
208 ACPI_FADT_OFFSET (XGpe0Block),
209 ACPI_FADT_OFFSET (Gpe0Block),
210 ACPI_FADT_OFFSET (Gpe0BlockLength),
212 ACPI_FADT_SEPARATE_LENGTH},
214 {"Gpe1Block",
215 ACPI_FADT_OFFSET (XGpe1Block),
216 ACPI_FADT_OFFSET (Gpe1Block),
217 ACPI_FADT_OFFSET (Gpe1BlockLength),
219 ACPI_FADT_SEPARATE_LENGTH}
222 #define ACPI_FADT_INFO_ENTRIES \
223 (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO))
226 /* Table used to split Event Blocks into separate status/enable registers */
228 typedef struct acpi_fadt_pm_info
230 ACPI_GENERIC_ADDRESS *Target;
231 UINT8 Source;
232 UINT8 RegisterNum;
234 } ACPI_FADT_PM_INFO;
236 static ACPI_FADT_PM_INFO FadtPmInfoTable[] =
238 {&AcpiGbl_XPm1aStatus,
239 ACPI_FADT_OFFSET (XPm1aEventBlock),
242 {&AcpiGbl_XPm1aEnable,
243 ACPI_FADT_OFFSET (XPm1aEventBlock),
246 {&AcpiGbl_XPm1bStatus,
247 ACPI_FADT_OFFSET (XPm1bEventBlock),
250 {&AcpiGbl_XPm1bEnable,
251 ACPI_FADT_OFFSET (XPm1bEventBlock),
255 #define ACPI_FADT_PM_INFO_ENTRIES \
256 (sizeof (FadtPmInfoTable) / sizeof (ACPI_FADT_PM_INFO))
259 /*******************************************************************************
261 * FUNCTION: AcpiTbInitGenericAddress
263 * PARAMETERS: GenericAddress - GAS struct to be initialized
264 * SpaceId - ACPI Space ID for this register
265 * ByteWidth - Width of this register, in bytes
266 * Address - Address of the register
268 * RETURN: None
270 * DESCRIPTION: Initialize a Generic Address Structure (GAS)
271 * See the ACPI specification for a full description and
272 * definition of this structure.
274 ******************************************************************************/
276 static inline void
277 AcpiTbInitGenericAddress (
278 ACPI_GENERIC_ADDRESS *GenericAddress,
279 UINT8 SpaceId,
280 UINT8 ByteWidth,
281 UINT64 Address)
285 * The 64-bit Address field is non-aligned in the byte packed
286 * GAS struct.
288 ACPI_MOVE_64_TO_64 (&GenericAddress->Address, &Address);
290 /* All other fields are byte-wide */
292 GenericAddress->SpaceId = SpaceId;
293 GenericAddress->BitWidth = (UINT8) ACPI_MUL_8 (ByteWidth);
294 GenericAddress->BitOffset = 0;
295 GenericAddress->AccessWidth = 0; /* Access width ANY */
299 /*******************************************************************************
301 * FUNCTION: AcpiTbParseFadt
303 * PARAMETERS: TableIndex - Index for the FADT
305 * RETURN: None
307 * DESCRIPTION: Initialize the FADT, DSDT and FACS tables
308 * (FADT contains the addresses of the DSDT and FACS)
310 ******************************************************************************/
312 void
313 AcpiTbParseFadt (
314 UINT32 TableIndex)
316 UINT32 Length;
317 ACPI_TABLE_HEADER *Table;
321 * The FADT has multiple versions with different lengths,
322 * and it contains pointers to both the DSDT and FACS tables.
324 * Get a local copy of the FADT and convert it to a common format
325 * Map entire FADT, assumed to be smaller than one page.
327 Length = AcpiGbl_RootTableList.Tables[TableIndex].Length;
329 Table = AcpiOsMapMemory (
330 AcpiGbl_RootTableList.Tables[TableIndex].Address, Length);
331 if (!Table)
333 return;
337 * Validate the FADT checksum before we copy the table. Ignore
338 * checksum error as we want to try to get the DSDT and FACS.
340 (void) AcpiTbVerifyChecksum (Table, Length);
342 /* Create a local copy of the FADT in common ACPI 2.0+ format */
344 AcpiTbCreateLocalFadt (Table, Length);
346 /* All done with the real FADT, unmap it */
348 AcpiOsUnmapMemory (Table, Length);
350 /* Obtain the DSDT and FACS tables via their addresses within the FADT */
352 AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt,
353 ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
355 AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs,
356 ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS);
360 /*******************************************************************************
362 * FUNCTION: AcpiTbCreateLocalFadt
364 * PARAMETERS: Table - Pointer to BIOS FADT
365 * Length - Length of the table
367 * RETURN: None
369 * DESCRIPTION: Get a local copy of the FADT and convert it to a common format.
370 * Performs validation on some important FADT fields.
372 * NOTE: We create a local copy of the FADT regardless of the version.
374 ******************************************************************************/
376 void
377 AcpiTbCreateLocalFadt (
378 ACPI_TABLE_HEADER *Table,
379 UINT32 Length)
383 * Check if the FADT is larger than the largest table that we expect
384 * (the ACPI 2.0/3.0 version). If so, truncate the table, and issue
385 * a warning.
387 if (Length > sizeof (ACPI_TABLE_FADT))
389 ACPI_WARNING ((AE_INFO,
390 "FADT (revision %u) is longer than ACPI 2.0 version, "
391 "truncating length %u to %u",
392 Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT)));
395 /* Clear the entire local FADT */
397 ACPI_MEMSET (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT));
399 /* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */
401 ACPI_MEMCPY (&AcpiGbl_FADT, Table,
402 ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT)));
404 /* Convert the local copy of the FADT to the common internal format */
406 AcpiTbConvertFadt ();
408 /* Validate FADT values now, before we make any changes */
410 AcpiTbValidateFadt ();
412 /* Initialize the global ACPI register structures */
414 AcpiTbSetupFadtRegisters ();
418 /*******************************************************************************
420 * FUNCTION: AcpiTbConvertFadt
422 * PARAMETERS: None, uses AcpiGbl_FADT
424 * RETURN: None
426 * DESCRIPTION: Converts all versions of the FADT to a common internal format.
427 * Expand 32-bit addresses to 64-bit as necessary.
429 * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT),
430 * and must contain a copy of the actual FADT.
432 * Notes on 64-bit register addresses:
434 * After this FADT conversion, later ACPICA code will only use the 64-bit "X"
435 * fields of the FADT for all ACPI register addresses.
437 * The 64-bit "X" fields are optional extensions to the original 32-bit FADT
438 * V1.0 fields. Even if they are present in the FADT, they are optional and
439 * are unused if the BIOS sets them to zero. Therefore, we must copy/expand
440 * 32-bit V1.0 fields if the corresponding X field is zero.
442 * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the
443 * corresponding "X" fields in the internal FADT.
445 * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded
446 * to the corresponding 64-bit X fields. For compatibility with other ACPI
447 * implementations, we ignore the 64-bit field if the 32-bit field is valid,
448 * regardless of whether the host OS is 32-bit or 64-bit.
450 ******************************************************************************/
452 static void
453 AcpiTbConvertFadt (
454 void)
456 ACPI_GENERIC_ADDRESS *Address64;
457 UINT32 Address32;
458 UINT32 i;
461 /* Update the local FADT table header length */
463 AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT);
466 * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
467 * Later code will always use the X 64-bit field.
469 if (!AcpiGbl_FADT.XFacs)
471 AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs;
473 if (!AcpiGbl_FADT.XDsdt)
475 AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt;
479 * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
480 * should be zero are indeed zero. This will workaround BIOSs that
481 * inadvertently place values in these fields.
483 * The ACPI 1.0 reserved fields that will be zeroed are the bytes located
484 * at offset 45, 55, 95, and the word located at offset 109, 110.
486 if (AcpiGbl_FADT.Header.Revision < 3)
488 AcpiGbl_FADT.PreferredProfile = 0;
489 AcpiGbl_FADT.PstateControl = 0;
490 AcpiGbl_FADT.CstControl = 0;
491 AcpiGbl_FADT.BootFlags = 0;
495 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
496 * generic address structures as necessary. Later code will always use
497 * the 64-bit address structures.
499 * March 2009:
500 * We now always use the 32-bit address if it is valid (non-null). This
501 * is not in accordance with the ACPI specification which states that
502 * the 64-bit address supersedes the 32-bit version, but we do this for
503 * compatibility with other ACPI implementations. Most notably, in the
504 * case where both the 32 and 64 versions are non-null, we use the 32-bit
505 * version. This is the only address that is guaranteed to have been
506 * tested by the BIOS manufacturer.
508 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
510 Address32 = *ACPI_ADD_PTR (UINT32,
511 &AcpiGbl_FADT, FadtInfoTable[i].Address32);
513 Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS,
514 &AcpiGbl_FADT, FadtInfoTable[i].Address64);
517 * If both 32- and 64-bit addresses are valid (non-zero),
518 * they must match.
520 if (Address64->Address && Address32 &&
521 (Address64->Address != (UINT64) Address32))
523 ACPI_ERROR ((AE_INFO,
524 "32/64X address mismatch in %s: 0x%8.8X/0x%8.8X%8.8X, using 32",
525 FadtInfoTable[i].Name, Address32,
526 ACPI_FORMAT_UINT64 (Address64->Address)));
529 /* Always use 32-bit address if it is valid (non-null) */
531 if (Address32)
534 * Copy the 32-bit address to the 64-bit GAS structure. The
535 * Space ID is always I/O for 32-bit legacy address fields
537 AcpiTbInitGenericAddress (Address64, ACPI_ADR_SPACE_SYSTEM_IO,
538 *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length),
539 (UINT64) Address32);
545 /*******************************************************************************
547 * FUNCTION: AcpiTbValidateFadt
549 * PARAMETERS: Table - Pointer to the FADT to be validated
551 * RETURN: None
553 * DESCRIPTION: Validate various important fields within the FADT. If a problem
554 * is found, issue a message, but no status is returned.
555 * Used by both the table manager and the disassembler.
557 * Possible additional checks:
558 * (AcpiGbl_FADT.Pm1EventLength >= 4)
559 * (AcpiGbl_FADT.Pm1ControlLength >= 2)
560 * (AcpiGbl_FADT.PmTimerLength >= 4)
561 * Gpe block lengths must be multiple of 2
563 ******************************************************************************/
565 static void
566 AcpiTbValidateFadt (
567 void)
569 char *Name;
570 ACPI_GENERIC_ADDRESS *Address64;
571 UINT8 Length;
572 UINT32 i;
576 * Check for FACS and DSDT address mismatches. An address mismatch between
577 * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
578 * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables.
580 if (AcpiGbl_FADT.Facs &&
581 (AcpiGbl_FADT.XFacs != (UINT64) AcpiGbl_FADT.Facs))
583 ACPI_WARNING ((AE_INFO,
584 "32/64X FACS address mismatch in FADT - "
585 "0x%8.8X/0x%8.8X%8.8X, using 32",
586 AcpiGbl_FADT.Facs, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XFacs)));
588 AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs;
591 if (AcpiGbl_FADT.Dsdt &&
592 (AcpiGbl_FADT.XDsdt != (UINT64) AcpiGbl_FADT.Dsdt))
594 ACPI_WARNING ((AE_INFO,
595 "32/64X DSDT address mismatch in FADT - "
596 "0x%8.8X/0x%8.8X%8.8X, using 32",
597 AcpiGbl_FADT.Dsdt, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XDsdt)));
599 AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt;
602 /* Examine all of the 64-bit extended address fields (X fields) */
604 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
607 * Generate pointer to the 64-bit address, get the register
608 * length (width) and the register name
610 Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS,
611 &AcpiGbl_FADT, FadtInfoTable[i].Address64);
612 Length = *ACPI_ADD_PTR (UINT8,
613 &AcpiGbl_FADT, FadtInfoTable[i].Length);
614 Name = FadtInfoTable[i].Name;
617 * For each extended field, check for length mismatch between the
618 * legacy length field and the corresponding 64-bit X length field.
620 if (Address64->Address &&
621 (Address64->BitWidth != ACPI_MUL_8 (Length)))
623 ACPI_WARNING ((AE_INFO,
624 "32/64X length mismatch in %s: %u/%u",
625 Name, ACPI_MUL_8 (Length), Address64->BitWidth));
628 if (FadtInfoTable[i].Type & ACPI_FADT_REQUIRED)
631 * Field is required (PM1aEvent, PM1aControl, PmTimer).
632 * Both the address and length must be non-zero.
634 if (!Address64->Address || !Length)
636 ACPI_ERROR ((AE_INFO,
637 "Required field %s has zero address and/or length:"
638 " 0x%8.8X%8.8X/0x%X",
639 Name, ACPI_FORMAT_UINT64 (Address64->Address), Length));
642 else if (FadtInfoTable[i].Type & ACPI_FADT_SEPARATE_LENGTH)
645 * Field is optional (PM2Control, GPE0, GPE1) AND has its own
646 * length field. If present, both the address and length must
647 * be valid.
649 if ((Address64->Address && !Length) ||
650 (!Address64->Address && Length))
652 ACPI_WARNING ((AE_INFO,
653 "Optional field %s has zero address or length: "
654 "0x%8.8X%8.8X/0x%X",
655 Name, ACPI_FORMAT_UINT64 (Address64->Address), Length));
662 /*******************************************************************************
664 * FUNCTION: AcpiTbSetupFadtRegisters
666 * PARAMETERS: None, uses AcpiGbl_FADT.
668 * RETURN: None
670 * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally,
671 * force FADT register definitions to their default lengths.
673 ******************************************************************************/
675 static void
676 AcpiTbSetupFadtRegisters (
677 void)
679 ACPI_GENERIC_ADDRESS *Target64;
680 ACPI_GENERIC_ADDRESS *Source64;
681 UINT8 Pm1RegisterByteWidth;
682 UINT32 i;
686 * Optionally check all register lengths against the default values and
687 * update them if they are incorrect.
689 if (AcpiGbl_UseDefaultRegisterWidths)
691 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
693 Target64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
694 FadtInfoTable[i].Address64);
697 * If a valid register (Address != 0) and the (DefaultLength > 0)
698 * (Not a GPE register), then check the width against the default.
700 if ((Target64->Address) &&
701 (FadtInfoTable[i].DefaultLength > 0) &&
702 (FadtInfoTable[i].DefaultLength != Target64->BitWidth))
704 ACPI_WARNING ((AE_INFO,
705 "Invalid length for %s: %u, using default %u",
706 FadtInfoTable[i].Name, Target64->BitWidth,
707 FadtInfoTable[i].DefaultLength));
709 /* Incorrect size, set width to the default */
711 Target64->BitWidth = FadtInfoTable[i].DefaultLength;
717 * Get the length of the individual PM1 registers (enable and status).
718 * Each register is defined to be (event block length / 2). Extra divide
719 * by 8 converts bits to bytes.
721 Pm1RegisterByteWidth = (UINT8)
722 ACPI_DIV_16 (AcpiGbl_FADT.XPm1aEventBlock.BitWidth);
725 * Calculate separate GAS structs for the PM1x (A/B) Status and Enable
726 * registers. These addresses do not appear (directly) in the FADT, so it
727 * is useful to pre-calculate them from the PM1 Event Block definitions.
729 * The PM event blocks are split into two register blocks, first is the
730 * PM Status Register block, followed immediately by the PM Enable
731 * Register block. Each is of length (Pm1EventLength/2)
733 * Note: The PM1A event block is required by the ACPI specification.
734 * However, the PM1B event block is optional and is rarely, if ever,
735 * used.
738 for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++)
740 Source64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
741 FadtPmInfoTable[i].Source);
743 if (Source64->Address)
745 AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target,
746 Source64->SpaceId, Pm1RegisterByteWidth,
747 Source64->Address +
748 (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth));