blob: 04dfee8e96ebdd09c5b606eebefe3b31902dc4f9 [file] [log] [blame]
// Copyright 2021 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.
#include <fidl/fuchsia.hardware.acpi/cpp/wire.h>
#include <lib/ddk/driver.h>
#include <lib/zx/result.h>
#include "src/devices/lib/acpi/object.h"
#include "src/devices/lib/acpi/util.h"
namespace acpi {
// This class is a wrapper around the underlying FIDL ACPI protocol.
// It provides helper functions to make calling common ACPI methods more ergonomic.
class Client {
// Connect to the ACPI FIDL server by calling ConnectServer() on the "acpi" fragment of |parent|.
static zx::result<Client> Create(zx_device_t* parent);
// Connect to the ACPI FIDL server and just return the FIDL ClientEnd.
static zx::result<fidl::ClientEnd<fuchsia_hardware_acpi::Device>> Connect(zx_device_t* parent);
// Alternate constructor mainly intended for use in unit tests.
static Client Create(fidl::WireSyncClient<fuchsia_hardware_acpi::Device> client);
// Borrow the underlying FIDL client.
fidl::WireSyncClient<fuchsia_hardware_acpi::Device>& borrow() { return client_; }
// This calls _DSM on the device with the given arguments. See
// ACPI Spec 6.4, 9.1.1 "_DSM (Device Specific Method)" for more information.
zx::result<Object> CallDsm(Uuid uuid, uint64_t revision, uint64_t func_index,
std::optional<fuchsia_hardware_acpi::wire::Object> params);
explicit Client(fidl::WireSyncClient<fuchsia_hardware_acpi::Device> client)
: client_(std::move(client)) {}
fidl::WireSyncClient<fuchsia_hardware_acpi::Device> client_;
} // namespace acpi