xref: /onnv-gate/usr/src/uts/intel/io/acpica/utilities/utxface.c (revision 11225:eb6056029d84)
13446Smrj /******************************************************************************
23446Smrj  *
33446Smrj  * Module Name: utxface - External interfaces for "global" ACPI functions
43446Smrj  *
53446Smrj  *****************************************************************************/
63446Smrj 
73446Smrj /******************************************************************************
83446Smrj  *
93446Smrj  * 1. Copyright Notice
103446Smrj  *
119980SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
123446Smrj  * All rights reserved.
133446Smrj  *
143446Smrj  * 2. License
153446Smrj  *
163446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
173446Smrj  * rights.  You may have additional license terms from the party that provided
183446Smrj  * you this software, covering your right to use that party's intellectual
193446Smrj  * property rights.
203446Smrj  *
213446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
223446Smrj  * copy of the source code appearing in this file ("Covered Code") an
233446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
243446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
253446Smrj  * make derivatives, distribute, use and display any portion of the Covered
263446Smrj  * Code in any form, with the right to sublicense such rights; and
273446Smrj  *
283446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
293446Smrj  * license (with the right to sublicense), under only those claims of Intel
303446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
313446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
323446Smrj  * solely to the minimum extent necessary to exercise the above copyright
333446Smrj  * license, and in no event shall the patent license extend to any additions
343446Smrj  * to or modifications of the Original Intel Code.  No other license or right
353446Smrj  * is granted directly or by implication, estoppel or otherwise;
363446Smrj  *
373446Smrj  * The above copyright and patent license is granted only if the following
383446Smrj  * conditions are met:
393446Smrj  *
403446Smrj  * 3. Conditions
413446Smrj  *
423446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
433446Smrj  * Redistribution of source code of any substantial portion of the Covered
443446Smrj  * Code or modification with rights to further distribute source must include
453446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
463446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
473446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
483446Smrj  * contain a file documenting the changes Licensee made to create that Covered
493446Smrj  * Code and the date of any change.  Licensee must include in that file the
503446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
513446Smrj  * must include a prominent statement that the modification is derived,
523446Smrj  * directly or indirectly, from Original Intel Code.
533446Smrj  *
543446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
553446Smrj  * Redistribution of source code of any substantial portion of the Covered
563446Smrj  * Code or modification without rights to further distribute source must
573446Smrj  * include the following Disclaimer and Export Compliance provision in the
583446Smrj  * documentation and/or other materials provided with distribution.  In
593446Smrj  * addition, Licensee may not authorize further sublicense of source of any
603446Smrj  * portion of the Covered Code, and must include terms to the effect that the
613446Smrj  * license from Licensee to its licensee is limited to the intellectual
623446Smrj  * property embodied in the software Licensee provides to its licensee, and
633446Smrj  * not to intellectual property embodied in modifications its licensee may
643446Smrj  * make.
653446Smrj  *
663446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
673446Smrj  * substantial portion of the Covered Code or modification must reproduce the
683446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
693446Smrj  * provision in the documentation and/or other materials provided with the
703446Smrj  * distribution.
713446Smrj  *
723446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
733446Smrj  * Intel Code.
743446Smrj  *
753446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
763446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
773446Smrj  * other dealings in products derived from or relating to the Covered Code
783446Smrj  * without prior written authorization from Intel.
793446Smrj  *
803446Smrj  * 4. Disclaimer and Export Compliance
813446Smrj  *
823446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
833446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
843446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
853446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
863446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
873446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
883446Smrj  * PARTICULAR PURPOSE.
893446Smrj  *
903446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
913446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
923446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
933446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
943446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
953446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
963446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
973446Smrj  * LIMITED REMEDY.
983446Smrj  *
993446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1003446Smrj  * software or system incorporating such software without first obtaining any
1013446Smrj  * required license or other approval from the U. S. Department of Commerce or
1023446Smrj  * any other agency or department of the United States Government.  In the
1033446Smrj  * event Licensee exports any such software from the United States or
1043446Smrj  * re-exports any such software from a foreign destination, Licensee shall
1053446Smrj  * ensure that the distribution and export/re-export of the software is in
1063446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
1073446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1083446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
1093446Smrj  * software, or service, directly or indirectly, to any country for which the
1103446Smrj  * United States government or any agency thereof requires an export license,
1113446Smrj  * other governmental approval, or letter of assurance, without first obtaining
1123446Smrj  * such license, approval or letter.
1133446Smrj  *
1143446Smrj  *****************************************************************************/
1153446Smrj 
1163446Smrj 
1173446Smrj #define __UTXFACE_C__
1183446Smrj 
1193446Smrj #include "acpi.h"
1209980SDana.Myers@Sun.COM #include "accommon.h"
1213446Smrj #include "acevents.h"
1223446Smrj #include "acnamesp.h"
1233446Smrj #include "acdebug.h"
1249980SDana.Myers@Sun.COM #include "actables.h"
1253446Smrj 
1263446Smrj #define _COMPONENT          ACPI_UTILITIES
1273446Smrj         ACPI_MODULE_NAME    ("utxface")
1283446Smrj 
1293446Smrj 
1307851SDana.Myers@Sun.COM #ifndef ACPI_ASL_COMPILER
1317851SDana.Myers@Sun.COM 
1323446Smrj /*******************************************************************************
1333446Smrj  *
1343446Smrj  * FUNCTION:    AcpiInitializeSubsystem
1353446Smrj  *
1363446Smrj  * PARAMETERS:  None
1373446Smrj  *
1383446Smrj  * RETURN:      Status
1393446Smrj  *
1403446Smrj  * DESCRIPTION: Initializes all global variables.  This is the first function
1413446Smrj  *              called, so any early initialization belongs here.
1423446Smrj  *
1433446Smrj  ******************************************************************************/
1443446Smrj 
1453446Smrj ACPI_STATUS
AcpiInitializeSubsystem(void)1463446Smrj AcpiInitializeSubsystem (
1473446Smrj     void)
1483446Smrj {
1493446Smrj     ACPI_STATUS             Status;
1503446Smrj 
1513446Smrj 
1523446Smrj     ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem);
1533446Smrj 
1543446Smrj 
1557851SDana.Myers@Sun.COM     AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;
1563446Smrj     ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());
1573446Smrj 
1583446Smrj     /* Initialize the OS-Dependent layer */
1593446Smrj 
1603446Smrj     Status = AcpiOsInitialize ();
1613446Smrj     if (ACPI_FAILURE (Status))
1623446Smrj     {
1633446Smrj         ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization"));
1643446Smrj         return_ACPI_STATUS (Status);
1653446Smrj     }
1663446Smrj 
1673446Smrj     /* Initialize all globals used by the subsystem */
1683446Smrj 
1697851SDana.Myers@Sun.COM     Status = AcpiUtInitGlobals ();
1707851SDana.Myers@Sun.COM     if (ACPI_FAILURE (Status))
1717851SDana.Myers@Sun.COM     {
1727851SDana.Myers@Sun.COM         ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals"));
1737851SDana.Myers@Sun.COM         return_ACPI_STATUS (Status);
1747851SDana.Myers@Sun.COM     }
1753446Smrj 
1763446Smrj     /* Create the default mutex objects */
1773446Smrj 
1783446Smrj     Status = AcpiUtMutexInitialize ();
1793446Smrj     if (ACPI_FAILURE (Status))
1803446Smrj     {
1813446Smrj         ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation"));
1823446Smrj         return_ACPI_STATUS (Status);
1833446Smrj     }
1843446Smrj 
1853446Smrj     /*
1863446Smrj      * Initialize the namespace manager and
1873446Smrj      * the root of the namespace tree
1883446Smrj      */
1893446Smrj     Status = AcpiNsRootInitialize ();
1903446Smrj     if (ACPI_FAILURE (Status))
1913446Smrj     {
1923446Smrj         ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization"));
1933446Smrj         return_ACPI_STATUS (Status);
1943446Smrj     }
1953446Smrj 
1963446Smrj     /* If configured, initialize the AML debugger */
1973446Smrj 
1983446Smrj     ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ());
1993446Smrj     return_ACPI_STATUS (Status);
2003446Smrj }
2013446Smrj 
ACPI_EXPORT_SYMBOL(AcpiInitializeSubsystem)2023446Smrj ACPI_EXPORT_SYMBOL (AcpiInitializeSubsystem)
2033446Smrj 
2043446Smrj 
2053446Smrj /*******************************************************************************
2063446Smrj  *
2073446Smrj  * FUNCTION:    AcpiEnableSubsystem
2083446Smrj  *
2093446Smrj  * PARAMETERS:  Flags           - Init/enable Options
2103446Smrj  *
2113446Smrj  * RETURN:      Status
2123446Smrj  *
2133446Smrj  * DESCRIPTION: Completes the subsystem initialization including hardware.
2143446Smrj  *              Puts system into ACPI mode if it isn't already.
2153446Smrj  *
2163446Smrj  ******************************************************************************/
2173446Smrj 
2183446Smrj ACPI_STATUS
2193446Smrj AcpiEnableSubsystem (
2203446Smrj     UINT32                  Flags)
2213446Smrj {
2223446Smrj     ACPI_STATUS             Status = AE_OK;
2233446Smrj 
2243446Smrj 
2253446Smrj     ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
2263446Smrj 
2273446Smrj 
2283446Smrj     /* Enable ACPI mode */
2293446Smrj 
2303446Smrj     if (!(Flags & ACPI_NO_ACPI_ENABLE))
2313446Smrj     {
2323446Smrj         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
2333446Smrj 
2343446Smrj         AcpiGbl_OriginalMode = AcpiHwGetMode();
2353446Smrj 
2363446Smrj         Status = AcpiEnable ();
2373446Smrj         if (ACPI_FAILURE (Status))
2383446Smrj         {
2393446Smrj             ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));
2403446Smrj             return_ACPI_STATUS (Status);
2413446Smrj         }
2423446Smrj     }
2433446Smrj 
2443446Smrj     /*
2459980SDana.Myers@Sun.COM      * Obtain a permanent mapping for the FACS. This is required for the
2469980SDana.Myers@Sun.COM      * Global Lock and the Firmware Waking Vector
2479980SDana.Myers@Sun.COM      */
2489980SDana.Myers@Sun.COM     Status = AcpiTbInitializeFacs ();
2499980SDana.Myers@Sun.COM     if (ACPI_FAILURE (Status))
2509980SDana.Myers@Sun.COM     {
2519980SDana.Myers@Sun.COM         ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
2529980SDana.Myers@Sun.COM         return_ACPI_STATUS (Status);
2539980SDana.Myers@Sun.COM     }
2549980SDana.Myers@Sun.COM 
2559980SDana.Myers@Sun.COM     /*
2563446Smrj      * Install the default OpRegion handlers.  These are installed unless
2573446Smrj      * other handlers have already been installed via the
2583446Smrj      * InstallAddressSpaceHandler interface.
2593446Smrj      */
2603446Smrj     if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
2613446Smrj     {
2623446Smrj         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
2633446Smrj             "[Init] Installing default address space handlers\n"));
2643446Smrj 
2653446Smrj         Status = AcpiEvInstallRegionHandlers ();
2663446Smrj         if (ACPI_FAILURE (Status))
2673446Smrj         {
2683446Smrj             return_ACPI_STATUS (Status);
2693446Smrj         }
2703446Smrj     }
2713446Smrj 
2723446Smrj     /*
2733446Smrj      * Initialize ACPI Event handling (Fixed and General Purpose)
2743446Smrj      *
2753446Smrj      * Note1: We must have the hardware and events initialized before we can
2763446Smrj      * execute any control methods safely. Any control method can require
2773446Smrj      * ACPI hardware support, so the hardware must be fully initialized before
2783446Smrj      * any method execution!
2793446Smrj      *
2803446Smrj      * Note2: Fixed events are initialized and enabled here. GPEs are
2813446Smrj      * initialized, but cannot be enabled until after the hardware is
2827851SDana.Myers@Sun.COM      * completely initialized (SCI and GlobalLock activated) and the various
2837851SDana.Myers@Sun.COM      * initialization control methods are run (_REG, _STA, _INI) on the
2847851SDana.Myers@Sun.COM      * entire namespace.
2853446Smrj      */
2863446Smrj     if (!(Flags & ACPI_NO_EVENT_INIT))
2873446Smrj     {
2883446Smrj         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
2893446Smrj             "[Init] Initializing ACPI events\n"));
2903446Smrj 
2913446Smrj         Status = AcpiEvInitializeEvents ();
2923446Smrj         if (ACPI_FAILURE (Status))
2933446Smrj         {
2943446Smrj             return_ACPI_STATUS (Status);
2953446Smrj         }
2963446Smrj     }
2973446Smrj 
2983446Smrj     /*
2993446Smrj      * Install the SCI handler and Global Lock handler. This completes the
3003446Smrj      * hardware initialization.
3013446Smrj      */
3023446Smrj     if (!(Flags & ACPI_NO_HANDLER_INIT))
3033446Smrj     {
3043446Smrj         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
3053446Smrj             "[Init] Installing SCI/GL handlers\n"));
3063446Smrj 
3073446Smrj         Status = AcpiEvInstallXruptHandlers ();
3083446Smrj         if (ACPI_FAILURE (Status))
3093446Smrj         {
3103446Smrj             return_ACPI_STATUS (Status);
3113446Smrj         }
3123446Smrj     }
3133446Smrj 
3143446Smrj     return_ACPI_STATUS (Status);
3153446Smrj }
3163446Smrj 
ACPI_EXPORT_SYMBOL(AcpiEnableSubsystem)3173446Smrj ACPI_EXPORT_SYMBOL (AcpiEnableSubsystem)
3183446Smrj 
3193446Smrj 
3203446Smrj /*******************************************************************************
3213446Smrj  *
3223446Smrj  * FUNCTION:    AcpiInitializeObjects
3233446Smrj  *
3243446Smrj  * PARAMETERS:  Flags           - Init/enable Options
3253446Smrj  *
3263446Smrj  * RETURN:      Status
3273446Smrj  *
3283446Smrj  * DESCRIPTION: Completes namespace initialization by initializing device
3293446Smrj  *              objects and executing AML code for Regions, buffers, etc.
3303446Smrj  *
3313446Smrj  ******************************************************************************/
3323446Smrj 
3333446Smrj ACPI_STATUS
3343446Smrj AcpiInitializeObjects (
3353446Smrj     UINT32                  Flags)
3363446Smrj {
3373446Smrj     ACPI_STATUS             Status = AE_OK;
3383446Smrj 
3393446Smrj 
3403446Smrj     ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
3413446Smrj 
3423446Smrj 
3433446Smrj     /*
3443446Smrj      * Run all _REG methods
3453446Smrj      *
3463446Smrj      * Note: Any objects accessed by the _REG methods will be automatically
3473446Smrj      * initialized, even if they contain executable AML (see the call to
3483446Smrj      * AcpiNsInitializeObjects below).
3493446Smrj      */
3503446Smrj     if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
3513446Smrj     {
3523446Smrj         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
3533446Smrj             "[Init] Executing _REG OpRegion methods\n"));
3543446Smrj 
3553446Smrj         Status = AcpiEvInitializeOpRegions ();
3563446Smrj         if (ACPI_FAILURE (Status))
3573446Smrj         {
3583446Smrj             return_ACPI_STATUS (Status);
3593446Smrj         }
3603446Smrj     }
3613446Smrj 
3623446Smrj     /*
363*11225SDana.Myers@Sun.COM      * Execute any module-level code that was detected during the table load
364*11225SDana.Myers@Sun.COM      * phase. Although illegal since ACPI 2.0, there are many machines that
365*11225SDana.Myers@Sun.COM      * contain this type of code. Each block of detected executable AML code
366*11225SDana.Myers@Sun.COM      * outside of any control method is wrapped with a temporary control
367*11225SDana.Myers@Sun.COM      * method object and placed on a global list. The methods on this list
368*11225SDana.Myers@Sun.COM      * are executed below.
369*11225SDana.Myers@Sun.COM      */
370*11225SDana.Myers@Sun.COM     AcpiNsExecModuleCodeList ();
371*11225SDana.Myers@Sun.COM 
372*11225SDana.Myers@Sun.COM     /*
3733446Smrj      * Initialize the objects that remain uninitialized. This runs the
3743446Smrj      * executable AML that may be part of the declaration of these objects:
3753446Smrj      * OperationRegions, BufferFields, Buffers, and Packages.
3763446Smrj      */
3773446Smrj     if (!(Flags & ACPI_NO_OBJECT_INIT))
3783446Smrj     {
3793446Smrj         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
3803446Smrj             "[Init] Completing Initialization of ACPI Objects\n"));
3813446Smrj 
3823446Smrj         Status = AcpiNsInitializeObjects ();
3833446Smrj         if (ACPI_FAILURE (Status))
3843446Smrj         {
3853446Smrj             return_ACPI_STATUS (Status);
3863446Smrj         }
3873446Smrj     }
3883446Smrj 
3893446Smrj     /*
3903446Smrj      * Initialize all device objects in the namespace. This runs the device
3913446Smrj      * _STA and _INI methods.
3923446Smrj      */
3933446Smrj     if (!(Flags & ACPI_NO_DEVICE_INIT))
3943446Smrj     {
3953446Smrj         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
3963446Smrj             "[Init] Initializing ACPI Devices\n"));
3973446Smrj 
3983446Smrj         Status = AcpiNsInitializeDevices ();
3993446Smrj         if (ACPI_FAILURE (Status))
4003446Smrj         {
4013446Smrj             return_ACPI_STATUS (Status);
4023446Smrj         }
4033446Smrj     }
4043446Smrj 
4053446Smrj     /*
4067851SDana.Myers@Sun.COM      * Initialize the GPE blocks defined in the FADT (GPE block 0 and 1).
4077851SDana.Myers@Sun.COM      * The runtime GPEs are enabled here.
4087851SDana.Myers@Sun.COM      *
4097851SDana.Myers@Sun.COM      * This is where the _PRW methods are executed for the GPEs. These
4107851SDana.Myers@Sun.COM      * methods can only be executed after the SCI and Global Lock handlers are
4117851SDana.Myers@Sun.COM      * installed and initialized.
4127851SDana.Myers@Sun.COM      *
4137851SDana.Myers@Sun.COM      * GPEs can only be enabled after the _REG, _STA, and _INI methods have
4147851SDana.Myers@Sun.COM      * been run. This ensures that all Operation Regions and all Devices have
4157851SDana.Myers@Sun.COM      * been initialized and are ready.
4167851SDana.Myers@Sun.COM      */
4177851SDana.Myers@Sun.COM     if (!(Flags & ACPI_NO_EVENT_INIT))
4187851SDana.Myers@Sun.COM     {
4197851SDana.Myers@Sun.COM         Status = AcpiEvInstallFadtGpes ();
4207851SDana.Myers@Sun.COM         if (ACPI_FAILURE (Status))
4217851SDana.Myers@Sun.COM         {
4227851SDana.Myers@Sun.COM             return (Status);
4237851SDana.Myers@Sun.COM         }
4247851SDana.Myers@Sun.COM     }
4257851SDana.Myers@Sun.COM 
4267851SDana.Myers@Sun.COM     /*
4273446Smrj      * Empty the caches (delete the cached objects) on the assumption that
4283446Smrj      * the table load filled them up more than they will be at runtime --
4293446Smrj      * thus wasting non-paged memory.
4303446Smrj      */
4313446Smrj     Status = AcpiPurgeCachedObjects ();
4323446Smrj 
4333446Smrj     AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
4343446Smrj     return_ACPI_STATUS (Status);
4353446Smrj }
4363446Smrj 
ACPI_EXPORT_SYMBOL(AcpiInitializeObjects)4373446Smrj ACPI_EXPORT_SYMBOL (AcpiInitializeObjects)
4383446Smrj 
4393446Smrj 
4407851SDana.Myers@Sun.COM #endif
4417851SDana.Myers@Sun.COM 
4423446Smrj /*******************************************************************************
4433446Smrj  *
4443446Smrj  * FUNCTION:    AcpiTerminate
4453446Smrj  *
4463446Smrj  * PARAMETERS:  None
4473446Smrj  *
4483446Smrj  * RETURN:      Status
4493446Smrj  *
450*11225SDana.Myers@Sun.COM  * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources.
4513446Smrj  *
4523446Smrj  ******************************************************************************/
4533446Smrj 
4543446Smrj ACPI_STATUS
4553446Smrj AcpiTerminate (
4563446Smrj     void)
4573446Smrj {
4583446Smrj     ACPI_STATUS         Status;
4593446Smrj 
4603446Smrj 
4613446Smrj     ACPI_FUNCTION_TRACE (AcpiTerminate);
4623446Smrj 
4633446Smrj 
464*11225SDana.Myers@Sun.COM     /* Just exit if subsystem is already shutdown */
465*11225SDana.Myers@Sun.COM 
466*11225SDana.Myers@Sun.COM     if (AcpiGbl_Shutdown)
467*11225SDana.Myers@Sun.COM     {
468*11225SDana.Myers@Sun.COM         ACPI_ERROR ((AE_INFO, "ACPI Subsystem is already terminated"));
469*11225SDana.Myers@Sun.COM         return_ACPI_STATUS (AE_OK);
470*11225SDana.Myers@Sun.COM     }
471*11225SDana.Myers@Sun.COM 
472*11225SDana.Myers@Sun.COM     /* Subsystem appears active, go ahead and shut it down */
473*11225SDana.Myers@Sun.COM 
474*11225SDana.Myers@Sun.COM     AcpiGbl_Shutdown = TRUE;
475*11225SDana.Myers@Sun.COM     AcpiGbl_StartupFlags = 0;
476*11225SDana.Myers@Sun.COM     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
477*11225SDana.Myers@Sun.COM 
4783446Smrj     /* Terminate the AML Debugger if present */
4793446Smrj 
480*11225SDana.Myers@Sun.COM     ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = TRUE);
4813446Smrj 
4823446Smrj     /* Shutdown and free all resources */
4833446Smrj 
4843446Smrj     AcpiUtSubsystemShutdown ();
4853446Smrj 
4863446Smrj     /* Free the mutex objects */
4873446Smrj 
4883446Smrj     AcpiUtMutexTerminate ();
4893446Smrj 
4903446Smrj 
4913446Smrj #ifdef ACPI_DEBUGGER
4923446Smrj 
4933446Smrj     /* Shut down the debugger */
4943446Smrj 
4953446Smrj     AcpiDbTerminate ();
4963446Smrj #endif
4973446Smrj 
4983446Smrj     /* Now we can shutdown the OS-dependent layer */
4993446Smrj 
5003446Smrj     Status = AcpiOsTerminate ();
5013446Smrj     return_ACPI_STATUS (Status);
5023446Smrj }
5033446Smrj 
ACPI_EXPORT_SYMBOL(AcpiTerminate)5043446Smrj ACPI_EXPORT_SYMBOL (AcpiTerminate)
5053446Smrj 
506*11225SDana.Myers@Sun.COM 
5077851SDana.Myers@Sun.COM #ifndef ACPI_ASL_COMPILER
5083446Smrj /*******************************************************************************
5093446Smrj  *
5103446Smrj  * FUNCTION:    AcpiSubsystemStatus
5113446Smrj  *
5123446Smrj  * PARAMETERS:  None
5133446Smrj  *
5143446Smrj  * RETURN:      Status of the ACPI subsystem
5153446Smrj  *
5163446Smrj  * DESCRIPTION: Other drivers that use the ACPI subsystem should call this
5173446Smrj  *              before making any other calls, to ensure the subsystem
5183446Smrj  *              initialized successfully.
5193446Smrj  *
5203446Smrj  ******************************************************************************/
5213446Smrj 
5223446Smrj ACPI_STATUS
5233446Smrj AcpiSubsystemStatus (
5243446Smrj     void)
5253446Smrj {
5263446Smrj 
5273446Smrj     if (AcpiGbl_StartupFlags & ACPI_INITIALIZED_OK)
5283446Smrj     {
5293446Smrj         return (AE_OK);
5303446Smrj     }
5313446Smrj     else
5323446Smrj     {
5333446Smrj         return (AE_ERROR);
5343446Smrj     }
5353446Smrj }
5363446Smrj 
ACPI_EXPORT_SYMBOL(AcpiSubsystemStatus)5373446Smrj ACPI_EXPORT_SYMBOL (AcpiSubsystemStatus)
5383446Smrj 
5393446Smrj 
5403446Smrj /*******************************************************************************
5413446Smrj  *
5423446Smrj  * FUNCTION:    AcpiGetSystemInfo
5433446Smrj  *
5443446Smrj  * PARAMETERS:  OutBuffer       - A buffer to receive the resources for the
5453446Smrj  *                                device
5463446Smrj  *
5473446Smrj  * RETURN:      Status          - the status of the call
5483446Smrj  *
5493446Smrj  * DESCRIPTION: This function is called to get information about the current
5503446Smrj  *              state of the ACPI subsystem.  It will return system information
5513446Smrj  *              in the OutBuffer.
5523446Smrj  *
5533446Smrj  *              If the function fails an appropriate status will be returned
5543446Smrj  *              and the value of OutBuffer is undefined.
5553446Smrj  *
5563446Smrj  ******************************************************************************/
5573446Smrj 
5583446Smrj ACPI_STATUS
5593446Smrj AcpiGetSystemInfo (
5603446Smrj     ACPI_BUFFER             *OutBuffer)
5613446Smrj {
5623446Smrj     ACPI_SYSTEM_INFO        *InfoPtr;
5633446Smrj     ACPI_STATUS             Status;
5643446Smrj 
5653446Smrj 
5663446Smrj     ACPI_FUNCTION_TRACE (AcpiGetSystemInfo);
5673446Smrj 
5683446Smrj 
5693446Smrj     /* Parameter validation */
5703446Smrj 
5713446Smrj     Status = AcpiUtValidateBuffer (OutBuffer);
5723446Smrj     if (ACPI_FAILURE (Status))
5733446Smrj     {
5743446Smrj         return_ACPI_STATUS (Status);
5753446Smrj     }
5763446Smrj 
5773446Smrj     /* Validate/Allocate/Clear caller buffer */
5783446Smrj 
5793446Smrj     Status = AcpiUtInitializeBuffer (OutBuffer, sizeof (ACPI_SYSTEM_INFO));
5803446Smrj     if (ACPI_FAILURE (Status))
5813446Smrj     {
5823446Smrj         return_ACPI_STATUS (Status);
5833446Smrj     }
5843446Smrj 
5853446Smrj     /*
5863446Smrj      * Populate the return buffer
5873446Smrj      */
5883446Smrj     InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer;
5893446Smrj 
5903446Smrj     InfoPtr->AcpiCaVersion = ACPI_CA_VERSION;
5913446Smrj 
5923446Smrj     /* System flags (ACPI capabilities) */
5933446Smrj 
5943446Smrj     InfoPtr->Flags = ACPI_SYS_MODE_ACPI;
5953446Smrj 
5963446Smrj     /* Timer resolution - 24 or 32 bits  */
5973446Smrj 
5987851SDana.Myers@Sun.COM     if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER)
5993446Smrj     {
6003446Smrj         InfoPtr->TimerResolution = 24;
6013446Smrj     }
6023446Smrj     else
6033446Smrj     {
6043446Smrj         InfoPtr->TimerResolution = 32;
6053446Smrj     }
6063446Smrj 
6073446Smrj     /* Clear the reserved fields */
6083446Smrj 
6093446Smrj     InfoPtr->Reserved1 = 0;
6103446Smrj     InfoPtr->Reserved2 = 0;
6113446Smrj 
6123446Smrj     /* Current debug levels */
6133446Smrj 
6143446Smrj     InfoPtr->DebugLayer = AcpiDbgLayer;
6153446Smrj     InfoPtr->DebugLevel = AcpiDbgLevel;
6163446Smrj 
6177851SDana.Myers@Sun.COM     return_ACPI_STATUS (AE_OK);
6187851SDana.Myers@Sun.COM }
6197851SDana.Myers@Sun.COM 
ACPI_EXPORT_SYMBOL(AcpiGetSystemInfo)6207851SDana.Myers@Sun.COM ACPI_EXPORT_SYMBOL (AcpiGetSystemInfo)
6217851SDana.Myers@Sun.COM 
6227851SDana.Myers@Sun.COM 
6237851SDana.Myers@Sun.COM /*******************************************************************************
6247851SDana.Myers@Sun.COM  *
6257851SDana.Myers@Sun.COM  * FUNCTION:    AcpiGetStatistics
6267851SDana.Myers@Sun.COM  *
6277851SDana.Myers@Sun.COM  * PARAMETERS:  Stats           - Where the statistics are returned
6287851SDana.Myers@Sun.COM  *
6297851SDana.Myers@Sun.COM  * RETURN:      Status          - the status of the call
6307851SDana.Myers@Sun.COM  *
6317851SDana.Myers@Sun.COM  * DESCRIPTION: Get the contents of the various system counters
6327851SDana.Myers@Sun.COM  *
6337851SDana.Myers@Sun.COM  ******************************************************************************/
6343446Smrj 
6357851SDana.Myers@Sun.COM ACPI_STATUS
6367851SDana.Myers@Sun.COM AcpiGetStatistics (
6377851SDana.Myers@Sun.COM     ACPI_STATISTICS         *Stats)
6387851SDana.Myers@Sun.COM {
6397851SDana.Myers@Sun.COM     ACPI_FUNCTION_TRACE (AcpiGetStatistics);
6407851SDana.Myers@Sun.COM 
6417851SDana.Myers@Sun.COM 
6427851SDana.Myers@Sun.COM     /* Parameter validation */
6437851SDana.Myers@Sun.COM 
6447851SDana.Myers@Sun.COM     if (!Stats)
6453446Smrj     {
6467851SDana.Myers@Sun.COM         return_ACPI_STATUS (AE_BAD_PARAMETER);
6473446Smrj     }
6483446Smrj 
6497851SDana.Myers@Sun.COM     /* Various interrupt-based event counters */
6507851SDana.Myers@Sun.COM 
6517851SDana.Myers@Sun.COM     Stats->SciCount = AcpiSciCount;
6527851SDana.Myers@Sun.COM     Stats->GpeCount = AcpiGpeCount;
6537851SDana.Myers@Sun.COM 
6547851SDana.Myers@Sun.COM     ACPI_MEMCPY (Stats->FixedEventCount, AcpiFixedEventCount,
6557851SDana.Myers@Sun.COM         sizeof (AcpiFixedEventCount));
6567851SDana.Myers@Sun.COM 
6577851SDana.Myers@Sun.COM 
6587851SDana.Myers@Sun.COM     /* Other counters */
6597851SDana.Myers@Sun.COM 
6607851SDana.Myers@Sun.COM     Stats->MethodCount = AcpiMethodCount;
6617851SDana.Myers@Sun.COM 
6623446Smrj     return_ACPI_STATUS (AE_OK);
6633446Smrj }
6643446Smrj 
ACPI_EXPORT_SYMBOL(AcpiGetStatistics)6657851SDana.Myers@Sun.COM ACPI_EXPORT_SYMBOL (AcpiGetStatistics)
6663446Smrj 
6673446Smrj 
6683446Smrj /*****************************************************************************
6693446Smrj  *
6703446Smrj  * FUNCTION:    AcpiInstallInitializationHandler
6713446Smrj  *
6723446Smrj  * PARAMETERS:  Handler             - Callback procedure
6733446Smrj  *              Function            - Not (currently) used, see below
6743446Smrj  *
6753446Smrj  * RETURN:      Status
6763446Smrj  *
6773446Smrj  * DESCRIPTION: Install an initialization handler
6783446Smrj  *
6793446Smrj  * TBD: When a second function is added, must save the Function also.
6803446Smrj  *
6813446Smrj  ****************************************************************************/
6823446Smrj 
6833446Smrj ACPI_STATUS
6843446Smrj AcpiInstallInitializationHandler (
6853446Smrj     ACPI_INIT_HANDLER       Handler,
6863446Smrj     UINT32                  Function)
6873446Smrj {
6883446Smrj 
6893446Smrj     if (!Handler)
6903446Smrj     {
6913446Smrj         return (AE_BAD_PARAMETER);
6923446Smrj     }
6933446Smrj 
6943446Smrj     if (AcpiGbl_InitHandler)
6953446Smrj     {
6963446Smrj         return (AE_ALREADY_EXISTS);
6973446Smrj     }
6983446Smrj 
6993446Smrj     AcpiGbl_InitHandler = Handler;
7003446Smrj     return AE_OK;
7013446Smrj }
7023446Smrj 
ACPI_EXPORT_SYMBOL(AcpiInstallInitializationHandler)7033446Smrj ACPI_EXPORT_SYMBOL (AcpiInstallInitializationHandler)
7043446Smrj 
7053446Smrj 
7063446Smrj /*****************************************************************************
7073446Smrj  *
7083446Smrj  * FUNCTION:    AcpiPurgeCachedObjects
7093446Smrj  *
7103446Smrj  * PARAMETERS:  None
7113446Smrj  *
7123446Smrj  * RETURN:      Status
7133446Smrj  *
7143446Smrj  * DESCRIPTION: Empty all caches (delete the cached objects)
7153446Smrj  *
7163446Smrj  ****************************************************************************/
7173446Smrj 
7183446Smrj ACPI_STATUS
7193446Smrj AcpiPurgeCachedObjects (
7203446Smrj     void)
7213446Smrj {
7223446Smrj     ACPI_FUNCTION_TRACE (AcpiPurgeCachedObjects);
7233446Smrj 
7243446Smrj     (void) AcpiOsPurgeCache (AcpiGbl_StateCache);
7253446Smrj     (void) AcpiOsPurgeCache (AcpiGbl_OperandCache);
7263446Smrj     (void) AcpiOsPurgeCache (AcpiGbl_PsNodeCache);
7273446Smrj     (void) AcpiOsPurgeCache (AcpiGbl_PsNodeExtCache);
7283446Smrj     return_ACPI_STATUS (AE_OK);
7293446Smrj }
7303446Smrj 
7313446Smrj ACPI_EXPORT_SYMBOL (AcpiPurgeCachedObjects)
7327851SDana.Myers@Sun.COM 
7339980SDana.Myers@Sun.COM #endif /* ACPI_ASL_COMPILER */
7349980SDana.Myers@Sun.COM 
735