diff --git a/zircon/system/core/devmgr/devcoordinator/coordinator-test.cpp b/zircon/system/core/devmgr/devcoordinator/coordinator-test.cpp index ca35f767469b0a79b1ae59d7501306850d5cee57..5000dd5642bfc068786220af0e5b550233c928e7 100644 --- a/zircon/system/core/devmgr/devcoordinator/coordinator-test.cpp +++ b/zircon/system/core/devmgr/devcoordinator/coordinator-test.cpp @@ -160,11 +160,11 @@ void CheckBindDriverReceived(const zx::channel& remote, const char* expected_dri // Validate the BindDriver request. auto hdr = reinterpret_cast<fidl_message_header_t*>(bytes); - ASSERT_EQ(fuchsia_device_manager_ControllerBindDriverOrdinal, hdr->ordinal); - status = fidl_decode(&fuchsia_device_manager_ControllerBindDriverRequestTable, bytes, + ASSERT_EQ(fuchsia_device_manager_DeviceControllerBindDriverOrdinal, hdr->ordinal); + status = fidl_decode(&fuchsia_device_manager_DeviceControllerBindDriverRequestTable, bytes, actual_bytes, handles, actual_handles, nullptr); ASSERT_OK(status); - auto req = reinterpret_cast<fuchsia_device_manager_ControllerBindDriverRequest*>(bytes); + auto req = reinterpret_cast<fuchsia_device_manager_DeviceControllerBindDriverRequest*>(bytes); ASSERT_EQ(req->driver_path.size, strlen(expected_driver)); ASSERT_BYTES_EQ(reinterpret_cast<const uint8_t*>(expected_driver), reinterpret_cast<const uint8_t*>(req->driver_path.data), @@ -172,10 +172,10 @@ void CheckBindDriverReceived(const zx::channel& remote, const char* expected_dri // Write the BindDriver response. memset(bytes, 0, sizeof(bytes)); - auto resp = reinterpret_cast<fuchsia_device_manager_ControllerBindDriverResponse*>(bytes); - resp->hdr.ordinal = fuchsia_device_manager_ControllerBindDriverOrdinal; + auto resp = reinterpret_cast<fuchsia_device_manager_DeviceControllerBindDriverResponse*>(bytes); + resp->hdr.ordinal = fuchsia_device_manager_DeviceControllerBindDriverOrdinal; resp->status = ZX_OK; - status = fidl_encode(&fuchsia_device_manager_ControllerBindDriverResponseTable, bytes, + status = fidl_encode(&fuchsia_device_manager_DeviceControllerBindDriverResponseTable, bytes, sizeof(*resp), handles, fbl::count_of(handles), &actual_handles, nullptr); ASSERT_OK(status); ASSERT_EQ(0, actual_handles); @@ -246,11 +246,11 @@ void CheckCreateDeviceReceived(const zx::channel& remote, const char* expected_d // Validate the CreateDevice request. auto hdr = reinterpret_cast<fidl_message_header_t*>(bytes); - ASSERT_EQ(fuchsia_device_manager_ControllerCreateDeviceOrdinal, hdr->ordinal); - status = fidl_decode(&fuchsia_device_manager_ControllerCreateDeviceRequestTable, bytes, + ASSERT_EQ(fuchsia_device_manager_DevhostControllerCreateDeviceOrdinal, hdr->ordinal); + status = fidl_decode(&fuchsia_device_manager_DevhostControllerCreateDeviceRequestTable, bytes, actual_bytes, handles, actual_handles, nullptr); ASSERT_OK(status); - auto req = reinterpret_cast<fuchsia_device_manager_ControllerCreateDeviceRequest*>( + auto req = reinterpret_cast<fuchsia_device_manager_DevhostControllerCreateDeviceRequest*>( bytes); ASSERT_EQ(req->driver_path.size, strlen(expected_driver)); ASSERT_BYTES_EQ(reinterpret_cast<const uint8_t*>(expected_driver), @@ -277,11 +277,12 @@ void CheckCreateCompositeDeviceReceived(const zx::channel& remote, const char* e // Validate the CreateCompositeDevice request. auto hdr = reinterpret_cast<fidl_message_header_t*>(bytes); - ASSERT_EQ(fuchsia_device_manager_ControllerCreateCompositeDeviceOrdinal, hdr->ordinal); - status = fidl_decode(&fuchsia_device_manager_ControllerCreateCompositeDeviceRequestTable, bytes, + ASSERT_EQ(fuchsia_device_manager_DevhostControllerCreateCompositeDeviceOrdinal, hdr->ordinal); + status = fidl_decode(&fuchsia_device_manager_DevhostControllerCreateCompositeDeviceRequestTable, + bytes, actual_bytes, handles, actual_handles, nullptr); ASSERT_OK(status); - auto req = reinterpret_cast<fuchsia_device_manager_ControllerCreateCompositeDeviceRequest*>( + auto req = reinterpret_cast<fuchsia_device_manager_DevhostControllerCreateCompositeDeviceRequest*>( bytes); ASSERT_EQ(req->name.size, strlen(expected_name)); ASSERT_BYTES_EQ(reinterpret_cast<const uint8_t*>(expected_name), @@ -290,13 +291,14 @@ void CheckCreateCompositeDeviceReceived(const zx::channel& remote, const char* e // Write the CreateCompositeDevice response. memset(bytes, 0, sizeof(bytes)); - auto resp = reinterpret_cast<fuchsia_device_manager_ControllerCreateCompositeDeviceResponse*>( + auto resp = reinterpret_cast<fuchsia_device_manager_DevhostControllerCreateCompositeDeviceResponse*>( bytes); - resp->hdr.ordinal = fuchsia_device_manager_ControllerCreateCompositeDeviceOrdinal; + resp->hdr.ordinal = fuchsia_device_manager_DevhostControllerCreateCompositeDeviceOrdinal; resp->status = ZX_OK; - status = fidl_encode(&fuchsia_device_manager_ControllerCreateCompositeDeviceResponseTable, - bytes, sizeof(*resp), handles, fbl::count_of(handles), &actual_handles, - nullptr); + status = fidl_encode( + &fuchsia_device_manager_DevhostControllerCreateCompositeDeviceResponseTable, + bytes, sizeof(*resp), handles, fbl::count_of(handles), &actual_handles, + nullptr); ASSERT_OK(status); ASSERT_EQ(0, actual_handles); status = remote.write(0, bytes, sizeof(*resp), nullptr, 0); diff --git a/zircon/system/core/devmgr/devcoordinator/coordinator.cpp b/zircon/system/core/devmgr/devcoordinator/coordinator.cpp index 5fb866576c91a1bcf7f2ca5c5812b3d89b90d64b..2e97ddd77325214349d36c1849c2eb41d9e2e9bc 100644 --- a/zircon/system/core/devmgr/devcoordinator/coordinator.cpp +++ b/zircon/system/core/devmgr/devcoordinator/coordinator.cpp @@ -1447,37 +1447,40 @@ zx_status_t Coordinator::HandleDeviceRead(const fbl::RefPtr<Device>& dev) { // This is an if statement because, depending on the state of the ordinal // migration, GenOrdinal and Ordinal may be the same value. See FIDL-372 uint32_t ordinal = hdr->ordinal; - if (ordinal == fuchsia_device_manager_ControllerBindDriverOrdinal || - ordinal == fuchsia_device_manager_ControllerBindDriverGenOrdinal) { + if (ordinal == fuchsia_device_manager_DeviceControllerBindDriverOrdinal || + ordinal == fuchsia_device_manager_DeviceControllerBindDriverGenOrdinal) { const char* err_msg = nullptr; - r = fidl_decode_msg(&fuchsia_device_manager_ControllerBindDriverResponseTable, &fidl_msg, - &err_msg); + r = fidl_decode_msg(&fuchsia_device_manager_DeviceControllerBindDriverResponseTable, + &fidl_msg, &err_msg); if (r != ZX_OK) { log(ERROR, "devcoordinator: rpc: bind-driver '%s' received malformed reply: %s\n", dev->name.data(), err_msg); return ZX_ERR_IO; } auto resp = - reinterpret_cast<fuchsia_device_manager_ControllerBindDriverResponse*>(fidl_msg.bytes); + reinterpret_cast<fuchsia_device_manager_DeviceControllerBindDriverResponse*>( + fidl_msg.bytes); if (resp->status != ZX_OK) { log(ERROR, "devcoordinator: rpc: bind-driver '%s' status %d\n", dev->name.data(), resp->status); } // TODO: try next driver, clear BOUND flag - } else if (ordinal == fuchsia_device_manager_ControllerSuspendOrdinal || - ordinal == fuchsia_device_manager_ControllerSuspendGenOrdinal) { + } else if (ordinal == fuchsia_device_manager_DeviceControllerSuspendOrdinal || + ordinal == fuchsia_device_manager_DeviceControllerSuspendGenOrdinal) { const char* err_msg = nullptr; - r = fidl_decode_msg(&fuchsia_device_manager_ControllerSuspendResponseTable, &fidl_msg, - &err_msg); + r = fidl_decode_msg(&fuchsia_device_manager_DeviceControllerSuspendResponseTable, + &fidl_msg, &err_msg); if (r != ZX_OK) { log(ERROR, "devcoordinator: rpc: suspend '%s' received malformed reply: %s\n", dev->name.data(), err_msg); return ZX_ERR_IO; } auto resp = - reinterpret_cast<fuchsia_device_manager_ControllerSuspendResponse*>(fidl_msg.bytes); + reinterpret_cast<fuchsia_device_manager_DeviceControllerSuspendResponse*>( + fidl_msg.bytes); if (resp->status != ZX_OK) { - log(ERROR, "devcoordinator: rpc: suspend '%s' status %d\n", dev->name.data(), resp->status); + log(ERROR, "devcoordinator: rpc: suspend '%s' status %d\n", dev->name.data(), + resp->status); } suspend_context().set_status(resp->status); ContinueSuspend(&suspend_context(), root_resource()); diff --git a/zircon/system/core/devmgr/devcoordinator/fidl.cpp b/zircon/system/core/devmgr/devcoordinator/fidl.cpp index ee8b26dc4e3eab5337d7a696f62f36b6020e0bd6..3b6f55a8062d1b8b22cec77309d74205fff9c49c 100644 --- a/zircon/system/core/devmgr/devcoordinator/fidl.cpp +++ b/zircon/system/core/devmgr/devcoordinator/fidl.cpp @@ -13,12 +13,13 @@ namespace devmgr { zx_status_t dh_send_remove_device(const Device* dev) { - FIDL_ALIGNDECL char wr_bytes[sizeof(fuchsia_device_manager_ControllerRemoveDeviceRequest)]; + FIDL_ALIGNDECL char wr_bytes[ + sizeof(fuchsia_device_manager_DeviceControllerRemoveDeviceRequest)]; fidl::Builder builder(wr_bytes, sizeof(wr_bytes)); - auto req = builder.New<fuchsia_device_manager_ControllerRemoveDeviceRequest>(); + auto req = builder.New<fuchsia_device_manager_DeviceControllerRemoveDeviceRequest>(); ZX_ASSERT(req != nullptr); - req->hdr.ordinal = fuchsia_device_manager_ControllerRemoveDeviceOrdinal; + req->hdr.ordinal = fuchsia_device_manager_DeviceControllerRemoveDeviceOrdinal; // TODO(teisenbe): Allocate and track txids req->hdr.txid = 1; @@ -31,16 +32,16 @@ zx_status_t dh_send_create_device(Device* dev, Devhost* dh, zx::channel rpc, zx: size_t driver_path_size = dev->libname.size(); size_t args_size = strlen(args); uint32_t wr_num_bytes = - static_cast<uint32_t>(sizeof(fuchsia_device_manager_ControllerCreateDeviceRequest) + + static_cast<uint32_t>(sizeof(fuchsia_device_manager_DevhostControllerCreateDeviceRequest) + FIDL_ALIGN(driver_path_size) + FIDL_ALIGN(args_size)); FIDL_ALIGNDECL char wr_bytes[wr_num_bytes]; fidl::Builder builder(wr_bytes, wr_num_bytes); - auto req = builder.New<fuchsia_device_manager_ControllerCreateDeviceRequest>(); + auto req = builder.New<fuchsia_device_manager_DevhostControllerCreateDeviceRequest>(); char* driver_path_data = builder.NewArray<char>(static_cast<uint32_t>(driver_path_size)); char* args_data = builder.NewArray<char>(static_cast<uint32_t>(args_size)); ZX_ASSERT(req != nullptr && driver_path_data != nullptr && args_data != nullptr); - req->hdr.ordinal = fuchsia_device_manager_ControllerCreateDeviceOrdinal; + req->hdr.ordinal = fuchsia_device_manager_DevhostControllerCreateDeviceOrdinal; // TODO(teisenbe): Allocate and track txids req->hdr.txid = 1; @@ -72,12 +73,13 @@ zx_status_t dh_send_create_device(Device* dev, Devhost* dh, zx::channel rpc, zx: zx_status_t dh_send_create_device_stub(Device* dev, Devhost* dh, zx::channel rpc, uint32_t protocol_id) { - FIDL_ALIGNDECL char wr_bytes[sizeof(fuchsia_device_manager_ControllerCreateDeviceStubRequest)]; + FIDL_ALIGNDECL char wr_bytes[ + sizeof(fuchsia_device_manager_DevhostControllerCreateDeviceStubRequest)]; fidl::Builder builder(wr_bytes, sizeof(wr_bytes)); - auto req = builder.New<fuchsia_device_manager_ControllerCreateDeviceStubRequest>(); + auto req = builder.New<fuchsia_device_manager_DevhostControllerCreateDeviceStubRequest>(); ZX_ASSERT(req != nullptr); - req->hdr.ordinal = fuchsia_device_manager_ControllerCreateDeviceStubOrdinal; + req->hdr.ordinal = fuchsia_device_manager_DevhostControllerCreateDeviceStubOrdinal; // TODO(teisenbe): Allocate and track txids req->hdr.txid = 1; @@ -94,14 +96,15 @@ zx_status_t dh_send_create_device_stub(Device* dev, Devhost* dh, zx::channel rpc zx_status_t dh_send_bind_driver(const Device* dev, const char* libname, zx::vmo driver) { size_t libname_size = strlen(libname); uint32_t wr_num_bytes = static_cast<uint32_t>( - sizeof(fuchsia_device_manager_ControllerBindDriverRequest) + FIDL_ALIGN(libname_size)); + sizeof(fuchsia_device_manager_DeviceControllerBindDriverRequest) + + FIDL_ALIGN(libname_size)); FIDL_ALIGNDECL char wr_bytes[wr_num_bytes]; fidl::Builder builder(wr_bytes, wr_num_bytes); - auto req = builder.New<fuchsia_device_manager_ControllerBindDriverRequest>(); + auto req = builder.New<fuchsia_device_manager_DeviceControllerBindDriverRequest>(); char* libname_data = builder.NewArray<char>(static_cast<uint32_t>(libname_size)); ZX_ASSERT(req != nullptr && libname_data != nullptr); - req->hdr.ordinal = fuchsia_device_manager_ControllerBindDriverOrdinal; + req->hdr.ordinal = fuchsia_device_manager_DeviceControllerBindDriverOrdinal; // TODO(teisenbe): Allocate and track txids req->hdr.txid = 1; @@ -118,12 +121,13 @@ zx_status_t dh_send_bind_driver(const Device* dev, const char* libname, zx::vmo } zx_status_t dh_send_connect_proxy(const Device* dev, zx::channel proxy) { - FIDL_ALIGNDECL char wr_bytes[sizeof(fuchsia_device_manager_ControllerConnectProxyRequest)]; + FIDL_ALIGNDECL char wr_bytes[ + sizeof(fuchsia_device_manager_DeviceControllerConnectProxyRequest)]; fidl::Builder builder(wr_bytes, sizeof(wr_bytes)); - auto req = builder.New<fuchsia_device_manager_ControllerConnectProxyRequest>(); + auto req = builder.New<fuchsia_device_manager_DeviceControllerConnectProxyRequest>(); ZX_ASSERT(req != nullptr); - req->hdr.ordinal = fuchsia_device_manager_ControllerConnectProxyOrdinal; + req->hdr.ordinal = fuchsia_device_manager_DeviceControllerConnectProxyOrdinal; // TODO(teisenbe): Allocate and track txids req->hdr.txid = 1; @@ -136,12 +140,12 @@ zx_status_t dh_send_connect_proxy(const Device* dev, zx::channel proxy) { } zx_status_t dh_send_suspend(const Device* dev, uint32_t flags) { - FIDL_ALIGNDECL char wr_bytes[sizeof(fuchsia_device_manager_ControllerSuspendRequest)]; + FIDL_ALIGNDECL char wr_bytes[sizeof(fuchsia_device_manager_DeviceControllerSuspendRequest)]; fidl::Builder builder(wr_bytes, sizeof(wr_bytes)); - auto req = builder.New<fuchsia_device_manager_ControllerSuspendRequest>(); + auto req = builder.New<fuchsia_device_manager_DeviceControllerSuspendRequest>(); ZX_ASSERT(req != nullptr); - req->hdr.ordinal = fuchsia_device_manager_ControllerSuspendOrdinal; + req->hdr.ordinal = fuchsia_device_manager_DeviceControllerSuspendOrdinal; // TODO(teisenbe): Allocate and track txids req->hdr.txid = 1; req->flags = flags; @@ -156,17 +160,17 @@ zx_status_t dh_send_create_composite_device(Devhost* dh, const Device* composite size_t components_size = composite.components_count() * sizeof(uint64_t); size_t name_size = composite.name().size(); uint32_t wr_num_bytes = static_cast<uint32_t>( - sizeof(fuchsia_device_manager_ControllerCreateCompositeDeviceRequest) + + sizeof(fuchsia_device_manager_DevhostControllerCreateCompositeDeviceRequest) + FIDL_ALIGN(components_size) + FIDL_ALIGN(name_size)); FIDL_ALIGNDECL char wr_bytes[wr_num_bytes]; fidl::Builder builder(wr_bytes, wr_num_bytes); - auto req = builder.New<fuchsia_device_manager_ControllerCreateCompositeDeviceRequest>(); + auto req = builder.New<fuchsia_device_manager_DevhostControllerCreateCompositeDeviceRequest>(); uint64_t* components_data = builder.NewArray<uint64_t>( static_cast<uint32_t>(composite.components_count())); char* name_data = builder.NewArray<char>(static_cast<uint32_t>(name_size)); ZX_ASSERT(req != nullptr && components_data != nullptr && name_data != nullptr); - req->hdr.ordinal = fuchsia_device_manager_ControllerCreateCompositeDeviceOrdinal; + req->hdr.ordinal = fuchsia_device_manager_DevhostControllerCreateCompositeDeviceOrdinal; // TODO(teisenbe): Allocate and track txids req->hdr.txid = 1; diff --git a/zircon/system/core/devmgr/devhost/devhost.cpp b/zircon/system/core/devmgr/devhost/devhost.cpp index eccc4c219f72037ec74dd70ede85334dfccb2e82..fa2b734b5367ad9e13619e77df569f22ac439200 100644 --- a/zircon/system/core/devmgr/devhost/devhost.cpp +++ b/zircon/system/core/devmgr/devhost/devhost.cpp @@ -493,7 +493,8 @@ static zx_status_t fidl_CreateCompositeDevice(void* raw_ctx, zx_handle_t raw_rpc auto newconn = fbl::make_unique<DevcoordinatorConnection>(); if (!newconn) { - return fuchsia_device_manager_ControllerCreateCompositeDevice_reply(txn, ZX_ERR_NO_MEMORY); + return fuchsia_device_manager_DevhostControllerCreateCompositeDevice_reply(txn, + ZX_ERR_NO_MEMORY); } // Convert the component IDs into zx_device references @@ -508,7 +509,7 @@ static zx_status_t fidl_CreateCompositeDevice(void* raw_ctx, zx_handle_t raw_rpc uint64_t local_id = component_local_ids_data[i]; fbl::RefPtr<zx_device_t> dev = zx_device::GetDeviceFromLocalId(local_id); if (dev == nullptr || (dev->flags & DEV_FLAG_DEAD)) { - return fuchsia_device_manager_ControllerCreateCompositeDevice_reply( + return fuchsia_device_manager_DevhostControllerCreateCompositeDevice_reply( txn, ZX_ERR_NOT_FOUND); } components_list[i] = std::move(dev); @@ -518,7 +519,7 @@ static zx_status_t fidl_CreateCompositeDevice(void* raw_ctx, zx_handle_t raw_rpc fbl::RefPtr<zx_device_t> dev; zx_status_t status = zx_device::Create(&dev); if (status != ZX_OK) { - return fuchsia_device_manager_ControllerCreateCompositeDevice_reply(txn, status); + return fuchsia_device_manager_DevhostControllerCreateCompositeDevice_reply(txn, status); } static_assert(fuchsia_device_manager_DEVICE_NAME_MAX + 1 >= sizeof(dev->name)); memcpy(dev->name, name_data, name_size); @@ -528,7 +529,7 @@ static zx_status_t fidl_CreateCompositeDevice(void* raw_ctx, zx_handle_t raw_rpc status = InitializeCompositeDevice(dev, std::move(components_list)); if (status != ZX_OK) { - return fuchsia_device_manager_ControllerCreateCompositeDevice_reply(txn, status); + return fuchsia_device_manager_DevhostControllerCreateCompositeDevice_reply(txn, status); } newconn->dev = dev; @@ -537,9 +538,9 @@ static zx_status_t fidl_CreateCompositeDevice(void* raw_ctx, zx_handle_t raw_rpc log(RPC_IN, "devhost[%s] creating new composite conn=%p\n", ctx->path, newconn.get()); if ((status = DevcoordinatorConnection::BeginWait(std::move(newconn), DevhostAsyncLoop()->dispatcher())) != ZX_OK) { - return fuchsia_device_manager_ControllerCreateCompositeDevice_reply(txn, status); + return fuchsia_device_manager_DevhostControllerCreateCompositeDevice_reply(txn, status); } - return fuchsia_device_manager_ControllerCreateCompositeDevice_reply(txn, ZX_OK); + return fuchsia_device_manager_DevhostControllerCreateCompositeDevice_reply(txn, ZX_OK); } static zx_status_t fidl_BindDriver(void* raw_ctx, const char* driver_path_data, @@ -555,13 +556,13 @@ static zx_status_t fidl_BindDriver(void* raw_ctx, const char* driver_path_data, fbl::RefPtr<zx_driver_t> drv; if (ctx->conn->dev->flags & DEV_FLAG_DEAD) { log(ERROR, "devhost[%s] bind to removed device disallowed\n", ctx->path); - return fuchsia_device_manager_ControllerBindDriver_reply(txn, ZX_ERR_IO_NOT_PRESENT); + return fuchsia_device_manager_DeviceControllerBindDriver_reply(txn, ZX_ERR_IO_NOT_PRESENT); } zx_status_t r; if ((r = dh_find_driver(driver_path, std::move(driver_vmo), &drv)) < 0) { log(ERROR, "devhost[%s] driver load failed: %d\n", ctx->path, r); - return fuchsia_device_manager_ControllerBindDriver_reply(txn, r); + return fuchsia_device_manager_DeviceControllerBindDriver_reply(txn, r); } if (drv->has_bind_op()) { @@ -579,14 +580,14 @@ static zx_status_t fidl_BindDriver(void* raw_ctx, const char* driver_path_data, log(ERROR, "devhost[%s] bind driver '%.*s' failed: %d\n", ctx->path, static_cast<int>(driver_path_size), driver_path_data, r); } - return fuchsia_device_manager_ControllerBindDriver_reply(txn, r); + return fuchsia_device_manager_DeviceControllerBindDriver_reply(txn, r); } if (!drv->has_create_op()) { log(ERROR, "devhost[%s] neither create nor bind are implemented: '%.*s'\n", ctx->path, static_cast<int>(driver_path_size), driver_path_data); } - return fuchsia_device_manager_ControllerBindDriver_reply(txn, ZX_ERR_NOT_SUPPORTED); + return fuchsia_device_manager_DeviceControllerBindDriver_reply(txn, ZX_ERR_NOT_SUPPORTED); } static zx_status_t fidl_ConnectProxy(void* raw_ctx, zx_handle_t raw_shadow) { @@ -614,7 +615,7 @@ static zx_status_t fidl_Suspend(void* raw_ctx, uint32_t flags, fidl_txn_t* txn) r = devhost_device_suspend(device, flags); } // TODO(teisenbe): We should probably check this return... - fuchsia_device_manager_ControllerSuspend_reply(txn, r); + fuchsia_device_manager_DeviceControllerSuspend_reply(txn, r); return ZX_OK; } @@ -624,14 +625,17 @@ static zx_status_t fidl_RemoveDevice(void* raw_ctx) { return ZX_OK; } -static fuchsia_device_manager_Controller_ops_t fidl_ops = { +static fuchsia_device_manager_DevhostController_ops_t devhost_fidl_ops = { .CreateDeviceStub = fidl_CreateDeviceStub, .CreateDevice = fidl_CreateDevice, + .CreateCompositeDevice = fidl_CreateCompositeDevice, +}; + +static fuchsia_device_manager_DeviceController_ops_t device_fidl_ops = { .BindDriver = fidl_BindDriver, .ConnectProxy = fidl_ConnectProxy, - .Suspend = fidl_Suspend, .RemoveDevice = fidl_RemoveDevice, - .CreateCompositeDevice = fidl_CreateCompositeDevice, + .Suspend = fidl_Suspend, }; static zx_status_t dh_handle_rpc_read(zx_handle_t h, DevcoordinatorConnection* conn) { @@ -663,13 +667,18 @@ static zx_status_t dh_handle_rpc_read(zx_handle_t h, DevcoordinatorConnection* c // Double-check that Open (the only message we forward) cannot be mistaken for an // internal dev coordinator RPC message. static_assert( - fuchsia_device_manager_ControllerCreateDeviceStubOrdinal != + fuchsia_device_manager_DevhostControllerCreateDeviceStubOrdinal != fuchsia_io_DirectoryOpenOrdinal && - fuchsia_device_manager_ControllerCreateDeviceOrdinal != fuchsia_io_DirectoryOpenOrdinal && - fuchsia_device_manager_ControllerBindDriverOrdinal != fuchsia_io_DirectoryOpenOrdinal && - fuchsia_device_manager_ControllerConnectProxyOrdinal != fuchsia_io_DirectoryOpenOrdinal && - fuchsia_device_manager_ControllerSuspendOrdinal != fuchsia_io_DirectoryOpenOrdinal && - fuchsia_device_manager_ControllerRemoveDeviceOrdinal != fuchsia_io_DirectoryOpenOrdinal); + fuchsia_device_manager_DevhostControllerCreateDeviceOrdinal != + fuchsia_io_DirectoryOpenOrdinal && + fuchsia_device_manager_DeviceControllerBindDriverOrdinal != + fuchsia_io_DirectoryOpenOrdinal && + fuchsia_device_manager_DeviceControllerConnectProxyOrdinal != + fuchsia_io_DirectoryOpenOrdinal && + fuchsia_device_manager_DeviceControllerSuspendOrdinal != + fuchsia_io_DirectoryOpenOrdinal && + fuchsia_device_manager_DeviceControllerRemoveDeviceOrdinal != + fuchsia_io_DirectoryOpenOrdinal); auto hdr = static_cast<fidl_message_header_t*>(fidl_msg.bytes); if (hdr->ordinal == fuchsia_io_DirectoryOpenOrdinal) { @@ -686,8 +695,15 @@ static zx_status_t dh_handle_rpc_read(zx_handle_t h, DevcoordinatorConnection* c FidlTxn txn(zx::unowned_channel(h), hdr->txid); DevhostRpcReadContext read_ctx = {path, conn}; - return fuchsia_device_manager_Controller_dispatch(&read_ctx, txn.fidl_txn(), &fidl_msg, - &fidl_ops); + // TODO(teisenbe): Instead of trying both, have a different handler function + // for devhosts and devices + r = fuchsia_device_manager_DevhostController_try_dispatch(&read_ctx, txn.fidl_txn(), &fidl_msg, + &devhost_fidl_ops); + if (r != ZX_ERR_NOT_SUPPORTED) { + return r; + } + return fuchsia_device_manager_DeviceController_dispatch(&read_ctx, txn.fidl_txn(), &fidl_msg, + &device_fidl_ops); } // handles devcoordinator rpc diff --git a/zircon/system/fidl/fuchsia-device-manager/coordinator.fidl b/zircon/system/fidl/fuchsia-device-manager/coordinator.fidl index c7b2cd361b74bf782810843c2cb41613f02c1be4..fb320726dce3c0c85adb2f503c09a5fdf4f6db28 100644 --- a/zircon/system/fidl/fuchsia-device-manager/coordinator.fidl +++ b/zircon/system/fidl/fuchsia-device-manager/coordinator.fidl @@ -67,11 +67,31 @@ struct DeviceComponent { array<DeviceComponentPart>:DEVICE_COMPONENT_PARTS_MAX parts; }; -/// Interface for controlling a device in a devhost process from the devcoordinator. +/// Protocol for controlling devices in a devhost process from the devcoordinator [Layout = "Simple"] -protocol Controller { - // TODO(ZX-2921): These should probably return a status? +protocol DeviceController { + /// Bind the requested driver to this device. |driver_path| is informational, + /// but all calls to BindDriver/CreateDevice should use the same |driver_path| + /// each time they use a |driver| VMO with the same contents. + BindDriver(string:DEVICE_PATH_MAX driver_path, handle<vmo> driver) + -> (zx.status status); + /// Give this device a channel to its shadow in another process. + ConnectProxy(handle<channel> shadow); + + /// Ask the devhost to remove this device. On success, the remote end of + /// this interface channel will close instead of returning a result. + RemoveDevice(); + + /// Ask devhost to suspend all of its devices, using the target state indicated by |flags|. + /// This should logically be in DevhostController, but currently this is instead sent to the + /// first device in the devhost + Suspend(uint32 flags) -> (zx.status status); +}; + +/// Protocol for controlling a devhost process from the devcoordinator +[Layout = "Simple"] +protocol DevhostController { /// Create a device in the devhost that only implements the device protocol /// and claims to support the given |protocol_id|. This device will communicate /// with the devcoordinator via |rpc|. @@ -95,22 +115,6 @@ protocol Controller { handle<vmo> driver, handle? parent_proxy, string:DEVICE_ARGS_MAX? proxy_args, LocalDeviceId local_device_id); - /// Bind the requested driver to this device. |driver_path| is informational, - /// but all calls to BindDriver/CreateDevice should use the same |driver_path| - /// each time they use a |driver| VMO with the same contents. - BindDriver(string:DEVICE_PATH_MAX driver_path, handle<vmo> driver) - -> (zx.status status); - - /// Give this device a channel to its shadow in another process. - ConnectProxy(handle<channel> shadow); - - /// Ask devhost to suspend all of its devices, using the target state indicated by |flags|. - Suspend(uint32 flags) -> (zx.status status); - - /// Ask the devhost to remove this device. On success, the remote end of - /// this interface channel will close instead of returning a result. - RemoveDevice(); - /// Introduce a composite device that has the given name and properties. /// |components| will be a list of all of the composite's components, /// described using devhost local device ids. The order of the components