From 27e05004520268a1f4bd642b2bf1ebddffd3ecfc Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 15 Mar 2024 15:08:29 +0100 Subject: [PATCH] sculpt_manager: Pci_info -> Board_info This is a preparatory commit for issue #5150. Board_info is designated for the selection of device drivers. It is not specific to PCI devices. --- repos/gems/src/app/phone_manager/main.cc | 29 +++++----- repos/gems/src/app/sculpt_manager/main.cc | 31 ++++------ .../src/app/sculpt_manager/model/board_info.h | 56 +++++++++++++++++++ .../src/app/sculpt_manager/model/pci_info.h | 28 ---------- repos/gems/src/app/sculpt_manager/network.h | 10 ++-- .../app/sculpt_manager/view/network_widget.h | 20 +++---- 6 files changed, 94 insertions(+), 80 deletions(-) create mode 100644 repos/gems/src/app/sculpt_manager/model/board_info.h delete mode 100644 repos/gems/src/app/sculpt_manager/model/pci_info.h diff --git a/repos/gems/src/app/phone_manager/main.cc b/repos/gems/src/app/phone_manager/main.cc index 2d29e46bf9..40e89726bd 100644 --- a/repos/gems/src/app/phone_manager/main.cc +++ b/repos/gems/src/app/phone_manager/main.cc @@ -292,10 +292,11 @@ struct Sculpt::Main : Input_event_handler, */ void refresh_storage_dialog() override { _generate_dialog(); } - Pci_info _pci_info { .wifi_present = true, - .modem_present = true }; + Board_info _board_info { .wifi_present = true, + .lan_present = false, + .modem_present = true }; - Network _network { _env, _heap, *this, *this, _child_states, *this, _runtime_state, _pci_info }; + Network _network { _env, _heap, *this, *this, _child_states, *this, _runtime_state }; /** * Network::Action interface @@ -753,13 +754,11 @@ struct Sculpt::Main : Input_event_handler, _popup.state, _deploy._children }; Conditional_widget - _network_widget { - Conditional_widget::Attr { .centered = true }, + _network_widget { Conditional_widget::Attr { .centered = true }, Id { "net settings" }, _network._nic_target, _network._access_points, _network._wifi_connection, _network._nic_state, - _network.wpa_passphrase, _network._wlan_config_policy, - _pci_info }; + _network.wpa_passphrase, _network._wlan_config_policy }; void _view_main_dialog(Scope<> &s) const { @@ -844,7 +843,7 @@ struct Sculpt::Main : Input_event_handler, _network_title_bar.view_status(s, network_status_message()); }); - s.widget(_network_widget, _network_title_bar.selected()); + s.widget(_network_widget, _network_title_bar.selected(), _board_info); s.widget(_software_title_bar, [&] (auto &s) { _software_title_bar.view_status(s, _software_status_message()); }); @@ -1602,11 +1601,11 @@ struct Sculpt::Main : Input_event_handler, bool regenerate_dialog = false; /* mobile data connectivity depends on the presence of a battery */ - if (_power_state.modem_present() != _pci_info.modem_present) { + if (_power_state.modem_present() != _board_info.modem_present) { /* update condition for the "Mobile data" network option */ - _pci_info.modem_present = _power_state.modem_present() - && _modem_state.ready(); + _board_info.modem_present = _power_state.modem_present() + && _modem_state.ready(); regenerate_dialog = true; } @@ -1739,10 +1738,10 @@ struct Sculpt::Main : Input_event_handler, /* update condition of "Mobile data" network option */ { - bool const orig_mobile_data_ready = _pci_info.modem_present; - _pci_info.modem_present = _power_state.modem_present() - && _modem_state.ready(); - if (orig_mobile_data_ready != _pci_info.modem_present) + bool const orig_mobile_data_ready = _board_info.modem_present; + _board_info.modem_present = _power_state.modem_present() + && _modem_state.ready(); + if (orig_mobile_data_ready != _board_info.modem_present) regenerate_dialog = true; } diff --git a/repos/gems/src/app/sculpt_manager/main.cc b/repos/gems/src/app/sculpt_manager/main.cc index 718254ea65..a364675749 100644 --- a/repos/gems/src/app/sculpt_manager/main.cc +++ b/repos/gems/src/app/sculpt_manager/main.cc @@ -203,27 +203,18 @@ struct Sculpt::Main : Input_event_handler, ** Device discovery ** **********************/ - Attached_rom_dataspace _pci_devices { _env, "report -> drivers/pci_devices" }; + Attached_rom_dataspace _devices { _env, "report -> drivers/devices" }; - Signal_handler
_pci_devices_handler { - _env.ep(), *this, &Main::_handle_pci_devices }; + Signal_handler
_devices_handler { + _env.ep(), *this, &Main::_handle_devices }; - Pci_info _pci_info { }; + Board_info _board_info { }; - void _handle_pci_devices() + void _handle_devices() { - _pci_devices.update(); - _pci_info.wifi_present = false; - _pci_info.lan_present = true; - _pci_info.modem_present = false; + _devices.update(); - _pci_devices.xml().for_each_sub_node("device", [&] (Xml_node device) { - device.with_optional_sub_node("pci-config", [&] (Xml_node pci) { - /* detect Intel Wireless card */ - if (pci.attribute_value("class", 0UL) == 0x28000) - _pci_info.wifi_present = true; - }); - }); + _board_info = Board_info::from_xml(_devices.xml()); update_network_dialog(); } @@ -275,7 +266,7 @@ struct Sculpt::Main : Input_event_handler, ** Network ** *************/ - Network _network { _env, _heap, *this, *this, _child_states, *this, _runtime_state, _pci_info }; + Network _network { _env, _heap, *this, *this, _child_states, *this, _runtime_state }; struct Network_top_level_dialog : Top_level_dialog { @@ -287,7 +278,7 @@ struct Sculpt::Main : Input_event_handler, void view(Scope<> &s) const override { s.sub_scope([&] (Scope &s) { - _main._network.dialog.view(s); }); + _main._network.dialog.view(s, _main._board_info); }); } void click(Clicked_at const &at) override @@ -1406,7 +1397,7 @@ struct Sculpt::Main : Input_event_handler, * Subscribe to reports */ _update_state_rom .sigh(_update_state_handler); - _pci_devices .sigh(_pci_devices_handler); + _devices .sigh(_devices_handler); _window_list .sigh(_window_list_handler); _decorator_margins .sigh(_decorator_margins_handler); _scan_rom .sigh(_scan_handler); @@ -1426,7 +1417,7 @@ struct Sculpt::Main : Input_event_handler, */ _handle_gui_mode(); _storage.handle_storage_devices_update(); - _handle_pci_devices(); + _handle_devices(); _handle_runtime_config(); /* diff --git a/repos/gems/src/app/sculpt_manager/model/board_info.h b/repos/gems/src/app/sculpt_manager/model/board_info.h new file mode 100644 index 0000000000..267919c2aa --- /dev/null +++ b/repos/gems/src/app/sculpt_manager/model/board_info.h @@ -0,0 +1,56 @@ +/* + * \brief Board discovery information + * \author Norman Feske + * \date 2018-06-01 + */ + +/* + * Copyright (C) 2018 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 _MODEL__BOARD_INFO_H_ +#define _MODEL__BOARD_INFO_H_ + +#include "types.h" + +namespace Sculpt { struct Board_info; } + +struct Sculpt::Board_info +{ + bool wifi_present; + bool lan_present; + bool modem_present; + + static Board_info from_xml(Xml_node const &devices) + { + bool wifi = false, lan = false; + + devices.for_each_sub_node("device", [&] (Xml_node const &device) { + device.with_optional_sub_node("pci-config", [&] (Xml_node const &pci) { + + auto has_class = [&] (unsigned class_value) + { + return pci.attribute_value("class", 0UL) == class_value; + }; + + /* PCI class values */ + static constexpr unsigned WIFI = 0x28000, + LAN = 0x20000; + + if (has_class(WIFI)) wifi = true; + if (has_class(LAN)) lan = true; + }); + }); + + return { + .wifi_present = wifi, + .lan_present = lan, + .modem_present = false + }; + } +}; + +#endif /* _MODEL__BOARD_INFO_H_ */ diff --git a/repos/gems/src/app/sculpt_manager/model/pci_info.h b/repos/gems/src/app/sculpt_manager/model/pci_info.h deleted file mode 100644 index 19b2b8977c..0000000000 --- a/repos/gems/src/app/sculpt_manager/model/pci_info.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * \brief PCI discovery information - * \author Norman Feske - * \date 2018-06-01 - */ - -/* - * Copyright (C) 2018 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 _MODEL__PCI_INFO_H_ -#define _MODEL__PCI_INFO_H_ - -#include "types.h" - -namespace Sculpt { struct Pci_info; } - -struct Sculpt::Pci_info -{ - bool wifi_present = false; - bool lan_present = false; - bool modem_present = false; -}; - -#endif /* _MODEL__PCI_INFO_H_ */ diff --git a/repos/gems/src/app/sculpt_manager/network.h b/repos/gems/src/app/sculpt_manager/network.h index 5499f1d68e..67f7b982bb 100644 --- a/repos/gems/src/app/sculpt_manager/network.h +++ b/repos/gems/src/app/sculpt_manager/network.h @@ -20,7 +20,7 @@ /* local includes */ #include -#include +#include #include #include #include @@ -53,7 +53,6 @@ struct Sculpt::Network : Network_widget::Action Runtime_config_generator &_runtime_config_generator; Runtime_info const &_runtime_info; - Pci_info const &_pci_info; using Wlan_config_policy = Network_widget::Wlan_config_policy; @@ -113,8 +112,7 @@ struct Sculpt::Network : Network_widget::Action Network_widget dialog { _nic_target, _access_points, - _wifi_connection, _nic_state, wpa_passphrase, _wlan_config_policy, - _pci_info }; + _wifi_connection, _nic_state, wpa_passphrase, _wlan_config_policy }; Managed_config _wlan_config { _env, "config", "wifi", *this, &Network::_handle_wlan_config }; @@ -218,12 +216,12 @@ struct Sculpt::Network : Network_widget::Action Network(Env &env, Allocator &alloc, Action &action, Info const &info, Registry &child_states, Runtime_config_generator &runtime_config_generator, - Runtime_info const &runtime_info, Pci_info const &pci_info) + Runtime_info const &runtime_info) : _env(env), _alloc(alloc), _action(action), _info(info), _child_states(child_states), _runtime_config_generator(runtime_config_generator), - _runtime_info(runtime_info), _pci_info(pci_info) + _runtime_info(runtime_info) { /* * Subscribe to reports diff --git a/repos/gems/src/app/sculpt_manager/view/network_widget.h b/repos/gems/src/app/sculpt_manager/view/network_widget.h index 9046456a14..1c67794c99 100644 --- a/repos/gems/src/app/sculpt_manager/view/network_widget.h +++ b/repos/gems/src/app/sculpt_manager/view/network_widget.h @@ -17,7 +17,7 @@ /* local includes */ #include #include -#include +#include #include namespace Sculpt { struct Network_widget; } @@ -29,7 +29,6 @@ struct Sculpt::Network_widget : Widget Nic_target const &_nic_target; Nic_state const &_nic_state; - Pci_info const &_pci_info; struct Action : Ap_selector_widget::Action { @@ -47,7 +46,7 @@ struct Sculpt::Network_widget : Widget _wifi { Id { "Wifi" }, Type::WIFI }, _modem { Id { "Mobile data" }, Type::MODEM }; - void view(Scope &s, Nic_target const &target, Pci_info const &pci_info) const + void view(Scope &s, Nic_target const &target, Board_info const &board_info) const { Type const selected = target.type(); @@ -61,15 +60,15 @@ struct Sculpt::Network_widget : Widget s.widget(_local, selected); if (target.managed() || target.manual_type == Nic_target::WIRED) - if (pci_info.lan_present) + if (board_info.lan_present) s.widget(_wired, selected); if (target.managed() || target.manual_type == Nic_target::WIFI) - if (pci_info.wifi_present) + if (board_info.wifi_present) s.widget(_wifi, selected); if (target.managed() || target.manual_type == Nic_target::MODEM) - if (pci_info.modem_present) + if (board_info.modem_present) s.widget(_modem, selected); } @@ -94,21 +93,20 @@ struct Sculpt::Network_widget : Widget Wifi_connection const &wifi_connection, Nic_state const &nic_state, Blind_wpa_passphrase const &wpa_passphrase, - Wlan_config_policy const &wlan_config_policy, - Pci_info const &pci_info) + Wlan_config_policy const &wlan_config_policy) : - _nic_target(nic_target), _nic_state(nic_state), _pci_info(pci_info), + _nic_target(nic_target), _nic_state(nic_state), _ap_selector(Id { "aps" }, access_points, wifi_connection, wlan_config_policy, wpa_passphrase) { } - void view(Scope &s) const + void view(Scope &s, Board_info const &board_info) const { s.sub_scope([&] (Scope &s) { s.sub_scope(35); - s.widget(_target_selector, _nic_target, _pci_info); + s.widget(_target_selector, _nic_target, board_info); if (_nic_target.wifi() || _nic_target.wired() || _nic_target.modem()) {