Subversion Repositories Kolibri OS

Rev

Rev 1498 | Go to most recent revision | 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: tbxface - Public interfaces to the ACPI subsystem
3
 * Module Name: tbxface - Public interfaces to the ACPI subsystem
4
 *                         ACPI table oriented interfaces
4
 *                         ACPI table oriented interfaces
5
 *
5
 *
6
 *****************************************************************************/
6
 *****************************************************************************/
7
 
7
 
8
/******************************************************************************
8
/******************************************************************************
9
 *
9
 *
10
 * 1. Copyright Notice
10
 * 1. Copyright Notice
11
 *
11
 *
12
 * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
12
 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
13
 * All rights reserved.
13
 * All rights reserved.
14
 *
14
 *
15
 * 2. License
15
 * 2. License
16
 *
16
 *
17
 * 2.1. This is your license from Intel Corp. under its intellectual property
17
 * 2.1. This is your license from Intel Corp. under its intellectual property
18
 * rights.  You may have additional license terms from the party that provided
18
 * rights.  You may have additional license terms from the party that provided
19
 * you this software, covering your right to use that party's intellectual
19
 * you this software, covering your right to use that party's intellectual
20
 * property rights.
20
 * property rights.
21
 *
21
 *
22
 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22
 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23
 * copy of the source code appearing in this file ("Covered Code") an
23
 * copy of the source code appearing in this file ("Covered Code") an
24
 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24
 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25
 * base code distributed originally by Intel ("Original Intel Code") to copy,
25
 * base code distributed originally by Intel ("Original Intel Code") to copy,
26
 * make derivatives, distribute, use and display any portion of the Covered
26
 * make derivatives, distribute, use and display any portion of the Covered
27
 * Code in any form, with the right to sublicense such rights; and
27
 * Code in any form, with the right to sublicense such rights; and
28
 *
28
 *
29
 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29
 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30
 * license (with the right to sublicense), under only those claims of Intel
30
 * license (with the right to sublicense), under only those claims of Intel
31
 * patents that are infringed by the Original Intel Code, to make, use, sell,
31
 * patents that are infringed by the Original Intel Code, to make, use, sell,
32
 * offer to sell, and import the Covered Code and derivative works thereof
32
 * offer to sell, and import the Covered Code and derivative works thereof
33
 * solely to the minimum extent necessary to exercise the above copyright
33
 * solely to the minimum extent necessary to exercise the above copyright
34
 * license, and in no event shall the patent license extend to any additions
34
 * license, and in no event shall the patent license extend to any additions
35
 * to or modifications of the Original Intel Code.  No other license or right
35
 * to or modifications of the Original Intel Code.  No other license or right
36
 * is granted directly or by implication, estoppel or otherwise;
36
 * is granted directly or by implication, estoppel or otherwise;
37
 *
37
 *
38
 * The above copyright and patent license is granted only if the following
38
 * The above copyright and patent license is granted only if the following
39
 * conditions are met:
39
 * conditions are met:
40
 *
40
 *
41
 * 3. Conditions
41
 * 3. Conditions
42
 *
42
 *
43
 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43
 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44
 * Redistribution of source code of any substantial portion of the Covered
44
 * Redistribution of source code of any substantial portion of the Covered
45
 * Code or modification with rights to further distribute source must include
45
 * Code or modification with rights to further distribute source must include
46
 * the above Copyright Notice, the above License, this list of Conditions,
46
 * the above Copyright Notice, the above License, this list of Conditions,
47
 * and the following Disclaimer and Export Compliance provision.  In addition,
47
 * and the following Disclaimer and Export Compliance provision.  In addition,
48
 * Licensee must cause all Covered Code to which Licensee contributes to
48
 * Licensee must cause all Covered Code to which Licensee contributes to
49
 * contain a file documenting the changes Licensee made to create that Covered
49
 * contain a file documenting the changes Licensee made to create that Covered
50
 * Code and the date of any change.  Licensee must include in that file the
50
 * Code and the date of any change.  Licensee must include in that file the
51
 * documentation of any changes made by any predecessor Licensee.  Licensee
51
 * documentation of any changes made by any predecessor Licensee.  Licensee
52
 * must include a prominent statement that the modification is derived,
52
 * must include a prominent statement that the modification is derived,
53
 * directly or indirectly, from Original Intel Code.
53
 * directly or indirectly, from Original Intel Code.
54
 *
54
 *
55
 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55
 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56
 * Redistribution of source code of any substantial portion of the Covered
56
 * Redistribution of source code of any substantial portion of the Covered
57
 * Code or modification without rights to further distribute source must
57
 * Code or modification without rights to further distribute source must
58
 * include the following Disclaimer and Export Compliance provision in the
58
 * include the following Disclaimer and Export Compliance provision in the
59
 * documentation and/or other materials provided with distribution.  In
59
 * documentation and/or other materials provided with distribution.  In
60
 * addition, Licensee may not authorize further sublicense of source of any
60
 * addition, Licensee may not authorize further sublicense of source of any
61
 * portion of the Covered Code, and must include terms to the effect that the
61
 * portion of the Covered Code, and must include terms to the effect that the
62
 * license from Licensee to its licensee is limited to the intellectual
62
 * license from Licensee to its licensee is limited to the intellectual
63
 * property embodied in the software Licensee provides to its licensee, and
63
 * property embodied in the software Licensee provides to its licensee, and
64
 * not to intellectual property embodied in modifications its licensee may
64
 * not to intellectual property embodied in modifications its licensee may
65
 * make.
65
 * make.
66
 *
66
 *
67
 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67
 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68
 * substantial portion of the Covered Code or modification must reproduce the
68
 * substantial portion of the Covered Code or modification must reproduce the
69
 * above Copyright Notice, and the following Disclaimer and Export Compliance
69
 * above Copyright Notice, and the following Disclaimer and Export Compliance
70
 * provision in the documentation and/or other materials provided with the
70
 * provision in the documentation and/or other materials provided with the
71
 * distribution.
71
 * distribution.
72
 *
72
 *
73
 * 3.4. Intel retains all right, title, and interest in and to the Original
73
 * 3.4. Intel retains all right, title, and interest in and to the Original
74
 * Intel Code.
74
 * Intel Code.
75
 *
75
 *
76
 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76
 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77
 * Intel shall be used in advertising or otherwise to promote the sale, use or
77
 * Intel shall be used in advertising or otherwise to promote the sale, use or
78
 * other dealings in products derived from or relating to the Covered Code
78
 * other dealings in products derived from or relating to the Covered Code
79
 * without prior written authorization from Intel.
79
 * without prior written authorization from Intel.
80
 *
80
 *
81
 * 4. Disclaimer and Export Compliance
81
 * 4. Disclaimer and Export Compliance
82
 *
82
 *
83
 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83
 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84
 * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84
 * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85
 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
85
 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86
 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
86
 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87
 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
87
 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88
 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88
 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89
 * PARTICULAR PURPOSE.
89
 * PARTICULAR PURPOSE.
90
 *
90
 *
91
 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91
 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92
 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92
 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93
 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93
 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94
 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94
 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95
 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95
 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96
 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
96
 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97
 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97
 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98
 * LIMITED REMEDY.
98
 * LIMITED REMEDY.
99
 *
99
 *
100
 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100
 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101
 * software or system incorporating such software without first obtaining any
101
 * software or system incorporating such software without first obtaining any
102
 * required license or other approval from the U. S. Department of Commerce or
102
 * required license or other approval from the U. S. Department of Commerce or
103
 * any other agency or department of the United States Government.  In the
103
 * any other agency or department of the United States Government.  In the
104
 * event Licensee exports any such software from the United States or
104
 * event Licensee exports any such software from the United States or
105
 * re-exports any such software from a foreign destination, Licensee shall
105
 * re-exports any such software from a foreign destination, Licensee shall
106
 * ensure that the distribution and export/re-export of the software is in
106
 * ensure that the distribution and export/re-export of the software is in
107
 * compliance with all laws, regulations, orders, or other restrictions of the
107
 * compliance with all laws, regulations, orders, or other restrictions of the
108
 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108
 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109
 * any of its subsidiaries will export/re-export any technical data, process,
109
 * any of its subsidiaries will export/re-export any technical data, process,
110
 * software, or service, directly or indirectly, to any country for which the
110
 * software, or service, directly or indirectly, to any country for which the
111
 * United States government or any agency thereof requires an export license,
111
 * United States government or any agency thereof requires an export license,
112
 * other governmental approval, or letter of assurance, without first obtaining
112
 * other governmental approval, or letter of assurance, without first obtaining
113
 * such license, approval or letter.
113
 * such license, approval or letter.
114
 *
114
 *
115
 *****************************************************************************/
