From: falcovorbis <fal...@us...> - 2024-04-20 03:11:58
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via c1410a93e38ab6f80efcb9400b47c8451d490d13 (commit) from ab6634d7e39a0e1ff371e6bf7288c2fc88fc4b29 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c1410a93e38ab6f80efcb9400b47c8451d490d13 Author: Paul Cercueil <pa...@cr...> Date: Sat Apr 20 05:11:45 2024 +0200 init: Add KOS_NO_SHUTDOWN flag to disable shutdown (#509) Serious homebrew games and apps generally don't have any way to return to the calling application; exiting them means rebooting the console. Those applications can now shave off a few kilobytes of RAM by using the KOS_NO_SHUTDOWN init flag. Signed-off-by: Paul Cercueil <pa...@cr...> Co-authored-by: Falco Girgis <gyr...@gm...> ----------------------------------------------------------------------- Summary of changes: include/kos/init.h | 2 ++ kernel/libc/newlib/newlib_exit.c | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/kos/init.h b/include/kos/init.h index abb6ee9c..bb14f069 100644 --- a/include/kos/init.h +++ b/include/kos/init.h @@ -61,6 +61,7 @@ __BEGIN_DECLS KOS_INIT_FLAG(flags, INIT_FS_ROMDISK, fs_romdisk_init); \ KOS_INIT_FLAG(flags, INIT_FS_ROMDISK, fs_romdisk_shutdown); \ KOS_INIT_FLAG(flags, INIT_EXPORT, export_init); \ + KOS_INIT_FLAG_NONE(flags, INIT_NO_SHUTDOWN, kos_shutdown); \ KOS_INIT_FLAGS_ARCH(flags) #define __KOS_INIT_FLAGS_1(flags) \ @@ -138,6 +139,7 @@ extern void * __kos_romdisk; #define INIT_QUIET 0x00000010 /**< \brief Disable dbgio */ #define INIT_EXPORT 0x00000020 /**< \brief Export kernel symbols */ #define INIT_FS_ROMDISK 0x00000040 /**< \brief Enable support for romdisks */ +#define INIT_NO_SHUTDOWN 0x00000080 /**< \brief Disable hardware shutdown */ /** @} */ __END_DECLS diff --git a/kernel/libc/newlib/newlib_exit.c b/kernel/libc/newlib/newlib_exit.c index ff1dfeee..3ab369ca 100644 --- a/kernel/libc/newlib/newlib_exit.c +++ b/kernel/libc/newlib/newlib_exit.c @@ -6,9 +6,23 @@ */ #include <arch/arch.h> +#include <stdbool.h> extern void arch_exit_handler(int ret_code) __noreturn; +static int ret_code; + +void kos_shutdown(void) +{ + arch_exit_handler(ret_code); + + __builtin_unreachable(); +} + +KOS_INIT_FLAG_WEAK(kos_shutdown, true); + void _exit(int code) { - arch_exit_handler(code); + ret_code = code; + + KOS_INIT_FLAG_CALL(kos_shutdown); } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |