Fix CD cancelling commands; Cleanup CD code a bit
This commit is contained in:
@@ -5,20 +5,13 @@
|
||||
namespace JabyEngine {
|
||||
namespace CD {
|
||||
namespace internal {
|
||||
extern State current_state;
|
||||
extern CD_IO::Interrupt::Type last_interrupt;
|
||||
extern State current_state;
|
||||
|
||||
static CD_IO::Interrupt::Type read_last_interrupt() {
|
||||
return const_cast<volatile CD_IO::Interrupt::Type&>(last_interrupt);
|
||||
}
|
||||
|
||||
static State read_current_state() {
|
||||
return const_cast<volatile State&>(current_state);
|
||||
}
|
||||
extern uint8_t cmd_interrupt_bit;
|
||||
|
||||
struct Command {
|
||||
static void wait_until(CD_IO::Interrupt::Type irq) {
|
||||
while(read_last_interrupt() != irq);
|
||||
static void wait_completed() {
|
||||
while(const_cast<volatile uint8_t&>(cmd_interrupt_bit) > 0);
|
||||
}
|
||||
|
||||
template<typename...ARGS>
|
||||
@@ -26,7 +19,8 @@ namespace JabyEngine {
|
||||
while(CD_IO::IndexStatus.is_set(CD_IO::IndexStatus_t::IsTransmissionBusy));
|
||||
|
||||
((parameter_fifo = args),...);
|
||||
cmd_fifo = cmd.id;
|
||||
cmd_fifo = cmd.id;
|
||||
cmd_interrupt_bit = bit::set(0, cmd.complete_irq);
|
||||
}
|
||||
|
||||
template<typename T, typename...ARGS>
|
||||
@@ -37,7 +31,7 @@ namespace JabyEngine {
|
||||
template<typename...ARGS>
|
||||
static void send_wait(CD_IO::CommandFifo_v& cmd_fifo, CD_IO::ParameterFifo_v& parameter_fifo, CD_IO::Command::Desc cmd, ARGS...args) {
|
||||
send(cmd_fifo, parameter_fifo, cmd, args...);
|
||||
wait_until(cmd.complete_irq);
|
||||
wait_completed();
|
||||
}
|
||||
|
||||
template<typename T, typename...ARGS>
|
||||
@@ -46,6 +40,10 @@ namespace JabyEngine {
|
||||
}
|
||||
};
|
||||
|
||||
static State read_current_state() {
|
||||
return const_cast<volatile State&>(current_state);
|
||||
}
|
||||
|
||||
void read_file(FileInfo file_info, const SectorBufferAllocator& buffer_allocator);
|
||||
void continue_reading();
|
||||
}
|
||||
|
Reference in New Issue
Block a user