115
 *****************************************************************************/
116
 
116
 
117
#define __TBXFACE_C__
117
#define __TBXFACE_C__
118
 
118
 
119
#include "acpi.h"
119
#include "acpi.h"
120
#include "accommon.h"
120
#include "accommon.h"
121
#include "acnamesp.h"
121
#include "acnamesp.h"
122
#include "actables.h"
122
#include "actables.h"
123
 
123
 
124
#define _COMPONENT          ACPI_TABLES
124
#define _COMPONENT          ACPI_TABLES
125
        ACPI_MODULE_NAME    ("tbxface")
125
        ACPI_MODULE_NAME    ("tbxface")
126
 
126
 
127
/* Local prototypes */
127
/* Local prototypes */
128
 
128
 
129
static ACPI_STATUS
129
static ACPI_STATUS
130
AcpiTbLoadNamespace (
130
AcpiTbLoadNamespace (
131
    void);
131
    void);
132
 
132
 
133
 
133
 
134
/*******************************************************************************
134
/*******************************************************************************
135
 *
135
 *
136
 * FUNCTION:    AcpiAllocateRootTable
136
 * FUNCTION:    AcpiAllocateRootTable
137
 *
137
 *
138
 * PARAMETERS:  InitialTableCount   - Size of InitialTableArray, in number of
138
 * PARAMETERS:  InitialTableCount   - Size of InitialTableArray, in number of
139
 *                                    ACPI_TABLE_DESC structures
139
 *                                    ACPI_TABLE_DESC structures
140
 *
140
 *
141
 * RETURN:      Status
141
 * RETURN:      Status
142
 *
142
 *
143
 * DESCRIPTION: Allocate a root table array. Used by iASL compiler and
143
 * DESCRIPTION: Allocate a root table array. Used by iASL compiler and
144
 *              AcpiInitializeTables.
144
 *              AcpiInitializeTables.
145
 *
145
 *
146
 ******************************************************************************/
146
 ******************************************************************************/
147
 
147
 
148
ACPI_STATUS
148
ACPI_STATUS
149
AcpiAllocateRootTable (
149
AcpiAllocateRootTable (
150
    UINT32                  InitialTableCount)
150
    UINT32                  InitialTableCount)
151
{
151
{
152
 
152
 
153
    AcpiGbl_RootTableList.MaxTableCount = InitialTableCount;
153
    AcpiGbl_RootTableList.MaxTableCount = InitialTableCount;
154
    AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE;
154
    AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE;
155
 
155
 
156
    return (AcpiTbResizeRootTableList ());
156
    return (AcpiTbResizeRootTableList ());
157
}
157
}
158
 
158
 
159
 
159
 
