From 5f450709617d2191ee90548299d15dd449435b3e Mon Sep 17 00:00:00 2001 From: Jaby Date: Mon, 13 May 2024 22:29:23 +0200 Subject: [PATCH] Unlock user mode in callback (buggy in XEBRA?) --- src/Library/src/CD/cd.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/Library/src/CD/cd.cpp b/src/Library/src/CD/cd.cpp index 7d557d51..e1674654 100644 --- a/src/Library/src/CD/cd.cpp +++ b/src/Library/src/CD/cd.cpp @@ -112,18 +112,7 @@ namespace JabyEngine { } break; case CD_IO::Interrupt::DataEnd: { - - //set_tcb(get_tcb_of_th(thread)); - - /*printf("EPC: 0x%p; SR: 0x%p\n", get_current_tcb().reg[31], get_current_tcb().sr); - get_current_tcb().reg[31] = (uint32_t)(void(*)())[]() { - printf("Wuff! Now crash!\n"); - while(true); - }; - printf("EPC: 0x%p; SR: 0x%p\n", get_current_tcb().reg[31], get_current_tcb().sr); while(true);*/ - //SysCall::ReturnFromException(); - - if(thread != 0) { + if(thread != 0 && table_of_tables.processes->current_tcb == &table_of_tables.threads[0]) { //changeThread(thread); printf("About to change...\n"); table_of_tables.processes->current_tcb = &table_of_tables.threads[thread&0xFFFF]; @@ -169,13 +158,18 @@ namespace JabyEngine { printf("Hallo!\n"); CD_IO::PortIndex0::change_to(); - Command::send(CD_IO::Command::SetLoc, static_cast(0x0), static_cast(0x09), static_cast(0x0)); + printf("Wait...\n"); + Command::send_wait(CD_IO::Command::SetLoc, static_cast(0x0), static_cast(0x09), static_cast(0x0)); + printf("Done!\n"); Command::send(CD_IO::Command::Play); table_of_tables.processes->current_tcb = &table_of_tables.threads[0]; SysCall::ReturnFromException(); - }, reinterpret_cast(0x80010000), SysCall::get_gp()); + }, &stack[1023], SysCall::get_gp()); SysCall::ExitCriticalSection(); + + table_of_tables.threads[thread&0xFFFF].sr = table_of_tables.threads[0].sr; + printf(">>> 0x%X\n", table_of_tables.threads[0].sr); } Command::wait_completed();