diff --git a/repos/gems/run/sculpt.run b/repos/gems/run/sculpt.run
index 42bebcaab3..94b02024f3 100644
--- a/repos/gems/run/sculpt.run
+++ b/repos/gems/run/sculpt.run
@@ -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) {
+
+ }
+
+ set result(pinephone) {
+
+
+ }
+
+ 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 {
- } [log_route] [nic_driver_routes] {
+ } [log_route] [nic_driver_routes] [usb_driver_routes] {
diff --git a/repos/gems/sculpt/drivers/pc b/repos/gems/sculpt/drivers/pc
index 4220d6d02c..cdec6b826d 100644
--- a/repos/gems/sculpt/drivers/pc
+++ b/repos/gems/sculpt/drivers/pc
@@ -26,9 +26,6 @@
-
-
-
@@ -42,19 +39,15 @@
-
-
-
-
@@ -64,19 +57,16 @@
-
-
-
@@ -139,7 +129,7 @@
-
+
@@ -151,43 +141,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -209,9 +162,7 @@
-
-
@@ -237,7 +188,6 @@
-
diff --git a/repos/gems/sculpt/event_filter/default b/repos/gems/sculpt/event_filter/default
index 2bfa706a23..a23a946f8d 100644
--- a/repos/gems/sculpt/event_filter/default
+++ b/repos/gems/sculpt/event_filter/default
@@ -8,8 +8,8 @@
-
-
-
-
+
+
+
+
diff --git a/repos/gems/sculpt/event_filter/pc b/repos/gems/sculpt/event_filter/pc
index 239b29d99c..547d925c5f 100644
--- a/repos/gems/sculpt/event_filter/pc
+++ b/repos/gems/sculpt/event_filter/pc
@@ -36,5 +36,5 @@
-
+
diff --git a/repos/gems/sculpt/leitzentrale/default b/repos/gems/sculpt/leitzentrale/default
index 45bbd1607a..d9fbc1e9f2 100644
--- a/repos/gems/sculpt/leitzentrale/default
+++ b/repos/gems/sculpt/leitzentrale/default
@@ -242,6 +242,8 @@
+
+
diff --git a/repos/gems/sculpt/leitzentrale/phone b/repos/gems/sculpt/leitzentrale/phone
index d45c2d4321..651bca00cc 100644
--- a/repos/gems/sculpt/leitzentrale/phone
+++ b/repos/gems/sculpt/leitzentrale/phone
@@ -136,6 +136,8 @@
+
+
diff --git a/repos/gems/sculpt/usb/default b/repos/gems/sculpt/usb/default
index 7d42895d9c..df9a2dfd10 100644
--- a/repos/gems/sculpt/usb/default
+++ b/repos/gems/sculpt/usb/default
@@ -1,13 +1,2 @@
-
-
-
-
-
-
+
+
diff --git a/repos/gems/src/app/driver_manager/main.cc b/repos/gems/src/app/driver_manager/main.cc
index 2989779fc9..6a58394aed 100644
--- a/repos/gems/src/app/driver_manager/main.cc
+++ b/repos/gems/src/app/driver_manager/main.cc
@@ -24,7 +24,6 @@
#include
#include
#include
-#include
#include
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 { };
@@ -247,14 +243,6 @@ struct Driver_manager::Main
Signal_handler _devices_update_handler {
_env.ep(), *this, &Main::_handle_devices_update };
- void _handle_usb_devices_update();
-
- Signal_handler _usb_devices_update_handler {
- _env.ep(), *this, &Main::_handle_usb_devices_update };
-
- Signal_handler _usb_policy_update_handler {
- _env.ep(), *this, &Main::_handle_usb_devices_update };
-
void _handle_ahci_ports_update();
Signal_handler _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(""),
- Xml_node(""));
-
- _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); }
diff --git a/repos/gems/src/app/phone_manager/main.cc b/repos/gems/src/app/phone_manager/main.cc
index f7c73191a0..292d7a3d70 100644
--- a/repos/gems/src/app/phone_manager/main.cc
+++ b/repos/gems/src/app/phone_manager/main.cc
@@ -38,6 +38,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -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 _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 _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 _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 _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 _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);
diff --git a/repos/gems/src/app/sculpt_manager/graph.cc b/repos/gems/src/app/sculpt_manager/graph.cc
index 24793d805e..f9be6557df 100644
--- a/repos/gems/src/app/sculpt_manager/graph.cc
+++ b/repos/gems/src/app/sculpt_manager/graph.cc
@@ -112,6 +112,10 @@ void Graph::_view_selected_node_content(Scope &s,
s.sub_scope(25);
s.sub_scope