From f8a74f286f33369ccd300e207eb72071ca0cd9e2 Mon Sep 17 00:00:00 2001 From: Andrea Barisani Date: Thu, 17 Oct 2024 09:40:36 +0200 Subject: [PATCH 1/3] add support to wake tamago < 1.23 applets on >= 1.23 os --- trusted_os/handler.go | 1 + trusted_os/handler.s | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/trusted_os/handler.go b/trusted_os/handler.go index 2937eb1..1840a8b 100644 --- a/trusted_os/handler.go +++ b/trusted_os/handler.go @@ -36,6 +36,7 @@ var irqHandler = make(map[int]func()) // defined in handler.s func wakeHandler(g uint32, p uint32) +func wakeHandlerPreGo122(g uint32, p uint32) func isr() { irq := imx6ul.GIC.GetInterrupt(true) diff --git a/trusted_os/handler.s b/trusted_os/handler.s index 466185a..614a3ee 100644 --- a/trusted_os/handler.s +++ b/trusted_os/handler.s @@ -15,6 +15,12 @@ #include "go_asm.h" #include "textflag.h" +#define g_timer 208 +#define timer_nextwhen 36 +#define timer_status 44 +#define const_timerModifiedEarlier 7 +#define p_timerModifiedEarliest 2384 + TEXT ·wakeHandler(SB),$0-8 MOVW handlerG+0(FP), R0 MOVW handlerP+4(FP), R1 @@ -28,3 +34,37 @@ TEXT ·wakeHandler(SB),$0-8 B runtime·WakeG(SB) done: RET + +// In order to support applets built with tamago < 1.23 the previous version of +// WakeG is made available here. +TEXT ·wakeHandlerPreGo123(SB),$0-8 + MOVW handlerG+0(FP), R0 + MOVW handlerP+4(FP), R1 + + CMP $0, R0 + B.EQ done + + CMP $0, R1 + B.EQ done + + MOVW (g_timer)(R0), R0 + CMP $0, R0 + B.EQ done + + // g->timer.nextwhen = 1 + MOVW $1, R2 + MOVW R2, (timer_nextwhen+0)(R0) + MOVW $0, R2 + MOVW R2, (timer_nextwhen+4)(R0) + + // g->timer.status = timerModifiedEarlier + MOVW $const_timerModifiedEarlier, R2 + MOVW R2, (timer_status+0)(R0) + + // g->m->p.timerModifiedEarliest = 1 + MOVW $1, R2 + MOVW R2, (p_timerModifiedEarliest)(R1) + MOVW $0, R2 + MOVW R2, (p_timerModifiedEarliest+4)(R1) +done: + RET From 63a004dd951e03419b2b9bf7edd3553f9e778439 Mon Sep 17 00:00:00 2001 From: Andrea Barisani Date: Thu, 17 Oct 2024 11:17:23 +0200 Subject: [PATCH 2/3] Update trusted_os/handler.go Co-authored-by: Martin Hutchinson --- trusted_os/handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trusted_os/handler.go b/trusted_os/handler.go index 1840a8b..5ec2669 100644 --- a/trusted_os/handler.go +++ b/trusted_os/handler.go @@ -36,7 +36,7 @@ var irqHandler = make(map[int]func()) // defined in handler.s func wakeHandler(g uint32, p uint32) -func wakeHandlerPreGo122(g uint32, p uint32) +func wakeHandlerPreGo123(g uint32, p uint32) func isr() { irq := imx6ul.GIC.GetInterrupt(true) From af57ab62c4d2dc5036f8c8017ac3e0192ea87441 Mon Sep 17 00:00:00 2001 From: Andrea Barisani Date: Thu, 17 Oct 2024 13:08:30 +0200 Subject: [PATCH 3/3] tidying --- trusted_os/handler.s | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/trusted_os/handler.s b/trusted_os/handler.s index 614a3ee..570fb5f 100644 --- a/trusted_os/handler.s +++ b/trusted_os/handler.s @@ -15,12 +15,16 @@ #include "go_asm.h" #include "textflag.h" +// These defines are only used to aid applet runtime backward compatiblity, +// within wakeHandlerPreGo123, and represent timer structs offsets fo Go < +// 1.23. #define g_timer 208 #define timer_nextwhen 36 #define timer_status 44 #define const_timerModifiedEarlier 7 #define p_timerModifiedEarliest 2384 +// Supports tamago >= 1.23 applet runtime. TEXT ·wakeHandler(SB),$0-8 MOVW handlerG+0(FP), R0 MOVW handlerP+4(FP), R1 @@ -35,8 +39,7 @@ TEXT ·wakeHandler(SB),$0-8 done: RET -// In order to support applets built with tamago < 1.23 the previous version of -// WakeG is made available here. +// Supports tamago < 1.23 applet runtime. TEXT ·wakeHandlerPreGo123(SB),$0-8 MOVW handlerG+0(FP), R0 MOVW handlerP+4(FP), R1