Fixed for real?

This commit is contained in:
Jaby 2024-07-04 12:16:30 +02:00
parent 3ab9d8b1f8
commit 73515933c6
6 changed files with 115 additions and 19 deletions

View File

@ -30,7 +30,7 @@ namespace JabyEngine {
} }
static void ack_irq(Bit irq) { static void ack_irq(Bit irq) {
Status.write(Status.read().clear(irq)); Status.write({bit::clear<uint32_t>(0b11111111111, irq)});
} }
static void disable_irq(Bit irq) { static void disable_irq(Bit irq) {

View File

@ -141,6 +141,27 @@ namespace JabyEngine {
return gp; return gp;
} }
static __always_inline void DequeueCdIntr() {
register uint32_t FuncID asm("t1") = 0xa3;
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
__syscall_function_cast(Table_A, void(*)())();
}
static __always_inline void FlushCache() {
register uint32_t FuncID asm("t1") = 0x44;
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
__syscall_function_cast(Table_A, void(*)())();
}
static __always_inline void SetDefaultExceptionJmpBuf() {
register uint32_t FuncID asm("t1") = 0x18;
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));
__syscall_function_cast(Table_B, void(*)())();
}
static __always_inline void* memcpy(void *dst, const void *src, size_t len) { static __always_inline void* memcpy(void *dst, const void *src, size_t len) {
register uint32_t FuncID asm("t1") = 0x2A; register uint32_t FuncID asm("t1") = 0x2A;
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID)); __asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));

View File

@ -48,7 +48,7 @@ namespace JabyEngine {
setting.get_loc_functional = !CD::get_loc().is_zero(); setting.get_loc_functional = !CD::get_loc().is_zero();
CD::enable_CDXA(double_speed); //< Activates PortIndex0 CD::enable_CDXA(double_speed); //< Activates PortIndex0
set_channel(channel);printf("!!0-%X %X %X\n", setting.start_loc.min, setting.start_loc.sec, setting.start_loc.sector); set_channel(channel);//printf("!!0-%X %X %X\n", setting.start_loc.min, setting.start_loc.sec, setting.start_loc.sector);
CD::Command::send(CD_IO::Command::SetLoc, setting.start_loc.min, setting.start_loc.sec, setting.start_loc.sector); CD::Command::send(CD_IO::Command::SetLoc, setting.start_loc.min, setting.start_loc.sec, setting.start_loc.sector);
CD::Command::send(CD_IO::Command::ReadS); CD::Command::send(CD_IO::Command::ReadS);
} }
@ -75,7 +75,7 @@ namespace JabyEngine {
void pop_play() { void pop_play() {
CD::enable_CDXA(setting.double_speed); //< Activates PortIndex0 CD::enable_CDXA(setting.double_speed); //< Activates PortIndex0
set_channel(setting.channel);printf("!!1-%X %X %X\n", setting.last_loc.min, setting.last_loc.sec, setting.last_loc.sector); set_channel(setting.channel);//printf("!!1-%X %X %X\n", setting.last_loc.min, setting.last_loc.sec, setting.last_loc.sector);
CD::Command::send_wait_response(CD_IO::Command::SetLoc, setting.last_loc.min, setting.last_loc.sec, setting.last_loc.sector); CD::Command::send_wait_response(CD_IO::Command::SetLoc, setting.last_loc.min, setting.last_loc.sec, setting.last_loc.sector);
CD::Command::send(CD_IO::Command::ReadS); CD::Command::send(CD_IO::Command::ReadS);
} }

View File

@ -8,6 +8,7 @@ namespace JabyEngine {
namespace CD { namespace CD {
namespace internal { namespace internal {
extern SysCall::InterruptCallback irq_callback; extern SysCall::InterruptCallback irq_callback;
extern void blubb();
} }
} }
@ -33,21 +34,26 @@ namespace JabyEngine {
// TODO: Verify this on real HW // TODO: Verify this on real HW
CD_IO::Interrupt::enable_extended(CD_IO::PortIndex1::InterruptEnable); CD_IO::Interrupt::enable_extended(CD_IO::PortIndex1::InterruptEnable);
/*const auto event = SysCall::OpenEvent(0xF0000003, 0x1000, 0x1000, ::JabyEngine::CD::internal::blubb);
printf(">>> 0x%p\n", event);
SysCall::EnableEvent(event);*/
Interrupt::enable_irq(Interrupt::CDROM); Interrupt::enable_irq(Interrupt::CDROM);
Interrupt::ack_irq(Interrupt::CDROM); Interrupt::ack_irq(Interrupt::CDROM);
SysCall::ExitCriticalSection(); SysCall::ExitCriticalSection();
__debug_boot_color_at(::JabyEngine::GPU::Color24::Red(), DebugX, DebugY, DebugScale); __debug_boot_color_at(::JabyEngine::GPU::Color24::Red(), DebugX, DebugY, DebugScale);
CD_IO::PortIndex0::change_to(); CD_IO::PortIndex0::change_to();
printf("@%i\n", __LINE__);
__debug_boot_color_at(::JabyEngine::GPU::Color24::Green(), DebugX, DebugY, DebugScale); __debug_boot_color_at(::JabyEngine::GPU::Color24::Green(), DebugX, DebugY, DebugScale);
Command::send(CD_IO::Command::GetStat); Command::send(CD_IO::Command::GetStat);printf("@%i\n", __LINE__);
__debug_boot_color_at(::JabyEngine::GPU::Color24::Blue(), DebugX, DebugY, DebugScale); __debug_boot_color_at(::JabyEngine::GPU::Color24::Blue(), DebugX, DebugY, DebugScale);
Command::send(CD_IO::Command::GetStat); Command::send(CD_IO::Command::GetStat);printf("@%i\n", __LINE__);
__debug_boot_color_at(::JabyEngine::GPU::Color24::Yellow(), DebugX, DebugY, DebugScale); __debug_boot_color_at(::JabyEngine::GPU::Color24::Yellow(), DebugX, DebugY, DebugScale);
Command::send(CD_IO::Command::Init); Command::send(CD_IO::Command::Init);printf("@%i\n", __LINE__);
Command::send(CD_IO::Command::Demute); Command::send(CD_IO::Command::Demute);printf("@%i\n", __LINE__);
} }
} }
} }

