Fix for No and disabeling of callback support for now

This commit is contained in:
Jaby 2024-05-31 22:48:06 +02:00
parent 457422877f
commit 3eb2cc350f
9 changed files with 18 additions and 24 deletions

View File

@ -2,7 +2,7 @@
#include "syscalls.hpp" #include "syscalls.hpp"
namespace JabyEngine { namespace JabyEngine {
namespace Callback { namespace [[deprecated("Callbacks are deprecated for now")]] Callback {
struct VSyncCallback { struct VSyncCallback {
using Function = void (*)(); using Function = void (*)();

View File

@ -8,7 +8,7 @@ namespace JabyEngine {
void identify(); void identify();
} }
namespace Callbacks { namespace [[deprecated("Callbacks are deprecated for now")]] Callbacks {
void setup(); void setup();
} }

View File

@ -26,9 +26,13 @@ namespace JabyEngine {
}; };
namespace internal { namespace internal {
struct XASectorHeader { struct RawXADataSector {
Header header; Header header;
SubHeader sub_header; SubHeader sub_header;
SubHeader copy_sub_header;
uint8_t data[0x800];
uint32_t edc;
uint8_t ecc[0x114];
}; };
class SectorBufferAllocator { class SectorBufferAllocator {

View File

@ -2,7 +2,7 @@
#include <PSX/System/threads.hpp> #include <PSX/System/threads.hpp>
namespace JabyEngine { namespace JabyEngine {
namespace Callback { namespace [[deprecated("Callbacks are deprecated for now")]] Callback {
namespace internal { namespace internal {
namespace VSync { namespace VSync {
static constexpr size_t StackSize = 64; static constexpr size_t StackSize = 64;

View File

@ -47,7 +47,7 @@ namespace JabyEngine {
static constexpr auto DebugScale = 1.0; static constexpr auto DebugScale = 1.0;
BIOS::identify(); BIOS::identify();
Callbacks::setup(); //Callbacks::setup();
__debug_boot_color_at(::JabyEngine::GPU::Color24::Grey(), DebugX, DebugY, DebugScale); __debug_boot_color_at(::JabyEngine::GPU::Color24::Grey(), DebugX, DebugY, DebugScale);
DMA::setup(); DMA::setup();

View File

@ -6,7 +6,7 @@
namespace JabyEngine { namespace JabyEngine {
namespace CD { namespace CD {
namespace internal { namespace internal {
union Configuration { union Configuration {
struct File { struct File {
uint32_t cur_lba; uint32_t cur_lba;
@ -88,9 +88,6 @@ namespace JabyEngine {
static void read_sector_to(uint32_t* dst, size_t bytes) { static void read_sector_to(uint32_t* dst, size_t bytes) {
CD_IO::PortIndex0::Request.write(CD_IO::Request::want_data()); CD_IO::PortIndex0::Request.write(CD_IO::Request::want_data());
CD_IO::PortIndex1::change_to();
CD_IO::Interrupt::ack_extended(CD_IO::PortIndex1::InterruptFlag);
CD_IO::PortIndex0::change_to();
// We only support DMA rn // We only support DMA rn
read_sector_dma(dst, bytes); read_sector_dma(dst, bytes);
@ -100,7 +97,6 @@ namespace JabyEngine {
} }
static void resume_at(const CDTimeStamp& cd_time) { static void resume_at(const CDTimeStamp& cd_time) {
CD_IO::PortIndex0::change_to();
Command::send<CD_IO::PortIndex0>(CD_IO::Command::SetLoc, cd_time.get_min_cd(), cd_time.get_sec_cd(), cd_time.get_sector_cd()); Command::send<CD_IO::PortIndex0>(CD_IO::Command::SetLoc, cd_time.get_min_cd(), cd_time.get_sec_cd(), cd_time.get_sector_cd());
CD_IO::PortIndex1::change_to(); CD_IO::PortIndex1::change_to();
@ -127,6 +123,7 @@ namespace JabyEngine {
CD_IO::PortIndex1::change_to(); CD_IO::PortIndex1::change_to();
const auto cur_irq = CD_IO::Interrupt::get_type(CD_IO::PortIndex1::InterruptFlag); const auto cur_irq = CD_IO::Interrupt::get_type(CD_IO::PortIndex1::InterruptFlag);
CD_IO::Interrupt::ack_extended(CD_IO::PortIndex1::InterruptFlag);
CD_IO::PortIndex0::change_to(); CD_IO::PortIndex0::change_to();
cmd_interrupt_bit = bit::clear(cmd_interrupt_bit, cur_irq); cmd_interrupt_bit = bit::clear(cmd_interrupt_bit, cur_irq);
@ -144,8 +141,6 @@ namespace JabyEngine {
current_state = State::Done; current_state = State::Done;
pause(); pause();
} }
goto skip_ack;
} }
else { else {
@ -169,14 +164,14 @@ namespace JabyEngine {
else { else {
switch(cur_irq) { switch(cur_irq) {
case CD_IO::Interrupt::DataReady: { case CD_IO::Interrupt::DataReady: {
XASectorHeader xa_file; // The IRQ stack is 0x1000 bytes large so this should fit
RawXADataSector xa_file;
read_sector_to(reinterpret_cast<uint32_t*>(&xa_file), sizeof(XASectorHeader)); read_sector_to(reinterpret_cast<uint32_t*>(&xa_file), sizeof(RawXADataSector));
if(cur_cfg.xa.channel == xa_file.sub_header.channel_number) { if(cur_cfg.xa.channel == xa_file.sub_header.channel_number) {
resume_at(cur_cfg.xa.start_time); resume_at(cur_cfg.xa.start_time);
Command::send<CD_IO::PortIndex0>(CD_IO::Command::ReadS); Command::send<CD_IO::PortIndex0>(CD_IO::Command::ReadS);
} }
goto skip_ack;
} break; } break;
case CD_IO::Interrupt::DiskError: { case CD_IO::Interrupt::DiskError: {
@ -184,15 +179,11 @@ namespace JabyEngine {
} break; } break;
}; };
} }
CD_IO::PortIndex1::change_to();
CD_IO::Interrupt::ack_extended(CD_IO::PortIndex1::InterruptFlag);
skip_ack:
CD_IO::PortIndex0::change_to();
// No masking required because we can only write bit 0 - 2 // No masking required because we can only write bit 0 - 2
CD_IO::IndexStatus.write(old_status); CD_IO::IndexStatus.write(old_status);
Interrupt::ack_irq(Interrupt::CDROM); Interrupt::ack_irq(Interrupt::CDROM);
SysCall::ReturnFromException(); SysCall::ReturnFromException();
__builtin_unreachable(); __builtin_unreachable();
} }

View File

@ -1,5 +1,4 @@
#include "../../internal-include/GPU/gpu_internal.hpp" #include "../../internal-include/GPU/gpu_internal.hpp"
#include "../../internal-include/System/callbacks_internal.hpp"
#include <PSX/Timer/frame_timer.hpp> #include <PSX/Timer/frame_timer.hpp>
#include <PSX/System/IOPorts/interrupt_io.hpp> #include <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/syscalls.hpp> #include <PSX/System/syscalls.hpp>
@ -41,7 +40,8 @@ namespace JabyEngine {
MasterTime::value++; MasterTime::value++;
Interrupt::ack_irq(Interrupt::VBlank); Interrupt::ack_irq(Interrupt::VBlank);
Callback::internal::VSync::execute(); //Callback::internal::VSync::execute();
SysCall::ReturnFromException();
__builtin_unreachable(); __builtin_unreachable();
} }

View File

@ -1,8 +1,6 @@
#include "../../internal-include/System/callbacks_internal.hpp" #include "../../internal-include/System/callbacks_internal.hpp"
#include <PSX/System/callbacks.hpp> #include <PSX/System/callbacks.hpp>
#include <stdio.hpp>
namespace JabyEngine { namespace JabyEngine {
namespace Callback { namespace Callback {
VSyncCallback::Function VSyncCallback :: callback = nullptr; VSyncCallback::Function VSyncCallback :: callback = nullptr;
@ -17,6 +15,7 @@ namespace JabyEngine {
if(VSyncCallback::callback) { if(VSyncCallback::callback) {
VSyncCallback::callback(); VSyncCallback::callback();
} }
SysCall::EnterCriticalSection();
MainThread::restore(); MainThread::restore();
} }
} }