From f96cea81517a370b27a849f6c61286161e80c246 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 26 Mar 2024 18:25:22 +0100 Subject: [PATCH] sculpt: remove notion of system 'block_devices' This patch removes the remains of the original block-device discovery as done by the former driver manager. Block sessions are now always provided by components hosted in the runtime subsytem. The storage node of the graph is no more. Issue #5150 --- repos/gems/src/app/phone_manager/feature.h | 2 - repos/gems/src/app/phone_manager/main.cc | 82 ++++++------ .../gems/src/app/sculpt_manager/driver/ahci.h | 5 +- .../gems/src/app/sculpt_manager/driver/mmc.h | 5 +- .../gems/src/app/sculpt_manager/driver/nvme.h | 5 +- .../gems/src/app/sculpt_manager/driver/usb.h | 5 +- repos/gems/src/app/sculpt_manager/feature.h | 3 - repos/gems/src/app/sculpt_manager/graph.cc | 55 ++------ repos/gems/src/app/sculpt_manager/graph.h | 9 +- repos/gems/src/app/sculpt_manager/main.cc | 88 +++++++------ .../app/sculpt_manager/model/ahci_device.h | 7 +- .../app/sculpt_manager/model/block_device.h | 50 -------- .../sculpt_manager/model/discovery_state.h | 36 ++++-- .../src/app/sculpt_manager/model/mmc_device.h | 7 +- .../app/sculpt_manager/model/nvme_device.h | 7 +- .../app/sculpt_manager/model/storage_device.h | 82 ++++++------ .../sculpt_manager/model/storage_devices.h | 103 +++++---------- .../app/sculpt_manager/model/storage_target.h | 42 +++---- .../sculpt_manager/model/usb_storage_device.h | 55 ++++---- .../app/sculpt_manager/runtime/gpt_write.cc | 2 +- .../sculpt_manager/runtime/inspect_view.cc | 2 +- repos/gems/src/app/sculpt_manager/storage.cc | 119 ++++++------------ repos/gems/src/app/sculpt_manager/storage.h | 71 +++-------- repos/gems/src/app/sculpt_manager/types.h | 2 + .../view/partition_operations.cc | 6 +- .../view/partition_operations.h | 2 +- .../view/storage_device_widget.cc | 2 +- .../view/storage_device_widget.h | 4 +- .../app/sculpt_manager/view/storage_widget.h | 33 +---- 29 files changed, 342 insertions(+), 549 deletions(-) delete mode 100644 repos/gems/src/app/sculpt_manager/model/block_device.h diff --git a/repos/gems/src/app/phone_manager/feature.h b/repos/gems/src/app/phone_manager/feature.h index 0df990f04c..dc16faddb7 100644 --- a/repos/gems/src/app/phone_manager/feature.h +++ b/repos/gems/src/app/phone_manager/feature.h @@ -22,9 +22,7 @@ namespace Sculpt { struct Feature; }; struct Sculpt::Feature { static constexpr bool PRESENT_PLUS_MENU = false; - static constexpr bool STORAGE_DIALOG_HOSTED_IN_GRAPH = false; static constexpr bool INSPECT_VIEW = false; - static constexpr bool VISUAL_HOVER = false; }; #endif /* _FEATURE_H_ */ diff --git a/repos/gems/src/app/phone_manager/main.cc b/repos/gems/src/app/phone_manager/main.cc index b9a5f5565f..11304c922d 100644 --- a/repos/gems/src/app/phone_manager/main.cc +++ b/repos/gems/src/app/phone_manager/main.cc @@ -68,7 +68,7 @@ namespace Sculpt { struct Main; } struct Sculpt::Main : Input_event_handler, Runtime_config_generator, Deploy::Action, - Storage::Action, + Storage_device::Action, Network::Action, Network::Info, Graph::Action, @@ -81,6 +81,7 @@ struct Sculpt::Main : Input_event_handler, Dialpad_widget::Action, Current_call_widget::Action, Network_widget::Action, + Ram_fs_widget::Action, Software_presets_widget::Action, Software_options_widget::Action, Software_update_widget::Action, @@ -210,7 +211,7 @@ struct Sculpt::Main : Input_event_handler, */ void handle_device_plug_unplug() override { - _handle_block_devices(); + _handle_storage_devices(); network_config_changed(); generate_runtime_config(); } @@ -311,37 +312,39 @@ struct Sculpt::Main : Input_event_handler, ** 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() + void _handle_storage_devices() { - _block_devices_rom.update(); + Storage_target const orig_sculpt_partition = _storage._sculpt_partition; - _drivers.with_storage_devices([&] (Xml_node const &usb_devices, - Xml_node const &ahci_ports, - Xml_node const &nvme_namespaces, - Xml_node const &mmc_devices) { - _storage.update(usb_devices, ahci_ports, nvme_namespaces, mmc_devices, - _block_devices_rom.xml(), - _block_devices_handler); - }); + bool total_progress = false; + for (bool progress = true; progress; total_progress |= progress) { + progress = false; + _drivers.with_storage_devices([&] (Drivers::Storage_devices const &devices) { + progress = _storage.update(devices.usb, devices.ahci, + devices.nvme, devices.mmc).progress; }); - /* update USB policies for storage devices */ - _drivers.update_usb(); + /* update USB policies for storage devices */ + _drivers.update_usb(); + } + + if (orig_sculpt_partition != _storage._sculpt_partition) + _restart_from_storage_target(); + + if (total_progress) { + generate_runtime_config(); + _generate_dialog(); + } } - Storage _storage { _env, _heap, _child_states, *this, *this }; - /** - * Storage::Action interface + * Storage_device::Action */ - void use_storage_target(Storage_target const &target) override - { - _storage._sculpt_partition = target; + void storage_device_discovered() override { _handle_storage_devices(); } + Storage _storage { _env, _heap, _child_states, *this }; + + void _restart_from_storage_target() + { /* trigger loading of the configuration from the sculpt partition */ _prepare_version.value++; @@ -350,11 +353,6 @@ struct Sculpt::Main : Input_event_handler, generate_runtime_config(); } - /** - * Storage::Action interface - */ - void refresh_storage_dialog() override { _generate_dialog(); } - /************* ** Network ** @@ -1256,7 +1254,7 @@ struct Sculpt::Main : Input_event_handler, _storage_widget .propagate(at, *this); _software_presets_widget.propagate(at, _presets, *this); _software_add_widget .propagate(at, *this); - _graph .propagate(at, *this, _storage); + _graph .propagate(at, *this, *this); _update_touch_keyboard_visibility(); } @@ -1350,44 +1348,57 @@ struct Sculpt::Main : Input_event_handler, void use(Storage_target const &target) override { + _storage._sculpt_partition = target; _software_update_widget.hosted.reset(); _download_queue.reset(); - _storage.use(target); + generate_runtime_config(); } /* - * Storage_dialog::Action interface + * Storage_device_widget::Action interface */ void format(Storage_target const &target) override { _storage.format(target); + generate_runtime_config(); } void cancel_format(Storage_target const &target) override { _storage.cancel_format(target); _reset_storage_widget_operation(); + generate_runtime_config(); } void expand(Storage_target const &target) override { _storage.expand(target); + generate_runtime_config(); } void cancel_expand(Storage_target const &target) override { _storage.cancel_expand(target); _reset_storage_widget_operation(); + generate_runtime_config(); } void check(Storage_target const &target) override { _storage.check(target); + generate_runtime_config(); } void toggle_default_storage_target(Storage_target const &target) override { _storage.toggle_default_storage_target(target); + generate_runtime_config(); + } + + void reset_ram_fs() override + { + _storage.reset_ram_fs(); + generate_runtime_config(); } /* @@ -2228,7 +2239,7 @@ void Sculpt::Main::_handle_runtime_state() device.for_each_partition([&] (Partition &partition) { - Storage_target const target { device.label, device.port, partition.number }; + Storage_target const target { device.driver, device.port, partition.number }; if (partition.check_in_progress) { String<64> name(target.label(), ".e2fsck"); @@ -2320,8 +2331,7 @@ void Sculpt::Main::_handle_runtime_state() /* handle failed initialization of USB-storage devices */ _storage._storage_devices.usb_storage_devices.for_each([&] (Usb_storage_device &dev) { - String<64> name(dev.usb_block_drv_name()); - Child_exit_state exit_state(state, name); + Child_exit_state exit_state(state, dev.driver); if (exit_state.exited) { dev.discard_usb_block_drv(); reconfigure_runtime = true; diff --git a/repos/gems/src/app/sculpt_manager/driver/ahci.h b/repos/gems/src/app/sculpt_manager/driver/ahci.h index 0007643883..1f64929744 100644 --- a/repos/gems/src/app/sculpt_manager/driver/ahci.h +++ b/repos/gems/src/app/sculpt_manager/driver/ahci.h @@ -79,7 +79,10 @@ struct Sculpt::Ahci_driver : private Noncopyable Ram_quota { 10*1024*1024 }, Cap_quota { 100 }); } - void with_ports(auto const &fn) const { fn(_ports.xml()); } + void with_ports(auto const &fn) const + { + fn(_ahci.constructed() ? _ports.xml() : Xml_node("")); + } }; #endif /* _DRIVER__AHCI_H_ */ diff --git a/repos/gems/src/app/sculpt_manager/driver/mmc.h b/repos/gems/src/app/sculpt_manager/driver/mmc.h index c37d099d90..927e13f10f 100644 --- a/repos/gems/src/app/sculpt_manager/driver/mmc.h +++ b/repos/gems/src/app/sculpt_manager/driver/mmc.h @@ -77,7 +77,10 @@ struct Sculpt::Mmc_driver : private Noncopyable Ram_quota { 16*1024*1024 }, Cap_quota { 500 }); } - void with_devices(auto const &fn) const { fn(_devices.xml()); } + void with_devices(auto const &fn) const + { + fn(_mmc.constructed() ? _devices.xml() : Xml_node("")); + } }; #endif /* _DRIVER__MMC_H_ */ diff --git a/repos/gems/src/app/sculpt_manager/driver/nvme.h b/repos/gems/src/app/sculpt_manager/driver/nvme.h index bd70f4c6d7..6afb501d59 100644 --- a/repos/gems/src/app/sculpt_manager/driver/nvme.h +++ b/repos/gems/src/app/sculpt_manager/driver/nvme.h @@ -78,7 +78,10 @@ struct Sculpt::Nvme_driver : private Noncopyable Ram_quota { 8*1024*1024 }, Cap_quota { 100 }); } - void with_namespaces(auto const &fn) const { fn(_namespaces.xml()); } + void with_namespaces(auto const &fn) const + { + fn(_nvme.constructed() ? _namespaces.xml() : Xml_node("")); + } }; #endif /* _DRIVER_NVME_H_ */ diff --git a/repos/gems/src/app/sculpt_manager/driver/usb.h b/repos/gems/src/app/sculpt_manager/driver/usb.h index f58fae0217..b9f40247a3 100644 --- a/repos/gems/src/app/sculpt_manager/driver/usb.h +++ b/repos/gems/src/app/sculpt_manager/driver/usb.h @@ -178,7 +178,10 @@ struct Sculpt::Usb_driver : private Noncopyable _usb_config.trigger_update(); } - void with_devices(auto const &fn) const { fn(_devices.xml()); } + void with_devices(auto const &fn) const + { + fn(_hcd.constructed() ? _devices.xml() : Xml_node("")); + } }; #endif /* _DRIVER__USB_H_ */ diff --git a/repos/gems/src/app/sculpt_manager/feature.h b/repos/gems/src/app/sculpt_manager/feature.h index a37c53f3fb..3abf362ecf 100644 --- a/repos/gems/src/app/sculpt_manager/feature.h +++ b/repos/gems/src/app/sculpt_manager/feature.h @@ -24,9 +24,6 @@ struct Sculpt::Feature /* show the '+' botton at the graph for opening the deploy popup dialog */ static constexpr bool PRESENT_PLUS_MENU = true; - /* manage storage from within the respective graph nodes */ - static constexpr bool STORAGE_DIALOG_HOSTED_IN_GRAPH = true; - /* allow the browsing of file systems via the inspect view */ static constexpr bool INSPECT_VIEW = true; }; diff --git a/repos/gems/src/app/sculpt_manager/graph.cc b/repos/gems/src/app/sculpt_manager/graph.cc index f4c3c72411..706b142f6d 100644 --- a/repos/gems/src/app/sculpt_manager/graph.cc +++ b/repos/gems/src/app/sculpt_manager/graph.cc @@ -110,7 +110,7 @@ void Graph::_view_selected_node_content(Scope &s, s.sub_scope