From 24875c0ea8186ea249337725d6569fe47e935d83 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 13 Jun 2017 13:07:58 +0200 Subject: [PATCH] platform_drv: add report about available pci devices Issue #1359 --- repos/os/recipes/src/platform_drv/used_apis | 1 + .../platform/spec/x86/pci_device_config.h | 7 ---- .../platform/spec/x86/pci_session_component.h | 39 +++++++++++++++++++ 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/repos/os/recipes/src/platform_drv/used_apis b/repos/os/recipes/src/platform_drv/used_apis index 162b9dd12..dbf0f2d7f 100644 --- a/repos/os/recipes/src/platform_drv/used_apis +++ b/repos/os/recipes/src/platform_drv/used_apis @@ -1,3 +1,4 @@ base os platform_session +report_session diff --git a/repos/os/src/drivers/platform/spec/x86/pci_device_config.h b/repos/os/src/drivers/platform/spec/x86/pci_device_config.h index 22c9ee278..64be19b76 100644 --- a/repos/os/src/drivers/platform/spec/x86/pci_device_config.h +++ b/repos/os/src/drivers/platform/spec/x86/pci_device_config.h @@ -169,13 +169,6 @@ namespace Platform { */ bool pci_bridge() { return _header_type == HEADER_PCI_TO_PCI; } - /** - * Return true if device is a PCI bridge - * - * \deprecated use 'pci_bridge instead - */ - bool is_pci_bridge() { return pci_bridge(); } - /** * Return true if device is valid */ diff --git a/repos/os/src/drivers/platform/spec/x86/pci_session_component.h b/repos/os/src/drivers/platform/spec/x86/pci_session_component.h index b4c4406f7..6f402bef9 100644 --- a/repos/os/src/drivers/platform/spec/x86/pci_session_component.h +++ b/repos/os/src/drivers/platform/spec/x86/pci_session_component.h @@ -28,6 +28,7 @@ /* os */ #include #include +#include #include #include @@ -1011,6 +1012,8 @@ class Platform::Root : public Genode::Root_component Genode::Env &_env; Genode::Attached_rom_dataspace &_config; + Genode::Reporter _pci_reporter { _env, "pci" }; + Genode::Rpc_entrypoint _device_pd_ep; Genode::Heap _heap { _env.ram(), _env.rm() }; Platform::Pci_buses _buses { _env, _heap }; @@ -1191,6 +1194,42 @@ class Platform::Root : public Genode::Root_component Genode::error("PCI config space data could not be parsed."); } } + + _pci_reporter.enabled(config.xml().has_sub_node("report") && + config.xml().sub_node("report") + .attribute_value("pci", true)); + + if (_pci_reporter.enabled()) { + + Config_access config_access(env); + Device_config config; + int bus = 0, device = 0, function = -1; + + Genode::Reporter::Xml_generator xml(_pci_reporter, [&] () { + /* iterate over pci devices */ + while (true) { + function += 1; + if (!_buses.find_next(bus, device, function, &config, + &config_access)) + return; + + bus = config.bus_number(); + device = config.device_number(); + function = config.function_number(); + + using Genode::String; + using Genode::Hex; + + xml.node("device", [&] () { + xml.attribute("bdf" , String<8>(Hex(bus, Hex::Prefix::OMIT_PREFIX), ":", Hex(device, Hex::Prefix::OMIT_PREFIX), ".", function)); + xml.attribute("vendor_id" , String<8>(Hex(config.vendor_id()))); + xml.attribute("device_id" , String<8>(Hex(config.device_id()))); + xml.attribute("class_code", String<12>(Hex(config.class_code()))); + xml.attribute("bridge" , config.pci_bridge() ? "yes" : "no"); + }); + } + }); + } } void system_reset()