diff --git a/run/tyrquake.run b/run/tyrquake.run index 0e7b6f3..8fbd2e1 100644 --- a/run/tyrquake.run +++ b/run/tyrquake.run @@ -12,35 +12,21 @@ if {[expr [have_include "power_on/qemu"] && !$force_qemu]} { set wget [check_installed wget] set unzip [check_installed unzip] -set build_components { - core init +create_boot_directory + +import_from_depot \ + genodelabs/src/[base_src] \ + genodelabs/pkg/[drivers_interactive_pkg] \ + genodelabs/src/init \ + genodelabs/src/report_rom \ + +build { app/retro_frontend - drivers/audio - drivers/framebuffer - drivers/input - drivers/timer libretro/tyrquake server/fb_upscale server/input_remap - server/report_rom } -source ${genode_dir}/repos/base/run/platform_drv.inc -# override default platform driver policy -proc platform_drv_policy {} { - return { - - - - } -} - -append_platform_drv_build_components - -build $build_components - -create_boot_directory - # # Generate config # @@ -60,58 +46,33 @@ append config { - } + -append_if [have_spec sdl] config { - - + + + + + + + + + + + + + - - } -append_platform_drv_config - -append_if [have_spec vesa] config { - - - - - - } - -append_if [have_spec pl11x] config { - - - - } - -append_if [have_spec ps2] config { - - - - - } - -append config { - - - - - - - - - - + @@ -119,23 +80,38 @@ append config { - - - - - + + + + + + + + + + + - - - - - - - + + + + + + + + + + + - + @@ -147,14 +123,13 @@ append config { - - - - - - - - + + + + + + + @@ -203,32 +178,18 @@ puts $variables_fd { close $variables_fd # generic modules -append boot_modules { - core init ld.lib.so - } [audio_drv_binary] { +build_boot_image { fb_upscale input_remap libc.lib.so libm.lib.so - report_rom + quake.tar retro_frontend stdcxx.lib.so - timer tyrquake_libretro.lib.so - quake.tar variables } -# platform-specific modules -lappend_if [have_spec linux] boot_modules fb_sdl -lappend_if [have_spec vesa] boot_modules fb_drv -lappend_if [have_spec ps2] boot_modules ps2_drv -lappend_if [have_spec pl11x] boot_modules fb_drv - -append_platform_drv_boot_modules - -build_boot_image $boot_modules - append qemu_args " -soundhw es1370 " run_genode_until forever diff --git a/src/app/retro_frontend/callbacks.h b/src/app/retro_frontend/callbacks.h index 8e88e64..691e395 100644 --- a/src/app/retro_frontend/callbacks.h +++ b/src/app/retro_frontend/callbacks.h @@ -277,6 +277,12 @@ bool environment_callback(unsigned cmd, void *data) return true; } + case RETRO_ENVIRONMENT_GET_USERNAME: + { + *(char const **)data = NULL; + return true; + } + case RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER: { retro_framebuffer *fb = (retro_framebuffer*)data; diff --git a/src/app/retro_frontend/component.cc b/src/app/retro_frontend/component.cc index bc4263c..969bc0e 100644 --- a/src/app/retro_frontend/component.cc +++ b/src/app/retro_frontend/component.cc @@ -58,6 +58,7 @@ Retro_frontend::Frontend::Frontend(Libc::Env &env) : env(env) shared_object.lookup ("retro_set_audio_sample_batch")(audio_sample_batch_callback); } catch (...) { + Genode::error("failed to initialize audio"); shared_object.lookup ("retro_set_audio_sample")(audio_sample_noop); @@ -154,7 +155,8 @@ void Libc::Component::construct(Libc::Env &env) init_keyboard_map(); - try { static Frontend inst(env); } + /* run the frontend and core initialization in application context */ + try { Libc::with_libc([&env] () { static Frontend inst(env); }); } catch (Shared_object::Invalid_rom_module) { error("failed to load core"); } diff --git a/src/app/retro_frontend/frontend.h b/src/app/retro_frontend/frontend.h index 452c7e9..0b88c1a 100644 --- a/src/app/retro_frontend/frontend.h +++ b/src/app/retro_frontend/frontend.h @@ -287,7 +287,7 @@ struct Retro_frontend::Frontend (framebuffer->mode.height() == 0)) { Genode::error("zero framebuffer mode received, exiting"); - exit(); + Libc::with_libc([&] () { exit(); }); env.parent().exit(0); } } @@ -302,7 +302,8 @@ struct Retro_frontend::Frontend Retro_run retro_run = shared_object.lookup("retro_run"); - void run() { retro_run(); } + /* switch to application context and advance the core */ + void run() { Libc::with_libc([&] () { retro_run(); }); } Genode::Signal_handler core_runner { env.ep(), *this, &Frontend::run }; @@ -422,13 +423,14 @@ struct Retro_frontend::Frontend timer.sigh(Genode::Signal_context_capability()); /* stop playpack */ - stereo_out->stop_stream(); + if (stereo_out.constructed()) + stereo_out->stop_stream(); /* set signal handler for unpausing */ controller.input.sigh(resume_handler); /* a good time to flush memory to the FS */ - save_memory(); + Libc::with_libc([&] () { save_memory(); }); } }