# HG changeset patch # User Emery Hemingway # Date 1611172558 -3600 # Wed Jan 20 20:55:58 2021 +0100 # Branch genode # Node ID 686f8e127f30b954b9c540b67c1c361620d04c2b # Parent 2d51d36a709362fff19c0d4aa2e493740dca5935 Add Genode platform support diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -2843,11 +2843,7 @@ pthread_cflags="-D_REENTRANT" pthread_lib="-L/usr/lib -lpthread" ;; - *-*-haiku*) - pthread_cflags="-D_REENTRANT" - pthread_lib="" - ;; - *-*-nto*) + *-*-genode*|*-*-haiku*|*-*-nto*) pthread_cflags="-D_REENTRANT" pthread_lib="" ;; @@ -4085,6 +4081,30 @@ have_timers=yes fi ;; + *-*-genode*) + ARCH=genode + CheckDLOPEN + CheckDummyAudio + CheckDummyVideo + + # Set up files for the audio library + if test x$enable_audio = xyes; then + AC_DEFINE(SDL_AUDIO_DRIVER_GENODE, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/audio/genode/*.cc" + SUMMARY_audio="${SUMMARY_audio} genode" + have_audio=yes + fi + + # Set up files for the video library + if test x$enable_video = xyes; then + AC_DEFINE(SDL_VIDEO_DRIVER_GENODE, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/video/genode/*.cc" + SUMMARY_audio="${SUMMARY_video} genode" + have_video=yes + fi + + SOURCES="$srcdir/src/core/genode/*.cc $srcdir/src/main/genode/*.cc $SOURCES " + ;; *) AC_MSG_ERROR([ *** Unsupported host: Please add to configure.ac diff --git a/include/SDL_config_genode.h b/include/SDL_config_genode.h new file mode 100644 --- /dev/null +++ b/include/SDL_config_genode.h @@ -0,0 +1,52 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_genode_h_ +#define SDL_config_genode_h_ +#define SDL_config_h_ + +#include "SDL_platform.h" + +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 + +/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ +#define SDL_JOYSTICK_DISABLED 1 + +/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ +#define SDL_HAPTIC_DISABLED 1 + +/* Enable the stub sensor driver (src/sensor/dummy/\*.c) */ +#define SDL_SENSOR_DISABLED 1 + +/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ +#define SDL_LOADSO_DISABLED 1 + +/* Enable the stub thread support (src/thread/generic/\*.c) */ +#define SDL_THREADS_DISABLED 1 + +/* Enable the stub timer support (src/timer/dummy/\*.c) */ +#define SDL_TIMERS_DISABLED 1 + +/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */ +#define SDL_FILESYSTEM_DUMMY 1 + +#endif /* SDL_config_genode_h_ */ diff --git a/src/audio/genode/SDL_Genode_audio.cc b/src/audio/genode/SDL_Genode_audio.cc new file mode 100644 diff --git a/src/core/genode/SDL_genode.cc b/src/core/genode/SDL_genode.cc new file mode 100644 --- /dev/null +++ b/src/core/genode/SDL_genode.cc @@ -0,0 +1,67 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef __GENODE__ + +#include "SDL_genode.h" + +/* Genode includes */ +#include +#include +#include +#include +#include + +static Genode::Env *_global_env = nullptr; + +static Genode::Constructible _global_gui { }; + +void SDL_Genode_Init(Genode::Env &env) +{ + _global_env = &env; +} + +Genode::Env &SDL_Genode_Env(void) +{ + if (!_global_env) { + Genode::error("sdl_init_genode() not called, aborting"); + throw Genode::Exception(); + } + + return *_global_env; +} + +Gui::Connection &SDL_Genode_Gui() +{ + if (!_global_gui.constructed()) + _global_gui.construct(global_env()); + + return *_global_gui; +} + +extern "C" +int SDL_Genode_SystemRAM() +{ + return SDL_Genode_Env().pd().ram_quota().value; +} + + +#endif /* __GENODE__ */ diff --git a/src/core/genode/SDL_genode.h b/src/core/genode/SDL_genode.h new file mode 100644 --- /dev/null +++ b/src/core/genode/SDL_genode.h @@ -0,0 +1,36 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" +#include "SDL_system.h" + +/* Genode includes */ +#include + +/* Genode platform initialization */ +void SDL_Genode_Init(Genode::Env &env); + +Genode::Env &SDL_Genode_Env(void); + +Gui::Connection &SDL_Genode_Gui(); + +extern "C" +int SDL_Genode_SystemRAM(); diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -95,6 +95,10 @@ #include #endif +#ifdef __GENODE__ +extern int SDL_Genode_SystemRAM(); +#endif + #define CPU_HAS_RDTSC (1 << 0) #define CPU_HAS_ALTIVEC (1 << 1) #define CPU_HAS_MMX (1 << 2) @@ -923,6 +927,11 @@ } } #endif +#ifdef __GENODE__ + if (SDL_SystemRAM <= 0) { + SDL_SystemRAM = SDL_Genode_SystemRAM(); + } +#endif #endif } return SDL_SystemRAM; diff --git a/src/main/genode/SDL_Genode.cc b/src/main/genode/SDL_Genode.cc new file mode 100644 diff --git a/src/video/genode/SDL_Genode_video.cc b/src/video/genode/SDL_Genode_video.cc new file mode 100644