Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
0002 /******************************************************************************
0003  *
0004  * Module Name: utxfinit - External interfaces for ACPICA initialization
0005  *
0006  * Copyright (C) 2000 - 2022, Intel Corp.
0007  *
0008  *****************************************************************************/
0009 
0010 #define EXPORT_ACPI_INTERFACES
0011 
0012 #include <acpi/acpi.h>
0013 #include "accommon.h"
0014 #include "acevents.h"
0015 #include "acnamesp.h"
0016 #include "acdebug.h"
0017 #include "actables.h"
0018 
0019 #define _COMPONENT          ACPI_UTILITIES
0020 ACPI_MODULE_NAME("utxfinit")
0021 
0022 /* For acpi_exec only */
0023 void ae_do_object_overrides(void);
0024 
0025 /*******************************************************************************
0026  *
0027  * FUNCTION:    acpi_initialize_subsystem
0028  *
0029  * PARAMETERS:  None
0030  *
0031  * RETURN:      Status
0032  *
0033  * DESCRIPTION: Initializes all global variables. This is the first function
0034  *              called, so any early initialization belongs here.
0035  *
0036  ******************************************************************************/
0037 
0038 acpi_status ACPI_INIT_FUNCTION acpi_initialize_subsystem(void)
0039 {
0040     acpi_status status;
0041 
0042     ACPI_FUNCTION_TRACE(acpi_initialize_subsystem);
0043 
0044     acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE;
0045     ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
0046 
0047     /* Initialize the OS-Dependent layer */
0048 
0049     status = acpi_os_initialize();
0050     if (ACPI_FAILURE(status)) {
0051         ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
0052         return_ACPI_STATUS(status);
0053     }
0054 
0055     /* Initialize all globals used by the subsystem */
0056 
0057     status = acpi_ut_init_globals();
0058     if (ACPI_FAILURE(status)) {
0059         ACPI_EXCEPTION((AE_INFO, status,
0060                 "During initialization of globals"));
0061         return_ACPI_STATUS(status);
0062     }
0063 
0064     /* Create the default mutex objects */
0065 
0066     status = acpi_ut_mutex_initialize();
0067     if (ACPI_FAILURE(status)) {
0068         ACPI_EXCEPTION((AE_INFO, status,
0069                 "During Global Mutex creation"));
0070         return_ACPI_STATUS(status);
0071     }
0072 
0073     /*
0074      * Initialize the namespace manager and
0075      * the root of the namespace tree
0076      */
0077     status = acpi_ns_root_initialize();
0078     if (ACPI_FAILURE(status)) {
0079         ACPI_EXCEPTION((AE_INFO, status,
0080                 "During Namespace initialization"));
0081         return_ACPI_STATUS(status);
0082     }
0083 
0084     /* Initialize the global OSI interfaces list with the static names */
0085 
0086     status = acpi_ut_initialize_interfaces();
0087     if (ACPI_FAILURE(status)) {
0088         ACPI_EXCEPTION((AE_INFO, status,
0089                 "During OSI interfaces initialization"));
0090         return_ACPI_STATUS(status);
0091     }
0092 
0093     return_ACPI_STATUS(AE_OK);
0094 }
0095 
0096 ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem)
0097 
0098 /*******************************************************************************
0099  *
0100  * FUNCTION:    acpi_enable_subsystem
0101  *
0102  * PARAMETERS:  flags               - Init/enable Options
0103  *
0104  * RETURN:      Status
0105  *
0106  * DESCRIPTION: Completes the subsystem initialization including hardware.
0107  *              Puts system into ACPI mode if it isn't already.
0108  *
0109  ******************************************************************************/
0110 acpi_status ACPI_INIT_FUNCTION acpi_enable_subsystem(u32 flags)
0111 {
0112     acpi_status status = AE_OK;
0113 
0114     ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
0115 
0116     /*
0117      * The early initialization phase is complete. The namespace is loaded,
0118      * and we can now support address spaces other than Memory, I/O, and
0119      * PCI_Config.
0120      */
0121     acpi_gbl_early_initialization = FALSE;
0122 
0123 #if (!ACPI_REDUCED_HARDWARE)
0124 
0125     /* Enable ACPI mode */
0126 
0127     if (!(flags & ACPI_NO_ACPI_ENABLE)) {
0128         ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
0129                   "[Init] Going into ACPI mode\n"));
0130 
0131         acpi_gbl_original_mode = acpi_hw_get_mode();
0132 
0133         status = acpi_enable();
0134         if (ACPI_FAILURE(status)) {
0135             ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
0136             return_ACPI_STATUS(status);
0137         }
0138     }
0139 
0140     /*
0141      * Obtain a permanent mapping for the FACS. This is required for the
0142      * Global Lock and the Firmware Waking Vector
0143      */
0144     if (!(flags & ACPI_NO_FACS_INIT)) {
0145         status = acpi_tb_initialize_facs();
0146         if (ACPI_FAILURE(status)) {
0147             ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
0148             return_ACPI_STATUS(status);
0149         }
0150     }
0151 
0152     /*
0153      * Initialize ACPI Event handling (Fixed and General Purpose)
0154      *
0155      * Note1: We must have the hardware and events initialized before we can
0156      * execute any control methods safely. Any control method can require
0157      * ACPI hardware support, so the hardware must be fully initialized before
0158      * any method execution!
0159      *
0160      * Note2: Fixed events are initialized and enabled here. GPEs are
0161      * initialized, but cannot be enabled until after the hardware is
0162      * completely initialized (SCI and global_lock activated) and the various
0163      * initialization control methods are run (_REG, _STA, _INI) on the
0164      * entire namespace.
0165      */
0166     if (!(flags & ACPI_NO_EVENT_INIT)) {
0167         ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
0168                   "[Init] Initializing ACPI events\n"));
0169 
0170         status = acpi_ev_initialize_events();
0171         if (ACPI_FAILURE(status)) {
0172             return_ACPI_STATUS(status);
0173         }
0174     }
0175 
0176     /*
0177      * Install the SCI handler and Global Lock handler. This completes the
0178      * hardware initialization.
0179      */
0180     if (!(flags & ACPI_NO_HANDLER_INIT)) {
0181         ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
0182                   "[Init] Installing SCI/GL handlers\n"));
0183 
0184         status = acpi_ev_install_xrupt_handlers();
0185         if (ACPI_FAILURE(status)) {
0186             return_ACPI_STATUS(status);
0187         }
0188     }
0189 #endif              /* !ACPI_REDUCED_HARDWARE */
0190 
0191     return_ACPI_STATUS(status);
0192 }
0193 
0194 ACPI_EXPORT_SYMBOL_INIT(acpi_enable_subsystem)
0195 
0196 /*******************************************************************************
0197  *
0198  * FUNCTION:    acpi_initialize_objects
0199  *
0200  * PARAMETERS:  flags               - Init/enable Options
0201  *
0202  * RETURN:      Status
0203  *
0204  * DESCRIPTION: Completes namespace initialization by initializing device
0205  *              objects and executing AML code for Regions, buffers, etc.
0206  *
0207  ******************************************************************************/
0208 acpi_status ACPI_INIT_FUNCTION acpi_initialize_objects(u32 flags)
0209 {
0210     acpi_status status = AE_OK;
0211 
0212     ACPI_FUNCTION_TRACE(acpi_initialize_objects);
0213 
0214 #ifdef ACPI_OBSOLETE_BEHAVIOR
0215     /*
0216      * 05/2019: Removed, initialization now happens at both object
0217      * creation and table load time
0218      */
0219 
0220     /*
0221      * Initialize the objects that remain uninitialized. This
0222      * runs the executable AML that may be part of the
0223      * declaration of these objects: operation_regions, buffer_fields,
0224      * bank_fields, Buffers, and Packages.
0225      */
0226     if (!(flags & ACPI_NO_OBJECT_INIT)) {
0227         status = acpi_ns_initialize_objects();
0228         if (ACPI_FAILURE(status)) {
0229             return_ACPI_STATUS(status);
0230         }
0231     }
0232 #endif
0233 
0234     /*
0235      * Initialize all device/region objects in the namespace. This runs
0236      * the device _STA and _INI methods and region _REG methods.
0237      */
0238     if (!(flags & (ACPI_NO_DEVICE_INIT | ACPI_NO_ADDRESS_SPACE_INIT))) {
0239         status = acpi_ns_initialize_devices(flags);
0240         if (ACPI_FAILURE(status)) {
0241             return_ACPI_STATUS(status);
0242         }
0243     }
0244 
0245     /*
0246      * Empty the caches (delete the cached objects) on the assumption that
0247      * the table load filled them up more than they will be at runtime --
0248      * thus wasting non-paged memory.
0249      */
0250     status = acpi_purge_cached_objects();
0251 
0252     acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
0253     return_ACPI_STATUS(status);
0254 }
0255 
0256 ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_objects)