From 3b365422121e21c2697ba01e9a32f1ac82b5bddf Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 4 Mar 2019 13:53:40 +0100 Subject: [PATCH] vbox5: use nitpicker session Issue #3196 --- .../recipes/pkg/vbox5-nova-sculpt/archives | 3 - .../recipes/pkg/vbox5-nova-sculpt/runtime | 1 - .../recipes/raw/vbox5-nova-sculpt/init.config | 14 +- repos/ports/run/vbox5_genode_usb_hid.run | 41 +++++- repos/ports/run/vbox_share.inc | 36 +++++ repos/ports/run/vbox_win.inc | 138 +++++++----------- repos/ports/run/virtualbox.run | 70 +++------ repos/ports/run/virtualbox_auto.inc | 16 +- .../ports/src/virtualbox5/frontend/console.cc | 7 +- .../ports/src/virtualbox5/frontend/console.h | 15 +- repos/ports/src/virtualbox5/frontend/fb.h | 69 ++++++--- repos/ports/src/virtualbox5/frontend/main.cc | 2 +- 12 files changed, 226 insertions(+), 186 deletions(-) diff --git a/repos/ports/recipes/pkg/vbox5-nova-sculpt/archives b/repos/ports/recipes/pkg/vbox5-nova-sculpt/archives index 400870872..dbc6d6912 100755 --- a/repos/ports/recipes/pkg/vbox5-nova-sculpt/archives +++ b/repos/ports/recipes/pkg/vbox5-nova-sculpt/archives @@ -3,11 +3,8 @@ _/src/vbox5-nova _/src/base-nova _/src/libc _/src/init -_/src/nit_fb -_/src/libc _/src/posix _/src/zlib -_/src/nit_fb _/src/libiconv _/src/stdcxx _/src/vfs diff --git a/repos/ports/recipes/pkg/vbox5-nova-sculpt/runtime b/repos/ports/recipes/pkg/vbox5-nova-sculpt/runtime index 43aac9abe..f38df30dd 100755 --- a/repos/ports/recipes/pkg/vbox5-nova-sculpt/runtime +++ b/repos/ports/recipes/pkg/vbox5-nova-sculpt/runtime @@ -19,7 +19,6 @@ - diff --git a/repos/ports/recipes/raw/vbox5-nova-sculpt/init.config b/repos/ports/recipes/raw/vbox5-nova-sculpt/init.config index ad1c2a09d..229afa994 100755 --- a/repos/ports/recipes/raw/vbox5-nova-sculpt/init.config +++ b/repos/ports/recipes/raw/vbox5-nova-sculpt/init.config @@ -30,18 +30,6 @@ - - - - - - - - - - - - @@ -69,7 +57,7 @@ - + diff --git a/repos/ports/run/vbox5_genode_usb_hid.run b/repos/ports/run/vbox5_genode_usb_hid.run index d801135e0..07882d9a5 100644 --- a/repos/ports/run/vbox5_genode_usb_hid.run +++ b/repos/ports/run/vbox5_genode_usb_hid.run @@ -14,7 +14,6 @@ if { [have_include "power_on/qemu"] || ![have_spec nova] || ![have_spec x86_64]} } set build_components { - core init timer drivers/framebuffer drivers/input drivers/usb @@ -37,6 +36,11 @@ build $build_components create_boot_directory +import_from_depot [depot_user]/src/[base_src] \ + [depot_user]/src/init \ + [depot_user]/src/nitpicker + + set config { @@ -142,6 +146,39 @@ append config { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -153,6 +190,8 @@ append config { + + diff --git a/repos/ports/run/vbox_share.inc b/repos/ports/run/vbox_share.inc index 8cd756c29..70d4ee9d9 100644 --- a/repos/ports/run/vbox_share.inc +++ b/repos/ports/run/vbox_share.inc @@ -196,6 +196,8 @@ set config_of_app { + + @@ -224,6 +226,40 @@ append config_of_app { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } append_if [expr $use_vbox5] config_of_app " " diff --git a/repos/ports/run/vbox_win.inc b/repos/ports/run/vbox_win.inc index e6ab19f9d..0721e07f0 100644 --- a/repos/ports/run/vbox_win.inc +++ b/repos/ports/run/vbox_win.inc @@ -27,9 +27,6 @@ set build_components { server/input_merger drivers/nic drivers/audio - server/nitpicker - app/pointer - server/nit_fb server/report_rom server/dynamic_rom } @@ -38,19 +35,13 @@ set boot_modules { input_merger nic_drv audio_drv - nitpicker - pointer - nit_fb report_rom dynamic_rom } -set virtualbox_binary "virtualbox-rem" set virtualbox5_binary "virtualbox5-rem" -if {[have_spec muen]} { set virtualbox_binary "virtualbox-muen" } if {[have_spec nova]} { - set virtualbox_binary "virtualbox-nova" set virtualbox5_binary "virtualbox5-nova" } @@ -124,26 +115,17 @@ append config_of_app { - + + + - - - - - - - - - - - @@ -151,79 +133,33 @@ append config_of_app { - } - -append config_of_app { + } -for { set i 1} { $i <= $use_vms } { incr i} { - append config_of_app " - " - append config_of_app { - - - - - - } - - append config_of_app " - " - - append config_of_app { - } - - append config_of_app " - " - +if { $use_vms > 1 } { append config_of_app { + + + + + + - + } } append config_of_app { - + - } - -for { set i 1} { $i <= $use_vms } { incr i} { - append config_of_app " - " - - append config_of_app { - } - - if { $use_vms > 1 } { - append config_of_app " - " - } else { - append config_of_app { - } - } - - append config_of_app { - - } - - append_if [expr !$use_rumpfs] config_of_app { - - - - } - - append config_of_app { - } -} - -append config_of_app { + @@ -234,6 +170,40 @@ append config_of_app { + + + + + + + + + + + + + + + } + +append_if [expr !$use_rumpfs] config_of_app { + + + + + + + + + + + + + + } + +append config_of_app { + @@ -284,6 +254,9 @@ for { set i 1} { $i <= $use_vms } { incr i} { } + append_if [expr ($use_vms > 1)] config_of_app { + } + append_if [expr $use_ram_fs] config_of_app { } @@ -291,16 +264,11 @@ for { set i 1} { $i <= $use_vms } { incr i} { } append_if [expr !$use_rumpfs] config_of_app { } - append config_of_app " - - - - shape\"/> - " append config_of_app { + - + } diff --git a/repos/ports/run/virtualbox.run b/repos/ports/run/virtualbox.run index 63571f70d..f061d390c 100644 --- a/repos/ports/run/virtualbox.run +++ b/repos/ports/run/virtualbox.run @@ -11,8 +11,8 @@ set use_gui 0 set use_bridge [expr $use_net && $use_gui] set build_components { - core init timer drivers/framebuffer + server/report_rom } if {$use_vbox5} { @@ -21,6 +21,12 @@ if {$use_vbox5} { if {[have_spec nova]} { set virtualbox_binary "virtualbox5-nova" } } +create_boot_directory + +import_from_depot [depot_user]/src/[base_src] \ + [depot_user]/src/init \ + [depot_user]/src/nitpicker + source ${genode_dir}/repos/base/run/platform_drv.inc # override defaults of platform_drv.inc proc platform_drv_priority {} { return { priority="-1"} } @@ -33,17 +39,10 @@ lappend_if [have_spec x86] build_components drivers/rtc lappend_if [expr $use_net] build_components drivers/nic lappend_if [expr $use_bridge] build_components server/nic_bridge -lappend_if [expr $use_gui] build_components server/report_rom -lappend_if [expr $use_gui] build_components server/nitpicker -lappend_if [expr $use_gui] build_components server/nit_fb -lappend_if [expr $use_gui] build_components app/pointer - append_platform_drv_build_components build $build_components -create_boot_directory - set config { @@ -98,6 +97,7 @@ append_if [have_spec framebuffer] config { + } append_if [have_spec sdl] config { @@ -145,7 +145,7 @@ append_if [expr $use_bridge] config { } -append_if [expr $use_gui] config { +append config { @@ -162,12 +162,12 @@ append_if [expr $use_gui] config { } -append_if [expr ($use_gui && $use_ps2)] config { +append_if [expr $use_ps2] config { } -append_if [expr ($use_gui && $use_usb)] config { +append_if [expr $use_usb] config { } -append_if [expr $use_gui] config { +append config { @@ -183,6 +183,7 @@ append_if [expr $use_gui] config { + @@ -190,39 +191,11 @@ append_if [expr $use_gui] config { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + } +append_if [expr $use_gui] config { } + append_if [expr $use_gui] config " " append_if [expr $use_gui] config { @@ -269,13 +242,11 @@ append config { append_if [expr $use_bridge] config { } -append_if [expr $use_gui] config { +append config { - } - -append config { + @@ -286,7 +257,7 @@ install_config $config exec cp ${genode_dir}/repos/ports/run/test.vbox bin/. -set boot_modules { core ld.lib.so init timer test.iso test.vbox } +set boot_modules { test.iso test.vbox } append boot_modules $virtualbox_binary @@ -298,9 +269,6 @@ lappend_if [have_spec linux] boot_modules fb_sdl lappend_if [have_spec x86] boot_modules rtc_drv lappend_if [expr $use_gui] boot_modules report_rom -lappend_if [expr $use_gui] boot_modules nitpicker -lappend_if [expr $use_gui] boot_modules nit_fb -lappend_if [expr $use_gui] boot_modules pointer append boot_modules { ld.lib.so libc.lib.so vfs.lib.so libm.lib.so libc_pipe.lib.so diff --git a/repos/ports/run/virtualbox_auto.inc b/repos/ports/run/virtualbox_auto.inc index 2add1bffa..5936ba005 100644 --- a/repos/ports/run/virtualbox_auto.inc +++ b/repos/ports/run/virtualbox_auto.inc @@ -27,8 +27,17 @@ if {[have_spec nova]} { proc kernel_output { } { return "novga logmem" } } +create_boot_directory + +import_from_depot [depot_user]/src/[base_src] \ + [depot_user]/src/init \ + [depot_user]/src/nitpicker + +if {$use_vms > 1} { + import_from_depot [depot_user]/pkg/themed_wm +} + append build_components { - core init timer server/part_block server/fs_rom drivers/ahci @@ -55,8 +64,6 @@ append_platform_drv_build_components build $build_components -create_boot_directory - set config { } @@ -363,9 +370,8 @@ append config { install_config $config append boot_modules { - core init timer part_block ahci_drv fs_rom - ld.lib.so libc.lib.so vfs.lib.so libm.lib.so + libc.lib.so vfs.lib.so libm.lib.so libc_pipe.lib.so libc_terminal.lib.so libiconv.lib.so stdcxx.lib.so qemu-usb.lib.so diff --git a/repos/ports/src/virtualbox5/frontend/console.cc b/repos/ports/src/virtualbox5/frontend/console.cc index 89e0acb3e..2344f15fa 100644 --- a/repos/ports/src/virtualbox5/frontend/console.cc +++ b/repos/ports/src/virtualbox5/frontend/console.cc @@ -108,7 +108,7 @@ void GenodeConsole::update_video_mode() if (!fb) return; - if ((fb->w() == 0) && (fb->h() == 0)) { + if ((fb->w() <= 1) && (fb->h() <= 1)) { /* interpret a size of 0x0 as indication to quit VirtualBox */ if (PowerButton() != S_OK) Genode::error("ACPI shutdown failed"); @@ -281,7 +281,7 @@ void GenodeConsole::handle_mode_change() Genodefb *fb = dynamic_cast(pFramebuffer); - fb->update_mode(); + fb->update_mode(_nitpicker.mode()); update_video_mode(); } @@ -330,8 +330,7 @@ void GenodeConsole::init_backends(IKeyboard * gKeyboard, IMouse * gMouse) HRESULT rc = i_getDisplay()->QueryFramebuffer(0, &pFramebuffer); Assert(SUCCEEDED(rc) && pFramebuffer); - Genodefb *fb = dynamic_cast(pFramebuffer); - fb->mode_sigh(_mode_change_signal_dispatcher); + _nitpicker.mode_sigh(_mode_change_signal_dispatcher); handle_mode_change(); } diff --git a/repos/ports/src/virtualbox5/frontend/console.h b/repos/ports/src/virtualbox5/frontend/console.h index b475ac71f..a8e5917b8 100644 --- a/repos/ports/src/virtualbox5/frontend/console.h +++ b/repos/ports/src/virtualbox5/frontend/console.h @@ -14,11 +14,14 @@ /* Genode includes */ #include +#include +#include #include #include #include -#include -#include +#define Framebuffer Fb_Genode +#include +#undef Framebuffer #include #include #include @@ -111,7 +114,8 @@ class GenodeConsole : public Console { private: - Input::Connection _input; + Nitpicker::Connection _nitpicker; + Input::Session_client &_input; unsigned _ax, _ay; bool _last_received_motion_event_was_absolute; Report::Connection _shape_report_connection; @@ -141,7 +145,8 @@ class GenodeConsole : public Console { GenodeConsole() : Console(), - _input(genode_env()), + _nitpicker(genode_env()), + _input(*_nitpicker.input()), _ax(0), _ay(0), _last_received_motion_event_was_absolute(false), _shape_report_connection(genode_env(), "shape", @@ -172,6 +177,8 @@ class GenodeConsole : public Console { } } + Nitpicker::Connection &nitpicker() { return _nitpicker; } + void init_clipboard(); void init_backends(IKeyboard * gKeyboard, IMouse * gMouse); diff --git a/repos/ports/src/virtualbox5/frontend/fb.h b/repos/ports/src/virtualbox5/frontend/fb.h index 81df159af..fc9c7cec0 100644 --- a/repos/ports/src/virtualbox5/frontend/fb.h +++ b/repos/ports/src/virtualbox5/frontend/fb.h @@ -14,7 +14,7 @@ /* Genode includes */ #define Framebuffer Fb_Genode #include -#include +#include #undef Framebuffer #include @@ -26,20 +26,24 @@ #include "Global.h" #include "VirtualBoxBase.h" +typedef Nitpicker::Session::View_handle View_handle; + class Genodefb : VBOX_SCRIPTABLE_IMPL(IFramebuffer) { private: Genode::Env &_env; - Fb_Genode::Connection _fb; + Nitpicker::Connection &_nitpicker; + Fb_Genode::Session &_fb; + View_handle _view; + + /* The mode at the time when the mode change signal was received */ + Fb_Genode::Mode _next_fb_mode { 1024, 768, Fb_Genode::Mode::RGB565 }; /* The mode matching the currently attached dataspace */ Fb_Genode::Mode _fb_mode; - /* The mode at the time when the mode change signal was received */ - Fb_Genode::Mode _next_fb_mode; - /* * The mode currently used by the VM. Can be smaller than the * framebuffer mode. @@ -56,14 +60,42 @@ class Genodefb : _fb.refresh(0, 0, _virtual_fb_mode.width(), _virtual_fb_mode.height()); } + void _adjust_buffer() + { + _nitpicker.buffer(Fb_Genode::Mode(_next_fb_mode.width(), _next_fb_mode.height(), + Fb_Genode::Mode::RGB565), false); + + typedef Nitpicker::Session::Command Command; + + Nitpicker::Rect rect(Nitpicker::Point(0, 0), + Nitpicker::Area(_next_fb_mode.width(), _next_fb_mode.height())); + + _nitpicker.enqueue(_view, rect); + _nitpicker.execute(); + } + + Fb_Genode::Mode _initial_setup() + { + typedef Nitpicker::Session::Command Command; + + _view = _nitpicker.create_view(); + + _adjust_buffer(); + + _nitpicker.enqueue(_view, View_handle()); + _nitpicker.execute(); + + return _next_fb_mode; + } + public: - Genodefb (Genode::Env &env) + Genodefb (Genode::Env &env, Nitpicker::Connection &nitpicker) : _env(env), - _fb(env, Fb_Genode::Mode(0, 0, Fb_Genode::Mode::INVALID)), - _fb_mode(_fb.mode()), - _next_fb_mode(_fb_mode), + _nitpicker(nitpicker), + _fb(*nitpicker.framebuffer()), + _fb_mode(_initial_setup()), _virtual_fb_mode(_fb_mode), _fb_base(env.rm().attach(_fb.dataspace())) { @@ -75,15 +107,10 @@ class Genodefb : int w() const { return _next_fb_mode.width(); } int h() const { return _next_fb_mode.height(); } - void mode_sigh(Genode::Signal_context_capability sigh) - { - _fb.mode_sigh(sigh); - } - - void update_mode() + void update_mode(Fb_Genode::Mode mode) { Lock(); - _next_fb_mode = _fb.mode(); + _next_fb_mode = mode; Unlock(); } @@ -111,7 +138,9 @@ class Genodefb : Genode::log("fb resize : [", screen, "] ", _virtual_fb_mode.width(), "x", _virtual_fb_mode.height(), " -> ", - w, "x", h); + w, "x", h, + " (host: ", _next_fb_mode.width(), "x", + _next_fb_mode.height(), ")"); if ((w < (ULONG)_next_fb_mode.width()) || (h < (ULONG)_next_fb_mode.height())) { @@ -125,6 +154,8 @@ class Genodefb : _env.rm().detach(_fb_base); + _adjust_buffer(); + _fb_base = _env.rm().attach(_fb.dataspace()); result = S_OK; @@ -133,7 +164,9 @@ class Genodefb : Genode::log("fb resize : [", screen, "] ", _virtual_fb_mode.width(), "x", _virtual_fb_mode.height(), " -> ", - w, "x", h, " ignored"); + w, "x", h, " ignored" + " (host: ", _next_fb_mode.width(), "x", + _next_fb_mode.height(), ")"); Unlock(); diff --git a/repos/ports/src/virtualbox5/frontend/main.cc b/repos/ports/src/virtualbox5/frontend/main.cc index 299f328fb..ed4b249ac 100644 --- a/repos/ports/src/virtualbox5/frontend/main.cc +++ b/repos/ports/src/virtualbox5/frontend/main.cc @@ -169,7 +169,7 @@ HRESULT setupmachine(Genode::Env &env) for (unsigned uScreenId = 0; uScreenId < cMonitors; uScreenId++) { - Genodefb *fb = new Genodefb(env); + Genodefb *fb = new Genodefb(env, genodeConsole->nitpicker()); HRESULT rc = display->AttachFramebuffer(uScreenId, fb, gaFramebufferId[uScreenId].asOutParam()); if (FAILED(rc)) return rc;