160
/*******************************************************************************
160
/*******************************************************************************
161
 *
161
 *
162
 * FUNCTION:    AcpiInitializeTables
162
 * FUNCTION:    AcpiInitializeTables
163
 *
163
 *
164
 * PARAMETERS:  InitialTableArray   - Pointer to an array of pre-allocated
164
 * PARAMETERS:  InitialTableArray   - Pointer to an array of pre-allocated
165
 *                                    ACPI_TABLE_DESC structures. If NULL, the
165
 *                                    ACPI_TABLE_DESC structures. If NULL, the
166
 *                                    array is dynamically allocated.
166
 *                                    array is dynamically allocated.
167
 *              InitialTableCount   - Size of InitialTableArray, in number of
167
 *              InitialTableCount   - Size of InitialTableArray, in number of
168
 *                                    ACPI_TABLE_DESC structures
168
 *                                    ACPI_TABLE_DESC structures
169
 *              AllowRealloc        - Flag to tell Table Manager if resize of
169
 *              AllowRealloc        - Flag to tell Table Manager if resize of
170
 *                                    pre-allocated array is allowed. Ignored
170
 *                                    pre-allocated array is allowed. Ignored
171
 *                                    if InitialTableArray is NULL.
171
 *                                    if InitialTableArray is NULL.
172
 *
172
 *
173
 * RETURN:      Status
173
 * RETURN:      Status
174
 *
174
 *
175
 * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT.
175
 * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT.
176
 *
176
 *
177
 * NOTE:        Allows static allocation of the initial table array in order
177
 * NOTE:        Allows static allocation of the initial table array in order
178
 *              to avoid the use of dynamic memory in confined environments
178
 *              to avoid the use of dynamic memory in confined environments
179
 *              such as the kernel boot sequence where it may not be available.
179
 *              such as the kernel boot sequence where it may not be available.
180
 *
180
 *
181
 *              If the host OS memory managers are initialized, use NULL for
181
 *              If the host OS memory managers are initialized, use NULL for
182
 *              InitialTableArray, and the table will be dynamically allocated.
182
 *              InitialTableArray, and the table will be dynamically allocated.
183
 *
183
 *
184
 ******************************************************************************/
184
 ******************************************************************************/
185
 
185
 
186
ACPI_STATUS
186
ACPI_STATUS
187
AcpiInitializeTables (
187
AcpiInitializeTables (
188
    ACPI_TABLE_DESC         *InitialTableArray,
188
    ACPI_TABLE_DESC         *InitialTableArray,
189
    UINT32                  InitialTableCount,
189
    UINT32                  InitialTableCount,
190
    BOOLEAN                 AllowResize)
190
    BOOLEAN                 AllowResize)
191
{
191
{
192
    ACPI_PHYSICAL_ADDRESS   RsdpAddress;
192
    ACPI_PHYSICAL_ADDRESS   RsdpAddress;
193
    ACPI_STATUS             Status;
193
    ACPI_STATUS             Status;
194
 
194
 
195
 
195
 
196
    ACPI_FUNCTION_TRACE (AcpiInitializeTables);
196
    ACPI_FUNCTION_TRACE (AcpiInitializeTables);
197
 
197
 
198
 
198
 
199
    /*
199
    /*
200
     * Set up the Root Table Array
200
     * Set up the Root Table Array
201
     * Allocate the table array if requested
201
     * Allocate the table array if requested
202
     */
202
     */
203
    if (!InitialTableArray)
203
    if (!InitialTableArray)
204
    {
204
    {
205
        Status = AcpiAllocateRootTable (InitialTableCount);
205
        Status = AcpiAllocateRootTable (InitialTableCount);
206
        if (ACPI_FAILURE (Status))
206
        if (ACPI_FAILURE (Status))
207
        {
207
        {
208
            return_ACPI_STATUS (Status);
208
            return_ACPI_STATUS (Status);
209
        }
209
        }
210
    }
210
    }
211
    else
211
    else
212
    {
212
    {
213
        /* Root Table Array has been statically allocated by the host */
213
        /* Root Table Array has been statically allocated by the host */
214
 
214
 
215
        ACPI_MEMSET (InitialTableArray, 0,
215
        ACPI_MEMSET (InitialTableArray, 0,
216
            (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC));
216
            (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC));
217
 
217
 
218
        AcpiGbl_RootTableList.Tables = InitialTableArray;
218
        AcpiGbl_RootTableList.Tables = InitialTableArray;
219
        AcpiGbl_RootTableList.MaxTableCount = InitialTableCount;
219
        AcpiGbl_RootTableList.MaxTableCount = InitialTableCount;
220
        AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN;
220
        AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN;
221
        if (AllowResize)
221
        if (AllowResize)
222
        {
222
        {
223
            AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE;
223
            AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE;
224
        }
224
        }
225
    }
225
    }
226
 
226
 
227
    /* Get the address of the RSDP */
227
    /* Get the address of the RSDP */
228
 
228
 
229
    RsdpAddress = AcpiOsGetRootPointer ();
229
    RsdpAddress = AcpiOsGetRootPointer ();
230
    if (!RsdpAddress)
230
    if (!RsdpAddress)
231
    {
231
    {
232
        return_ACPI_STATUS (AE_NOT_FOUND);
232
        return_ACPI_STATUS (AE_NOT_FOUND);
233
    }
233
    }
234
 
234
 
235
    /*
235
    /*
236
     * Get the root table (RSDT or XSDT) and extract all entries to the local
236
     * Get the root table (RSDT or XSDT) and extract all entries to the local
237
     * Root Table Array. This array contains the information of the RSDT/XSDT
237
     * Root Table Array. This array contains the information of the RSDT/XSDT
238
     * in a common, more useable format.
238
     * in a common, more useable format.
239
     */
239
     */
240
    Status = AcpiTbParseRootTable (RsdpAddress);
240
    Status = AcpiTbParseRootTable (RsdpAddress);
241
    return_ACPI_STATUS (Status);
241
    return_ACPI_STATUS (Status);
242
}
242
}
243
 
243
 
244
ACPI_EXPORT_SYMBOL (AcpiInitializeTables)
244
ACPI_EXPORT_SYMBOL (AcpiInitializeTables)
245
 
245
 
246
 
246
 
247
/*******************************************************************************
247
/*******************************************************************************
248
 *
248
 *
249
 * FUNCTION:    AcpiReallocateRootTable
249
 * FUNCTION:    AcpiReallocateRootTable
250
 *
250
 *
251
 * PARAMETERS:  None
251
 * PARAMETERS:  None
252
 *
252
 *
253
 * RETURN:      Status
253
 * RETURN:      Status
254
 *
254
 *
255
 * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
255
 * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
256
 *              root list from the previously provided scratch area. Should
256
 *              root list from the previously provided scratch area. Should
257
 *              be called once dynamic memory allocation is available in the
257
 *              be called once dynamic memory allocation is available in the
258
 *              kernel
258
 *              kernel
259
 *
259
 *
260
 ******************************************************************************/
