From f6e502e1215d89fe4880d6cb2b7d264a82638e21 Mon Sep 17 00:00:00 2001 From: Matthew Hiles <15929821+sparques@users.noreply.github.com> Date: Fri, 28 Aug 2026 13:48:48 -0400 Subject: [PATCH] UEFI: add support for tasks scheduler and make it default (#5553) * add support for UEFI time and UEFI events; fix STOP \n -> \r\n conversion * make it so both scheduler=none and scheduler=tasks works * address pr comments - Renamed/shared the amd64 Win64 ABI task stack Go file for both Windows and UEFI. - Deleted the duplicate UEFI task stack Go file and old Windows-suffixed Go file. - Added task_stack_amd64_windows.S unconditionally to targets/uefi-amd64.json. - Removed the UEFI ExtraFiles() special case from compileopts/config.go. - Added a scheduler.none tinygo_task_exit stub. - Removed the custom UEFI sleep override so normal scheduler sleep queue is used. * revert back to simpler return value for ExtraFiles() * create uefi specific tasks_none file * remove unused sleepSchedulerCustom stuff * add back the uefi tag * lib: restore macos-minimal-sdk pointer --- src/internal/task/task_none_uefi.go | 8 ++++++++ src/internal/task/task_stack_amd64.go | 2 +- ..._stack_amd64_windows.go => task_stack_amd64_winabi.go} | 4 ++-- src/runtime/scheduler_cooperative.go | 4 ---- src/runtime/sleep_custom_default.go | 7 ------- targets/uefi-amd64.json | 5 +++-- 6 files changed, 14 insertions(+), 16 deletions(-) create mode 100644 src/internal/task/task_none_uefi.go rename src/internal/task/{task_stack_amd64_windows.go => task_stack_amd64_winabi.go} (94%) delete mode 100644 src/runtime/sleep_custom_default.go diff --git a/src/internal/task/task_none_uefi.go b/src/internal/task/task_none_uefi.go new file mode 100644 index 000000000..f4e755b84 --- /dev/null +++ b/src/internal/task/task_none_uefi.go @@ -0,0 +1,8 @@ +//go:build scheduler.none && uefi + +package task + +//go:export tinygo_task_exit +func taskExit() { + runtimePanic("scheduler is disabled") +} diff --git a/src/internal/task/task_stack_amd64.go b/src/internal/task/task_stack_amd64.go index d252b1c50..bfd18b575 100644 --- a/src/internal/task/task_stack_amd64.go +++ b/src/internal/task/task_stack_amd64.go @@ -1,4 +1,4 @@ -//go:build scheduler.tasks && amd64 && !windows +//go:build scheduler.tasks && amd64 && !windows && !uefi package task diff --git a/src/internal/task/task_stack_amd64_windows.go b/src/internal/task/task_stack_amd64_winabi.go similarity index 94% rename from src/internal/task/task_stack_amd64_windows.go rename to src/internal/task/task_stack_amd64_winabi.go index f174196f3..17d19d7c8 100644 --- a/src/internal/task/task_stack_amd64_windows.go +++ b/src/internal/task/task_stack_amd64_winabi.go @@ -1,9 +1,9 @@ -//go:build scheduler.tasks && amd64 && windows +//go:build scheduler.tasks && amd64 && (windows || uefi) package task // This is almost the same as task_stack_amd64.go, but with the extra rdi and -// rsi registers saved: Windows has a slightly different calling convention. +// rsi registers saved: Windows and UEFI use the Win64 calling convention. import "unsafe" diff --git a/src/runtime/scheduler_cooperative.go b/src/runtime/scheduler_cooperative.go index 72d9e175c..a69247c84 100644 --- a/src/runtime/scheduler_cooperative.go +++ b/src/runtime/scheduler_cooperative.go @@ -297,10 +297,6 @@ func sleep(duration int64) { if duration <= 0 { return } - if schedulerSleepCustom(duration) { - return - } - addSleepTask(task.Current(), nanosecondsToTicks(duration)) task.Pause() } diff --git a/src/runtime/sleep_custom_default.go b/src/runtime/sleep_custom_default.go deleted file mode 100644 index a32fe1dce..000000000 --- a/src/runtime/sleep_custom_default.go +++ /dev/null @@ -1,7 +0,0 @@ -//go:build !(scheduler.tasks && uefi) - -package runtime - -func schedulerSleepCustom(duration int64) bool { - return false -} diff --git a/targets/uefi-amd64.json b/targets/uefi-amd64.json index c594aecce..a3c0875bb 100644 --- a/targets/uefi-amd64.json +++ b/targets/uefi-amd64.json @@ -6,7 +6,7 @@ "goos": "linux", "goarch": "amd64", "gc": "leaking", - "scheduler": "none", + "scheduler": "tasks", "linker": "ld.lld", "linker-flavor": "coff", "libc": "picolibc", @@ -35,7 +35,8 @@ "extra-files": [ "src/device/amd64/cpu_amd64.S", "src/device/uefi/asm_amd64.S", - "src/runtime/asm_amd64_windows.S" + "src/runtime/asm_amd64_windows.S", + "src/internal/task/task_stack_amd64_windows.S" ], "gdb": ["gdb-multiarch", "gdb"] }