diff --git a/repos/os/run/pci.run b/repos/os/run/pci.run new file mode 100644 index 0000000000..92a01a8b18 --- /dev/null +++ b/repos/os/run/pci.run @@ -0,0 +1,67 @@ +assert_spec pci +# +# Build +# +set build_components { core init test/pci } + +source ${genode_dir}/repos/base/run/platform_drv.inc + +# override default platform driver policy +proc platform_drv_policy {} { + return { + } +} + +append_platform_drv_build_components + +build $build_components +create_boot_directory + +# +# Generate config +# + +append config { + + + + + + + + + + + + + + + } + +append_platform_drv_config + +append config { + + + +} + +install_config $config + +# +# Boot modules +# + +# generic modules +set boot_modules { + core ld.lib.so init test-pci +} + +# platform-specific modules +append_platform_drv_boot_modules +build_boot_image $boot_modules + +append qemu_args "-nographic -m 64" + +run_genode_until "--- Platform test finished ---.*\n" 10 + diff --git a/repos/os/src/test/pci/test.cc b/repos/os/src/test/pci/test.cc index da2cf5361f..3a21ede984 100644 --- a/repos/os/src/test/pci/test.cc +++ b/repos/os/src/test/pci/test.cc @@ -5,16 +5,17 @@ */ /* - * Copyright (C) 2008-2013 Genode Labs GmbH + * Copyright (C) 2008-2016 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include +#include using namespace Genode; @@ -45,7 +46,7 @@ static void print_device_info(Platform::Device_capability device_cap) "class=", Hex(class_code), " " "vendor=", Hex(vendor_id), " ", (vendor_id == INTEL_VENDOR_ID ? "(Intel)" : "(unknown)"), - "device=", Hex(device_id)); + " device=", Hex(device_id)); for (int resource_id = 0; resource_id < 6; resource_id++) { @@ -63,31 +64,40 @@ static void print_device_info(Platform::Device_capability device_cap) } -int main(int argc, char **argv) +void Component::construct(Genode::Env &env) { log("--- Platform test started ---"); /* open session to pci service */ - static Platform::Connection pci; + static Platform::Connection pci(env); + + /* + * Functor that is called if the platform driver throws a + * 'Out_of_metadata' exception. + */ + auto handler = [&] () { pci.upgrade_ram(4096); }; + + Platform::Device_capability prev_device_cap, device_cap; + + auto attempt = [&] () { device_cap = pci.first_device(); }; + retry(attempt, handler); /* * Iterate through all installed devices * and print the available device information. */ - Platform::Device_capability prev_device_cap, - device_cap = pci.first_device(); while (device_cap.valid()) { print_device_info(device_cap); pci.release_device(prev_device_cap); prev_device_cap = device_cap; - device_cap = pci.next_device(prev_device_cap); + + auto attempt = [&] () { device_cap = pci.next_device(device_cap); }; + retry(attempt, handler); } /* release last device */ pci.release_device(prev_device_cap); log("--- Platform test finished ---"); - - return 0; }