260
 ******************************************************************************/
261
 
261
 
262
ACPI_STATUS
262
ACPI_STATUS
263
AcpiReallocateRootTable (
263
AcpiReallocateRootTable (
264
    void)
264
    void)
265
{
265
{
266
    ACPI_TABLE_DESC         *Tables;
266
    ACPI_TABLE_DESC         *Tables;
267
    ACPI_SIZE               NewSize;
267
    ACPI_SIZE               NewSize;
268
    ACPI_SIZE               CurrentSize;
268
    ACPI_SIZE               CurrentSize;
269
 
269
 
270
 
270
 
271
    ACPI_FUNCTION_TRACE (AcpiReallocateRootTable);
271
    ACPI_FUNCTION_TRACE (AcpiReallocateRootTable);
272
 
272
 
273
 
273
 
274
    /*
274
    /*
275
     * Only reallocate the root table if the host provided a static buffer
275
     * Only reallocate the root table if the host provided a static buffer
276
     * for the table array in the call to AcpiInitializeTables.
276
     * for the table array in the call to AcpiInitializeTables.
277
     */
277
     */
278
    if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
278
    if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
279
    {
279
    {
280
        return_ACPI_STATUS (AE_SUPPORT);
280
        return_ACPI_STATUS (AE_SUPPORT);
281
    }
281
    }
282
 
282
 
283
    /*
283
    /*
284
     * Get the current size of the root table and add the default
284
     * Get the current size of the root table and add the default
285
     * increment to create the new table size.
285
     * increment to create the new table size.
286
     */
286
     */
287
    CurrentSize = (ACPI_SIZE)
287
    CurrentSize = (ACPI_SIZE)
288
        AcpiGbl_RootTableList.CurrentTableCount * sizeof (ACPI_TABLE_DESC);
288
        AcpiGbl_RootTableList.CurrentTableCount * sizeof (ACPI_TABLE_DESC);
289
 
289
 
290
    NewSize = CurrentSize +
290
    NewSize = CurrentSize +
291
        (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof (ACPI_TABLE_DESC));
291
        (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof (ACPI_TABLE_DESC));
292
 
292
 
293
    /* Create new array and copy the old array */
293
    /* Create new array and copy the old array */
294
 
294
 
295
    Tables = ACPI_ALLOCATE_ZEROED (NewSize);
295
    Tables = ACPI_ALLOCATE_ZEROED (NewSize);
296
    if (!Tables)
296
    if (!Tables)
297
    {
297
    {
298
        return_ACPI_STATUS (AE_NO_MEMORY);
298
        return_ACPI_STATUS (AE_NO_MEMORY);
299
    }
299
    }
300
 
300
 
301
    ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, CurrentSize);
301
    ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, CurrentSize);
302
 
302
 
303
    /*
303
    /*
304
     * Update the root table descriptor. The new size will be the current
304
     * Update the root table descriptor. The new size will be the current
305
     * number of tables plus the increment, independent of the reserved
305
     * number of tables plus the increment, independent of the reserved
306
     * size of the original table list.
306
     * size of the original table list.
307
     */
307
     */
308
    AcpiGbl_RootTableList.Tables = Tables;
308
    AcpiGbl_RootTableList.Tables = Tables;
309
    AcpiGbl_RootTableList.MaxTableCount =
309
    AcpiGbl_RootTableList.MaxTableCount =
310
        AcpiGbl_RootTableList.CurrentTableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT;
310
        AcpiGbl_RootTableList.CurrentTableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT;
311
    AcpiGbl_RootTableList.Flags =
311
    AcpiGbl_RootTableList.Flags =
312
        ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
312
        ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
313
 
313
 
314
    return_ACPI_STATUS (AE_OK);
314
    return_ACPI_STATUS (AE_OK);
315
}
315
}
316
 
316
 
317
ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable)
317
ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable)
318
 
318
 
319
 
319
 
320
/*******************************************************************************
320
/*******************************************************************************
321
 *
321
 *
322
 * FUNCTION:    AcpiGetTableHeader
322
 * FUNCTION:    AcpiGetTableHeader
323
 *
323
 *
324
 * PARAMETERS:  Signature           - ACPI signature of needed table
324
 * PARAMETERS:  Signature           - ACPI signature of needed table
325
 *              Instance            - Which instance (for SSDTs)
325
 *              Instance            - Which instance (for SSDTs)
326
 *              OutTableHeader      - The pointer to the table header to fill
326
 *              OutTableHeader      - The pointer to the table header to fill
327
 *
327
 *
328
 * RETURN:      Status and pointer to mapped table header
328
 * RETURN:      Status and pointer to mapped table header
329
 *
329
 *
330
 * DESCRIPTION: Finds an ACPI table header.
330
 * DESCRIPTION: Finds an ACPI table header.
331
 *
331
 *
332
 * NOTE:        Caller is responsible in unmapping the header with
332
 * NOTE:        Caller is responsible in unmapping the header with
333
 *              AcpiOsUnmapMemory
333
 *              AcpiOsUnmapMemory
334
 *
334
 *
335
 ******************************************************************************/
335
 ******************************************************************************/
336
 
336
 
337
ACPI_STATUS
337
ACPI_STATUS
338
AcpiGetTableHeader (
338
AcpiGetTableHeader (
339
    char                    *Signature,
339
    char                    *Signature,
340
    UINT32                  Instance,
340
    UINT32                  Instance,
341
    ACPI_TABLE_HEADER       *OutTableHeader)
341
    ACPI_TABLE_HEADER       *OutTableHeader)
