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: utmisc - common utility procedures
3
 * Module Name: utmisc - common utility procedures
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
 
116
 
117
#define __UTMISC_C__
117
#define __UTMISC_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
 
122
 
123
 
123
 
124
#define _COMPONENT          ACPI_UTILITIES
124
#define _COMPONENT          ACPI_UTILITIES
125
        ACPI_MODULE_NAME    ("utmisc")
125
        ACPI_MODULE_NAME    ("utmisc")
126
 
-
 
127
/*
-
 
128
 * Common suffix for messages
-
 
129
 */
-
 
130
#define ACPI_COMMON_MSG_SUFFIX \
-
 
131
    AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber)
-
 
132
 
126
 
133
 
127
 
134
/*******************************************************************************
128
/*******************************************************************************
135
 *
129
 *
136
 * FUNCTION:    AcpiUtValidateException
130
 * FUNCTION:    AcpiUtValidateException
137
 *
131
 *
138
 * PARAMETERS:  Status       - The ACPI_STATUS code to be formatted
132
 * PARAMETERS:  Status       - The ACPI_STATUS code to be formatted
139
 *
133
 *
140
 * RETURN:      A string containing the exception text. NULL if exception is
134
 * RETURN:      A string containing the exception text. NULL if exception is
141
 *              not valid.
135
 *              not valid.
142
 *
136
 *
143
 * DESCRIPTION: This function validates and translates an ACPI exception into
137
 * DESCRIPTION: This function validates and translates an ACPI exception into
144
 *              an ASCII string.
138
 *              an ASCII string.
145
 *
139
 *
146
 ******************************************************************************/
140
 ******************************************************************************/
147
 
141
 
148
const char *
142
const char *
149
AcpiUtValidateException (
143
AcpiUtValidateException (
150
    ACPI_STATUS             Status)
144
    ACPI_STATUS             Status)
151
{
145
{
152
    UINT32                  SubStatus;
146
    UINT32                  SubStatus;
153
    const char              *Exception = NULL;
147
    const char              *Exception = NULL;
154
 
148
 
155
 
149
 
156
    ACPI_FUNCTION_ENTRY ();
150
    ACPI_FUNCTION_ENTRY ();
157
 
151
 
158
 
152
 
159
    /*
153
    /*
160
     * Status is composed of two parts, a "type" and an actual code
154
     * Status is composed of two parts, a "type" and an actual code
161
     */
155
     */
162
    SubStatus = (Status & ~AE_CODE_MASK);
156
    SubStatus = (Status & ~AE_CODE_MASK);
163
 
157
 
164
    switch (Status & AE_CODE_MASK)
158
    switch (Status & AE_CODE_MASK)
165
    {
159
    {
166
    case AE_CODE_ENVIRONMENTAL:
160
    case AE_CODE_ENVIRONMENTAL:
167
 
161
 
168
        if (SubStatus <= AE_CODE_ENV_MAX)
162
        if (SubStatus <= AE_CODE_ENV_MAX)
169
        {
163
        {
170
            Exception = AcpiGbl_ExceptionNames_Env [SubStatus];
164
            Exception = AcpiGbl_ExceptionNames_Env [SubStatus];
171
        }
165
        }
172
        break;
166
        break;
173
 
167
 
174
    case AE_CODE_PROGRAMMER:
168
    case AE_CODE_PROGRAMMER:
175
 
169
 
176
        if (SubStatus <= AE_CODE_PGM_MAX)
170
        if (SubStatus <= AE_CODE_PGM_MAX)
177
        {
171
        {
178
            Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus];
172
            Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus];
179
        }
173
        }
180
        break;
174
        break;
181
 
175
 
182
    case AE_CODE_ACPI_TABLES:
176
    case AE_CODE_ACPI_TABLES:
183
 
177
 
184
        if (SubStatus <= AE_CODE_TBL_MAX)
178
        if (SubStatus <= AE_CODE_TBL_MAX)
185
        {
179
        {
186
            Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus];
180
            Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus];
187
        }
181
        }
188
        break;
182
        break;
189
 
183
 
190
    case AE_CODE_AML:
184
    case AE_CODE_AML:
191
 
185
 
192
        if (SubStatus <= AE_CODE_AML_MAX)
186
        if (SubStatus <= AE_CODE_AML_MAX)
193
        {
187
        {
194
            Exception = AcpiGbl_ExceptionNames_Aml [SubStatus];
188
            Exception = AcpiGbl_ExceptionNames_Aml [SubStatus];
195
        }
189
        }
196
        break;
190
        break;
197
 
191
 
198
    case AE_CODE_CONTROL:
192
    case AE_CODE_CONTROL:
199
 
193
 
200
        if (SubStatus <= AE_CODE_CTRL_MAX)
194
        if (SubStatus <= AE_CODE_CTRL_MAX)
201
        {
195
        {
202
            Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus];
196
            Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus];
203
        }
197
        }
204
        break;
198
        break;
205
 
199
 
206
    default:
200
    default:
207
        break;
201
        break;
208
    }
202
    }
209
 
203
 
210
    return (ACPI_CAST_PTR (const char, Exception));
204
    return (ACPI_CAST_PTR (const char, Exception));
211
}
205
}
212
 
206
 
213
 
207
 
214
/*******************************************************************************
208
/*******************************************************************************
215
 *
209
 *
216
 * FUNCTION:    AcpiUtIsPciRootBridge
210
 * FUNCTION:    AcpiUtIsPciRootBridge
217
 *
211
 *
218
 * PARAMETERS:  Id              - The HID/CID in string format
212
 * PARAMETERS:  Id              - The HID/CID in string format
219
 *
213
 *
220
 * RETURN:      TRUE if the Id is a match for a PCI/PCI-Express Root Bridge
214
 * RETURN:      TRUE if the Id is a match for a PCI/PCI-Express Root Bridge
221
 *
215
 *
222
 * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID.
216
 * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID.
223
 *
217
 *
224
 ******************************************************************************/
218
 ******************************************************************************/
225
 
219
 
226
BOOLEAN
220
BOOLEAN
227
AcpiUtIsPciRootBridge (
221
AcpiUtIsPciRootBridge (
228
    char                    *Id)
222
    char                    *Id)
229
{
223
{
230
 
224
 
231
    /*
225
    /*
232
     * Check if this is a PCI root bridge.
226
     * Check if this is a PCI root bridge.
233
     * ACPI 3.0+: check for a PCI Express root also.
227
     * ACPI 3.0+: check for a PCI Express root also.
234
     */
228
     */
235
    if (!(ACPI_STRCMP (Id,
229
    if (!(ACPI_STRCMP (Id,
236
            PCI_ROOT_HID_STRING)) ||
230
            PCI_ROOT_HID_STRING)) ||
237
 
231
 
238
        !(ACPI_STRCMP (Id,
232
        !(ACPI_STRCMP (Id,
239
            PCI_EXPRESS_ROOT_HID_STRING)))
233
            PCI_EXPRESS_ROOT_HID_STRING)))
240
    {
234
    {
241
        return (TRUE);
235
        return (TRUE);
242
    }
236
    }
243
 
237
 
244
    return (FALSE);
238
    return (FALSE);
245
}
239
}
246
 
240
 
247
 
241
 
248
/*******************************************************************************
242
/*******************************************************************************
249
 *
243
 *
250
 * FUNCTION:    AcpiUtIsAmlTable
244
 * FUNCTION:    AcpiUtIsAmlTable
251
 *
245
 *
252
 * PARAMETERS:  Table               - An ACPI table
246
 * PARAMETERS:  Table               - An ACPI table
253
 *
247
 *
254
 * RETURN:      TRUE if table contains executable AML; FALSE otherwise
248
 * RETURN:      TRUE if table contains executable AML; FALSE otherwise
255
 *
249
 *
256
 * DESCRIPTION: Check ACPI Signature for a table that contains AML code.
250
 * DESCRIPTION: Check ACPI Signature for a table that contains AML code.
257
 *              Currently, these are DSDT,SSDT,PSDT. All other table types are
251
 *              Currently, these are DSDT,SSDT,PSDT. All other table types are
258
 *              data tables that do not contain AML code.
252
 *              data tables that do not contain AML code.
259
 *
253
 *
260
 ******************************************************************************/
254
 ******************************************************************************/
261
 
255
 
262
BOOLEAN
256
BOOLEAN
263
AcpiUtIsAmlTable (
257
AcpiUtIsAmlTable (
264
    ACPI_TABLE_HEADER       *Table)
258
    ACPI_TABLE_HEADER       *Table)
265
{
259
{
266
 
260
 
267
    /* These are the only tables that contain executable AML */
261
    /* These are the only tables that contain executable AML */
268
 
262
 
269
    if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) ||
263
    if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) ||
270
        ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_PSDT) ||
264
        ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_PSDT) ||
271
        ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT))
265
        ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT))
272
    {
266
    {
273
        return (TRUE);
267
        return (TRUE);
274
    }
268
    }
275
 
269
 
276
    return (FALSE);
270
    return (FALSE);
277
}
271
}
278
 
272
 
279
 
273
 
280
/*******************************************************************************
274
/*******************************************************************************
281
 *
275
 *
282
 * FUNCTION:    AcpiUtAllocateOwnerId
276
 * FUNCTION:    AcpiUtAllocateOwnerId
283
 *
277
 *
284
 * PARAMETERS:  OwnerId         - Where the new owner ID is returned
278
 * PARAMETERS:  OwnerId         - Where the new owner ID is returned
285
 *
279
 *
286
 * RETURN:      Status
280
 * RETURN:      Status
287
 *
281
 *
288
 * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
282
 * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
289
 *              track objects created by the table or method, to be deleted
283
 *              track objects created by the table or method, to be deleted
290
 *              when the method exits or the table is unloaded.
284
 *              when the method exits or the table is unloaded.
291
 *
285
 *
292
 ******************************************************************************/
286
 ******************************************************************************/
293
 
287
 
294
ACPI_STATUS
288
ACPI_STATUS
295
AcpiUtAllocateOwnerId (
289
AcpiUtAllocateOwnerId (
296
    ACPI_OWNER_ID           *OwnerId)
290
    ACPI_OWNER_ID           *OwnerId)
