mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-11 21:32:57 +00:00
gems: remove driver_manager
The former pkg/drivers_managed-pc has been replaced by the pkg/sculpt_drivers-pc, which is merely a collection of archives. Issue #5150
This commit is contained in:
parent
99da68183f
commit
85e020b8e1
@ -1,4 +0,0 @@
|
||||
|
||||
Device-driver subsystem that starts drivers for
|
||||
framebuffer, input, and block devices on demand
|
||||
|
@ -1,7 +1,5 @@
|
||||
_/pkg/sculpt
|
||||
_/pkg/drivers_managed-pc
|
||||
_/pkg/pc_wifi
|
||||
_/pkg/pc_nic_drv
|
||||
_/pkg/sculpt_drivers-pc
|
||||
_/pkg/vbox6
|
||||
_/pkg/acpica
|
||||
_/pkg/system_clock-pc
|
||||
|
3
repos/gems/recipes/pkg/sculpt_drivers-pc/README
Normal file
3
repos/gems/recipes/pkg/sculpt_drivers-pc/README
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
Device drivers for the Sculpt OS base system on the PC
|
||||
|
@ -1,20 +1,16 @@
|
||||
_/src/pc_platform_drv
|
||||
_/src/pci_decode
|
||||
_/pkg/pc_wifi
|
||||
_/src/acpi_drv
|
||||
_/src/ps2_drv
|
||||
_/src/pc_usb_host_drv
|
||||
_/src/usb_hid_drv
|
||||
_/src/usb_block_drv
|
||||
_/src/vesa_drv
|
||||
_/src/pc_intel_fb_drv
|
||||
_/src/intel_gpu_drv
|
||||
_/src/boot_fb_drv
|
||||
_/src/ahci_drv
|
||||
_/src/boot_fb_drv
|
||||
_/src/intel_gpu_drv
|
||||
_/src/nvme_drv
|
||||
_/src/report_rom
|
||||
_/src/event_filter
|
||||
_/src/init
|
||||
_/src/driver_manager
|
||||
_/src/rom_filter
|
||||
_/src/pci_decode
|
||||
_/src/pc_intel_fb_drv
|
||||
_/src/pc_nic_drv
|
||||
_/src/pc_platform_drv
|
||||
_/src/pc_usb_host_drv
|
||||
_/src/ps2_drv
|
||||
_/src/usb_block_drv
|
||||
_/src/usb_hid_drv
|
||||
_/src/vesa_drv
|
||||
_/src/rom_reporter
|
||||
_/raw/drivers_managed-pc
|
@ -1,20 +0,0 @@
|
||||
content: drivers.config fb_drv.config event_filter.config en_us.chargen \
|
||||
special.chargen numlock_remap.config gpu_drv.config
|
||||
|
||||
drivers.config:
|
||||
cp $(REP_DIR)/sculpt/drivers/pc $@
|
||||
|
||||
numlock_remap.config:
|
||||
cp $(REP_DIR)/sculpt/numlock_remap/default $@
|
||||
|
||||
event_filter.config:
|
||||
cp $(REP_DIR)/sculpt/event_filter/pc $@
|
||||
|
||||
fb_drv.config:
|
||||
cp $(REP_DIR)/sculpt/fb_drv/default $@
|
||||
|
||||
gpu_drv.config:
|
||||
cp $(REP_DIR)/sculpt/gpu_drv/intel $@
|
||||
|
||||
en_us.chargen special.chargen:
|
||||
cp $(GENODE_DIR)/repos/os/src/server/event_filter/$@ $@
|
@ -1 +0,0 @@
|
||||
2023-11-29 c9447e22a08d7ea395792c64bf1c59f5e091664e
|
@ -1,2 +0,0 @@
|
||||
SRC_DIR := src/app/driver_manager
|
||||
include $(GENODE_DIR)/repos/base/recipes/src/content.inc
|
@ -1 +0,0 @@
|
||||
2024-02-25 93cc0093e10f3300e2c7cc633c24c8430299322b
|
@ -1,9 +0,0 @@
|
||||
base
|
||||
os
|
||||
report_session
|
||||
block_session
|
||||
usb_session
|
||||
capture_session
|
||||
timer_session
|
||||
platform_session
|
||||
gpu_session
|
@ -1,166 +0,0 @@
|
||||
if {![have_spec x86] || [have_spec linux]} {
|
||||
puts "Platform is unsupported."
|
||||
exit 0
|
||||
}
|
||||
|
||||
build { app/driver_manager test/driver_manager lib/ld }
|
||||
|
||||
create_boot_directory
|
||||
|
||||
import_from_depot [depot_user]/src/[base_src] \
|
||||
[depot_user]/pkg/drivers_managed-pc \
|
||||
[depot_user]/src/report_rom \
|
||||
[depot_user]/src/dynamic_rom \
|
||||
[depot_user]/src/nitpicker \
|
||||
[depot_user]/src/init
|
||||
|
||||
install_config {
|
||||
<config prio_levels="2">
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<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>
|
||||
<default caps="100"/>
|
||||
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides><service name="Timer"/></provides>
|
||||
</start>
|
||||
|
||||
<start name="report_rom">
|
||||
<binary name="report_rom"/>
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Report"/> <service name="ROM"/> </provides>
|
||||
<config verbose="yes">
|
||||
<policy label="test-driver_manager -> block_devices" report="drivers -> block_devices"/>
|
||||
<policy label="test-driver_manager -> displays" report="nitpicker -> displays"/>
|
||||
</config>
|
||||
</start>
|
||||
|
||||
<start name="drivers" caps="2500" managing_system="yes">
|
||||
<resource name="RAM" quantum="64M"/>
|
||||
<binary name="init"/>
|
||||
<route>
|
||||
<service name="ROM" label_last="managed/event_filter">
|
||||
<parent label="event_filter.config"/> </service>
|
||||
<service name="ROM" label_last="numlock_remap">
|
||||
<parent label="numlock_remap.config"/> </service>
|
||||
<service name="ROM" label="config"> <parent label="drivers.config"/> </service>
|
||||
<service name="ROM" label="capslock"> <child name="dynamic_rom"/> </service>
|
||||
<service name="ROM" label="numlock"> <child name="dynamic_rom"/> </service>
|
||||
<service name="ROM" label="system"> <child name="dynamic_rom"/> </service>
|
||||
<service name="ROM" label="usb_policy"><child name="dynamic_rom"/> </service>
|
||||
<service name="Timer"> <child name="timer"/> </service>
|
||||
<service name="Capture"> <child name="nitpicker"/> </service>
|
||||
<service name="Event"> <child name="nitpicker"/> </service>
|
||||
<service name="Report"> <child name="report_rom"/> </service>
|
||||
<any-service> <parent/> </any-service>
|
||||
</route>
|
||||
<provides> <service name="Block"/> </provides>
|
||||
</start>
|
||||
|
||||
<start name="dynamic_rom">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides> <service name="ROM"/> </provides>
|
||||
<config verbose="yes">
|
||||
<rom name="capslock">
|
||||
<inline> <capslock enabled="no"/> </inline>
|
||||
<sleep milliseconds="500" />
|
||||
<inline> <capslock enabled="yes"/> </inline>
|
||||
<sleep milliseconds="500" />
|
||||
</rom>
|
||||
<rom name="numlock">
|
||||
<inline> <numlock enabled="no"/> </inline>
|
||||
<sleep milliseconds="1000" />
|
||||
<inline> <numlock enabled="yes"/> </inline>
|
||||
<sleep milliseconds="1000" />
|
||||
</rom>
|
||||
<rom name="system">
|
||||
<inline> <system state=""/> </inline>
|
||||
<sleep milliseconds="10000" />
|
||||
</rom>
|
||||
<rom name="numlock_remap">
|
||||
<inline> <system state=""/> </inline>
|
||||
<sleep milliseconds="10000" />
|
||||
</rom>
|
||||
</config>
|
||||
</start>
|
||||
|
||||
<start name="nitpicker">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<provides>
|
||||
<service name="Gui"/> <service name="Capture"/> <service name="Event"/>
|
||||
</provides>
|
||||
<config>
|
||||
<capture/> <event/>
|
||||
<report displays="yes"/>
|
||||
</config>
|
||||
<route>
|
||||
<service name="Report"> <child name="report_rom"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
</start>
|
||||
|
||||
<start name="test-driver_manager">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<config>
|
||||
<check_ahci_block_device label="ahci-1" block_count="65536" block_size="512"
|
||||
model="QEMU HARDDISK"/>
|
||||
<check_displays/>
|
||||
</config>
|
||||
<route>
|
||||
<service name="ROM" label="block_devices"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="displays"> <child name="report_rom"/> </service>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</route>
|
||||
</start>
|
||||
|
||||
</config>}
|
||||
|
||||
set fd [open [run_dir]/genode/fb_drv.config "w"]
|
||||
puts $fd {
|
||||
<config width="1024" height="768" buffered="yes"> <!-- used by VESA driver -->
|
||||
<report connectors="yes"/>
|
||||
<connector name="eDP-36" width="1920" height="1080" enabled="true"/>
|
||||
</config>}
|
||||
close $fd
|
||||
|
||||
set fd [open [run_dir]/genode/usb_policy "w"]
|
||||
puts $fd {<usb/>}
|
||||
close $fd
|
||||
|
||||
copy_file [genode_dir]/repos/gems/sculpt/drivers/pc \
|
||||
[run_dir]/genode/drivers.config
|
||||
|
||||
build_boot_image [build_artifacts]
|
||||
|
||||
#
|
||||
# Build ext2 file-system images to be supplied to Qemu
|
||||
#
|
||||
if {[have_include "power_on/qemu"]} {
|
||||
|
||||
set mke2fs [installed_command mke2fs]
|
||||
set dd [installed_command dd]
|
||||
|
||||
catch { exec $dd if=/dev/zero of=bin/hdd_disk.raw bs=1M count=32 }
|
||||
catch { exec $mke2fs -F bin/hdd_disk.raw }
|
||||
}
|
||||
|
||||
#
|
||||
# Qemu opts for supplying hdd_disk.raw as AHCI disk
|
||||
#
|
||||
append qemu_args " -nographic "
|
||||
append qemu_args " -device ahci,id=ahci "
|
||||
append qemu_args " -drive id=hdd,file=bin/hdd_disk.raw,format=raw,if=none -device ide-hd,drive=hdd,bus=ahci.1 "
|
||||
|
||||
run_genode_until {.*all expected devices present and accessible.*\n} 120
|
||||
|
@ -4,7 +4,7 @@ system: pc
|
||||
gpu_drv: intel
|
||||
|
||||
# supplemental depot content added to the system image
|
||||
import: pkg/drivers_managed-pc pkg/pc_wifi src/pc_nic_drv
|
||||
import: pkg/sculpt_drivers-pc
|
||||
|
||||
# selection of launcher-menu entries
|
||||
launcher: vm_fs shared_fs download_debug_info
|
||||
|
@ -6,4 +6,4 @@ ram_fs: depot
|
||||
launcher: ping pc_nic
|
||||
|
||||
# supplemental depot content added to the system image
|
||||
import: pkg/drivers_managed-pc src/pc_nic_drv pkg/pc_nic pkg/ping
|
||||
import: pkg/sculpt_drivers-pc pkg/pc_nic pkg/ping
|
||||
|
@ -1,354 +0,0 @@
|
||||
/*
|
||||
* \brief Driver manager
|
||||
* \author Norman Feske
|
||||
* \date 2017-06-13
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/component.h>
|
||||
#include <base/registry.h>
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <os/reporter.h>
|
||||
#include <block_session/block_session.h>
|
||||
#include <rm_session/rm_session.h>
|
||||
#include <capture_session/capture_session.h>
|
||||
#include <gpu_session/gpu_session.h>
|
||||
#include <io_mem_session/io_mem_session.h>
|
||||
#include <io_port_session/io_port_session.h>
|
||||
#include <timer_session/timer_session.h>
|
||||
#include <log_session/log_session.h>
|
||||
#include <platform_session/platform_session.h>
|
||||
|
||||
namespace Driver_manager {
|
||||
using namespace Genode;
|
||||
struct Main;
|
||||
struct Device_driver;
|
||||
struct Nvme_driver;
|
||||
|
||||
struct Priority { int value; };
|
||||
|
||||
struct Version { unsigned value; };
|
||||
}
|
||||
|
||||
|
||||
class Driver_manager::Device_driver : Noncopyable
|
||||
{
|
||||
public:
|
||||
|
||||
typedef String<64> Name;
|
||||
typedef String<100> Binary;
|
||||
typedef String<32> Service;
|
||||
|
||||
protected:
|
||||
|
||||
static void _gen_common_start_node_content(Xml_generator &xml,
|
||||
Name const &name,
|
||||
Binary const &binary,
|
||||
Ram_quota ram,
|
||||
Cap_quota caps,
|
||||
Priority priority,
|
||||
Version version)
|
||||
{
|
||||
xml.attribute("name", name);
|
||||
xml.attribute("caps", String<64>(caps));
|
||||
xml.attribute("priority", priority.value);
|
||||
xml.attribute("version", version.value);
|
||||
xml.node("binary", [&] () { xml.attribute("name", binary); });
|
||||
xml.node("resource", [&] () {
|
||||
xml.attribute("name", "RAM");
|
||||
xml.attribute("quantum", String<64>(ram));
|
||||
});
|
||||
}
|
||||
|
||||
template <typename SESSION>
|
||||
static void _gen_provides_node(Xml_generator &xml)
|
||||
{
|
||||
xml.node("provides", [&] () {
|
||||
xml.node("service", [&] () {
|
||||
xml.attribute("name", SESSION::service_name()); }); });
|
||||
}
|
||||
|
||||
static void _gen_config_route(Xml_generator &xml, char const *config_name)
|
||||
{
|
||||
xml.node("service", [&] () {
|
||||
xml.attribute("name", Rom_session::service_name());
|
||||
xml.attribute("label", "config");
|
||||
xml.node("parent", [&] () {
|
||||
xml.attribute("label", config_name); });
|
||||
});
|
||||
}
|
||||
|
||||
static void _gen_default_parent_route(Xml_generator &xml)
|
||||
{
|
||||
xml.node("any-service", [&] () {
|
||||
xml.node("parent", [&] () { }); });
|
||||
}
|
||||
|
||||
template <typename SESSION>
|
||||
static void _gen_forwarded_service(Xml_generator &xml,
|
||||
Device_driver::Name const &name)
|
||||
{
|
||||
xml.node("service", [&] () {
|
||||
xml.attribute("name", SESSION::service_name());
|
||||
xml.node("default-policy", [&] () {
|
||||
xml.node("child", [&] () {
|
||||
xml.attribute("name", name);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
virtual ~Device_driver() { }
|
||||
|
||||
public:
|
||||
|
||||
virtual void generate_start_node(Xml_generator &xml) const = 0;
|
||||
};
|
||||
|
||||
|
||||
struct Driver_manager::Nvme_driver : Device_driver
|
||||
{
|
||||
void generate_start_node(Xml_generator &xml) const override
|
||||
{
|
||||
xml.node("start", [&] () {
|
||||
_gen_common_start_node_content(xml, "nvme_drv", "nvme_drv",
|
||||
Ram_quota{8*1024*1024}, Cap_quota{100},
|
||||
Priority{-1}, Version{0});
|
||||
_gen_provides_node<Block::Session>(xml);
|
||||
xml.node("config", [&] () {
|
||||
xml.node("report", [&] () { xml.attribute("namespaces", "yes"); });
|
||||
xml.node("policy", [&] () {
|
||||
xml.attribute("label_suffix", String<64>("nvme-0"));
|
||||
xml.attribute("namespace", 1);
|
||||
xml.attribute("writeable", "yes");
|
||||
});
|
||||
});
|
||||
xml.node("route", [&] () {
|
||||
xml.node("service", [&] () {
|
||||
xml.attribute("name", "Report");
|
||||
xml.node("parent", [&] () { xml.attribute("label", "nvme_ns"); });
|
||||
});
|
||||
_gen_default_parent_route(xml);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
typedef String<32> Default_label;
|
||||
|
||||
void gen_service_forwarding_policy(Xml_generator &xml,
|
||||
Default_label const &default_label) const
|
||||
{
|
||||
xml.node("policy", [&] () {
|
||||
xml.attribute("label_suffix", String<64>("nvme-0"));
|
||||
xml.node("child", [&] () {
|
||||
xml.attribute("name", "nvme_drv"); });
|
||||
});
|
||||
|
||||
if (default_label.valid()) {
|
||||
xml.node("policy", [&] () {
|
||||
xml.attribute("label_suffix", " default");
|
||||
xml.node("child", [&] () {
|
||||
xml.attribute("name", "nvme_drv");
|
||||
xml.attribute("label", default_label);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct Driver_manager::Main
|
||||
{
|
||||
Env &_env;
|
||||
|
||||
Attached_rom_dataspace _platform { _env, "platform_info" };
|
||||
Attached_rom_dataspace _devices { _env, "devices" };
|
||||
Attached_rom_dataspace _nvme_ns { _env, "nvme_ns" };
|
||||
|
||||
Reporter _init_config { _env, "config", "init.config" };
|
||||
Reporter _block_devices { _env, "block_devices" };
|
||||
|
||||
Constructible<Nvme_driver> _nvme_driver { };
|
||||
|
||||
bool _devices_rom_parsed { false };
|
||||
|
||||
void _handle_devices_update();
|
||||
|
||||
Signal_handler<Main> _devices_update_handler {
|
||||
_env.ep(), *this, &Main::_handle_devices_update };
|
||||
|
||||
void _handle_nvme_ns_update();
|
||||
|
||||
Signal_handler<Main> _nvme_ns_update_handler {
|
||||
_env.ep(), *this, &Main::_handle_nvme_ns_update };
|
||||
|
||||
static void _gen_parent_service_xml(Xml_generator &xml, char const *name)
|
||||
{
|
||||
xml.node("service", [&] () { xml.attribute("name", name); });
|
||||
};
|
||||
|
||||
void _generate_init_config (Reporter &) const;
|
||||
void _generate_block_devices(Reporter &) const;
|
||||
|
||||
void _generate_block_devices()
|
||||
{
|
||||
/* devices must be detected before the checks below can be conducted */
|
||||
if (!_devices_rom_parsed)
|
||||
return;
|
||||
|
||||
/* check that all drivers completed initialization before reporting */
|
||||
if (_nvme_driver.constructed() && !_nvme_ns.xml().has_type("controller"))
|
||||
return;
|
||||
|
||||
_generate_block_devices(_block_devices);
|
||||
}
|
||||
|
||||
Main(Env &env) : _env(env)
|
||||
{
|
||||
_init_config.enabled(true);
|
||||
_block_devices.enabled(true);
|
||||
|
||||
_devices .sigh(_devices_update_handler);
|
||||
_nvme_ns .sigh(_nvme_ns_update_handler);
|
||||
|
||||
_generate_init_config(_init_config);
|
||||
|
||||
_handle_devices_update();
|
||||
_handle_nvme_ns_update();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void Driver_manager::Main::_handle_devices_update()
|
||||
{
|
||||
_devices.update();
|
||||
|
||||
if (!_devices.valid())
|
||||
return;
|
||||
|
||||
bool has_ahci = false;
|
||||
bool has_nvme = false;
|
||||
|
||||
_devices.xml().for_each_sub_node([&] (Xml_node device) {
|
||||
device.with_optional_sub_node("pci-config", [&] (Xml_node pci) {
|
||||
|
||||
uint16_t const vendor_id = (uint16_t)pci.attribute_value("vendor_id", 0U);
|
||||
uint16_t const class_code = (uint16_t)(pci.attribute_value("class", 0U) >> 8);
|
||||
|
||||
enum {
|
||||
VENDOR_INTEL = 0x8086U,
|
||||
CLASS_AHCI = 0x106U,
|
||||
CLASS_NVME = 0x108U,
|
||||
};
|
||||
|
||||
if (vendor_id == VENDOR_INTEL && class_code == CLASS_AHCI)
|
||||
has_ahci = true;
|
||||
|
||||
if (class_code == CLASS_NVME)
|
||||
has_nvme = true;
|
||||
});
|
||||
});
|
||||
|
||||
if (!_nvme_driver.constructed() && has_nvme) {
|
||||
_nvme_driver.construct();
|
||||
_generate_init_config(_init_config);
|
||||
}
|
||||
|
||||
_devices_rom_parsed = true;
|
||||
}
|
||||
|
||||
|
||||
void Driver_manager::Main::_handle_nvme_ns_update()
|
||||
{
|
||||
_nvme_ns.update();
|
||||
_generate_block_devices();
|
||||
|
||||
/* update service forwarding rules */
|
||||
_generate_init_config(_init_config);
|
||||
}
|
||||
|
||||
|
||||
void Driver_manager::Main::_generate_init_config(Reporter &init_config) const
|
||||
{
|
||||
Reporter::Xml_generator xml(init_config, [&] () {
|
||||
|
||||
xml.attribute("verbose", false);
|
||||
xml.attribute("prio_levels", 2);
|
||||
|
||||
xml.node("report", [&] () {
|
||||
xml.attribute("child_ram", true);
|
||||
xml.attribute("delay_ms", 2500);
|
||||
});
|
||||
|
||||
xml.node("heartbeat", [&] () { xml.attribute("rate_ms", 2500); });
|
||||
|
||||
xml.node("parent-provides", [&] () {
|
||||
_gen_parent_service_xml(xml, Rom_session::service_name());
|
||||
_gen_parent_service_xml(xml, Io_mem_session::service_name());
|
||||
_gen_parent_service_xml(xml, Io_port_session::service_name());
|
||||
_gen_parent_service_xml(xml, Cpu_session::service_name());
|
||||
_gen_parent_service_xml(xml, Pd_session::service_name());
|
||||
_gen_parent_service_xml(xml, Rm_session::service_name());
|
||||
_gen_parent_service_xml(xml, Log_session::service_name());
|
||||
_gen_parent_service_xml(xml, Timer::Session::service_name());
|
||||
_gen_parent_service_xml(xml, Platform::Session::service_name());
|
||||
_gen_parent_service_xml(xml, Report::Session::service_name());
|
||||
_gen_parent_service_xml(xml, Capture::Session::service_name());
|
||||
});
|
||||
|
||||
if (_nvme_driver.constructed())
|
||||
_nvme_driver->generate_start_node(xml);
|
||||
|
||||
/* block-service forwarding rules */
|
||||
bool const nvme = _nvme_driver.constructed() && _nvme_ns.xml().has_sub_node("namespace");
|
||||
|
||||
if (!nvme) return;
|
||||
|
||||
xml.node("service", [&] () {
|
||||
xml.attribute("name", Block::Session::service_name());
|
||||
if (nvme)
|
||||
_nvme_driver->gen_service_forwarding_policy(xml, "nvme-0");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void Driver_manager::Main::_generate_block_devices(Reporter &block_devices) const
|
||||
{
|
||||
Reporter::Xml_generator xml(block_devices, [&] () {
|
||||
|
||||
/* for now just report the first name space */
|
||||
if (_nvme_ns.xml().has_sub_node("namespace")) {
|
||||
|
||||
Xml_node nvme_ctrl = _nvme_ns.xml();
|
||||
Xml_node nvme_ns = _nvme_ns.xml().sub_node("namespace");
|
||||
xml.node("device", [&] () {
|
||||
|
||||
unsigned long const
|
||||
block_count = nvme_ns.attribute_value("block_count", 0UL),
|
||||
block_size = nvme_ns.attribute_value("block_size", 0UL);
|
||||
|
||||
typedef String<40+1> Model;
|
||||
Model const model = nvme_ctrl.attribute_value("model", Model());
|
||||
typedef String<20+1> Serial;
|
||||
Serial const serial = nvme_ctrl.attribute_value("serial", Serial());
|
||||
|
||||
xml.attribute("label", String<16>("nvme-0"));
|
||||
xml.attribute("block_count", block_count);
|
||||
xml.attribute("block_size", block_size);
|
||||
xml.attribute("model", model);
|
||||
xml.attribute("serial", serial);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env) { static Driver_manager::Main main(env); }
|
@ -1,5 +0,0 @@
|
||||
TARGET = driver_manager
|
||||
SRC_CC = main.cc
|
||||
LIBS += base
|
||||
|
||||
REQUIRES = x86
|
@ -1,138 +0,0 @@
|
||||
/*
|
||||
* \brief Test for validating the device detection of the driver manager
|
||||
* \author Norman Feske
|
||||
* \date 2017-06-30
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/component.h>
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <base/allocator_avl.h>
|
||||
#include <base/heap.h>
|
||||
#include <block_session/connection.h>
|
||||
|
||||
namespace Test {
|
||||
using namespace Genode;
|
||||
struct Main;
|
||||
}
|
||||
|
||||
|
||||
struct Test::Main
|
||||
{
|
||||
Env &_env;
|
||||
|
||||
Attached_rom_dataspace _config { _env, "config" };
|
||||
Attached_rom_dataspace _block_devices { _env, "block_devices" };
|
||||
Attached_rom_dataspace _displays { _env, "displays" };
|
||||
|
||||
static bool _attribute_matches(char const *attr, Xml_node expected, Xml_node checked)
|
||||
{
|
||||
typedef String<80> Value;
|
||||
return !expected.has_attribute(attr)
|
||||
|| (expected.attribute_value(attr, Value()) ==
|
||||
checked .attribute_value(attr, Value()));
|
||||
}
|
||||
|
||||
static bool _block_device_matches(Xml_node expect, Xml_node device)
|
||||
{
|
||||
return _attribute_matches("label", expect, device)
|
||||
&& _attribute_matches("block_size", expect, device)
|
||||
&& _attribute_matches("block_count", expect, device);
|
||||
}
|
||||
|
||||
static bool _usb_block_device_matches(Xml_node expect, Xml_node device)
|
||||
{
|
||||
return _block_device_matches(expect, device)
|
||||
&& _attribute_matches("vendor", expect, device)
|
||||
&& _attribute_matches("product", expect, device);
|
||||
}
|
||||
|
||||
static bool _ahci_block_device_matches(Xml_node expect, Xml_node device)
|
||||
{
|
||||
return _block_device_matches(expect, device)
|
||||
&& _attribute_matches("model", expect, device)
|
||||
&& _attribute_matches("serial", expect, device);
|
||||
}
|
||||
|
||||
void _check_conditions()
|
||||
{
|
||||
_block_devices.update();
|
||||
|
||||
bool expected_devices_present = true;
|
||||
|
||||
log("-- check presence of expected block devices --");
|
||||
|
||||
_config.xml().for_each_sub_node([&] (Xml_node expect) {
|
||||
|
||||
/* skip nodes that are unrelated to block devices */
|
||||
if (expect.type() != "check_usb_block_device"
|
||||
&& expect.type() != "check_ahci_block_device")
|
||||
return;
|
||||
|
||||
bool device_exists = false;
|
||||
|
||||
_block_devices.xml().for_each_sub_node("device", [&] (Xml_node device) {
|
||||
|
||||
if (expect.type() == "check_usb_block_device"
|
||||
&& _usb_block_device_matches(expect, device))
|
||||
device_exists = true;
|
||||
|
||||
if (expect.type() == "check_ahci_block_device"
|
||||
&& _ahci_block_device_matches(expect, device))
|
||||
device_exists = true;
|
||||
});
|
||||
|
||||
log("block device '", expect.attribute_value("label", String<80>()), "' ",
|
||||
device_exists ? "present" : "not present");
|
||||
|
||||
if (!device_exists)
|
||||
expected_devices_present = false;
|
||||
});
|
||||
|
||||
if (!expected_devices_present)
|
||||
return;
|
||||
|
||||
/* attempt to create a session to each block device */
|
||||
_block_devices.xml().for_each_sub_node("device", [&] (Xml_node device) {
|
||||
|
||||
typedef String<64> Label;
|
||||
Label label = device.attribute_value("label", Label());
|
||||
|
||||
log("connect to block device '", label, "'");
|
||||
|
||||
Heap heap(_env.ram(), _env.rm());
|
||||
Allocator_avl packet_alloc(&heap);
|
||||
Block::Connection<> block(_env, &packet_alloc, 128*1024, label.string());
|
||||
});
|
||||
|
||||
if (_config.xml().has_sub_node("check_displays")) {
|
||||
_displays.update();
|
||||
if (!_displays.xml().has_sub_node("display"))
|
||||
return;
|
||||
|
||||
log("available displays: ", _displays.xml());
|
||||
}
|
||||
|
||||
log("all expected devices present and accessible");
|
||||
}
|
||||
|
||||
Signal_handler<Main> _block_devices_update_handler {
|
||||
_env.ep(), *this, &Main::_check_conditions };
|
||||
|
||||
Main(Env &env) : _env(env)
|
||||
{
|
||||
_block_devices.sigh(_block_devices_update_handler);
|
||||
_check_conditions();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env) { static Test::Main main(env); }
|
||||
|
@ -1,3 +0,0 @@
|
||||
TARGET = test-driver_manager
|
||||
SRC_CC = main.cc
|
||||
LIBS += base
|
Loading…
x
Reference in New Issue
Block a user