Fixup CD freeze?

This commit is contained in:
jaby 2024-07-01 23:01:41 +02:00
parent 271733a7fe
commit 07756fd180
2 changed files with 30 additions and 3 deletions

View File

@ -31,6 +31,7 @@ ENTRY(_ZN10JabyEngine5startEv)
TLOAD_ADDR = DEFINED(TLOAD_ADDR) ? TLOAD_ADDR : 0x80010000; TLOAD_ADDR = DEFINED(TLOAD_ADDR) ? TLOAD_ADDR : 0x80010000;
MEMORY { MEMORY {
zero : ORIGIN = 0x0 LENGTH = 0x100
bios : ORIGIN = 0x100, LENGTH = 0x500 bios : ORIGIN = 0x100, LENGTH = 0x500
loader : ORIGIN = (TLOAD_ADDR - 0x800), LENGTH = 2048 loader : ORIGIN = (TLOAD_ADDR - 0x800), LENGTH = 2048
ram(rwx) : ORIGIN = 0x80010000, LENGTH = 2M - 0x10000 ram(rwx) : ORIGIN = 0x80010000, LENGTH = 2M - 0x10000
@ -53,6 +54,10 @@ __stack_start = ORIGIN(ram) + LENGTH(ram);
SECTIONS { SECTIONS {
.zero (NOLOAD) : {
_ZN10JabyEngine2CD4zeroE = .;
} > zero
.bios (NOLOAD) : { .bios (NOLOAD) : {
_ZN10JabyEngine15table_of_tablesE = .; _ZN10JabyEngine15table_of_tablesE = .;
} > bios } > bios

View File

@ -40,11 +40,13 @@ namespace JabyEngine {
static File cur_file; static File cur_file;
State current_state = State::Ready; State current_state = State::Ready;
auto irq_callback = SysCall::InterruptCallback::from(IRQ::verifier, IRQ::handler); auto irq_callback = SysCall::InterruptCallback::from(IRQ::verifier, IRQ::handler);
static BCDTimeStamp send_read_cmd0(uint32_t lba, CD_IO::Command::Desc cmd) { static BCDTimeStamp send_read_cmd0(uint32_t lba, CD_IO::Command::Desc cmd) {
const auto loc = BCDTimeStamp::from(lba); const auto loc = BCDTimeStamp::from(lba);
printf("!!2-%X %X %X\n", loc.min, loc.sec, loc.sector);
NewCommand::send(CD_IO::Command::SetLoc, loc.min, loc.sec, loc.sector); NewCommand::send(CD_IO::Command::SetLoc, loc.min, loc.sec, loc.sector);
NewCommand::send(cmd); NewCommand::send(cmd);
return loc; return loc;
@ -67,6 +69,7 @@ namespace JabyEngine {
DMA_IO::CDROM.channel_ctrl.write(DMA_IO::CHCHR::StartCDROM()); DMA_IO::CDROM.channel_ctrl.write(DMA_IO::CHCHR::StartCDROM());
DMA_IO::CDROM.wait(); DMA_IO::CDROM.wait();
CD_IO::PortIndex0::change_to();
CD_IO::PortIndex0::Request.write(CD_IO::Request::reset()); CD_IO::PortIndex0::Request.write(CD_IO::Request::reset());
}; };
@ -84,6 +87,7 @@ namespace JabyEngine {
} }
void resume_at0(const BCDTimeStamp& cd_time) { void resume_at0(const BCDTimeStamp& cd_time) {
printf("!!3-%X %X %X\n", cd_time.min, cd_time.sec, cd_time.sector);
NewCommand::send(CD_IO::Command::SetLoc, cd_time.min, cd_time.sec, cd_time.sector); NewCommand::send(CD_IO::Command::SetLoc, cd_time.min, cd_time.sec, cd_time.sector);
} }
@ -104,15 +108,20 @@ namespace JabyEngine {
const auto old_status = CD_IO::IndexStatus.read(); const auto old_status = CD_IO::IndexStatus.read();
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);
if(cur_irq == CD_IO::Interrupt::DataReady) { const auto is_data_rdy = cur_irq == CD_IO::Interrupt::DataReady;
if(is_data_rdy) {
CD_IO::PortIndex0::change_to(); 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::PortIndex1::change_to();
CD_IO::Interrupt::ack_extended(CD_IO::PortIndex1::InterruptFlag); CD_IO::Interrupt::ack_extended(CD_IO::PortIndex1::InterruptFlag);
CD_IO::PortIndex0::change_to(); CD_IO::Interrupt::reset_parameter_fifo(CD_IO::PortIndex1::InterruptFlag);
zero = 0;
zero = 1;
zero = 2;
zero = 3;
// 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);
@ -128,6 +137,9 @@ namespace JabyEngine {
if(sector) { if(sector) {
//Now obtain sector //Now obtain sector
read_sector_to0(sector->data, CD_IO::DataSector::SizeBytes); read_sector_to0(sector->data, CD_IO::DataSector::SizeBytes);
const auto time = get_locL();
printf("%X %X %X\n", time.min, time.sec, time.sector);
if(cur_file.done_processing()) { if(cur_file.done_processing()) {
current_state = State::Done; current_state = State::Done;
@ -194,6 +206,16 @@ namespace JabyEngine {
return BCDTimeStamp{min, sec, sectors}; return BCDTimeStamp{min, sec, sectors};
} }
BCDTimeStamp get_locL() {
NewCommand::send_wait_response(CD_IO::Command::GetLocL);
const auto min = CD_IO::PortIndex0::ResponseFifo.read().raw;
const auto sec = CD_IO::PortIndex0::ResponseFifo.read().raw;
const auto sector = CD_IO::PortIndex0::ResponseFifo.read().raw;
return BCDTimeStamp{min, sec, sector};
}
void enable_CD() { void enable_CD() {
NewCommand::send(CD_IO::Command::SetMode, DataSectorMode); NewCommand::send(CD_IO::Command::SetMode, DataSectorMode);
} }