297
{
291
{
298
    UINT32                  i;
292
    UINT32                  i;
299
    UINT32                  j;
293
    UINT32                  j;
300
    UINT32                  k;
294
    UINT32                  k;
301
    ACPI_STATUS             Status;
295
    ACPI_STATUS             Status;
302
 
296
 
303
 
297
 
304
    ACPI_FUNCTION_TRACE (UtAllocateOwnerId);
298
    ACPI_FUNCTION_TRACE (UtAllocateOwnerId);
305
 
299
 
306
 
300
 
307
    /* Guard against multiple allocations of ID to the same location */
301
    /* Guard against multiple allocations of ID to the same location */
308
 
302
 
309
    if (*OwnerId)
303
    if (*OwnerId)
310
    {
304
    {
311
        ACPI_ERROR ((AE_INFO, "Owner ID [0x%2.2X] already exists", *OwnerId));
305
        ACPI_ERROR ((AE_INFO, "Owner ID [0x%2.2X] already exists", *OwnerId));
312
        return_ACPI_STATUS (AE_ALREADY_EXISTS);
306
        return_ACPI_STATUS (AE_ALREADY_EXISTS);
313
    }
307
    }
314
 
308
 
315
    /* Mutex for the global ID mask */
309
    /* Mutex for the global ID mask */
316
 
310
 
317
    Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
311
    Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
318
    if (ACPI_FAILURE (Status))
312
    if (ACPI_FAILURE (Status))
319
    {
313
    {
320
        return_ACPI_STATUS (Status);
314
        return_ACPI_STATUS (Status);
321
    }
315
    }
322
 
316
 
323
    /*
317
    /*
324
     * Find a free owner ID, cycle through all possible IDs on repeated
318
     * Find a free owner ID, cycle through all possible IDs on repeated
325
     * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
319
     * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have
326
     * to be scanned twice.
320
     * to be scanned twice.
327
     */
321
     */
328
    for (i = 0, j = AcpiGbl_LastOwnerIdIndex;
322
    for (i = 0, j = AcpiGbl_LastOwnerIdIndex;
329
         i < (ACPI_NUM_OWNERID_MASKS + 1);
323
         i < (ACPI_NUM_OWNERID_MASKS + 1);
330
         i++, j++)
324
         i++, j++)
331
    {
325
    {
332
        if (j >= ACPI_NUM_OWNERID_MASKS)
326
        if (j >= ACPI_NUM_OWNERID_MASKS)
333
        {
327
        {
334
            j = 0;  /* Wraparound to start of mask array */
328
            j = 0;  /* Wraparound to start of mask array */
335
        }
329
        }
336
 
330
 
337
        for (k = AcpiGbl_NextOwnerIdOffset; k < 32; k++)
331
        for (k = AcpiGbl_NextOwnerIdOffset; k < 32; k++)
338
        {
332
        {
339
            if (AcpiGbl_OwnerIdMask[j] == ACPI_UINT32_MAX)
333
            if (AcpiGbl_OwnerIdMask[j] == ACPI_UINT32_MAX)
340
            {
334
            {
341
                /* There are no free IDs in this mask */
335
                /* There are no free IDs in this mask */
342
 
336
 
343
                break;
337
                break;
344
            }
338
            }
345
 
339
 
346
            if (!(AcpiGbl_OwnerIdMask[j] & (1 << k)))
340
            if (!(AcpiGbl_OwnerIdMask[j] & (1 << k)))
347
            {
341
            {
348
                /*
342
                /*
349
                 * Found a free ID. The actual ID is the bit index plus one,
343
                 * Found a free ID. The actual ID is the bit index plus one,
350
                 * making zero an invalid Owner ID. Save this as the last ID
344
                 * making zero an invalid Owner ID. Save this as the last ID
351
                 * allocated and update the global ID mask.
345
                 * allocated and update the global ID mask.
352
                 */
346
                 */
353
                AcpiGbl_OwnerIdMask[j] |= (1 << k);
347
                AcpiGbl_OwnerIdMask[j] |= (1 << k);
354
 
348
 
355
                AcpiGbl_LastOwnerIdIndex = (UINT8) j;
349
                AcpiGbl_LastOwnerIdIndex = (UINT8) j;
356
                AcpiGbl_NextOwnerIdOffset = (UINT8) (k + 1);
350
                AcpiGbl_NextOwnerIdOffset = (UINT8) (k + 1);
357
 
351
 
358
                /*
352
                /*
359
                 * Construct encoded ID from the index and bit position
353
                 * Construct encoded ID from the index and bit position
360
                 *
354
                 *
361
                 * Note: Last [j].k (bit 255) is never used and is marked
355
                 * Note: Last [j].k (bit 255) is never used and is marked
362
                 * permanently allocated (prevents +1 overflow)
356
                 * permanently allocated (prevents +1 overflow)
363
                 */
357
                 */
364
                *OwnerId = (ACPI_OWNER_ID) ((k + 1) + ACPI_MUL_32 (j));
358
                *OwnerId = (ACPI_OWNER_ID) ((k + 1) + ACPI_MUL_32 (j));
365
 
359
 
366
                ACPI_DEBUG_PRINT ((ACPI_DB_VALUES,
360
                ACPI_DEBUG_PRINT ((ACPI_DB_VALUES,
367
                    "Allocated OwnerId: %2.2X\n", (unsigned int) *OwnerId));
361
                    "Allocated OwnerId: %2.2X\n", (unsigned int) *OwnerId));
368
                goto Exit;
362
                goto Exit;
369
            }
363
            }
370
        }
364
        }
371
 
365
 
372
        AcpiGbl_NextOwnerIdOffset = 0;
366
        AcpiGbl_NextOwnerIdOffset = 0;
373
    }
367
    }
374
 
368
 
375
    /*
369
    /*
376
     * All OwnerIds have been allocated. This typically should
370
     * All OwnerIds have been allocated. This typically should
377
     * not happen since the IDs are reused after deallocation. The IDs are
371
     * not happen since the IDs are reused after deallocation. The IDs are
378
     * allocated upon table load (one per table) and method execution, and
372
     * allocated upon table load (one per table) and method execution, and
379
     * they are released when a table is unloaded or a method completes
373
     * they are released when a table is unloaded or a method completes
380
     * execution.
374
     * execution.
381
     *
375
     *
382
     * If this error happens, there may be very deep nesting of invoked control
376
     * If this error happens, there may be very deep nesting of invoked control
383
     * methods, or there may be a bug where the IDs are not released.
377
     * methods, or there may be a bug where the IDs are not released.
384
     */
378
     */
385
    Status = AE_OWNER_ID_LIMIT;
379
    Status = AE_OWNER_ID_LIMIT;
386
    ACPI_ERROR ((AE_INFO,
380
    ACPI_ERROR ((AE_INFO,
387
        "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT"));
381
        "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT"));
388
 
382
 
389
Exit:
383
Exit:
390
    (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
384
    (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
391
    return_ACPI_STATUS (Status);
385
    return_ACPI_STATUS (Status);
392
}
386
}
393
 
387
 
394
 
388
 
395
/*******************************************************************************
389
/*******************************************************************************
396
 *
390
 *
397
 * FUNCTION:    AcpiUtReleaseOwnerId
391
 * FUNCTION:    AcpiUtReleaseOwnerId
398
 *
392
 *
399
 * PARAMETERS:  OwnerIdPtr          - Pointer to a previously allocated OwnerID
393
 * PARAMETERS:  OwnerIdPtr          - Pointer to a previously allocated OwnerID
400
 *
394
 *
401
 * RETURN:      None. No error is returned because we are either exiting a
395
 * RETURN:      None. No error is returned because we are either exiting a
402
 *              control method or unloading a table. Either way, we would
396
 *              control method or unloading a table. Either way, we would
403
 *              ignore any error anyway.
397
 *              ignore any error anyway.
404
 *
398
 *
405
 * DESCRIPTION: Release a table or method owner ID.  Valid IDs are 1 - 255
399
 * DESCRIPTION: Release a table or method owner ID.  Valid IDs are 1 - 255
406
 *
400
 *
407
 ******************************************************************************/
401
 ******************************************************************************/
408
 
402
 
409
void
403
void
410
AcpiUtReleaseOwnerId (
404
AcpiUtReleaseOwnerId (
411
    ACPI_OWNER_ID           *OwnerIdPtr)
405
    ACPI_OWNER_ID           *OwnerIdPtr)
412
{
406
{
413
    ACPI_OWNER_ID           OwnerId = *OwnerIdPtr;
407
    ACPI_OWNER_ID           OwnerId = *OwnerIdPtr;
414
    ACPI_STATUS             Status;
408
    ACPI_STATUS             Status;
415
    UINT32                  Index;
409
    UINT32                  Index;
416
    UINT32                  Bit;
410
    UINT32                  Bit;
417
 
411
 
418
 
412
 
419
    ACPI_FUNCTION_TRACE_U32 (UtReleaseOwnerId, OwnerId);
413
    ACPI_FUNCTION_TRACE_U32 (UtReleaseOwnerId, OwnerId);
420
 
414
 
421
 
415
 
422
    /* Always clear the input OwnerId (zero is an invalid ID) */
416
    /* Always clear the input OwnerId (zero is an invalid ID) */
423
 
417
 
424
    *OwnerIdPtr = 0;
418
    *OwnerIdPtr = 0;
425
 
419
 
426
    /* Zero is not a valid OwnerID */
420
    /* Zero is not a valid OwnerID */
427
 
421
 
428
    if (OwnerId == 0)
422
    if (OwnerId == 0)
429
    {
423
    {
430
        ACPI_ERROR ((AE_INFO, "Invalid OwnerId: 0x%2.2X", OwnerId));
424
        ACPI_ERROR ((AE_INFO, "Invalid OwnerId: 0x%2.2X", OwnerId));
431
        return_VOID;
425
        return_VOID;
432
    }
426
    }
433
 
427
 
434
    /* Mutex for the global ID mask */
428
    /* Mutex for the global ID mask */
435
 
429
 
436
    Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
430
    Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES);
437
    if (ACPI_FAILURE (Status))
431
    if (ACPI_FAILURE (Status))
438
    {
432
    {
439
        return_VOID;
433
        return_VOID;
440
    }
434
    }
441
 
435
 
442
    /* Normalize the ID to zero */
436
    /* Normalize the ID to zero */
443
 
437
 
444
    OwnerId--;
438
    OwnerId--;
445
 
439
 
446
    /* Decode ID to index/offset pair */
440
    /* Decode ID to index/offset pair */
447
 
441
 
448
    Index = ACPI_DIV_32 (OwnerId);
442
    Index = ACPI_DIV_32 (OwnerId);
449
    Bit = 1 << ACPI_MOD_32 (OwnerId);
443
    Bit = 1 << ACPI_MOD_32 (OwnerId);
450
 
444
 
451
    /* Free the owner ID only if it is valid */
445
    /* Free the owner ID only if it is valid */
452
 
446
 
453
    if (AcpiGbl_OwnerIdMask[Index] & Bit)
447
    if (AcpiGbl_OwnerIdMask[Index] & Bit)
454
    {
448
    {
455
        AcpiGbl_OwnerIdMask[Index] ^= Bit;
449
        AcpiGbl_OwnerIdMask[Index] ^= Bit;
456
    }
450
    }
457
    else
451
    else
458
    {
452
    {
459
        ACPI_ERROR ((AE_INFO,
453
        ACPI_ERROR ((AE_INFO,
460
            "Release of non-allocated OwnerId: 0x%2.2X", OwnerId + 1));
454
            "Release of non-allocated OwnerId: 0x%2.2X", OwnerId + 1));
461
    }
455
    }
462
 
456
 
463
    (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
457
    (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
464
    return_VOID;
458
    return_VOID;
465
}
459
}
466
 
460
 
467
 
461
 
468
/*******************************************************************************
462
/*******************************************************************************
469
 *
463
 *
470
 * FUNCTION:    AcpiUtStrupr (strupr)
464
 * FUNCTION:    AcpiUtStrupr (strupr)
471
 *
465
 *
472
 * PARAMETERS:  SrcString       - The source string to convert
466
 * PARAMETERS:  SrcString       - The source string to convert
473
 *
467
 *
474
 * RETURN:      None
468
 * RETURN:      None
475
 *
469
 *
476
 * DESCRIPTION: Convert string to uppercase
470
 * DESCRIPTION: Convert string to uppercase
477
 *
471
 *
478
 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
472
 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
479
 *
473
 *
480
 ******************************************************************************/
474
 ******************************************************************************/
481
 
475
 
482
void
476
void
483
AcpiUtStrupr (
477
AcpiUtStrupr (
484
    char                    *SrcString)
478
    char                    *SrcString)
485
{
479
{
486
    char                    *String;
480
    char                    *String;
487
 
481
 
488
 
482
 
489
    ACPI_FUNCTION_ENTRY ();
483
    ACPI_FUNCTION_ENTRY ();
490
 
484
 
491
 
485
 
492
    if (!SrcString)
486
    if (!SrcString)
493
    {
487
    {
494
        return;
488
        return;
495
    }
489
    }
496
 
490
 
497
    /* Walk entire string, uppercasing the letters */
491
    /* Walk entire string, uppercasing the letters */
498
 
492
 
499
    for (String = SrcString; *String; String++)
493
    for (String = SrcString; *String; String++)
500
    {
494
    {
501
        *String = (char) ACPI_TOUPPER (*String);
495
        *String = (char) ACPI_TOUPPER (*String);
502
    }
496
    }
503
 
497
 
504
    return;
498
    return;
505
}
499
}
506
 
500
 
-
 
501
 
-
 
502
#ifdef ACPI_ASL_COMPILER
-
 
503
/*******************************************************************************
-
 
504
 *
-
 
505
 * FUNCTION:    AcpiUtStrlwr (strlwr)
-
 
506
 *
-
 
507
 * PARAMETERS:  SrcString       - The source string to convert
-
 
508
 *
-
 
509
 * RETURN:      None
-
 
510
 *
-
 
511
 * DESCRIPTION: Convert string to lowercase
-
 
512
 *
-
 
513
 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
-
 
514
 *
-
 
515
 ******************************************************************************/
-
 
516
 
-
 
517
void
-
 
518
AcpiUtStrlwr (
-
 
519
    char                    *SrcString)
-
 
520
{
-
 
521
    char                    *String;
-
 
522
 
-
 
523
 
-
 
524
    ACPI_FUNCTION_ENTRY ();
-
 
525
 
-
 
526
 
-
 
527
    if (!SrcString)
-
 
528
    {
-
 
529
        return;
-
 
530
    }
-
 
531
 
-
 
532
    /* Walk entire string, lowercasing the letters */
-
 
533
 
-
 
534
    for (String = SrcString; *String; String++)
-
 
535
    {
-
 
536
        *String = (char) ACPI_TOLOWER (*String);
-
 
537
    }
-
 
538
 
-
 
539
    return;
-
 
540
}
-
 
541
#endif
-
 
542
 
507
 
543
 
508
/*******************************************************************************
544
/*******************************************************************************
509
 *
545
 *
510
 * FUNCTION:    AcpiUtPrintString
546
 * FUNCTION:    AcpiUtPrintString
511
 *
547
 *
512
 * PARAMETERS:  String          - Null terminated ASCII string
548
 * PARAMETERS:  String          - Null terminated ASCII string
513
 *              MaxLength       - Maximum output length
549
 *              MaxLength       - Maximum output length
514
 *
550
 *
515
 * RETURN:      None
551
 * RETURN:      None
516
 *
552
 *
517
 * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
553
 * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape
518
 *              sequences.
554
 *              sequences.
519
 *
555
 *
520
 ******************************************************************************/
556
 ******************************************************************************/
521
 
557
 
522
void
558
void
523
AcpiUtPrintString (
559
AcpiUtPrintString (
524
    char                    *String,
560
    char                    *String,
525
    UINT8                   MaxLength)
561
    UINT8                   MaxLength)
526
{
562
{
527
    UINT32                  i;
563
    UINT32                  i;
528
 
564
 
529
 
565
 
530
    if (!String)
566
    if (!String)
531
    {
567
    {
532
        AcpiOsPrintf ("<\"NULL STRING PTR\">");
568
        AcpiOsPrintf ("<\"NULL STRING PTR\">");
533
        return;
569
        return;
534
    }
570
    }
535
 
571
 
536
    AcpiOsPrintf ("\"");
572
    AcpiOsPrintf ("\"");
537
    for (i = 0; String[i] && (i < MaxLength); i++)
573
    for (i = 0; String[i] && (i < MaxLength); i++)
538
    {
574
    {
539
        /* Escape sequences */
575
        /* Escape sequences */
540
 
576
 
541
        switch (String[i])
577
        switch (String[i])
542
        {
578
        {
543
        case 0x07:
579
        case 0x07:
544
            AcpiOsPrintf ("\\a");       /* BELL */
580
            AcpiOsPrintf ("\\a");       /* BELL */
545
            break;
581
            break;
546
 
582
 
547
        case 0x08:
583
        case 0x08:
548
            AcpiOsPrintf ("\\b");       /* BACKSPACE */
584
            AcpiOsPrintf ("\\b");       /* BACKSPACE */
549
            break;
585
            break;
550
 
586
 
551
        case 0x0C:
587
        case 0x0C:
552
            AcpiOsPrintf ("\\f");       /* FORMFEED */
588
            AcpiOsPrintf ("\\f");       /* FORMFEED */
553
            break;
589
            break;
554
 
590
 
555
        case 0x0A:
591
        case 0x0A:
556
            AcpiOsPrintf ("\\n");       /* LINEFEED */
592
            AcpiOsPrintf ("\\n");       /* LINEFEED */
557
            break;
593
            break;
558
 
594
 
559
        case 0x0D:
595
        case 0x0D:
560
            AcpiOsPrintf ("\\r");       /* CARRIAGE RETURN*/
596
            AcpiOsPrintf ("\\r");       /* CARRIAGE RETURN*/
561
            break;
597
            break;
562
 
598
 
563
        case 0x09:
599
        case 0x09:
564
            AcpiOsPrintf ("\\t");       /* HORIZONTAL TAB */
600
            AcpiOsPrintf ("\\t");       /* HORIZONTAL TAB */
565
            break;
601
            break;
566
 
602
 
567
        case 0x0B:
603
        case 0x0B:
568
            AcpiOsPrintf ("\\v");       /* VERTICAL TAB */
604
            AcpiOsPrintf ("\\v");       /* VERTICAL TAB */
569
            break;
605
            break;
570
 
606
 
571
        case '\'':                      /* Single Quote */
607
        case '\'':                      /* Single Quote */
572
        case '\"':                      /* Double Quote */
608
        case '\"':                      /* Double Quote */
573
        case '\\':                      /* Backslash */
609
        case '\\':                      /* Backslash */
574
            AcpiOsPrintf ("\\%c", (int) String[i]);
610
            AcpiOsPrintf ("\\%c", (int) String[i]);
575
            break;
611
            break;
576
 
612
 
577
        default:
613
        default:
578
 
614
 
579
            /* Check for printable character or hex escape */
615
            /* Check for printable character or hex escape */
580
 
616
 
581
            if (ACPI_IS_PRINT (String[i]))
617
            if (ACPI_IS_PRINT (String[i]))
582
            {
618
            {
583
                /* This is a normal character */
619
                /* This is a normal character */
584
 
620
 
585
                AcpiOsPrintf ("%c", (int) String[i]);
621
                AcpiOsPrintf ("%c", (int) String[i]);
586
            }
622
            }
587
            else
623
            else
588
            {
624
            {
589
                /* All others will be Hex escapes */
625
                /* All others will be Hex escapes */
590
 
626
 
591
                AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]);
627
                AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]);
592
            }
628
            }
593
            break;
629
            break;
594
        }
630
        }
595
    }
631
    }
596
    AcpiOsPrintf ("\"");
632
    AcpiOsPrintf ("\"");
597
 
633
 
598
    if (i == MaxLength && String[i])
634
    if (i == MaxLength && String[i])
599
    {
635
    {
600
        AcpiOsPrintf ("...");
636
        AcpiOsPrintf ("...");
601
    }
637
    }
602
}
638
}
603
 
