Support CD Callback

This commit is contained in:
2024-06-14 20:53:30 +02:00
parent 4e95d7b6b2
commit f74be026e0
4 changed files with 26 additions and 15 deletions

View File

@@ -4,14 +4,20 @@
namespace JabyEngine {
namespace Callback {
namespace internal {
static void execute_callback(Thread::Handle thread_handle) {
static void execute_callback(Thread::Handle thread_handle, uint32_t parm) {
if(CurrentThread::is_me(MainThread::Handle)) {
CurrentThread::replace_with(thread_handle);
CurrentThread::force_a0(parm);
}
SysCall::ReturnFromException();
}
static uint32_t resume_callback(Thread::Handle handle) {
SysCall::ChangeThread(handle);
asm("sw $a0, %0" : "=m"(handle));
return handle;
}
namespace VSync {
static constexpr size_t StackSize = 64;
@@ -20,18 +26,22 @@ namespace JabyEngine {
void routine();
static void [[deprecated("Currently not in use")]] execute() {
execute_callback(VSync::thread_handle);
execute_callback(VSync::thread_handle, 0);
}
}
namespace CD {
static constexpr size_t StackSize = 256;
extern SysCall::ThreadHandle thread_handle;
extern uint32_t stack[StackSize];
extern Thread::Handle thread_handle;
extern uint32_t stack[StackSize];
static void execute() {
execute_callback(CD::thread_handle);
static void execute(uint32_t parm) {
execute_callback(CD::thread_handle, parm);
}
static uint32_t resume() {
return resume_callback(MainThread::Handle);
}
}
}