Fix GPU freeze

This commit is contained in:
jaby 2024-05-29 21:25:52 +02:00
parent 30495279eb
commit 477fbf59e7
3 changed files with 12 additions and 8 deletions

View File

@ -63,7 +63,6 @@ namespace JabyEngine {
void enable_CDXA(bool double_speed); void enable_CDXA(bool double_speed);
static void pause() { static void pause() {
CD_IO::PortIndex0::change_to();
Command::send<CD_IO::PortIndex0>(CD_IO::Command::Pause); Command::send<CD_IO::PortIndex0>(CD_IO::Command::Pause);
} }
} }

View File

@ -29,8 +29,6 @@ namespace JabyEngine {
struct XASectorHeader { struct XASectorHeader {
Header header; Header header;
SubHeader sub_header; SubHeader sub_header;
SubHeader copy_subheader;
uint32_t part_data;
}; };
class SectorBufferAllocator { class SectorBufferAllocator {

View File

@ -87,8 +87,10 @@ 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::change_to();
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);
@ -125,7 +127,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();
cmd_interrupt_bit = bit::clear(cmd_interrupt_bit, cur_irq); cmd_interrupt_bit = bit::clear(cmd_interrupt_bit, cur_irq);
@ -142,6 +144,8 @@ namespace JabyEngine {
current_state = State::Done; current_state = State::Done;
pause(); pause();
} }
goto skip_ack;
} }
else { else {
@ -172,6 +176,7 @@ namespace JabyEngine {
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: {
@ -179,6 +184,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);
@ -193,7 +203,6 @@ namespace JabyEngine {
sector_allocator = buffer_allocator; sector_allocator = buffer_allocator;
Command::wait_completed(); Command::wait_completed();
CD_IO::PortIndex0::change_to();
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, DataSectorMode); Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, DataSectorMode);
send_read_n(cur_cfg.file.cur_lba); send_read_n(cur_cfg.file.cur_lba);
@ -235,7 +244,6 @@ namespace JabyEngine {
void enable_CDDA() { void enable_CDDA() {
Command::wait_completed(); Command::wait_completed();
CD_IO::PortIndex0::change_to();
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, AudioSectorMode); Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, AudioSectorMode);
} }
@ -246,7 +254,6 @@ namespace JabyEngine {
const uint8_t mode = XAAudioSectorMode.raw | (double_speed ? DoubleSpeedBit : SingleSpeedBit); const uint8_t mode = XAAudioSectorMode.raw | (double_speed ? DoubleSpeedBit : SingleSpeedBit);
Command::wait_completed(); Command::wait_completed();
CD_IO::PortIndex0::change_to();
Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, mode); Command::send_wait<CD_IO::PortIndex0>(CD_IO::Command::SetMode, mode);
} }
} }