diff --git a/repos/gems/src/app/sculpt_manager/main.cc b/repos/gems/src/app/sculpt_manager/main.cc index d64200a412..3b91d301c7 100644 --- a/repos/gems/src/app/sculpt_manager/main.cc +++ b/repos/gems/src/app/sculpt_manager/main.cc @@ -84,6 +84,31 @@ struct Sculpt::Main : Input_event_handler, void _handle_nitpicker_hover(); + /********************** + ** Device discovery ** + **********************/ + + Attached_rom_dataspace _pci_devices { _env, "report -> drivers/pci_devices" }; + + Signal_handler
_pci_devices_handler { + _env.ep(), *this, &Main::_handle_pci_devices }; + + Pci_info _pci_info { }; + + void _handle_pci_devices() + { + _pci_devices.update(); + _pci_info.wifi_present = false; + + _pci_devices.xml().for_each_sub_node("device", [&] (Xml_node device) { + + /* detect Intel Wireless card */ + if (device.attribute_value("class_code", 0UL) == 0x28000) + _pci_info.wifi_present = true; + }); + } + + /*************************** ** Configuration loading ** ***************************/ @@ -115,7 +140,7 @@ struct Sculpt::Main : Input_event_handler, } - Network _network { _env, _heap, *this, *this, *this }; + Network _network { _env, _heap, *this, *this, *this, _pci_info }; /************ @@ -323,6 +348,7 @@ struct Sculpt::Main : Input_event_handler, _update_state_rom.sigh(_update_state_handler); _nitpicker_hover .sigh(_nitpicker_hover_handler); _hover_rom .sigh(_hover_handler); + _pci_devices .sigh(_pci_devices_handler); /* * Generate initial configurations @@ -334,6 +360,7 @@ struct Sculpt::Main : Input_event_handler, */ _storage.handle_storage_devices_update(); _deploy.handle_deploy(); + _handle_pci_devices(); generate_runtime_config(); generate_dialog(); diff --git a/repos/gems/src/app/sculpt_manager/model/pci_info.h b/repos/gems/src/app/sculpt_manager/model/pci_info.h new file mode 100644 index 0000000000..e36b59e6f7 --- /dev/null +++ b/repos/gems/src/app/sculpt_manager/model/pci_info.h @@ -0,0 +1,26 @@ +/* + * \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; +}; + +#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 a2dd9bee5e..03257527a2 100644 --- a/repos/gems/src/app/sculpt_manager/network.h +++ b/repos/gems/src/app/sculpt_manager/network.h @@ -40,6 +40,7 @@ struct Sculpt::Network : Network_dialog::Action Runtime_config_generator &_runtime_config_generator; Runtime_info const &_runtime_info; + Pci_info const &_pci_info; Nic_target _nic_target { }; Nic_state _nic_state { }; @@ -94,7 +95,8 @@ struct Sculpt::Network : Network_dialog::Action Network_dialog dialog { _env, _dialog_generator, _nic_target, _access_points, - _wifi_connection, _nic_state, wpa_passphrase, _wlan_config_policy }; + _wifi_connection, _nic_state, wpa_passphrase, _wlan_config_policy, + _pci_info }; Managed_config _wlan_config { _env, "selected_network", "wlan", *this, &Network::_handle_wlan_config }; @@ -183,11 +185,11 @@ struct Sculpt::Network : Network_dialog::Action Network(Env &env, Allocator &alloc, Dialog::Generator &dialog_generator, Runtime_config_generator &runtime_config_generator, - Runtime_info const &runtime_info) + Runtime_info const &runtime_info, Pci_info const &pci_info) : _env(env), _alloc(alloc), _dialog_generator(dialog_generator), _runtime_config_generator(runtime_config_generator), - _runtime_info(runtime_info) + _runtime_info(runtime_info), _pci_info(pci_info) { _generate_nic_router_config(); diff --git a/repos/gems/src/app/sculpt_manager/view/network_dialog.cc b/repos/gems/src/app/sculpt_manager/view/network_dialog.cc index 0fc6b9ac6a..d578163a8e 100644 --- a/repos/gems/src/app/sculpt_manager/view/network_dialog.cc +++ b/repos/gems/src/app/sculpt_manager/view/network_dialog.cc @@ -224,7 +224,8 @@ void Sculpt::Network_dialog::generate(Xml_generator &xml) const gen_nic_button("wired", Nic_target::WIRED, "Wired"); if (_nic_target.managed() || _nic_target.wifi()) - gen_nic_button("wifi", Nic_target::WIFI, "Wifi"); + if (_pci_info.wifi_present) + gen_nic_button("wifi", Nic_target::WIFI, "Wifi"); }); if (_nic_target.type == Nic_target::WIFI || _nic_target.type == Nic_target::WIRED) { diff --git a/repos/gems/src/app/sculpt_manager/view/network_dialog.h b/repos/gems/src/app/sculpt_manager/view/network_dialog.h index d8d90aa443..66704db18f 100644 --- a/repos/gems/src/app/sculpt_manager/view/network_dialog.h +++ b/repos/gems/src/app/sculpt_manager/view/network_dialog.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,7 @@ struct Sculpt::Network_dialog : Dialog Nic_state const &_nic_state; Blind_wpa_passphrase const &_wpa_passphrase; Wlan_config_policy const &_wlan_config_policy; + Pci_info const &_pci_info; Hoverable_item _nic_item { }; Selectable_item _ap_item { }; @@ -101,12 +103,14 @@ struct Sculpt::Network_dialog : Dialog Wifi_connection const &wifi_connection, Nic_state const &nic_state, Blind_wpa_passphrase const &wpa_passphrase, - Wlan_config_policy const &wlan_config_policy) + Wlan_config_policy const &wlan_config_policy, + Pci_info const &pci_info) : _env(env), _dialog_generator(dialog_generator), _nic_target(nic_target), _access_points(access_points), _wifi_connection(wifi_connection), _nic_state(nic_state), - _wpa_passphrase(wpa_passphrase), _wlan_config_policy(wlan_config_policy) + _wpa_passphrase(wpa_passphrase), _wlan_config_policy(wlan_config_policy), + _pci_info(pci_info) { } };