Integrate all the progress into master #6

Merged
jaby merged 595 commits from ToolBox into main 2025-01-01 13:17:44 +00:00
2 changed files with 30 additions and 3 deletions
Showing only changes of commit 2e7f6cd20f - Show all commits

View File

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

View File

@ -40,11 +40,13 @@ namespace JabyEngine {
static File cur_file;
State current_state = State::Ready;
auto irq_callback = SysCall::InterruptCallback::from(IRQ::verifier, IRQ::handler);
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);
NewCommand::send(CD_IO::Command::SetLoc, loc.min, loc.sec, loc.sector);
NewCommand::send(cmd);
return loc;
@ -67,6 +69,7 @@ namespace JabyEngine {
DMA_IO::CDROM.channel_ctrl.write(DMA_IO::CHCHR::StartCDROM());
DMA_IO::CDROM.wait();
CD_IO::PortIndex0::change_to();
CD_IO::PortIndex0::Request.write(CD_IO::Request::reset());
};
@ -84,6 +87,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);
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();
CD_IO::PortIndex1::change_to();
const auto cur_irq = CD_IO::Interrupt::get_type(CD_IO::PortIndex1::InterruptFlag);
if(cur_irq == CD_IO::Interrupt::DataReady) {
const auto cur_irq = CD_IO::Interrupt::get_type(CD_IO::PortIndex1::InterruptFlag);
const auto is_data_rdy = cur_irq == CD_IO::Interrupt::DataReady;
if(is_data_rdy) {
CD_IO::PortIndex0::change_to();
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();
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
CD_IO::IndexStatus.write(old_status);
@ -128,6 +137,9 @@ namespace JabyEngine {
if(sector) {
//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);
if(cur_file.done_processing()) {
current_state = State::Done;
@ -194,6 +206,16 @@ namespace JabyEngine {
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() {
NewCommand::send(CD_IO::Command::SetMode, DataSectorMode);
}