]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/contrib/dev/acpica/tables/tbfadt.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / contrib / dev / acpica / tables / tbfadt.c
1 /******************************************************************************
2  *
3  * Module Name: tbfadt   - FADT table utilities
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2011, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43
44 #define __TBFADT_C__
45
46 #include <contrib/dev/acpica/include/acpi.h>
47 #include <contrib/dev/acpica/include/accommon.h>
48 #include <contrib/dev/acpica/include/actables.h>
49
50 #define _COMPONENT          ACPI_TABLES
51         ACPI_MODULE_NAME    ("tbfadt")
52
53 /* Local prototypes */
54
55 static ACPI_INLINE void
56 AcpiTbInitGenericAddress (
57     ACPI_GENERIC_ADDRESS    *GenericAddress,
58     UINT8                   SpaceId,
59     UINT8                   ByteWidth,
60     UINT64                  Address);
61
62 static void
63 AcpiTbConvertFadt (
64     void);
65
66 static void
67 AcpiTbValidateFadt (
68     void);
69
70 static void
71 AcpiTbSetupFadtRegisters (
72     void);
73
74
75 /* Table for conversion of FADT to common internal format and FADT validation */
76
77 typedef struct acpi_fadt_info
78 {
79     char                    *Name;
80     UINT8                   Address64;
81     UINT8                   Address32;
82     UINT8                   Length;
83     UINT8                   DefaultLength;
84     UINT8                   Type;
85
86 } ACPI_FADT_INFO;
87
88 #define ACPI_FADT_REQUIRED          1
89 #define ACPI_FADT_SEPARATE_LENGTH   2
90
91 static ACPI_FADT_INFO     FadtInfoTable[] =
92 {
93     {"Pm1aEventBlock",
94         ACPI_FADT_OFFSET (XPm1aEventBlock),
95         ACPI_FADT_OFFSET (Pm1aEventBlock),
96         ACPI_FADT_OFFSET (Pm1EventLength),
97         ACPI_PM1_REGISTER_WIDTH * 2,        /* Enable + Status register */
98         ACPI_FADT_REQUIRED},
99
100     {"Pm1bEventBlock",
101         ACPI_FADT_OFFSET (XPm1bEventBlock),
102         ACPI_FADT_OFFSET (Pm1bEventBlock),
103         ACPI_FADT_OFFSET (Pm1EventLength),
104         ACPI_PM1_REGISTER_WIDTH * 2,        /* Enable + Status register */
105         0},
106
107     {"Pm1aControlBlock",
108         ACPI_FADT_OFFSET (XPm1aControlBlock),
109         ACPI_FADT_OFFSET (Pm1aControlBlock),
110         ACPI_FADT_OFFSET (Pm1ControlLength),
111         ACPI_PM1_REGISTER_WIDTH,
112         ACPI_FADT_REQUIRED},
113
114     {"Pm1bControlBlock",
115         ACPI_FADT_OFFSET (XPm1bControlBlock),
116         ACPI_FADT_OFFSET (Pm1bControlBlock),
117         ACPI_FADT_OFFSET (Pm1ControlLength),
118         ACPI_PM1_REGISTER_WIDTH,
119         0},
120
121     {"Pm2ControlBlock",
122         ACPI_FADT_OFFSET (XPm2ControlBlock),
123         ACPI_FADT_OFFSET (Pm2ControlBlock),
124         ACPI_FADT_OFFSET (Pm2ControlLength),
125         ACPI_PM2_REGISTER_WIDTH,
126         ACPI_FADT_SEPARATE_LENGTH},
127
128     {"PmTimerBlock",
129         ACPI_FADT_OFFSET (XPmTimerBlock),
130         ACPI_FADT_OFFSET (PmTimerBlock),
131         ACPI_FADT_OFFSET (PmTimerLength),
132         ACPI_PM_TIMER_WIDTH,
133         ACPI_FADT_REQUIRED},
134
135     {"Gpe0Block",
136         ACPI_FADT_OFFSET (XGpe0Block),
137         ACPI_FADT_OFFSET (Gpe0Block),
138         ACPI_FADT_OFFSET (Gpe0BlockLength),
139         0,
140         ACPI_FADT_SEPARATE_LENGTH},
141
142     {"Gpe1Block",
143         ACPI_FADT_OFFSET (XGpe1Block),
144         ACPI_FADT_OFFSET (Gpe1Block),
145         ACPI_FADT_OFFSET (Gpe1BlockLength),
146         0,
147         ACPI_FADT_SEPARATE_LENGTH}
148 };
149
150 #define ACPI_FADT_INFO_ENTRIES \
151             (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO))
152
153
154 /* Table used to split Event Blocks into separate status/enable registers */
155
156 typedef struct acpi_fadt_pm_info
157 {
158     ACPI_GENERIC_ADDRESS    *Target;
159     UINT8                   Source;
160     UINT8                   RegisterNum;
161
162 } ACPI_FADT_PM_INFO;
163
164 static ACPI_FADT_PM_INFO    FadtPmInfoTable[] =
165 {
166     {&AcpiGbl_XPm1aStatus,
167         ACPI_FADT_OFFSET (XPm1aEventBlock),
168         0},
169
170     {&AcpiGbl_XPm1aEnable,
171         ACPI_FADT_OFFSET (XPm1aEventBlock),
172         1},
173
174     {&AcpiGbl_XPm1bStatus,
175         ACPI_FADT_OFFSET (XPm1bEventBlock),
176         0},
177
178     {&AcpiGbl_XPm1bEnable,
179         ACPI_FADT_OFFSET (XPm1bEventBlock),
180         1}
181 };
182
183 #define ACPI_FADT_PM_INFO_ENTRIES \
184             (sizeof (FadtPmInfoTable) / sizeof (ACPI_FADT_PM_INFO))
185
186
187 /*******************************************************************************
188  *
189  * FUNCTION:    AcpiTbInitGenericAddress
190  *
191  * PARAMETERS:  GenericAddress      - GAS struct to be initialized
192  *              SpaceId             - ACPI Space ID for this register
193  *              ByteWidth           - Width of this register, in bytes
194  *              Address             - Address of the register
195  *
196  * RETURN:      None
197  *
198  * DESCRIPTION: Initialize a Generic Address Structure (GAS)
199  *              See the ACPI specification for a full description and
200  *              definition of this structure.
201  *
202  ******************************************************************************/
203
204 static ACPI_INLINE void
205 AcpiTbInitGenericAddress (
206     ACPI_GENERIC_ADDRESS    *GenericAddress,
207     UINT8                   SpaceId,
208     UINT8                   ByteWidth,
209     UINT64                  Address)
210 {
211
212     /*
213      * The 64-bit Address field is non-aligned in the byte packed
214      * GAS struct.
215      */
216     ACPI_MOVE_64_TO_64 (&GenericAddress->Address, &Address);
217
218     /* All other fields are byte-wide */
219
220     GenericAddress->SpaceId = SpaceId;
221     GenericAddress->BitWidth = (UINT8) ACPI_MUL_8 (ByteWidth);
222     GenericAddress->BitOffset = 0;
223     GenericAddress->AccessWidth = 0; /* Access width ANY */
224 }
225
226
227 /*******************************************************************************
228  *
229  * FUNCTION:    AcpiTbParseFadt
230  *
231  * PARAMETERS:  TableIndex          - Index for the FADT
232  *
233  * RETURN:      None
234  *
235  * DESCRIPTION: Initialize the FADT, DSDT and FACS tables
236  *              (FADT contains the addresses of the DSDT and FACS)
237  *
238  ******************************************************************************/
239
240 void
241 AcpiTbParseFadt (
242     UINT32                  TableIndex)
243 {
244     UINT32                  Length;
245     ACPI_TABLE_HEADER       *Table;
246
247
248     /*
249      * The FADT has multiple versions with different lengths,
250      * and it contains pointers to both the DSDT and FACS tables.
251      *
252      * Get a local copy of the FADT and convert it to a common format
253      * Map entire FADT, assumed to be smaller than one page.
254      */
255     Length = AcpiGbl_RootTableList.Tables[TableIndex].Length;
256
257     Table = AcpiOsMapMemory (
258                 AcpiGbl_RootTableList.Tables[TableIndex].Address, Length);
259     if (!Table)
260     {
261         return;
262     }
263
264     /*
265      * Validate the FADT checksum before we copy the table. Ignore
266      * checksum error as we want to try to get the DSDT and FACS.
267      */
268     (void) AcpiTbVerifyChecksum (Table, Length);
269
270     /* Create a local copy of the FADT in common ACPI 2.0+ format */
271
272     AcpiTbCreateLocalFadt (Table, Length);
273
274     /* All done with the real FADT, unmap it */
275
276     AcpiOsUnmapMemory (Table, Length);
277
278     /* Obtain the DSDT and FACS tables via their addresses within the FADT */
279
280     AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt,
281         ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
282
283     AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs,
284         ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS);
285 }
286
287
288 /*******************************************************************************
289  *
290  * FUNCTION:    AcpiTbCreateLocalFadt
291  *
292  * PARAMETERS:  Table               - Pointer to BIOS FADT
293  *              Length              - Length of the table
294  *
295  * RETURN:      None
296  *
297  * DESCRIPTION: Get a local copy of the FADT and convert it to a common format.
298  *              Performs validation on some important FADT fields.
299  *
300  * NOTE:        We create a local copy of the FADT regardless of the version.
301  *
302  ******************************************************************************/
303
304 void
305 AcpiTbCreateLocalFadt (
306     ACPI_TABLE_HEADER       *Table,
307     UINT32                  Length)
308 {
309
310     /*
311      * Check if the FADT is larger than the largest table that we expect
312      * (the ACPI 2.0/3.0 version). If so, truncate the table, and issue
313      * a warning.
314      */
315     if (Length > sizeof (ACPI_TABLE_FADT))
316     {
317         ACPI_WARNING ((AE_INFO,
318             "FADT (revision %u) is longer than ACPI 2.0 version, "
319             "truncating length %u to %u",
320             Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT)));
321     }
322
323     /* Clear the entire local FADT */
324
325     ACPI_MEMSET (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT));
326
327     /* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */
328
329     ACPI_MEMCPY (&AcpiGbl_FADT, Table,
330         ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT)));
331
332     /* Convert the local copy of the FADT to the common internal format */
333
334     AcpiTbConvertFadt ();
335
336     /* Validate FADT values now, before we make any changes */
337
338     AcpiTbValidateFadt ();
339
340     /* Initialize the global ACPI register structures */
341
342     AcpiTbSetupFadtRegisters ();
343 }
344
345
346 /*******************************************************************************
347  *
348  * FUNCTION:    AcpiTbConvertFadt
349  *
350  * PARAMETERS:  None, uses AcpiGbl_FADT
351  *
352  * RETURN:      None
353  *
354  * DESCRIPTION: Converts all versions of the FADT to a common internal format.
355  *              Expand 32-bit addresses to 64-bit as necessary.
356  *
357  * NOTE:        AcpiGbl_FADT must be of size (ACPI_TABLE_FADT),
358  *              and must contain a copy of the actual FADT.
359  *
360  * Notes on 64-bit register addresses:
361  *
362  * After this FADT conversion, later ACPICA code will only use the 64-bit "X"
363  * fields of the FADT for all ACPI register addresses.
364  *
365  * The 64-bit "X" fields are optional extensions to the original 32-bit FADT
366  * V1.0 fields. Even if they are present in the FADT, they are optional and
367  * are unused if the BIOS sets them to zero. Therefore, we must copy/expand
368  * 32-bit V1.0 fields if the corresponding X field is zero.
369  *
370  * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the
371  * corresponding "X" fields in the internal FADT.
372  *
373  * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded
374  * to the corresponding 64-bit X fields. For compatibility with other ACPI
375  * implementations, we ignore the 64-bit field if the 32-bit field is valid,
376  * regardless of whether the host OS is 32-bit or 64-bit.
377  *
378  ******************************************************************************/
379
380 static void
381 AcpiTbConvertFadt (
382     void)
383 {
384     ACPI_GENERIC_ADDRESS    *Address64;
385     UINT32                  Address32;
386     UINT32                  i;
387
388
389     /* Update the local FADT table header length */
390
391     AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT);
392
393     /*
394      * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
395      * Later code will always use the X 64-bit field.
396      */
397     if (!AcpiGbl_FADT.XFacs)
398     {
399         AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs;
400     }
401     if (!AcpiGbl_FADT.XDsdt)
402     {
403         AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt;
404     }
405
406     /*
407      * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
408      * should be zero are indeed zero. This will workaround BIOSs that
409      * inadvertently place values in these fields.
410      *
411      * The ACPI 1.0 reserved fields that will be zeroed are the bytes located
412      * at offset 45, 55, 95, and the word located at offset 109, 110.
413      *
414      * Note: The FADT revision value is unreliable. Only the length can be
415      * trusted.
416      */
417     if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE)
418     {
419         AcpiGbl_FADT.PreferredProfile = 0;
420         AcpiGbl_FADT.PstateControl = 0;
421         AcpiGbl_FADT.CstControl = 0;
422         AcpiGbl_FADT.BootFlags = 0;
423     }
424
425     /*
426      * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
427      * generic address structures as necessary. Later code will always use
428      * the 64-bit address structures.
429      *
430      * March 2009:
431      * We now always use the 32-bit address if it is valid (non-null). This
432      * is not in accordance with the ACPI specification which states that
433      * the 64-bit address supersedes the 32-bit version, but we do this for
434      * compatibility with other ACPI implementations. Most notably, in the
435      * case where both the 32 and 64 versions are non-null, we use the 32-bit
436      * version. This is the only address that is guaranteed to have been
437      * tested by the BIOS manufacturer.
438      */
439     for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
440     {
441         Address32 = *ACPI_ADD_PTR (UINT32,
442             &AcpiGbl_FADT, FadtInfoTable[i].Address32);
443
444         Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS,
445             &AcpiGbl_FADT, FadtInfoTable[i].Address64);
446
447         /*
448          * If both 32- and 64-bit addresses are valid (non-zero),
449          * they must match.
450          */
451         if (Address64->Address && Address32 &&
452            (Address64->Address != (UINT64) Address32))
453         {
454             ACPI_ERROR ((AE_INFO,
455                 "32/64X address mismatch in %s: 0x%8.8X/0x%8.8X%8.8X, using 32",
456                 FadtInfoTable[i].Name, Address32,
457                 ACPI_FORMAT_UINT64 (Address64->Address)));
458         }
459
460         /* Always use 32-bit address if it is valid (non-null) */
461
462         if (Address32)
463         {
464             /*
465              * Copy the 32-bit address to the 64-bit GAS structure. The
466              * Space ID is always I/O for 32-bit legacy address fields
467              */
468             AcpiTbInitGenericAddress (Address64, ACPI_ADR_SPACE_SYSTEM_IO,
469                 *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length),
470                 (UINT64) Address32);
471         }
472     }
473 }
474
475
476 /*******************************************************************************
477  *
478  * FUNCTION:    AcpiTbValidateFadt
479  *
480  * PARAMETERS:  Table           - Pointer to the FADT to be validated
481  *
482  * RETURN:      None
483  *
484  * DESCRIPTION: Validate various important fields within the FADT. If a problem
485  *              is found, issue a message, but no status is returned.
486  *              Used by both the table manager and the disassembler.
487  *
488  * Possible additional checks:
489  * (AcpiGbl_FADT.Pm1EventLength >= 4)
490  * (AcpiGbl_FADT.Pm1ControlLength >= 2)
491  * (AcpiGbl_FADT.PmTimerLength >= 4)
492  * Gpe block lengths must be multiple of 2
493  *
494  ******************************************************************************/
495
496 static void
497 AcpiTbValidateFadt (
498     void)
499 {
500     char                    *Name;
501     ACPI_GENERIC_ADDRESS    *Address64;
502     UINT8                   Length;
503     UINT32                  i;
504
505
506     /*
507      * Check for FACS and DSDT address mismatches. An address mismatch between
508      * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
509      * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables.
510      */
511     if (AcpiGbl_FADT.Facs &&
512         (AcpiGbl_FADT.XFacs != (UINT64) AcpiGbl_FADT.Facs))
513     {
514         ACPI_WARNING ((AE_INFO,
515             "32/64X FACS address mismatch in FADT - "
516             "0x%8.8X/0x%8.8X%8.8X, using 32",
517             AcpiGbl_FADT.Facs, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XFacs)));
518
519         AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs;
520     }
521
522     if (AcpiGbl_FADT.Dsdt &&
523         (AcpiGbl_FADT.XDsdt != (UINT64) AcpiGbl_FADT.Dsdt))
524     {
525         ACPI_WARNING ((AE_INFO,
526             "32/64X DSDT address mismatch in FADT - "
527             "0x%8.8X/0x%8.8X%8.8X, using 32",
528             AcpiGbl_FADT.Dsdt, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XDsdt)));
529
530         AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt;
531     }
532
533     /* Examine all of the 64-bit extended address fields (X fields) */
534
535     for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
536     {
537         /*
538          * Generate pointer to the 64-bit address, get the register
539          * length (width) and the register name
540          */
541         Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS,
542                         &AcpiGbl_FADT, FadtInfoTable[i].Address64);
543         Length = *ACPI_ADD_PTR (UINT8,
544                         &AcpiGbl_FADT, FadtInfoTable[i].Length);
545         Name = FadtInfoTable[i].Name;
546
547         /*
548          * For each extended field, check for length mismatch between the
549          * legacy length field and the corresponding 64-bit X length field.
550          */
551         if (Address64->Address &&
552            (Address64->BitWidth != ACPI_MUL_8 (Length)))
553         {
554             ACPI_WARNING ((AE_INFO,
555                 "32/64X length mismatch in %s: %u/%u",
556                 Name, ACPI_MUL_8 (Length), Address64->BitWidth));
557         }
558
559         if (FadtInfoTable[i].Type & ACPI_FADT_REQUIRED)
560         {
561             /*
562              * Field is required (PM1aEvent, PM1aControl, PmTimer).
563              * Both the address and length must be non-zero.
564              */
565             if (!Address64->Address || !Length)
566             {
567                 ACPI_ERROR ((AE_INFO,
568                     "Required field %s has zero address and/or length:"
569                     " 0x%8.8X%8.8X/0x%X",
570                     Name, ACPI_FORMAT_UINT64 (Address64->Address), Length));
571             }
572         }
573         else if (FadtInfoTable[i].Type & ACPI_FADT_SEPARATE_LENGTH)
574         {
575             /*
576              * Field is optional (PM2Control, GPE0, GPE1) AND has its own
577              * length field. If present, both the address and length must
578              * be valid.
579              */
580             if ((Address64->Address && !Length) ||
581                 (!Address64->Address && Length))
582             {
583                 ACPI_WARNING ((AE_INFO,
584                     "Optional field %s has zero address or length: "
585                     "0x%8.8X%8.8X/0x%X",
586                     Name, ACPI_FORMAT_UINT64 (Address64->Address), Length));
587             }
588         }
589     }
590 }
591
592
593 /*******************************************************************************
594  *
595  * FUNCTION:    AcpiTbSetupFadtRegisters
596  *
597  * PARAMETERS:  None, uses AcpiGbl_FADT.
598  *
599  * RETURN:      None
600  *
601  * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally,
602  *              force FADT register definitions to their default lengths.
603  *
604  ******************************************************************************/
605
606 static void
607 AcpiTbSetupFadtRegisters (
608     void)
609 {
610     ACPI_GENERIC_ADDRESS    *Target64;
611     ACPI_GENERIC_ADDRESS    *Source64;
612     UINT8                   Pm1RegisterByteWidth;
613     UINT32                  i;
614
615
616     /*
617      * Optionally check all register lengths against the default values and
618      * update them if they are incorrect.
619      */
620     if (AcpiGbl_UseDefaultRegisterWidths)
621     {
622         for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
623         {
624             Target64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
625                 FadtInfoTable[i].Address64);
626
627             /*
628              * If a valid register (Address != 0) and the (DefaultLength > 0)
629              * (Not a GPE register), then check the width against the default.
630              */
631             if ((Target64->Address) &&
632                 (FadtInfoTable[i].DefaultLength > 0) &&
633                 (FadtInfoTable[i].DefaultLength != Target64->BitWidth))
634             {
635                 ACPI_WARNING ((AE_INFO,
636                     "Invalid length for %s: %u, using default %u",
637                     FadtInfoTable[i].Name, Target64->BitWidth,
638                     FadtInfoTable[i].DefaultLength));
639
640                 /* Incorrect size, set width to the default */
641
642                 Target64->BitWidth = FadtInfoTable[i].DefaultLength;
643             }
644         }
645     }
646
647     /*
648      * Get the length of the individual PM1 registers (enable and status).
649      * Each register is defined to be (event block length / 2). Extra divide
650      * by 8 converts bits to bytes.
651      */
652     Pm1RegisterByteWidth = (UINT8)
653         ACPI_DIV_16 (AcpiGbl_FADT.XPm1aEventBlock.BitWidth);
654
655     /*
656      * Calculate separate GAS structs for the PM1x (A/B) Status and Enable
657      * registers. These addresses do not appear (directly) in the FADT, so it
658      * is useful to pre-calculate them from the PM1 Event Block definitions.
659      *
660      * The PM event blocks are split into two register blocks, first is the
661      * PM Status Register block, followed immediately by the PM Enable
662      * Register block. Each is of length (Pm1EventLength/2)
663      *
664      * Note: The PM1A event block is required by the ACPI specification.
665      * However, the PM1B event block is optional and is rarely, if ever,
666      * used.
667      */
668
669     for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++)
670     {
671         Source64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
672             FadtPmInfoTable[i].Source);
673
674         if (Source64->Address)
675         {
676             AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target,
677                 Source64->SpaceId, Pm1RegisterByteWidth,
678                 Source64->Address +
679                     (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth));
680         }
681     }
682 }
683