Subversion Repositories Kolibri OS

Rev

Rev 1498 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1498 Rev 2216
1
/******************************************************************************
1
/******************************************************************************
2
 *
2
 *
3
 * Module Name: tbfadt   - FADT table utilities
3
 * Module Name: tbfadt   - FADT table utilities
4
 *
4
 *
5
 *****************************************************************************/
5
 *****************************************************************************/
6
 
6
 
7
/******************************************************************************
7
/******************************************************************************
8
 *
8
 *
9
 * 1. Copyright Notice
9
 * 1. Copyright Notice
10
 *
10
 *
11
 * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
11
 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
12
 * All rights reserved.
12
 * All rights reserved.
13
 *
13
 *
14
 * 2. License
14
 * 2. License
15
 *
15
 *
16
 * 2.1. This is your license from Intel Corp. under its intellectual property
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
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
18
 * you this software, covering your right to use that party's intellectual
19
 * property rights.
19
 * property rights.
20
 *
20
 *
21
 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
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
22
 * copy of the source code appearing in this file ("Covered Code") an
23
 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
23
 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24
 * base code distributed originally by Intel ("Original Intel Code") to copy,
24
 * base code distributed originally by Intel ("Original Intel Code") to copy,
25
 * make derivatives, distribute, use and display any portion of the Covered
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
26
 * Code in any form, with the right to sublicense such rights; and
27
 *
27
 *
28
 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
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
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,
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
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
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
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
34
 * to or modifications of the Original Intel Code.  No other license or right
35
 * is granted directly or by implication, estoppel or otherwise;
35
 * is granted directly or by implication, estoppel or otherwise;
36
 *
36
 *
37
 * The above copyright and patent license is granted only if the following
37
 * The above copyright and patent license is granted only if the following
38
 * conditions are met:
38
 * conditions are met:
39
 *
39
 *
40
 * 3. Conditions
40
 * 3. Conditions
41
 *
41
 *
42
 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
42
 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43
 * Redistribution of source code of any substantial portion of the Covered
43
 * Redistribution of source code of any substantial portion of the Covered
44
 * Code or modification with rights to further distribute source must include
44
 * Code or modification with rights to further distribute source must include
45
 * the above Copyright Notice, the above License, this list of Conditions,
45
 * the above Copyright Notice, the above License, this list of Conditions,
46
 * and the following Disclaimer and Export Compliance provision.  In addition,
46
 * and the following Disclaimer and Export Compliance provision.  In addition,
47
 * Licensee must cause all Covered Code to which Licensee contributes to
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
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
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
50
 * documentation of any changes made by any predecessor Licensee.  Licensee
51
 * must include a prominent statement that the modification is derived,
51
 * must include a prominent statement that the modification is derived,
52
 * directly or indirectly, from Original Intel Code.
52
 * directly or indirectly, from Original Intel Code.
53
 *
53
 *
54
 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
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
55
 * Redistribution of source code of any substantial portion of the Covered
56
 * Code or modification without rights to further distribute source must
56
 * Code or modification without rights to further distribute source must
57
 * include the following Disclaimer and Export Compliance provision in the
57
 * include the following Disclaimer and Export Compliance provision in the
58
 * documentation and/or other materials provided with distribution.  In
58
 * documentation and/or other materials provided with distribution.  In
59
 * addition, Licensee may not authorize further sublicense of source of any
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
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
61
 * license from Licensee to its licensee is limited to the intellectual
62
 * property embodied in the software Licensee provides to its licensee, and
62
 * property embodied in the software Licensee provides to its licensee, and
63
 * not to intellectual property embodied in modifications its licensee may
63
 * not to intellectual property embodied in modifications its licensee may
64
 * make.
64
 * make.
65
 *
65
 *
66
 * 3.3. Redistribution of Executable. Redistribution in executable form of any
66
 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67
 * substantial portion of the Covered Code or modification must reproduce the
67
 * substantial portion of the Covered Code or modification must reproduce the
68
 * above Copyright Notice, and the following Disclaimer and Export Compliance
68
 * above Copyright Notice, and the following Disclaimer and Export Compliance
69
 * provision in the documentation and/or other materials provided with the
69
 * provision in the documentation and/or other materials provided with the
70
 * distribution.
70
 * distribution.
71
 *
71
 *
72
 * 3.4. Intel retains all right, title, and interest in and to the Original
72
 * 3.4. Intel retains all right, title, and interest in and to the Original
73
 * Intel Code.
73
 * Intel Code.
74
 *
74
 *
75
 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
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
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
77
 * other dealings in products derived from or relating to the Covered Code
78
 * without prior written authorization from Intel.
78
 * without prior written authorization from Intel.
79
 *
79
 *
80
 * 4. Disclaimer and Export Compliance
80
 * 4. Disclaimer and Export Compliance
81
 *
81
 *
82
 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
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
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,
84
 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
85
 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
85
 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
86
 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
86
 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
87
 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
87
 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88
 * PARTICULAR PURPOSE.
88
 * PARTICULAR PURPOSE.
89
 *
89
 *
90
 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
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
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,
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
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
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
95
 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
96
 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
96
 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97
 * LIMITED REMEDY.
97
 * LIMITED REMEDY.
98
 *
98
 *
99
 * 4.3. Licensee shall not export, either directly or indirectly, any of this
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
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
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
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
103
 * event Licensee exports any such software from the United States or
104
 * re-exports any such software from a foreign destination, Licensee shall
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
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
106
 * compliance with all laws, regulations, orders, or other restrictions of the
107
 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
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,
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
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,
110
 * United States government or any agency thereof requires an export license,
111
 * other governmental approval, or letter of assurance, without first obtaining
111
 * other governmental approval, or letter of assurance, without first obtaining
112
 * such license, approval or letter.
112
 * such license, approval or letter.
113
 *
113
 *
114
 *****************************************************************************/
114
 *****************************************************************************/
115
 
115
 
116
#define __TBFADT_C__
116
#define __TBFADT_C__
117
 
117
 
118
#include "acpi.h"
118
#include "acpi.h"
119
#include "accommon.h"
119
#include "accommon.h"
120
#include "actables.h"
120
#include "actables.h"
121
 
121
 
122
#define _COMPONENT          ACPI_TABLES
122
#define _COMPONENT          ACPI_TABLES
123
        ACPI_MODULE_NAME    ("tbfadt")
