| // Copyright 2022 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef SRC_ACPI_MULTIPLY_ACPI_CONTROLLER_H_ |
| #define SRC_ACPI_MULTIPLY_ACPI_CONTROLLER_H_ |
| |
| #include <lib/driver/compat/cpp/compat.h> |
| #include <lib/driver/component/cpp/driver_cpp.h> |
| |
| #include "acpi_server.h" |
| |
| namespace acpi_multiply { |
| |
| // Sample driver that implements a `fuchsia.hardware.acpi` bus controller and emulates the |
| // following ACPI protocol behaviors for the ACPI multiple driver: |
| // 1. Child driver writes two values to multiply to register offsets 0x0 and 0x04 |
| // 2. Child driver calls EvaluateObject("_MUL") to perform the multiplication, and waits |
| // for an interrupt. |
| // 3. This driver performs the multiplication, writes the result (64-bit) to 0x08 |
| // and triggers an interrupt. |
| class AcpiMultiplyController : public driver::DriverBase { |
| public: |
| AcpiMultiplyController(driver::DriverStartArgs start_args, |
| fdf::UnownedDispatcher driver_dispatcher) |
| : driver::DriverBase("acpi-multiply-controller", std::move(start_args), |
| std::move(driver_dispatcher)) {} |
| |
| virtual ~AcpiMultiplyController() = default; |
| |
| zx::result<> Start() override; |
| |
| private: |
| zx::result<> InitializeServer(); |
| zx::result<> AddChild(); |
| |
| std::optional<compat::DeviceServer> child_; |
| fidl::WireSyncClient<fuchsia_driver_framework::Node> node_; |
| fidl::WireSyncClient<fuchsia_driver_framework::NodeController> controller_; |
| |
| std::shared_ptr<AcpiDeviceServer> server_; |
| }; |
| |
| } // namespace acpi_multiply |
| |
| #endif // SRC_ACPI_MULTIPLY_ACPI_CONTROLLER_H_ |