#ifndef __JABYENGINE_CD_INTERNAL_HPP__ #define __JABYENGINE_CD_INTERNAL_HPP__ #include "cd_types.hpp" namespace JabyEngine { namespace CD { namespace internal { extern CD_IO::Interrupt::Type last_interrupt; extern State current_state; static CD_IO::Interrupt::Type read_last_interrupt() { return const_cast(last_interrupt); } static State read_current_state() { return const_cast(current_state); } struct Command { static void wait_until(CD_IO::Interrupt::Type irq) { while(read_last_interrupt() != irq); } template static void send(CD_IO::CommandFifo_t& cmd_fifo, CD_IO::ParameterFifo_t& parameter_fifo, CD_IO::Command::Info cmd, ARGS...args) { while(CD_IO::IndexStatus.read().is_bit_set(CD_IO::IndexStatus::IsTransmissionBusy)); (parameter_fifo.write(static_cast(args)), ...); cmd_fifo.write(cmd.id); } template static void send(CD_IO::Command::Info cmd, ARGS...args) { send(T::CommandFifo, T::ParameterFifo, cmd, args...); } template static void send_wait(CD_IO::CommandFifo_t& cmd_fifo, CD_IO::ParameterFifo_t& parameter_fifo, CD_IO::Command::Info cmd, ARGS...args) { send(cmd_fifo, parameter_fifo, cmd, args...); wait_until(cmd.complete_irq); } template static void send_wait(CD_IO::Command::Info cmd, ARGS...args) { send_wait(T::CommandFifo, T::ParameterFifo, cmd, args...); } }; void read_file(FileInfo file_info, const SectorBufferAllocator& buffer_allocator); } } } #endif //!__JABYENGINE_CD_INTERNAL_HPP__