mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-08 11:55:24 +00:00
sculpt: host PC USB driver in runtime
This commit moves the USB and USB HID driver from the drivers subsystem into the runtime. The former special USB node of the graph corresponds now to the USB host-controller driver (named "usb"). The management options for USB storage devices are available inside this component node now. Issue #5150
This commit is contained in:
parent
3580bb6e17
commit
556a7b8b17
@ -186,6 +186,27 @@ proc nic_driver_routes { } {
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# ROM routes that relabel generic USB driver names to board-specific binaries
|
||||
#
|
||||
proc usb_driver_routes { } {
|
||||
|
||||
set result(pc) {
|
||||
<service name="ROM" label="usb_drv"> <parent label="pc_usb_host_drv"/> </service>
|
||||
}
|
||||
|
||||
set result(pinephone) {
|
||||
<service name="ROM" label="usb_drv"> <parent label="a64_usb_host_drv"/> </service>
|
||||
<service name="ROM" label="usb_drv.dtb"> <parent label="usb-pinephone.dtb"/> </service>
|
||||
}
|
||||
|
||||
if {[info exists result([board])]} {
|
||||
return $result([board]); }
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
proc log_core_start_node { } {
|
||||
|
||||
if {[have_board linux]} return
|
||||
@ -690,7 +711,7 @@ install_config {
|
||||
<child name="leitzentrale" label="fonts"/> </service>
|
||||
<service name="Report"> <child name="fs_report"/> </service>
|
||||
<service name="LOG" label="unlogged"> <parent/> </service>
|
||||
} [log_route] [nic_driver_routes] {
|
||||
} [log_route] [nic_driver_routes] [usb_driver_routes] {
|
||||
<service name="Event" label="leitzentrale"> <child name="leitzentrale"/> </service>
|
||||
<service name="Event"> <child name="event_filter"/> </service>
|
||||
<service name="Capture" label="global"> <child name="nitpicker"/> </service>
|
||||
|
@ -26,9 +26,6 @@
|
||||
<service name="Block">
|
||||
<default-policy> <child name="dynamic"/> </default-policy> </service>
|
||||
|
||||
<service name="Usb">
|
||||
<default-policy> <child name="usb_drv"/> </default-policy> </service>
|
||||
|
||||
<service name="Platform">
|
||||
<default-policy> <child name="platform_drv"/> </default-policy> </service>
|
||||
|
||||
@ -42,19 +39,15 @@
|
||||
<policy label="pci_decode -> system" report="acpi_drv -> acpi"/>
|
||||
<policy label="platform_drv -> acpi" report="acpi_drv -> acpi"/>
|
||||
<policy label="platform_drv -> devices" report="pci_decode -> devices"/>
|
||||
<policy label="usb_drv -> config" report="driver_manager -> usb_drv.config"/>
|
||||
<policy label="dynamic -> config" report="driver_manager -> init.config"/>
|
||||
<policy label="driver_manager -> devices" report="platform_drv -> devices"/>
|
||||
<policy label="driver_manager -> usb_devices" report="usb_drv -> devices"/>
|
||||
<policy label="driver_manager -> dynamic_state" report="dynamic -> state"/>
|
||||
<policy label="driver_manager -> ahci_ports" report="dynamic -> ahci_ports"/>
|
||||
<policy label="driver_manager -> nvme_ns" report="dynamic -> nvme_ns"/>
|
||||
<policy label="rom_reporter -> acpi" report="acpi_drv -> acpi"/>
|
||||
<policy label="rom_reporter -> devices" report="platform_drv -> devices"/>
|
||||
<policy label="rom_reporter -> pci_devices" report="pci_decode -> devices"/>
|
||||
<policy label="rom_reporter -> usb_devices" report="usb_drv -> devices"/>
|
||||
<policy label="rom_reporter -> dynamic_state" report="dynamic -> state"/>
|
||||
<policy label="usb_hid_drv -> report" report="usb_drv -> devices"/>
|
||||
</config>
|
||||
</start>
|
||||
|
||||
@ -64,19 +57,16 @@
|
||||
<rom label="acpi"/>
|
||||
<rom label="pci_devices"/>
|
||||
<rom label="devices"/>
|
||||
<rom label="usb_devices"/>
|
||||
<rom label="dynamic_state"/>
|
||||
</config>
|
||||
<route>
|
||||
<service name="ROM" label="acpi"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="pci_devices"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="devices"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="usb_devices"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="dynamic_state"> <child name="report_rom"/> </service>
|
||||
<service name="Report" label="acpi"> <parent label="acpi"/> </service>
|
||||
<service name="Report" label="pci_devices"> <parent label="pci_devices"/> </service>
|
||||
<service name="Report" label="devices"> <parent label="devices"/> </service>
|
||||
<service name="Report" label="usb_devices"> <parent label="usb_devices"/> </service>
|
||||
<service name="Report" label="dynamic_state"> <parent label="dynamic -> state"/> </service>
|
||||
<service name="LOG"> <parent/> </service>
|
||||
<service name="PD"> <parent/> </service>
|
||||
@ -139,7 +129,7 @@
|
||||
<policy label_prefix="runtime -> vesa_fb" info="yes"> <pci class="VGA"/> </policy>
|
||||
<policy label_prefix="dynamic -> ahci_drv"> <pci class="AHCI"/> </policy>
|
||||
<policy label_prefix="dynamic -> nvme_drv" info="yes"> <pci class="NVME"/> </policy>
|
||||
<policy label_prefix="usb_drv" info="yes"> <pci class="USB"/> </policy>
|
||||
<policy label_prefix="runtime -> usb" info="yes"> <pci class="USB"/> </policy>
|
||||
<policy label_prefix="runtime -> intel_gpu" info="yes">
|
||||
<pci class="VGA"/>
|
||||
<pci class="ISABRIDGE"/>
|
||||
@ -151,43 +141,6 @@
|
||||
</config>
|
||||
</start>
|
||||
|
||||
<start name="usb_drv" caps="200">
|
||||
<binary name="pc_usb_host_drv"/>
|
||||
<resource name="RAM" quantum="16M"/>
|
||||
<provides> <service name="Usb"/> </provides>
|
||||
<route>
|
||||
<service name="Platform"> <child name="platform_drv"/> </service>
|
||||
<service name="ROM" label="config">
|
||||
<child name="report_rom"/> </service>
|
||||
<service name="Report" label="devices"> <child name="report_rom"/> </service>
|
||||
<service name="Report" label="config"> <parent label="usb_active_config"/> </service>
|
||||
<service name="ROM"> <parent/> </service>
|
||||
<service name="PD"> <parent/> </service>
|
||||
<service name="RM"> <parent/> </service>
|
||||
<service name="CPU"> <parent/> </service>
|
||||
<service name="LOG"> <parent/> </service>
|
||||
<service name="Timer"> <parent/> </service>
|
||||
</route>
|
||||
</start>
|
||||
|
||||
<start name="usb_hid_drv" caps="180">
|
||||
<resource name="RAM" quantum="11M"/>
|
||||
<config capslock_led="rom" numlock_led="rom"/>
|
||||
<route>
|
||||
<service name="ROM" label="report"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="capslock"> <parent label="capslock"/> </service>
|
||||
<service name="ROM" label="numlock"> <parent label="numlock"/> </service>
|
||||
<service name="ROM"> <parent/> </service>
|
||||
<service name="PD"> <parent/> </service>
|
||||
<service name="RM"> <parent/> </service>
|
||||
<service name="CPU"> <parent/> </service>
|
||||
<service name="LOG"> <parent/> </service>
|
||||
<service name="Timer"> <parent/> </service>
|
||||
<service name="Event"> <parent label="usb"/> </service>
|
||||
<service name="Usb"> <child name="usb_drv"/> </service>
|
||||
</route>
|
||||
</start>
|
||||
|
||||
<start name="ps2_drv">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<config capslock_led="rom" numlock_led="rom" system="yes"/>
|
||||
@ -209,9 +162,7 @@
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<route>
|
||||
<service name="Report" label="init.config"> <child name="report_rom"/> </service>
|
||||
<service name="Report" label="usb_drv.config"> <child name="report_rom"/> </service>
|
||||
<service name="Report" label="block_devices"> <parent label="block_devices"/> </service>
|
||||
<service name="ROM" label="usb_devices"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="devices"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="ahci_ports"> <child name="report_rom"/> </service>
|
||||
<service name="ROM" label="nvme_ns"> <child name="report_rom"/> </service>
|
||||
@ -237,7 +188,6 @@
|
||||
<service name="Report" label="nvme_ns"> <child name="report_rom"/> </service>
|
||||
<service name="Report" label="state"> <child name="report_rom"/> </service>
|
||||
<service name="Report"> <parent/> </service>
|
||||
<service name="Usb"> <child name="usb_drv"/> </service>
|
||||
<service name="ROM" label="config"> <child name="report_rom"/> </service>
|
||||
<service name="LOG"> <parent/> </service>
|
||||
<service name="PD"> <parent/> </service>
|
||||
|
@ -8,8 +8,8 @@
|
||||
<input name="sdl"/>
|
||||
</merge>
|
||||
</output>
|
||||
<policy label="drivers -> ps2" input="ps2"/>
|
||||
<policy label="drivers -> usb" input="usb"/>
|
||||
<policy label="drivers -> touch" input="touch"/>
|
||||
<policy label="drivers -> sdl" input="sdl"/>
|
||||
<policy label="drivers -> ps2" input="ps2"/>
|
||||
<policy label="runtime -> usb_hid" input="usb"/>
|
||||
<policy label="drivers -> touch" input="touch"/>
|
||||
<policy label="drivers -> sdl" input="sdl"/>
|
||||
</config>
|
||||
|
@ -36,5 +36,5 @@
|
||||
</chargen>
|
||||
</output>
|
||||
<policy label="drivers -> ps2" input="ps2"/>
|
||||
<policy label="drivers -> usb_hid" input="usb"/>
|
||||
<policy label="runtime -> usb_hid" input="usb"/>
|
||||
</config>
|
||||
|
@ -242,6 +242,8 @@
|
||||
<child name="config_fs_report" label="managed -> nic_router"/> </service>
|
||||
<service name="Report" label="fb_drv_config">
|
||||
<child name="config_fs_report" label="managed -> fb_drv"/> </service>
|
||||
<service name="Report" label="usb_config">
|
||||
<child name="config_fs_report" label="managed -> usb"/> </service>
|
||||
<service name="Report" label="system_config">
|
||||
<child name="config_fs_report" label="managed -> system"/> </service>
|
||||
<service name="Report" label="event_filter_config">
|
||||
|
@ -136,6 +136,8 @@
|
||||
<child name="config_fs_report" label="managed -> audio"/> </service>
|
||||
<service name="Report" label="nic_router_config">
|
||||
<child name="config_fs_report" label="managed -> nic_router"/> </service>
|
||||
<service name="Report" label="usb_config">
|
||||
<child name="config_fs_report" label="managed -> usb"/> </service>
|
||||
<service name="Report" label="installation_config">
|
||||
<child name="config_fs_report" label="managed -> installation"/> </service>
|
||||
<service name="Report" label="depot_query">
|
||||
|
@ -1,13 +1,2 @@
|
||||
<!--
|
||||
Manually maintained rules for assigning USB devices to clients.
|
||||
|
||||
The content is indented with two tabs because it is incorporated as is
|
||||
into the <raw> sub node of the the USB driver configuration.
|
||||
-->
|
||||
|
||||
<usb>
|
||||
|
||||
<!-- rule for flashing the ergodox firmware
|
||||
<policy label_suffix="teensy" vendor_id="0x16c0" product_id="0x0478"/>
|
||||
-->
|
||||
</usb>
|
||||
<config bios_handoff="no">
|
||||
</config>
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <io_port_session/io_port_session.h>
|
||||
#include <timer_session/timer_session.h>
|
||||
#include <log_session/log_session.h>
|
||||
#include <usb_session/usb_session.h>
|
||||
#include <platform_session/platform_session.h>
|
||||
|
||||
namespace Driver_manager {
|
||||
@ -227,14 +226,11 @@ struct Driver_manager::Main
|
||||
Env &_env;
|
||||
|
||||
Attached_rom_dataspace _platform { _env, "platform_info" };
|
||||
Attached_rom_dataspace _usb_devices { _env, "usb_devices" };
|
||||
Attached_rom_dataspace _usb_policy { _env, "usb_policy" };
|
||||
Attached_rom_dataspace _devices { _env, "devices" };
|
||||
Attached_rom_dataspace _ahci_ports { _env, "ahci_ports" };
|
||||
Attached_rom_dataspace _nvme_ns { _env, "nvme_ns" };
|
||||
|
||||
Reporter _init_config { _env, "config", "init.config" };
|
||||
Reporter _usb_drv_config { _env, "config", "usb_drv.config" };
|
||||
Reporter _block_devices { _env, "block_devices" };
|
||||
|
||||
Constructible<Ahci_driver> _ahci_driver { };
|
||||
@ -247,14 +243,6 @@ struct Driver_manager::Main
|
||||
Signal_handler<Main> _devices_update_handler {
|
||||
_env.ep(), *this, &Main::_handle_devices_update };
|
||||
|
||||
void _handle_usb_devices_update();
|
||||
|
||||
Signal_handler<Main> _usb_devices_update_handler {
|
||||
_env.ep(), *this, &Main::_handle_usb_devices_update };
|
||||
|
||||
Signal_handler<Main> _usb_policy_update_handler {
|
||||
_env.ep(), *this, &Main::_handle_usb_devices_update };
|
||||
|
||||
void _handle_ahci_ports_update();
|
||||
|
||||
Signal_handler<Main> _ahci_ports_update_handler {
|
||||
@ -270,9 +258,8 @@ struct Driver_manager::Main
|
||||
xml.node("service", [&] () { xml.attribute("name", name); });
|
||||
};
|
||||
|
||||
void _generate_init_config (Reporter &) const;
|
||||
void _generate_usb_drv_config (Reporter &, Xml_node, Xml_node) const;
|
||||
void _generate_block_devices (Reporter &) const;
|
||||
void _generate_init_config (Reporter &) const;
|
||||
void _generate_block_devices(Reporter &) const;
|
||||
|
||||
Ahci_driver::Default_label _default_block_device() const;
|
||||
|
||||
@ -294,11 +281,9 @@ struct Driver_manager::Main
|
||||
Main(Env &env) : _env(env)
|
||||
{
|
||||
_init_config.enabled(true);
|
||||
_usb_drv_config.enabled(true);
|
||||
_block_devices.enabled(true);
|
||||
|
||||
_devices .sigh(_devices_update_handler);
|
||||
_usb_policy.sigh(_usb_policy_update_handler);
|
||||
_ahci_ports.sigh(_ahci_ports_update_handler);
|
||||
_nvme_ns .sigh(_nvme_ns_update_handler);
|
||||
|
||||
@ -351,15 +336,6 @@ void Driver_manager::Main::_handle_devices_update()
|
||||
_generate_init_config(_init_config);
|
||||
}
|
||||
|
||||
/* generate initial usb driver config not before we know whether ohci should be enabled */
|
||||
_generate_usb_drv_config(_usb_drv_config,
|
||||
Xml_node("<devices/>"),
|
||||
Xml_node("<usb/>"));
|
||||
|
||||
_usb_devices.sigh(_usb_devices_update_handler);
|
||||
|
||||
_handle_usb_devices_update();
|
||||
|
||||
_devices_rom_parsed = true;
|
||||
}
|
||||
|
||||
@ -384,15 +360,6 @@ void Driver_manager::Main::_handle_nvme_ns_update()
|
||||
}
|
||||
|
||||
|
||||
void Driver_manager::Main::_handle_usb_devices_update()
|
||||
{
|
||||
_usb_devices.update();
|
||||
_usb_policy.update();
|
||||
|
||||
_generate_usb_drv_config(_usb_drv_config, _usb_devices.xml(), _usb_policy.xml());
|
||||
}
|
||||
|
||||
|
||||
void Driver_manager::Main::_generate_init_config(Reporter &init_config) const
|
||||
{
|
||||
Reporter::Xml_generator xml(init_config, [&] () {
|
||||
@ -418,7 +385,6 @@ void Driver_manager::Main::_generate_init_config(Reporter &init_config) const
|
||||
_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, Usb::Session::service_name());
|
||||
_gen_parent_service_xml(xml, Capture::Session::service_name());
|
||||
});
|
||||
|
||||
@ -524,65 +490,4 @@ void Driver_manager::Main::_generate_block_devices(Reporter &block_devices) cons
|
||||
}
|
||||
|
||||
|
||||
void Driver_manager::Main::_generate_usb_drv_config(Reporter &usb_drv_config,
|
||||
Xml_node devices,
|
||||
Xml_node policy) const
|
||||
{
|
||||
Reporter::Xml_generator xml(usb_drv_config, [&] () {
|
||||
|
||||
xml.attribute("bios_handoff", false);
|
||||
|
||||
xml.node("report", [&] () {
|
||||
xml.attribute("config", true);
|
||||
xml.attribute("devices", true);
|
||||
});
|
||||
|
||||
/* incorporate user-managed policy */
|
||||
policy.with_raw_content([&] (char const *start, size_t length) {
|
||||
xml.append(start, length); });
|
||||
|
||||
/* usb hid drv gets all hid devices */
|
||||
xml.node("policy", [&] () {
|
||||
xml.attribute("label_prefix", "usb_hid_drv");
|
||||
xml.node("device", [&] () {
|
||||
xml.attribute("class", "0x3");
|
||||
});
|
||||
});
|
||||
|
||||
/* produce policy nodes for all storage devices */
|
||||
devices.for_each_sub_node("device", [&] (Xml_node device) {
|
||||
|
||||
bool usb_storage = false;
|
||||
device.for_each_sub_node("config", [&] (Xml_node cfg) {
|
||||
|
||||
cfg.for_each_sub_node("interface", [&] (Xml_node iface) {
|
||||
|
||||
enum { USB_CLASS_MASS_STORAGE = 8 };
|
||||
|
||||
if (iface.attribute_value("class", 0UL) ==
|
||||
USB_CLASS_MASS_STORAGE)
|
||||
usb_storage = true;
|
||||
});
|
||||
});
|
||||
|
||||
if (!usb_storage)
|
||||
return;
|
||||
|
||||
using Name = String<64>;
|
||||
|
||||
Name const name = device.attribute_value("name", Name());
|
||||
|
||||
xml.node("policy", [&] () {
|
||||
|
||||
xml.attribute("label_suffix", name);
|
||||
xml.attribute("class", "storage");
|
||||
xml.node("device", [&] () {
|
||||
xml.attribute("name", name);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env) { static Driver_manager::Main main(env); }
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <model/screensaver.h>
|
||||
#include <managed_config.h>
|
||||
#include <fb_driver.h>
|
||||
#include <usb_driver.h>
|
||||
#include <gui.h>
|
||||
#include <storage.h>
|
||||
#include <network.h>
|
||||
@ -80,11 +81,13 @@ struct Sculpt::Main : Input_event_handler,
|
||||
Pin_widget::Action,
|
||||
Dialpad_widget::Action,
|
||||
Current_call_widget::Action,
|
||||
Network_widget::Action,
|
||||
Software_presets_widget::Action,
|
||||
Software_options_widget::Action,
|
||||
Software_update_widget::Action,
|
||||
Software_add_widget::Action,
|
||||
Screensaver::Action
|
||||
Screensaver::Action,
|
||||
Usb_driver::Action
|
||||
{
|
||||
Env &_env;
|
||||
|
||||
@ -119,36 +122,11 @@ struct Sculpt::Main : Input_event_handler,
|
||||
** Device management **
|
||||
***********************/
|
||||
|
||||
Attached_rom_dataspace const _platform { _env, "platform_info" };
|
||||
|
||||
Attached_rom_dataspace _devices { _env, "report -> drivers/devices" };
|
||||
|
||||
Signal_handler<Main> _devices_handler {
|
||||
_env.ep(), *this, &Main::_handle_devices };
|
||||
|
||||
Board_info _board_info { };
|
||||
|
||||
void _handle_devices()
|
||||
{
|
||||
_devices.update();
|
||||
|
||||
_board_info = Board_info::from_xml(_devices.xml(), _platform.xml());
|
||||
|
||||
/* enable non-PCI wifi (PinePhone) */
|
||||
if (_devices.xml().num_sub_nodes() == 0)
|
||||
_board_info.wifi_present = true;
|
||||
|
||||
_fb_driver.update(_child_states, _board_info, _platform.xml());
|
||||
|
||||
update_network_dialog();
|
||||
}
|
||||
|
||||
Managed_config<Main> _system_config {
|
||||
_env, "system", "system", *this, &Main::_handle_system_config };
|
||||
|
||||
struct System
|
||||
{
|
||||
bool usb;
|
||||
bool storage;
|
||||
|
||||
using State = String<32>;
|
||||
@ -166,7 +144,6 @@ struct Sculpt::Main : Input_event_handler,
|
||||
static System from_xml(Xml_node const &node)
|
||||
{
|
||||
return System {
|
||||
.usb = node.attribute_value("usb", false),
|
||||
.storage = node.attribute_value("storage", false),
|
||||
.state = node.attribute_value("state", State()),
|
||||
.power_profile = node.attribute_value("power_profile", Power_profile()),
|
||||
@ -177,7 +154,6 @@ struct Sculpt::Main : Input_event_handler,
|
||||
|
||||
void generate(Xml_generator &xml) const
|
||||
{
|
||||
if (usb) xml.attribute("usb", "yes");
|
||||
if (storage) xml.attribute("storage", "yes");
|
||||
|
||||
if (state.length() > 1)
|
||||
@ -196,8 +172,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
|
||||
bool operator != (System const &other) const
|
||||
{
|
||||
return (other.usb != usb)
|
||||
|| (other.storage != storage)
|
||||
return (other.storage != storage)
|
||||
|| (other.state != state)
|
||||
|| (other.power_profile != power_profile)
|
||||
|| (other.brightness != brightness)
|
||||
@ -218,6 +193,33 @@ struct Sculpt::Main : Input_event_handler,
|
||||
_update_managed_system_config();
|
||||
}
|
||||
|
||||
Attached_rom_dataspace const _platform { _env, "platform_info" };
|
||||
|
||||
Attached_rom_dataspace _devices { _env, "report -> drivers/devices" };
|
||||
|
||||
Signal_handler<Main> _devices_handler {
|
||||
_env.ep(), *this, &Main::_handle_devices };
|
||||
|
||||
Board_info _board_info { };
|
||||
|
||||
void _handle_devices()
|
||||
{
|
||||
_devices.update();
|
||||
|
||||
_board_info = Board_info::from_xml(_devices.xml(), _platform.xml());
|
||||
|
||||
/* enable non-PCI wifi (PinePhone) */
|
||||
if (_devices.xml().num_sub_nodes() == 0)
|
||||
_board_info.wifi_present = true;
|
||||
|
||||
_board_info.usb_present = true;
|
||||
|
||||
_fb_driver.update(_child_states, _board_info, _platform.xml());
|
||||
_update_usb_drivers();
|
||||
|
||||
update_network_dialog();
|
||||
}
|
||||
|
||||
void _enter_second_driver_stage()
|
||||
{
|
||||
/*
|
||||
@ -226,12 +228,11 @@ struct Sculpt::Main : Input_event_handler,
|
||||
* is up, we can kick off the start of the remaining drivers.
|
||||
*/
|
||||
|
||||
if (_system.usb && _system.storage)
|
||||
if (_system.storage)
|
||||
return;
|
||||
|
||||
System const orig_system = _system;
|
||||
|
||||
_system.usb = true;
|
||||
_system.storage = true;
|
||||
|
||||
if (_system != orig_system)
|
||||
@ -243,6 +244,16 @@ struct Sculpt::Main : Input_event_handler,
|
||||
Signal_handler<Main> _gui_mode_handler {
|
||||
_env.ep(), *this, &Main::_handle_gui_mode };
|
||||
|
||||
Usb_driver _usb_driver { _env, *this };
|
||||
|
||||
void _update_usb_drivers()
|
||||
{
|
||||
_usb_driver.update(_child_states, _board_info, {
|
||||
.hid = false,
|
||||
.net = (_network._nic_target.type() == Nic_target::MODEM)
|
||||
});
|
||||
}
|
||||
|
||||
void _handle_gui_mode();
|
||||
|
||||
bool _verbose_modem = false;
|
||||
@ -302,8 +313,44 @@ struct Sculpt::Main : Input_event_handler,
|
||||
return _prepare_version.value != _prepare_completed.value;
|
||||
}
|
||||
|
||||
|
||||
/*************
|
||||
** Storage **
|
||||
*************/
|
||||
|
||||
Attached_rom_dataspace _block_devices_rom { _env, "report -> drivers/block_devices" };
|
||||
|
||||
Signal_handler<Main> _block_devices_handler {
|
||||
_env.ep(), *this, &Main::_handle_block_devices };
|
||||
|
||||
void _handle_block_devices()
|
||||
{
|
||||
_block_devices_rom.update();
|
||||
_usb_driver.with_devices([&] (Xml_node const &usb_devices) {
|
||||
_storage.update(usb_devices,
|
||||
_block_devices_rom.xml(),
|
||||
_block_devices_handler);
|
||||
});
|
||||
|
||||
/* update USB policies for storage devices */
|
||||
_update_usb_drivers();
|
||||
}
|
||||
|
||||
Storage _storage { _env, _heap, _child_states, *this, *this };
|
||||
|
||||
/**
|
||||
* Usb_driver::Action
|
||||
*/
|
||||
void handle_usb_plug_unplug() override { _handle_block_devices(); }
|
||||
|
||||
/**
|
||||
* Usb_driver::Action
|
||||
*/
|
||||
void gen_usb_storage_policies(Xml_generator &xml) const override
|
||||
{
|
||||
_storage.gen_usb_storage_policies(xml);
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage::Action interface
|
||||
*/
|
||||
@ -324,6 +371,11 @@ struct Sculpt::Main : Input_event_handler,
|
||||
*/
|
||||
void refresh_storage_dialog() override { _generate_dialog(); }
|
||||
|
||||
|
||||
/*************
|
||||
** Network **
|
||||
*************/
|
||||
|
||||
Network _network { _env, _heap, *this, *this, _child_states, *this, _runtime_state };
|
||||
|
||||
/**
|
||||
@ -345,6 +397,31 @@ struct Sculpt::Main : Input_event_handler,
|
||||
return _network_widget.hosted.ap_list_hovered(at); }); }); });
|
||||
}
|
||||
|
||||
/**
|
||||
* Network_widget::Action
|
||||
*/
|
||||
void nic_target(Nic_target::Type const type) override
|
||||
{
|
||||
_network.nic_target(type);
|
||||
|
||||
/* start/stop USB net driver */
|
||||
_update_usb_drivers();
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
/**
|
||||
* Network_widget::Action
|
||||
*/
|
||||
void wifi_connect(Access_point::Bssid bssid) override
|
||||
{
|
||||
_network.wifi_connect(bssid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Network_widget::Action
|
||||
*/
|
||||
void wifi_disconnect() override { _network.wifi_disconnect(); }
|
||||
|
||||
|
||||
/************
|
||||
** Update **
|
||||
@ -1173,7 +1250,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
_pin_widget .propagate(at, _sim_pin, *this);
|
||||
_dialpad_widget .propagate(at, *this);
|
||||
_storage_widget .propagate(at, *this);
|
||||
_network_widget .propagate(at, _network);
|
||||
_network_widget .propagate(at, *this);
|
||||
_software_presets_widget.propagate(at, _presets);
|
||||
_software_update_widget .propagate(at, *this);
|
||||
_software_add_widget .propagate(at, *this);
|
||||
@ -1356,11 +1433,6 @@ struct Sculpt::Main : Input_event_handler,
|
||||
_network.restart_wifi_drv_on_next_runtime_cfg();
|
||||
generate_runtime_config();
|
||||
|
||||
} else if (name == "usb_net") {
|
||||
|
||||
_network.restart_usb_net_on_next_runtime_cfg();
|
||||
generate_runtime_config();
|
||||
|
||||
} else {
|
||||
|
||||
_runtime_state.restart(name);
|
||||
@ -1975,8 +2047,8 @@ struct Sculpt::Main : Input_event_handler,
|
||||
_handle_config();
|
||||
_handle_leitzentrale();
|
||||
_handle_gui_mode();
|
||||
_storage.handle_storage_devices_update();
|
||||
_handle_devices();
|
||||
_handle_block_devices();
|
||||
_handle_runtime_config();
|
||||
_handle_modem_state();
|
||||
|
||||
@ -2387,6 +2459,9 @@ void Sculpt::Main::_generate_runtime_config(Xml_generator &xml) const
|
||||
|
||||
_fb_driver.gen_start_nodes(xml);
|
||||
|
||||
if (_network._nic_target.type() == Nic_target::Type::MODEM)
|
||||
_usb_driver.gen_start_nodes(xml);
|
||||
|
||||
_dialog_runtime.gen_start_nodes(xml);
|
||||
|
||||
_touch_keyboard.gen_start_node(xml);
|
||||
|
@ -112,6 +112,10 @@ void Graph::_view_selected_node_content(Scope<Depgraph, Frame, Vbox> &s,
|
||||
s.sub_scope<Min_ex>(25);
|
||||
s.sub_scope<Label>(ram);
|
||||
s.sub_scope<Label>(caps);
|
||||
|
||||
if ((name == "usb") && _storage_devices.usb_present)
|
||||
s.sub_scope<Frame>([&] (Scope<Depgraph, Frame, Vbox, Frame> &s) {
|
||||
s.widget(_usb_devices_widget); });
|
||||
}
|
||||
|
||||
|
||||
@ -134,25 +138,6 @@ void Graph::_view_storage_node(Scope<Depgraph> &s) const
|
||||
}
|
||||
|
||||
|
||||
void Graph::_view_usb_node(Scope<Depgraph> &s) const
|
||||
{
|
||||
bool const any_selected = _runtime_state.selected().valid();
|
||||
|
||||
Selectable_node::view(s, Id { "usb" },
|
||||
{
|
||||
.selected = _usb_selected,
|
||||
.important = !any_selected || _runtime_state.usb_in_tcb(),
|
||||
.primary_dep = { },
|
||||
.pretty_name = "USB"
|
||||
},
|
||||
[&] (Scope<Depgraph, Frame, Vbox> &s) {
|
||||
s.sub_scope<Frame>([&] (Scope<Depgraph, Frame, Vbox, Frame> &s) {
|
||||
s.widget(_usb_devices_widget); });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Graph::view(Scope<Depgraph> &s) const
|
||||
{
|
||||
if (Feature::PRESENT_PLUS_MENU && _sculpt_partition.valid())
|
||||
@ -163,14 +148,8 @@ void Graph::view(Scope<Depgraph> &s) const
|
||||
else
|
||||
s.sub_scope<Parent_node>(Id { "storage" }, "Storage");
|
||||
|
||||
if (_storage_devices.usb_present)
|
||||
_view_usb_node(s);
|
||||
else
|
||||
s.sub_scope<Parent_node>(Id { "usb" }, "USB");
|
||||
|
||||
/* parent roles */
|
||||
s.sub_scope<Parent_node>(Id { "hardware" }, "Hardware");
|
||||
s.sub_scope<Parent_node>(Id { "hardware" }, "Hardware");
|
||||
s.sub_scope<Parent_node>(Id { "config" }, "Config");
|
||||
s.sub_scope<Parent_node>(Id { "info" }, "Info");
|
||||
s.sub_scope<Parent_node>(Id { "GUI" }, "GUI");
|
||||
@ -281,9 +260,7 @@ void Graph::click(Clicked_at const &at, Action &action)
|
||||
Id const id = at.matching_id<Depgraph, Frame, Vbox, Button>();
|
||||
if (id.valid()) {
|
||||
_storage_selected = !_storage_selected && (id.value == "storage");
|
||||
_usb_selected = !_usb_selected && (id.value == "usb");
|
||||
|
||||
if (_usb_selected) _usb_devices_widget .reset();
|
||||
if (_storage_selected) _block_devices_widget.reset();
|
||||
|
||||
_runtime_config.with_start_name(id, [&] (Start_name const &name) {
|
||||
|
@ -63,14 +63,12 @@ struct Sculpt::Graph : Widget<Depgraph>
|
||||
_storage_devices, _sculpt_partition };
|
||||
|
||||
bool _storage_selected = false;
|
||||
bool _usb_selected = false;
|
||||
|
||||
void _view_selected_node_content(Scope<Depgraph, Frame, Vbox> &,
|
||||
Start_name const &,
|
||||
Runtime_state::Info const &) const;
|
||||
|
||||
void _view_storage_node(Scope<Depgraph> &) const;
|
||||
void _view_usb_node(Scope<Depgraph> &) const;
|
||||
|
||||
Graph(Runtime_state &runtime_state,
|
||||
Runtime_config const &runtime_config,
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <view/system_dialog.h>
|
||||
#include <view/file_browser_dialog.h>
|
||||
#include <fb_driver.h>
|
||||
#include <usb_driver.h>
|
||||
#include <gui.h>
|
||||
#include <keyboard_focus.h>
|
||||
#include <network.h>
|
||||
@ -64,6 +65,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
Graph::Action,
|
||||
Panel_dialog::Action,
|
||||
Popup_dialog::Action,
|
||||
Network_widget::Action,
|
||||
Settings_widget::Action,
|
||||
Software_presets_widget::Action,
|
||||
Software_update_widget::Action,
|
||||
@ -72,7 +74,8 @@ struct Sculpt::Main : Input_event_handler,
|
||||
Depot_query,
|
||||
Panel_dialog::State,
|
||||
Popup_dialog::Refresh,
|
||||
Screensaver::Action
|
||||
Screensaver::Action,
|
||||
Usb_driver::Action
|
||||
{
|
||||
Env &_env;
|
||||
|
||||
@ -213,8 +216,6 @@ struct Sculpt::Main : Input_event_handler,
|
||||
|
||||
Board_info _board_info { };
|
||||
|
||||
Fb_driver _fb_driver { };
|
||||
|
||||
void _handle_devices()
|
||||
{
|
||||
_devices.update();
|
||||
@ -222,8 +223,22 @@ struct Sculpt::Main : Input_event_handler,
|
||||
_board_info = Board_info::from_xml(_devices.xml(), _platform.xml());
|
||||
|
||||
_fb_driver.update(_child_states, _board_info, _platform.xml());
|
||||
_update_usb_drivers();
|
||||
|
||||
update_network_dialog();
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
Fb_driver _fb_driver { };
|
||||
|
||||
Usb_driver _usb_driver { _env, *this };
|
||||
|
||||
void _update_usb_drivers()
|
||||
{
|
||||
_usb_driver.update(_child_states, _board_info, {
|
||||
.hid = true,
|
||||
.net = (_network._nic_target.type() == Nic_target::MODEM)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -244,8 +259,39 @@ struct Sculpt::Main : Input_event_handler,
|
||||
** Storage **
|
||||
*************/
|
||||
|
||||
Attached_rom_dataspace _block_devices_rom { _env, "report -> drivers/block_devices" };
|
||||
|
||||
Signal_handler<Main> _block_devices_handler {
|
||||
_env.ep(), *this, &Main::_handle_block_devices };
|
||||
|
||||
void _handle_block_devices()
|
||||
{
|
||||
_block_devices_rom.update();
|
||||
_usb_driver.with_devices([&] (Xml_node const &usb_devices) {
|
||||
_storage.update(usb_devices,
|
||||
_block_devices_rom.xml(),
|
||||
_block_devices_handler);
|
||||
});
|
||||
|
||||
/* update USB policies for storage devices */
|
||||
_update_usb_drivers();
|
||||
}
|
||||
|
||||
Storage _storage { _env, _heap, _child_states, *this, *this };
|
||||
|
||||
/**
|
||||
* Usb_driver::Action
|
||||
*/
|
||||
void handle_usb_plug_unplug() override { _handle_block_devices(); }
|
||||
|
||||
/**
|
||||
* Usb_driver::Action
|
||||
*/
|
||||
void gen_usb_storage_policies(Xml_generator &xml) const override
|
||||
{
|
||||
_storage.gen_usb_storage_policies(xml);
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage::Action interface
|
||||
*/
|
||||
@ -275,6 +321,15 @@ struct Sculpt::Main : Input_event_handler,
|
||||
|
||||
Network _network { _env, _heap, *this, *this, _child_states, *this, _runtime_state };
|
||||
|
||||
/**
|
||||
* Network::Info interface
|
||||
*/
|
||||
bool ap_list_hovered() const override
|
||||
{
|
||||
return _network_dialog.if_hovered([&] (Hovered_at const &at) {
|
||||
return _network.dialog.ap_list_hovered(at); });
|
||||
}
|
||||
|
||||
struct Network_top_level_dialog : Top_level_dialog
|
||||
{
|
||||
Main &_main;
|
||||
@ -290,7 +345,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
|
||||
void click(Clicked_at const &at) override
|
||||
{
|
||||
_main._network.dialog.click(at, _main._network);
|
||||
_main._network.dialog.click(at, _main);
|
||||
}
|
||||
|
||||
void clack(Clacked_at const &) override { }
|
||||
@ -299,6 +354,31 @@ struct Sculpt::Main : Input_event_handler,
|
||||
|
||||
Dialog_view<Network_top_level_dialog> _network_dialog { _dialog_runtime, *this };
|
||||
|
||||
/**
|
||||
* Network_widget::Action
|
||||
*/
|
||||
void nic_target(Nic_target::Type const type) override
|
||||
{
|
||||
_network.nic_target(type);
|
||||
|
||||
/* start/stop USB net driver */
|
||||
_update_usb_drivers();
|
||||
generate_runtime_config();
|
||||
}
|
||||
|
||||
/**
|
||||
* Network_widget::Action
|
||||
*/
|
||||
void wifi_connect(Access_point::Bssid bssid) override
|
||||
{
|
||||
_network.wifi_connect(bssid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Network_widget::Action
|
||||
*/
|
||||
void wifi_disconnect() override { _network.wifi_disconnect(); }
|
||||
|
||||
/**
|
||||
* Network::Action interface
|
||||
*/
|
||||
@ -308,15 +388,6 @@ struct Sculpt::Main : Input_event_handler,
|
||||
_system_dialog.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Network::Info interface
|
||||
*/
|
||||
bool ap_list_hovered() const override
|
||||
{
|
||||
return _network_dialog.if_hovered([&] (Hovered_at const &at) {
|
||||
return _network.dialog.ap_list_hovered(at); });
|
||||
}
|
||||
|
||||
|
||||
/************
|
||||
** Update **
|
||||
@ -853,11 +924,6 @@ struct Sculpt::Main : Input_event_handler,
|
||||
_network.restart_wifi_drv_on_next_runtime_cfg();
|
||||
generate_runtime_config();
|
||||
|
||||
} else if (name == "usb_net") {
|
||||
|
||||
_network.restart_usb_net_on_next_runtime_cfg();
|
||||
generate_runtime_config();
|
||||
|
||||
} else {
|
||||
|
||||
_runtime_state.restart(name);
|
||||
@ -1374,7 +1440,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
|
||||
void view(Scope<> &s) const override
|
||||
{
|
||||
s.sub_scope<Depgraph>([&] (Scope<Depgraph> &s) {
|
||||
s.sub_scope<Depgraph>(Id { "graph" }, [&] (Scope<Depgraph> &s) {
|
||||
_main._graph.view(s); });
|
||||
}
|
||||
|
||||
@ -1410,6 +1476,7 @@ struct Sculpt::Main : Input_event_handler,
|
||||
_blueprint_rom .sigh(_blueprint_handler);
|
||||
_image_index_rom .sigh(_image_index_handler);
|
||||
_editor_saved_rom .sigh(_editor_saved_handler);
|
||||
_block_devices_rom .sigh(_block_devices_handler);
|
||||
|
||||
/*
|
||||
* Generate initial configurations
|
||||
@ -1421,8 +1488,8 @@ struct Sculpt::Main : Input_event_handler,
|
||||
* Import initial report content
|
||||
*/
|
||||
_handle_gui_mode();
|
||||
_storage.handle_storage_devices_update();
|
||||
_handle_devices();
|
||||
_handle_block_devices();
|
||||
_handle_runtime_config();
|
||||
|
||||
/*
|
||||
@ -1986,7 +2053,7 @@ void Sculpt::Main::_handle_runtime_state()
|
||||
reconfigure_runtime = true;
|
||||
|
||||
if (refresh_storage)
|
||||
_storage.handle_storage_devices_update();
|
||||
_handle_block_devices();
|
||||
|
||||
if (regenerate_dialog) {
|
||||
_generate_dialog();
|
||||
@ -2048,6 +2115,7 @@ void Sculpt::Main::_generate_runtime_config(Xml_generator &xml) const
|
||||
});
|
||||
|
||||
_fb_driver.gen_start_nodes(xml);
|
||||
_usb_driver.gen_start_nodes(xml);
|
||||
|
||||
_dialog_runtime.gen_start_nodes(xml);
|
||||
|
||||
@ -2194,10 +2262,10 @@ void Sculpt::Main::_generate_event_filter_config(Xml_generator &xml)
|
||||
xml.attribute("label", label);
|
||||
xml.attribute("input", input); }); };
|
||||
|
||||
gen_policy("drivers -> ps2", "ps2");
|
||||
gen_policy("drivers -> usb", "usb");
|
||||
gen_policy("drivers -> touch", "touch");
|
||||
gen_policy("drivers -> sdl", "sdl");
|
||||
gen_policy("drivers -> ps2", "ps2");
|
||||
gen_policy("runtime -> usb_hid", "usb");
|
||||
gen_policy("drivers -> touch", "touch");
|
||||
gen_policy("drivers -> sdl", "sdl");
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,6 +110,8 @@ struct Sculpt::Managed_config
|
||||
/* determine initial '_mode' */
|
||||
_update_manual_config_rom();
|
||||
}
|
||||
|
||||
void trigger_update() { _manual_config_handler.local_submit(); }
|
||||
};
|
||||
|
||||
#endif /* _MANAGED_CONFIG_H_ */
|
||||
|
@ -28,6 +28,7 @@ struct Sculpt::Board_info
|
||||
bool vesa_fb_present;
|
||||
bool nvme_present;
|
||||
bool ahci_present;
|
||||
bool usb_present;
|
||||
|
||||
static Board_info from_xml(Xml_node const &devices, Xml_node const &platform)
|
||||
{
|
||||
@ -47,6 +48,7 @@ struct Sculpt::Board_info
|
||||
VGA = 0x30000,
|
||||
AHCI = 0x10600,
|
||||
NVME = 0x10800,
|
||||
UHCI = 0xc0300, OHCI = 0xc0310, EHCI = 0xc0320, XHCI = 0xc0330,
|
||||
};
|
||||
|
||||
enum class Pci_vendor : unsigned { INTEL = 0x8086U, };
|
||||
@ -65,6 +67,10 @@ struct Sculpt::Board_info
|
||||
if (matches_class(Pci_class::LAN)) result.lan_present = true;
|
||||
if (matches_class(Pci_class::NVME)) result.nvme_present = true;
|
||||
|
||||
if (matches_class(Pci_class::UHCI) || matches_class(Pci_class::OHCI)
|
||||
|| matches_class(Pci_class::EHCI) || matches_class(Pci_class::XHCI))
|
||||
result.usb_present = true;
|
||||
|
||||
if (matches_class(Pci_class::AHCI) && matches_vendor(Pci_vendor::INTEL))
|
||||
result.ahci_present = true;
|
||||
|
||||
@ -94,7 +100,8 @@ struct Sculpt::Board_info
|
||||
" boot_fb=", boot_fb_present,
|
||||
" vesa_fb=", vesa_fb_present,
|
||||
" nvme=", nvme_present,
|
||||
" ahci=", ahci_present);
|
||||
" ahci=", ahci_present,
|
||||
" usb=", usb_present);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -76,9 +76,7 @@ class Sculpt::Runtime_config
|
||||
|| (service == "IO_MEM")
|
||||
|| (service == "Rtc")
|
||||
|| (service == "IRQ")
|
||||
|| (service == "TRACE")
|
||||
|| (service == "Event")
|
||||
|| (service == "Capture");
|
||||
|| (service == "TRACE");
|
||||
if (hardware) {
|
||||
result = "hardware";
|
||||
return;
|
||||
@ -130,7 +128,10 @@ class Sculpt::Runtime_config
|
||||
}
|
||||
}
|
||||
|
||||
if (service == "Gui") {
|
||||
bool const gui = (service == "Gui")
|
||||
|| (service == "Event")
|
||||
|| (service == "Capture");
|
||||
if (gui) {
|
||||
result = "GUI";
|
||||
return;
|
||||
}
|
||||
@ -317,7 +318,7 @@ class Sculpt::Runtime_config
|
||||
_nitpicker { _r, Type::GUI, "system GUI server" },
|
||||
_gpu { _r, Type::GPU, "GPU" },
|
||||
_lz_event { _r, Type::EVENT, "management GUI events", "leitzentrale" },
|
||||
_event { _r, Type::EVENT, "system input events", "global" },
|
||||
_event { _r, Type::EVENT, "filtered input events" },
|
||||
_lz_capture{ _r, Type::CAPTURE, "management GUI", "leitzentrale" },
|
||||
_capture { _r, Type::CAPTURE, "system GUI", "global" },
|
||||
_config_fs { _r, Type::FILE_SYSTEM, "writeable system configuration", "config" },
|
||||
@ -337,7 +338,6 @@ class Sculpt::Runtime_config
|
||||
_io_port { _r, Type::IO_PORT, "raw hardware access" },
|
||||
_irq { _r, Type::IRQ, "raw hardware access" },
|
||||
_block { _r, Type::BLOCK, "direct block-device access" },
|
||||
_usb { _r, Type::USB, "direct USB-device access" },
|
||||
_pci_wifi { _r, Type::PLATFORM, "wifi hardware", "wifi" },
|
||||
_pci_net { _r, Type::PLATFORM, "network hardware", "nic" },
|
||||
_pci_audio { _r, Type::PLATFORM, "audio hardware", "audio" },
|
||||
|
@ -81,7 +81,7 @@ struct Sculpt::Storage_devices
|
||||
|
||||
return *new (alloc)
|
||||
Usb_storage_device(env, alloc, sigh,
|
||||
node.attribute_value("label_suffix", Label()));
|
||||
node.attribute_value("name", Label()));
|
||||
},
|
||||
|
||||
/* destroy */
|
||||
@ -104,6 +104,12 @@ struct Sculpt::Storage_devices
|
||||
return device_added_or_vanished;
|
||||
}
|
||||
|
||||
void gen_usb_storage_policies(Xml_generator &xml) const
|
||||
{
|
||||
usb_storage_devices.for_each([&] (Usb_storage_device const &device) {
|
||||
device.gen_usb_policy(xml); });
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true as soon as the storage-device information from the drivers
|
||||
* subsystem is complete.
|
||||
|
@ -102,7 +102,7 @@ struct Sculpt::Usb_storage_device : List_model<Usb_storage_device>::Element,
|
||||
|
||||
bool discarded() const { return Storage_device::state == FAILED; }
|
||||
|
||||
Label usb_block_drv_name() const { return Label(label, ".drv"); }
|
||||
Label usb_block_drv_name() const { return label; }
|
||||
|
||||
Usb_storage_device(Env &env, Allocator &alloc, Signal_context_capability sigh,
|
||||
Label const &label)
|
||||
@ -117,14 +117,28 @@ struct Sculpt::Usb_storage_device : List_model<Usb_storage_device>::Element,
|
||||
|
||||
inline void gen_usb_block_drv_start_content(Xml_generator &xml) const;
|
||||
|
||||
static bool type_matches(Xml_node node)
|
||||
void gen_usb_policy(Xml_generator &xml) const
|
||||
{
|
||||
return node.attribute_value("class", String<32>()) == "storage";
|
||||
xml.node("policy", [&] {
|
||||
xml.attribute("label_prefix", label);
|
||||
xml.node("device", [&] {
|
||||
xml.attribute("name", label); }); });
|
||||
}
|
||||
|
||||
static bool type_matches(Xml_node const &device)
|
||||
{
|
||||
bool storage_device = false;
|
||||
device.for_each_sub_node("config", [&] (Xml_node const &config) {
|
||||
config.for_each_sub_node("interface", [&] (Xml_node const &interface) {
|
||||
if (interface.attribute_value("class", 0u) == 0x8)
|
||||
storage_device = true; }); });
|
||||
|
||||
return storage_device;
|
||||
}
|
||||
|
||||
bool matches(Xml_node node) const
|
||||
{
|
||||
return node.attribute_value("label_suffix", Label()) == label;
|
||||
return node.attribute_value("name", Label()) == label;
|
||||
}
|
||||
};
|
||||
|
||||
@ -146,8 +160,8 @@ void Sculpt::Usb_storage_device::gen_usb_block_drv_start_content(Xml_generator &
|
||||
|
||||
xml.node("route", [&] () {
|
||||
gen_service_node<Usb::Session>(xml, [&] () {
|
||||
xml.node("parent", [&] () {
|
||||
xml.attribute("label", label); }); });
|
||||
xml.node("child", [&] () {
|
||||
xml.attribute("name", "usb"); }); });
|
||||
|
||||
gen_parent_rom_route(xml, "usb_block_drv");
|
||||
gen_parent_rom_route(xml, "ld.lib.so");
|
||||
|
@ -265,43 +265,19 @@ void Sculpt::Network::_handle_nic_router_config(Xml_node config)
|
||||
|
||||
void Sculpt::Network::gen_runtime_start_nodes(Xml_generator &xml) const
|
||||
{
|
||||
switch (_nic_target.type()) {
|
||||
case Nic_target::WIRED:
|
||||
|
||||
if (_nic_target.type() == Nic_target::WIRED)
|
||||
xml.node("start", [&] () {
|
||||
xml.attribute("version", _nic_drv_version);
|
||||
gen_nic_drv_start_content(xml);
|
||||
});
|
||||
xml.node("start", [&] () { gen_nic_router_start_content(xml); });
|
||||
break;
|
||||
|
||||
case Nic_target::WIFI:
|
||||
gen_nic_drv_start_content(xml); });
|
||||
|
||||
if (_nic_target.type() == Nic_target::WIFI)
|
||||
xml.node("start", [&] () {
|
||||
xml.attribute("version", _wifi_drv_version);
|
||||
gen_wifi_drv_start_content(xml);
|
||||
});
|
||||
xml.node("start", [&] () { gen_nic_router_start_content(xml); });
|
||||
break;
|
||||
gen_wifi_drv_start_content(xml); });
|
||||
|
||||
case Nic_target::MODEM:
|
||||
bool const nic_router_needed = _nic_target.type() != Nic_target::OFF
|
||||
&& _nic_target.type() != Nic_target::UNDEFINED;
|
||||
|
||||
xml.node("start", [&] () {
|
||||
xml.attribute("version", _usb_net_version);
|
||||
gen_usb_net_start_content(xml);
|
||||
});
|
||||
xml.node("start", [&] () { gen_nic_router_start_content(xml); });
|
||||
break;
|
||||
|
||||
case Nic_target::DISCONNECTED:
|
||||
|
||||
xml.node("start", [&] () { gen_nic_router_start_content(xml); });
|
||||
break;
|
||||
|
||||
case Nic_target::OFF:
|
||||
break;
|
||||
|
||||
case Nic_target::UNDEFINED:
|
||||
break;
|
||||
}
|
||||
if (nic_router_needed)
|
||||
xml.node("start", [&] { gen_nic_router_start_content(xml); });
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
namespace Sculpt { struct Network; }
|
||||
|
||||
|
||||
struct Sculpt::Network : Network_widget::Action
|
||||
struct Sculpt::Network : Noncopyable
|
||||
{
|
||||
Env &_env;
|
||||
|
||||
@ -65,7 +65,6 @@ struct Sculpt::Network : Network_widget::Action
|
||||
|
||||
unsigned _nic_drv_version = 0;
|
||||
unsigned _wifi_drv_version = 0;
|
||||
unsigned _usb_net_version = 0;
|
||||
|
||||
Attached_rom_dataspace _wlan_accesspoints_rom {
|
||||
_env, "report -> runtime/wifi_drv/accesspoints" };
|
||||
@ -135,10 +134,7 @@ struct Sculpt::Network : Network_widget::Action
|
||||
|
||||
void _update_nic_target_from_config(Xml_node const &);
|
||||
|
||||
/**
|
||||
* Network_widget::Action interface
|
||||
*/
|
||||
void nic_target(Nic_target::Type const type) override
|
||||
void nic_target(Nic_target::Type const type)
|
||||
{
|
||||
if (type != _nic_target.managed_type) {
|
||||
_nic_target.managed_type = type;
|
||||
@ -148,7 +144,7 @@ struct Sculpt::Network : Network_widget::Action
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_connect(Access_point::Bssid bssid) override
|
||||
void wifi_connect(Access_point::Bssid bssid)
|
||||
{
|
||||
_access_points.for_each([&] (Access_point const &ap) {
|
||||
if (ap.bssid != bssid)
|
||||
@ -183,9 +179,8 @@ struct Sculpt::Network : Network_widget::Action
|
||||
|
||||
void restart_nic_drv_on_next_runtime_cfg() { _nic_drv_version++; }
|
||||
void restart_wifi_drv_on_next_runtime_cfg() { _wifi_drv_version++; }
|
||||
void restart_usb_net_on_next_runtime_cfg() { _usb_net_version++; }
|
||||
|
||||
void wifi_disconnect() override
|
||||
void wifi_disconnect()
|
||||
{
|
||||
/*
|
||||
* Reflect state change immediately to the user interface even
|
||||
|
@ -30,4 +30,3 @@
|
||||
#include <runtime/update.cc>
|
||||
#include <runtime/wifi_drv.cc>
|
||||
#include <runtime/fs_tool.cc>
|
||||
#include <runtime/usb_net.cc>
|
||||
|
@ -71,7 +71,6 @@ namespace Sculpt {
|
||||
|
||||
void gen_nic_drv_start_content(Xml_generator &);
|
||||
void gen_wifi_drv_start_content(Xml_generator &);
|
||||
void gen_usb_net_start_content(Xml_generator &);
|
||||
|
||||
void gen_nic_router_start_content(Xml_generator &);
|
||||
void gen_nic_router_uplink(Xml_generator &, char const *);
|
||||
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* \brief XML configuration for USB network driver
|
||||
* \author Norman Feske
|
||||
* \date 2022-08-24
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
|
||||
#include <runtime.h>
|
||||
|
||||
void Sculpt::gen_usb_net_start_content(Xml_generator &xml)
|
||||
{
|
||||
gen_common_start_content(xml, "usb_net",
|
||||
Cap_quota{200}, Ram_quota{20*1024*1024},
|
||||
Priority::NETWORK);
|
||||
|
||||
xml.node("binary", [&] () {
|
||||
xml.attribute("name", "usb_net_drv");
|
||||
});
|
||||
|
||||
xml.node("config", [&] () {
|
||||
xml.attribute("mac", "02:00:00:00:01:05");
|
||||
});
|
||||
|
||||
xml.node("route", [&] () {
|
||||
|
||||
xml.node("service", [&] () {
|
||||
xml.attribute("name", "Uplink");
|
||||
xml.node("child", [&] () {
|
||||
xml.attribute("name", "nic_router");
|
||||
xml.attribute("label", "usb_net -> ");
|
||||
});
|
||||
});
|
||||
|
||||
gen_service_node<Usb::Session>(xml, [&] () {
|
||||
xml.node("parent", [&] () {
|
||||
xml.attribute("label", "usb_net"); }); });
|
||||
|
||||
gen_parent_rom_route(xml, "usb_net_drv");
|
||||
gen_parent_rom_route(xml, "ld.lib.so");
|
||||
gen_parent_route<Cpu_session> (xml);
|
||||
gen_parent_route<Pd_session> (xml);
|
||||
gen_parent_route<Rm_session> (xml);
|
||||
gen_parent_route<Log_session> (xml);
|
||||
gen_parent_route<Timer::Session>(xml);
|
||||
});
|
||||
}
|
@ -15,7 +15,9 @@
|
||||
#include <storage.h>
|
||||
|
||||
|
||||
void Sculpt::Storage::handle_storage_devices_update()
|
||||
void Sculpt::Storage::update(Xml_node const &usb_devices,
|
||||
Xml_node const &block_devices,
|
||||
Signal_context_capability sigh)
|
||||
{
|
||||
bool reconfigure_runtime = false;
|
||||
|
||||
@ -31,22 +33,18 @@ void Sculpt::Storage::handle_storage_devices_update()
|
||||
};
|
||||
|
||||
{
|
||||
_block_devices_rom.update();
|
||||
|
||||
_storage_devices.update_block_devices_from_xml(_env, _alloc, _block_devices_rom.xml(),
|
||||
_storage_device_update_handler);
|
||||
_storage_devices.update_block_devices_from_xml(_env, _alloc, block_devices,
|
||||
sigh);
|
||||
|
||||
_storage_devices.block_devices.for_each([&] (Block_device &dev) {
|
||||
process_part_block_report(dev); });
|
||||
}
|
||||
|
||||
{
|
||||
_usb_active_config_rom.update();
|
||||
|
||||
bool const usb_storage_added_or_vanished =
|
||||
_storage_devices.update_usb_storage_devices_from_xml(_env, _alloc,
|
||||
_usb_active_config_rom.xml(),
|
||||
_storage_device_update_handler);
|
||||
usb_devices,
|
||||
sigh);
|
||||
|
||||
if (usb_storage_added_or_vanished)
|
||||
reconfigure_runtime = true;
|
||||
|
@ -43,10 +43,6 @@ struct Sculpt::Storage : Storage_device_widget::Action, Ram_fs_widget::Action
|
||||
|
||||
Runtime_config_generator &_runtime;
|
||||
|
||||
Attached_rom_dataspace _block_devices_rom { _env, "report -> drivers/block_devices" };
|
||||
|
||||
Attached_rom_dataspace _usb_active_config_rom { _env, "report -> drivers/usb_active_config" };
|
||||
|
||||
Storage_devices _storage_devices { };
|
||||
|
||||
Ram_fs_state _ram_fs_state;
|
||||
@ -57,10 +53,8 @@ struct Sculpt::Storage : Storage_device_widget::Action, Ram_fs_widget::Action
|
||||
|
||||
Inspect_view_version _inspect_view_version { 0 };
|
||||
|
||||
void handle_storage_devices_update();
|
||||
|
||||
Signal_handler<Storage> _storage_device_update_handler {
|
||||
_env.ep(), *this, &Storage::handle_storage_devices_update };
|
||||
void update(Xml_node const &usb_devices, Xml_node const &block_devices,
|
||||
Signal_context_capability sigh);
|
||||
|
||||
/*
|
||||
* Determine whether showing the file-system browser or not
|
||||
@ -76,6 +70,11 @@ struct Sculpt::Storage : Storage_device_widget::Action, Ram_fs_widget::Action
|
||||
|
||||
void gen_runtime_start_nodes(Xml_generator &) const;
|
||||
|
||||
void gen_usb_storage_policies(Xml_generator &xml) const
|
||||
{
|
||||
_storage_devices.gen_usb_storage_policies(xml);
|
||||
}
|
||||
|
||||
template <typename FN>
|
||||
void _apply_partition(Storage_target const &target, FN const &fn)
|
||||
{
|
||||
@ -182,16 +181,12 @@ struct Sculpt::Storage : Storage_device_widget::Action, Ram_fs_widget::Action
|
||||
_runtime.generate_runtime_config();
|
||||
}
|
||||
|
||||
|
||||
Storage(Env &env, Allocator &alloc, Registry<Child_state> &child_states,
|
||||
Action &action, Runtime_config_generator &runtime)
|
||||
:
|
||||
_env(env), _alloc(alloc), _action(action), _runtime(runtime),
|
||||
_ram_fs_state(child_states, "ram_fs")
|
||||
{
|
||||
_block_devices_rom .sigh(_storage_device_update_handler);
|
||||
_usb_active_config_rom.sigh(_storage_device_update_handler);
|
||||
}
|
||||
{ }
|
||||
};
|
||||
|
||||
#endif /* _STORAGE_H_ */
|
||||
|
175
repos/gems/src/app/sculpt_manager/usb_driver.h
Normal file
175
repos/gems/src/app/sculpt_manager/usb_driver.h
Normal file
@ -0,0 +1,175 @@
|
||||
/*
|
||||
* \brief Sculpt USB-driver management
|
||||
* \author Norman Feske
|
||||
* \date 2024-03-18
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2024 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.
|
||||
*/
|
||||
|
||||
#ifndef _USB_DRIVER_H_
|
||||
#define _USB_DRIVER_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <uplink_session/uplink_session.h>
|
||||
|
||||
/* local includes */
|
||||
#include <model/child_exit_state.h>
|
||||
#include <model/board_info.h>
|
||||
#include <managed_config.h>
|
||||
#include <runtime.h>
|
||||
|
||||
namespace Sculpt { struct Usb_driver; }
|
||||
|
||||
|
||||
struct Sculpt::Usb_driver : private Noncopyable
|
||||
{
|
||||
struct Action : Interface
|
||||
{
|
||||
virtual void handle_usb_plug_unplug() = 0;
|
||||
virtual void gen_usb_storage_policies(Xml_generator &) const = 0;
|
||||
};
|
||||
|
||||
Env &_env;
|
||||
Action &_action;
|
||||
|
||||
Constructible<Child_state> _hcd { },
|
||||
_hid { },
|
||||
_net { };
|
||||
|
||||
Attached_rom_dataspace _devices { _env, "report -> runtime/usb/devices" };
|
||||
|
||||
Signal_handler<Usb_driver> _devices_handler {
|
||||
_env.ep(), *this, &Usb_driver::_handle_devices };
|
||||
|
||||
void _handle_devices()
|
||||
{
|
||||
_devices.update();
|
||||
_action.handle_usb_plug_unplug();
|
||||
}
|
||||
|
||||
Managed_config<Usb_driver> _usb_config {
|
||||
_env, "config", "usb", *this, &Usb_driver::_handle_usb_config };
|
||||
|
||||
void _handle_usb_config(Xml_node config)
|
||||
{
|
||||
_usb_config.generate([&] (Xml_generator &xml) {
|
||||
copy_attributes(xml, config);
|
||||
|
||||
xml.node("report", [&] {
|
||||
xml.attribute("devices", "yes"); });
|
||||
|
||||
xml.node("policy", [&] {
|
||||
xml.attribute("label_prefix", "usb_hid");
|
||||
xml.node("device", [&] {
|
||||
xml.attribute("class", "0x3"); }); });
|
||||
|
||||
/* copy user-provided rules */
|
||||
config.for_each_sub_node("policy", [&] (Xml_node const &policy) {
|
||||
copy_node(xml, policy); });
|
||||
|
||||
_action.gen_usb_storage_policies(xml);
|
||||
});
|
||||
}
|
||||
|
||||
Usb_driver(Env &env, Action &action) : _env(env), _action(action)
|
||||
{
|
||||
_devices.sigh(_devices_handler);
|
||||
_usb_config.trigger_update();
|
||||
_devices_handler.local_submit();
|
||||
}
|
||||
|
||||
void gen_start_nodes(Xml_generator &xml) const
|
||||
{
|
||||
auto gen_common_routes = [&] (Xml_generator &xml)
|
||||
{
|
||||
gen_parent_route<Rom_session> (xml);
|
||||
gen_parent_route<Cpu_session> (xml);
|
||||
gen_parent_route<Pd_session> (xml);
|
||||
gen_parent_route<Log_session> (xml);
|
||||
gen_parent_route<Timer::Session> (xml);
|
||||
gen_parent_route<Report::Session> (xml);
|
||||
};
|
||||
|
||||
auto start_node = [&] (auto const &driver, auto const &binary, auto const &fn)
|
||||
{
|
||||
if (driver.constructed())
|
||||
xml.node("start", [&] {
|
||||
driver->gen_start_node_content(xml);
|
||||
gen_named_node(xml, "binary", binary);
|
||||
fn(); });
|
||||
};
|
||||
|
||||
start_node(_hcd, "usb_drv", [&] {
|
||||
gen_provides<Usb::Session>(xml);
|
||||
xml.node("route", [&] {
|
||||
gen_parent_route<Platform::Session>(xml);
|
||||
gen_parent_rom_route(xml, "config", "config -> managed/usb");
|
||||
gen_parent_rom_route(xml, "dtb", "usb_drv.dtb");
|
||||
gen_common_routes(xml);
|
||||
});
|
||||
});
|
||||
|
||||
start_node(_hid, "usb_hid_drv", [&] {
|
||||
xml.node("config", [&] {
|
||||
xml.attribute("capslock_led", "rom");
|
||||
xml.attribute("numlock_led", "rom");
|
||||
});
|
||||
xml.node("route", [&] {
|
||||
gen_service_node<Usb::Session>(xml, [&] {
|
||||
gen_named_node(xml, "child", "usb"); });
|
||||
gen_parent_rom_route(xml, "capslock", "capslock");
|
||||
gen_parent_rom_route(xml, "numlock", "numlock");
|
||||
gen_common_routes(xml);
|
||||
gen_service_node<Event::Session>(xml, [&] {
|
||||
xml.node("parent", [&] {
|
||||
xml.attribute("label", "usb_hid"); }); });
|
||||
});
|
||||
});
|
||||
|
||||
start_node(_net, "usb_net_drv", [&] {
|
||||
xml.node("config", [&] {
|
||||
xml.attribute("mac", "02:00:00:00:01:05");
|
||||
});
|
||||
xml.node("route", [&] {
|
||||
gen_service_node<Usb::Session>(xml, [&] {
|
||||
gen_named_node(xml, "child", "usb"); });
|
||||
gen_common_routes(xml);
|
||||
gen_service_node<Uplink::Session>(xml, [&] {
|
||||
xml.node("child", [&] () {
|
||||
xml.attribute("name", "nic_router");
|
||||
xml.attribute("label", "usb_net -> ");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
struct Features { bool hid, net; };
|
||||
|
||||
void update(Registry<Child_state> ®istry,
|
||||
Board_info const &board_info, Features features)
|
||||
{
|
||||
_hcd.conditional(board_info.usb_present,
|
||||
registry, "usb", Priority::MULTIMEDIA,
|
||||
Ram_quota { 16*1024*1024 }, Cap_quota { 200 });
|
||||
|
||||
_hid.conditional(board_info.usb_present && features.hid,
|
||||
registry, "usb_hid", Priority::MULTIMEDIA,
|
||||
Ram_quota { 11*1024*1024 }, Cap_quota { 180 });
|
||||
|
||||
_net.conditional(board_info.usb_present && features.net,
|
||||
registry, "usb_net", Priority::DEFAULT,
|
||||
Ram_quota { 20*1024*1024 }, Cap_quota { 200 });
|
||||
|
||||
_usb_config.trigger_update();
|
||||
}
|
||||
|
||||
void with_devices(auto const &fn) const { fn(_devices.xml()); }
|
||||
};
|
||||
|
||||
#endif /* _USB_DRIVER_H_ */
|
@ -133,6 +133,28 @@ namespace Sculpt {
|
||||
{
|
||||
return _attribute_value<T>(node, args...);
|
||||
}
|
||||
|
||||
static inline void copy_attributes(Xml_generator &xml, Xml_node const &from)
|
||||
{
|
||||
using Value = String<64>;
|
||||
from.for_each_attribute([&] (Xml_attribute const &attr) {
|
||||
Value value { };
|
||||
attr.value(value);
|
||||
xml.attribute(attr.name().string(), value);
|
||||
});
|
||||
}
|
||||
|
||||
struct Xml_max_depth { unsigned value; };
|
||||
|
||||
static inline void copy_node(Xml_generator &xml, Xml_node const &from,
|
||||
Xml_max_depth max_depth = { 5 })
|
||||
{
|
||||
if (max_depth.value)
|
||||
xml.node(from.type().string(), [&] {
|
||||
copy_attributes(xml, from);
|
||||
from.for_each_sub_node([&] (Xml_node const &sub_node) {
|
||||
copy_node(xml, sub_node, { max_depth.value - 1 }); }); });
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _XML_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user