639
 
604
 
640
 
605
/*******************************************************************************
641
/*******************************************************************************
606
 *
642
 *
607
 * FUNCTION:    AcpiUtDwordByteSwap
643
 * FUNCTION:    AcpiUtDwordByteSwap
608
 *
644
 *
609
 * PARAMETERS:  Value           - Value to be converted
645
 * PARAMETERS:  Value           - Value to be converted
610
 *
646
 *
611
 * RETURN:      UINT32 integer with bytes swapped
647
 * RETURN:      UINT32 integer with bytes swapped
612
 *
648
 *
613
 * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
649
 * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
614
 *
650
 *
615
 ******************************************************************************/
651
 ******************************************************************************/
616
 
652
 
617
UINT32
653
UINT32
618
AcpiUtDwordByteSwap (
654
AcpiUtDwordByteSwap (
619
    UINT32                  Value)
655
    UINT32                  Value)
620
{
656
{
621
    union
657
    union
622
    {
658
    {
623
        UINT32              Value;
659
        UINT32              Value;
624
        UINT8               Bytes[4];
660
        UINT8               Bytes[4];
625
    } Out;
661
    } Out;
626
    union
662
    union
627
    {
663
    {
628
        UINT32              Value;
664
        UINT32              Value;
629
        UINT8               Bytes[4];
665
        UINT8               Bytes[4];
630
    } In;
666
    } In;
631
 
667
 
632
 
668
 
633
    ACPI_FUNCTION_ENTRY ();
669
    ACPI_FUNCTION_ENTRY ();
634
 
670
 
635
 
671
 
636
    In.Value = Value;
672
    In.Value = Value;
637
 
673
 
638
    Out.Bytes[0] = In.Bytes[3];
674
    Out.Bytes[0] = In.Bytes[3];
639
    Out.Bytes[1] = In.Bytes[2];
675
    Out.Bytes[1] = In.Bytes[2];
640
    Out.Bytes[2] = In.Bytes[1];
676
    Out.Bytes[2] = In.Bytes[1];
641
    Out.Bytes[3] = In.Bytes[0];
677
    Out.Bytes[3] = In.Bytes[0];
642
 
678
 
643
    return (Out.Value);
679
    return (Out.Value);
644
}
680
}
645
 
