Skip to content

Commit

Permalink
Merge pull request #1676 from nicolasnoble/psyqo-trampoline
Browse files Browse the repository at this point in the history
Shuffling psyqo's trampoline initialization.
  • Loading branch information
nicolasnoble committed Jun 24, 2024
2 parents 7582595 + 7ce6042 commit 2694cb4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/mips/psyqo/src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ void trampoline(int slot) { s_functions[slot].lambda(); }
KernelEventFunction allocateEventFunction(eastl::function<void()>&& lambda) {
for (unsigned slot = 0; slot < SLOTS; slot++) {
if (!s_functions[slot].lambda) {
s_functions[slot].code[0] = Mips::Encoder::j(reinterpret_cast<uint32_t>(trampoline));
s_functions[slot].code[1] = Mips::Encoder::addiu(Mips::Encoder::Reg::A0, Mips::Encoder::Reg::R0, slot);
s_functions[slot].lambda = eastl::move(lambda);
syscall_flushCache();
return s_functions[slot].getFunction();
}
}
Expand Down Expand Up @@ -157,6 +154,11 @@ void psyqo::Kernel::Internal::addInitializer(eastl::function<void()>&& lambda) {
}

void psyqo::Kernel::Internal::prepare() {
for (unsigned slot = 0; slot < SLOTS; slot++) {
s_functions[slot].code[0] = Mips::Encoder::j(reinterpret_cast<uint32_t>(trampoline));
s_functions[slot].code[1] = Mips::Encoder::addiu(Mips::Encoder::Reg::A0, Mips::Encoder::Reg::R0, slot);
}
syscall_flushCache();
syscall_dequeueCDRomHandlers();
syscall_setDefaultExceptionJmpBuf();
uint32_t event = syscall_openEvent(EVENT_DMA, 0x1000, EVENT_MODE_CALLBACK, []() {
Expand Down

0 comments on commit 2694cb4

Please sign in to comment.