mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
parent
be5ae4dffa
commit
ff0f1ebafc
67
repos/os/run/pci.run
Normal file
67
repos/os/run/pci.run
Normal file
@ -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 {
|
||||
<policy label_prefix="test-pci"> <pci class="ALL"/> </policy>}
|
||||
}
|
||||
|
||||
append_platform_drv_build_components
|
||||
|
||||
build $build_components
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
append config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="RAM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append config {
|
||||
<start name="test-pci">
|
||||
<resource name="RAM" quantum="2M"/>
|
||||
</start>
|
||||
</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
|
||||
|
@ -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 <base/env.h>
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
#include <platform_session/connection.h>
|
||||
#include <platform_device/client.h>
|
||||
#include <util/retry.h>
|
||||
|
||||
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<Platform::Session::Out_of_metadata>(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<Platform::Session::Out_of_metadata>(attempt, handler);
|
||||
}
|
||||
|
||||
/* release last device */
|
||||
pci.release_device(prev_device_cap);
|
||||
|
||||
log("--- Platform test finished ---");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user