681
 
646
 
682
 
647
/*******************************************************************************
683
/*******************************************************************************
648
 *
684
 *
649
 * FUNCTION:    AcpiUtSetIntegerWidth
685
 * FUNCTION:    AcpiUtSetIntegerWidth
650
 *
686
 *
651
 * PARAMETERS:  Revision            From DSDT header
687
 * PARAMETERS:  Revision            From DSDT header
652
 *
688
 *
653
 * RETURN:      None
689
 * RETURN:      None
654
 *
690
 *
655
 * DESCRIPTION: Set the global integer bit width based upon the revision
691
 * DESCRIPTION: Set the global integer bit width based upon the revision
656
 *              of the DSDT.  For Revision 1 and 0, Integers are 32 bits.
692
 *              of the DSDT.  For Revision 1 and 0, Integers are 32 bits.
657
 *              For Revision 2 and above, Integers are 64 bits.  Yes, this
693
 *              For Revision 2 and above, Integers are 64 bits.  Yes, this
658
 *              makes a difference.
694
 *              makes a difference.
659
 *
695
 *
660
 ******************************************************************************/
696
 ******************************************************************************/
661
 
697
 
662
void
698
void
663
AcpiUtSetIntegerWidth (
699
AcpiUtSetIntegerWidth (
664
    UINT8                   Revision)
700
    UINT8                   Revision)
665
{
701
{
666
 
702
 
667
    if (Revision < 2)
703
    if (Revision < 2)
668
    {
704
    {
669
        /* 32-bit case */
705
        /* 32-bit case */
670
 
706
 
671
        AcpiGbl_IntegerBitWidth    = 32;
707
        AcpiGbl_IntegerBitWidth    = 32;
672
        AcpiGbl_IntegerNybbleWidth = 8;
708
        AcpiGbl_IntegerNybbleWidth = 8;
673
        AcpiGbl_IntegerByteWidth   = 4;
709
        AcpiGbl_IntegerByteWidth   = 4;
674
    }
710
    }
675
    else
711
    else
676
    {
712
    {
677
        /* 64-bit case (ACPI 2.0+) */
713
        /* 64-bit case (ACPI 2.0+) */
678
 
714
 
679
        AcpiGbl_IntegerBitWidth    = 64;
715
        AcpiGbl_IntegerBitWidth    = 64;
680
        AcpiGbl_IntegerNybbleWidth = 16;
716
        AcpiGbl_IntegerNybbleWidth = 16;
681
        AcpiGbl_IntegerByteWidth   = 8;
717
        AcpiGbl_IntegerByteWidth   = 8;
682
    }
718
    }
683
}
719
}
684
 
720
 
685
 
721
 
686
#ifdef ACPI_DEBUG_OUTPUT
722
#ifdef ACPI_DEBUG_OUTPUT
687
/*******************************************************************************
723
/*******************************************************************************
688
 *
724
 *
689
 * FUNCTION:    AcpiUtDisplayInitPathname
725
 * FUNCTION:    AcpiUtDisplayInitPathname
690
 *
726
 *
691
 * PARAMETERS:  Type                - Object type of the node
727
 * PARAMETERS:  Type                - Object type of the node
692
 *              ObjHandle           - Handle whose pathname will be displayed
728
 *              ObjHandle           - Handle whose pathname will be displayed
693
 *              Path                - Additional path string to be appended.
729
 *              Path                - Additional path string to be appended.
694
 *                                      (NULL if no extra path)
730
 *                                      (NULL if no extra path)
695
 *
731
 *
696
 * RETURN:      ACPI_STATUS
732
 * RETURN:      ACPI_STATUS
697
 *
733
 *
698
 * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
734
 * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
699
 *
735
 *
700
 ******************************************************************************/
736
 ******************************************************************************/
701
 
737
 
702
void
738
void
703
AcpiUtDisplayInitPathname (
739
AcpiUtDisplayInitPathname (
704
    UINT8                   Type,
740
    UINT8                   Type,
705
    ACPI_NAMESPACE_NODE     *ObjHandle,
741
    ACPI_NAMESPACE_NODE     *ObjHandle,
706
    char                    *Path)
742
    char                    *Path)
707
{
743
{
708
    ACPI_STATUS             Status;
744
    ACPI_STATUS             Status;
709
    ACPI_BUFFER             Buffer;
745
    ACPI_BUFFER             Buffer;
710
 
746
 
711
 
747
 
712
    ACPI_FUNCTION_ENTRY ();
748
    ACPI_FUNCTION_ENTRY ();
713
 
749
 
714
 
750
 
715
    /* Only print the path if the appropriate debug level is enabled */
751
    /* Only print the path if the appropriate debug level is enabled */
716
 
752
 
717
    if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
753
    if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
718
    {
754
    {
719
        return;
755
        return;
720
    }
756
    }
721
 
757
 
722
    /* Get the full pathname to the node */
758
    /* Get the full pathname to the node */
723
 
759
 
724
    Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
760
    Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
725
    Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
761
    Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
726
    if (ACPI_FAILURE (Status))
762
    if (ACPI_FAILURE (Status))
727
    {
763
    {
728
        return;
764
        return;
729
    }
765
    }
730
 
766
 
731
    /* Print what we're doing */
767
    /* Print what we're doing */
732
 
768
 
733
    switch (Type)
769
    switch (Type)
734
    {
770
    {
735
    case ACPI_TYPE_METHOD:
771
    case ACPI_TYPE_METHOD:
736
        AcpiOsPrintf ("Executing    ");
772
        AcpiOsPrintf ("Executing    ");
737
        break;
773
        break;
738
 
774
 
739
    default:
775
    default:
740
        AcpiOsPrintf ("Initializing ");
776
        AcpiOsPrintf ("Initializing ");
741
        break;
777
        break;
742
    }
778
    }
743
 
779
 
744
    /* Print the object type and pathname */
780
    /* Print the object type and pathname */
745
 
781
 
746
    AcpiOsPrintf ("%-12s  %s",
782
    AcpiOsPrintf ("%-12s  %s",
747
        AcpiUtGetTypeName (Type), (char *) Buffer.Pointer);
783
        AcpiUtGetTypeName (Type), (char *) Buffer.Pointer);
748
 
784
 
749
    /* Extra path is used to append names like _STA, _INI, etc. */
785
    /* Extra path is used to append names like _STA, _INI, etc. */
750
 
786
 
751
    if (Path)
787
    if (Path)
752
    {
788
    {
753
        AcpiOsPrintf (".%s", Path);
789
        AcpiOsPrintf (".%s", Path);
754
    }
790
    }
755
    AcpiOsPrintf ("\n");
791
    AcpiOsPrintf ("\n");
756
 
792
 
757
    ACPI_FREE (Buffer.Pointer);
793
    ACPI_FREE (Buffer.Pointer);
758
}
794
}
759
#endif
795
#endif
760
 
796
 
761
 
797
 
