Platform Bus no longer uses Banjo

3 views
Skip to first unread message

Simon Shields

unread,
Oct 3, 2022, 6:58:32 PM10/3/22
to drive...@fuchsia.dev

If you do not write board drivers, you can skip this message.

As of fxrev.dev/714349, the platform bus protocol (fuchsia.hardware.platform.Bus) is now served using FIDL and the driver runtime rather than banjo. I migrated all in-tree drivers, but if you maintain a board driver that is not built as part of CQ, it might be broken.

How do I unblock myself?

In the short term, you can depend on //src/devices/bus/lib/fuchsia.hardware.platform.bus:fuchsia.hardware.platform.bus_banjo_cpp, which will allow you to use the existing Banjo interfaces with no change. For an example, see CL 1 and CL 2. We would like to delete this library in the near future, so please let me know if you start using it.


How do I migrate?

Bind rules:

In your bind program's build rules, replace //src/devices/bind/fuchsia.platform with //src/devices/bind/fuchsia.hardware.platform.bus. Then replace fuchsia.BIND_PROTOCOL == fuchsia.platform.BIND_PROTOCOL.BUS; with fuchsia.BIND_FIDL_PROTOCOL == fuchsia.hardware.platform.bus.BIND_FIDL_PROTOCOL.PLATFORM_BUS;

Drivers:

The first step is to replace any references in your BUILD.gn files to //sdk/banjo/fuchsia.hardware.platform.bus with //sdk/fidl/fuchsia.hardware.platform.bus:fuchsia.hardware.platform.bus_driver_cpp.


Then, to connect to the protocol using the driver runtime, replace:

pbus_protocol_t pbus;

zx_status_t status = device_get_protocol(parent, ZX_PROTOCOL_PBUS, &pbus);

with

// Up the top somewhere

#include <fidl/fuchsia.hardware.platform.bus/cpp/driver/fidl.h>

#include <fidl/fuchsia.hardware.platform.bus/cpp/fidl.h>


// In your board driver function

auto endpoints = fdf::CreateEndpoints<fuchsia_hardware_platform_bus::PlatformBus>();

if (endpoints.is_error()) {

return endpoints.error_value();

}


zx_status_t status = device_connect_runtime_protocol(

        parent, fuchsia_hardware_platform_bus::Service::PlatformBus::ServiceName, fuchsia_hardware_platform_bus::Service::PlatformBus::Name,

        endpoints->server.TakeHandle().release());

From there, the transition is relatively straightforward. Each pbus_something_t has an equivalent called fuchsia_hardware_platform_bus::Something. A good example to look at is the vim3 eMMC transition.

Each method on the platform bus is named as it was before, but Device is replaced by Node to better reflect DFv2's terminology. For instance, DeviceAdd is now called NodeAdd.

Migrating composites

If you have composites to migrate, you can use the platform-bus-composites library, which provides a function that converts from old-style fragment definitions to the FIDL style. Additionally, if you use CompositeDeviceAdd, it's now called AddCompositeImplicitPbusFragment.


If you have any questions or need help, feel free to reach out!

Reply all
Reply to author
Forward
0 new messages