|
From: kosmirror <kos...@us...> - 2025-09-03 14:48:12
|
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 b4c45a947548022020173b1621efe4fe6a9ccb71 (commit)
via a42a8a5d84142ebd92825bd889c59bb3179a9db1 (commit)
from 1bd27cd8e7c8e65d7de3fbb21a02cee305cf6814 (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 b4c45a947548022020173b1621efe4fe6a9ccb71
Author: Paul Cercueil <pa...@cr...>
Date: Wed May 21 12:23:59 2025 +0200
environ: Switch to gUSA atomic model
Switch to the gUSA atomic model, which allows atomics to work without
having to mask interrupts.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit a42a8a5d84142ebd92825bd889c59bb3179a9db1
Author: Paul Cercueil <pa...@cr...>
Date: Sun May 19 13:33:46 2024 +0200
Add support for gUSA atomic model
Add support for the gUSA atomic model, which is what is used in the
Linux kernel. By specifying -matomic-model=soft-gusa, the gUSA atomic
model can now be used.
Instead of creating critical sections by masking interrupts, gUSA relies
on the scheduler detecting atomic sections, identified by the stack
pointer going negative, and rolling back to the beginning of the atomic
section if interrupted in the middle.
The minimal overhead added to the scheduler is balanced by the gains
recovered by not masking interrupts for every single atomic access.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
environ_dreamcast.sh | 2 +-
kernel/arch/dreamcast/kernel/irq.c | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/environ_dreamcast.sh b/environ_dreamcast.sh
index 7dd3e872..e947323b 100644
--- a/environ_dreamcast.sh
+++ b/environ_dreamcast.sh
@@ -24,7 +24,7 @@ if [ -z "${KOS_SH4_PRECISION}" ] || [ "${KOS_SH4_PRECISION}" = "-m4-single" ]; t
fi
fi
-export KOS_CFLAGS="${KOS_CFLAGS} ${KOS_SH4_PRECISION} -ml -mfsrra -mfsca -ffunction-sections -fdata-sections -matomic-model=soft-imask -ftls-model=local-exec"
+export KOS_CFLAGS="${KOS_CFLAGS} ${KOS_SH4_PRECISION} -ml -mfsrra -mfsca -ffunction-sections -fdata-sections -matomic-model=soft-gusa -ftls-model=local-exec"
export KOS_AFLAGS="${KOS_AFLAGS} -little"
export KOS_LDFLAGS="${KOS_LDFLAGS} ${KOS_SH4_PRECISION} -ml -Wl,--gc-sections"
export KOS_LD_SCRIPT="-T${KOS_BASE}/utils/ldscripts/shlelf.xc"
diff --git a/kernel/arch/dreamcast/kernel/irq.c b/kernel/arch/dreamcast/kernel/irq.c
index c8a23011..3e3be5a8 100644
--- a/kernel/arch/dreamcast/kernel/irq.c
+++ b/kernel/arch/dreamcast/kernel/irq.c
@@ -216,6 +216,16 @@ void irq_handle_exception(int code) {
uint32_t evt = 0;
int handled = 0;
+ if(__is_defined(__SH_ATOMIC_MODEL_SOFT_GUSA__)
+ && __unlikely((int32_t)irq_srt_addr->r[15] >= -128
+ && irq_srt_addr->pc != irq_srt_addr->r[0])) {
+ /* The stack pointer has been altered: it means we are in the middle of
+ an atomic section, and we need to roll-back.
+ The r0 register contains the address of the end of the section,
+ and the stack pointer contains the negated section size. */
+ irq_srt_addr->pc = irq_srt_addr->r[0] + irq_srt_addr->r[15];
+ }
+
switch(code) {
/* If it's a code 3, grab the event from intevt. */
case 3:
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|