342
{
342
{
343
    UINT32                  i;
343
    UINT32                  i;
344
    UINT32                  j;
344
    UINT32                  j;
345
    ACPI_TABLE_HEADER       *Header;
345
    ACPI_TABLE_HEADER       *Header;
346
 
346
 
347
 
347
 
348
    /* Parameter validation */
348
    /* Parameter validation */
349
 
349
 
350
    if (!Signature || !OutTableHeader)
350
    if (!Signature || !OutTableHeader)
351
    {
351
    {
352
        return (AE_BAD_PARAMETER);
352
        return (AE_BAD_PARAMETER);
353
    }
353
    }
354
 
354
 
355
    /* Walk the root table list */
355
    /* Walk the root table list */
356
 
356
 
357
    for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
357
    for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
358
    {
358
    {
359
        if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
359
        if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
360
                    Signature))
360
                    Signature))
361
        {
361
        {
362
            continue;
362
            continue;
363
        }
363
        }
364
 
364
 
365
        if (++j < Instance)
365
        if (++j < Instance)
366
        {
366
        {
367
            continue;
367
            continue;
368
        }
368
        }
369
 
369
 
370
        if (!AcpiGbl_RootTableList.Tables[i].Pointer)
370
        if (!AcpiGbl_RootTableList.Tables[i].Pointer)
371
        {
371
        {
372
            if ((AcpiGbl_RootTableList.Tables[i].Flags &
372
            if ((AcpiGbl_RootTableList.Tables[i].Flags &
373
                    ACPI_TABLE_ORIGIN_MASK) ==
373
                    ACPI_TABLE_ORIGIN_MASK) ==
374
                ACPI_TABLE_ORIGIN_MAPPED)
374
                ACPI_TABLE_ORIGIN_MAPPED)
375
            {
375
            {
376
                Header = AcpiOsMapMemory (
376
                Header = AcpiOsMapMemory (
377
                            AcpiGbl_RootTableList.Tables[i].Address,
377
                            AcpiGbl_RootTableList.Tables[i].Address,
378
                            sizeof (ACPI_TABLE_HEADER));
378
                            sizeof (ACPI_TABLE_HEADER));
379
                if (!Header)
379
                if (!Header)
380
                {
380
                {
381
                    return AE_NO_MEMORY;
381
                    return AE_NO_MEMORY;
382
                }
382
                }
383
 
383
 
384
                ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER));
384
                ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER));
385
                AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER));
385
                AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER));
386
            }
386
            }
387
            else
387
            else
388
            {
388
            {
389
                return AE_NOT_FOUND;
389
                return AE_NOT_FOUND;
390
            }
390
            }
391
        }
391
        }
392
        else
392
        else
393
        {
393
        {
394
            ACPI_MEMCPY (OutTableHeader,
394
            ACPI_MEMCPY (OutTableHeader,
395
                AcpiGbl_RootTableList.Tables[i].Pointer,
395
                AcpiGbl_RootTableList.Tables[i].Pointer,
396
                sizeof(ACPI_TABLE_HEADER));
396
                sizeof(ACPI_TABLE_HEADER));
397
        }
397
        }
398
 
398
 
399
        return (AE_OK);
399
        return (AE_OK);
400
    }
400
    }
401
 
401
 
402
    return (AE_NOT_FOUND);
402
    return (AE_NOT_FOUND);
403
}
403
}
404
 
404
 
405
ACPI_EXPORT_SYMBOL (AcpiGetTableHeader)
405
ACPI_EXPORT_SYMBOL (AcpiGetTableHeader)
406
 
406
 
407
 
407
 
408
/*******************************************************************************
408
/*******************************************************************************
409
 *
409
 *
410
 * FUNCTION:    AcpiGetTable
410
 * FUNCTION:    AcpiGetTable
411
 *
411
 *
412
 * PARAMETERS:  Signature           - ACPI signature of needed table
412
 * PARAMETERS:  Signature           - ACPI signature of needed table
413
 *              Instance            - Which instance (for SSDTs)
413
 *              Instance            - Which instance (for SSDTs)
414
 *              OutTable            - Where the pointer to the table is returned
414
 *              OutTable            - Where the pointer to the table is returned
415
 *
415
 *
416
 * RETURN:      Status and pointer to table
416
 * RETURN:      Status and pointer to table
417
 *
417
 *
418
 * DESCRIPTION: Finds and verifies an ACPI table.
418
 * DESCRIPTION: Finds and verifies an ACPI table.
419
 *
419
 *
420
 ******************************************************************************/
420
 ******************************************************************************/
421
 
421
 
422
ACPI_STATUS
422
ACPI_STATUS
423
AcpiGetTable (
423
AcpiGetTable (
424
    char                    *Signature,
424
    char                    *Signature,
425
    UINT32                  Instance,
425
    UINT32                  Instance,
426
    ACPI_TABLE_HEADER       **OutTable)
426
    ACPI_TABLE_HEADER       **OutTable)
427
{
427
{
428
    UINT32                  i;
428
    UINT32                  i;
429
    UINT32                  j;
429
    UINT32                  j;
430
    ACPI_STATUS             Status;
430
    ACPI_STATUS             Status;
431
 
431
 
432
 
432
 
433
    /* Parameter validation */
433
    /* Parameter validation */
434
 
434
 
435
    if (!Signature || !OutTable)
435
    if (!Signature || !OutTable)
436
    {
436
    {
437
        return (AE_BAD_PARAMETER);
437
        return (AE_BAD_PARAMETER);
438
    }
438
    }
439
 
439
 
440
    /* Walk the root table list */
440
    /* Walk the root table list */
441
 
441
 
442
    for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
442
    for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
443
    {
443
    {
444
        if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
444
        if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
445
                Signature))
445
                Signature))
446
        {
446
        {
447
            continue;
447
            continue;
448
        }
448
        }
449
 
449
 
450
        if (++j < Instance)
450
        if (++j < Instance)
451
        {
451
        {
452
            continue;
452
            continue;
453
        }
453
        }
454
 
454
 
455
        Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
455
        Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
456
        if (ACPI_SUCCESS (Status))
456
        if (ACPI_SUCCESS (Status))
457
        {
457
        {
458
            *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer;
458
            *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer;
459
        }
459
        }