762
/*******************************************************************************
798
/*******************************************************************************
763
 *
799
 *
764
 * FUNCTION:    AcpiUtValidAcpiChar
800
 * FUNCTION:    AcpiUtValidAcpiChar
765
 *
801
 *
766
 * PARAMETERS:  Char            - The character to be examined
802
 * PARAMETERS:  Char            - The character to be examined
767
 *              Position        - Byte position (0-3)
803
 *              Position        - Byte position (0-3)
768
 *
804
 *
769
 * RETURN:      TRUE if the character is valid, FALSE otherwise
805
 * RETURN:      TRUE if the character is valid, FALSE otherwise
770
 *
806
 *
771
 * DESCRIPTION: Check for a valid ACPI character. Must be one of:
807
 * DESCRIPTION: Check for a valid ACPI character. Must be one of:
772
 *              1) Upper case alpha
808
 *              1) Upper case alpha
773
 *              2) numeric
809
 *              2) numeric
774
 *              3) underscore
810
 *              3) underscore
775
 *
811
 *
776
 *              We allow a '!' as the last character because of the ASF! table
812
 *              We allow a '!' as the last character because of the ASF! table
777
 *
813
 *
778
 ******************************************************************************/
814
 ******************************************************************************/
779
 
815
 
780
BOOLEAN
816
BOOLEAN
781
AcpiUtValidAcpiChar (
817
AcpiUtValidAcpiChar (
782
    char                    Character,
818
    char                    Character,
783
    UINT32                  Position)
819
    UINT32                  Position)
784
{
820
{
785
 
821
 
786
    if (!((Character >= 'A' && Character <= 'Z') ||
822
    if (!((Character >= 'A' && Character <= 'Z') ||
787
          (Character >= '0' && Character <= '9') ||
823
          (Character >= '0' && Character <= '9') ||
788
          (Character == '_')))
824
          (Character == '_')))
789
    {
825
    {
790
        /* Allow a '!' in the last position */
826
        /* Allow a '!' in the last position */
791
 
827
 
792
        if (Character == '!' && Position == 3)
828
        if (Character == '!' && Position == 3)
793
        {
829
        {
794
            return (TRUE);
830
            return (TRUE);
795
        }
831
        }
796
 
832
 
797
        return (FALSE);
833
        return (FALSE);
798
    }
834
    }
799
 
835
 
800
    return (TRUE);
836
    return (TRUE);
801
}
837
}
802
 
838
 
803
 
839
 
804
/*******************************************************************************
840
/*******************************************************************************
805
 *
841
 *
806
 * FUNCTION:    AcpiUtValidAcpiName
842
 * FUNCTION:    AcpiUtValidAcpiName
807
 *
843
 *
808
 * PARAMETERS:  Name            - The name to be examined
844
 * PARAMETERS:  Name            - The name to be examined
809
 *
845
 *
810
 * RETURN:      TRUE if the name is valid, FALSE otherwise
846
 * RETURN:      TRUE if the name is valid, FALSE otherwise
811
 *
847
 *
812
 * DESCRIPTION: Check for a valid ACPI name.  Each character must be one of:
848
 * DESCRIPTION: Check for a valid ACPI name.  Each character must be one of:
813
 *              1) Upper case alpha
849
 *              1) Upper case alpha
814
 *              2) numeric
850
 *              2) numeric
815
 *              3) underscore
851
 *              3) underscore
816
 *
852
 *
817
 ******************************************************************************/
853
 ******************************************************************************/
818
 
854
 
819
BOOLEAN
855
BOOLEAN
820
AcpiUtValidAcpiName (
856
AcpiUtValidAcpiName (
821
    UINT32                  Name)
857
    UINT32                  Name)
822
{
858
{
823
    UINT32                  i;
859
    UINT32                  i;
824
 
860
 
825
 
861
 
826
    ACPI_FUNCTION_ENTRY ();
862
    ACPI_FUNCTION_ENTRY ();
827
 
863
 
828
 
864
 
829
    for (i = 0; i < ACPI_NAME_SIZE; i++)
865
    for (i = 0; i < ACPI_NAME_SIZE; i++)
830
    {
866
    {
831
        if (!AcpiUtValidAcpiChar ((ACPI_CAST_PTR (char, &Name))[i], i))
867
        if (!AcpiUtValidAcpiChar ((ACPI_CAST_PTR (char, &Name))[i], i))
832
        {
868
        {
833
            return (FALSE);
869
            return (FALSE);
834
        }
870
        }
835
    }
871
    }
836
 
872
 
837
    return (TRUE);
873
    return (TRUE);
838
}
874
}
839
 
875
 
840
 
876
 
841
/*******************************************************************************
877
/*******************************************************************************
842
 *
878
 *
843
 * FUNCTION:    AcpiUtRepairName
879
 * FUNCTION:    AcpiUtRepairName
844
 *
880
 *
845
 * PARAMETERS:  Name            - The ACPI name to be repaired
881
 * PARAMETERS:  Name            - The ACPI name to be repaired
846
 *
882
 *
847
 * RETURN:      Repaired version of the name
883
 * RETURN:      Repaired version of the name
848
 *
884
 *
849
 * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and
885
 * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and
850
 *              return the new name. NOTE: the Name parameter must reside in
886
 *              return the new name. NOTE: the Name parameter must reside in
851
 *              read/write memory, cannot be a const.
887
 *              read/write memory, cannot be a const.
852
 *
888
 *
853
 * An ACPI Name must consist of valid ACPI characters. We will repair the name
889
 * An ACPI Name must consist of valid ACPI characters. We will repair the name
854
 * if necessary because we don't want to abort because of this, but we want
890
 * if necessary because we don't want to abort because of this, but we want
855
 * all namespace names to be printable. A warning message is appropriate.
891
 * all namespace names to be printable. A warning message is appropriate.
856
 *
892
 *
857
 * This issue came up because there are in fact machines that exhibit
893
 * This issue came up because there are in fact machines that exhibit
858
 * this problem, and we want to be able to enable ACPI support for them,
894
 * this problem, and we want to be able to enable ACPI support for them,
859
 * even though there are a few bad names.
895
 * even though there are a few bad names.
860
 *
896
 *
861
 ******************************************************************************/
897
 ******************************************************************************/
862
 
898
 
863
void
899
void
864
AcpiUtRepairName (
900
AcpiUtRepairName (
865
    char                    *Name)
901
    char                    *Name)
