diff --git a/include/PSX/System/callbacks.hpp b/include/PSX/System/callbacks.hxx similarity index 81% rename from include/PSX/System/callbacks.hpp rename to include/PSX/System/callbacks.hxx index ae6e950c..020c353f 100644 --- a/include/PSX/System/callbacks.hpp +++ b/include/PSX/System/callbacks.hxx @@ -2,7 +2,7 @@ #include "syscalls.hpp" namespace JabyEngine { - namespace Callback { + namespace [[deprecated("Callbacks are deprecated for now")]] Callback { struct VSyncCallback { using Function = void (*)(); diff --git a/src/Library/internal-include/BootLoader/boot_loader.hpp b/src/Library/internal-include/BootLoader/boot_loader.hpp index 49b5a6ea..2398c3a9 100644 --- a/src/Library/internal-include/BootLoader/boot_loader.hpp +++ b/src/Library/internal-include/BootLoader/boot_loader.hpp @@ -8,7 +8,7 @@ namespace JabyEngine { void identify(); } - namespace Callbacks { + namespace [[deprecated("Callbacks are deprecated for now")]] Callbacks { void setup(); } diff --git a/src/Library/internal-include/CD/cd_types.hpp b/src/Library/internal-include/CD/cd_types.hpp index 5600a4f2..27252172 100644 --- a/src/Library/internal-include/CD/cd_types.hpp +++ b/src/Library/internal-include/CD/cd_types.hpp @@ -26,9 +26,13 @@ namespace JabyEngine { }; namespace internal { - struct XASectorHeader { + struct RawXADataSector { Header header; SubHeader sub_header; + SubHeader copy_sub_header; + uint8_t data[0x800]; + uint32_t edc; + uint8_t ecc[0x114]; }; class SectorBufferAllocator { diff --git a/src/Library/internal-include/System/callbacks_internal.hpp b/src/Library/internal-include/System/callbacks_internal.hxx similarity index 85% rename from src/Library/internal-include/System/callbacks_internal.hpp rename to src/Library/internal-include/System/callbacks_internal.hxx index 6664e202..a37980a1 100644 --- a/src/Library/internal-include/System/callbacks_internal.hpp +++ b/src/Library/internal-include/System/callbacks_internal.hxx @@ -2,7 +2,7 @@ #include namespace JabyEngine { - namespace Callback { + namespace [[deprecated("Callbacks are deprecated for now")]] Callback { namespace internal { namespace VSync { static constexpr size_t StackSize = 64; diff --git a/src/Library/src/BootLoader/callbacks_boot.cpp b/src/Library/src/BootLoader/callbacks_boot.cxx similarity index 100% rename from src/Library/src/BootLoader/callbacks_boot.cpp rename to src/Library/src/BootLoader/callbacks_boot.cxx diff --git a/src/Library/src/BootLoader/start_boot.cpp b/src/Library/src/BootLoader/start_boot.cpp index 4c85bae2..9af5db2e 100644 --- a/src/Library/src/BootLoader/start_boot.cpp +++ b/src/Library/src/BootLoader/start_boot.cpp @@ -47,7 +47,7 @@ namespace JabyEngine { static constexpr auto DebugScale = 1.0; BIOS::identify(); - Callbacks::setup(); + //Callbacks::setup(); __debug_boot_color_at(::JabyEngine::GPU::Color24::Grey(), DebugX, DebugY, DebugScale); DMA::setup(); diff --git a/src/Library/src/CD/cd.cpp b/src/Library/src/CD/cd.cpp index 90581106..9d566e17 100644 --- a/src/Library/src/CD/cd.cpp +++ b/src/Library/src/CD/cd.cpp @@ -6,7 +6,7 @@ namespace JabyEngine { namespace CD { - namespace internal { + namespace internal { union Configuration { struct File { uint32_t cur_lba; @@ -88,9 +88,6 @@ namespace JabyEngine { static void read_sector_to(uint32_t* dst, size_t bytes) { 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 read_sector_dma(dst, bytes); @@ -100,7 +97,6 @@ namespace JabyEngine { } static void resume_at(const CDTimeStamp& cd_time) { - CD_IO::PortIndex0::change_to(); Command::send(CD_IO::Command::SetLoc, cd_time.get_min_cd(), cd_time.get_sec_cd(), cd_time.get_sector_cd()); CD_IO::PortIndex1::change_to(); @@ -127,6 +123,7 @@ namespace JabyEngine { CD_IO::PortIndex1::change_to(); 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(); cmd_interrupt_bit = bit::clear(cmd_interrupt_bit, cur_irq); @@ -144,8 +141,6 @@ namespace JabyEngine { current_state = State::Done; pause(); } - - goto skip_ack; } else { @@ -169,14 +164,14 @@ namespace JabyEngine { else { switch(cur_irq) { 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(&xa_file), sizeof(XASectorHeader)); + read_sector_to(reinterpret_cast(&xa_file), sizeof(RawXADataSector)); if(cur_cfg.xa.channel == xa_file.sub_header.channel_number) { resume_at(cur_cfg.xa.start_time); Command::send(CD_IO::Command::ReadS); } - goto skip_ack; } break; case CD_IO::Interrupt::DiskError: { @@ -184,15 +179,11 @@ namespace JabyEngine { } 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 CD_IO::IndexStatus.write(old_status); Interrupt::ack_irq(Interrupt::CDROM); + SysCall::ReturnFromException(); __builtin_unreachable(); } diff --git a/src/Library/src/GPU/gpu.cpp b/src/Library/src/GPU/gpu.cpp index 99e7e3d7..86579d29 100644 --- a/src/Library/src/GPU/gpu.cpp +++ b/src/Library/src/GPU/gpu.cpp @@ -1,5 +1,4 @@ #include "../../internal-include/GPU/gpu_internal.hpp" -#include "../../internal-include/System/callbacks_internal.hpp" #include #include #include @@ -41,7 +40,8 @@ namespace JabyEngine { MasterTime::value++; Interrupt::ack_irq(Interrupt::VBlank); - Callback::internal::VSync::execute(); + //Callback::internal::VSync::execute(); + SysCall::ReturnFromException(); __builtin_unreachable(); } diff --git a/src/Library/src/System/callbacks.cpp b/src/Library/src/System/callbacks.cxx similarity index 89% rename from src/Library/src/System/callbacks.cpp rename to src/Library/src/System/callbacks.cxx index d71da9b5..4a8e065a 100644 --- a/src/Library/src/System/callbacks.cpp +++ b/src/Library/src/System/callbacks.cxx @@ -1,8 +1,6 @@ #include "../../internal-include/System/callbacks_internal.hpp" #include -#include - namespace JabyEngine { namespace Callback { VSyncCallback::Function VSyncCallback :: callback = nullptr; @@ -17,6 +15,7 @@ namespace JabyEngine { if(VSyncCallback::callback) { VSyncCallback::callback(); } + SysCall::EnterCriticalSection(); MainThread::restore(); } }