Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support to wake tamago < 1.23 applets on >= 1.23 os #284

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions trusted_os/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var irqHandler = make(map[int]func())

// defined in handler.s
func wakeHandler(g uint32, p uint32)
func wakeHandlerPreGo123(g uint32, p uint32)

func isr() {
irq := imx6ul.GIC.GetInterrupt(true)
Expand Down
43 changes: 43 additions & 0 deletions trusted_os/handler.s
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +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
abarisani marked this conversation as resolved.
Show resolved Hide resolved
#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
Expand All @@ -28,3 +38,36 @@ TEXT ·wakeHandler(SB),$0-8
B runtime·WakeG(SB)
done:
RET

// Supports tamago < 1.23 applet runtime.
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