utglobal.c revision 77424
167754Smsmith/******************************************************************************
267754Smsmith *
377424Smsmith * Module Name: utglobal - Global variables for the ACPI subsystem
467754Smsmith *              $Revision: 122 $
567754Smsmith *
667754Smsmith *****************************************************************************/
767754Smsmith
867754Smsmith/******************************************************************************
967754Smsmith *
1067754Smsmith * 1. Copyright Notice
11202771Sjkim *
1270243Smsmith * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
1367754Smsmith * All rights reserved.
1467754Smsmith *
1567754Smsmith * 2. License
1667754Smsmith *
1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property
1867754Smsmith * rights.  You may have additional license terms from the party that provided
1967754Smsmith * you this software, covering your right to use that party's intellectual
2067754Smsmith * property rights.
2167754Smsmith *
2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an
2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy,
2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered
2767754Smsmith * Code in any form, with the right to sublicense such rights; and
2867754Smsmith *
2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3067754Smsmith * license (with the right to sublicense), under only those claims of Intel
3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell,
3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof
3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright
3467754Smsmith * license, and in no event shall the patent license extend to any additions
3567754Smsmith * to or modifications of the Original Intel Code.  No other license or right
3667754Smsmith * is granted directly or by implication, estoppel or otherwise;
3767754Smsmith *
3867754Smsmith * The above copyright and patent license is granted only if the following
3967754Smsmith * conditions are met:
4067754Smsmith *
4167754Smsmith * 3. Conditions
4267754Smsmith *
4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4467754Smsmith * Redistribution of source code of any substantial portion of the Covered
4567754Smsmith * Code or modification with rights to further distribute source must include
4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions,
4767754Smsmith * and the following Disclaimer and Export Compliance provision.  In addition,
4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to
4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered
5067754Smsmith * Code and the date of any change.  Licensee must include in that file the
5167754Smsmith * documentation of any changes made by any predecessor Licensee.  Licensee
5267754Smsmith * must include a prominent statement that the modification is derived,
5367754Smsmith * directly or indirectly, from Original Intel Code.
5467754Smsmith *
5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5667754Smsmith * Redistribution of source code of any substantial portion of the Covered
5767754Smsmith * Code or modification without rights to further distribute source must
5867754Smsmith * include the following Disclaimer and Export Compliance provision in the
5967754Smsmith * documentation and/or other materials provided with distribution.  In
6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any
6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the
6267754Smsmith * license from Licensee to its licensee is limited to the intellectual
6367754Smsmith * property embodied in the software Licensee provides to its licensee, and
6467754Smsmith * not to intellectual property embodied in modifications its licensee may
6567754Smsmith * make.
6667754Smsmith *
6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any
6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the
6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance
7067754Smsmith * provision in the documentation and/or other materials provided with the
7167754Smsmith * distribution.
7267754Smsmith *
7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original
7467754Smsmith * Intel Code.
7567754Smsmith *
7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or
7867754Smsmith * other dealings in products derived from or relating to the Covered Code
7967754Smsmith * without prior written authorization from Intel.
8067754Smsmith *
8167754Smsmith * 4. Disclaimer and Export Compliance
8267754Smsmith *
8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8467754Smsmith * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
8967754Smsmith * PARTICULAR PURPOSE.
9067754Smsmith *
9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9867754Smsmith * LIMITED REMEDY.
9967754Smsmith *
10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this
10167754Smsmith * software or system incorporating such software without first obtaining any
10267754Smsmith * required license or other approval from the U. S. Department of Commerce or
10367754Smsmith * any other agency or department of the United States Government.  In the
10467754Smsmith * event Licensee exports any such software from the United States or
10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall
10667754Smsmith * ensure that the distribution and export/re-export of the software is in
10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the
10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor
10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process,
11067754Smsmith * software, or service, directly or indirectly, to any country for which the
11167754Smsmith * United States government or any agency thereof requires an export license,
11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining
11367754Smsmith * such license, approval or letter.
11467754Smsmith *
11567754Smsmith *****************************************************************************/
11677424Smsmith
11767754Smsmith#define __UTGLOBAL_C__
11867754Smsmith#define DEFINE_ACPI_GLOBALS
119193341Sjkim
120193341Sjkim#include "acpi.h"
121193341Sjkim#include "acevents.h"
12267754Smsmith#include "acnamesp.h"
12377424Smsmith#include "acinterp.h"
12491116Smsmith#include "amlcode.h"
12567754Smsmith
12667754Smsmith
127151937Sjkim#define _COMPONENT          ACPI_UTILITIES
12867754Smsmith        MODULE_NAME         ("utglobal")
12967754Smsmith
13067754Smsmith
13167754Smsmith/******************************************************************************
13267754Smsmith *
13367754Smsmith * Static global variable initialization.
13467754Smsmith *
13567754Smsmith ******************************************************************************/
13667754Smsmith
13767754Smsmith/*
13867754Smsmith * We want the debug switches statically initialized so they
13967754Smsmith * are already set when the debugger is entered.
140102550Siwasaki */
141114237Snjl
14267754Smsmith/* Debug switch - level and trace mask */
143114237Snjl
14467754Smsmith#ifdef ACPI_DEBUG
14567754SmsmithUINT32                      AcpiDbgLevel = DEBUG_DEFAULT;
14667754Smsmith#else
14767754SmsmithUINT32                      AcpiDbgLevel = NORMAL_DEFAULT;
14877424Smsmith#endif
14967754Smsmith
15067754Smsmith/* Debug switch - layer (component) mask */
15167754Smsmith
15267754SmsmithUINT32                      AcpiDbgLayer = ACPI_COMPONENT_DEFAULT;
15367754SmsmithUINT32                      AcpiGbl_NestingLevel = 0;
154114237Snjl
15567754Smsmith
15667754Smsmith/* Debugger globals */
15767754Smsmith
15867754SmsmithBOOLEAN                     AcpiGbl_DbTerminateThreads = FALSE;
15967754SmsmithBOOLEAN                     AcpiGbl_MethodExecuting = FALSE;
16067754Smsmith
16187031Smsmith/* System flags */
16283174Smsmith
16367754SmsmithUINT32                      AcpiGbl_SystemFlags = 0;
16467754SmsmithUINT32                      AcpiGbl_StartupFlags = 0;
165129684Snjl
166129684Snjl/* System starts unitialized! */
167129684SnjlBOOLEAN                     AcpiGbl_Shutdown = TRUE;
168129684Snjl
169129684Snjl
170129684SnjlUINT8                       AcpiGbl_DecodeTo8bit [8] = {1,2,4,8,16,32,64,128};
171129684Snjl
172129684Snjl
173129684Snjl/******************************************************************************
17469450Smsmith *
175197104Sjkim * Namespace globals
176129684Snjl *
177197104Sjkim ******************************************************************************/
178197104Sjkim
179197104Sjkim
180197104Sjkim/*
181197104Sjkim * Names built-in to the interpreter
182197104Sjkim *
183197104Sjkim * Initial values are currently supported only for types String and Number.
184197104Sjkim * To avoid type punning, both are specified as strings in this table.
185197104Sjkim *
186129684Snjl * NOTES:
187129684Snjl * 1) _SB_ is defined to be a device to allow _SB_/_INI to be run
188129684Snjl *    during the initialization sequence.
189129684Snjl */
190129684Snjl
19169450SmsmithPREDEFINED_NAMES            AcpiGbl_PreDefinedNames[] =
192167802Sjkim{
193167802Sjkim    {"_GPE",    INTERNAL_TYPE_DEF_ANY},
194167802Sjkim    {"_PR_",    INTERNAL_TYPE_DEF_ANY},
195167802Sjkim    {"_SB_",    ACPI_TYPE_DEVICE},
196167802Sjkim    {"_SI_",    INTERNAL_TYPE_DEF_ANY},
197167802Sjkim    {"_TZ_",    INTERNAL_TYPE_DEF_ANY},
198167802Sjkim    {"_REV",    ACPI_TYPE_INTEGER, "2"},
199167802Sjkim    {"_OS_",    ACPI_TYPE_STRING, ACPI_OS_NAME},
200167802Sjkim    {"_GL_",    ACPI_TYPE_MUTEX, "0"},
201167802Sjkim    {NULL,      ACPI_TYPE_ANY}           /* Table terminator */
202167802Sjkim};
203167802Sjkim
204167802Sjkim
205167802Sjkim/*
206167802Sjkim * Properties of the ACPI Object Types, both internal and external.
207167802Sjkim *
208167802Sjkim * Elements of AcpiNsProperties are bit significant
209167802Sjkim * and the table is indexed by values of ACPI_OBJECT_TYPE
210129684Snjl */
211167802Sjkim
212151937SjkimUINT8                       AcpiGbl_NsProperties[] =
213151937Sjkim{
214167802Sjkim    NSP_NORMAL,                 /* 00 Any              */
215151937Sjkim    NSP_NORMAL,                 /* 01 Number           */
216127175Snjl    NSP_NORMAL,                 /* 02 String           */
217167802Sjkim    NSP_NORMAL,                 /* 03 Buffer           */
218167802Sjkim    NSP_LOCAL,                  /* 04 Package          */
219167802Sjkim    NSP_NORMAL,                 /* 05 FieldUnit        */
220167802Sjkim    NSP_NEWSCOPE | NSP_LOCAL,   /* 06 Device           */
221127175Snjl    NSP_LOCAL,                  /* 07 AcpiEvent        */
222167802Sjkim    NSP_NEWSCOPE | NSP_LOCAL,   /* 08 Method           */
223167802Sjkim    NSP_LOCAL,                  /* 09 Mutex            */
224167802Sjkim    NSP_LOCAL,                  /* 10 Region           */
225167802Sjkim    NSP_NEWSCOPE | NSP_LOCAL,   /* 11 Power            */
226167802Sjkim    NSP_NEWSCOPE | NSP_LOCAL,   /* 12 Processor        */
227167802Sjkim    NSP_NEWSCOPE | NSP_LOCAL,   /* 13 Thermal          */
228167802Sjkim    NSP_NORMAL,                 /* 14 BufferField      */
229167802Sjkim    NSP_NORMAL,                 /* 15 DdbHandle        */
230167802Sjkim    NSP_NORMAL,                 /* 16 Debug Object     */
231167802Sjkim    NSP_NORMAL,                 /* 17 DefField         */
232167802Sjkim    NSP_NORMAL,                 /* 18 BankField        */
233167802Sjkim    NSP_NORMAL,                 /* 19 IndexField       */
234151937Sjkim    NSP_NORMAL,                 /* 20 Reference        */
23567754Smsmith    NSP_NORMAL,                 /* 21 Alias            */
23667754Smsmith    NSP_NORMAL,                 /* 22 Notify           */
23767754Smsmith    NSP_NORMAL,                 /* 23 Address Handler  */
23867754Smsmith    NSP_NEWSCOPE | NSP_LOCAL,   /* 24 Resource         */
23967754Smsmith    NSP_NORMAL,                 /* 25 DefFieldDefn     */
24067754Smsmith    NSP_NORMAL,                 /* 26 BankFieldDefn    */
241104470Siwasaki    NSP_NORMAL,                 /* 27 IndexFieldDefn   */
24267754Smsmith    NSP_NORMAL,                 /* 28 If               */
24377424Smsmith    NSP_NORMAL,                 /* 29 Else             */
244127175Snjl    NSP_NORMAL,                 /* 30 While            */
24577424Smsmith    NSP_NEWSCOPE,               /* 31 Scope            */
246151937Sjkim    NSP_LOCAL,                  /* 32 DefAny           */
247151937Sjkim    NSP_NORMAL,                 /* 33 Extra            */
24867754Smsmith    NSP_NORMAL                  /* 34 Invalid          */
24991116Smsmith};
25067754Smsmith
251107325Siwasaki
252107325Siwasaki/* Hex to ASCII conversion table */
25399679Siwasaki
254107325SiwasakiNATIVE_CHAR                 AcpiGbl_HexToAscii[] =
255129684Snjl                                {'0','1','2','3','4','5','6','7',
256151937Sjkim                                '8','9','A','B','C','D','E','F'};
25799146Siwasaki
258151937Sjkim
259102550Siwasaki/******************************************************************************
260127175Snjl *
261151937Sjkim * Table globals
262102550Siwasaki *
263151937Sjkim * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
264151937Sjkim * it is NOT an exhaustive list of all possible ACPI tables.  All ACPI tables
265151937Sjkim * that are not used by the subsystem are simply ignored.
266151937Sjkim *
26767754Smsmith ******************************************************************************/
26867754Smsmith
26967754Smsmith
27067754SmsmithACPI_TABLE_DESC             AcpiGbl_AcpiTables[NUM_ACPI_TABLES];
271104470Siwasaki
27267754Smsmith
273193267SjkimACPI_TABLE_SUPPORT          AcpiGbl_AcpiTableData[NUM_ACPI_TABLES] =
27467754Smsmith{
27591116Smsmith    /***********    Name,    Signature,  Signature size,    How many allowed?,   Supported?  Global typed pointer */
27691116Smsmith
27791116Smsmith    /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, sizeof (RSDP_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      NULL},
27891116Smsmith    /* DSDT 1 */ {DSDT_SIG,  DSDT_SIG, sizeof (DSDT_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      (void **) &AcpiGbl_DSDT},
27999146Siwasaki    /* FADT 2 */ {FADT_SIG,  FADT_SIG, sizeof (FADT_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      (void **) &AcpiGbl_FADT},
28091116Smsmith    /* FACS 3 */ {FACS_SIG,  FACS_SIG, sizeof (FACS_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      (void **) &AcpiGbl_FACS},
28199146Siwasaki    /* PSDT 4 */ {PSDT_SIG,  PSDT_SIG, sizeof (PSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK,      NULL},
28299146Siwasaki    /* SSDT 5 */ {SSDT_SIG,  SSDT_SIG, sizeof (SSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK,      NULL},
28399146Siwasaki    /* XSDT 6 */ {XSDT_SIG,  XSDT_SIG, sizeof (RSDT_SIG)-1, ACPI_TABLE_SINGLE,   AE_OK,      NULL},
28499146Siwasaki};
28599146Siwasaki
28699146Siwasaki
28799146Siwasaki#ifdef ACPI_DEBUG
28899146Siwasaki
28991116Smsmith/******************************************************************************
29091116Smsmith *
29191116Smsmith * Strings and procedures used for debug only
29291116Smsmith *
29391116Smsmith ******************************************************************************/
29491116Smsmith
29591116SmsmithNATIVE_CHAR                 *MsgAcpiErrorBreak = "*** Break on ACPI_ERROR ***\n";
29691116Smsmith
297128212Snjl
298128212Snjl/*****************************************************************************
299128212Snjl *
300128212Snjl * FUNCTION:    AcpiUtGetMutexName
301128212Snjl *
302128212Snjl * PARAMETERS:  None.
303128212Snjl *
304128212Snjl * RETURN:      Status
305128212Snjl *
30667754Smsmith * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
30767754Smsmith *
30867754Smsmith ****************************************************************************/
30971867Smsmith
31071867SmsmithNATIVE_CHAR *
311114237SnjlAcpiUtGetMutexName (
312151937Sjkim    UINT32                  MutexId)
313151937Sjkim{
314151937Sjkim
315151937Sjkim    if (MutexId > MAX_MTX)
31671867Smsmith    {
317151937Sjkim        return ("Invalid Mutex ID");
318151937Sjkim    }
31983174Smsmith
32083174Smsmith    return (AcpiGbl_MutexNames[MutexId]);
32183174Smsmith}
32283174Smsmith
32383174Smsmith
324151937Sjkim/*
32583174Smsmith * Elements of AcpiGbl_NsTypeNames below must match
326151937Sjkim * one-to-one with values of ACPI_OBJECT_TYPE
32783174Smsmith *
328151937Sjkim * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when
32983174Smsmith * stored in a table it really means that we have thus far seen no evidence to
330151937Sjkim * indicatewhat type is actually going to be stored for this entry.
33183174Smsmith */
33299679Siwasaki
33382367Smsmithstatic NATIVE_CHAR          AcpiGbl_BadType[] = "UNDEFINED";
334202771Sjkim#define TYPE_NAME_LENGTH    9                       /* Maximum length of each string */
33582367Smsmith
33682367Smsmithstatic NATIVE_CHAR          *AcpiGbl_NsTypeNames[] =    /* printable names of ACPI types */
33771867Smsmith{
33882367Smsmith    /* 00 */ "Untyped",
33982367Smsmith    /* 01 */ "Integer",
34082367Smsmith    /* 02 */ "String",
34183174Smsmith    /* 03 */ "Buffer",
34291116Smsmith    /* 04 */ "Package",
34391116Smsmith    /* 05 */ "FieldUnit",
34491116Smsmith    /* 06 */ "Device",
34591116Smsmith    /* 07 */ "Event",
34691116Smsmith    /* 08 */ "Method",
34791116Smsmith    /* 09 */ "Mutex",
34891116Smsmith    /* 10 */ "Region",
34991116Smsmith    /* 11 */ "Power",
35091116Smsmith    /* 12 */ "Processor",
35191116Smsmith    /* 13 */ "Thermal",
35291116Smsmith    /* 14 */ "BuffField",
35391116Smsmith    /* 15 */ "DdbHandle",
35491116Smsmith    /* 16 */ "DebugObj",
35591116Smsmith    /* 17 */ "RegnField",
35691116Smsmith    /* 18 */ "BankField",
35791116Smsmith    /* 19 */ "IndxField",
35891116Smsmith    /* 20 */ "Reference",
359151937Sjkim    /* 21 */ "Alias",
36091116Smsmith    /* 22 */ "Notify",
36191116Smsmith    /* 23 */ "AddrHndlr",
36291116Smsmith    /* 24 */ "Resource",
36391116Smsmith    /* 25 */ "RgnFldDfn",
36491116Smsmith    /* 26 */ "BnkFldDfn",
36591116Smsmith    /* 27 */ "IdxFldDfn",
366151937Sjkim    /* 28 */ "If",
36791116Smsmith    /* 29 */ "Else",
36891116Smsmith    /* 30 */ "While",
36991116Smsmith    /* 31 */ "Scope",
37091116Smsmith    /* 32 */ "DefAny",
371193267Sjkim    /* 33 */ "Extra",
37291116Smsmith    /* 34 */ "Invalid"
37391116Smsmith};
37491116Smsmith
37591116Smsmith
37691116Smsmith/*****************************************************************************
37791116Smsmith *
37891116Smsmith * FUNCTION:    AcpiUtGetTypeName
37991116Smsmith *
38091116Smsmith * PARAMETERS:  None.
38191116Smsmith *
38291116Smsmith * RETURN:      Status
38391116Smsmith *
384123315Snjl * DESCRIPTION: Translate a Type ID into a name string (Debug only)
38591116Smsmith *
38691116Smsmith ****************************************************************************/
387151937Sjkim
38891116SmsmithNATIVE_CHAR *
38991116SmsmithAcpiUtGetTypeName (
39091116Smsmith    UINT32                  Type)
39191116Smsmith{
39291116Smsmith
39391116Smsmith    if (Type > INTERNAL_TYPE_INVALID)
39491116Smsmith    {
39591116Smsmith        return (AcpiGbl_BadType);
39691116Smsmith    }
397151937Sjkim
39891116Smsmith    return (AcpiGbl_NsTypeNames[Type]);
39991116Smsmith}
40091116Smsmith
401114237Snjl
40291116Smsmith/* Region type decoding */
40391116Smsmith
40491116SmsmithNATIVE_CHAR *AcpiGbl_RegionTypes[NUM_REGION_TYPES] =
405100966Siwasaki{
40691116Smsmith    "SystemMemory",
40791116Smsmith    "SystemIO",
408193267Sjkim    "PCIConfig",
409100966Siwasaki    "EmbeddedControl",
410197104Sjkim    "SMBus",
411114237Snjl    "CMOS",
41291116Smsmith    "PCIBarTarget",
41391116Smsmith};
41491116Smsmith
415114237Snjl
41691116Smsmith/*****************************************************************************
41791116Smsmith *
41891116Smsmith * FUNCTION:    AcpiUtGetRegionName
41991116Smsmith *
42091116Smsmith * PARAMETERS:  None.
42191116Smsmith *
42291116Smsmith * RETURN:      Status
42391116Smsmith *
42491116Smsmith * DESCRIPTION: Translate a Space ID into a name string (Debug only)
42591116Smsmith *
426114237Snjl ****************************************************************************/
42791116Smsmith
42891116SmsmithNATIVE_CHAR *
429167802SjkimAcpiUtGetRegionName (
43091116Smsmith    UINT8                   SpaceId)
43191116Smsmith{
43291116Smsmith
433151937Sjkim    if (SpaceId >= USER_REGION_BEGIN)
43491116Smsmith    {
43591116Smsmith        return ("UserDefinedRegion");
43691116Smsmith    }
43791116Smsmith
43891116Smsmith    else if (SpaceId >= NUM_REGION_TYPES)
43991116Smsmith    {
44091116Smsmith        return ("InvalidSpaceID");
44191116Smsmith    }
44291116Smsmith
443151937Sjkim    return (AcpiGbl_RegionTypes[SpaceId]);
44491116Smsmith}
44591116Smsmith
44691116Smsmith
447114237Snjl/* Data used in keeping track of fields */
44891116Smsmith
44991116SmsmithNATIVE_CHAR *AcpiGbl_FENames[NUM_FIELD_NAMES] =
45091116Smsmith{
45191116Smsmith    "skip",
45291116Smsmith    "?access?"
45391116Smsmith};              /* FE = Field Element */
45491116Smsmith
45591116Smsmith
45691116SmsmithNATIVE_CHAR *AcpiGbl_MatchOps[NUM_MATCH_OPS] =
457114237Snjl{
45891116Smsmith    "Error",
45991116Smsmith    "MTR",
46091116Smsmith    "MEQ",
46191116Smsmith    "MLE",
46291116Smsmith    "MLT",
46391116Smsmith    "MGE",
46491116Smsmith    "MGT"
46591116Smsmith};
46691116Smsmith
467167802Sjkim
46891116Smsmith/* Access type decoding */
46991116Smsmith
47091116SmsmithNATIVE_CHAR *AcpiGbl_AccessTypes[NUM_ACCESS_TYPES] =
471151937Sjkim{
47267754Smsmith    "AnyAcc",
47391116Smsmith    "ByteAcc",
47491116Smsmith    "WordAcc",
47591116Smsmith    "DWordAcc",
47691116Smsmith    "BlockAcc",
47791116Smsmith    "SMBSendRecvAcc",
47891116Smsmith    "SMBQuickAcc"
47991116Smsmith};
48091116Smsmith
481151937Sjkim
48291116Smsmith/* Update rule decoding */
48367754Smsmith
48467754SmsmithNATIVE_CHAR *AcpiGbl_UpdateRules[NUM_UPDATE_RULES] =
48567754Smsmith{
48667754Smsmith    "Preserve",
487151937Sjkim    "WriteAsOnes",
488151937Sjkim    "WriteAsZeros"
489151937Sjkim};
49067754Smsmith
491114237Snjl#endif
49267754Smsmith
493151937Sjkim
494151937Sjkim/*****************************************************************************
495151937Sjkim *
49667754Smsmith * FUNCTION:    AcpiUtValidObjectType
49767754Smsmith *
49871867Smsmith * PARAMETERS:  None.
49967754Smsmith *
50067754Smsmith * RETURN:      TRUE if valid object type
50167754Smsmith *
50267754Smsmith * DESCRIPTION: Validate an object type
50367754Smsmith *
50467754Smsmith ****************************************************************************/
50567754Smsmith
50667754SmsmithBOOLEAN
50767754SmsmithAcpiUtValidObjectType (
50867754Smsmith    UINT32                  Type)
50967754Smsmith{
51067754Smsmith
51185756Smsmith    if (Type > ACPI_TYPE_MAX)
51267754Smsmith    {
51385756Smsmith        if ((Type < INTERNAL_TYPE_BEGIN) ||
51485756Smsmith            (Type > INTERNAL_TYPE_MAX))
51577424Smsmith        {
51685756Smsmith            return (FALSE);
51767754Smsmith        }
51867754Smsmith    }
519128212Snjl
520128212Snjl    return (TRUE);
521128212Snjl}
522128212Snjl
523128212Snjl
524128212Snjl/*****************************************************************************
525128212Snjl *
526128212Snjl * FUNCTION:    AcpiUtFormatException
527128212Snjl *
52867754Smsmith * PARAMETERS:  Status              - Acpi status to be formatted
52967754Smsmith *
53067754Smsmith * RETURN:      Formatted status string
531114237Snjl *
53277424Smsmith * DESCRIPTION: Convert an ACPI exception to a string
53391116Smsmith *
53467754Smsmith ****************************************************************************/
53567754Smsmith
536107325SiwasakiNATIVE_CHAR *
53767754SmsmithAcpiUtFormatException (
538167802Sjkim    ACPI_STATUS             Status)
53967754Smsmith{
54067754Smsmith    NATIVE_CHAR             *Exception = "UNKNOWN_STATUS";
541167802Sjkim    ACPI_STATUS             SubStatus;
54267754Smsmith
54367754Smsmith
54469746Smsmith    SubStatus = (Status & ~AE_CODE_MASK);
545114237Snjl
54699679Siwasaki
54799679Siwasaki    switch (Status & AE_CODE_MASK)
54899679Siwasaki    {
54999679Siwasaki    case AE_CODE_ENVIRONMENTAL:
55099679Siwasaki
55199679Siwasaki        if (SubStatus <= AE_CODE_ENV_MAX)
55299679Siwasaki        {
55399679Siwasaki            Exception = AcpiGbl_ExceptionNames_Env [SubStatus];
55499679Siwasaki        }
555193267Sjkim        break;
55699679Siwasaki
55799679Siwasaki    case AE_CODE_PROGRAMMER:
55899679Siwasaki
559151937Sjkim        if (SubStatus <= AE_CODE_PGM_MAX)
560123315Snjl        {
561123315Snjl            Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus -1];
562123315Snjl        }
563123315Snjl        break;
564123315Snjl
565123315Snjl    case AE_CODE_ACPI_TABLES:
566123315Snjl
567123315Snjl        if (SubStatus <= AE_CODE_TBL_MAX)
568123315Snjl        {
569151937Sjkim            Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1];
570123315Snjl        }
571123315Snjl        break;
572123315Snjl
573123315Snjl    case AE_CODE_AML:
574123315Snjl
575128212Snjl        if (SubStatus <= AE_CODE_AML_MAX)
576123315Snjl        {
577123315Snjl            Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1];
578128212Snjl        }
579128212Snjl        break;
580123315Snjl
581123315Snjl    case AE_CODE_CONTROL:
582128212Snjl
583123315Snjl        if (SubStatus <= AE_CODE_CTRL_MAX)
584123315Snjl        {
585128212Snjl            Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1];
586123315Snjl        }
587128212Snjl        break;
588128212Snjl
589128212Snjl    default:
590128212Snjl        break;
591128212Snjl    }
592128212Snjl
593128212Snjl
594128212Snjl    return (Exception);
595167802Sjkim}
596123315Snjl
597128212Snjl
598123315Snjl/****************************************************************************
599123315Snjl *
600193267Sjkim * FUNCTION:    AcpiUtAllocateOwnerId
601193267Sjkim *
602193267Sjkim * PARAMETERS:  IdType          - Type of ID (method or table)
603193267Sjkim *
604193267Sjkim * DESCRIPTION: Allocate a table or method owner id
605128212Snjl *
606128212Snjl ***************************************************************************/
607128212Snjl
608123315SnjlACPI_OWNER_ID
609123315SnjlAcpiUtAllocateOwnerId (
610123315Snjl    UINT32                  IdType)
611123315Snjl{
612151937Sjkim    ACPI_OWNER_ID           OwnerId = 0xFFFF;
613123315Snjl
614123315Snjl
615123315Snjl    FUNCTION_TRACE ("UtAllocateOwnerId");
616123315Snjl
617123315Snjl
618123315Snjl    AcpiUtAcquireMutex (ACPI_MTX_CACHES);
619123315Snjl
620123315Snjl    switch (IdType)
621123315Snjl    {
622151937Sjkim    case OWNER_TYPE_TABLE:
623123315Snjl
624151937Sjkim        OwnerId = AcpiGbl_NextTableOwnerId;
625151937Sjkim        AcpiGbl_NextTableOwnerId++;
626151937Sjkim
627123315Snjl        if (AcpiGbl_NextTableOwnerId == FIRST_METHOD_ID)
628123315Snjl        {
629123315Snjl            AcpiGbl_NextTableOwnerId = FIRST_TABLE_ID;
630123315Snjl        }
631123315Snjl        break;
632123315Snjl
633123315Snjl
634123315Snjl    case OWNER_TYPE_METHOD:
635123315Snjl
636123315Snjl        OwnerId = AcpiGbl_NextMethodOwnerId;
637123315Snjl        AcpiGbl_NextMethodOwnerId++;
638123315Snjl
639123315Snjl        if (AcpiGbl_NextMethodOwnerId == FIRST_TABLE_ID)
640123315Snjl        {
641123315Snjl            AcpiGbl_NextMethodOwnerId = FIRST_METHOD_ID;
642123315Snjl        }
643123315Snjl        break;
644123315Snjl    }
645123315Snjl
646123315Snjl
647123315Snjl    AcpiUtReleaseMutex (ACPI_MTX_CACHES);
648123315Snjl
649123315Snjl    return_VALUE (OwnerId);
650123315Snjl}
651123315Snjl
652123315Snjl
653123315Snjl/****************************************************************************
654123315Snjl *
655123315Snjl * FUNCTION:    AcpiUtInitGlobals
656123315Snjl *
657123315Snjl * PARAMETERS:  none
658123315Snjl *
659167802Sjkim * DESCRIPTION: Init library globals.  All globals that require specific
660123315Snjl *              initialization should be initialized here!
661123315Snjl *
662167802Sjkim ***************************************************************************/
663167802Sjkim
664123315Snjlvoid
665123315SnjlAcpiUtInitGlobals (
666123315Snjl    void)
667123315Snjl{
668193267Sjkim    UINT32                  i;
669193267Sjkim
670193267Sjkim
671193267Sjkim    FUNCTION_TRACE ("UtInitGlobals");
672193267Sjkim
673193267Sjkim
674193267Sjkim    /* ACPI table structure */
675193267Sjkim
676193267Sjkim    for (i = 0; i < NUM_ACPI_TABLES; i++)
677193267Sjkim    {
678193267Sjkim        AcpiGbl_AcpiTables[i].Prev          = &AcpiGbl_AcpiTables[i];
679193267Sjkim        AcpiGbl_AcpiTables[i].Next          = &AcpiGbl_AcpiTables[i];
680193267Sjkim        AcpiGbl_AcpiTables[i].Pointer       = NULL;
681193267Sjkim        AcpiGbl_AcpiTables[i].Length        = 0;
682193267Sjkim        AcpiGbl_AcpiTables[i].Allocation    = ACPI_MEM_NOT_ALLOCATED;
683193267Sjkim        AcpiGbl_AcpiTables[i].Count         = 0;
684193267Sjkim    }
685193267Sjkim
686193267Sjkim
687193267Sjkim    /* Address Space handler array */
688193267Sjkim
689193267Sjkim    for (i = 0; i < ACPI_NUM_ADDRESS_SPACES; i++)
690193267Sjkim    {
691193267Sjkim        AcpiGbl_AddressSpaces[i].Handler    = NULL;
692193267Sjkim        AcpiGbl_AddressSpaces[i].Context    = NULL;
693193267Sjkim    }
694193267Sjkim
695193267Sjkim    /* Mutex locked flags */
696193267Sjkim
697193267Sjkim    for (i = 0; i < NUM_MTX; i++)
698193267Sjkim    {
699193267Sjkim        AcpiGbl_AcpiMutexInfo[i].Mutex      = NULL;
700193267Sjkim        AcpiGbl_AcpiMutexInfo[i].OwnerId    = ACPI_MUTEX_NOT_ACQUIRED;
701193267Sjkim        AcpiGbl_AcpiMutexInfo[i].UseCount   = 0;
702193267Sjkim    }
703193267Sjkim
704193267Sjkim    /* Global notify handlers */
705193267Sjkim
706193267Sjkim    AcpiGbl_SysNotify.Handler           = NULL;
707193267Sjkim    AcpiGbl_DrvNotify.Handler           = NULL;
708193267Sjkim
709193267Sjkim    /* Global "typed" ACPI table pointers */
710193267Sjkim
711193267Sjkim    AcpiGbl_RSDP                        = NULL;
712193267Sjkim    AcpiGbl_XSDT                        = NULL;
713193267Sjkim    AcpiGbl_FACS                        = NULL;
714193267Sjkim    AcpiGbl_FADT                        = NULL;
715193267Sjkim    AcpiGbl_DSDT                        = NULL;
716193267Sjkim
717193267Sjkim
718193267Sjkim    /* Global Lock support */
719193267Sjkim
720193267Sjkim    AcpiGbl_GlobalLockAcquired          = FALSE;
721193267Sjkim    AcpiGbl_GlobalLockThreadCount       = 0;
722102550Siwasaki
723100966Siwasaki    /* Miscellaneous variables */
724100966Siwasaki
725100966Siwasaki    AcpiGbl_SystemFlags                 = 0;
72699679Siwasaki    AcpiGbl_StartupFlags                = 0;
727151937Sjkim    AcpiGbl_RsdpOriginalLocation        = 0;
728100966Siwasaki    AcpiGbl_CmSingleStep                = FALSE;
729100966Siwasaki    AcpiGbl_DbTerminateThreads          = FALSE;
730100966Siwasaki    AcpiGbl_Shutdown                    = FALSE;
731151937Sjkim    AcpiGbl_NsLookupCount               = 0;
732100966Siwasaki    AcpiGbl_PsFindCount                 = 0;
733151937Sjkim    AcpiGbl_AcpiHardwarePresent         = TRUE;
734151937Sjkim    AcpiGbl_NextTableOwnerId            = FIRST_TABLE_ID;
735100966Siwasaki    AcpiGbl_NextMethodOwnerId           = FIRST_METHOD_ID;
736100966Siwasaki    AcpiGbl_DebuggerConfiguration       = DEBUGGER_THREADING;
737100966Siwasaki
738151937Sjkim    /* Cache of small "state" objects */
73969746Smsmith
740114237Snjl    AcpiGbl_GenericStateCache           = NULL;
741100966Siwasaki    AcpiGbl_GenericStateCacheDepth      = 0;
742100966Siwasaki    AcpiGbl_StateCacheRequests          = 0;
74369746Smsmith    AcpiGbl_StateCacheHits              = 0;
74469746Smsmith
745167802Sjkim    AcpiGbl_ParseCache                  = NULL;
746100966Siwasaki    AcpiGbl_ParseCacheDepth             = 0;
747100966Siwasaki    AcpiGbl_ParseCacheRequests          = 0;
748100966Siwasaki    AcpiGbl_ParseCacheHits              = 0;
74969746Smsmith
750100966Siwasaki    AcpiGbl_ExtParseCache               = NULL;
751100966Siwasaki    AcpiGbl_ExtParseCacheDepth          = 0;
752193267Sjkim    AcpiGbl_ExtParseCacheRequests       = 0;
753193267Sjkim    AcpiGbl_ExtParseCacheHits           = 0;
754193267Sjkim
755193267Sjkim    AcpiGbl_ObjectCache                 = NULL;
756193267Sjkim    AcpiGbl_ObjectCacheDepth            = 0;
757193267Sjkim    AcpiGbl_ObjectCacheRequests         = 0;
758193267Sjkim    AcpiGbl_ObjectCacheHits             = 0;
759193267Sjkim
760193267Sjkim    AcpiGbl_WalkStateCache              = NULL;
761193267Sjkim    AcpiGbl_WalkStateCacheDepth         = 0;
762193267Sjkim    AcpiGbl_WalkStateCacheRequests      = 0;
763193267Sjkim    AcpiGbl_WalkStateCacheHits          = 0;
764193267Sjkim
765193267Sjkim    /* Hardware oriented */
766193267Sjkim
767193267Sjkim    AcpiGbl_Gpe0EnableRegisterSave      = NULL;
768193267Sjkim    AcpiGbl_Gpe1EnableRegisterSave      = NULL;
769193267Sjkim    AcpiGbl_OriginalMode                = SYS_MODE_UNKNOWN;   /*  original ACPI/legacy mode   */
770193267Sjkim    AcpiGbl_GpeRegisters                = NULL;
771193267Sjkim    AcpiGbl_GpeInfo                     = NULL;
772193267Sjkim
773193267Sjkim    /* Namespace */
774193267Sjkim
775193267Sjkim    AcpiGbl_RootNode                    = NULL;
776193267Sjkim
777193267Sjkim    AcpiGbl_RootNodeStruct.Name         = ACPI_ROOT_NAME;
778193267Sjkim    AcpiGbl_RootNodeStruct.DataType     = ACPI_DESC_TYPE_NAMED;
779193267Sjkim    AcpiGbl_RootNodeStruct.Type         = ACPI_TYPE_ANY;
780193267Sjkim    AcpiGbl_RootNodeStruct.Child        = NULL;
781193267Sjkim    AcpiGbl_RootNodeStruct.Peer         = NULL;
782193267Sjkim    AcpiGbl_RootNodeStruct.Object       = NULL;
783193267Sjkim    AcpiGbl_RootNodeStruct.Flags        = ANOBJ_END_OF_PEER_LIST;
784193267Sjkim
785193267Sjkim    /* Memory allocation metrics - compiled out in non-debug mode. */
786193267Sjkim
787193267Sjkim    INITIALIZE_ALLOCATION_METRICS();
788193267Sjkim
789193267Sjkim    return_VOID;
790193267Sjkim}
791193267Sjkim
792193267Sjkim
793193267Sjkim