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
This commit is contained in:
Stefan Kalkowski 2021-10-12 13:33:27 +02:00 committed by Norman Feske
parent 8679f32d0b
commit 98400a68c9
2 changed files with 7 additions and 1 deletions

View File

@ -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); }
};

View File

@ -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<Virtio_nic::Root> root { };