vbox: remove signal receiver usage for fb & input

avoids deadlocks due to new libc and vfs usage
This commit is contained in:
Alexander Boettcher 2017-02-20 13:44:12 +01:00 committed by Christian Helmuth
parent 328da2975f
commit 3226dd0649
6 changed files with 66 additions and 94 deletions

View File

@ -179,7 +179,7 @@ void GenodeConsole::update_video_mode()
32); 32);
} }
void GenodeConsole::handle_input(unsigned) void GenodeConsole::handle_input()
{ {
static LONG64 mt_events [64]; static LONG64 mt_events [64];
unsigned mt_number = 0; unsigned mt_number = 0;
@ -329,7 +329,7 @@ void GenodeConsole::handle_input(unsigned)
RTTimeMilliTS()); RTTimeMilliTS());
} }
void GenodeConsole::handle_mode_change(unsigned) void GenodeConsole::handle_mode_change()
{ {
Display *d = getDisplay(); Display *d = getDisplay();
Genodefb *fb = dynamic_cast<Genodefb *>(d->getFramebuffer()); Genodefb *fb = dynamic_cast<Genodefb *>(d->getFramebuffer());
@ -365,7 +365,7 @@ void GenodeConsole::init_clipboard()
} }
} }
void GenodeConsole::handle_cb_rom_change(unsigned) void GenodeConsole::handle_cb_rom_change()
{ {
if (!_clipboard_rom) if (!_clipboard_rom)
return; return;
@ -373,7 +373,7 @@ void GenodeConsole::handle_cb_rom_change(unsigned)
vboxClipboardSync(nullptr); vboxClipboardSync(nullptr);
} }
void GenodeConsole::event_loop(IKeyboard * gKeyboard, IMouse * gMouse) void GenodeConsole::init_backends(IKeyboard * gKeyboard, IMouse * gMouse)
{ {
_vbox_keyboard = gKeyboard; _vbox_keyboard = gKeyboard;
_vbox_mouse = gMouse; _vbox_mouse = gMouse;
@ -383,16 +383,6 @@ void GenodeConsole::event_loop(IKeyboard * gKeyboard, IMouse * gMouse)
Genodefb *fb = dynamic_cast<Genodefb *>(d->getFramebuffer()); Genodefb *fb = dynamic_cast<Genodefb *>(d->getFramebuffer());
fb->mode_sigh(_mode_change_signal_dispatcher); fb->mode_sigh(_mode_change_signal_dispatcher);
for (;;) {
Genode::Signal sig = _receiver.wait_for_signal();
Genode::Signal_dispatcher_base *dispatcher =
dynamic_cast<Genode::Signal_dispatcher_base *>(sig.context());
if (dispatcher)
dispatcher->dispatch(sig.num());
}
} }
void GenodeConsole::onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, void GenodeConsole::onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative,

View File

