2020-01-18 11:38:21 +03:00
|
|
|
/*
|
2020-03-06 17:55:17 +03:00
|
|
|
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
|
2020-01-18 11:38:21 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
Kernel: Introduce the ACPI subsystem
ACPI subsystem includes 3 types of parsers that are created during
runtime, each one capable of parsing ACPI tables at different level.
ACPIParser is the most basic parser which is essentialy a parser that
can't parse anything useful, due to a user request to disable ACPI
support in a kernel boot parameter.
ACPIStaticParser is a derived class from ACPIParser, which is able to
parse only static data (e.g. FADT, HPET, MCFG and other tables), thus
making it not able to parse AML (ACPI Machine Language) nor to support
handling of hardware events and power management. This type of parser
can be created with a kernel boot parameter.
ACPIDynamicParser is a derived class from ACPIStaticParser, which
includes all the capabilities of the latter, but *should* implement an
AML interpretation, (by building the ACPI AML namespace) and handling
power & hardware events. Currently the methods to support AML
interpretation are not implemented.
This type of parser is created automatically during runtime if the user
didn't specify a boot parameter related to ACPI initialization.
Also, adding strncmp function definition in StdLib.h, to be able to use
it in ACPIStaticParser class.
2019-12-31 14:01:09 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/RefPtr.h>
|
|
|
|
#include <Kernel/ACPI/ACPIStaticParser.h>
|
2020-02-22 20:53:03 +03:00
|
|
|
#include <Kernel/Interrupts/IRQHandler.h>
|
Kernel: Introduce the ACPI subsystem
ACPI subsystem includes 3 types of parsers that are created during
runtime, each one capable of parsing ACPI tables at different level.
ACPIParser is the most basic parser which is essentialy a parser that
can't parse anything useful, due to a user request to disable ACPI
support in a kernel boot parameter.
ACPIStaticParser is a derived class from ACPIParser, which is able to
parse only static data (e.g. FADT, HPET, MCFG and other tables), thus
making it not able to parse AML (ACPI Machine Language) nor to support
handling of hardware events and power management. This type of parser
can be created with a kernel boot parameter.
ACPIDynamicParser is a derived class from ACPIStaticParser, which
includes all the capabilities of the latter, but *should* implement an
AML interpretation, (by building the ACPI AML namespace) and handling
power & hardware events. Currently the methods to support AML
interpretation are not implemented.
This type of parser is created automatically during runtime if the user
didn't specify a boot parameter related to ACPI initialization.
Also, adding strncmp function definition in StdLib.h, to be able to use
it in ACPIStaticParser class.
2019-12-31 14:01:09 +03:00
|
|
|
#include <Kernel/Lock.h>
|
|
|
|
#include <Kernel/VM/PhysicalPage.h>
|
2020-02-09 19:15:58 +03:00
|
|
|
#include <LibBareMetal/Memory/PhysicalAddress.h>
|
Kernel: Introduce the ACPI subsystem
ACPI subsystem includes 3 types of parsers that are created during
runtime, each one capable of parsing ACPI tables at different level.
ACPIParser is the most basic parser which is essentialy a parser that
can't parse anything useful, due to a user request to disable ACPI
support in a kernel boot parameter.
ACPIStaticParser is a derived class from ACPIParser, which is able to
parse only static data (e.g. FADT, HPET, MCFG and other tables), thus
making it not able to parse AML (ACPI Machine Language) nor to support
handling of hardware events and power management. This type of parser
can be created with a kernel boot parameter.
ACPIDynamicParser is a derived class from ACPIStaticParser, which
includes all the capabilities of the latter, but *should* implement an
AML interpretation, (by building the ACPI AML namespace) and handling
power & hardware events. Currently the methods to support AML
interpretation are not implemented.
This type of parser is created automatically during runtime if the user
didn't specify a boot parameter related to ACPI initialization.
Also, adding strncmp function definition in StdLib.h, to be able to use
it in ACPIStaticParser class.
2019-12-31 14:01:09 +03:00
|
|
|
|
2020-02-16 03:27:42 +03:00
|
|
|
namespace Kernel {
|
2020-02-28 23:24:10 +03:00
|
|
|
namespace ACPI {
|
2020-03-03 20:29:32 +03:00
|
|
|
|
2020-04-09 15:10:44 +03:00
|
|
|
class DynamicParser final
|
|
|
|
: public IRQHandler
|
|
|
|
, public StaticParser {
|
|
|
|
friend class Parser;
|
|
|
|
|
|
|
|
public:
|
2020-03-22 03:12:45 +03:00
|
|
|
virtual void enable_aml_interpretation() override;
|
|
|
|
virtual void enable_aml_interpretation(File& dsdt_file) override;
|
|
|
|
virtual void enable_aml_interpretation(u8* physical_dsdt, u32 dsdt_payload_legnth) override;
|
|
|
|
virtual void disable_aml_interpretation() override;
|
|
|
|
virtual void try_acpi_shutdown() override;
|
|
|
|
virtual bool can_shutdown() override { return true; }
|
|
|
|
virtual const char* purpose() const override { return "ACPI Parser"; }
|
2020-03-03 20:29:32 +03:00
|
|
|
|
2020-03-22 03:12:45 +03:00
|
|
|
protected:
|
|
|
|
DynamicParser();
|
|
|
|
explicit DynamicParser(PhysicalAddress);
|
2020-03-03 20:29:32 +03:00
|
|
|
|
2020-03-22 03:12:45 +03:00
|
|
|
private:
|
|
|
|
void build_namespace();
|
|
|
|
// ^IRQHandler
|
|
|
|
virtual void handle_irq(const RegisterState&) override;
|
2020-03-03 20:29:32 +03:00
|
|
|
|
2020-03-22 03:12:45 +03:00
|
|
|
OwnPtr<Region> m_acpi_namespace;
|
|
|
|
};
|
2020-02-16 03:27:42 +03:00
|
|
|
}
|
2020-02-28 23:24:10 +03:00
|
|
|
}
|