From 98400a68c924b06fb793408c0f9223590ab1896b Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Tue, 12 Oct 2021 13:33:27 +0200 Subject: [PATCH] os: extend ARM Platform::Device constructor Enable construction by explicitely naming a specific device, if more than one device of the same type exist. Ref #4297 --- repos/os/include/spec/arm/platform_session/device.h | 5 +++++ repos/os/src/drivers/nic/virtio/mmio_device.cc | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/repos/os/include/spec/arm/platform_session/device.h b/repos/os/include/spec/arm/platform_session/device.h index d70eacd997..61b8f86322 100644 --- a/repos/os/include/spec/arm/platform_session/device.h +++ b/repos/os/include/spec/arm/platform_session/device.h @@ -70,6 +70,11 @@ class Platform::Device : Interface, Noncopyable _platform(platform), _cap(platform.device_by_type(type.name.string())) { } + Device(Connection &platform, Name name) + : + _platform(platform), _cap(platform.acquire_device(name)) + { } + ~Device() { _platform.release_device(_cap); } }; diff --git a/repos/os/src/drivers/nic/virtio/mmio_device.cc b/repos/os/src/drivers/nic/virtio/mmio_device.cc index b9a522c6ef..9168412df1 100644 --- a/repos/os/src/drivers/nic/virtio/mmio_device.cc +++ b/repos/os/src/drivers/nic/virtio/mmio_device.cc @@ -35,7 +35,8 @@ struct Virtio_mmio_nic::Main Env & env; Heap heap { env.ram(), env.rm() }; Platform::Connection platform { env }; - Platform::Device platform_device { platform, { "nic" } }; + Platform::Device platform_device { platform, + Platform::Device::Type { "nic" } }; Virtio::Device device { platform_device }; Attached_rom_dataspace config_rom { env, "config" }; Constructible root { };