@ -111,20 +111,19 @@ class GenodeConsole : public Console {
private: private:
Input::Connection _input; Input::Connection _input;
Genode::Signal_receiver _receiver; unsigned _ax, _ay;
unsigned _ax, _ay; bool _last_received_motion_event_was_absolute;
bool _last_received_motion_event_was_absolute; Report::Connection _shape_report_connection;
Report::Connection _shape_report_connection; Genode::Attached_dataspace _shape_report_ds;
Genode::Attached_dataspace _shape_report_ds; Vbox_pointer::Shape_report *_shape_report;
Vbox_pointer::Shape_report *_shape_report; Genode::Reporter *_clipboard_reporter;
Genode::Reporter *_clipboard_reporter; Genode::Attached_rom_dataspace *_clipboard_rom;
Genode::Attached_rom_dataspace *_clipboard_rom; IKeyboard *_vbox_keyboard;
IKeyboard *_vbox_keyboard; IMouse *_vbox_mouse;
IMouse *_vbox_mouse; Genode::Signal_handler<GenodeConsole> _input_signal_dispatcher;
Genode::Signal_dispatcher<GenodeConsole> _input_signal_dispatcher; Genode::Signal_handler<GenodeConsole> _mode_change_signal_dispatcher;
Genode::Signal_dispatcher<GenodeConsole> _mode_change_signal_dispatcher; Genode::Signal_handler<GenodeConsole> _clipboard_signal_dispatcher;
Genode::Signal_dispatcher<GenodeConsole> _clipboard_signal_dispatcher;
bool _key_status[Input::KEY_MAX + 1]; bool _key_status[Input::KEY_MAX + 1];
@ -151,9 +150,9 @@ class GenodeConsole : public Console {
_clipboard_rom(nullptr), _clipboard_rom(nullptr),
_vbox_keyboard(0), _vbox_keyboard(0),
_vbox_mouse(0), _vbox_mouse(0),
_input_signal_dispatcher(_receiver, *this, &GenodeConsole::handle_input), _input_signal_dispatcher(genode_env().ep(), *this, &GenodeConsole::handle_input),
_mode_change_signal_dispatcher(_receiver, *this, &GenodeConsole::handle_mode_change), _mode_change_signal_dispatcher(genode_env().ep(), *this, &GenodeConsole::handle_mode_change),
_clipboard_signal_dispatcher(_receiver, *this, &GenodeConsole::handle_cb_rom_change) _clipboard_signal_dispatcher(genode_env().ep(), *this, &GenodeConsole::handle_cb_rom_change)
{ {
for (unsigned i = 0; i <= Input::KEY_MAX; i++) for (unsigned i = 0; i <= Input::KEY_MAX; i++)
_key_status[i] = 0; _key_status[i] = 0;
@ -163,7 +162,7 @@ class GenodeConsole : public Console {
void init_clipboard(); void init_clipboard();
void event_loop(IKeyboard * gKeyboard, IMouse * gMouse); void init_backends(IKeyboard * gKeyboard, IMouse * gMouse);
void onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, void onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative,
BOOL supportsMT, BOOL needsHostCursor); BOOL supportsMT, BOOL needsHostCursor);
@ -229,7 +228,7 @@ class GenodeConsole : public Console {
void update_video_mode(); void update_video_mode();
void handle_input(unsigned); void handle_input();
void handle_mode_change(unsigned); void handle_mode_change();
void handle_cb_rom_change(unsigned); void handle_cb_rom_change();
}; };

View File

@ -96,13 +96,13 @@ HRESULT setupmachine(Genode::Env &env)
static com::Utf8Str vm_name(c_vbox_vmname); static com::Utf8Str vm_name(c_vbox_vmname);
/* Machine object */ /* Machine object */
ComObjPtr<Machine> machine; static ComObjPtr<Machine> machine;
rc = machine.createObject(); rc = machine.createObject();
if (FAILED(rc)) if (FAILED(rc))
return rc; return rc;
/* Virtualbox object */ /* Virtualbox object */
ComObjPtr<VirtualBox> virtualbox; static ComObjPtr<VirtualBox> virtualbox;
rc = virtualbox.createObject(); rc = virtualbox.createObject();
if (FAILED(rc)) if (FAILED(rc))
return rc; return rc;
@ -120,7 +120,7 @@ HRESULT setupmachine(Genode::Env &env)
return rc; return rc;
// open a session // open a session
ComObjPtr<Session> session; static ComObjPtr<Session> session;
rc = session.createObject(); rc = session.createObject();
if (FAILED(rc)) if (FAILED(rc))
return rc; return rc;
@ -130,17 +130,17 @@ HRESULT setupmachine(Genode::Env &env)
return rc; return rc;
/* Console object */ /* Console object */
ComPtr<IConsole> gConsole; static ComPtr<IConsole> gConsole;
rc = session->COMGETTER(Console)(gConsole.asOutParam()); rc = session->COMGETTER(Console)(gConsole.asOutParam());
/* handle input of Genode and forward it to VMM layer */ /* handle input of Genode and forward it to VMM layer */
ComPtr<GenodeConsole> genodeConsole = gConsole; static ComPtr<GenodeConsole> genodeConsole = gConsole;
RTLogPrintf("genodeConsole = %p\n", genodeConsole); RTLogPrintf("genodeConsole = %p\n", genodeConsole);
genodeConsole->init_clipboard(); genodeConsole->init_clipboard();
/* Display object */ /* Display object */
ComPtr<IDisplay> display; static ComPtr<IDisplay> display;
rc = gConsole->COMGETTER(Display)(display.asOutParam()); rc = gConsole->COMGETTER(Display)(display.asOutParam());
if (FAILED(rc)) if (FAILED(rc))
return rc; return rc;
@ -182,16 +182,15 @@ HRESULT setupmachine(Genode::Env &env)
Assert (&*gMouse); Assert (&*gMouse);
/* request keyboard object */ /* request keyboard object */
ComPtr<IKeyboard> gKeyboard; static ComPtr<IKeyboard> gKeyboard;
rc = gConsole->COMGETTER(Keyboard)(gKeyboard.asOutParam()); rc = gConsole->COMGETTER(Keyboard)(gKeyboard.asOutParam());
if (FAILED(rc)) if (FAILED(rc))
return rc; return rc;
Assert (&*gKeyboard); Assert (&*gKeyboard);
genodeConsole->event_loop(gKeyboard, gMouse); genodeConsole->init_backends(gKeyboard, gMouse);
Assert(!"return not expected"); return rc;
return E_FAIL;
} }
@ -252,5 +251,4 @@ void Libc::Component::construct(Libc::Env &env)
throw -2; throw -2;
} }
}); });
Genode::error("VMM exiting ...");
} }