123
        ACPI_MODULE_NAME    ("tbfadt")
124
 
124
 
125
/* Local prototypes */
125
/* Local prototypes */
126
 
126
 
127
static inline void
127
static ACPI_INLINE void
128
AcpiTbInitGenericAddress (
128
AcpiTbInitGenericAddress (
129
    ACPI_GENERIC_ADDRESS    *GenericAddress,
129
    ACPI_GENERIC_ADDRESS    *GenericAddress,
130
    UINT8                   SpaceId,
130
    UINT8                   SpaceId,
131
    UINT8                   ByteWidth,
131
    UINT8                   ByteWidth,
132
    UINT64                  Address);
132
    UINT64                  Address);
133
 
133
 
134
static void
134
static void
135
AcpiTbConvertFadt (
135
AcpiTbConvertFadt (
136
    void);
136
    void);
137
 
137
 
138
static void
138
static void
139
AcpiTbValidateFadt (
139
AcpiTbValidateFadt (
140
    void);
140
    void);
141
 
141
 
142
static void
142
static void
143
AcpiTbSetupFadtRegisters (
143
AcpiTbSetupFadtRegisters (
144
    void);
144
    void);
145
 
145
 
146
 
146
 
147
/* Table for conversion of FADT to common internal format and FADT validation */
147
/* Table for conversion of FADT to common internal format and FADT validation */
148
 
148
 
149
typedef struct acpi_fadt_info
149
typedef struct acpi_fadt_info
150
{
150
{
151
    char                    *Name;
151
    char                    *Name;
152
    UINT8                   Address64;
152
    UINT8                   Address64;
153
    UINT8                   Address32;
153
    UINT8                   Address32;
154
    UINT8                   Length;
154
    UINT8                   Length;
155
    UINT8                   DefaultLength;
155
    UINT8                   DefaultLength;
156
    UINT8                   Type;
156
    UINT8                   Type;
157
 
157
 
158
} ACPI_FADT_INFO;
158
} ACPI_FADT_INFO;
159
 
159
 
160
#define ACPI_FADT_REQUIRED          1
160
#define ACPI_FADT_REQUIRED          1
161
#define ACPI_FADT_SEPARATE_LENGTH   2
161
#define ACPI_FADT_SEPARATE_LENGTH   2
162
 
162
 
163
static ACPI_FADT_INFO     FadtInfoTable[] =
163
static ACPI_FADT_INFO     FadtInfoTable[] =
164
{
164
{
165
    {"Pm1aEventBlock",
165
    {"Pm1aEventBlock",
166
        ACPI_FADT_OFFSET (XPm1aEventBlock),
166
        ACPI_FADT_OFFSET (XPm1aEventBlock),
167
        ACPI_FADT_OFFSET (Pm1aEventBlock),
167
        ACPI_FADT_OFFSET (Pm1aEventBlock),
168
        ACPI_FADT_OFFSET (Pm1EventLength),
168
        ACPI_FADT_OFFSET (Pm1EventLength),
169
        ACPI_PM1_REGISTER_WIDTH * 2,        /* Enable + Status register */
169
        ACPI_PM1_REGISTER_WIDTH * 2,        /* Enable + Status register */
170
        ACPI_FADT_REQUIRED},
170
        ACPI_FADT_REQUIRED},
171
 
171
 
172
    {"Pm1bEventBlock",
172
    {"Pm1bEventBlock",
173
        ACPI_FADT_OFFSET (XPm1bEventBlock),
173
        ACPI_FADT_OFFSET (XPm1bEventBlock),
174
        ACPI_FADT_OFFSET (Pm1bEventBlock),
174
        ACPI_FADT_OFFSET (Pm1bEventBlock),
175
        ACPI_FADT_OFFSET (Pm1EventLength),
175
        ACPI_FADT_OFFSET (Pm1EventLength),
176
        ACPI_PM1_REGISTER_WIDTH * 2,        /* Enable + Status register */
176
        ACPI_PM1_REGISTER_WIDTH * 2,        /* Enable + Status register */
177
        0},
177
        0},
178
 
178
 
179
    {"Pm1aControlBlock",
179
    {"Pm1aControlBlock",
180
        ACPI_FADT_OFFSET (XPm1aControlBlock),
180
        ACPI_FADT_OFFSET (XPm1aControlBlock),
181
        ACPI_FADT_OFFSET (Pm1aControlBlock),
181
        ACPI_FADT_OFFSET (Pm1aControlBlock),
182
        ACPI_FADT_OFFSET (Pm1ControlLength),
182
        ACPI_FADT_OFFSET (Pm1ControlLength),
183
        ACPI_PM1_REGISTER_WIDTH,
183
        ACPI_PM1_REGISTER_WIDTH,
184
        ACPI_FADT_REQUIRED},
184
        ACPI_FADT_REQUIRED},
185
 
185
 
186
    {"Pm1bControlBlock",
186
    {"Pm1bControlBlock",
187
        ACPI_FADT_OFFSET (XPm1bControlBlock),
187
        ACPI_FADT_OFFSET (XPm1bControlBlock),
188
        ACPI_FADT_OFFSET (Pm1bControlBlock),
188
        ACPI_FADT_OFFSET (Pm1bControlBlock),
189
        ACPI_FADT_OFFSET (Pm1ControlLength),
189
        ACPI_FADT_OFFSET (Pm1ControlLength),
190
        ACPI_PM1_REGISTER_WIDTH,
190
        ACPI_PM1_REGISTER_WIDTH,
191
        0},
191
        0},
192
 
192
 
193
    {"Pm2ControlBlock",
193
    {"Pm2ControlBlock",
194
        ACPI_FADT_OFFSET (XPm2ControlBlock),
194
        ACPI_FADT_OFFSET (XPm2ControlBlock),
195
        ACPI_FADT_OFFSET (Pm2ControlBlock),
195
        ACPI_FADT_OFFSET (Pm2ControlBlock),
196
        ACPI_FADT_OFFSET (Pm2ControlLength),
196
        ACPI_FADT_OFFSET (Pm2ControlLength),
197
        ACPI_PM2_REGISTER_WIDTH,
197
        ACPI_PM2_REGISTER_WIDTH,
198
        ACPI_FADT_SEPARATE_LENGTH},
198
        ACPI_FADT_SEPARATE_LENGTH},
199
 
199
 
200
    {"PmTimerBlock",
200
    {"PmTimerBlock",
201
        ACPI_FADT_OFFSET (XPmTimerBlock),
201
        ACPI_FADT_OFFSET (XPmTimerBlock),
202
        ACPI_FADT_OFFSET (PmTimerBlock),
202
        ACPI_FADT_OFFSET (PmTimerBlock),
203
        ACPI_FADT_OFFSET (PmTimerLength),
203
        ACPI_FADT_OFFSET (PmTimerLength),
204
        ACPI_PM_TIMER_WIDTH,
204
        ACPI_PM_TIMER_WIDTH,
205
        ACPI_FADT_REQUIRED},
205
        ACPI_FADT_REQUIRED},
206
 
206
 
207
    {"Gpe0Block",
207
    {"Gpe0Block",
208
        ACPI_FADT_OFFSET (XGpe0Block),
208
        ACPI_FADT_OFFSET (XGpe0Block),
209
        ACPI_FADT_OFFSET (Gpe0Block),
209
        ACPI_FADT_OFFSET (Gpe0Block),
210
        ACPI_FADT_OFFSET (Gpe0BlockLength),
210
        ACPI_FADT_OFFSET (Gpe0BlockLength),
211
        0,
211
        0,
212
        ACPI_FADT_SEPARATE_LENGTH},
212
        ACPI_FADT_SEPARATE_LENGTH},
213
 
213
 
214
    {"Gpe1Block",
214
    {"Gpe1Block",
215
        ACPI_FADT_OFFSET (XGpe1Block),
215
        ACPI_FADT_OFFSET (XGpe1Block),
216
        ACPI_FADT_OFFSET (Gpe1Block),
216
        ACPI_FADT_OFFSET (Gpe1Block),
217
        ACPI_FADT_OFFSET (Gpe1BlockLength),
217
        ACPI_FADT_OFFSET (Gpe1BlockLength),
218
        0,
218
        0,
219
        ACPI_FADT_SEPARATE_LENGTH}
219
        ACPI_FADT_SEPARATE_LENGTH}
220
};
220
};
221
 