View File

@ -46,6 +46,10 @@ namespace JabyEngine {
static constexpr auto DebugY = 0; static constexpr auto DebugY = 0;
static constexpr auto DebugScale = 1.0; static constexpr auto DebugScale = 1.0;
SysCall::FlushCache();
SysCall::DequeueCdIntr();
SysCall::SetDefaultExceptionJmpBuf();
BIOS::identify(); BIOS::identify();
Callbacks::setup(); Callbacks::setup();

View File

@ -50,7 +50,7 @@ namespace JabyEngine {
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); //printf("!!2-%X %X %X\n", loc.min, loc.sec, loc.sector);
Command::send(CD_IO::Command::SetLoc, loc.min, loc.sec, loc.sector); Command::send(CD_IO::Command::SetLoc, loc.min, loc.sec, loc.sector);
Command::send(cmd); Command::send(cmd);
return loc; return loc;
@ -91,7 +91,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); //printf("!!3-%X %X %X\n", cd_time.min, cd_time.sec, cd_time.sector);
Command::send(CD_IO::Command::SetLoc, cd_time.min, cd_time.sec, cd_time.sector); Command::send(CD_IO::Command::SetLoc, cd_time.min, cd_time.sec, cd_time.sector);
} }
@ -117,11 +117,11 @@ namespace JabyEngine {
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::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::Interrupt::reset_parameter_fifo(CD_IO::PortIndex1::InterruptFlag); /*CD_IO::Interrupt::reset_parameter_fifo(CD_IO::PortIndex1::InterruptFlag);
zero = 0; zero = 0;
zero = 1; zero = 1;
zero = 2; zero = 2;
zero = 3; zero = 3;*/
irq_bit_pending = bit::clear(irq_bit_pending, cur_irq); irq_bit_pending = bit::clear(irq_bit_pending, cur_irq);
@ -130,17 +130,13 @@ namespace JabyEngine {
CD_IO::PortIndex0::Request.write(CD_IO::Request::want_data()); CD_IO::PortIndex0::Request.write(CD_IO::Request::want_data());
} }
if(cur_irq == CD_IO::Interrupt::Acknowledge) {
CD_IO::PortIndex0::ResponseFifo.read();
}
// 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);
Callback::internal::CD::execute(cur_irq, irq_bit_pending, cur_irq, last_cmd); Callback::internal::CD::execute(cur_irq, irq_bit_pending, cur_irq, last_cmd);
} }
void process(uint32_t irq) { void process(uint32_t irq) {
printf("%i -> %i -> %i\n", irq_bit_pending, irq, last_cmd); //printf("%i -> %i -> %i\n", irq_bit_pending, irq, last_cmd);
if(current_state != State::XAMode) { if(current_state != State::XAMode) {
switch(irq) { switch(irq) {
case CD_IO::Interrupt::DataReady: { case CD_IO::Interrupt::DataReady: {
@ -150,8 +146,8 @@ namespace JabyEngine {
//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(); /*const auto time = get_locL();
printf("%X %X %X\n", time.min, time.sec, time.sector); 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;
@ -182,6 +178,75 @@ namespace JabyEngine {
} }
} }
} }
uint32_t entered = 0;
void blubb() {
entered = 1;
printf("A\n");
Interrupt::ack_irq(Interrupt::CDROM);
const auto old_status = CD_IO::IndexStatus.read();
CD_IO::PortIndex1::change_to();
const auto cur_irq = CD_IO::Interrupt::get_type(CD_IO::PortIndex1::InterruptFlag);
CD_IO::PortIndex1::change_to();
CD_IO::Interrupt::ack_extended(CD_IO::PortIndex1::InterruptFlag);
CD_IO::Interrupt::reset_parameter_fifo(CD_IO::PortIndex1::InterruptFlag);
zero = 0;
zero = 1;
zero = 2;
zero = 3;
irq_bit_pending = bit::clear(irq_bit_pending, cur_irq);
CD_IO::PortIndex0::change_to();
if(cur_irq == CD_IO::Interrupt::DataReady) {
CD_IO::PortIndex0::Request.write(CD_IO::Request::want_data());
}
if(cur_irq == CD_IO::Interrupt::Acknowledge) {
CD_IO::PortIndex0::ResponseFifo.read();
}
if(current_state != State::XAMode) {
switch(cur_irq) {
case CD_IO::Interrupt::DataReady: {
// Obtain sector content here
auto* sector = sector_allocator.allocate_sector();
if(sector) {
//Now obtain sector
IRQ::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()) {
current_state = State::Done;
Command::send(CD_IO::Command::Pause);
}
}
else {
current_state = State::BufferFull;
Command::send(CD_IO::Command::Pause);
}
} break;
case CD_IO::Interrupt::DataEnd: {
// TODO: Fix this!! This is a freaking static time
IRQ::resume_at0(BCDTimeStamp{.min = 0x0, .sec = 0x09, .sector = 0x0});
Command::send(CD_IO::Command::Play);
} break;
case CD_IO::Interrupt::DiskError: {
current_state = State::Error;
} break;
}
}
else {
current_state = CDXA::interrupt_handler(cur_irq);
}
}
void read_file(AutoLBAEntry file_info, const SectorBufferAllocator& buffer_allocator) { void read_file(AutoLBAEntry file_info, const SectorBufferAllocator& buffer_allocator) {
cur_file.set_from(file_info); cur_file.set_from(file_info);