1 /******************************************************************************
3 * Module Name: tbfadt - FADT table utilities
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2014, Intel Corp.
12 * All rights reserved.
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
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
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
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
72 * 3.4. Intel retains all right, title, and interest in and to the Original
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
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
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 *****************************************************************************/
119 #include "accommon.h"
120 #include "actables.h"
122 #define _COMPONENT ACPI_TABLES
123 ACPI_MODULE_NAME ("tbfadt")
125 /* Local prototypes */
128 AcpiTbInitGenericAddress (
129 ACPI_GENERIC_ADDRESS
*GenericAddress
,
140 AcpiTbSetupFadtRegisters (
144 AcpiTbSelectAddress (
150 /* Table for conversion of FADT to common internal format and FADT validation */
152 typedef struct acpi_fadt_info
163 #define ACPI_FADT_OPTIONAL 0
164 #define ACPI_FADT_REQUIRED 1
165 #define ACPI_FADT_SEPARATE_LENGTH 2
167 static ACPI_FADT_INFO FadtInfoTable
[] =
170 ACPI_FADT_OFFSET (XPm1aEventBlock
),
171 ACPI_FADT_OFFSET (Pm1aEventBlock
),
172 ACPI_FADT_OFFSET (Pm1EventLength
),
173 ACPI_PM1_REGISTER_WIDTH
* 2, /* Enable + Status register */
177 ACPI_FADT_OFFSET (XPm1bEventBlock
),
178 ACPI_FADT_OFFSET (Pm1bEventBlock
),
179 ACPI_FADT_OFFSET (Pm1EventLength
),
180 ACPI_PM1_REGISTER_WIDTH
* 2, /* Enable + Status register */
184 ACPI_FADT_OFFSET (XPm1aControlBlock
),
185 ACPI_FADT_OFFSET (Pm1aControlBlock
),
186 ACPI_FADT_OFFSET (Pm1ControlLength
),
187 ACPI_PM1_REGISTER_WIDTH
,
191 ACPI_FADT_OFFSET (XPm1bControlBlock
),
192 ACPI_FADT_OFFSET (Pm1bControlBlock
),
193 ACPI_FADT_OFFSET (Pm1ControlLength
),
194 ACPI_PM1_REGISTER_WIDTH
,
198 ACPI_FADT_OFFSET (XPm2ControlBlock
),
199 ACPI_FADT_OFFSET (Pm2ControlBlock
),
200 ACPI_FADT_OFFSET (Pm2ControlLength
),
201 ACPI_PM2_REGISTER_WIDTH
,
202 ACPI_FADT_SEPARATE_LENGTH
},
205 ACPI_FADT_OFFSET (XPmTimerBlock
),
206 ACPI_FADT_OFFSET (PmTimerBlock
),
207 ACPI_FADT_OFFSET (PmTimerLength
),
209 ACPI_FADT_SEPARATE_LENGTH
}, /* ACPI 5.0A: Timer is optional */
212 ACPI_FADT_OFFSET (XGpe0Block
),
213 ACPI_FADT_OFFSET (Gpe0Block
),
214 ACPI_FADT_OFFSET (Gpe0BlockLength
),
216 ACPI_FADT_SEPARATE_LENGTH
},
219 ACPI_FADT_OFFSET (XGpe1Block
),
220 ACPI_FADT_OFFSET (Gpe1Block
),
221 ACPI_FADT_OFFSET (Gpe1BlockLength
),
223 ACPI_FADT_SEPARATE_LENGTH
}
226 #define ACPI_FADT_INFO_ENTRIES \
227 (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO))
230 /* Table used to split Event Blocks into separate status/enable registers */
232 typedef struct acpi_fadt_pm_info
234 ACPI_GENERIC_ADDRESS
*Target
;
240 static ACPI_FADT_PM_INFO FadtPmInfoTable
[] =
242 {&AcpiGbl_XPm1aStatus
,
243 ACPI_FADT_OFFSET (XPm1aEventBlock
),
246 {&AcpiGbl_XPm1aEnable
,
247 ACPI_FADT_OFFSET (XPm1aEventBlock
),
250 {&AcpiGbl_XPm1bStatus
,
251 ACPI_FADT_OFFSET (XPm1bEventBlock
),
254 {&AcpiGbl_XPm1bEnable
,
255 ACPI_FADT_OFFSET (XPm1bEventBlock
),
259 #define ACPI_FADT_PM_INFO_ENTRIES \
260 (sizeof (FadtPmInfoTable) / sizeof (ACPI_FADT_PM_INFO))
263 /*******************************************************************************
265 * FUNCTION: AcpiTbInitGenericAddress
267 * PARAMETERS: GenericAddress - GAS struct to be initialized
268 * SpaceId - ACPI Space ID for this register
269 * ByteWidth - Width of this register
270 * Address - Address of the register
271 * RegisterName - ASCII name of the ACPI register
275 * DESCRIPTION: Initialize a Generic Address Structure (GAS)
276 * See the ACPI specification for a full description and
277 * definition of this structure.
279 ******************************************************************************/
282 AcpiTbInitGenericAddress (
283 ACPI_GENERIC_ADDRESS
*GenericAddress
,
292 /* Bit width field in the GAS is only one byte long, 255 max */
294 BitWidth
= (UINT8
) (ByteWidth
* 8);
296 if (ByteWidth
> 31) /* (31*8)=248 */
298 ACPI_ERROR ((AE_INFO
,
299 "%s - 32-bit FADT register is too long (%u bytes, %u bits) "
300 "to convert to GAS struct - 255 bits max, truncating",
301 RegisterName
, ByteWidth
, (ByteWidth
* 8)));
307 * The 64-bit Address field is non-aligned in the byte packed
310 ACPI_MOVE_64_TO_64 (&GenericAddress
->Address
, &Address
);
312 /* All other fields are byte-wide */
314 GenericAddress
->SpaceId
= SpaceId
;
315 GenericAddress
->BitWidth
= BitWidth
;
316 GenericAddress
->BitOffset
= 0;
317 GenericAddress
->AccessWidth
= 0; /* Access width ANY */
321 /*******************************************************************************
323 * FUNCTION: AcpiTbSelectAddress
325 * PARAMETERS: RegisterName - ASCII name of the ACPI register
326 * Address32 - 32-bit address of the register
327 * Address64 - 64-bit address of the register
329 * RETURN: The resolved 64-bit address
331 * DESCRIPTION: Select between 32-bit and 64-bit versions of addresses within
332 * the FADT. Used for the FACS and DSDT addresses.
336 * Check for FACS and DSDT address mismatches. An address mismatch between
337 * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
338 * DSDT/X_DSDT) could be a corrupted address field or it might indicate
339 * the presence of two FACS or two DSDT tables.
342 * By default, as per the ACPICA specification, a valid 64-bit address is
343 * used regardless of the value of the 32-bit address. However, this
344 * behavior can be overridden via the AcpiGbl_Use32BitFadtAddresses flag.
346 ******************************************************************************/
349 AcpiTbSelectAddress (
357 /* 64-bit address is zero, use 32-bit address */
359 return ((UINT64
) Address32
);
363 (Address64
!= (UINT64
) Address32
))
365 /* Address mismatch between 32-bit and 64-bit versions */
367 ACPI_BIOS_WARNING ((AE_INFO
,
368 "32/64X %s address mismatch in FADT: "
369 "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
370 RegisterName
, Address32
, ACPI_FORMAT_UINT64 (Address64
),
371 AcpiGbl_Use32BitFadtAddresses
? 32 : 64));
373 /* 32-bit address override */
375 if (AcpiGbl_Use32BitFadtAddresses
)
377 return ((UINT64
) Address32
);
381 /* Default is to use the 64-bit address */
387 /*******************************************************************************
389 * FUNCTION: AcpiTbParseFadt
391 * PARAMETERS: TableIndex - Index for the FADT
395 * DESCRIPTION: Initialize the FADT, DSDT and FACS tables
396 * (FADT contains the addresses of the DSDT and FACS)
398 ******************************************************************************/
405 ACPI_TABLE_HEADER
*Table
;
409 * The FADT has multiple versions with different lengths,
410 * and it contains pointers to both the DSDT and FACS tables.
412 * Get a local copy of the FADT and convert it to a common format
413 * Map entire FADT, assumed to be smaller than one page.
415 Length
= AcpiGbl_RootTableList
.Tables
[TableIndex
].Length
;
417 Table
= AcpiOsMapMemory (
418 AcpiGbl_RootTableList
.Tables
[TableIndex
].Address
, Length
);
425 * Validate the FADT checksum before we copy the table. Ignore
426 * checksum error as we want to try to get the DSDT and FACS.
428 (void) AcpiTbVerifyChecksum (Table
, Length
);
430 /* Create a local copy of the FADT in common ACPI 2.0+ format */
432 AcpiTbCreateLocalFadt (Table
, Length
);
434 /* All done with the real FADT, unmap it */
436 AcpiOsUnmapMemory (Table
, Length
);
438 /* Obtain the DSDT and FACS tables via their addresses within the FADT */
440 AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS
) AcpiGbl_FADT
.XDsdt
,
441 ACPI_SIG_DSDT
, ACPI_TABLE_INDEX_DSDT
);
443 /* If Hardware Reduced flag is set, there is no FACS */
445 if (!AcpiGbl_ReducedHardware
)
447 AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS
) AcpiGbl_FADT
.XFacs
,
448 ACPI_SIG_FACS
, ACPI_TABLE_INDEX_FACS
);
453 /*******************************************************************************
455 * FUNCTION: AcpiTbCreateLocalFadt
457 * PARAMETERS: Table - Pointer to BIOS FADT
458 * Length - Length of the table
462 * DESCRIPTION: Get a local copy of the FADT and convert it to a common format.
463 * Performs validation on some important FADT fields.
465 * NOTE: We create a local copy of the FADT regardless of the version.
467 ******************************************************************************/
470 AcpiTbCreateLocalFadt (
471 ACPI_TABLE_HEADER
*Table
,
476 * Check if the FADT is larger than the largest table that we expect
477 * (the ACPI 5.0 version). If so, truncate the table, and issue
480 if (Length
> sizeof (ACPI_TABLE_FADT
))
482 ACPI_BIOS_WARNING ((AE_INFO
,
483 "FADT (revision %u) is longer than ACPI 5.0 version, "
484 "truncating length %u to %u",
485 Table
->Revision
, Length
, (UINT32
) sizeof (ACPI_TABLE_FADT
)));
488 /* Clear the entire local FADT */
490 ACPI_MEMSET (&AcpiGbl_FADT
, 0, sizeof (ACPI_TABLE_FADT
));
492 /* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */
494 ACPI_MEMCPY (&AcpiGbl_FADT
, Table
,
495 ACPI_MIN (Length
, sizeof (ACPI_TABLE_FADT
)));
497 /* Take a copy of the Hardware Reduced flag */
499 AcpiGbl_ReducedHardware
= FALSE
;
500 if (AcpiGbl_FADT
.Flags
& ACPI_FADT_HW_REDUCED
)
502 AcpiGbl_ReducedHardware
= TRUE
;
505 /* Convert the local copy of the FADT to the common internal format */
507 AcpiTbConvertFadt ();
509 /* Initialize the global ACPI register structures */
511 AcpiTbSetupFadtRegisters ();
515 /*******************************************************************************
517 * FUNCTION: AcpiTbConvertFadt
519 * PARAMETERS: None - AcpiGbl_FADT is used.
523 * DESCRIPTION: Converts all versions of the FADT to a common internal format.
524 * Expand 32-bit addresses to 64-bit as necessary. Also validate
525 * important fields within the FADT.
527 * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT), and must
528 * contain a copy of the actual BIOS-provided FADT.
530 * Notes on 64-bit register addresses:
532 * After this FADT conversion, later ACPICA code will only use the 64-bit "X"
533 * fields of the FADT for all ACPI register addresses.
535 * The 64-bit X fields are optional extensions to the original 32-bit FADT
536 * V1.0 fields. Even if they are present in the FADT, they are optional and
537 * are unused if the BIOS sets them to zero. Therefore, we must copy/expand
538 * 32-bit V1.0 fields to the 64-bit X fields if the the 64-bit X field is
541 * For ACPI 1.0 FADTs (that contain no 64-bit addresses), all 32-bit address
542 * fields are expanded to the corresponding 64-bit X fields in the internal
545 * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded
546 * to the corresponding 64-bit X fields, if the 64-bit field is originally
547 * zero. Adhering to the ACPI specification, we completely ignore the 32-bit
548 * field if the 64-bit field is valid, regardless of whether the host OS is
551 * Possible additional checks:
552 * (AcpiGbl_FADT.Pm1EventLength >= 4)
553 * (AcpiGbl_FADT.Pm1ControlLength >= 2)
554 * (AcpiGbl_FADT.PmTimerLength >= 4)
555 * Gpe block lengths must be multiple of 2
557 ******************************************************************************/
564 ACPI_GENERIC_ADDRESS
*Address64
;
571 * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
572 * should be zero are indeed zero. This will workaround BIOSs that
573 * inadvertently place values in these fields.
575 * The ACPI 1.0 reserved fields that will be zeroed are the bytes located
576 * at offset 45, 55, 95, and the word located at offset 109, 110.
578 * Note: The FADT revision value is unreliable. Only the length can be
581 if (AcpiGbl_FADT
.Header
.Length
<= ACPI_FADT_V2_SIZE
)
583 AcpiGbl_FADT
.PreferredProfile
= 0;
584 AcpiGbl_FADT
.PstateControl
= 0;
585 AcpiGbl_FADT
.CstControl
= 0;
586 AcpiGbl_FADT
.BootFlags
= 0;
590 * Now we can update the local FADT length to the length of the
591 * current FADT version as defined by the ACPI specification.
592 * Thus, we will have a common FADT internally.
594 AcpiGbl_FADT
.Header
.Length
= sizeof (ACPI_TABLE_FADT
);
597 * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
598 * Later ACPICA code will always use the X 64-bit field.
600 AcpiGbl_FADT
.XFacs
= AcpiTbSelectAddress ("FACS",
601 AcpiGbl_FADT
.Facs
, AcpiGbl_FADT
.XFacs
);
603 AcpiGbl_FADT
.XDsdt
= AcpiTbSelectAddress ("DSDT",
604 AcpiGbl_FADT
.Dsdt
, AcpiGbl_FADT
.XDsdt
);
606 /* If Hardware Reduced flag is set, we are all done */
608 if (AcpiGbl_ReducedHardware
)
613 /* Examine all of the 64-bit extended address fields (X fields) */
615 for (i
= 0; i
< ACPI_FADT_INFO_ENTRIES
; i
++)
618 * Get the 32-bit and 64-bit addresses, as well as the register
619 * length and register name.
621 Address32
= *ACPI_ADD_PTR (UINT32
,
622 &AcpiGbl_FADT
, FadtInfoTable
[i
].Address32
);
624 Address64
= ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS
,
625 &AcpiGbl_FADT
, FadtInfoTable
[i
].Address64
);
627 Length
= *ACPI_ADD_PTR (UINT8
,
628 &AcpiGbl_FADT
, FadtInfoTable
[i
].Length
);
630 Name
= FadtInfoTable
[i
].Name
;
633 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
634 * generic address structures as necessary. Later code will always use
635 * the 64-bit address structures.
638 * Now always use the 64-bit address if it is valid (non-zero), in
639 * accordance with the ACPI specification which states that a 64-bit
640 * address supersedes the 32-bit version. This behavior can be
641 * overridden by the AcpiGbl_Use32BitFadtAddresses flag.
643 * During 64-bit address construction and verification,
644 * these cases are handled:
646 * Address32 zero, Address64 [don't care] - Use Address64
648 * Address32 non-zero, Address64 zero - Copy/use Address32
649 * Address32 non-zero == Address64 non-zero - Use Address64
650 * Address32 non-zero != Address64 non-zero - Warning, use Address64
652 * Override: if AcpiGbl_Use32BitFadtAddresses is TRUE, and:
653 * Address32 non-zero != Address64 non-zero - Warning, copy/use Address32
655 * Note: SpaceId is always I/O for 32-bit legacy address fields
659 if (!Address64
->Address
)
661 /* 64-bit address is zero, use 32-bit address */
663 AcpiTbInitGenericAddress (Address64
,
664 ACPI_ADR_SPACE_SYSTEM_IO
,
665 *ACPI_ADD_PTR (UINT8
, &AcpiGbl_FADT
,
666 FadtInfoTable
[i
].Length
),
667 (UINT64
) Address32
, Name
);
669 else if (Address64
->Address
!= (UINT64
) Address32
)
671 /* Address mismatch */
673 ACPI_BIOS_WARNING ((AE_INFO
,
674 "32/64X address mismatch in FADT/%s: "
675 "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
677 ACPI_FORMAT_UINT64 (Address64
->Address
),
678 AcpiGbl_Use32BitFadtAddresses
? 32 : 64));
680 if (AcpiGbl_Use32BitFadtAddresses
)
682 /* 32-bit address override */
684 AcpiTbInitGenericAddress (Address64
,
685 ACPI_ADR_SPACE_SYSTEM_IO
,
686 *ACPI_ADD_PTR (UINT8
, &AcpiGbl_FADT
,
687 FadtInfoTable
[i
].Length
),
688 (UINT64
) Address32
, Name
);
694 * For each extended field, check for length mismatch between the
695 * legacy length field and the corresponding 64-bit X length field.
696 * Note: If the legacy length field is > 0xFF bits, ignore this
697 * check. (GPE registers can be larger than the 64-bit GAS structure
698 * can accomodate, 0xFF bits).
700 if (Address64
->Address
&&
701 (ACPI_MUL_8 (Length
) <= ACPI_UINT8_MAX
) &&
702 (Address64
->BitWidth
!= ACPI_MUL_8 (Length
)))
704 ACPI_BIOS_WARNING ((AE_INFO
,
705 "32/64X length mismatch in FADT/%s: %u/%u",
706 Name
, ACPI_MUL_8 (Length
), Address64
->BitWidth
));
709 if (FadtInfoTable
[i
].Type
& ACPI_FADT_REQUIRED
)
712 * Field is required (PM1aEvent, PM1aControl).
713 * Both the address and length must be non-zero.
715 if (!Address64
->Address
|| !Length
)
717 ACPI_BIOS_ERROR ((AE_INFO
,
718 "Required FADT field %s has zero address and/or length: "
720 Name
, ACPI_FORMAT_UINT64 (Address64
->Address
), Length
));
723 else if (FadtInfoTable
[i
].Type
& ACPI_FADT_SEPARATE_LENGTH
)
726 * Field is optional (PM2Control, GPE0, GPE1) AND has its own
727 * length field. If present, both the address and length must
730 if ((Address64
->Address
&& !Length
) ||
731 (!Address64
->Address
&& Length
))
733 ACPI_BIOS_WARNING ((AE_INFO
,
734 "Optional FADT field %s has zero address or length: "
736 Name
, ACPI_FORMAT_UINT64 (Address64
->Address
), Length
));
743 /*******************************************************************************
745 * FUNCTION: AcpiTbSetupFadtRegisters
747 * PARAMETERS: None, uses AcpiGbl_FADT.
751 * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally,
752 * force FADT register definitions to their default lengths.
754 ******************************************************************************/
757 AcpiTbSetupFadtRegisters (
760 ACPI_GENERIC_ADDRESS
*Target64
;
761 ACPI_GENERIC_ADDRESS
*Source64
;
762 UINT8 Pm1RegisterByteWidth
;
767 * Optionally check all register lengths against the default values and
768 * update them if they are incorrect.
770 if (AcpiGbl_UseDefaultRegisterWidths
)
772 for (i
= 0; i
< ACPI_FADT_INFO_ENTRIES
; i
++)
774 Target64
= ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS
, &AcpiGbl_FADT
,
775 FadtInfoTable
[i
].Address64
);
778 * If a valid register (Address != 0) and the (DefaultLength > 0)
779 * (Not a GPE register), then check the width against the default.
781 if ((Target64
->Address
) &&
782 (FadtInfoTable
[i
].DefaultLength
> 0) &&
783 (FadtInfoTable
[i
].DefaultLength
!= Target64
->BitWidth
))
785 ACPI_BIOS_WARNING ((AE_INFO
,
786 "Invalid length for FADT/%s: %u, using default %u",
787 FadtInfoTable
[i
].Name
, Target64
->BitWidth
,
788 FadtInfoTable
[i
].DefaultLength
));
790 /* Incorrect size, set width to the default */
792 Target64
->BitWidth
= FadtInfoTable
[i
].DefaultLength
;
798 * Get the length of the individual PM1 registers (enable and status).
799 * Each register is defined to be (event block length / 2). Extra divide
800 * by 8 converts bits to bytes.
802 Pm1RegisterByteWidth
= (UINT8
)
803 ACPI_DIV_16 (AcpiGbl_FADT
.XPm1aEventBlock
.BitWidth
);
806 * Calculate separate GAS structs for the PM1x (A/B) Status and Enable
807 * registers. These addresses do not appear (directly) in the FADT, so it
808 * is useful to pre-calculate them from the PM1 Event Block definitions.
810 * The PM event blocks are split into two register blocks, first is the
811 * PM Status Register block, followed immediately by the PM Enable
812 * Register block. Each is of length (Pm1EventLength/2)
814 * Note: The PM1A event block is required by the ACPI specification.
815 * However, the PM1B event block is optional and is rarely, if ever,
819 for (i
= 0; i
< ACPI_FADT_PM_INFO_ENTRIES
; i
++)
821 Source64
= ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS
, &AcpiGbl_FADT
,
822 FadtPmInfoTable
[i
].Source
);
824 if (Source64
->Address
)
826 AcpiTbInitGenericAddress (FadtPmInfoTable
[i
].Target
,
827 Source64
->SpaceId
, Pm1RegisterByteWidth
,
829 (FadtPmInfoTable
[i
].RegisterNum
* Pm1RegisterByteWidth
),