221
 
222
#define ACPI_FADT_INFO_ENTRIES \
222
#define ACPI_FADT_INFO_ENTRIES \
223
            (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO))
223
            (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO))
224
 
224
 
225
 
225
 
226
/* Table used to split Event Blocks into separate status/enable registers */
226
/* Table used to split Event Blocks into separate status/enable registers */
227
 
227
 
228
typedef struct acpi_fadt_pm_info
228
typedef struct acpi_fadt_pm_info
229
{
229
{
230
    ACPI_GENERIC_ADDRESS    *Target;
230
    ACPI_GENERIC_ADDRESS    *Target;
231
    UINT8                   Source;
231
    UINT8                   Source;
232
    UINT8                   RegisterNum;
232
    UINT8                   RegisterNum;
233
 
233
 
234
} ACPI_FADT_PM_INFO;
234
} ACPI_FADT_PM_INFO;
235
 
235
 
236
static ACPI_FADT_PM_INFO    FadtPmInfoTable[] =
236
static ACPI_FADT_PM_INFO    FadtPmInfoTable[] =
237
{
237
{
238
    {&AcpiGbl_XPm1aStatus,
238
    {&AcpiGbl_XPm1aStatus,
239
        ACPI_FADT_OFFSET (XPm1aEventBlock),
239
        ACPI_FADT_OFFSET (XPm1aEventBlock),
240
        0},
240
        0},
241
 
241
 
242
    {&AcpiGbl_XPm1aEnable,
242
    {&AcpiGbl_XPm1aEnable,
243
        ACPI_FADT_OFFSET (XPm1aEventBlock),
243
        ACPI_FADT_OFFSET (XPm1aEventBlock),
244
        1},
244
        1},
245
 
245
 
246
    {&AcpiGbl_XPm1bStatus,
246
    {&AcpiGbl_XPm1bStatus,
247
        ACPI_FADT_OFFSET (XPm1bEventBlock),
247
        ACPI_FADT_OFFSET (XPm1bEventBlock),
248
        0},
248
        0},
249
 
249
 
250
    {&AcpiGbl_XPm1bEnable,
250
    {&AcpiGbl_XPm1bEnable,
251
        ACPI_FADT_OFFSET (XPm1bEventBlock),
251
        ACPI_FADT_OFFSET (XPm1bEventBlock),
252
        1}
252
        1}
253
};
253
};
254
 
254
 
255
#define ACPI_FADT_PM_INFO_ENTRIES \
255
#define ACPI_FADT_PM_INFO_ENTRIES \
256
            (sizeof (FadtPmInfoTable) / sizeof (ACPI_FADT_PM_INFO))
256
            (sizeof (FadtPmInfoTable) / sizeof (ACPI_FADT_PM_INFO))
257
 
257
 
258
 
258
 
259
/*******************************************************************************
259
/*******************************************************************************
260
 *
260
 *
261
 * FUNCTION:    AcpiTbInitGenericAddress
261
 * FUNCTION:    AcpiTbInitGenericAddress
262
 *
262
 *
263
 * PARAMETERS:  GenericAddress      - GAS struct to be initialized
263
 * PARAMETERS:  GenericAddress      - GAS struct to be initialized
264
 *              SpaceId             - ACPI Space ID for this register
264
 *              SpaceId             - ACPI Space ID for this register
265
 *              ByteWidth           - Width of this register, in bytes
265
 *              ByteWidth           - Width of this register, in bytes
266
 *              Address             - Address of the register
266
 *              Address             - Address of the register
267
 *
267
 *
268
 * RETURN:      None
268
 * RETURN:      None
269
 *
269
 *
270
 * DESCRIPTION: Initialize a Generic Address Structure (GAS)
270
 * DESCRIPTION: Initialize a Generic Address Structure (GAS)
271
 *              See the ACPI specification for a full description and
271
 *              See the ACPI specification for a full description and
272
 *              definition of this structure.
272
 *              definition of this structure.
273
 *
273
 *
274
 ******************************************************************************/
274
 ******************************************************************************/
275
 
275
 
