From: ljsebald <ljs...@us...> - 2023-12-28 22:07:57
|
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 d59f16e00557ccd548aa58b634d6c3604fd4cc11 (commit) via 48c5a84d606f97c4f6b0badd82842472dd1cb640 (commit) via 092811a12fd2675a362bbd138cc58ac60c68c45f (commit) via dc35443b01ee39b172d57401185475b9be7e2441 (commit) via 0f1c2b17a9a71bb3c40c756404c737f7d53bb245 (commit) from a8f88c8315632fe0c7defc76a561f7442ce3f1eb (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 d59f16e00557ccd548aa58b634d6c3604fd4cc11 Author: Paul Cercueil <pa...@cr...> Date: Thu Dec 28 23:06:36 2023 +0100 dc: Fix parameter passing to fipr() and fipr_magnitude_sqr() (#438) The registers used for parameter passing is different whether the code was compiled with -m4-single-only, or just -m4 / -m4-single. Signed-off-by: Paul Cercueil <pa...@cr...> commit 48c5a84d606f97c4f6b0badd82842472dd1cb640 Author: Falco Girgis <gyr...@gm...> Date: Thu Dec 28 16:05:17 2023 -0600 Disabling Watchdog Timer on KOS exit and init (#439) * Disabling WDT on KOS exit and init now by default. - Kept running into issues where nongraceful exit would not call atexit(wdt_disable) - The only foolproof way to ensure graceful WDT behavior is to disable it within KOS itself for deinit/init paths - Updated examples to reflect this change * Removed warning from WDT documentation - Disabling it is no longer something the user has to worry about, if they intended for its lifetime to be that of the application commit 092811a12fd2675a362bbd138cc58ac60c68c45f Merge: a8f88c8 dc35443 Author: Lawrence Sebald <ljs...@us...> Date: Thu Dec 28 17:03:53 2023 -0500 Merge pull request #440 from KallistiOS/init_mallocstats_fix Fixed INIT_MALLOCSTATS KOS init flag commit dc35443b01ee39b172d57401185475b9be7e2441 Merge: 0f1c2b1 a8f88c8 Author: Falco Girgis <gyr...@gm...> Date: Thu Dec 28 13:27:22 2023 -0600 Merge branch 'master' into init_mallocstats_fix commit 0f1c2b17a9a71bb3c40c756404c737f7d53bb245 Author: Falco Girgis <gyr...@gm...> Date: Thu Dec 28 05:45:11 2023 -0600 Fixed INIT_MALLOCSTATS KOS init flag - It was not displaying properly previously when used - Apparently newlib had already shutdown standard I/O handling code when this code was called - Moved to KOS's logging mechanism to bypass newlib ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/basic/watchdog/watchdog.c | 13 ++---- examples/dreamcast/cpp/concurrency/concurrency.cpp | 3 -- kernel/arch/dreamcast/include/arch/args.h | 48 ++++++++++++++++++++++ kernel/arch/dreamcast/include/arch/wdt.h | 7 ---- kernel/arch/dreamcast/include/dc/fmath_base.h | 26 ++++++------ kernel/arch/dreamcast/kernel/init.c | 10 +++++ kernel/libc/koslib/malloc.c | 6 +-- 7 files changed, 78 insertions(+), 35 deletions(-) create mode 100644 kernel/arch/dreamcast/include/arch/args.h diff --git a/examples/dreamcast/basic/watchdog/watchdog.c b/examples/dreamcast/basic/watchdog/watchdog.c index 9a72812..79987e8 100644 --- a/examples/dreamcast/basic/watchdog/watchdog.c +++ b/examples/dreamcast/basic/watchdog/watchdog.c @@ -30,7 +30,7 @@ #define SEC (1000 * MSEC) /* Test configuration constants */ -#define WDT_PET_COUNT 2000 +#define WDT_PET_COUNT 4000 #define WDT_INTERVAL (500 * MSEC) #define WDT_SECONDS 10 #define WDT_COUNT_MAX ((WDT_SECONDS * SEC) / WDT_INTERVAL) @@ -56,14 +56,6 @@ int main(int argc, char *argv[]) { cont_btn_callback(0, CONT_START | CONT_A | CONT_B | CONT_X | CONT_Y, (cont_btn_callback_t)exit); - /* Note that is EXTREMELY important that the WDT gets disabled - when it is done being used, otherwise it can continue running - after the application exits and can interfere with DC-Load - operation. Since we have multiple exit points (one from returning - from main and one from the button callback), the safest thing to do - is to register wdt_disable() to be called automatically upon exit. */ - atexit(wdt_disable); - printf("\nEnabling WDT in watchdog mode!\n"); /* Enable watchdog mode with a period of 5.25ms, causing a manual @@ -81,7 +73,8 @@ int main(int argc, char *argv[]) { if(current_count > max_count) max_count = current_count; - wdt_pet(); + if(current_count) + wdt_pet(); } /* Immediately disable the WDT once we're done with it. */ diff --git a/examples/dreamcast/cpp/concurrency/concurrency.cpp b/examples/dreamcast/cpp/concurrency/concurrency.cpp index e4892ae..b623f30 100644 --- a/examples/dreamcast/cpp/concurrency/concurrency.cpp +++ b/examples/dreamcast/cpp/concurrency/concurrency.cpp @@ -706,9 +706,6 @@ int main(int argc, char* argv[]) { exit(EXIT_FAILURE); }, nullptr); - // Ensure that we disable the watchdog timer no matter how we exit - atexit(wdt_disable); - /* Spawn N automatically joined threads which will each spawn threads for each test case and asynchronously wait upon their results... Basically making each thread execute its own instances of every test case concurrently diff --git a/kernel/arch/dreamcast/include/arch/args.h b/kernel/arch/dreamcast/include/arch/args.h new file mode 100644 index 0000000..63a2c4e --- /dev/null +++ b/kernel/arch/dreamcast/include/arch/args.h @@ -0,0 +1,48 @@ +/* KallistiOS ##version## + + arch/dreamcast/include/arch/args.h + Copyright (C) 2023 Paul Cercueil <pa...@cr...> + +*/ + +/** \file arch/args.h + \brief Macros for getting argument registers in inline assembly + + This file contains the KOS_FPARG(n) macro, which resolves to the register + name that corresponds to the nth floating-point argument of a function. + + \author Paul Cercueil +*/ + +#if __SH4_SINGLE_ONLY__ +#define KOS_SH4_SINGLE_ONLY 1 +#else +#define KOS_SH4_SINGLE_ONLY 0 +#endif + +#define __KOS_FPARG_0_1 "fr4" +#define __KOS_FPARG_0_0 "fr5" +#define __KOS_FPARG_1_1 "fr5" +#define __KOS_FPARG_1_0 "fr4" +#define __KOS_FPARG_2_1 "fr6" +#define __KOS_FPARG_2_0 "fr7" +#define __KOS_FPARG_3_1 "fr7" +#define __KOS_FPARG_3_0 "fr6" +#define __KOS_FPARG_4_1 "fr8" +#define __KOS_FPARG_4_0 "fr9" +#define __KOS_FPARG_5_1 "fr9" +#define __KOS_FPARG_5_0 "fr8" +#define __KOS_FPARG_6_1 "fr10" +#define __KOS_FPARG_6_0 "fr11" +#define __KOS_FPARG_7_1 "fr11" +#define __KOS_FPARG_7_0 "fr10" + +#define __KOS_FPARG(n,single) __KOS_FPARG_##n##_##single +#define _KOS_FPARG(n,single) __KOS_FPARG(n,single) + +/** \brief Get the name of the nth floating-point argument register + * + * This macro resolves to the register name that corresponds to the nth + * floating-point argument of a function (starting from n=0). + */ +#define KOS_FPARG(n) _KOS_FPARG(n, KOS_SH4_SINGLE_ONLY) diff --git a/kernel/arch/dreamcast/include/arch/wdt.h b/kernel/arch/dreamcast/include/arch/wdt.h index b782507..f3e66e4 100644 --- a/kernel/arch/dreamcast/include/arch/wdt.h +++ b/kernel/arch/dreamcast/include/arch/wdt.h @@ -47,13 +47,6 @@ __BEGIN_DECLS The timer can be stopped in either mode by calling wdt_disable(). - \warning - Once the WDT has been enabled, special care must be taken to disable it - when exiting from the application. If left enabled, the WDT will continue - running beyond the lifetime of the application, causing either a reset or - an unhandled exception (depending on which mode was used), preventing you - from gracefully returning to a DC-Load session when testing. - \sa rtc */ diff --git a/kernel/arch/dreamcast/include/dc/fmath_base.h b/kernel/arch/dreamcast/include/dc/fmath_base.h index 02aaa2c..a08501d 100644 --- a/kernel/arch/dreamcast/include/dc/fmath_base.h +++ b/kernel/arch/dreamcast/include/dc/fmath_base.h @@ -18,6 +18,8 @@ #ifndef __DC_FMATH_BASE_H #define __DC_FMATH_BASE_H +#include <arch/args.h> + #include <sys/cdefs.h> __BEGIN_DECLS @@ -132,14 +134,14 @@ __BEGIN_DECLS /* Floating point inner product (dot product) */ #define __fipr(x, y, z, w, a, b, c, d) ({ \ - register float __x __asm__("fr5") = (x); \ - register float __y __asm__("fr4") = (y); \ - register float __z __asm__("fr7") = (z); \ - register float __w __asm__("fr6") = (w); \ - register float __a __asm__("fr9") = (a); \ - register float __b __asm__("fr8") = (b); \ - register float __c __asm__("fr11") = (c); \ - register float __d __asm__("fr10") = (d); \ + register float __x __asm__(KOS_FPARG(0)) = (x); \ + register float __y __asm__(KOS_FPARG(1)) = (y); \ + register float __z __asm__(KOS_FPARG(2)) = (z); \ + register float __w __asm__(KOS_FPARG(3)) = (w); \ + register float __a __asm__(KOS_FPARG(4)) = (a); \ + register float __b __asm__(KOS_FPARG(5)) = (b); \ + register float __c __asm__(KOS_FPARG(6)) = (c); \ + register float __d __asm__(KOS_FPARG(7)) = (d); \ __asm__ __volatile__( \ "fipr fv8,fv4" \ : "+f" (__z) \ @@ -150,10 +152,10 @@ __BEGIN_DECLS /* Floating point inner product w/self (square of vector magnitude) */ #define __fipr_magnitude_sqr(x, y, z, w) ({ \ - register float __x __asm__("fr5") = (x); \ - register float __y __asm__("fr4") = (y); \ - register float __z __asm__("fr7") = (z); \ - register float __w __asm__("fr6") = (w); \ + register float __x __asm__(KOS_FPARG(0)) = (x); \ + register float __y __asm__(KOS_FPARG(1)) = (y); \ + register float __z __asm__(KOS_FPARG(2)) = (z); \ + register float __w __asm__(KOS_FPARG(3)) = (w); \ __asm__ __volatile__( \ "fipr fv4,fv4" \ : "+f" (__z) \ diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c index b224ab7..2342d94 100644 --- a/kernel/arch/dreamcast/kernel/init.c +++ b/kernel/arch/dreamcast/kernel/init.c @@ -17,6 +17,7 @@ #include <arch/memory.h> #include <arch/rtc.h> #include <arch/timer.h> +#include <arch/wdt.h> #include <dc/ubc.h> #include <dc/pvr.h> #include <dc/vmufs.h> @@ -250,6 +251,9 @@ void arch_main(void) { *DMAOR = 0x8201; #endif /* _arch_sub_naomi */ + /* Ensure the WDT is not enabled from a previous session */ + wdt_disable(); + /* Ensure that UBC is not enabled from a previous session */ ubc_disable_all(); @@ -289,6 +293,9 @@ void arch_shutdown(void) { dbglog(DBG_CRITICAL, "arch: shutting down kernel\n"); + /* Disable the WDT, if active */ + wdt_disable(); + /* Turn off UBC breakpoints, if any */ ubc_disable_all(); @@ -366,6 +373,9 @@ void arch_menu(void) { /* Called to shut down non-gracefully; assume the system is in peril and don't try to call the dtors */ void arch_abort(void) { + /* Disable the WDT, if active */ + wdt_disable(); + /* Turn off UBC breakpoints, if any */ ubc_disable_all(); diff --git a/kernel/libc/koslib/malloc.c b/kernel/libc/koslib/malloc.c index 2d7ea40..1dc1770 100644 --- a/kernel/libc/koslib/malloc.c +++ b/kernel/libc/koslib/malloc.c @@ -5280,11 +5280,11 @@ void mSTATs(void) { #endif - fprintf(stderr, "max system bytes = %10lu\n", + dbglog(DBG_CRITICAL, "max system bytes = %10lu\n", (CHUNK_SIZE_T)(mi.usmblks)); - fprintf(stderr, "system bytes = %10lu\n", + dbglog(DBG_CRITICAL, "system bytes = %10lu\n", (CHUNK_SIZE_T)(mi.arena + mi.hblkhd)); - fprintf(stderr, "in use bytes = %10lu\n", + dbglog(DBG_CRITICAL, "in use bytes = %10lu\n", (CHUNK_SIZE_T)(mi.uordblks + mi.hblkhd)); #ifdef WIN32 hooks/post-receive -- A pseudo Operating System for the Dreamcast. |