460
 
460
 
461
        return (Status);
461
        return (Status);
462
    }
462
    }
463
 
463
 
464
    return (AE_NOT_FOUND);
464
    return (AE_NOT_FOUND);
465
}
465
}
466
 
466
 
467
ACPI_EXPORT_SYMBOL (AcpiGetTable)
467
ACPI_EXPORT_SYMBOL (AcpiGetTable)
468
 
468
 
469
 
469
 
470
/*******************************************************************************
470
/*******************************************************************************
471
 *
471
 *
472
 * FUNCTION:    AcpiGetTableByIndex
472
 * FUNCTION:    AcpiGetTableByIndex
473
 *
473
 *
474
 * PARAMETERS:  TableIndex          - Table index
474
 * PARAMETERS:  TableIndex          - Table index
475
 *              Table               - Where the pointer to the table is returned
475
 *              Table               - Where the pointer to the table is returned
476
 *
476
 *
477
 * RETURN:      Status and pointer to the table
477
 * RETURN:      Status and pointer to the table
478
 *
478
 *
479
 * DESCRIPTION: Obtain a table by an index into the global table list.
479
 * DESCRIPTION: Obtain a table by an index into the global table list.
480
 *
480
 *
481
 ******************************************************************************/
481
 ******************************************************************************/
482
 
482
 
483
ACPI_STATUS
483
ACPI_STATUS
484
AcpiGetTableByIndex (
484
AcpiGetTableByIndex (
485
    UINT32                  TableIndex,
485
    UINT32                  TableIndex,
486
    ACPI_TABLE_HEADER       **Table)
486
    ACPI_TABLE_HEADER       **Table)
487
{
487
{
488
    ACPI_STATUS             Status;
488
    ACPI_STATUS             Status;
489
 
489
 
490
 
490
 
491
    ACPI_FUNCTION_TRACE (AcpiGetTableByIndex);
491
    ACPI_FUNCTION_TRACE (AcpiGetTableByIndex);
492
 
492
 
493
 
493
 
494
    /* Parameter validation */
494
    /* Parameter validation */
495
 
495
 
496
    if (!Table)
496
    if (!Table)
497
    {
497
    {
498
        return_ACPI_STATUS (AE_BAD_PARAMETER);
498
        return_ACPI_STATUS (AE_BAD_PARAMETER);
499
    }
499
    }
500
 
500
 
501
    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
501
    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
502
 
502
 
503
    /* Validate index */
503
    /* Validate index */
504
 
504
 
505
    if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount)
505
    if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount)
506
    {
506
    {
507
        (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
507
        (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
508
        return_ACPI_STATUS (AE_BAD_PARAMETER);
508
        return_ACPI_STATUS (AE_BAD_PARAMETER);
509
    }
509
    }
510
 
510
 
511
    if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer)
511
    if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer)
512
    {
512
    {
513
        /* Table is not mapped, map it */
513
        /* Table is not mapped, map it */
514
 
514
 
515
        Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]);
515
        Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]);
516
        if (ACPI_FAILURE (Status))
516
        if (ACPI_FAILURE (Status))
517
        {
517
        {
518
            (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
518
            (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
519
            return_ACPI_STATUS (Status);
519
            return_ACPI_STATUS (Status);
520
        }
520
        }
521
    }
521
    }
522
 
522
 
523
    *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer;
523
    *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer;
524
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
524
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
525
    return_ACPI_STATUS (AE_OK);
525
    return_ACPI_STATUS (AE_OK);
526
}
526
}
527
 
527
 
528
ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex)
528
ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex)
529
 
529
 
530
 
530
 
531
/*******************************************************************************
531
/*******************************************************************************
532
 *
532
 *
533
 * FUNCTION:    AcpiTbLoadNamespace
533
 * FUNCTION:    AcpiTbLoadNamespace
534
 *
534
 *
535
 * PARAMETERS:  None
535
 * PARAMETERS:  None
536
 *
536
 *
537
 * RETURN:      Status
537
 * RETURN:      Status
538
 *
538
 *
539
 * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
539
 * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
540
 *              the RSDT/XSDT.
540
 *              the RSDT/XSDT.
541
 *
541
 *
542
 ******************************************************************************/
542
 ******************************************************************************/
543
 
543
 
544
static ACPI_STATUS
544
static ACPI_STATUS
545
AcpiTbLoadNamespace (
545
AcpiTbLoadNamespace (
546
    void)
546
    void)
547
{
547
{
548
    ACPI_STATUS             Status;
548
    ACPI_STATUS             Status;
549
    UINT32                  i;
549
    UINT32                  i;
550
    ACPI_TABLE_HEADER       *NewDsdt;
550
    ACPI_TABLE_HEADER       *NewDsdt;
551
 
551
 
552
 
552
 
553
    ACPI_FUNCTION_TRACE (TbLoadNamespace);
553
    ACPI_FUNCTION_TRACE (TbLoadNamespace);
554
 
554
 
555
 
555
 
556
    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
556
    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
557
 
557
 
558
    /*
558
    /*
559
     * Load the namespace. The DSDT is required, but any SSDT and
559
     * Load the namespace. The DSDT is required, but any SSDT and
560
     * PSDT tables are optional. Verify the DSDT.
560
     * PSDT tables are optional. Verify the DSDT.
561
     */
561
     */
562
    if (!AcpiGbl_RootTableList.CurrentTableCount ||
562
    if (!AcpiGbl_RootTableList.CurrentTableCount ||
563
        !ACPI_COMPARE_NAME (
563
        !ACPI_COMPARE_NAME (
564
            &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature),
564
            &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature),
565
            ACPI_SIG_DSDT) ||
565
            ACPI_SIG_DSDT) ||
566
         ACPI_FAILURE (AcpiTbVerifyTable (
566
         ACPI_FAILURE (AcpiTbVerifyTable (
567
            &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT])))
567
            &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT])))
568
    {
568
    {
569
        Status = AE_NO_ACPI_TABLES;
569
        Status = AE_NO_ACPI_TABLES;
570
        goto UnlockAndExit;
570
        goto UnlockAndExit;
571
    }
571
    }