View File

@ -124,7 +124,7 @@ void GenodeConsole::update_video_mode()
32); 32);
} }
void GenodeConsole::handle_input(unsigned) void GenodeConsole::handle_input()
{ {
static LONG64 mt_events [64]; static LONG64 mt_events [64];
unsigned mt_number = 0; unsigned mt_number = 0;
@ -274,7 +274,7 @@ void GenodeConsole::handle_input(unsigned)
RTTimeMilliTS()); RTTimeMilliTS());
} }
void GenodeConsole::handle_mode_change(unsigned) void GenodeConsole::handle_mode_change()
{ {
IFramebuffer *pFramebuffer = NULL; IFramebuffer *pFramebuffer = NULL;
HRESULT rc = i_getDisplay()->QueryFramebuffer(0, &pFramebuffer); HRESULT rc = i_getDisplay()->QueryFramebuffer(0, &pFramebuffer);
@ -313,7 +313,7 @@ void GenodeConsole::init_clipboard()
} }
} }
void GenodeConsole::handle_cb_rom_change(unsigned) void GenodeConsole::handle_cb_rom_change()
{ {
if (!_clipboard_rom) if (!_clipboard_rom)
return; return;
@ -321,7 +321,7 @@ void GenodeConsole::handle_cb_rom_change(unsigned)
vboxClipboardSync(nullptr); vboxClipboardSync(nullptr);
} }
void GenodeConsole::event_loop(IKeyboard * gKeyboard, IMouse * gMouse) void GenodeConsole::init_backends(IKeyboard * gKeyboard, IMouse * gMouse)
{ {
_vbox_keyboard = gKeyboard; _vbox_keyboard = gKeyboard;
_vbox_mouse = gMouse; _vbox_mouse = gMouse;
@ -334,17 +334,6 @@ void GenodeConsole::event_loop(IKeyboard * gKeyboard, IMouse * gMouse)
Genodefb *fb = dynamic_cast<Genodefb *>(pFramebuffer); Genodefb *fb = dynamic_cast<Genodefb *>(pFramebuffer);
fb->mode_sigh(_mode_change_signal_dispatcher); fb->mode_sigh(_mode_change_signal_dispatcher);
for (;;) {
Genode::Signal sig = _receiver.wait_for_signal();
Genode::Signal_dispatcher_base *dispatcher =
dynamic_cast<Genode::Signal_dispatcher_base *>(sig.context());
if (dispatcher)
dispatcher->dispatch(sig.num());
}
} }
void GenodeConsole::i_onMouseCapabilityChange(BOOL supportsAbsolute, void GenodeConsole::i_onMouseCapabilityChange(BOOL supportsAbsolute,

View File

@ -111,20 +111,19 @@ class GenodeConsole : public Console {
private: private:
Input::Connection _input; Input::Connection _input;
Genode::Signal_receiver _receiver; unsigned _ax, _ay;
unsigned _ax, _ay; bool _last_received_motion_event_was_absolute;
bool _last_received_motion_event_was_absolute; Report::Connection _shape_report_connection;
Report::Connection _shape_report_connection; Genode::Attached_dataspace _shape_report_ds;
Genode::Attached_dataspace _shape_report_ds; Vbox_pointer::Shape_report *_shape_report;
Vbox_pointer::Shape_report *_shape_report; Genode::Reporter *_clipboard_reporter;
Genode::Reporter *_clipboard_reporter; Genode::Attached_rom_dataspace *_clipboard_rom;
Genode::Attached_rom_dataspace *_clipboard_rom; IKeyboard *_vbox_keyboard;
IKeyboard *_vbox_keyboard; IMouse *_vbox_mouse;
IMouse *_vbox_mouse; Genode::Signal_handler<GenodeConsole> _input_signal_dispatcher;
Genode::Signal_dispatcher<GenodeConsole> _input_signal_dispatcher; Genode::Signal_handler<GenodeConsole> _mode_change_signal_dispatcher;
Genode::Signal_dispatcher<GenodeConsole> _mode_change_signal_dispatcher; Genode::Signal_handler<GenodeConsole> _clipboard_signal_dispatcher;
Genode::Signal_dispatcher<GenodeConsole> _clipboard_signal_dispatcher;
bool _key_status[Input::KEY_MAX + 1]; bool _key_status[Input::KEY_MAX + 1];
@ -151,9 +150,9 @@ class GenodeConsole : public Console {
_clipboard_rom(nullptr), _clipboard_rom(nullptr),
_vbox_keyboard(0), _vbox_keyboard(0),
_vbox_mouse(0), _vbox_mouse(0),
_input_signal_dispatcher(_receiver, *this, &GenodeConsole::handle_input), _input_signal_dispatcher(genode_env().ep(), *this, &GenodeConsole::handle_input),
_mode_change_signal_dispatcher(_receiver, *this, &GenodeConsole::handle_mode_change), _mode_change_signal_dispatcher(genode_env().ep(), *this, &GenodeConsole::handle_mode_change),
_clipboard_signal_dispatcher(_receiver, *this, &GenodeConsole::handle_cb_rom_change) _clipboard_signal_dispatcher(genode_env().ep(), *this, &GenodeConsole::handle_cb_rom_change)
{ {
for (unsigned i = 0; i <= Input::KEY_MAX; i++) for (unsigned i = 0; i <= Input::KEY_MAX; i++)
_key_status[i] = 0; _key_status[i] = 0;
@ -163,7 +162,7 @@ class GenodeConsole : public Console {
void init_clipboard(); void init_clipboard();
void event_loop(IKeyboard * gKeyboard, IMouse * gMouse); void init_backends(IKeyboard * gKeyboard, IMouse * gMouse);
void i_onMouseCapabilityChange(BOOL supportsAbsolute, void i_onMouseCapabilityChange(BOOL supportsAbsolute,
BOOL supportsRelative, BOOL supportsMT, BOOL supportsRelative, BOOL supportsMT,
@ -229,7 +228,7 @@ class GenodeConsole : public Console {
void update_video_mode(); void update_video_mode();
void handle_input(unsigned); void handle_input();
void handle_mode_change(unsigned); void handle_mode_change();
void handle_cb_rom_change(unsigned); void handle_cb_rom_change();
}; };

View File

@ -99,13 +99,13 @@ HRESULT setupmachine(Genode::Env &env)
static com::Utf8Str vm_name(c_vbox_vmname); static com::Utf8Str vm_name(c_vbox_vmname);
/* Machine object */ /* Machine object */
ComObjPtr<Machine> machine; static ComObjPtr<Machine> machine;
rc = machine.createObject(); rc = machine.createObject();
if (FAILED(rc)) if (FAILED(rc))
return rc; return rc;
/* Virtualbox object */ /* Virtualbox object */
ComObjPtr<VirtualBox> virtualbox; static ComObjPtr<VirtualBox> virtualbox;
rc = virtualbox.createObject(); rc = virtualbox.createObject();
if (FAILED(rc)) if (FAILED(rc))
return rc; return rc;
@ -125,7 +125,7 @@ HRESULT setupmachine(Genode::Env &env)
return rc; return rc;
// open a session // open a session
ComObjPtr<Session> session; static ComObjPtr<Session> session;
rc = session.createObject(); rc = session.createObject();
if (FAILED(rc)) if (FAILED(rc))
return rc; return rc;
@ -157,17 +157,17 @@ HRESULT setupmachine(Genode::Env &env)
} }
/* Console object */ /* Console object */
ComPtr<IConsole> gConsole; static ComPtr<IConsole> gConsole;
rc = session->COMGETTER(Console)(gConsole.asOutParam()); rc = session->COMGETTER(Console)(gConsole.asOutParam());
/* handle input of Genode and forward it to VMM layer */ /* handle input of Genode and forward it to VMM layer */
ComPtr<GenodeConsole> genodeConsole = gConsole; static ComPtr<GenodeConsole> genodeConsole = gConsole;
RTLogPrintf("genodeConsole = %p\n", genodeConsole); RTLogPrintf("genodeConsole = %p\n", genodeConsole);
genodeConsole->init_clipboard(); genodeConsole->init_clipboard();
/* Display object */ /* Display object */
ComPtr<IDisplay> display; static ComPtr<IDisplay> display;
rc = gConsole->COMGETTER(Display)(display.asOutParam()); rc = gConsole->COMGETTER(Display)(display.asOutParam());
if (FAILED(rc)) if (FAILED(rc))
return rc; return rc;
@ -213,16 +213,15 @@ HRESULT setupmachine(Genode::Env &env)
Assert (&*gMouse); Assert (&*gMouse);
/* request keyboard object */ /* request keyboard object */
ComPtr<IKeyboard> gKeyboard; static ComPtr<IKeyboard> gKeyboard;
rc = gConsole->COMGETTER(Keyboard)(gKeyboard.asOutParam()); rc = gConsole->COMGETTER(Keyboard)(gKeyboard.asOutParam());
if (FAILED(rc)) if (FAILED(rc))
return rc; return rc;
Assert (&*gKeyboard); Assert (&*gKeyboard);
genodeConsole->event_loop(gKeyboard, gMouse); genodeConsole->init_backends(gKeyboard, gMouse);
Assert(!"return not expected"); return rc;
return E_FAIL;
} }
@ -284,6 +283,4 @@ void Libc::Component::construct(Libc::Env &env)
throw -2; throw -2;
} }
}); });
Genode::error("VMM exiting ...");
} }