276
static inline void
276
static ACPI_INLINE void
277
AcpiTbInitGenericAddress (
277
AcpiTbInitGenericAddress (
278
    ACPI_GENERIC_ADDRESS    *GenericAddress,
278
    ACPI_GENERIC_ADDRESS    *GenericAddress,
279
    UINT8                   SpaceId,
279
    UINT8                   SpaceId,
280
    UINT8                   ByteWidth,
280
    UINT8                   ByteWidth,
281
    UINT64                  Address)
281
    UINT64                  Address)
282
{
282
{
283
 
283
 
284
    /*
284
    /*
285
     * The 64-bit Address field is non-aligned in the byte packed
285
     * The 64-bit Address field is non-aligned in the byte packed
286
     * GAS struct.
286
     * GAS struct.
287
     */
287
     */
288
    ACPI_MOVE_64_TO_64 (&GenericAddress->Address, &Address);
288
    ACPI_MOVE_64_TO_64 (&GenericAddress->Address, &Address);
289
 
289
 
290
    /* All other fields are byte-wide */
290
    /* All other fields are byte-wide */
291
 
291
 
292
    GenericAddress->SpaceId = SpaceId;
292
    GenericAddress->SpaceId = SpaceId;
293
    GenericAddress->BitWidth = (UINT8) ACPI_MUL_8 (ByteWidth);
293
    GenericAddress->BitWidth = (UINT8) ACPI_MUL_8 (ByteWidth);
294
    GenericAddress->BitOffset = 0;
294
    GenericAddress->BitOffset = 0;
295
    GenericAddress->AccessWidth = 0; /* Access width ANY */
295
    GenericAddress->AccessWidth = 0; /* Access width ANY */
296
}
296
}
297
 
297
 
298
 
298
 
299
/*******************************************************************************
299
/*******************************************************************************
300
 *
300
 *
301
 * FUNCTION:    AcpiTbParseFadt
301
 * FUNCTION:    AcpiTbParseFadt
302
 *
302
 *
303
 * PARAMETERS:  TableIndex          - Index for the FADT
303
 * PARAMETERS:  TableIndex          - Index for the FADT
304
 *
304
 *
305
 * RETURN:      None
305
 * RETURN:      None
306
 *
306
 *
307
 * DESCRIPTION: Initialize the FADT, DSDT and FACS tables
307
 * DESCRIPTION: Initialize the FADT, DSDT and FACS tables
308
 *              (FADT contains the addresses of the DSDT and FACS)
308
 *              (FADT contains the addresses of the DSDT and FACS)
309
 *
309
 *
310
 ******************************************************************************/
310
 ******************************************************************************/
311
 
311
 
312
void
312
void
313
AcpiTbParseFadt (
313
AcpiTbParseFadt (
314
    UINT32                  TableIndex)
314
    UINT32                  TableIndex)
315
{
315
{
316
    UINT32                  Length;
316
    UINT32                  Length;
317
    ACPI_TABLE_HEADER       *Table;
317
    ACPI_TABLE_HEADER       *Table;
318
 
318
 
319
 
319
 
320
    /*
320
    /*
321
     * The FADT has multiple versions with different lengths,
321
     * The FADT has multiple versions with different lengths,
322
     * and it contains pointers to both the DSDT and FACS tables.
322
     * and it contains pointers to both the DSDT and FACS tables.
323
     *
323
     *
324
     * Get a local copy of the FADT and convert it to a common format
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.
325
     * Map entire FADT, assumed to be smaller than one page.
326
     */
326
     */
327
    Length = AcpiGbl_RootTableList.Tables[TableIndex].Length;
327
    Length = AcpiGbl_RootTableList.Tables[TableIndex].Length;
328
 
328
 
329
    Table = AcpiOsMapMemory (
329
    Table = AcpiOsMapMemory (
330
                AcpiGbl_RootTableList.Tables[TableIndex].Address, Length);
330
                AcpiGbl_RootTableList.Tables[TableIndex].Address, Length);
331
    if (!Table)
331
    if (!Table)
332
    {
332
    {
333
        return;
333
        return;
334
    }
334
    }
335
 
335
 
336
    /*
336
    /*
337
     * Validate the FADT checksum before we copy the table. Ignore
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.
338
     * checksum error as we want to try to get the DSDT and FACS.
339
     */
339
     */
340
    (void) AcpiTbVerifyChecksum (Table, Length);
340
    (void) AcpiTbVerifyChecksum (Table, Length);
341
 
341
 
342
    /* Create a local copy of the FADT in common ACPI 2.0+ format */
342
    /* Create a local copy of the FADT in common ACPI 2.0+ format */
343
 
343
 
344
    AcpiTbCreateLocalFadt (Table, Length);
344
    AcpiTbCreateLocalFadt (Table, Length);
345
 
345
 
346
    /* All done with the real FADT, unmap it */
346
    /* All done with the real FADT, unmap it */
347
 
347
 
348
    AcpiOsUnmapMemory (Table, Length);
348
    AcpiOsUnmapMemory (Table, Length);
349
 
349
 
350
    /* Obtain the DSDT and FACS tables via their addresses within the FADT */
350
    /* Obtain the DSDT and FACS tables via their addresses within the FADT */
351
 
351
 
352
    AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt,
352
    AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt,
353
        ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
353
        ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
354
 
354
 
355
    AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs,
355
    AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs,
356
        ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS);
356
        ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS);
357
}
357
}
358
 
358
 
359
 
359
 
360
/*******************************************************************************
360
/*******************************************************************************
361
 *
361
 *
362
 * FUNCTION:    AcpiTbCreateLocalFadt
362
 * FUNCTION:    AcpiTbCreateLocalFadt
363
 *
363
 *
364
 * PARAMETERS:  Table               - Pointer to BIOS FADT
364
 * PARAMETERS:  Table               - Pointer to BIOS FADT
365
 *              Length              - Length of the table
365
 *              Length              - Length of the table
366
 *
366
 *
367
 * RETURN:      None
367
 * RETURN:      None
368
 *
368
 *
369
 * DESCRIPTION: Get a local copy of the FADT and convert it to a common format.
369
 * DESCRIPTION: Get a local copy of the FADT and convert it to a common format.
370
 *              Performs validation on some important FADT fields.
370
 *              Performs validation on some important FADT fields.
371
 *
371
 *
372
 * NOTE:        We create a local copy of the FADT regardless of the version.
372
 * NOTE:        We create a local copy of the FADT regardless of the version.
373
 *
373
 *
374
 ******************************************************************************/