572
 
572
 
573
    /*
573
    /*
574
     * Save the DSDT pointer for simple access. This is the mapped memory
574
     * Save the DSDT pointer for simple access. This is the mapped memory
575
     * address. We must take care here because the address of the .Tables
575
     * address. We must take care here because the address of the .Tables
576
     * array can change dynamically as tables are loaded at run-time. Note:
576
     * array can change dynamically as tables are loaded at run-time. Note:
577
     * .Pointer field is not validated until after call to AcpiTbVerifyTable.
577
     * .Pointer field is not validated until after call to AcpiTbVerifyTable.
578
     */
578
     */
579
    AcpiGbl_DSDT = AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer;
579
    AcpiGbl_DSDT = AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer;
580
 
580
 
581
    /*
581
    /*
582
     * Optionally copy the entire DSDT to local memory (instead of simply
582
     * Optionally copy the entire DSDT to local memory (instead of simply
583
     * mapping it.) There are some BIOSs that corrupt or replace the original
583
     * mapping it.) There are some BIOSs that corrupt or replace the original
584
     * DSDT, creating the need for this option. Default is FALSE, do not copy
584
     * DSDT, creating the need for this option. Default is FALSE, do not copy
585
     * the DSDT.
585
     * the DSDT.
586
     */
586
     */
587
    if (AcpiGbl_CopyDsdtLocally)
587
    if (AcpiGbl_CopyDsdtLocally)
588
    {
588
    {
589
        NewDsdt = AcpiTbCopyDsdt (ACPI_TABLE_INDEX_DSDT);
589
        NewDsdt = AcpiTbCopyDsdt (ACPI_TABLE_INDEX_DSDT);
590
        if (NewDsdt)
590
        if (NewDsdt)
591
        {
591
        {
592
            AcpiGbl_DSDT = NewDsdt;
592
            AcpiGbl_DSDT = NewDsdt;
593
        }
593
        }
594
    }
594
    }
595
 
595
 
596
    /*
596
    /*
597
     * Save the original DSDT header for detection of table corruption
597
     * Save the original DSDT header for detection of table corruption
598
     * and/or replacement of the DSDT from outside the OS.
598
     * and/or replacement of the DSDT from outside the OS.
599
     */
599
     */
600
    ACPI_MEMCPY (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT,
600
    ACPI_MEMCPY (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT,
601
        sizeof (ACPI_TABLE_HEADER));
601
        sizeof (ACPI_TABLE_HEADER));
602
 
602
 
603
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
603
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
604
 
604
 
605
    /* Load and parse tables */
605
    /* Load and parse tables */
606
 
606
 
607
    Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode);
607
    Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode);
608
    if (ACPI_FAILURE (Status))
608
    if (ACPI_FAILURE (Status))
609
    {
609
    {
610
        return_ACPI_STATUS (Status);
610
        return_ACPI_STATUS (Status);
611
    }
611
    }
612
 
612
 
613
    /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
613
    /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
614
 
614
 
615
    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
615
    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
616
    for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
616
    for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
617
    {
617
    {
618
        if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
618
        if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
619
                    ACPI_SIG_SSDT) &&
619
                    ACPI_SIG_SSDT) &&
620
             !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
620
             !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
621
                    ACPI_SIG_PSDT)) ||
621
                    ACPI_SIG_PSDT)) ||
622
             ACPI_FAILURE (AcpiTbVerifyTable (
622
             ACPI_FAILURE (AcpiTbVerifyTable (
623
                &AcpiGbl_RootTableList.Tables[i])))
623
                &AcpiGbl_RootTableList.Tables[i])))
624
        {
624
        {
625
            continue;
625
            continue;
626
        }
626
        }
627
 
627
 
628
        /* Ignore errors while loading tables, get as many as possible */
628
        /* Ignore errors while loading tables, get as many as possible */
629
 
629
 
630
        (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
630
        (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
631
        (void) AcpiNsLoadTable (i, AcpiGbl_RootNode);
631
        (void) AcpiNsLoadTable (i, AcpiGbl_RootNode);
632
        (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
632
        (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
633
    }
633
    }
634
 
634
 
635
    ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
635
    ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
636
 
636
 
637
UnlockAndExit:
637
UnlockAndExit:
638
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
638
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
639
    return_ACPI_STATUS (Status);
639
    return_ACPI_STATUS (Status);
640
}
640
}
641
 
641
 
642
 
642
 
643
/*******************************************************************************
643
/*******************************************************************************
644
 *
644
 *
645
 * FUNCTION:    AcpiLoadTables
645
 * FUNCTION:    AcpiLoadTables
646
 *
646
 *
647
 * PARAMETERS:  None
647
 * PARAMETERS:  None
648
 *
648
 *
649
 * RETURN:      Status
649
 * RETURN:      Status
650
 *
650
 *
651
 * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
651
 * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
652
 *
652
 *
653
 ******************************************************************************/
653
 ******************************************************************************/
654
 
654
 
655
ACPI_STATUS
655
ACPI_STATUS
656
AcpiLoadTables (
656
AcpiLoadTables (
657
    void)
657
    void)
658
{
658
{
659
    ACPI_STATUS             Status;
659
    ACPI_STATUS             Status;
660
 
660
 
661
 
661
 
662
    ACPI_FUNCTION_TRACE (AcpiLoadTables);
662
    ACPI_FUNCTION_TRACE (AcpiLoadTables);
663
 
663
 
664
 
664
 
665
    /* Load the namespace from the tables */
665
    /* Load the namespace from the tables */
666
 
666
 
667
    Status = AcpiTbLoadNamespace ();
667
    Status = AcpiTbLoadNamespace ();
668
    if (ACPI_FAILURE (Status))
668
    if (ACPI_FAILURE (Status))
669
    {
669
    {
670
        ACPI_EXCEPTION ((AE_INFO, Status,
670
        ACPI_EXCEPTION ((AE_INFO, Status,
671
            "While loading namespace from ACPI tables"));
671
            "While loading namespace from ACPI tables"));
672
    }
672
    }
673
 
673
 
674
    return_ACPI_STATUS (Status);
674
    return_ACPI_STATUS (Status);
675
}
675
}
676
 
