Integrate all the progress into master #6
|
@ -221,9 +221,6 @@ namespace LoadingScene {
|
|||
}
|
||||
|
||||
void main() {
|
||||
printf("Hello Plaschi\n");
|
||||
CDXA::planschi();
|
||||
printf("Bye Bye Planschi\n");
|
||||
setup();
|
||||
|
||||
while(true) {
|
||||
|
|
|
@ -10,7 +10,5 @@ namespace JabyEngine {
|
|||
|
||||
void push_play();
|
||||
void pop_play();
|
||||
|
||||
void planschi();
|
||||
}
|
||||
}
|
|
@ -42,41 +42,35 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
template<typename...ARGS>
|
||||
static void send(CD_IO::Command::Desc cmd, bool sync, ARGS...args) {
|
||||
static void send(CD_IO::Command::Desc cmd, ARGS...args) {
|
||||
while(CD_IO::IndexStatus.read().is_set(CD_IO::IndexStatus::IsTransmissionBusy));
|
||||
|
||||
CD_IO::PortIndex0::change_to();
|
||||
((CD_IO::PortIndex0::ParameterFifo.write(CD_IO::ParameterFifo{args})),...);
|
||||
CD_IO::PortIndex0::CommandFifo.write(CD_IO::CommandFifo{cmd.id});
|
||||
|
||||
if(sync)
|
||||
while(CD_IO::IndexStatus.read().is_set(CD_IO::IndexStatus::IsTransmissionBusy));
|
||||
while(CD_IO::IndexStatus.read().is_set(CD_IO::IndexStatus::IsTransmissionBusy));
|
||||
}
|
||||
};
|
||||
|
||||
// Requires Index 0
|
||||
template<typename...ARGS>
|
||||
static void send(CD_IO::Command::Desc cmd, ARGS...args) {
|
||||
Internal::send(cmd, true, args...);
|
||||
}
|
||||
|
||||
template<typename...ARGS>
|
||||
static void sendX(CD_IO::Command::Desc cmd, ARGS...args) {
|
||||
Internal::send(cmd, false, args...);
|
||||
Internal::send(cmd, args...);
|
||||
}
|
||||
|
||||
// Requires Index 0
|
||||
template<typename...ARGS>
|
||||
static void send_wait_response(CD_IO::Command::Desc cmd, ARGS...args) {
|
||||
Interrupt::disable_irq(Interrupt::CDROM);
|
||||
Internal::send(cmd, true, args...);
|
||||
Internal::send(cmd, args...);
|
||||
Internal::wait_completed(cmd.complete_irq);
|
||||
Interrupt::enable_irq(Interrupt::CDROM);
|
||||
}
|
||||
};
|
||||
|
||||
namespace IRQ {
|
||||
void data_ready_handler(uint32_t data);
|
||||
void process(uint32_t irq);
|
||||
void read_sector_to0(uint32_t* dst, size_t bytes);
|
||||
void resume_at0(const BCDTimeStamp& cd_time);
|
||||
}
|
||||
|
|
|
@ -35,9 +35,10 @@ namespace JabyEngine {
|
|||
|
||||
extern Thread::Handle thread_handle;
|
||||
extern uint32_t stack[StackSize];
|
||||
void routine(uint32_t irq);
|
||||
|
||||
static void execute(uint32_t parm) {
|
||||
execute_callback(CD::thread_handle, parm);
|
||||
static void execute(uint32_t irq) {
|
||||
execute_callback(CD::thread_handle, irq);
|
||||
}
|
||||
|
||||
static uint32_t resume() {
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace JabyEngine {
|
|||
CD::IRQ::read_sector_to0(reinterpret_cast<uint32_t*>(&xa_file), sizeof(CD::RawXADataSector));
|
||||
if(setting.channel == xa_file.sub_header.channel_number) {
|
||||
CD::IRQ::resume_at0(setting.start_loc);
|
||||
CD::NewCommand::sendX(CD_IO::Command::ReadS);
|
||||
CD::NewCommand::send(CD_IO::Command::ReadS);
|
||||
}
|
||||
} break;
|
||||
|
||||
|
@ -67,13 +67,5 @@ namespace JabyEngine {
|
|||
CD::NewCommand::send(CD_IO::Command::SetLoc, setting.last_loc.min, setting.last_loc.sec, setting.last_loc.sector);
|
||||
CD::NewCommand::send(CD_IO::Command::ReadS);
|
||||
}
|
||||
|
||||
void planschi() {
|
||||
for(size_t n = 0; n < 100; n++) {
|
||||
CD::enable_CD();
|
||||
CD::enable_CDXA(false);
|
||||
printf("%i\n", n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
#include "../../internal-include/BootLoader/boot_loader.hpp"
|
||||
#include "../../internal-include/CD/cd_internal.hpp"
|
||||
#include "../../internal-include/System/callbacks_internal.hpp"
|
||||
|
||||
namespace JabyEngine {
|
||||
|
@ -16,7 +15,7 @@ namespace JabyEngine {
|
|||
);
|
||||
Thread::set_user_mode_for(InternalCallback::VSync::thread_handle);*/
|
||||
|
||||
InternalCallback::CD::thread_handle = Thread::create(JabyEngine::CD::internal::IRQ::data_ready_handler, InternalCallback::CD::stack);
|
||||
InternalCallback::CD::thread_handle = Thread::create(InternalCallback::CD::routine, InternalCallback::CD::stack);
|
||||
Thread::set_user_mode_for(InternalCallback::CD::thread_handle);
|
||||
SysCall::ExitCriticalSection();
|
||||
}
|
||||
|
|
|
@ -76,8 +76,6 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
void read_sector_to0(uint32_t* dst, size_t bytes) {
|
||||
CD_IO::PortIndex0::Request.write(CD_IO::Request::want_data());
|
||||
|
||||
// We only support DMA rn
|
||||
read_sector_dma0(dst, bytes);
|
||||
|
||||
|
@ -86,7 +84,7 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
void resume_at0(const BCDTimeStamp& cd_time) {
|
||||
NewCommand::sendX(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);
|
||||
}
|
||||
|
||||
//######################################################################################################################
|
||||
|
@ -107,11 +105,23 @@ namespace JabyEngine {
|
|||
|
||||
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) {
|
||||
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();
|
||||
|
||||
// No masking required because we can only write bit 0 - 2
|
||||
CD_IO::IndexStatus.write(old_status);
|
||||
Callback::internal::CD::execute(cur_irq);
|
||||
}
|
||||
|
||||
void process(uint32_t irq) {
|
||||
if(current_state != State::XAMode) {
|
||||
switch(cur_irq) {
|
||||
switch(irq) {
|
||||
case CD_IO::Interrupt::DataReady: {
|
||||
// Obtain sector content here
|
||||
auto* sector = sector_allocator.allocate_sector();
|
||||
|
@ -138,31 +148,13 @@ namespace JabyEngine {
|
|||
} break;
|
||||
|
||||
case CD_IO::Interrupt::DiskError: {
|
||||
printf("CD ERROR\n");
|
||||
current_state = State::Error;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
current_state = CDXA::interrupt_handler(cur_irq);
|
||||
}
|
||||
|
||||
// No masking required because we can only write bit 0 - 2
|
||||
CD_IO::IndexStatus.write(old_status);
|
||||
Callback::internal::CD::execute(cur_irq);
|
||||
}
|
||||
|
||||
void data_ready_handler(uint32_t data) {
|
||||
while(true) {
|
||||
if(current_state == State::XAMode) {
|
||||
if(data == CD_IO::Interrupt::DataReady) {
|
||||
printf("Scree...\n");
|
||||
IRQ::resume_at0(BCDTimeStamp::from(221));
|
||||
NewCommand::send(CD_IO::Command::ReadS);
|
||||
}
|
||||
}
|
||||
data = Callback::internal::CD::resume();
|
||||
current_state = CDXA::interrupt_handler(irq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,17 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
namespace CD {
|
||||
namespace CD_IRQ = JabyEngine::CD::internal::IRQ;
|
||||
|
||||
SysCall::ThreadHandle thread_handle = 0;
|
||||
uint32_t stack[StackSize];
|
||||
|
||||
void routine(uint32_t irq) {
|
||||
while(true) {
|
||||
CD_IRQ::process(irq);
|
||||
irq = Callback::internal::CD::resume();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue