173d4e80bSchristos /******************************************************************************
273d4e80bSchristos *
373d4e80bSchristos * Module Name: utxfinit - External interfaces for ACPICA initialization
473d4e80bSchristos *
573d4e80bSchristos *****************************************************************************/
673d4e80bSchristos
773d4e80bSchristos /*
8*e5631441Schristos * Copyright (C) 2000 - 2022, Intel Corp.
973d4e80bSchristos * All rights reserved.
1073d4e80bSchristos *
1173d4e80bSchristos * Redistribution and use in source and binary forms, with or without
1273d4e80bSchristos * modification, are permitted provided that the following conditions
1373d4e80bSchristos * are met:
1473d4e80bSchristos * 1. Redistributions of source code must retain the above copyright
1573d4e80bSchristos * notice, this list of conditions, and the following disclaimer,
1673d4e80bSchristos * without modification.
1773d4e80bSchristos * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1873d4e80bSchristos * substantially similar to the "NO WARRANTY" disclaimer below
1973d4e80bSchristos * ("Disclaimer") and any redistribution must be conditioned upon
2073d4e80bSchristos * including a substantially similar Disclaimer requirement for further
2173d4e80bSchristos * binary redistribution.
2273d4e80bSchristos * 3. Neither the names of the above-listed copyright holders nor the names
2373d4e80bSchristos * of any contributors may be used to endorse or promote products derived
2473d4e80bSchristos * from this software without specific prior written permission.
2573d4e80bSchristos *
2673d4e80bSchristos * Alternatively, this software may be distributed under the terms of the
2773d4e80bSchristos * GNU General Public License ("GPL") version 2 as published by the Free
2873d4e80bSchristos * Software Foundation.
2973d4e80bSchristos *
3073d4e80bSchristos * NO WARRANTY
3173d4e80bSchristos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3273d4e80bSchristos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33d4291bf2Schristos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3473d4e80bSchristos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3573d4e80bSchristos * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3673d4e80bSchristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3773d4e80bSchristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3873d4e80bSchristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3973d4e80bSchristos * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4073d4e80bSchristos * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4173d4e80bSchristos * POSSIBILITY OF SUCH DAMAGES.
4273d4e80bSchristos */
4373d4e80bSchristos
4473d4e80bSchristos #define EXPORT_ACPI_INTERFACES
4573d4e80bSchristos
4673d4e80bSchristos #include "acpi.h"
4773d4e80bSchristos #include "accommon.h"
4873d4e80bSchristos #include "acevents.h"
4973d4e80bSchristos #include "acnamesp.h"
5073d4e80bSchristos #include "acdebug.h"
5173d4e80bSchristos #include "actables.h"
5273d4e80bSchristos
5373d4e80bSchristos #define _COMPONENT ACPI_UTILITIES
5473d4e80bSchristos ACPI_MODULE_NAME ("utxfinit")
5573d4e80bSchristos
564e4949bdSchristos /* For AcpiExec only */
574e4949bdSchristos void
584e4949bdSchristos AeDoObjectOverrides (
594e4949bdSchristos void);
604e4949bdSchristos
6173d4e80bSchristos
6273d4e80bSchristos /*******************************************************************************
6373d4e80bSchristos *
6473d4e80bSchristos * FUNCTION: AcpiInitializeSubsystem
6573d4e80bSchristos *
6673d4e80bSchristos * PARAMETERS: None
6773d4e80bSchristos *
6873d4e80bSchristos * RETURN: Status
6973d4e80bSchristos *
7073d4e80bSchristos * DESCRIPTION: Initializes all global variables. This is the first function
7173d4e80bSchristos * called, so any early initialization belongs here.
7273d4e80bSchristos *
7373d4e80bSchristos ******************************************************************************/
7473d4e80bSchristos
7534e07d20Schristos ACPI_STATUS ACPI_INIT_FUNCTION
AcpiInitializeSubsystem(void)7673d4e80bSchristos AcpiInitializeSubsystem (
7773d4e80bSchristos void)
7873d4e80bSchristos {
7973d4e80bSchristos ACPI_STATUS Status;
8073d4e80bSchristos
8173d4e80bSchristos
8273d4e80bSchristos ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem);
8373d4e80bSchristos
8473d4e80bSchristos
8573d4e80bSchristos AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;
8673d4e80bSchristos ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());
8773d4e80bSchristos
8873d4e80bSchristos /* Initialize the OS-Dependent layer */
8973d4e80bSchristos
9073d4e80bSchristos Status = AcpiOsInitialize ();
9173d4e80bSchristos if (ACPI_FAILURE (Status))
9273d4e80bSchristos {
9373d4e80bSchristos ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization"));
9473d4e80bSchristos return_ACPI_STATUS (Status);
9573d4e80bSchristos }
9673d4e80bSchristos
9773d4e80bSchristos /* Initialize all globals used by the subsystem */
9873d4e80bSchristos
9973d4e80bSchristos Status = AcpiUtInitGlobals ();
10073d4e80bSchristos if (ACPI_FAILURE (Status))
10173d4e80bSchristos {
10273d4e80bSchristos ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals"));
10373d4e80bSchristos return_ACPI_STATUS (Status);
10473d4e80bSchristos }
10573d4e80bSchristos
10673d4e80bSchristos /* Create the default mutex objects */
10773d4e80bSchristos
10873d4e80bSchristos Status = AcpiUtMutexInitialize ();
10973d4e80bSchristos if (ACPI_FAILURE (Status))
11073d4e80bSchristos {
11173d4e80bSchristos ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation"));
11273d4e80bSchristos return_ACPI_STATUS (Status);
11373d4e80bSchristos }
11473d4e80bSchristos
11573d4e80bSchristos /*
11673d4e80bSchristos * Initialize the namespace manager and
11773d4e80bSchristos * the root of the namespace tree
11873d4e80bSchristos */
11973d4e80bSchristos Status = AcpiNsRootInitialize ();
12073d4e80bSchristos if (ACPI_FAILURE (Status))
12173d4e80bSchristos {
12273d4e80bSchristos ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization"));
12373d4e80bSchristos return_ACPI_STATUS (Status);
12473d4e80bSchristos }
12573d4e80bSchristos
12673d4e80bSchristos /* Initialize the global OSI interfaces list with the static names */
12773d4e80bSchristos
12873d4e80bSchristos Status = AcpiUtInitializeInterfaces ();
12973d4e80bSchristos if (ACPI_FAILURE (Status))
13073d4e80bSchristos {
13173d4e80bSchristos ACPI_EXCEPTION ((AE_INFO, Status, "During OSI interfaces initialization"));
13273d4e80bSchristos return_ACPI_STATUS (Status);
13373d4e80bSchristos }
13473d4e80bSchristos
13573d4e80bSchristos return_ACPI_STATUS (AE_OK);
13673d4e80bSchristos }
13773d4e80bSchristos
ACPI_EXPORT_SYMBOL_INIT(AcpiInitializeSubsystem)13873d4e80bSchristos ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeSubsystem)
13973d4e80bSchristos
14073d4e80bSchristos
14173d4e80bSchristos /*******************************************************************************
14273d4e80bSchristos *
14373d4e80bSchristos * FUNCTION: AcpiEnableSubsystem
14473d4e80bSchristos *
14573d4e80bSchristos * PARAMETERS: Flags - Init/enable Options
14673d4e80bSchristos *
14773d4e80bSchristos * RETURN: Status
14873d4e80bSchristos *
14973d4e80bSchristos * DESCRIPTION: Completes the subsystem initialization including hardware.
15073d4e80bSchristos * Puts system into ACPI mode if it isn't already.
15173d4e80bSchristos *
15273d4e80bSchristos ******************************************************************************/
15373d4e80bSchristos
15434e07d20Schristos ACPI_STATUS ACPI_INIT_FUNCTION
15573d4e80bSchristos AcpiEnableSubsystem (
15673d4e80bSchristos UINT32 Flags)
15773d4e80bSchristos {
15873d4e80bSchristos ACPI_STATUS Status = AE_OK;
15973d4e80bSchristos
16073d4e80bSchristos
16173d4e80bSchristos ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
16273d4e80bSchristos
16373d4e80bSchristos
1645fe1040dSchristos /*
1655fe1040dSchristos * The early initialization phase is complete. The namespace is loaded,
1665fe1040dSchristos * and we can now support address spaces other than Memory, I/O, and
1675fe1040dSchristos * PCI_Config.
1685fe1040dSchristos */
1695fe1040dSchristos AcpiGbl_EarlyInitialization = FALSE;
1705fe1040dSchristos
17173d4e80bSchristos #if (!ACPI_REDUCED_HARDWARE)
17273d4e80bSchristos
17373d4e80bSchristos /* Enable ACPI mode */
17473d4e80bSchristos
17573d4e80bSchristos if (!(Flags & ACPI_NO_ACPI_ENABLE))
17673d4e80bSchristos {
17773d4e80bSchristos ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
17873d4e80bSchristos
17973d4e80bSchristos AcpiGbl_OriginalMode = AcpiHwGetMode();
18073d4e80bSchristos
18173d4e80bSchristos Status = AcpiEnable ();
18273d4e80bSchristos if (ACPI_FAILURE (Status))
18373d4e80bSchristos {
18473d4e80bSchristos ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));
18573d4e80bSchristos return_ACPI_STATUS (Status);
18673d4e80bSchristos }
18773d4e80bSchristos }
18873d4e80bSchristos
18973d4e80bSchristos /*
19073d4e80bSchristos * Obtain a permanent mapping for the FACS. This is required for the
19173d4e80bSchristos * Global Lock and the Firmware Waking Vector
19273d4e80bSchristos */
193db5c6ae1Schristos if (!(Flags & ACPI_NO_FACS_INIT))
194db5c6ae1Schristos {
19573d4e80bSchristos Status = AcpiTbInitializeFacs ();
19673d4e80bSchristos if (ACPI_FAILURE (Status))
19773d4e80bSchristos {
19873d4e80bSchristos ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
19973d4e80bSchristos return_ACPI_STATUS (Status);
20073d4e80bSchristos }
201db5c6ae1Schristos }
20273d4e80bSchristos
20373d4e80bSchristos /*
20473d4e80bSchristos * Initialize ACPI Event handling (Fixed and General Purpose)
20573d4e80bSchristos *
20673d4e80bSchristos * Note1: We must have the hardware and events initialized before we can
20773d4e80bSchristos * execute any control methods safely. Any control method can require
20873d4e80bSchristos * ACPI hardware support, so the hardware must be fully initialized before
20973d4e80bSchristos * any method execution!
21073d4e80bSchristos *
21173d4e80bSchristos * Note2: Fixed events are initialized and enabled here. GPEs are
21273d4e80bSchristos * initialized, but cannot be enabled until after the hardware is
21373d4e80bSchristos * completely initialized (SCI and GlobalLock activated) and the various
21473d4e80bSchristos * initialization control methods are run (_REG, _STA, _INI) on the
21573d4e80bSchristos * entire namespace.
21673d4e80bSchristos */
21773d4e80bSchristos if (!(Flags & ACPI_NO_EVENT_INIT))
21873d4e80bSchristos {
21973d4e80bSchristos ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
22073d4e80bSchristos "[Init] Initializing ACPI events\n"));
22173d4e80bSchristos
22273d4e80bSchristos Status = AcpiEvInitializeEvents ();
22373d4e80bSchristos if (ACPI_FAILURE (Status))
22473d4e80bSchristos {
22573d4e80bSchristos return_ACPI_STATUS (Status);
22673d4e80bSchristos }
22773d4e80bSchristos }
22873d4e80bSchristos
22973d4e80bSchristos /*
23073d4e80bSchristos * Install the SCI handler and Global Lock handler. This completes the
23173d4e80bSchristos * hardware initialization.
23273d4e80bSchristos */
23373d4e80bSchristos if (!(Flags & ACPI_NO_HANDLER_INIT))
23473d4e80bSchristos {
23573d4e80bSchristos ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
23673d4e80bSchristos "[Init] Installing SCI/GL handlers\n"));
23773d4e80bSchristos
23873d4e80bSchristos Status = AcpiEvInstallXruptHandlers ();
23973d4e80bSchristos if (ACPI_FAILURE (Status))
24073d4e80bSchristos {
24173d4e80bSchristos return_ACPI_STATUS (Status);
24273d4e80bSchristos }
24373d4e80bSchristos }
24473d4e80bSchristos
24573d4e80bSchristos #endif /* !ACPI_REDUCED_HARDWARE */
24673d4e80bSchristos
24773d4e80bSchristos return_ACPI_STATUS (Status);
24873d4e80bSchristos }
24973d4e80bSchristos
ACPI_EXPORT_SYMBOL_INIT(AcpiEnableSubsystem)25073d4e80bSchristos ACPI_EXPORT_SYMBOL_INIT (AcpiEnableSubsystem)
25173d4e80bSchristos
25273d4e80bSchristos
25373d4e80bSchristos /*******************************************************************************
25473d4e80bSchristos *
25573d4e80bSchristos * FUNCTION: AcpiInitializeObjects
25673d4e80bSchristos *
25773d4e80bSchristos * PARAMETERS: Flags - Init/enable Options
25873d4e80bSchristos *
25973d4e80bSchristos * RETURN: Status
26073d4e80bSchristos *
26173d4e80bSchristos * DESCRIPTION: Completes namespace initialization by initializing device
26273d4e80bSchristos * objects and executing AML code for Regions, buffers, etc.
26373d4e80bSchristos *
26473d4e80bSchristos ******************************************************************************/
26573d4e80bSchristos
26634e07d20Schristos ACPI_STATUS ACPI_INIT_FUNCTION
26773d4e80bSchristos AcpiInitializeObjects (
26873d4e80bSchristos UINT32 Flags)
26973d4e80bSchristos {
27073d4e80bSchristos ACPI_STATUS Status = AE_OK;
27173d4e80bSchristos
27273d4e80bSchristos
27373d4e80bSchristos ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
27473d4e80bSchristos
27573d4e80bSchristos
276517d1194Schristos #ifdef ACPI_OBSOLETE_BEHAVIOR
2774e4949bdSchristos /*
278517d1194Schristos * 05/2019: Removed, initialization now happens at both object
279517d1194Schristos * creation and table load time
28073d4e80bSchristos */
28173d4e80bSchristos
28273d4e80bSchristos /*
283e1e2165cSchristos * Initialize the objects that remain uninitialized. This
284e1e2165cSchristos * runs the executable AML that may be part of the
285517d1194Schristos * declaration of these objects: OperationRegions, BufferFields,
286517d1194Schristos * BankFields, Buffers, and Packages.
28773d4e80bSchristos */
28873d4e80bSchristos if (!(Flags & ACPI_NO_OBJECT_INIT))
28973d4e80bSchristos {
29073d4e80bSchristos Status = AcpiNsInitializeObjects ();
29173d4e80bSchristos if (ACPI_FAILURE (Status))
29273d4e80bSchristos {
29373d4e80bSchristos return_ACPI_STATUS (Status);
29473d4e80bSchristos }
29573d4e80bSchristos }
296517d1194Schristos #endif
29773d4e80bSchristos
29873d4e80bSchristos /*
299e1e2165cSchristos * Initialize all device/region objects in the namespace. This runs
300e1e2165cSchristos * the device _STA and _INI methods and region _REG methods.
30173d4e80bSchristos */
302e1e2165cSchristos if (!(Flags & (ACPI_NO_DEVICE_INIT | ACPI_NO_ADDRESS_SPACE_INIT)))
30373d4e80bSchristos {
304e1e2165cSchristos Status = AcpiNsInitializeDevices (Flags);
30573d4e80bSchristos if (ACPI_FAILURE (Status))
30673d4e80bSchristos {
30773d4e80bSchristos return_ACPI_STATUS (Status);
30873d4e80bSchristos }
30973d4e80bSchristos }
31073d4e80bSchristos
31173d4e80bSchristos /*
31273d4e80bSchristos * Empty the caches (delete the cached objects) on the assumption that
31373d4e80bSchristos * the table load filled them up more than they will be at runtime --
31473d4e80bSchristos * thus wasting non-paged memory.
31573d4e80bSchristos */
31673d4e80bSchristos Status = AcpiPurgeCachedObjects ();
31773d4e80bSchristos
31873d4e80bSchristos AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
31973d4e80bSchristos return_ACPI_STATUS (Status);
32073d4e80bSchristos }
32173d4e80bSchristos
32273d4e80bSchristos ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeObjects)
323