From 7c5b59556a559304ed5bb897552b312ff4e99cf9 Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Fri, 8 Sep 2023 13:28:56 +0200 Subject: [PATCH] pci_decode: add node to devices genodelabs/genode#5002 --- repos/os/src/app/pci_decode/main.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/repos/os/src/app/pci_decode/main.cc b/repos/os/src/app/pci_decode/main.cc index 6f4759df73..42c7460529 100644 --- a/repos/os/src/app/pci_decode/main.cc +++ b/repos/os/src/app/pci_decode/main.cc @@ -244,6 +244,35 @@ bus_t Main::parse_pci_function(Bdf bdf, gen.attribute("size", rmrr.size); }); }); + + /* XXX We currently only support unsegmented platforms with a single + * pci config space. Yet as soon as we do support those, we + * must assign the DMA-remapping hardware unit to the different pci + * segments resp. their devices. + */ + + bool drhd_device_found = false; + drhd_list.for_each([&] (Drhd const & drhd) { + if (drhd_device_found) return; + + bool device_match = false; + drhd.devices.for_each([&] (Drhd::Device const & device) { + if (device.bdf == bdf) + device_match = true; + }); + + if (device_match) { + drhd_device_found = true; + gen.node("io_mmu", [&] { gen.attribute("name", drhd.name()); }); + } + }); + + if (!drhd_device_found) { + drhd_list.for_each([&] (Drhd const & drhd) { + if (drhd.scope == Drhd::Scope::INCLUDE_PCI_ALL) + gen.node("io_mmu", [&] { gen.attribute("name", drhd.name()); }); + }); + } }); return subordinate_bus;