374
 ******************************************************************************/
375
 
375
 
376
void
376
void
377
AcpiTbCreateLocalFadt (
377
AcpiTbCreateLocalFadt (
378
    ACPI_TABLE_HEADER       *Table,
378
    ACPI_TABLE_HEADER       *Table,
379
    UINT32                  Length)
379
    UINT32                  Length)
380
{
380
{
381
 
381
 
382
    /*
382
    /*
383
     * Check if the FADT is larger than the largest table that we expect
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
384
     * (the ACPI 2.0/3.0 version). If so, truncate the table, and issue
385
     * a warning.
385
     * a warning.
386
     */
386
     */
387
    if (Length > sizeof (ACPI_TABLE_FADT))
387
    if (Length > sizeof (ACPI_TABLE_FADT))
388
    {
388
    {
389
        ACPI_WARNING ((AE_INFO,
389
        ACPI_WARNING ((AE_INFO,
390
            "FADT (revision %u) is longer than ACPI 2.0 version, "
390
            "FADT (revision %u) is longer than ACPI 2.0 version, "
391
            "truncating length %u to %u",
391
            "truncating length %u to %u",
392
            Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT)));
392
            Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT)));
393
    }
393
    }
394
 
394
 
395
    /* Clear the entire local FADT */
395
    /* Clear the entire local FADT */
396
 
396
 
397
    ACPI_MEMSET (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT));
397
    ACPI_MEMSET (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT));
398
 
398
 
399
    /* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */
399
    /* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */
400
 
400
 
401
    ACPI_MEMCPY (&AcpiGbl_FADT, Table,
401
    ACPI_MEMCPY (&AcpiGbl_FADT, Table,
402
        ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT)));
402
        ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT)));
403
 
403
 
404
    /* Convert the local copy of the FADT to the common internal format */
404
    /* Convert the local copy of the FADT to the common internal format */
405
 
405
 
406
    AcpiTbConvertFadt ();
406
    AcpiTbConvertFadt ();
407
 
407
 
408
    /* Validate FADT values now, before we make any changes */
408
    /* Validate FADT values now, before we make any changes */
409
 
409
 
410
    AcpiTbValidateFadt ();
410
    AcpiTbValidateFadt ();
411
 
411
 
412
    /* Initialize the global ACPI register structures */
412
    /* Initialize the global ACPI register structures */
413
 
413
 
414
    AcpiTbSetupFadtRegisters ();
414
    AcpiTbSetupFadtRegisters ();
415
}
415
}
416
 
416
 
417
 
417
 
418
/*******************************************************************************
418
/*******************************************************************************
419
 *
419
 *
420
 * FUNCTION:    AcpiTbConvertFadt
420
 * FUNCTION:    AcpiTbConvertFadt
421
 *
421
 *
422
 * PARAMETERS:  None, uses AcpiGbl_FADT
422
 * PARAMETERS:  None, uses AcpiGbl_FADT
423
 *
423
 *
424
 * RETURN:      None
424
 * RETURN:      None
425
 *
425
 *
426
 * DESCRIPTION: Converts all versions of the FADT to a common internal format.
426
 * DESCRIPTION: Converts all versions of the FADT to a common internal format.
427
 *              Expand 32-bit addresses to 64-bit as necessary.
427
 *              Expand 32-bit addresses to 64-bit as necessary.
428
 *
428
 *
429
 * NOTE:        AcpiGbl_FADT must be of size (ACPI_TABLE_FADT),
429
 * NOTE:        AcpiGbl_FADT must be of size (ACPI_TABLE_FADT),
430
 *              and must contain a copy of the actual FADT.
430
 *              and must contain a copy of the actual FADT.
431
 *
431
 *
432
 * Notes on 64-bit register addresses:
432
 * Notes on 64-bit register addresses:
433
 *
433
 *
434
 * After this FADT conversion, later ACPICA code will only use the 64-bit "X"
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.
435
 * fields of the FADT for all ACPI register addresses.
436
 *
436
 *
437
 * The 64-bit "X" fields are optional extensions to the original 32-bit FADT
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
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
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.
440
 * 32-bit V1.0 fields if the corresponding X field is zero.
441
 *
441
 *
442
 * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the
442
 * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the
443
 * corresponding "X" fields in the internal FADT.
443
 * corresponding "X" fields in the internal FADT.
444
 *
444
 *
445
 * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded
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
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,
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.
448
 * regardless of whether the host OS is 32-bit or 64-bit.
449
 *
449
 *
450
 ******************************************************************************/
450
 ******************************************************************************/
451
 
451
 
452
static void
452
static void
453
AcpiTbConvertFadt (
453
AcpiTbConvertFadt (
454
    void)
454
    void)
455
{
455
{
456
    ACPI_GENERIC_ADDRESS    *Address64;
456
    ACPI_GENERIC_ADDRESS    *Address64;
457
    UINT32                  Address32;
457
    UINT32                  Address32;
458
    UINT32                  i;
458
    UINT32                  i;
459
 
459
 
460
 
460
 
461
    /* Update the local FADT table header length */
461
    /* Update the local FADT table header length */
462
 
462
 
463
    AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT);
463
    AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT);
464
 
464
 
465
    /*
465
    /*
466
     * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
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.
467
     * Later code will always use the X 64-bit field.
468
     */
468
     */
469
    if (!AcpiGbl_FADT.XFacs)
469
    if (!AcpiGbl_FADT.XFacs)
470
    {
470
    {
471
        AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs;
471
        AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs;
472
    }
472
    }
473
    if (!AcpiGbl_FADT.XDsdt)
473
    if (!AcpiGbl_FADT.XDsdt)
474
    {
474
    {
475
        AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt;
475
        AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt;
476
    }
476
    }
477
 
477
 
478
    /*
478
    /*
479
     * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
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
480
     * should be zero are indeed zero. This will workaround BIOSs that
481
     * inadvertently place values in these fields.
481
     * inadvertently place values in these fields.
482
     *
482
     *
483
     * The ACPI 1.0 reserved fields that will be zeroed are the bytes located
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.
484
     * at offset 45, 55, 95, and the word located at offset 109, 110.
-
 
485
     *
-
 
486
     * Note: The FADT revision value is unreliable. Only the length can be
-
 
487
     * trusted.
485
     */
488
     */
