From 10451652f429ef2ce0394bda16b2f1ecd792f02b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Thu, 23 Jun 2022 17:07:10 +0200 Subject: [PATCH] pc/wifi: avoid late frontend construction Dissolve unintentional dependency between wifi management layer and the control interface of the supplicant. Issue #4537. --- repos/pc/src/drivers/wifi/pc/frontend.h | 12 +++--------- repos/pc/src/drivers/wifi/pc/main.cc | 25 ++++++------------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/repos/pc/src/drivers/wifi/pc/frontend.h b/repos/pc/src/drivers/wifi/pc/frontend.h index aecdb3d746..5382174798 100644 --- a/repos/pc/src/drivers/wifi/pc/frontend.h +++ b/repos/pc/src/drivers/wifi/pc/frontend.h @@ -333,7 +333,7 @@ struct Wifi::Frontend /* remaining stuff */ - Msg_buffer _msg { }; + Msg_buffer &_msg; Genode::Blockade _notify_blockade { }; @@ -1537,9 +1537,10 @@ struct Wifi::Frontend /** * Constructor */ - Frontend(Genode::Env &env) + Frontend(Genode::Env &env, Msg_buffer &msg_buffer) : _ap_allocator(env.ram(), env.rm()), + _msg(msg_buffer), _rfkill_handler(env.ep(), *this, &Wifi::Frontend::_handle_rfkill), _config_rom(env, "wifi_config"), _config_sigh(env.ep(), *this, &Wifi::Frontend::_handle_config_update), @@ -1622,13 +1623,6 @@ struct Wifi::Frontend * Used by the wpa_supplicant to wait for the front end. */ void block_for_processing() { _notify_lock_lock(); } - - /** - * Return shared memory message buffer - * - * Used for communication between front end and wpa_supplicant. - */ - Msg_buffer &msg_buffer() { return _msg; } }; #endif /* _WIFI_FRONTEND_H_ */ diff --git a/repos/pc/src/drivers/wifi/pc/main.cc b/repos/pc/src/drivers/wifi/pc/main.cc index 75089e190f..4907315cef 100644 --- a/repos/pc/src/drivers/wifi/pc/main.cc +++ b/repos/pc/src/drivers/wifi/pc/main.cc @@ -28,7 +28,7 @@ using namespace Genode; - +static Msg_buffer _wifi_msg_buffer; static Wifi::Frontend *_wifi_frontend = nullptr; @@ -100,6 +100,10 @@ struct Main Main(Genode::Env &env) : env(env) { + _frontend.construct(env, _wifi_msg_buffer); + _wifi_frontend = &*_frontend; + wifi_set_rfkill_sigh(_wifi_frontend->rfkill_sigh()); + _wpa.construct(env, _wpa_startup_blockade); wifi_init(env, _wpa_startup_blockade); @@ -116,24 +120,7 @@ static Main *_main; */ void *wifi_get_buffer(void) { - /* - * XXX creating the front end at this point is merely a hack - * to post-pone its creation - */ - if (_wifi_frontend) - return &_wifi_frontend->msg_buffer(); - - Libc::with_libc([&] () { - - if (_main->_frontend.constructed()) - return; - - _main->_frontend.construct(_main->env); - _wifi_frontend = &*_main->_frontend; - wifi_set_rfkill_sigh(_wifi_frontend->rfkill_sigh()); - }); - - return &_wifi_frontend->msg_buffer(); + return &_wifi_msg_buffer; }