866
{
902
{
867
    UINT32                  i;
903
    UINT32                  i;
868
    BOOLEAN                 FoundBadChar = FALSE;
904
    BOOLEAN                 FoundBadChar = FALSE;
869
 
905
 
870
 
906
 
871
    ACPI_FUNCTION_NAME (UtRepairName);
907
    ACPI_FUNCTION_NAME (UtRepairName);
872
 
908
 
873
 
909
 
874
    /* Check each character in the name */
910
    /* Check each character in the name */
875
 
911
 
876
    for (i = 0; i < ACPI_NAME_SIZE; i++)
912
    for (i = 0; i < ACPI_NAME_SIZE; i++)
877
    {
913
    {
878
        if (AcpiUtValidAcpiChar (Name[i], i))
914
        if (AcpiUtValidAcpiChar (Name[i], i))
879
        {
915
        {
880
            continue;
916
            continue;
881
        }
917
        }
882
 
918
 
883
        /*
919
        /*
884
         * Replace a bad character with something printable, yet technically
920
         * Replace a bad character with something printable, yet technically
885
         * still invalid. This prevents any collisions with existing "good"
921
         * still invalid. This prevents any collisions with existing "good"
886
         * names in the namespace.
922
         * names in the namespace.
887
         */
923
         */
888
        Name[i] = '*';
924
        Name[i] = '*';
889
        FoundBadChar = TRUE;
925
        FoundBadChar = TRUE;
890
    }
926
    }
891
 
927
 
892
    if (FoundBadChar)
928
    if (FoundBadChar)
893
    {
929
    {
894
        /* Report warning only if in strict mode or debug mode */
930
        /* Report warning only if in strict mode or debug mode */
895
 
931
 
896
        if (!AcpiGbl_EnableInterpreterSlack)
932
        if (!AcpiGbl_EnableInterpreterSlack)
897
        {
933
        {
898
            ACPI_WARNING ((AE_INFO,
934
            ACPI_WARNING ((AE_INFO,
899
                "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
935
                "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
900
        }
936
        }
901
        else
937
        else
902
        {
938
        {
903
            ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
939
            ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
904
                "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
940
                "Found bad character(s) in name, repaired: [%4.4s]\n", Name));
905
        }
941
        }
906
    }
942
    }
907
}
943
}
908
 
944
 
909
 
945
 
910
/*******************************************************************************
946
/*******************************************************************************
911
 *
947
 *
912
 * FUNCTION:    AcpiUtStrtoul64
948
 * FUNCTION:    AcpiUtStrtoul64
913
 *
949
 *
914
 * PARAMETERS:  String          - Null terminated string
950
 * PARAMETERS:  String          - Null terminated string
915
 *              Base            - Radix of the string: 16 or ACPI_ANY_BASE;
951
 *              Base            - Radix of the string: 16 or ACPI_ANY_BASE;
916
 *                                ACPI_ANY_BASE means 'in behalf of ToInteger'
952
 *                                ACPI_ANY_BASE means 'in behalf of ToInteger'
917
 *              RetInteger      - Where the converted integer is returned
953
 *              RetInteger      - Where the converted integer is returned
918
 *
954
 *
919
 * RETURN:      Status and Converted value
955
 * RETURN:      Status and Converted value
920
 *
956
 *
921
 * DESCRIPTION: Convert a string into an unsigned value. Performs either a
957
 * DESCRIPTION: Convert a string into an unsigned value. Performs either a
922
 *              32-bit or 64-bit conversion, depending on the current mode
958
 *              32-bit or 64-bit conversion, depending on the current mode
923
 *              of the interpreter.
959
 *              of the interpreter.
924
 *              NOTE: Does not support Octal strings, not needed.
960
 *              NOTE: Does not support Octal strings, not needed.
925
 *
961
 *
926
 ******************************************************************************/
962
 ******************************************************************************/
927
 
963
 
928
ACPI_STATUS
964
ACPI_STATUS
929
AcpiUtStrtoul64 (
965
AcpiUtStrtoul64 (
930
    char                    *String,
966
    char                    *String,
931
    UINT32                  Base,
967
    UINT32                  Base,
932
    UINT64                  *RetInteger)
968
    UINT64                  *RetInteger)
933
{
969
{
934
    UINT32                  ThisDigit = 0;
970
    UINT32                  ThisDigit = 0;
935
    UINT64                  ReturnValue = 0;
971
    UINT64                  ReturnValue = 0;
936
    UINT64                  Quotient;
972
    UINT64                  Quotient;
937
    UINT64                  Dividend;
973
    UINT64                  Dividend;
938
    UINT32                  ToIntegerOp = (Base == ACPI_ANY_BASE);
974
    UINT32                  ToIntegerOp = (Base == ACPI_ANY_BASE);
939
    UINT32                  Mode32 = (AcpiGbl_IntegerByteWidth == 4);
975
    UINT32                  Mode32 = (AcpiGbl_IntegerByteWidth == 4);
940
    UINT8                   ValidDigits = 0;
976
    UINT8                   ValidDigits = 0;
941
    UINT8                   SignOf0x = 0;
977
    UINT8                   SignOf0x = 0;
942
    UINT8                   Term = 0;
978
    UINT8                   Term = 0;
943
 
979
 
944
 
980
 
945
    ACPI_FUNCTION_TRACE_STR (UtStroul64, String);
981
    ACPI_FUNCTION_TRACE_STR (UtStroul64, String);
946
 
982
 
947
 
983
 
948
    switch (Base)
984
    switch (Base)
949
    {
985
    {
950
    case ACPI_ANY_BASE:
986
    case ACPI_ANY_BASE:
951
    case 16:
987
    case 16:
952
        break;
988
        break;
953
 
989
 
954
    default:
990
    default:
955
        /* Invalid Base */
991
        /* Invalid Base */
956
        return_ACPI_STATUS (AE_BAD_PARAMETER);
992
        return_ACPI_STATUS (AE_BAD_PARAMETER);
957
    }
993
    }
958
 
994
 
959
    if (!String)
995
    if (!String)
960
    {
996
    {
961
        goto ErrorExit;
997
        goto ErrorExit;
962
    }
998
    }
963
 
999
 
964
    /* Skip over any white space in the buffer */
1000
    /* Skip over any white space in the buffer */
965
 
1001
 
966
    while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t'))
1002
    while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t'))
967
    {
1003
    {
968
        String++;
1004
        String++;
969
    }
1005
    }
970
 
1006
 
971
    if (ToIntegerOp)
1007
    if (ToIntegerOp)
972
    {
1008
    {
973
        /*
1009
        /*
974
         * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
1010
         * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
975
         * We need to determine if it is decimal or hexadecimal.
1011
         * We need to determine if it is decimal or hexadecimal.
976
         */
1012
         */
977
        if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x'))
1013
        if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x'))
978
        {
1014
        {
979
            SignOf0x = 1;
1015
            SignOf0x = 1;
980
            Base = 16;
1016
            Base = 16;
981
 
1017
 
982
            /* Skip over the leading '0x' */
1018
            /* Skip over the leading '0x' */
983
            String += 2;
1019
            String += 2;
984
        }
1020
        }
985
        else
1021
        else
986
        {
1022
        {
987
            Base = 10;
1023
            Base = 10;
988
        }
1024
        }
989
    }
1025
    }
990
 
1026
 
991
    /* Any string left? Check that '0x' is not followed by white space. */
1027
    /* Any string left? Check that '0x' is not followed by white space. */
992
 
1028
 
993
    if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t')
1029
    if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t')
994
    {
1030
    {
995
        if (ToIntegerOp)
1031
        if (ToIntegerOp)
996
        {
1032
        {
997
            goto ErrorExit;
1033
            goto ErrorExit;
998
        }
1034
        }
999
        else
1035
        else
1000
        {
1036
        {
1001
            goto AllDone;
1037
            goto AllDone;
1002
        }
1038
        }
1003
    }
1039
    }
1004
 
1040
 
1005
    /*
1041
    /*
1006
     * Perform a 32-bit or 64-bit conversion, depending upon the current
1042
     * Perform a 32-bit or 64-bit conversion, depending upon the current
1007
     * execution mode of the interpreter
1043
     * execution mode of the interpreter
1008
     */
1044
     */
1009
    Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
1045
    Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
1010
 
1046
 
1011
    /* Main loop: convert the string to a 32- or 64-bit integer */
1047
    /* Main loop: convert the string to a 32- or 64-bit integer */
1012
 
1048
 
1013
    while (*String)
1049
    while (*String)
1014
    {
1050
    {
1015
        if (ACPI_IS_DIGIT (*String))
1051
        if (ACPI_IS_DIGIT (*String))
1016
        {
1052
        {
1017
            /* Convert ASCII 0-9 to Decimal value */
1053
            /* Convert ASCII 0-9 to Decimal value */
1018
 
1054
 
1019
            ThisDigit = ((UINT8) *String) - '0';
1055
            ThisDigit = ((UINT8) *String) - '0';
1020
        }
1056
        }
1021
        else if (Base == 10)
1057
        else if (Base == 10)
1022
        {
1058
        {
1023
            /* Digit is out of range; possible in ToInteger case only */
1059
            /* Digit is out of range; possible in ToInteger case only */
1024
 
1060
 
1025
            Term = 1;
1061
            Term = 1;
1026
        }
1062
        }
1027
        else
1063
        else
1028
        {
1064
        {
1029
            ThisDigit = (UINT8) ACPI_TOUPPER (*String);
1065
            ThisDigit = (UINT8) ACPI_TOUPPER (*String);
1030
            if (ACPI_IS_XDIGIT ((char) ThisDigit))
1066
            if (ACPI_IS_XDIGIT ((char) ThisDigit))
1031
            {
1067
            {
1032
                /* Convert ASCII Hex char to value */
1068
                /* Convert ASCII Hex char to value */
1033
 
1069
 
1034
                ThisDigit = ThisDigit - 'A' + 10;
1070
                ThisDigit = ThisDigit - 'A' + 10;
1035
            }
1071
            }
1036
            else
1072
            else
1037
            {
1073
            {
1038
                Term = 1;
1074
                Term = 1;
1039
            }
1075
            }
1040
        }
1076
        }
1041
 
1077
 
1042
        if (Term)
1078
        if (Term)
1043
        {
1079
        {
1044
            if (ToIntegerOp)
1080
            if (ToIntegerOp)
1045
            {
1081
            {
1046
                goto ErrorExit;
1082
                goto ErrorExit;
1047
            }
1083
            }
1048
            else
1084
            else
1049
            {
1085
            {
1050
                break;
1086
                break;
1051
            }
1087
            }
1052
        }
1088
        }
1053
        else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x)
1089
        else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x)
1054
        {
1090
        {
1055
            /* Skip zeros */
1091
            /* Skip zeros */
1056
            String++;
1092
            String++;
1057
            continue;
1093
            continue;
1058
        }
1094
        }
1059
 
1095
 
1060
        ValidDigits++;
1096
        ValidDigits++;
1061
 
1097
 
1062
        if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32)))
1098
        if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32)))
1063
        {
1099
        {
1064
            /*
1100
            /*
1065
             * This is ToInteger operation case.
1101
             * This is ToInteger operation case.
1066
             * No any restrictions for string-to-integer conversion,
1102
             * No any restrictions for string-to-integer conversion,
1067
             * see ACPI spec.
1103
             * see ACPI spec.
1068
             */
1104
             */
1069
            goto ErrorExit;
1105
            goto ErrorExit;
1070
        }
1106
        }
1071
 
1107
 
1072
        /* Divide the digit into the correct position */
1108
        /* Divide the digit into the correct position */
1073
 
1109
 
1074
        (void) AcpiUtShortDivide ((Dividend - (UINT64) ThisDigit),
1110
        (void) AcpiUtShortDivide ((Dividend - (UINT64) ThisDigit),
1075
                    Base, &Quotient, NULL);
1111
                    Base, &Quotient, NULL);
1076
 
1112
 
1077
        if (ReturnValue > Quotient)
1113
        if (ReturnValue > Quotient)
1078
        {
1114
        {
1079
            if (ToIntegerOp)
1115
            if (ToIntegerOp)
1080
            {
1116
            {
1081
                goto ErrorExit;
1117
                goto ErrorExit;
1082
            }
1118
            }
1083
            else
1119
            else
1084
            {
1120
            {
1085
                break;
1121
                break;
1086
            }
1122
            }
1087
        }
1123
        }
1088
 
1124
 
1089
        ReturnValue *= Base;
1125
        ReturnValue *= Base;
1090
        ReturnValue += ThisDigit;
1126
        ReturnValue += ThisDigit;
1091
        String++;
1127
        String++;
1092
    }
1128
    }
1093
 
1129
 
1094
    /* All done, normal exit */
1130
    /* All done, normal exit */
1095
 
1131
 
1096
AllDone:
1132
AllDone:
1097
 
1133
 
1098
    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
1134
    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
1099
        ACPI_FORMAT_UINT64 (ReturnValue)));
1135
        ACPI_FORMAT_UINT64 (ReturnValue)));
1100
 
1136
 
1101
    *RetInteger = ReturnValue;
1137
    *RetInteger = ReturnValue;
1102
    return_ACPI_STATUS (AE_OK);
1138
    return_ACPI_STATUS (AE_OK);
1103
 
1139
 
1104
 
1140
 
1105
ErrorExit:
1141
ErrorExit:
1106
    /* Base was set/validated above */
1142
    /* Base was set/validated above */
1107
 
1143
 
1108
    if (Base == 10)
1144
    if (Base == 10)
1109
    {
1145
    {
1110
        return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT);
1146
        return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT);
1111
    }
1147
    }
1112
    else
1148
    else
1113
    {
1149
    {
1114
        return_ACPI_STATUS (AE_BAD_HEX_CONSTANT);
1150
        return_ACPI_STATUS (AE_BAD_HEX_CONSTANT);
1115
    }
1151
    }
1116
}
1152
}
1117
 
1153
 
1118
 
1154
 