486
    if (AcpiGbl_FADT.Header.Revision < 3)
489
    if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE)
487
    {
490
    {
488
        AcpiGbl_FADT.PreferredProfile = 0;
491
        AcpiGbl_FADT.PreferredProfile = 0;
489
        AcpiGbl_FADT.PstateControl = 0;
492
        AcpiGbl_FADT.PstateControl = 0;
490
        AcpiGbl_FADT.CstControl = 0;
493
        AcpiGbl_FADT.CstControl = 0;
491
        AcpiGbl_FADT.BootFlags = 0;
494
        AcpiGbl_FADT.BootFlags = 0;
492
    }
495
    }
493
 
496
 
494
    /*
497
    /*
495
     * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
498
     * 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
499
     * generic address structures as necessary. Later code will always use
497
     * the 64-bit address structures.
500
     * the 64-bit address structures.
498
     *
501
     *
499
     * March 2009:
502
     * March 2009:
500
     * We now always use the 32-bit address if it is valid (non-null). This
503
     * 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
504
     * 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
505
     * the 64-bit address supersedes the 32-bit version, but we do this for
503
     * compatibility with other ACPI implementations. Most notably, in the
506
     * 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
507
     * 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
508
     * version. This is the only address that is guaranteed to have been
506
     * tested by the BIOS manufacturer.
509
     * tested by the BIOS manufacturer.
507
     */
510
     */
508
    for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
511
    for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
509
    {
512
    {
510
        Address32 = *ACPI_ADD_PTR (UINT32,
513
        Address32 = *ACPI_ADD_PTR (UINT32,
511
            &AcpiGbl_FADT, FadtInfoTable[i].Address32);
514
            &AcpiGbl_FADT, FadtInfoTable[i].Address32);
512
 
515
 
513
        Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS,
516
        Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS,
514
            &AcpiGbl_FADT, FadtInfoTable[i].Address64);
517
            &AcpiGbl_FADT, FadtInfoTable[i].Address64);
515
 
518
 
516
        /*
519
        /*
517
         * If both 32- and 64-bit addresses are valid (non-zero),
520
         * If both 32- and 64-bit addresses are valid (non-zero),
518
         * they must match.
521
         * they must match.
519
         */
522
         */
520
        if (Address64->Address && Address32 &&
523
        if (Address64->Address && Address32 &&
521
           (Address64->Address != (UINT64) Address32))
524
           (Address64->Address != (UINT64) Address32))
522
        {
525
        {
523
            ACPI_ERROR ((AE_INFO,
526
            ACPI_ERROR ((AE_INFO,
524
                "32/64X address mismatch in %s: 0x%8.8X/0x%8.8X%8.8X, using 32",
527
                "32/64X address mismatch in %s: 0x%8.8X/0x%8.8X%8.8X, using 32",
525
                FadtInfoTable[i].Name, Address32,
528
                FadtInfoTable[i].Name, Address32,
526
                ACPI_FORMAT_UINT64 (Address64->Address)));
529
                ACPI_FORMAT_UINT64 (Address64->Address)));
527
        }
530
        }
528
 
531
 
529
        /* Always use 32-bit address if it is valid (non-null) */
532
        /* Always use 32-bit address if it is valid (non-null) */
530
 
533
 
531
        if (Address32)
534
        if (Address32)
532
        {
535
        {
533
            /*
536
            /*
534
             * Copy the 32-bit address to the 64-bit GAS structure. The
537
             * 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
538
             * Space ID is always I/O for 32-bit legacy address fields
536
             */
539
             */
537
            AcpiTbInitGenericAddress (Address64, ACPI_ADR_SPACE_SYSTEM_IO,
540
            AcpiTbInitGenericAddress (Address64, ACPI_ADR_SPACE_SYSTEM_IO,
538
                *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length),
541
                *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length),
539
                (UINT64) Address32);
542
                (UINT64) Address32);
540
        }
543
        }
541
    }
544
    }
542
}
545
}
543
 
546
 
544
 
547
 
545
/*******************************************************************************
548
/*******************************************************************************
546
 *
549
 *
547
 * FUNCTION:    AcpiTbValidateFadt
550
 * FUNCTION:    AcpiTbValidateFadt
548
 *
551
 *
549
 * PARAMETERS:  Table           - Pointer to the FADT to be validated
552
 * PARAMETERS:  Table           - Pointer to the FADT to be validated
550
 *
553
 *
551
 * RETURN:      None
554
 * RETURN:      None
552
 *
555
 *
553
 * DESCRIPTION: Validate various important fields within the FADT. If a problem
556
 * DESCRIPTION: Validate various important fields within the FADT. If a problem
554
 *              is found, issue a message, but no status is returned.
557
 *              is found, issue a message, but no status is returned.
555
 *              Used by both the table manager and the disassembler.
558
 *              Used by both the table manager and the disassembler.
556
 *
559
 *
557
 * Possible additional checks:
560
 * Possible additional checks:
558
 * (AcpiGbl_FADT.Pm1EventLength >= 4)
561
 * (AcpiGbl_FADT.Pm1EventLength >= 4)
559
 * (AcpiGbl_FADT.Pm1ControlLength >= 2)
562
 * (AcpiGbl_FADT.Pm1ControlLength >= 2)
560
 * (AcpiGbl_FADT.PmTimerLength >= 4)
563
 * (AcpiGbl_FADT.PmTimerLength >= 4)
561
 * Gpe block lengths must be multiple of 2
564
 * Gpe block lengths must be multiple of 2
562
 *
565
 *
563
 ******************************************************************************/
566
 ******************************************************************************/
564
 
567
 
565
static void
568
static void
566
AcpiTbValidateFadt (
569
AcpiTbValidateFadt (
567
    void)
570
    void)
