From: darcagn <da...@us...> - 2024-05-17 19:07:04
|
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 1e8449ffef661f8be82dd5680a8669e79ae0eeb6 (commit) via 162e88d88cdf51c07319cdeceb8f9a12bc68cc2c (commit) from 5ff6cd01cd9d1d47472e45c0f29d955bfe864eec (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 1e8449ffef661f8be82dd5680a8669e79ae0eeb6 Author: Falco Girgis <gyr...@gm...> Date: Fri May 17 14:06:25 2024 -0500 Added dc-chain Configuration Option for C++'s Timezone Database (#554) * Added dc-chain configure option for C++'s tzdb. - Added new config option, libstdcxx_tzdb, for specifying how you want C++'s std::chrono::tzdb to be populated: 0 - None (only UTC and GMT supported), 1 - Automatic (system DB + downloading IANA DB), Path - Custom path to directory containing "tzdata.zi" database file + downloading IANA DB. - Default option is to disable the DB for C++. * Forgot to handle the default/NULL case for option. Whoops. If you left the config with the defaults, the option was never defined, so it was never passing anything to the toolchain, so the database was still getting added, despite the fact we want the default to disable it... Fixed. * Update utils/dc-chain/Makefile.default.cfg Co-authored-by: darcagn <da...@pr...> --------- Co-authored-by: darcagn <da...@pr...> commit 162e88d88cdf51c07319cdeceb8f9a12bc68cc2c Author: Paul Cercueil <pa...@cr...> Date: Fri May 17 07:55:29 2024 +0200 timers: Add timer_spin_delay_{us,ns} (#568) * timers: Add timer_spin_delay_{us,ns} These two functions can be used to busy-wait until a given timeout expires. They are similar to timer_spin_sleep(), except that they are much more precise and don't use a dedicated TIMER UNIT channel, which makes them inherently thread-safe. Signed-off-by: Paul Cercueil <pa...@cr...> * dc: scif-spi: Delay using timer_spin_delay_ns() Use the timer_spin_delay_ns() function instead of hardcoding the use of the TIMER UNIT 1. Signed-off-by: Paul Cercueil <pa...@cr...> --------- Signed-off-by: Paul Cercueil <pa...@cr...> Co-authored-by: Falco Girgis <gyr...@gm...> ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + kernel/arch/dreamcast/hardware/scif-spi.c | 13 ++----------- kernel/arch/dreamcast/include/arch/timer.h | 28 +++++++++++++++++++++++++++- kernel/arch/dreamcast/kernel/timer.c | 18 +++++++++++++++++- utils/dc-chain/Makefile.default.cfg | 13 +++++++++++++ utils/dc-chain/doc/CHANGELOG.md | 3 ++- utils/dc-chain/scripts/init.mk | 13 +++++++++++++ 7 files changed, 75 insertions(+), 14 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 252729cd..d367f2cb 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -224,6 +224,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - *** Added support for modifying scheduler frequency at runtime [FG] - *** Add support for worker threads [PC] - DC Added new System Calls module [AB] +- DC Add timer_spin_delay_{us,ns} and use them in scif-spi [PC] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/kernel/arch/dreamcast/hardware/scif-spi.c b/kernel/arch/dreamcast/hardware/scif-spi.c index b910bc57..cef162b1 100644 --- a/kernel/arch/dreamcast/hardware/scif-spi.c +++ b/kernel/arch/dreamcast/hardware/scif-spi.c @@ -3,6 +3,7 @@ hardware/scif-spi.c Copyright (C) 2012 Lawrence Sebald Copyright (C) 2023 Ruslan Rostovtsev + Copyright (C) 2024 Paul Cercueil */ #include <dc/scif.h> @@ -122,17 +123,7 @@ uint8 scif_spi_rw_byte(uint8 b) { /* Very accurate 1.5usec delay... */ static void slow_rw_delay(void) { - timer_prime(TMU1, 2000000, 0); - timer_clear(TMU1); - timer_start(TMU1); - - while(!timer_clear(TMU1)) - ; - while(!timer_clear(TMU1)) - ; - while(!timer_clear(TMU1)) - ; - timer_stop(TMU1); + timer_spin_delay_ns(1500); } uint8 scif_spi_slow_rw_byte(uint8 b) { diff --git a/kernel/arch/dreamcast/include/arch/timer.h b/kernel/arch/dreamcast/include/arch/timer.h index 30724489..9f8b3ec7 100644 --- a/kernel/arch/dreamcast/include/arch/timer.h +++ b/kernel/arch/dreamcast/include/arch/timer.h @@ -3,7 +3,8 @@ arch/dreamcast/include/timer.h Copyright (c) 2000, 2001 Megan Potter Copyright (c) 2023 Falco Girgis - + Copyright (c) 2024 Paul Cercueil + */ /** \file arch/timer.h @@ -348,6 +349,31 @@ uint64_t timer_ns_gettime64(void); */ void timer_spin_sleep(int ms); +/** \brief Spin-loop delay function with microsecond granularity + \ingroup tmu_sleep + + This function is meant as a very accurate delay function, even if threading + and interrupts are disabled. It is a delay and not a sleep, which means that + the CPU will be busy-looping during that time frame. For any time frame + bigger than a few hundred microseconds, it is recommended to sleep instead. + + \param us The number of microseconds to wait for. + \sa timer_spin_delay_ns, thd_sleep +*/ +void timer_spin_delay_us(unsigned short us); + +/** \brief Spin-loop delay function with nanosecond granularity + \ingroup tmu_sleep + + This function is meant as a very accurate delay function, even if threading + and interrupts are disabled. It is a delay and not a sleep, which means that + the CPU will be busy-looping during that time frame. + + \param ns The number of nanoseconds to wait for. + \sa timer_spin_delay_us, thd_sleep +*/ +void timer_spin_delay_ns(unsigned short ns); + /** \defgroup tmu_primary Primary Timer \brief Primary timer used by the kernel. \ingroup timers diff --git a/kernel/arch/dreamcast/kernel/timer.c b/kernel/arch/dreamcast/kernel/timer.c index f3d9fd73..a3dd8219 100644 --- a/kernel/arch/dreamcast/kernel/timer.c +++ b/kernel/arch/dreamcast/kernel/timer.c @@ -3,7 +3,7 @@ timer.c Copyright (C) 2000, 2001, 2002 Megan Potter Copyright (C) 2023 Falco Girgis - Copyright (C) 2023 Paul Cercueil <pa...@cr...> + Copyright (C) 2023, 2024 Paul Cercueil <pa...@cr...> */ #include <assert.h> @@ -171,6 +171,22 @@ void timer_spin_sleep(int ms) { timer_stop(TMU1); } +void timer_spin_delay_ns(unsigned short ns) { + uint64_t timeout = timer_ns_gettime64() + ns; + + /* Note that we don't actually care about the counter overflowing. + Nobody will run their Dreamcast straight for 585 years. */ + while(timer_ns_gettime64() < timeout); +} + +void timer_spin_delay_us(unsigned short us) { + uint64_t timeout = timer_us_gettime64() + us; + + /* Note that we don't actually care about the counter overflowing. + Nobody will run their Dreamcast straight for 584942 years. */ + while(timer_us_gettime64() < timeout); +} + /* Enable timer interrupts; needs to move to irq.c sometime. */ void timer_enable_ints(int which) { volatile uint16_t *ipra = (uint16_t *)0xffd00004; diff --git a/utils/dc-chain/Makefile.default.cfg b/utils/dc-chain/Makefile.default.cfg index e78e3a31..d7c9089f 100644 --- a/utils/dc-chain/Makefile.default.cfg +++ b/utils/dc-chain/Makefile.default.cfg @@ -204,6 +204,19 @@ newlib_c99_formats=1 # performance. #newlib_opt_space=1 +################### +### C++ OPTIONS ### +################### + +### Timezone database support (1|0|path) +# Uncomment this option to enable building support for C++'s std::chrono::tzdb +# into your C++ standard library by using a combination of the system's local +# timezone DB and one dynamically fetched from the "IANA Time Zone Database." +# Without support enabled, only the "UTC" and "GMT" timezones will be defined. +# You can optionally provide the path to a directory with a custom "tzdata.zi" +# database file. NOTE: Enabling this will result in larger C++ binaries! +#libstdcxx_tzdb=1 + ####################### ### WINDOWS OPTIONS ### ####################### diff --git a/utils/dc-chain/doc/CHANGELOG.md b/utils/dc-chain/doc/CHANGELOG.md index 6e4138e3..75c15e5d 100644 --- a/utils/dc-chain/doc/CHANGELOG.md +++ b/utils/dc-chain/doc/CHANGELOG.md @@ -2,7 +2,8 @@ | Date<br/>_____________ | Author(s)<br/>_____________ | Changes<br/>_____________ | |:-----------------------|:----------------------------|---------------------------| -| 2024-05-02| Eric Fradella | Deprecated GCC 4.7.4 profile. Revamped configuration system into separate profiles and Makefile.cfg. Revised configuration options and documentation. | +| 2024-05-08 | Falco Girgis | Added configuration option for libstdc++'s timezone database. | +| 2024-05-02 | Eric Fradella | Deprecated GCC 4.7.4 profile. Revamped configuration system into separate profiles and Makefile.cfg. Revised configuration options and documentation. | | 2024-05-01 | Falco Girgis | Added config option for enabling the Ada langauge. | | 2024-04-30 | Falco Girgis | Added config option for enabling iconv library support in Newlib. | | 2024-04-29 | Donald Haase<br/>Eric Fradella | Patch Newlib headers to expose lstat() declaration. | diff --git a/utils/dc-chain/scripts/init.mk b/utils/dc-chain/scripts/init.mk index 2889328b..bc37f4db 100644 --- a/utils/dc-chain/scripts/init.mk +++ b/utils/dc-chain/scripts/init.mk @@ -163,6 +163,19 @@ ifdef newlib_iconv_encodings endif endif +# Handle libstdc++ configuration options +ifdef libstdcxx_tzdb + ifeq (0,$(libstdcxx_tzdb)) + gcc_extra_configure_args += --with-libstdcxx-zoneinfo=no + else ifeq (1,$(libstdcxx_tzdb)) + gcc_extra_configure_args += --with-libstdcxx-zoneinfo=yes + else + gcc_extra_configure_args += --with-libstdcxx-zoneinfo=$(libstdcxx_tzdb),static + endif +else + gcc_extra_configure_args += --with-libstdcxx-zoneinfo=no +endif + # Handle install mode for toolchain debug symbols ifdef toolchain_debug ifneq (0,$(toolchain_debug)) hooks/post-receive -- A pseudo Operating System for the Dreamcast. |