/******************************************************************************* * * FUNCTION: acpi_initialize_objects * * PARAMETERS: Flags - Init/enable Options * * RETURN: Status * * DESCRIPTION: Completes namespace initialization by initializing device * objects and executing AML code for Regions, buffers, etc. * ******************************************************************************/ acpi_status acpi_initialize_objects(u32 flags) { acpi_status status = AE_OK; ACPI_FUNCTION_TRACE(acpi_initialize_objects); /* * Run all _REG methods * * Note: Any objects accessed by the _REG methods will be automatically * initialized, even if they contain executable AML (see the call to * acpi_ns_initialize_objects below). */ if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[Init] Executing _REG OpRegion methods\n")); status = acpi_ev_initialize_op_regions(); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } /* * Execute any module-level code that was detected during the table load * phase. Although illegal since ACPI 2.0, there are many machines that * contain this type of code. Each block of detected executable AML code * outside of any control method is wrapped with a temporary control * method object and placed on a global list. The methods on this list * are executed below. */ acpi_ns_exec_module_code_list(); /* * Initialize the objects that remain uninitialized. This runs the * executable AML that may be part of the declaration of these objects: * operation_regions, buffer_fields, Buffers, and Packages. */ if (!(flags & ACPI_NO_OBJECT_INIT)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[Init] Completing Initialization of ACPI Objects\n")); status = acpi_ns_initialize_objects(); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } /* * Initialize all device objects in the namespace. This runs the device * _STA and _INI methods. */ if (!(flags & ACPI_NO_DEVICE_INIT)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[Init] Initializing ACPI Devices\n")); status = acpi_ns_initialize_devices(); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } /* * Complete the GPE initialization for the GPE blocks defined in the FADT * (GPE block 0 and 1). * * Note1: This is where the _PRW methods are executed for the GPEs. These * methods can only be executed after the SCI and Global Lock handlers are * installed and initialized. * * Note2: Currently, there seems to be no need to run the _REG methods * before execution of the _PRW methods and enabling of the GPEs. */ if (!(flags & ACPI_NO_EVENT_INIT)) { status = acpi_ev_install_fadt_gpes(); if (ACPI_FAILURE(status)) return (status); } /* * Empty the caches (delete the cached objects) on the assumption that * the table load filled them up more than they will be at runtime -- * thus wasting non-paged memory. */ status = acpi_purge_cached_objects(); acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK; return_ACPI_STATUS(status); }
/**ltl * 功能:使能ACPI子系统 * 参数: * 返回值: * 说明: */ acpi_status acpi_enable_subsystem(u32 flags) { acpi_status status = AE_OK; ACPI_FUNCTION_TRACE(acpi_enable_subsystem); /* * We must initialize the hardware before we can enable ACPI. * The values from the FADT are validated here. */ if (!(flags & ACPI_NO_HARDWARE_INIT)) { /* 初始化ACPI硬件模块 */ ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[Init] Initializing ACPI hardware\n")); status = acpi_hw_initialize(); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } /* Enable ACPI mode */ if (!(flags & ACPI_NO_ACPI_ENABLE)) { /* 使能ACPI硬件模块 */ ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n")); /* 返回值模式 */ acpi_gbl_original_mode = acpi_hw_get_mode(); /* 设置ACPI模式 */ status = acpi_enable(); if (ACPI_FAILURE(status)) { ACPI_WARNING((AE_INFO, "AcpiEnable failed")); return_ACPI_STATUS(status); } } /* * Install the default op_region handlers. These are installed unless * other handlers have already been installed via the * install_address_space_handler interface. */ if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n")); /* 为四个地址空间设置默认处理句柄 */ status = acpi_ev_install_region_handlers(); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } /* * Initialize ACPI Event handling (Fixed and General Purpose) * * Note1: We must have the hardware and events initialized before we can * execute any control methods safely. Any control method can require * ACPI hardware support, so the hardware must be fully initialized before * any method execution! * * Note2: Fixed events are initialized and enabled here. GPEs are * initialized, but cannot be enabled until after the hardware is * completely initialized (SCI and global_lock activated) */ if (!(flags & ACPI_NO_EVENT_INIT)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[Init] Initializing ACPI events\n")); /* 初始化ACPI事件(设置相关寄存器) */ status = acpi_ev_initialize_events(); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } /* * Install the SCI handler and Global Lock handler. This completes the * hardware initialization. */ if (!(flags & ACPI_NO_HANDLER_INIT)) { ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "[Init] Installing SCI/GL handlers\n")); /* 为ACPI模块安装中断处理函数 */ status = acpi_ev_install_xrupt_handlers(); if (ACPI_FAILURE(status)) { return_ACPI_STATUS(status); } } /* * Complete the GPE initialization for the GPE blocks defined in the FADT * (GPE block 0 and 1). * * Note1: This is where the _PRW methods are executed for the GPEs. These * methods can only be executed after the SCI and Global Lock handlers are * installed and initialized. * * Note2: Currently, there seems to be no need to run the _REG methods * before execution of the _PRW methods and enabling of the GPEs. */ if (!(flags & ACPI_NO_EVENT_INIT)) { status = acpi_ev_install_fadt_gpes(); /* 使能通用寄存器 */ if (ACPI_FAILURE(status)) { return (status); } } return_ACPI_STATUS(status); }