utglobal.c revision 151600
167754Smsmith/******************************************************************************
267754Smsmith *
377424Smsmith * Module Name: utglobal - Global variables for the ACPI subsystem
4138287Smarks *              $Revision: 202 $
567754Smsmith *
667754Smsmith *****************************************************************************/
767754Smsmith
867754Smsmith/******************************************************************************
967754Smsmith *
1067754Smsmith * 1. Copyright Notice
1167754Smsmith *
12126372Snjl * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
1370243Smsmith * 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 *****************************************************************************/
11667754Smsmith
11777424Smsmith#define __UTGLOBAL_C__
11867754Smsmith#define DEFINE_ACPI_GLOBALS
11967754Smsmith
120151600Sobrien#include <contrib/dev/acpica/acpi.h>
121151600Sobrien#include <contrib/dev/acpica/acnamesp.h>
12267754Smsmith
12377424Smsmith#define _COMPONENT          ACPI_UTILITIES
12491116Smsmith        ACPI_MODULE_NAME    ("utglobal")
12567754Smsmith
12667754Smsmith
12767754Smsmith/******************************************************************************
12867754Smsmith *
12980062Smsmith * FUNCTION:    AcpiFormatException
13080062Smsmith *
13180062Smsmith * PARAMETERS:  Status       - The ACPI_STATUS code to be formatted
13280062Smsmith *
13380062Smsmith * RETURN:      A string containing the exception  text
13480062Smsmith *
13580062Smsmith * DESCRIPTION: This function translates an ACPI exception into an ASCII string.
13680062Smsmith *
13780062Smsmith ******************************************************************************/
13880062Smsmith
13980062Smsmithconst char *
14080062SmsmithAcpiFormatException (
14180062Smsmith    ACPI_STATUS             Status)
14280062Smsmith{
14383174Smsmith    const char              *Exception = "UNKNOWN_STATUS_CODE";
14480062Smsmith    ACPI_STATUS             SubStatus;
14580062Smsmith
14680062Smsmith
14799146Siwasaki    ACPI_FUNCTION_NAME ("FormatException");
14899146Siwasaki
14999146Siwasaki
15080062Smsmith    SubStatus = (Status & ~AE_CODE_MASK);
15180062Smsmith
15280062Smsmith    switch (Status & AE_CODE_MASK)
15380062Smsmith    {
15480062Smsmith    case AE_CODE_ENVIRONMENTAL:
15580062Smsmith
15680062Smsmith        if (SubStatus <= AE_CODE_ENV_MAX)
15780062Smsmith        {
15880062Smsmith            Exception = AcpiGbl_ExceptionNames_Env [SubStatus];
15999146Siwasaki            break;
16080062Smsmith        }
16199146Siwasaki        goto Unknown;
16280062Smsmith
16380062Smsmith    case AE_CODE_PROGRAMMER:
16480062Smsmith
16580062Smsmith        if (SubStatus <= AE_CODE_PGM_MAX)
16680062Smsmith        {
16780062Smsmith            Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus -1];
16899146Siwasaki            break;
16980062Smsmith        }
17099146Siwasaki        goto Unknown;
17180062Smsmith
17280062Smsmith    case AE_CODE_ACPI_TABLES:
17380062Smsmith
17480062Smsmith        if (SubStatus <= AE_CODE_TBL_MAX)
17580062Smsmith        {
17680062Smsmith            Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1];
17799146Siwasaki            break;
17880062Smsmith        }
17999146Siwasaki        goto Unknown;
18080062Smsmith
18180062Smsmith    case AE_CODE_AML:
18280062Smsmith
18380062Smsmith        if (SubStatus <= AE_CODE_AML_MAX)
18480062Smsmith        {
18580062Smsmith            Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1];
18699146Siwasaki            break;
18780062Smsmith        }
18899146Siwasaki        goto Unknown;
18980062Smsmith
19080062Smsmith    case AE_CODE_CONTROL:
19180062Smsmith
19280062Smsmith        if (SubStatus <= AE_CODE_CTRL_MAX)
19380062Smsmith        {
19480062Smsmith            Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1];
19599146Siwasaki            break;
19680062Smsmith        }
19799146Siwasaki        goto Unknown;
19880062Smsmith
19980062Smsmith    default:
20099146Siwasaki        goto Unknown;
20180062Smsmith    }
20280062Smsmith
20380062Smsmith
20480062Smsmith    return ((const char *) Exception);
20599146Siwasaki
20699146SiwasakiUnknown:
20799146Siwasaki
20899146Siwasaki    ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown exception code: 0x%8.8X\n", Status));
20999146Siwasaki    return ((const char *) Exception);
21080062Smsmith}
21180062Smsmith
21280062Smsmith
21380062Smsmith/******************************************************************************
21480062Smsmith *
21567754Smsmith * Static global variable initialization.
21667754Smsmith *
21767754Smsmith ******************************************************************************/
21867754Smsmith
21967754Smsmith/*
22067754Smsmith * We want the debug switches statically initialized so they
22167754Smsmith * are already set when the debugger is entered.
22267754Smsmith */
22367754Smsmith
22467754Smsmith/* Debug switch - level and trace mask */
22567754Smsmith
226102550Siwasaki#ifdef ACPI_DEBUG_OUTPUT
227114237SnjlUINT32                      AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
22867754Smsmith#else
229114237SnjlUINT32                      AcpiDbgLevel = ACPI_NORMAL_DEFAULT;
23067754Smsmith#endif
23167754Smsmith
23267754Smsmith/* Debug switch - layer (component) mask */
23367754Smsmith
23477424SmsmithUINT32                      AcpiDbgLayer = ACPI_COMPONENT_DEFAULT;
23567754SmsmithUINT32                      AcpiGbl_NestingLevel = 0;
23667754Smsmith
23767754Smsmith
23867754Smsmith/* Debugger globals */
23967754Smsmith
24067754SmsmithBOOLEAN                     AcpiGbl_DbTerminateThreads = FALSE;
241114237SnjlBOOLEAN                     AcpiGbl_AbortMethod = FALSE;
24267754SmsmithBOOLEAN                     AcpiGbl_MethodExecuting = FALSE;
24367754Smsmith
24467754Smsmith/* System flags */
24567754Smsmith
24667754SmsmithUINT32                      AcpiGbl_StartupFlags = 0;
24767754Smsmith
24887031Smsmith/* System starts uninitialized */
24983174Smsmith
25067754SmsmithBOOLEAN                     AcpiGbl_Shutdown = TRUE;
25167754Smsmith
25283174Smsmithconst UINT8                 AcpiGbl_DecodeTo8bit [8] = {1,2,4,8,16,32,64,128};
25367754Smsmith
254129684Snjlconst char                  *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] =
255129684Snjl{
256129684Snjl    "\\_S0_",
257129684Snjl    "\\_S1_",
258129684Snjl    "\\_S2_",
259129684Snjl    "\\_S3_",
260129684Snjl    "\\_S4_",
261129684Snjl    "\\_S5_"
262129684Snjl};
26369450Smsmith
264129684Snjlconst char                  *AcpiGbl_HighestDstateNames[4] =
265129684Snjl{
266129684Snjl    "_S1D",
267129684Snjl    "_S2D",
268129684Snjl    "_S3D",
269129684Snjl    "_S4D"
270129684Snjl};
27169450Smsmith
272129684Snjl/*
273129684Snjl * Strings supported by the _OSI predefined (internal) method.
274129684Snjl * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS.
275129684Snjl */
276129684Snjlconst char                  *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS] =
277129684Snjl{
278129684Snjl    "Linux",
279129684Snjl    "Windows 2000",
280129684Snjl    "Windows 2001",
281129684Snjl    "Windows 2001.1",
282129684Snjl    "Windows 2001 SP0",
283129684Snjl    "Windows 2001 SP1",
284129684Snjl    "Windows 2001 SP2",
285129684Snjl    "Windows 2001 SP3",
286129684Snjl    "Windows 2001 SP4"
287129684Snjl};
288127175Snjl
289127175Snjl
29067754Smsmith/******************************************************************************
29167754Smsmith *
29267754Smsmith * Namespace globals
29367754Smsmith *
29467754Smsmith ******************************************************************************/
29567754Smsmith
29667754Smsmith
29767754Smsmith/*
298104470Siwasaki * Predefined ACPI Names (Built-in to the Interpreter)
29967754Smsmith *
30077424Smsmith * NOTES:
301127175Snjl * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
30277424Smsmith *    during the initialization sequence.
30367754Smsmith */
30491116Smsmithconst ACPI_PREDEFINED_NAMES     AcpiGbl_PreDefinedNames[] =
30567754Smsmith{
306107325Siwasaki    {"_GPE",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
307107325Siwasaki    {"_PR_",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
30899679Siwasaki    {"_SB_",    ACPI_TYPE_DEVICE,           NULL},
309107325Siwasaki    {"_SI_",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
310129684Snjl    {"_TZ_",    ACPI_TYPE_THERMAL,          NULL},
31199146Siwasaki    {"_REV",    ACPI_TYPE_INTEGER,          "2"},
31299146Siwasaki    {"_OS_",    ACPI_TYPE_STRING,           ACPI_OS_NAME},
31399146Siwasaki    {"_GL_",    ACPI_TYPE_MUTEX,            "0"},
314102550Siwasaki
315127175Snjl#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
316102550Siwasaki    {"_OSI",    ACPI_TYPE_METHOD,           "1"},
317102550Siwasaki#endif
31899679Siwasaki    {NULL,      ACPI_TYPE_ANY,              NULL}              /* Table terminator */
31967754Smsmith};
32067754Smsmith
32167754Smsmith
32267754Smsmith/*
32367754Smsmith * Properties of the ACPI Object Types, both internal and external.
324104470Siwasaki * The table is indexed by values of ACPI_OBJECT_TYPE
32567754Smsmith */
32691116Smsmithconst UINT8                     AcpiGbl_NsProperties[] =
32767754Smsmith{
32891116Smsmith    ACPI_NS_NORMAL,                     /* 00 Any              */
32991116Smsmith    ACPI_NS_NORMAL,                     /* 01 Number           */
33091116Smsmith    ACPI_NS_NORMAL,                     /* 02 String           */
33191116Smsmith    ACPI_NS_NORMAL,                     /* 03 Buffer           */
33299146Siwasaki    ACPI_NS_NORMAL,                     /* 04 Package          */
33391116Smsmith    ACPI_NS_NORMAL,                     /* 05 FieldUnit        */
33499146Siwasaki    ACPI_NS_NEWSCOPE,                   /* 06 Device           */
33599146Siwasaki    ACPI_NS_NORMAL,                     /* 07 Event            */
33699146Siwasaki    ACPI_NS_NEWSCOPE,                   /* 08 Method           */
33799146Siwasaki    ACPI_NS_NORMAL,                     /* 09 Mutex            */
33899146Siwasaki    ACPI_NS_NORMAL,                     /* 10 Region           */
33999146Siwasaki    ACPI_NS_NEWSCOPE,                   /* 11 Power            */
34099146Siwasaki    ACPI_NS_NEWSCOPE,                   /* 12 Processor        */
34199146Siwasaki    ACPI_NS_NEWSCOPE,                   /* 13 Thermal          */
34291116Smsmith    ACPI_NS_NORMAL,                     /* 14 BufferField      */
34391116Smsmith    ACPI_NS_NORMAL,                     /* 15 DdbHandle        */
34491116Smsmith    ACPI_NS_NORMAL,                     /* 16 Debug Object     */
34591116Smsmith    ACPI_NS_NORMAL,                     /* 17 DefField         */
34691116Smsmith    ACPI_NS_NORMAL,                     /* 18 BankField        */
34791116Smsmith    ACPI_NS_NORMAL,                     /* 19 IndexField       */
34891116Smsmith    ACPI_NS_NORMAL,                     /* 20 Reference        */
34991116Smsmith    ACPI_NS_NORMAL,                     /* 21 Alias            */
350128212Snjl    ACPI_NS_NORMAL,                     /* 22 MethodAlias      */
351128212Snjl    ACPI_NS_NORMAL,                     /* 23 Notify           */
352128212Snjl    ACPI_NS_NORMAL,                     /* 24 Address Handler  */
353128212Snjl    ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 25 Resource Desc    */
354128212Snjl    ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 26 Resource Field   */
355128212Snjl    ACPI_NS_NEWSCOPE,                   /* 27 Scope            */
356128212Snjl    ACPI_NS_NORMAL,                     /* 28 Extra            */
357128212Snjl    ACPI_NS_NORMAL,                     /* 29 Data             */
358128212Snjl    ACPI_NS_NORMAL                      /* 30 Invalid          */
35967754Smsmith};
36067754Smsmith
36167754Smsmith
36271867Smsmith/* Hex to ASCII conversion table */
36371867Smsmith
364114237Snjlstatic const char           AcpiGbl_HexToAscii[] =
36571867Smsmith                                {'0','1','2','3','4','5','6','7',
36699679Siwasaki                                 '8','9','A','B','C','D','E','F'};
36771867Smsmith
36883174Smsmith/*****************************************************************************
36983174Smsmith *
37083174Smsmith * FUNCTION:    AcpiUtHexToAsciiChar
37183174Smsmith *
37283174Smsmith * PARAMETERS:  Integer             - Contains the hex digit
37383174Smsmith *              Position            - bit position of the digit within the
37483174Smsmith *                                    integer
37583174Smsmith *
37683174Smsmith * RETURN:      Ascii character
37783174Smsmith *
37883174Smsmith * DESCRIPTION: Convert a hex digit to an ascii character
37983174Smsmith *
38083174Smsmith ****************************************************************************/
38183174Smsmith
38299679Siwasakichar
38382367SmsmithAcpiUtHexToAsciiChar (
38482367Smsmith    ACPI_INTEGER            Integer,
38582367Smsmith    UINT32                  Position)
38682367Smsmith{
38771867Smsmith
38882367Smsmith    return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]);
38982367Smsmith}
39082367Smsmith
39183174Smsmith
39267754Smsmith/******************************************************************************
39367754Smsmith *
39491116Smsmith * Table name globals
39567754Smsmith *
39669450Smsmith * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
39769450Smsmith * it is NOT an exhaustive list of all possible ACPI tables.  All ACPI tables
39869450Smsmith * that are not used by the subsystem are simply ignored.
39969450Smsmith *
40091116Smsmith * Do NOT add any table to this list that is not consumed directly by this
40191116Smsmith * subsystem.
40291116Smsmith *
40367754Smsmith ******************************************************************************/
40467754Smsmith
405117521SnjlACPI_TABLE_LIST             AcpiGbl_TableLists[NUM_ACPI_TABLE_TYPES];
40667754Smsmith
407117521SnjlACPI_TABLE_SUPPORT          AcpiGbl_TableData[NUM_ACPI_TABLE_TYPES] =
40867754Smsmith{
409100966Siwasaki    /***********    Name,   Signature, Global typed pointer     Signature size,      Type                  How many allowed?,    Contains valid AML? */
41067754Smsmith
411100966Siwasaki    /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL,                    sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT     | ACPI_TABLE_SINGLE},
412123315Snjl    /* DSDT 1 */ {DSDT_SIG,  DSDT_SIG, (void *) &AcpiGbl_DSDT,  sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE   | ACPI_TABLE_EXECUTABLE},
413123315Snjl    /* FADT 2 */ {FADT_SIG,  FADT_SIG, (void *) &AcpiGbl_FADT,  sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY  | ACPI_TABLE_SINGLE},
414123315Snjl    /* FACS 3 */ {FACS_SIG,  FACS_SIG, (void *) &AcpiGbl_FACS,  sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE},
415100966Siwasaki    /* PSDT 4 */ {PSDT_SIG,  PSDT_SIG, NULL,                    sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY  | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
416100966Siwasaki    /* SSDT 5 */ {SSDT_SIG,  SSDT_SIG, NULL,                    sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY  | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
417100966Siwasaki    /* XSDT 6 */ {XSDT_SIG,  XSDT_SIG, NULL,                    sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT     | ACPI_TABLE_SINGLE},
41867754Smsmith};
41967754Smsmith
42067754Smsmith
42191116Smsmith/******************************************************************************
42291116Smsmith *
42391116Smsmith * Event and Hardware globals
42491116Smsmith *
42591116Smsmith ******************************************************************************/
42691116Smsmith
42791116SmsmithACPI_BIT_REGISTER_INFO      AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] =
42891116Smsmith{
42991116Smsmith    /* Name                                     Parent Register             Register Bit Position                   Register Bit Mask       */
43091116Smsmith
43191116Smsmith    /* ACPI_BITREG_TIMER_STATUS         */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_TIMER_STATUS,          ACPI_BITMASK_TIMER_STATUS},
43291116Smsmith    /* ACPI_BITREG_BUS_MASTER_STATUS    */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_BUS_MASTER_STATUS,     ACPI_BITMASK_BUS_MASTER_STATUS},
43391116Smsmith    /* ACPI_BITREG_GLOBAL_LOCK_STATUS   */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,    ACPI_BITMASK_GLOBAL_LOCK_STATUS},
43491116Smsmith    /* ACPI_BITREG_POWER_BUTTON_STATUS  */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_POWER_BUTTON_STATUS,   ACPI_BITMASK_POWER_BUTTON_STATUS},
43591116Smsmith    /* ACPI_BITREG_SLEEP_BUTTON_STATUS  */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,   ACPI_BITMASK_SLEEP_BUTTON_STATUS},
43691116Smsmith    /* ACPI_BITREG_RT_CLOCK_STATUS      */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_RT_CLOCK_STATUS,       ACPI_BITMASK_RT_CLOCK_STATUS},
43791116Smsmith    /* ACPI_BITREG_WAKE_STATUS          */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_WAKE_STATUS,           ACPI_BITMASK_WAKE_STATUS},
43891116Smsmith
43991116Smsmith    /* ACPI_BITREG_TIMER_ENABLE         */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_TIMER_ENABLE,          ACPI_BITMASK_TIMER_ENABLE},
44091116Smsmith    /* ACPI_BITREG_GLOBAL_LOCK_ENABLE   */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,    ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
44191116Smsmith    /* ACPI_BITREG_POWER_BUTTON_ENABLE  */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_POWER_BUTTON_ENABLE,   ACPI_BITMASK_POWER_BUTTON_ENABLE},
44291116Smsmith    /* ACPI_BITREG_SLEEP_BUTTON_ENABLE  */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,   ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
44391116Smsmith    /* ACPI_BITREG_RT_CLOCK_ENABLE      */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_RT_CLOCK_ENABLE,       ACPI_BITMASK_RT_CLOCK_ENABLE},
44491116Smsmith    /* ACPI_BITREG_WAKE_ENABLE          */   {ACPI_REGISTER_PM1_ENABLE,   0,                                      0},
44591116Smsmith
44691116Smsmith    /* ACPI_BITREG_SCI_ENABLE           */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SCI_ENABLE,            ACPI_BITMASK_SCI_ENABLE},
44791116Smsmith    /* ACPI_BITREG_BUS_MASTER_RLD       */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_BUS_MASTER_RLD,        ACPI_BITMASK_BUS_MASTER_RLD},
44891116Smsmith    /* ACPI_BITREG_GLOBAL_LOCK_RELEASE  */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,   ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
44991116Smsmith    /* ACPI_BITREG_SLEEP_TYPE_A         */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_TYPE_X,          ACPI_BITMASK_SLEEP_TYPE_X},
45091116Smsmith    /* ACPI_BITREG_SLEEP_TYPE_B         */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_TYPE_X,          ACPI_BITMASK_SLEEP_TYPE_X},
45191116Smsmith    /* ACPI_BITREG_SLEEP_ENABLE         */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_ENABLE,          ACPI_BITMASK_SLEEP_ENABLE},
45291116Smsmith
45391116Smsmith    /* ACPI_BITREG_ARB_DIS              */   {ACPI_REGISTER_PM2_CONTROL,  ACPI_BITPOSITION_ARB_DISABLE,           ACPI_BITMASK_ARB_DISABLE}
45491116Smsmith};
45591116Smsmith
45691116Smsmith
45791116SmsmithACPI_FIXED_EVENT_INFO       AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] =
45891116Smsmith{
45991116Smsmith    /* ACPI_EVENT_PMTIMER       */  {ACPI_BITREG_TIMER_STATUS,          ACPI_BITREG_TIMER_ENABLE,        ACPI_BITMASK_TIMER_STATUS,          ACPI_BITMASK_TIMER_ENABLE},
46091116Smsmith    /* ACPI_EVENT_GLOBAL        */  {ACPI_BITREG_GLOBAL_LOCK_STATUS,    ACPI_BITREG_GLOBAL_LOCK_ENABLE,  ACPI_BITMASK_GLOBAL_LOCK_STATUS,    ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
46191116Smsmith    /* ACPI_EVENT_POWER_BUTTON  */  {ACPI_BITREG_POWER_BUTTON_STATUS,   ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS,   ACPI_BITMASK_POWER_BUTTON_ENABLE},
46291116Smsmith    /* ACPI_EVENT_SLEEP_BUTTON  */  {ACPI_BITREG_SLEEP_BUTTON_STATUS,   ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS,   ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
463123315Snjl    /* ACPI_EVENT_RTC           */  {ACPI_BITREG_RT_CLOCK_STATUS,       ACPI_BITREG_RT_CLOCK_ENABLE,     ACPI_BITMASK_RT_CLOCK_STATUS,       ACPI_BITMASK_RT_CLOCK_ENABLE},
46491116Smsmith};
46591116Smsmith
46691116Smsmith/*****************************************************************************
46791116Smsmith *
46891116Smsmith * FUNCTION:    AcpiUtGetRegionName
46991116Smsmith *
47091116Smsmith * PARAMETERS:  None.
47191116Smsmith *
47291116Smsmith * RETURN:      Status
47391116Smsmith *
47491116Smsmith * DESCRIPTION: Translate a Space ID into a name string (Debug only)
47591116Smsmith *
47691116Smsmith ****************************************************************************/
47791116Smsmith
47891116Smsmith/* Region type decoding */
47991116Smsmith
480114237Snjlconst char        *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
48191116Smsmith{
482114237Snjl/*! [Begin] no source code translation (keep these ASL Keywords as-is) */
48391116Smsmith    "SystemMemory",
48491116Smsmith    "SystemIO",
485100966Siwasaki    "PCI_Config",
48691116Smsmith    "EmbeddedControl",
48791116Smsmith    "SMBus",
48891116Smsmith    "CMOS",
489100966Siwasaki    "PCIBARTarget",
490114237Snjl    "DataTable"
491114237Snjl/*! [End] no source code translation !*/
49291116Smsmith};
49391116Smsmith
49491116Smsmith
495114237Snjlchar *
49691116SmsmithAcpiUtGetRegionName (
49791116Smsmith    UINT8                   SpaceId)
49891116Smsmith{
49991116Smsmith
50091116Smsmith    if (SpaceId >= ACPI_USER_REGION_BEGIN)
50191116Smsmith    {
50291116Smsmith        return ("UserDefinedRegion");
50391116Smsmith    }
50491116Smsmith
50591116Smsmith    else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
50691116Smsmith    {
507114237Snjl        return ("InvalidSpaceId");
50891116Smsmith    }
50991116Smsmith
510114237Snjl    return ((char *) AcpiGbl_RegionTypes[SpaceId]);
51191116Smsmith}
51291116Smsmith
51391116Smsmith
51491116Smsmith/*****************************************************************************
51591116Smsmith *
51691116Smsmith * FUNCTION:    AcpiUtGetEventName
51791116Smsmith *
51891116Smsmith * PARAMETERS:  None.
51991116Smsmith *
52091116Smsmith * RETURN:      Status
52191116Smsmith *
52291116Smsmith * DESCRIPTION: Translate a Event ID into a name string (Debug only)
52391116Smsmith *
52491116Smsmith ****************************************************************************/
52591116Smsmith
52691116Smsmith/* Event type decoding */
52791116Smsmith
528114237Snjlstatic const char        *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
52991116Smsmith{
53091116Smsmith    "PM_Timer",
53191116Smsmith    "GlobalLock",
53291116Smsmith    "PowerButton",
53391116Smsmith    "SleepButton",
53491116Smsmith    "RealTimeClock",
53591116Smsmith};
53691116Smsmith
53791116Smsmith
538114237Snjlchar *
53991116SmsmithAcpiUtGetEventName (
54091116Smsmith    UINT32                  EventId)
54191116Smsmith{
54291116Smsmith
54391116Smsmith    if (EventId > ACPI_EVENT_MAX)
54491116Smsmith    {
54591116Smsmith        return ("InvalidEventID");
54691116Smsmith    }
54791116Smsmith
548114237Snjl    return ((char *) AcpiGbl_EventTypes[EventId]);
54991116Smsmith}
55091116Smsmith
55191116Smsmith
55267754Smsmith/*****************************************************************************
55367754Smsmith *
55491116Smsmith * FUNCTION:    AcpiUtGetTypeName
55591116Smsmith *
55691116Smsmith * PARAMETERS:  None.
55791116Smsmith *
55891116Smsmith * RETURN:      Status
55991116Smsmith *
56091116Smsmith * DESCRIPTION: Translate a Type ID into a name string (Debug only)
56191116Smsmith *
56291116Smsmith ****************************************************************************/
56391116Smsmith
56467754Smsmith/*
56567754Smsmith * Elements of AcpiGbl_NsTypeNames below must match
56667754Smsmith * one-to-one with values of ACPI_OBJECT_TYPE
56767754Smsmith *
56867754Smsmith * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when
56967754Smsmith * stored in a table it really means that we have thus far seen no evidence to
570127175Snjl * indicate what type is actually going to be stored for this entry.
57167754Smsmith */
572114237Snjlstatic const char           AcpiGbl_BadType[] = "UNDEFINED";
57385756Smsmith#define TYPE_NAME_LENGTH    12                           /* Maximum length of each string */
57467754Smsmith
575114237Snjlstatic const char           *AcpiGbl_NsTypeNames[] =    /* printable names of ACPI types */
57667754Smsmith{
57767754Smsmith    /* 00 */ "Untyped",
57871867Smsmith    /* 01 */ "Integer",
57967754Smsmith    /* 02 */ "String",
58067754Smsmith    /* 03 */ "Buffer",
58167754Smsmith    /* 04 */ "Package",
58267754Smsmith    /* 05 */ "FieldUnit",
58367754Smsmith    /* 06 */ "Device",
58467754Smsmith    /* 07 */ "Event",
58567754Smsmith    /* 08 */ "Method",
58667754Smsmith    /* 09 */ "Mutex",
58767754Smsmith    /* 10 */ "Region",
58867754Smsmith    /* 11 */ "Power",
58967754Smsmith    /* 12 */ "Processor",
59067754Smsmith    /* 13 */ "Thermal",
59185756Smsmith    /* 14 */ "BufferField",
59267754Smsmith    /* 15 */ "DdbHandle",
59385756Smsmith    /* 16 */ "DebugObject",
59485756Smsmith    /* 17 */ "RegionField",
59577424Smsmith    /* 18 */ "BankField",
59685756Smsmith    /* 19 */ "IndexField",
59767754Smsmith    /* 20 */ "Reference",
59867754Smsmith    /* 21 */ "Alias",
599128212Snjl    /* 22 */ "MethodAlias",
600128212Snjl    /* 23 */ "Notify",
601128212Snjl    /* 24 */ "AddrHandler",
602128212Snjl    /* 25 */ "ResourceDesc",
603128212Snjl    /* 26 */ "ResourceFld",
604128212Snjl    /* 27 */ "Scope",
605128212Snjl    /* 28 */ "Extra",
606128212Snjl    /* 29 */ "Data",
607128212Snjl    /* 30 */ "Invalid"
60867754Smsmith};
60967754Smsmith
61067754Smsmith
611114237Snjlchar *
61277424SmsmithAcpiUtGetTypeName (
61391116Smsmith    ACPI_OBJECT_TYPE        Type)
61467754Smsmith{
61567754Smsmith
616107325Siwasaki    if (Type > ACPI_TYPE_INVALID)
61767754Smsmith    {
618114237Snjl        return ((char *) AcpiGbl_BadType);
61967754Smsmith    }
62067754Smsmith
621114237Snjl    return ((char *) AcpiGbl_NsTypeNames[Type]);
62267754Smsmith}
62367754Smsmith
62469746Smsmith
625114237Snjlchar *
62699679SiwasakiAcpiUtGetObjectTypeName (
62799679Siwasaki    ACPI_OPERAND_OBJECT     *ObjDesc)
62899679Siwasaki{
62999679Siwasaki
63099679Siwasaki    if (!ObjDesc)
63199679Siwasaki    {
63299679Siwasaki        return ("[NULL Object Descriptor]");
63399679Siwasaki    }
63499679Siwasaki
63599679Siwasaki    return (AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc)));
63699679Siwasaki}
63799679Siwasaki
63899679Siwasaki
639123315Snjl/*****************************************************************************
640123315Snjl *
641123315Snjl * FUNCTION:    AcpiUtGetNodeName
642123315Snjl *
643123315Snjl * PARAMETERS:  Object               - A namespace node
644123315Snjl *
645123315Snjl * RETURN:      Pointer to a string
646123315Snjl *
647123315Snjl * DESCRIPTION: Validate the node and return the node's ACPI name.
648123315Snjl *
649123315Snjl ****************************************************************************/
650123315Snjl
651123315Snjlchar *
652123315SnjlAcpiUtGetNodeName (
653123315Snjl    void                    *Object)
654123315Snjl{
655128212Snjl    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) Object;
656123315Snjl
657123315Snjl
658128212Snjl    /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
659128212Snjl
660123315Snjl    if (!Object)
661123315Snjl    {
662128212Snjl        return ("NULL");
663123315Snjl    }
664123315Snjl
665128212Snjl    /* Check for Root node */
666123315Snjl
667128212Snjl    if ((Object == ACPI_ROOT_OBJECT) ||
668128212Snjl        (Object == AcpiGbl_RootNode))
669128212Snjl    {
670128212Snjl        return ("\"\\\" ");
671128212Snjl    }
672128212Snjl
673128212Snjl    /* Descriptor must be a namespace node */
674128212Snjl
675123315Snjl    if (Node->Descriptor != ACPI_DESC_TYPE_NAMED)
676123315Snjl    {
677128212Snjl        return ("####");
678123315Snjl    }
679123315Snjl
680128212Snjl    /* Name must be a valid ACPI name */
681128212Snjl
682123315Snjl    if (!AcpiUtValidAcpiName (* (UINT32 *) Node->Name.Ascii))
683123315Snjl    {
684128212Snjl        return ("????");
685123315Snjl    }
686123315Snjl
687128212Snjl    /* Return the name */
688128212Snjl
689123315Snjl    return (Node->Name.Ascii);
690123315Snjl}
691123315Snjl
692123315Snjl
693123315Snjl/*****************************************************************************
694123315Snjl *
695123315Snjl * FUNCTION:    AcpiUtGetDescriptorName
696123315Snjl *
697123315Snjl * PARAMETERS:  Object               - An ACPI object
698123315Snjl *
699123315Snjl * RETURN:      Pointer to a string
700123315Snjl *
701123315Snjl * DESCRIPTION: Validate object and return the descriptor type
702123315Snjl *
703123315Snjl ****************************************************************************/
704123315Snjl
705123315Snjlstatic const char           *AcpiGbl_DescTypeNames[] =    /* printable names of descriptor types */
706123315Snjl{
707123315Snjl    /* 00 */ "Invalid",
708123315Snjl    /* 01 */ "Cached",
709123315Snjl    /* 02 */ "State-Generic",
710123315Snjl    /* 03 */ "State-Update",
711123315Snjl    /* 04 */ "State-Package",
712123315Snjl    /* 05 */ "State-Control",
713123315Snjl    /* 06 */ "State-RootParseScope",
714123315Snjl    /* 07 */ "State-ParseScope",
715123315Snjl    /* 08 */ "State-WalkScope",
716123315Snjl    /* 09 */ "State-Result",
717123315Snjl    /* 10 */ "State-Notify",
718123315Snjl    /* 11 */ "State-Thread",
719123315Snjl    /* 12 */ "Walk",
720123315Snjl    /* 13 */ "Parser",
721123315Snjl    /* 14 */ "Operand",
722123315Snjl    /* 15 */ "Node"
723123315Snjl};
724123315Snjl
725123315Snjl
726123315Snjlchar *
727123315SnjlAcpiUtGetDescriptorName (
728123315Snjl    void                    *Object)
729123315Snjl{
730123315Snjl
731123315Snjl    if (!Object)
732123315Snjl    {
733123315Snjl        return ("NULL OBJECT");
734123315Snjl    }
735123315Snjl
736123315Snjl    if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX)
737123315Snjl    {
738123315Snjl        return ((char *) AcpiGbl_BadType);
739123315Snjl    }
740123315Snjl
741123315Snjl    return ((char *) AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]);
742123315Snjl
743123315Snjl}
744123315Snjl
745123315Snjl
746102550Siwasaki#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
747100966Siwasaki/*
748100966Siwasaki * Strings and procedures used for debug only
749100966Siwasaki */
75099679Siwasaki
751100966Siwasaki/*****************************************************************************
752100966Siwasaki *
753100966Siwasaki * FUNCTION:    AcpiUtGetMutexName
754100966Siwasaki *
755100966Siwasaki * PARAMETERS:  None.
756100966Siwasaki *
757100966Siwasaki * RETURN:      Status
758100966Siwasaki *
759100966Siwasaki * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
760100966Siwasaki *
761100966Siwasaki ****************************************************************************/
76269746Smsmith
763114237Snjlchar *
764100966SiwasakiAcpiUtGetMutexName (
765100966Siwasaki    UINT32                  MutexId)
76669746Smsmith{
76769746Smsmith
768117521Snjl    if (MutexId > MAX_MUTEX)
769100966Siwasaki    {
770100966Siwasaki        return ("Invalid Mutex ID");
771100966Siwasaki    }
77269746Smsmith
773100966Siwasaki    return (AcpiGbl_MutexNames[MutexId]);
774100966Siwasaki}
77569746Smsmith
77667754Smsmith#endif
77767754Smsmith
77867754Smsmith
77967754Smsmith/*****************************************************************************
78067754Smsmith *
78177424Smsmith * FUNCTION:    AcpiUtValidObjectType
78267754Smsmith *
783107325Siwasaki * PARAMETERS:  Type            - Object type to be validated
78467754Smsmith *
78567754Smsmith * RETURN:      TRUE if valid object type
78667754Smsmith *
78767754Smsmith * DESCRIPTION: Validate an object type
78867754Smsmith *
78967754Smsmith ****************************************************************************/
79067754Smsmith
79167754SmsmithBOOLEAN
79277424SmsmithAcpiUtValidObjectType (
79391116Smsmith    ACPI_OBJECT_TYPE        Type)
79467754Smsmith{
79567754Smsmith
796107325Siwasaki    if (Type > ACPI_TYPE_LOCAL_MAX)
79767754Smsmith    {
798107325Siwasaki        /* Note: Assumes all TYPEs are contiguous (external/local) */
799107325Siwasaki
800107325Siwasaki        return (FALSE);
80167754Smsmith    }
80267754Smsmith
80367754Smsmith    return (TRUE);
80467754Smsmith}
80567754Smsmith
80667754Smsmith
80767754Smsmith/****************************************************************************
80867754Smsmith *
80977424Smsmith * FUNCTION:    AcpiUtAllocateOwnerId
81067754Smsmith *
81167754Smsmith * PARAMETERS:  IdType          - Type of ID (method or table)
81267754Smsmith *
81367754Smsmith * DESCRIPTION: Allocate a table or method owner id
81467754Smsmith *
81567754Smsmith ***************************************************************************/
81667754Smsmith
81767754SmsmithACPI_OWNER_ID
81877424SmsmithAcpiUtAllocateOwnerId (
81967754Smsmith    UINT32                  IdType)
82067754Smsmith{
82167754Smsmith    ACPI_OWNER_ID           OwnerId = 0xFFFF;
82267754Smsmith
82367754Smsmith
82491116Smsmith    ACPI_FUNCTION_TRACE ("UtAllocateOwnerId");
82567754Smsmith
82667754Smsmith
82791116Smsmith    if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
82891116Smsmith    {
82991116Smsmith        return (0);
83091116Smsmith    }
83167754Smsmith
83267754Smsmith    switch (IdType)
83367754Smsmith    {
83491116Smsmith    case ACPI_OWNER_TYPE_TABLE:
83567754Smsmith
83667754Smsmith        OwnerId = AcpiGbl_NextTableOwnerId;
83767754Smsmith        AcpiGbl_NextTableOwnerId++;
83867754Smsmith
839117521Snjl        /* Check for wraparound */
840117521Snjl
84191116Smsmith        if (AcpiGbl_NextTableOwnerId == ACPI_FIRST_METHOD_ID)
84267754Smsmith        {
84391116Smsmith            AcpiGbl_NextTableOwnerId = ACPI_FIRST_TABLE_ID;
844117521Snjl            ACPI_REPORT_WARNING (("Table owner ID wraparound\n"));
84567754Smsmith        }
84667754Smsmith        break;
84767754Smsmith
84867754Smsmith
84991116Smsmith    case ACPI_OWNER_TYPE_METHOD:
85067754Smsmith
85167754Smsmith        OwnerId = AcpiGbl_NextMethodOwnerId;
85267754Smsmith        AcpiGbl_NextMethodOwnerId++;
85367754Smsmith
85491116Smsmith        if (AcpiGbl_NextMethodOwnerId == ACPI_FIRST_TABLE_ID)
85567754Smsmith        {
856117521Snjl            /* Check for wraparound */
857117521Snjl
85891116Smsmith            AcpiGbl_NextMethodOwnerId = ACPI_FIRST_METHOD_ID;
85967754Smsmith        }
86067754Smsmith        break;
86199679Siwasaki
86299679Siwasaki    default:
86399679Siwasaki        break;
86467754Smsmith    }
86567754Smsmith
86691116Smsmith    (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
86767754Smsmith    return_VALUE (OwnerId);
86867754Smsmith}
86967754Smsmith
87067754Smsmith
87167754Smsmith/****************************************************************************
87267754Smsmith *
87377424Smsmith * FUNCTION:    AcpiUtInitGlobals
87467754Smsmith *
87567754Smsmith * PARAMETERS:  none
87667754Smsmith *
87767754Smsmith * DESCRIPTION: Init library globals.  All globals that require specific
87867754Smsmith *              initialization should be initialized here!
87967754Smsmith *
88067754Smsmith ***************************************************************************/
88167754Smsmith
88267754Smsmithvoid
88377424SmsmithAcpiUtInitGlobals (
88467754Smsmith    void)
88567754Smsmith{
88667754Smsmith    UINT32                  i;
88767754Smsmith
88867754Smsmith
88991116Smsmith    ACPI_FUNCTION_TRACE ("UtInitGlobals");
89067754Smsmith
891127175Snjl
89282367Smsmith    /* Memory allocation and cache lists */
89382367Smsmith
89491116Smsmith    ACPI_MEMSET (AcpiGbl_MemoryLists, 0, sizeof (ACPI_MEMORY_LIST) * ACPI_NUM_MEM_LISTS);
89582367Smsmith
89691116Smsmith    AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].LinkOffset         = (UINT16) ACPI_PTR_DIFF (&(((ACPI_GENERIC_STATE *) NULL)->Common.Next), NULL);
89799679Siwasaki    AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].LinkOffset        = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL);
89899679Siwasaki    AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].LinkOffset    = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL);
89991116Smsmith    AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].LinkOffset       = (UINT16) ACPI_PTR_DIFF (&(((ACPI_OPERAND_OBJECT *) NULL)->Cache.Next), NULL);
90091116Smsmith    AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].LinkOffset          = (UINT16) ACPI_PTR_DIFF (&(((ACPI_WALK_STATE *) NULL)->Next), NULL);
90182367Smsmith
90283174Smsmith    AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ObjectSize        = sizeof (ACPI_NAMESPACE_NODE);
90383174Smsmith    AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ObjectSize         = sizeof (ACPI_GENERIC_STATE);
90499679Siwasaki    AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ObjectSize        = sizeof (ACPI_PARSE_OBJ_COMMON);
90599679Siwasaki    AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ObjectSize    = sizeof (ACPI_PARSE_OBJ_NAMED);
90683174Smsmith    AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ObjectSize       = sizeof (ACPI_OPERAND_OBJECT);
90783174Smsmith    AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ObjectSize          = sizeof (ACPI_WALK_STATE);
90882367Smsmith
909114237Snjl    AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].MaxCacheDepth      = ACPI_MAX_STATE_CACHE_DEPTH;
910114237Snjl    AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].MaxCacheDepth     = ACPI_MAX_PARSE_CACHE_DEPTH;
911114237Snjl    AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].MaxCacheDepth = ACPI_MAX_EXTPARSE_CACHE_DEPTH;
912114237Snjl    AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].MaxCacheDepth    = ACPI_MAX_OBJECT_CACHE_DEPTH;
913114237Snjl    AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].MaxCacheDepth       = ACPI_MAX_WALK_CACHE_DEPTH;
91482367Smsmith
91583174Smsmith    ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].ListName       = "Global Memory Allocation");
91683174Smsmith    ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ListName       = "Namespace Nodes");
91783174Smsmith    ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ListName        = "State Object Cache");
91883174Smsmith    ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ListName       = "Parse Node Cache");
91983174Smsmith    ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ListName   = "Extended Parse Node Cache");
92083174Smsmith    ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ListName      = "Operand Object Cache");
92183174Smsmith    ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ListName         = "Tree Walk Node Cache");
92282367Smsmith
92367754Smsmith    /* ACPI table structure */
92467754Smsmith
925117521Snjl    for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++)
92667754Smsmith    {
927117521Snjl        AcpiGbl_TableLists[i].Next          = NULL;
928117521Snjl        AcpiGbl_TableLists[i].Count         = 0;
92967754Smsmith    }
93067754Smsmith
93167754Smsmith    /* Mutex locked flags */
93267754Smsmith
933117521Snjl    for (i = 0; i < NUM_MUTEX; i++)
93467754Smsmith    {
935117521Snjl        AcpiGbl_MutexInfo[i].Mutex          = NULL;
936117521Snjl        AcpiGbl_MutexInfo[i].OwnerId        = ACPI_MUTEX_NOT_ACQUIRED;
937117521Snjl        AcpiGbl_MutexInfo[i].UseCount       = 0;
93867754Smsmith    }
93967754Smsmith
940114237Snjl    /* GPE support */
941114237Snjl
942117521Snjl    AcpiGbl_GpeXruptListHead            = NULL;
943117521Snjl    AcpiGbl_GpeFadtBlocks[0]            = NULL;
944117521Snjl    AcpiGbl_GpeFadtBlocks[1]            = NULL;
945114237Snjl
94667754Smsmith    /* Global notify handlers */
94767754Smsmith
948117521Snjl    AcpiGbl_SystemNotify.Handler        = NULL;
949117521Snjl    AcpiGbl_DeviceNotify.Handler        = NULL;
950138287Smarks    AcpiGbl_ExceptionHandler            = NULL;
95199679Siwasaki    AcpiGbl_InitHandler                 = NULL;
95267754Smsmith
95367754Smsmith    /* Global "typed" ACPI table pointers */
95467754Smsmith
95567754Smsmith    AcpiGbl_RSDP                        = NULL;
95669450Smsmith    AcpiGbl_XSDT                        = NULL;
95767754Smsmith    AcpiGbl_FACS                        = NULL;
95869450Smsmith    AcpiGbl_FADT                        = NULL;
95967754Smsmith    AcpiGbl_DSDT                        = NULL;
96067754Smsmith
96167754Smsmith    /* Global Lock support */
96267754Smsmith
96367754Smsmith    AcpiGbl_GlobalLockAcquired          = FALSE;
96467754Smsmith    AcpiGbl_GlobalLockThreadCount       = 0;
96591116Smsmith    AcpiGbl_GlobalLockHandle            = 0;
96667754Smsmith
96767754Smsmith    /* Miscellaneous variables */
96867754Smsmith
96999146Siwasaki    AcpiGbl_TableFlags                  = ACPI_PHYSICAL_POINTER;
97067754Smsmith    AcpiGbl_RsdpOriginalLocation        = 0;
97167754Smsmith    AcpiGbl_CmSingleStep                = FALSE;
97267754Smsmith    AcpiGbl_DbTerminateThreads          = FALSE;
97367754Smsmith    AcpiGbl_Shutdown                    = FALSE;
97467754Smsmith    AcpiGbl_NsLookupCount               = 0;
97567754Smsmith    AcpiGbl_PsFindCount                 = 0;
97667754Smsmith    AcpiGbl_AcpiHardwarePresent         = TRUE;
97791116Smsmith    AcpiGbl_NextTableOwnerId            = ACPI_FIRST_TABLE_ID;
97891116Smsmith    AcpiGbl_NextMethodOwnerId           = ACPI_FIRST_METHOD_ID;
97967754Smsmith    AcpiGbl_DebuggerConfiguration       = DEBUGGER_THREADING;
98091116Smsmith    AcpiGbl_DbOutputFlags               = ACPI_DB_CONSOLE_OUTPUT;
98167754Smsmith
98267754Smsmith    /* Hardware oriented */
98367754Smsmith
984104470Siwasaki    AcpiGbl_EventsInitialized           = FALSE;
985129684Snjl    AcpiGbl_SystemAwakeAndRunning       = TRUE;
98667754Smsmith
98767754Smsmith    /* Namespace */
98867754Smsmith
98967754Smsmith    AcpiGbl_RootNode                    = NULL;
99067754Smsmith
99199146Siwasaki    AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
99291116Smsmith    AcpiGbl_RootNodeStruct.Descriptor   = ACPI_DESC_TYPE_NAMED;
993107325Siwasaki    AcpiGbl_RootNodeStruct.Type         = ACPI_TYPE_DEVICE;
99467754Smsmith    AcpiGbl_RootNodeStruct.Child        = NULL;
99567754Smsmith    AcpiGbl_RootNodeStruct.Peer         = NULL;
99667754Smsmith    AcpiGbl_RootNodeStruct.Object       = NULL;
99767754Smsmith    AcpiGbl_RootNodeStruct.Flags        = ANOBJ_END_OF_PEER_LIST;
99867754Smsmith
99967754Smsmith
1000102550Siwasaki#ifdef ACPI_DEBUG_OUTPUT
100199679Siwasaki    AcpiGbl_LowestStackPointer          = ACPI_SIZE_MAX;
100283174Smsmith#endif
100383174Smsmith
100467754Smsmith    return_VOID;
100567754Smsmith}
100667754Smsmith
100767754Smsmith
1008