pc/wifi: avoid late frontend construction

Dissolve unintentional dependency between wifi management layer and the
control interface of the supplicant.

Issue #4537.
This commit is contained in:
Josef Söntgen 2022-06-23 17:07:10 +02:00 committed by Christian Helmuth
parent 9393c0136c
commit 10451652f4
2 changed files with 9 additions and 28 deletions

View File

@ -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_ */

View File

@ -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;
}