676
 
677
ACPI_EXPORT_SYMBOL (AcpiLoadTables)
677
ACPI_EXPORT_SYMBOL (AcpiLoadTables)
678
 
678
 
679
 
679
 
680
/*******************************************************************************
680
/*******************************************************************************
681
 *
681
 *
682
 * FUNCTION:    AcpiInstallTableHandler
682
 * FUNCTION:    AcpiInstallTableHandler
683
 *
683
 *
684
 * PARAMETERS:  Handler         - Table event handler
684
 * PARAMETERS:  Handler         - Table event handler
685
 *              Context         - Value passed to the handler on each event
685
 *              Context         - Value passed to the handler on each event
686
 *
686
 *
687
 * RETURN:      Status
687
 * RETURN:      Status
688
 *
688
 *
689
 * DESCRIPTION: Install table event handler
689
 * DESCRIPTION: Install table event handler
690
 *
690
 *
691
 ******************************************************************************/
691
 ******************************************************************************/
692
 
692
 
693
ACPI_STATUS
693
ACPI_STATUS
694
AcpiInstallTableHandler (
694
AcpiInstallTableHandler (
695
    ACPI_TABLE_HANDLER      Handler,
695
    ACPI_TABLE_HANDLER      Handler,
696
    void                    *Context)
696
    void                    *Context)
697
{
697
{
698
    ACPI_STATUS             Status;
698
    ACPI_STATUS             Status;
699
 
699
 
700
 
700
 
701
    ACPI_FUNCTION_TRACE (AcpiInstallTableHandler);
701
    ACPI_FUNCTION_TRACE (AcpiInstallTableHandler);
702
 
702
 
703
 
703
 
704
    if (!Handler)
704
    if (!Handler)
705
    {
705
    {
706
        return_ACPI_STATUS (AE_BAD_PARAMETER);
706
        return_ACPI_STATUS (AE_BAD_PARAMETER);
707
    }
707
    }
708
 
708
 
709
    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
709
    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
710
    if (ACPI_FAILURE (Status))
710
    if (ACPI_FAILURE (Status))
711
    {
711
    {
712
        return_ACPI_STATUS (Status);
712
        return_ACPI_STATUS (Status);
713
    }
713
    }
714
 
714
 
715
    /* Don't allow more than one handler */
715
    /* Don't allow more than one handler */
716
 
716
 
717
    if (AcpiGbl_TableHandler)
717
    if (AcpiGbl_TableHandler)
718
    {
718
    {
719
        Status = AE_ALREADY_EXISTS;
719
        Status = AE_ALREADY_EXISTS;
720
        goto Cleanup;
720
        goto Cleanup;
721
    }
721
    }
722
 
722
 
723
    /* Install the handler */
723
    /* Install the handler */
724
 
724
 
725
    AcpiGbl_TableHandler = Handler;
725
    AcpiGbl_TableHandler = Handler;
726
    AcpiGbl_TableHandlerContext = Context;
726
    AcpiGbl_TableHandlerContext = Context;
727
 
727
 
728
Cleanup:
728
Cleanup:
729
    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
729
    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
730
    return_ACPI_STATUS (Status);
730
    return_ACPI_STATUS (Status);
731
}
731
}
732
 
732
 
733
ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler)
733
ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler)
734
 
734
 
735
 
735
 
736
/*******************************************************************************
736
/*******************************************************************************
737
 *
737
 *
738
 * FUNCTION:    AcpiRemoveTableHandler
738
 * FUNCTION:    AcpiRemoveTableHandler
739
 *
739
 *
740
 * PARAMETERS:  Handler         - Table event handler that was installed
740
 * PARAMETERS:  Handler         - Table event handler that was installed
741
 *                                previously.
741
 *                                previously.
742
 *
742
 *
743
 * RETURN:      Status
743
 * RETURN:      Status
744
 *
744
 *
745
 * DESCRIPTION: Remove table event handler
745
 * DESCRIPTION: Remove table event handler
746
 *
746
 *
747
 ******************************************************************************/
747
 ******************************************************************************/
748
 
748
 
749
ACPI_STATUS
749
ACPI_STATUS
750
AcpiRemoveTableHandler (
750
AcpiRemoveTableHandler (
751
    ACPI_TABLE_HANDLER      Handler)
751
    ACPI_TABLE_HANDLER      Handler)
752
{
752
{
753
    ACPI_STATUS             Status;
753
    ACPI_STATUS             Status;
754
 
754
 
755
 
755
 
756
    ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler);
756
    ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler);
757
 
757
 
758
 
758
 
759
    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
759
    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
760
    if (ACPI_FAILURE (Status))
760
    if (ACPI_FAILURE (Status))
761
    {
761
    {
762
        return_ACPI_STATUS (Status);
762
        return_ACPI_STATUS (Status);
763
    }
763
    }
764
 
764
 
765
    /* Make sure that the installed handler is the same */
765
    /* Make sure that the installed handler is the same */
766
 
766
 
767
    if (!Handler ||
767
    if (!Handler ||
768
        Handler != AcpiGbl_TableHandler)
768
        Handler != AcpiGbl_TableHandler)
769
    {
769
    {
770
        Status = AE_BAD_PARAMETER;
770
        Status = AE_BAD_PARAMETER;
771
        goto Cleanup;
771
        goto Cleanup;
772
    }
772
    }
773
 
773
 
774
    /* Remove the handler */
774
    /* Remove the handler */
775
 
775
 
776
    AcpiGbl_TableHandler = NULL;
776
    AcpiGbl_TableHandler = NULL;
777
 
777
 
778
Cleanup:
778
Cleanup:
779
    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
779
    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
780
    return_ACPI_STATUS (Status);
780
    return_ACPI_STATUS (Status);
781
}
781
}
782
 
782
 
783
ACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler)
783
ACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler)