Path: blob/main/sys/contrib/dev/acpica/components/utilities/utxfinit.c
48406 views
/******************************************************************************1*2* Module Name: utxfinit - External interfaces for ACPICA initialization3*4*****************************************************************************/56/******************************************************************************7*8* 1. Copyright Notice9*10* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.11* All rights reserved.12*13* 2. License14*15* 2.1. This is your license from Intel Corp. under its intellectual property16* rights. You may have additional license terms from the party that provided17* you this software, covering your right to use that party's intellectual18* property rights.19*20* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a21* copy of the source code appearing in this file ("Covered Code") an22* irrevocable, perpetual, worldwide license under Intel's copyrights in the23* base code distributed originally by Intel ("Original Intel Code") to copy,24* make derivatives, distribute, use and display any portion of the Covered25* Code in any form, with the right to sublicense such rights; and26*27* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent28* license (with the right to sublicense), under only those claims of Intel29* patents that are infringed by the Original Intel Code, to make, use, sell,30* offer to sell, and import the Covered Code and derivative works thereof31* solely to the minimum extent necessary to exercise the above copyright32* license, and in no event shall the patent license extend to any additions33* to or modifications of the Original Intel Code. No other license or right34* is granted directly or by implication, estoppel or otherwise;35*36* The above copyright and patent license is granted only if the following37* conditions are met:38*39* 3. Conditions40*41* 3.1. Redistribution of Source with Rights to Further Distribute Source.42* Redistribution of source code of any substantial portion of the Covered43* Code or modification with rights to further distribute source must include44* the above Copyright Notice, the above License, this list of Conditions,45* and the following Disclaimer and Export Compliance provision. In addition,46* Licensee must cause all Covered Code to which Licensee contributes to47* contain a file documenting the changes Licensee made to create that Covered48* Code and the date of any change. Licensee must include in that file the49* documentation of any changes made by any predecessor Licensee. Licensee50* must include a prominent statement that the modification is derived,51* directly or indirectly, from Original Intel Code.52*53* 3.2. Redistribution of Source with no Rights to Further Distribute Source.54* Redistribution of source code of any substantial portion of the Covered55* Code or modification without rights to further distribute source must56* include the following Disclaimer and Export Compliance provision in the57* documentation and/or other materials provided with distribution. In58* addition, Licensee may not authorize further sublicense of source of any59* portion of the Covered Code, and must include terms to the effect that the60* license from Licensee to its licensee is limited to the intellectual61* property embodied in the software Licensee provides to its licensee, and62* not to intellectual property embodied in modifications its licensee may63* make.64*65* 3.3. Redistribution of Executable. Redistribution in executable form of any66* substantial portion of the Covered Code or modification must reproduce the67* above Copyright Notice, and the following Disclaimer and Export Compliance68* provision in the documentation and/or other materials provided with the69* distribution.70*71* 3.4. Intel retains all right, title, and interest in and to the Original72* Intel Code.73*74* 3.5. Neither the name Intel nor any other trademark owned or controlled by75* Intel shall be used in advertising or otherwise to promote the sale, use or76* other dealings in products derived from or relating to the Covered Code77* without prior written authorization from Intel.78*79* 4. Disclaimer and Export Compliance80*81* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED82* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE83* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,84* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY85* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY86* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A87* PARTICULAR PURPOSE.88*89* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES90* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR91* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,92* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY93* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL94* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS95* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY96* LIMITED REMEDY.97*98* 4.3. Licensee shall not export, either directly or indirectly, any of this99* software or system incorporating such software without first obtaining any100* required license or other approval from the U. S. Department of Commerce or101* any other agency or department of the United States Government. In the102* event Licensee exports any such software from the United States or103* re-exports any such software from a foreign destination, Licensee shall104* ensure that the distribution and export/re-export of the software is in105* compliance with all laws, regulations, orders, or other restrictions of the106* U.S. Export Administration Regulations. Licensee agrees that neither it nor107* any of its subsidiaries will export/re-export any technical data, process,108* software, or service, directly or indirectly, to any country for which the109* United States government or any agency thereof requires an export license,110* other governmental approval, or letter of assurance, without first obtaining111* such license, approval or letter.112*113*****************************************************************************114*115* Alternatively, you may choose to be licensed under the terms of the116* following license:117*118* Redistribution and use in source and binary forms, with or without119* modification, are permitted provided that the following conditions120* are met:121* 1. Redistributions of source code must retain the above copyright122* notice, this list of conditions, and the following disclaimer,123* without modification.124* 2. Redistributions in binary form must reproduce at minimum a disclaimer125* substantially similar to the "NO WARRANTY" disclaimer below126* ("Disclaimer") and any redistribution must be conditioned upon127* including a substantially similar Disclaimer requirement for further128* binary redistribution.129* 3. Neither the names of the above-listed copyright holders nor the names130* of any contributors may be used to endorse or promote products derived131* from this software without specific prior written permission.132*133* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS134* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT135* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR136* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT137* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,138* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT139* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,140* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY141* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT142* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE143* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.144*145* Alternatively, you may choose to be licensed under the terms of the146* GNU General Public License ("GPL") version 2 as published by the Free147* Software Foundation.148*149*****************************************************************************/150151#define EXPORT_ACPI_INTERFACES152153#include <contrib/dev/acpica/include/acpi.h>154#include <contrib/dev/acpica/include/accommon.h>155#include <contrib/dev/acpica/include/acevents.h>156#include <contrib/dev/acpica/include/acnamesp.h>157#include <contrib/dev/acpica/include/acdebug.h>158#include <contrib/dev/acpica/include/actables.h>159160#define _COMPONENT ACPI_UTILITIES161ACPI_MODULE_NAME ("utxfinit")162163/* For AcpiExec only */164void165AeDoObjectOverrides (166void);167168169/*******************************************************************************170*171* FUNCTION: AcpiInitializeSubsystem172*173* PARAMETERS: None174*175* RETURN: Status176*177* DESCRIPTION: Initializes all global variables. This is the first function178* called, so any early initialization belongs here.179*180******************************************************************************/181182ACPI_STATUS ACPI_INIT_FUNCTION183AcpiInitializeSubsystem (184void)185{186ACPI_STATUS Status;187188189ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem);190191192AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;193ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());194195/* Initialize the OS-Dependent layer */196197Status = AcpiOsInitialize ();198if (ACPI_FAILURE (Status))199{200ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization"));201return_ACPI_STATUS (Status);202}203204/* Initialize all globals used by the subsystem */205206Status = AcpiUtInitGlobals ();207if (ACPI_FAILURE (Status))208{209ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals"));210return_ACPI_STATUS (Status);211}212213/* Create the default mutex objects */214215Status = AcpiUtMutexInitialize ();216if (ACPI_FAILURE (Status))217{218ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation"));219return_ACPI_STATUS (Status);220}221222/*223* Initialize the namespace manager and224* the root of the namespace tree225*/226Status = AcpiNsRootInitialize ();227if (ACPI_FAILURE (Status))228{229ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization"));230return_ACPI_STATUS (Status);231}232233/* Initialize the global OSI interfaces list with the static names */234235Status = AcpiUtInitializeInterfaces ();236if (ACPI_FAILURE (Status))237{238ACPI_EXCEPTION ((AE_INFO, Status, "During OSI interfaces initialization"));239return_ACPI_STATUS (Status);240}241242return_ACPI_STATUS (AE_OK);243}244245ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeSubsystem)246247248/*******************************************************************************249*250* FUNCTION: AcpiEnableSubsystem251*252* PARAMETERS: Flags - Init/enable Options253*254* RETURN: Status255*256* DESCRIPTION: Completes the subsystem initialization including hardware.257* Puts system into ACPI mode if it isn't already.258*259******************************************************************************/260261ACPI_STATUS ACPI_INIT_FUNCTION262AcpiEnableSubsystem (263UINT32 Flags)264{265ACPI_STATUS Status = AE_OK;266267268ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);269270271/*272* The early initialization phase is complete. The namespace is loaded,273* and we can now support address spaces other than Memory, I/O, and274* PCI_Config.275*/276AcpiGbl_EarlyInitialization = FALSE;277278/*279* Obtain a permanent mapping for the FACS. This is required for the280* Global Lock and the Firmware Waking Vector281*/282if (!(Flags & ACPI_NO_FACS_INIT))283{284Status = AcpiTbInitializeFacs ();285if (ACPI_FAILURE (Status))286{287ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));288return_ACPI_STATUS (Status);289}290}291292#if (!ACPI_REDUCED_HARDWARE)293294/* Enable ACPI mode */295296if (!(Flags & ACPI_NO_ACPI_ENABLE))297{298ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));299300AcpiGbl_OriginalMode = AcpiHwGetMode();301302Status = AcpiEnable ();303if (ACPI_FAILURE (Status))304{305ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));306return_ACPI_STATUS (Status);307}308}309310/*311* Initialize ACPI Event handling (Fixed and General Purpose)312*313* Note1: We must have the hardware and events initialized before we can314* execute any control methods safely. Any control method can require315* ACPI hardware support, so the hardware must be fully initialized before316* any method execution!317*318* Note2: Fixed events are initialized and enabled here. GPEs are319* initialized, but cannot be enabled until after the hardware is320* completely initialized (SCI and GlobalLock activated) and the various321* initialization control methods are run (_REG, _STA, _INI) on the322* entire namespace.323*/324if (!(Flags & ACPI_NO_EVENT_INIT))325{326ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,327"[Init] Initializing ACPI events\n"));328329Status = AcpiEvInitializeEvents ();330if (ACPI_FAILURE (Status))331{332return_ACPI_STATUS (Status);333}334}335336/*337* Install the SCI handler and Global Lock handler. This completes the338* hardware initialization.339*/340if (!(Flags & ACPI_NO_HANDLER_INIT))341{342ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,343"[Init] Installing SCI/GL handlers\n"));344345Status = AcpiEvInstallXruptHandlers ();346if (ACPI_FAILURE (Status))347{348return_ACPI_STATUS (Status);349}350}351352#endif /* !ACPI_REDUCED_HARDWARE */353354return_ACPI_STATUS (Status);355}356357ACPI_EXPORT_SYMBOL_INIT (AcpiEnableSubsystem)358359360/*******************************************************************************361*362* FUNCTION: AcpiInitializeObjects363*364* PARAMETERS: Flags - Init/enable Options365*366* RETURN: Status367*368* DESCRIPTION: Completes namespace initialization by initializing device369* objects and executing AML code for Regions, buffers, etc.370*371******************************************************************************/372373ACPI_STATUS ACPI_INIT_FUNCTION374AcpiInitializeObjects (375UINT32 Flags)376{377ACPI_STATUS Status = AE_OK;378379380ACPI_FUNCTION_TRACE (AcpiInitializeObjects);381382383#ifdef ACPI_OBSOLETE_BEHAVIOR384/*385* 05/2019: Removed, initialization now happens at both object386* creation and table load time387*/388389/*390* Initialize the objects that remain uninitialized. This391* runs the executable AML that may be part of the392* declaration of these objects: OperationRegions, BufferFields,393* BankFields, Buffers, and Packages.394*/395if (!(Flags & ACPI_NO_OBJECT_INIT))396{397Status = AcpiNsInitializeObjects ();398if (ACPI_FAILURE (Status))399{400return_ACPI_STATUS (Status);401}402}403#endif404405/*406* Initialize all device/region objects in the namespace. This runs407* the device _STA and _INI methods and region _REG methods.408*/409if (!(Flags & (ACPI_NO_DEVICE_INIT | ACPI_NO_ADDRESS_SPACE_INIT)))410{411Status = AcpiNsInitializeDevices (Flags);412if (ACPI_FAILURE (Status))413{414return_ACPI_STATUS (Status);415}416}417418/*419* Empty the caches (delete the cached objects) on the assumption that420* the table load filled them up more than they will be at runtime --421* thus wasting non-paged memory.422*/423Status = AcpiPurgeCachedObjects ();424425AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;426return_ACPI_STATUS (Status);427}428429ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeObjects)430431432