568
{
571
{
569
    char                    *Name;
572
    char                    *Name;
570
    ACPI_GENERIC_ADDRESS    *Address64;
573
    ACPI_GENERIC_ADDRESS    *Address64;
571
    UINT8                   Length;
574
    UINT8                   Length;
572
    UINT32                  i;
575
    UINT32                  i;
573
 
576
 
574
 
577
 
575
    /*
578
    /*
576
     * Check for FACS and DSDT address mismatches. An address mismatch between
579
     * 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
580
     * 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.
581
     * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables.
579
     */
582
     */
580
    if (AcpiGbl_FADT.Facs &&
583
    if (AcpiGbl_FADT.Facs &&
581
        (AcpiGbl_FADT.XFacs != (UINT64) AcpiGbl_FADT.Facs))
584
        (AcpiGbl_FADT.XFacs != (UINT64) AcpiGbl_FADT.Facs))
582
    {
585
    {
583
        ACPI_WARNING ((AE_INFO,
586
        ACPI_WARNING ((AE_INFO,
584
            "32/64X FACS address mismatch in FADT - "
587
            "32/64X FACS address mismatch in FADT - "
585
            "0x%8.8X/0x%8.8X%8.8X, using 32",
588
            "0x%8.8X/0x%8.8X%8.8X, using 32",
586
            AcpiGbl_FADT.Facs, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XFacs)));
589
            AcpiGbl_FADT.Facs, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XFacs)));
587
 
590
 
588
        AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs;
591
        AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs;
589
    }
592
    }
590
 
593
 
591
    if (AcpiGbl_FADT.Dsdt &&
594
    if (AcpiGbl_FADT.Dsdt &&
592
        (AcpiGbl_FADT.XDsdt != (UINT64) AcpiGbl_FADT.Dsdt))
595
        (AcpiGbl_FADT.XDsdt != (UINT64) AcpiGbl_FADT.Dsdt))
593
    {
596
    {
594
        ACPI_WARNING ((AE_INFO,
597
        ACPI_WARNING ((AE_INFO,
595
            "32/64X DSDT address mismatch in FADT - "
598
            "32/64X DSDT address mismatch in FADT - "
596
            "0x%8.8X/0x%8.8X%8.8X, using 32",
599
            "0x%8.8X/0x%8.8X%8.8X, using 32",
597
            AcpiGbl_FADT.Dsdt, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XDsdt)));
600
            AcpiGbl_FADT.Dsdt, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XDsdt)));
598
 
601
 
599
        AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt;
602
        AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt;
600
    }
603
    }
601
 
604
 
602
    /* Examine all of the 64-bit extended address fields (X fields) */
605
    /* Examine all of the 64-bit extended address fields (X fields) */
603
 
606
 
604
    for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
607
    for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
605
    {
608
    {
606
        /*
609
        /*
607
         * Generate pointer to the 64-bit address, get the register
610
         * Generate pointer to the 64-bit address, get the register
608
         * length (width) and the register name
611
         * length (width) and the register name
609
         */
612
         */
610
        Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS,
613
        Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS,
611
                        &AcpiGbl_FADT, FadtInfoTable[i].Address64);
614
                        &AcpiGbl_FADT, FadtInfoTable[i].Address64);
612
        Length = *ACPI_ADD_PTR (UINT8,
615
        Length = *ACPI_ADD_PTR (UINT8,
613
                        &AcpiGbl_FADT, FadtInfoTable[i].Length);
616
                        &AcpiGbl_FADT, FadtInfoTable[i].Length);
614
        Name = FadtInfoTable[i].Name;
617
        Name = FadtInfoTable[i].Name;
615
 
618
 
616
        /*
619
        /*
617
         * For each extended field, check for length mismatch between the
620
         * For each extended field, check for length mismatch between the
618
         * legacy length field and the corresponding 64-bit X length field.
621
         * legacy length field and the corresponding 64-bit X length field.
619
         */
622
         */
620
        if (Address64->Address &&
623
        if (Address64->Address &&
621
           (Address64->BitWidth != ACPI_MUL_8 (Length)))
624
           (Address64->BitWidth != ACPI_MUL_8 (Length)))
622
        {
625
        {
623
            ACPI_WARNING ((AE_INFO,
626
            ACPI_WARNING ((AE_INFO,
624
                "32/64X length mismatch in %s: %u/%u",
627
                "32/64X length mismatch in %s: %u/%u",
625
                Name, ACPI_MUL_8 (Length), Address64->BitWidth));
628
                Name, ACPI_MUL_8 (Length), Address64->BitWidth));
626
        }
629
        }
627
 
630
 
628
        if (FadtInfoTable[i].Type & ACPI_FADT_REQUIRED)
631
        if (FadtInfoTable[i].Type & ACPI_FADT_REQUIRED)
629
        {
632
        {
630
            /*
633
            /*
631
             * Field is required (PM1aEvent, PM1aControl, PmTimer).
634
             * Field is required (PM1aEvent, PM1aControl, PmTimer).
632
             * Both the address and length must be non-zero.
635
             * Both the address and length must be non-zero.
633
             */
636
             */
634
            if (!Address64->Address || !Length)
637
            if (!Address64->Address || !Length)
635
            {
638
            {
636
                ACPI_ERROR ((AE_INFO,
639
                ACPI_ERROR ((AE_INFO,
637
                    "Required field %s has zero address and/or length:"
640
                    "Required field %s has zero address and/or length:"
638
                    " 0x%8.8X%8.8X/0x%X",
641
                    " 0x%8.8X%8.8X/0x%X",
639
                    Name, ACPI_FORMAT_UINT64 (Address64->Address), Length));
642
                    Name, ACPI_FORMAT_UINT64 (Address64->Address), Length));
640
            }
643
            }
641
        }
644
        }
642
        else if (FadtInfoTable[i].Type & ACPI_FADT_SEPARATE_LENGTH)
645
        else if (FadtInfoTable[i].Type & ACPI_FADT_SEPARATE_LENGTH)
643
        {
646
        {
644
            /*
647
            /*
645
             * Field is optional (PM2Control, GPE0, GPE1) AND has its own
648
             * Field is optional (PM2Control, GPE0, GPE1) AND has its own
646
             * length field. If present, both the address and length must
649
             * length field. If present, both the address and length must
647
             * be valid.
650
             * be valid.
648
             */
651
             */
649
            if ((Address64->Address && !Length) ||
652
            if ((Address64->Address && !Length) ||
650
                (!Address64->Address && Length))
653
                (!Address64->Address && Length))
651
            {
654
            {
652
                ACPI_WARNING ((AE_INFO,
655
                ACPI_WARNING ((AE_INFO,
653
                    "Optional field %s has zero address or length: "
656
                    "Optional field %s has zero address or length: "
654
                    "0x%8.8X%8.8X/0x%X",
657
                    "0x%8.8X%8.8X/0x%X",
655
                    Name, ACPI_FORMAT_UINT64 (Address64->Address), Length));
658
                    Name, ACPI_FORMAT_UINT64 (Address64->Address), Length));
656
            }
659
            }
657
        }
660
        }
