Integrate all the progress into master #6

Merged
jaby merged 595 commits from ToolBox into main 2025-01-01 13:17:44 +00:00
6 changed files with 115 additions and 19 deletions
Showing only changes of commit 73515933c6 - Show all commits

View File

@ -30,7 +30,7 @@ namespace JabyEngine {
}
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) {

View File

@ -141,6 +141,27 @@ namespace JabyEngine {
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) {
register uint32_t FuncID asm("t1") = 0x2A;
__asm__ volatile("" : "=r"(FuncID) : "r"(FuncID));

View File

@ -48,7 +48,7 @@ namespace JabyEngine {
setting.get_loc_functional = !CD::get_loc().is_zero();
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::ReadS);
}
@ -75,7 +75,7 @@ namespace JabyEngine {
void pop_play() {
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(CD_IO::Command::ReadS);
}

View File

@ -8,6 +8,7 @@ namespace JabyEngine {
namespace CD {
namespace internal {
extern SysCall::InterruptCallback irq_callback;
extern void blubb();
}
}
@ -33,21 +34,26 @@ namespace JabyEngine {
// TODO: Verify this on real HW
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::ack_irq(Interrupt::CDROM);
Interrupt::ack_irq(Interrupt::CDROM);
SysCall::ExitCriticalSection();
__debug_boot_color_at(::JabyEngine::GPU::Color24::Red(), DebugX, DebugY, DebugScale);
CD_IO::PortIndex0::change_to();
printf("@%i\n", __LINE__);
__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);
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);
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 DebugScale = 1.0;
SysCall::FlushCache();
SysCall::DequeueCdIntr();
SysCall::SetDefaultExceptionJmpBuf();
BIOS::identify();
Callbacks::setup();

View File

@ -50,7 +50,7 @@ namespace JabyEngine {
static BCDTimeStamp send_read_cmd0(uint32_t lba, CD_IO::Command::Desc cmd) {
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(cmd);
return loc;
@ -91,7 +91,7 @@ namespace JabyEngine {
}
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);
}
@ -117,11 +117,11 @@ namespace JabyEngine {
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);
/*CD_IO::Interrupt::reset_parameter_fifo(CD_IO::PortIndex1::InterruptFlag);
zero = 0;
zero = 1;
zero = 2;
zero = 3;
zero = 3;*/
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());
}
if(cur_irq == CD_IO::Interrupt::Acknowledge) {
CD_IO::PortIndex0::ResponseFifo.read();
}
// No masking required because we can only write bit 0 - 2
CD_IO::IndexStatus.write(old_status);
Callback::internal::CD::execute(cur_irq, irq_bit_pending, cur_irq, last_cmd);
}
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) {
switch(irq) {
case CD_IO::Interrupt::DataReady: {
@ -150,8 +146,8 @@ namespace JabyEngine {
//Now obtain sector
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);
/*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;
@ -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) {
cur_file.set_from(file_info);