1119
/*******************************************************************************
1155
/*******************************************************************************
1120
 *
1156
 *
1121
 * FUNCTION:    AcpiUtCreateUpdateStateAndPush
1157
 * FUNCTION:    AcpiUtCreateUpdateStateAndPush
1122
 *
1158
 *
1123
 * PARAMETERS:  Object          - Object to be added to the new state
1159
 * PARAMETERS:  Object          - Object to be added to the new state
1124
 *              Action          - Increment/Decrement
1160
 *              Action          - Increment/Decrement
1125
 *              StateList       - List the state will be added to
1161
 *              StateList       - List the state will be added to
1126
 *
1162
 *
1127
 * RETURN:      Status
1163
 * RETURN:      Status
1128
 *
1164
 *
1129
 * DESCRIPTION: Create a new state and push it
1165
 * DESCRIPTION: Create a new state and push it
1130
 *
1166
 *
1131
 ******************************************************************************/
1167
 ******************************************************************************/
1132
 
1168
 
1133
ACPI_STATUS
1169
ACPI_STATUS
1134
AcpiUtCreateUpdateStateAndPush (
1170
AcpiUtCreateUpdateStateAndPush (
1135
    ACPI_OPERAND_OBJECT     *Object,
1171
    ACPI_OPERAND_OBJECT     *Object,
1136
    UINT16                  Action,
1172
    UINT16                  Action,
1137
    ACPI_GENERIC_STATE      **StateList)
1173
    ACPI_GENERIC_STATE      **StateList)
1138
{
1174
{
1139
    ACPI_GENERIC_STATE       *State;
1175
    ACPI_GENERIC_STATE       *State;
1140
 
1176
 
1141
 
1177
 
1142
    ACPI_FUNCTION_ENTRY ();
1178
    ACPI_FUNCTION_ENTRY ();
1143
 
1179
 
1144
 
1180
 
1145
    /* Ignore null objects; these are expected */
1181
    /* Ignore null objects; these are expected */
1146
 
1182
 
1147
    if (!Object)
1183
    if (!Object)
1148
    {
1184
    {
1149
        return (AE_OK);
1185
        return (AE_OK);
1150
    }
1186
    }
1151
 
1187
 
1152
    State = AcpiUtCreateUpdateState (Object, Action);
1188
    State = AcpiUtCreateUpdateState (Object, Action);
1153
    if (!State)
1189
    if (!State)
1154
    {
1190
    {
1155
        return (AE_NO_MEMORY);
1191
        return (AE_NO_MEMORY);
1156
    }
1192
    }
1157
 
1193
 
1158
    AcpiUtPushGenericState (StateList, State);
1194
    AcpiUtPushGenericState (StateList, State);
1159
    return (AE_OK);
1195
    return (AE_OK);
1160
}
1196
}
1161
 
1197
 
1162
 
1198
 
1163
/*******************************************************************************
1199
/*******************************************************************************
1164
 *
1200
 *
1165
 * FUNCTION:    AcpiUtWalkPackageTree
1201
 * FUNCTION:    AcpiUtWalkPackageTree
1166
 *
1202
 *
1167
 * PARAMETERS:  SourceObject        - The package to walk
1203
 * PARAMETERS:  SourceObject        - The package to walk
1168
 *              TargetObject        - Target object (if package is being copied)
1204
 *              TargetObject        - Target object (if package is being copied)
1169
 *              WalkCallback        - Called once for each package element
1205
 *              WalkCallback        - Called once for each package element
1170
 *              Context             - Passed to the callback function
1206
 *              Context             - Passed to the callback function
1171
 *
1207
 *
1172
 * RETURN:      Status
1208
 * RETURN:      Status
1173
 *
1209
 *
1174
 * DESCRIPTION: Walk through a package
1210
 * DESCRIPTION: Walk through a package
1175
 *
1211
 *
1176
 ******************************************************************************/
1212
 ******************************************************************************/
1177
 
1213
 
1178
ACPI_STATUS
1214
ACPI_STATUS
1179
AcpiUtWalkPackageTree (
1215
AcpiUtWalkPackageTree (
1180
    ACPI_OPERAND_OBJECT     *SourceObject,
1216
    ACPI_OPERAND_OBJECT     *SourceObject,
1181
    void                    *TargetObject,
1217
    void                    *TargetObject,
1182
    ACPI_PKG_CALLBACK       WalkCallback,
1218
    ACPI_PKG_CALLBACK       WalkCallback,
1183
    void                    *Context)
1219
    void                    *Context)
1184
{
1220
{
1185
    ACPI_STATUS             Status = AE_OK;
1221
    ACPI_STATUS             Status = AE_OK;
1186
    ACPI_GENERIC_STATE      *StateList = NULL;
1222
    ACPI_GENERIC_STATE      *StateList = NULL;
1187
    ACPI_GENERIC_STATE      *State;
1223
    ACPI_GENERIC_STATE      *State;
1188
    UINT32                  ThisIndex;
1224
    UINT32                  ThisIndex;
1189
    ACPI_OPERAND_OBJECT     *ThisSourceObj;
1225
    ACPI_OPERAND_OBJECT     *ThisSourceObj;
1190
 
1226
 
1191
 
1227
 
1192
    ACPI_FUNCTION_TRACE (UtWalkPackageTree);
1228
    ACPI_FUNCTION_TRACE (UtWalkPackageTree);
1193
 
1229
 
1194
 
1230
 
1195
    State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0);
1231
    State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0);
1196
    if (!State)
1232
    if (!State)
1197
    {
1233
    {
1198
        return_ACPI_STATUS (AE_NO_MEMORY);
1234
        return_ACPI_STATUS (AE_NO_MEMORY);
1199
    }
1235
    }
1200
 
1236
 
1201
    while (State)
1237
    while (State)
1202
    {
1238
    {
1203
        /* Get one element of the package */
1239
        /* Get one element of the package */
1204
 
1240
 
1205
        ThisIndex     = State->Pkg.Index;
1241
        ThisIndex     = State->Pkg.Index;
1206
        ThisSourceObj = (ACPI_OPERAND_OBJECT *)
1242
        ThisSourceObj = (ACPI_OPERAND_OBJECT *)
1207
                        State->Pkg.SourceObject->Package.Elements[ThisIndex];
1243
                        State->Pkg.SourceObject->Package.Elements[ThisIndex];
1208
 
1244
 
1209
        /*
1245
        /*
1210
         * Check for:
1246
         * Check for:
1211
         * 1) An uninitialized package element.  It is completely
1247
         * 1) An uninitialized package element.  It is completely
1212
         *    legal to declare a package and leave it uninitialized
1248
         *    legal to declare a package and leave it uninitialized
1213
         * 2) Not an internal object - can be a namespace node instead
1249
         * 2) Not an internal object - can be a namespace node instead
1214
         * 3) Any type other than a package.  Packages are handled in else
1250
         * 3) Any type other than a package.  Packages are handled in else
1215
         *    case below.
1251
         *    case below.
1216
         */
1252
         */
1217
        if ((!ThisSourceObj) ||
1253
        if ((!ThisSourceObj) ||
1218
            (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) ||
1254
            (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) ||
1219
            (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE))
1255
            (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE))
1220
        {
1256
        {
1221
            Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj,
1257
            Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj,
1222
                                    State, Context);
1258
                                    State, Context);
1223
            if (ACPI_FAILURE (Status))
1259
            if (ACPI_FAILURE (Status))
1224
            {
1260
            {
1225
                return_ACPI_STATUS (Status);
1261
                return_ACPI_STATUS (Status);
1226
            }
1262
            }
1227
 
1263
 
1228
            State->Pkg.Index++;
1264
            State->Pkg.Index++;
1229
            while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count)
1265
            while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count)
1230
            {
1266
            {
1231
                /*
1267
                /*
1232
                 * We've handled all of the objects at this level,  This means
1268
                 * We've handled all of the objects at this level,  This means
1233
                 * that we have just completed a package.  That package may
1269
                 * that we have just completed a package.  That package may
1234
                 * have contained one or more packages itself.
1270
                 * have contained one or more packages itself.
1235
                 *
1271
                 *
1236
                 * Delete this state and pop the previous state (package).
1272
                 * Delete this state and pop the previous state (package).
1237
                 */
1273
                 */
1238
                AcpiUtDeleteGenericState (State);
1274
                AcpiUtDeleteGenericState (State);
1239
                State = AcpiUtPopGenericState (&StateList);
1275
                State = AcpiUtPopGenericState (&StateList);
1240
 
1276
 
1241
                /* Finished when there are no more states */
1277
                /* Finished when there are no more states */
1242
 
1278
 
1243
                if (!State)
1279
                if (!State)
1244
                {
1280
                {
1245
                    /*
1281
                    /*
1246
                     * We have handled all of the objects in the top level
1282
                     * We have handled all of the objects in the top level
1247
                     * package just add the length of the package objects
1283
                     * package just add the length of the package objects
1248
                     * and exit
1284
                     * and exit
1249
                     */
1285
                     */
1250
                    return_ACPI_STATUS (AE_OK);
1286
                    return_ACPI_STATUS (AE_OK);
1251
                }
1287
                }
1252
 
1288
 
1253
                /*
1289
                /*
1254
                 * Go back up a level and move the index past the just
1290
                 * Go back up a level and move the index past the just
1255
                 * completed package object.
1291
                 * completed package object.
1256
                 */
1292
                 */
1257
                State->Pkg.Index++;
1293
                State->Pkg.Index++;
1258
            }
1294
            }
1259
        }
1295
        }
1260
        else
1296
        else
1261
        {
1297
        {
1262
            /* This is a subobject of type package */
1298
            /* This is a subobject of type package */
1263
 
1299
 
1264
            Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj,
1300
            Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj,
1265
                                        State, Context);
1301
                                        State, Context);
1266
            if (ACPI_FAILURE (Status))
1302
            if (ACPI_FAILURE (Status))
1267
            {
1303
            {
1268
                return_ACPI_STATUS (Status);
1304
                return_ACPI_STATUS (Status);
1269
            }
1305
            }
1270
 
1306
 
1271
            /*
1307
            /*
1272
             * Push the current state and create a new one
1308
             * Push the current state and create a new one
1273
             * The callback above returned a new target package object.
1309
             * The callback above returned a new target package object.
1274
             */
1310
             */
1275
            AcpiUtPushGenericState (&StateList, State);
