GN:
deps = [ "//sdk/lib/driver/platform-device/cpp", # For fdf::PDev ]
Bazel:
deps = [ "@fuchsia_sdk//pkg/driver_platform_device_cpp", # For fdf::PDev ]
Declare that the driver uses the service in its .cml file:
use: [ { service: "fuchsia.hardware.platform.device.Service" }, ],
Include the header:
#include <lib/driver/platform-device/cpp/pdev.h>
To connect to pdev in your Start() method:
zx::result pdev_client = incoming()->Connect<fuchsia_hardware_platform_device::Service::Device>(); if (pdev_client.is_error()) { fdf::error("Failed to connect to pdev: {}", pdev_client.status_string()); return pdev_client.take_error(); } fdf::PDev pdev(std::move(pdev_client.value()));
zx::result mmio = pdev.MapMmio(0);
zx::result irq = pdev.GetInterrupt(0);
zx::result bti = pdev.GetBti(0);