658
    }
661
    }
659
}
662
}
660
 
663
 
661
 
664
 
662
/*******************************************************************************
665
/*******************************************************************************
663
 *
666
 *
664
 * FUNCTION:    AcpiTbSetupFadtRegisters
667
 * FUNCTION:    AcpiTbSetupFadtRegisters
665
 *
668
 *
666
 * PARAMETERS:  None, uses AcpiGbl_FADT.
669
 * PARAMETERS:  None, uses AcpiGbl_FADT.
667
 *
670
 *
668
 * RETURN:      None
671
 * RETURN:      None
669
 *
672
 *
670
 * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally,
673
 * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally,
671
 *              force FADT register definitions to their default lengths.
674
 *              force FADT register definitions to their default lengths.
672
 *
675
 *
673
 ******************************************************************************/
676
 ******************************************************************************/
674
 
677
 
675
static void
678
static void
676
AcpiTbSetupFadtRegisters (
679
AcpiTbSetupFadtRegisters (
677
    void)
680
    void)
678
{
681
{
679
    ACPI_GENERIC_ADDRESS    *Target64;
682
    ACPI_GENERIC_ADDRESS    *Target64;
680
    ACPI_GENERIC_ADDRESS    *Source64;
683
    ACPI_GENERIC_ADDRESS    *Source64;
681
    UINT8                   Pm1RegisterByteWidth;
684
    UINT8                   Pm1RegisterByteWidth;
682
    UINT32                  i;
685
    UINT32                  i;
683
 
686
 
684
 
687
 
685
    /*
688
    /*
686
     * Optionally check all register lengths against the default values and
689
     * Optionally check all register lengths against the default values and
687
     * update them if they are incorrect.
690
     * update them if they are incorrect.
688
     */
691
     */
689
    if (AcpiGbl_UseDefaultRegisterWidths)
692
    if (AcpiGbl_UseDefaultRegisterWidths)
690
    {
693
    {
691
        for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
694
        for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++)
692
        {
695
        {
693
            Target64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
696
            Target64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
694
                FadtInfoTable[i].Address64);
697
                FadtInfoTable[i].Address64);
695
 
698
 
696
            /*
699
            /*
697
             * If a valid register (Address != 0) and the (DefaultLength > 0)
700
             * If a valid register (Address != 0) and the (DefaultLength > 0)
698
             * (Not a GPE register), then check the width against the default.
701
             * (Not a GPE register), then check the width against the default.
699
             */
702
             */
700
            if ((Target64->Address) &&
703
            if ((Target64->Address) &&
701
                (FadtInfoTable[i].DefaultLength > 0) &&
704
                (FadtInfoTable[i].DefaultLength > 0) &&
702
                (FadtInfoTable[i].DefaultLength != Target64->BitWidth))
705
                (FadtInfoTable[i].DefaultLength != Target64->BitWidth))
703
            {
706
            {
704
                ACPI_WARNING ((AE_INFO,
707
                ACPI_WARNING ((AE_INFO,
705
                    "Invalid length for %s: %u, using default %u",
708
                    "Invalid length for %s: %u, using default %u",
706
                    FadtInfoTable[i].Name, Target64->BitWidth,
709
                    FadtInfoTable[i].Name, Target64->BitWidth,
707
                    FadtInfoTable[i].DefaultLength));
710
                    FadtInfoTable[i].DefaultLength));
708
 
711
 
709
                /* Incorrect size, set width to the default */
712
                /* Incorrect size, set width to the default */
710
 
713
 
711
                Target64->BitWidth = FadtInfoTable[i].DefaultLength;
714
                Target64->BitWidth = FadtInfoTable[i].DefaultLength;
712
            }
715
            }
713
        }
716
        }
714
    }
717
    }
715
 
718
 
716
    /*
719
    /*
717
     * Get the length of the individual PM1 registers (enable and status).
720
     * Get the length of the individual PM1 registers (enable and status).
718
     * Each register is defined to be (event block length / 2). Extra divide
721
     * Each register is defined to be (event block length / 2). Extra divide
719
     * by 8 converts bits to bytes.
722
     * by 8 converts bits to bytes.
720
     */
723
     */
721
    Pm1RegisterByteWidth = (UINT8)
724
    Pm1RegisterByteWidth = (UINT8)
722
        ACPI_DIV_16 (AcpiGbl_FADT.XPm1aEventBlock.BitWidth);
725
        ACPI_DIV_16 (AcpiGbl_FADT.XPm1aEventBlock.BitWidth);
723
 
726
 
724
    /*
727
    /*
725
     * Calculate separate GAS structs for the PM1x (A/B) Status and Enable
728
     * 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
729
     * 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.
730
     * is useful to pre-calculate them from the PM1 Event Block definitions.
728
     *
731
     *
729
     * The PM event blocks are split into two register blocks, first is the
732
     * The PM event blocks are split into two register blocks, first is the
730
     * PM Status Register block, followed immediately by the PM Enable
733
     * PM Status Register block, followed immediately by the PM Enable
731
     * Register block. Each is of length (Pm1EventLength/2)
734
     * Register block. Each is of length (Pm1EventLength/2)
732
     *
735
     *
733
     * Note: The PM1A event block is required by the ACPI specification.
736
     * Note: The PM1A event block is required by the ACPI specification.
734
     * However, the PM1B event block is optional and is rarely, if ever,
737
     * However, the PM1B event block is optional and is rarely, if ever,
735
     * used.
738
     * used.
736
     */
739
     */
737
 
740
 
738
    for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++)
741
    for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++)
739
    {
742
    {
740
        Source64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
743
        Source64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT,
741
            FadtPmInfoTable[i].Source);
744
            FadtPmInfoTable[i].Source);
742
 
745
 
743
        if (Source64->Address)
746
        if (Source64->Address)
744
        {
747
        {
745
            AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target,
748
            AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target,
746
                Source64->SpaceId, Pm1RegisterByteWidth,
749
                Source64->SpaceId, Pm1RegisterByteWidth,
747
                Source64->Address +
750
                Source64->Address +
748
                    (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth));
751
                    (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth));
749
        }
752
        }
750
    }
753
    }
751
}
754
}