1311
            AcpiUtPushGenericState (&StateList, State);
1276
            State = AcpiUtCreatePkgState (ThisSourceObj,
1312
            State = AcpiUtCreatePkgState (ThisSourceObj,
1277
                                            State->Pkg.ThisTargetObj, 0);
1313
                                            State->Pkg.ThisTargetObj, 0);
1278
            if (!State)
1314
            if (!State)
1279
            {
1315
            {
1280
                /* Free any stacked Update State objects */
1316
                /* Free any stacked Update State objects */
1281
 
1317
 
1282
                while (StateList)
1318
                while (StateList)
1283
                {
1319
                {
1284
                    State = AcpiUtPopGenericState (&StateList);
1320
                    State = AcpiUtPopGenericState (&StateList);
1285
                    AcpiUtDeleteGenericState (State);
1321
                    AcpiUtDeleteGenericState (State);
1286
                }
1322
                }
1287
                return_ACPI_STATUS (AE_NO_MEMORY);
1323
                return_ACPI_STATUS (AE_NO_MEMORY);
1288
            }
1324
            }
1289
        }
1325
        }
1290
    }
1326
    }
1291
 
1327
 
1292
    /* We should never get here */
1328
    /* We should never get here */
1293
 
1329
 
1294
    return_ACPI_STATUS (AE_AML_INTERNAL);
1330
    return_ACPI_STATUS (AE_AML_INTERNAL);
1295
}
1331
}
1296
 
1332
1297
 
-
 
1298
/*******************************************************************************
-
 
1299
 *
-
 
1300
 * FUNCTION:    AcpiError, AcpiException, AcpiWarning, AcpiInfo
-
 
1301
 *
-
 
1302
 * PARAMETERS:  ModuleName          - Caller's module name (for error output)
-
 
1303
 *              LineNumber          - Caller's line number (for error output)
-
 
1304
 *              Format              - Printf format string + additional args
-
 
1305
 *
-
 
1306
 * RETURN:      None
-
 
1307
 *
-
 
1308
 * DESCRIPTION: Print message with module/line/version info
-
 
1309
 *
-
 
1310
 ******************************************************************************/
-
 
1311
 
-
 
1312
void  ACPI_INTERNAL_VAR_XFACE
-
 
1313
AcpiError (
-
 
1314
    const char              *ModuleName,
-
 
1315
    UINT32                  LineNumber,
-
 
1316
    const char              *Format,
-
 
1317
    ...)
-
 
1318
{
-
 
1319
    va_list                 args;
-
 
1320
 
-
 
1321
 
-
 
1322
    AcpiOsPrintf ("ACPI Error: ");
-
 
1323
 
-
 
1324
    va_start (args, Format);
-
 
1325
    AcpiOsVprintf (Format, args);
-
 
1326
    ACPI_COMMON_MSG_SUFFIX;
-
 
1327
    va_end (args);
-
 
1328
}
-
 
1329
 
-
 
1330
void  ACPI_INTERNAL_VAR_XFACE
-
 
1331
AcpiException (
-
 
1332
    const char              *ModuleName,
-
 
1333
    UINT32                  LineNumber,
-
 
1334
    ACPI_STATUS             Status,
-
 
1335
    const char              *Format,
-
 
1336
    ...)
-
 
1337
{
-
 
1338
    va_list                 args;
-
 
1339
 
-
 
1340
 
-
 
1341
    AcpiOsPrintf ("ACPI Exception: %s, ", AcpiFormatException (Status));
-
 
1342
 
-
 
1343
    va_start (args, Format);
-
 
1344
    AcpiOsVprintf (Format, args);
-
 
1345
    ACPI_COMMON_MSG_SUFFIX;
-
 
1346
    va_end (args);
-
 
1347
}
-
 
1348
 
-
 
1349
void  ACPI_INTERNAL_VAR_XFACE
-
 
1350
AcpiWarning (
-
 
1351
    const char              *ModuleName,
-
 
1352
    UINT32                  LineNumber,
-
 
1353
    const char              *Format,
-
 
1354
    ...)
-
 
1355
{
-
 
1356
    va_list                 args;
-
 
1357
 
-
 
1358
 
-
 
1359
    AcpiOsPrintf ("ACPI Warning: ");
-
 
1360
 
-
 
1361
    va_start (args, Format);
-
 
1362
    AcpiOsVprintf (Format, args);
-
 
1363
    ACPI_COMMON_MSG_SUFFIX;
-
 
1364
    va_end (args);
-
 
1365
}
-
 
1366
 
-
 
1367
void  ACPI_INTERNAL_VAR_XFACE
-
 
1368
AcpiInfo (
-
 
1369
    const char              *ModuleName,
-
 
1370
    UINT32                  LineNumber,
-
 
1371
    const char              *Format,
-
 
1372
    ...)
-
 
1373
{
-
 
1374
    va_list                 args;
-
 
1375
 
-
 
1376
 
-
 
1377
    AcpiOsPrintf ("ACPI: ");
-
 
1378
 
-
 
1379
    va_start (args, Format);
-
 
1380
    AcpiOsVprintf (Format, args);
-
 
1381
    AcpiOsPrintf ("\n");
-
 
1382
    va_end (args);
-
 
1383
}
-
 
1384
 
-
 
1385
ACPI_EXPORT_SYMBOL (AcpiError)
-
 
1386
ACPI_EXPORT_SYMBOL (AcpiException)
-
 
1387
ACPI_EXPORT_SYMBOL (AcpiWarning)
-
 
1388
ACPI_EXPORT_SYMBOL (AcpiInfo)
-
 
1389
 
-
 
1390
 
-
 
1391
/*******************************************************************************
-
 
1392
 *
-
 
1393
 * FUNCTION:    AcpiUtPredefinedWarning
-
 
1394
 *
-
 
1395
 * PARAMETERS:  ModuleName      - Caller's module name (for error output)
-
 
1396
 *              LineNumber      - Caller's line number (for error output)
-
 
1397
 *              Pathname        - Full pathname to the node
-
 
1398
 *              NodeFlags       - From Namespace node for the method/object
-
 
1399
 *              Format          - Printf format string + additional args
-
 
1400
 *
-
 
1401
 * RETURN:      None
-
 
1402
 *
-
 
1403
 * DESCRIPTION: Warnings for the predefined validation module. Messages are
-
 
1404
 *              only emitted the first time a problem with a particular
-
 
1405
 *              method/object is detected. This prevents a flood of error
-
 
1406
 *              messages for methods that are repeatedly evaluated.
-
 
1407
 *
-
 
1408
 ******************************************************************************/
-
 
1409
 
-
 
1410
void  ACPI_INTERNAL_VAR_XFACE
-
 
1411
AcpiUtPredefinedWarning (
-
 
1412
    const char              *ModuleName,
-
 
1413
    UINT32                  LineNumber,
-
 
1414
    char                    *Pathname,
-
 
1415
    UINT8                   NodeFlags,
-
 
1416
    const char              *Format,
-
 
1417
    ...)
-
 
1418
{
-
 
1419
    va_list                 args;
-
 
1420
 
-
 
1421
 
-
 
1422
    /*
-
 
1423
     * Warning messages for this method/object will be disabled after the
-
 
1424
     * first time a validation fails or an object is successfully repaired.
-
 
1425
     */
-
 
1426
    if (NodeFlags & ANOBJ_EVALUATED)
-
 
1427
    {
-
 
1428
        return;
-
 
1429
    }
-
 
1430
 
-
 
1431
    AcpiOsPrintf ("ACPI Warning for %s: ", Pathname);
-
 
1432
 
-
 
1433
    va_start (args, Format);
-
 
1434
    AcpiOsVprintf (Format, args);
-
 
1435
    ACPI_COMMON_MSG_SUFFIX;
-
 
1436
    va_end (args);
-
 
1437
}
-
 
1438
 
-
 
1439
/*******************************************************************************
-
 
1440
 *
-
 
1441
 * FUNCTION:    AcpiUtPredefinedInfo
-
 
1442
 *
-
 
1443
 * PARAMETERS:  ModuleName      - Caller's module name (for error output)
-
 
1444
 *              LineNumber      - Caller's line number (for error output)
-
 
1445
 *              Pathname        - Full pathname to the node
-
 
1446
 *              NodeFlags       - From Namespace node for the method/object
-
 
1447
 *              Format          - Printf format string + additional args
-
 
1448
 *
-
 
1449
 * RETURN:      None
-
 
1450
 *
-
 
1451
 * DESCRIPTION: Info messages for the predefined validation module. Messages
-
 
1452
 *              are only emitted the first time a problem with a particular
-
 
1453
 *              method/object is detected. This prevents a flood of
-
 
1454
 *              messages for methods that are repeatedly evaluated.
-
 
1455
 *
-
 
1456
 ******************************************************************************/
-
 
1457
 
-
 
1458
void  ACPI_INTERNAL_VAR_XFACE
-
 
1459
AcpiUtPredefinedInfo (
-
 
1460
    const char              *ModuleName,
-
 
1461
    UINT32                  LineNumber,
-
 
1462
    char                    *Pathname,
-
 
1463
    UINT8                   NodeFlags,
-
 
1464
    const char              *Format,
-
 
1465
    ...)
-
 
1466
{
-
 
1467
    va_list                 args;
-
 
1468
 
-
 
1469
 
-
 
1470
    /*
-
 
1471
     * Warning messages for this method/object will be disabled after the
-
 
1472
     * first time a validation fails or an object is successfully repaired.
-
 
1473
     */
-
 
1474
    if (NodeFlags & ANOBJ_EVALUATED)
-
 
1475
    {
-
 
1476
        return;
-
 
1477
    }
-
 
1478
 
-
 
1479
    AcpiOsPrintf ("ACPI Info for %s: ", Pathname);
-
 
1480
 
-
 
1481
    va_start (args, Format);
-
 
1482
    AcpiOsVprintf (Format, args);
-
 
1483
    ACPI_COMMON_MSG_SUFFIX;
-
 
1484
    va_end (args);
-
 
1485
}
-