Finished CD_IOs

This commit is contained in:
jaby 2023-01-21 12:18:02 +01:00
parent 817e51b95d
commit 5a23249032
3 changed files with 74 additions and 125 deletions

View File

@ -4,7 +4,7 @@
namespace JabyEngine {
namespace CD_IO {
enum struct Index {
enum Index {
Index0 = 0,
Index1 = 1,
Index2 = 2,
@ -76,135 +76,87 @@ namespace JabyEngine {
static constexpr auto IORegister2Adr = 0x1F801802;
static constexpr auto IORegister3Adr = 0x1F801803;
struct Index0 {
__declare_io_port_member_const_simple(uint8_t, ResponseFifo, IORegister1Adr);
__declare_io_port_member_simple(uint8_t, CommandFifo, IORegister1Adr);
typedef VolatilePOD<uint8_t> ResponseFifo_t;
typedef VolatilePOD<uint8_t> CommandFifo_t;
typedef VolatilePOD<uint8_t> DataFifo_t;
typedef VolatilePOD<uint16_t> DataFifo16_t;
typedef VolatilePOD<uint8_t> ParameterFifo_t;
typedef VolatilePOD<uint8_t> SoundMapDataOut_t;
typedef VolatilePOD<CDDAVolume::Type> VolumeRegister_t;
typedef VolatileBitMapPOD<InterruptEnable> InterruptEnableRegister_t;
typedef VolatileBitMapPOD<InterruptFlag> InterruptFlagRegister_t;
typedef VolatileBitMapPOD<Request> RequestRegister_t;
typedef VolatileBitMapPOD<SoundMapCoding> SoundMapCodingInfo_t;
typedef VolatileBitMapPOD<AudioVolumeApply> AudioVolumeApplyChange_t;
__declare_io_port_member_const_simple(uint8_t, DataFifo, IORegister2Adr);
__declare_io_port_member_const_simple(uint16_t, DataFifo16, IORegister2Adr);
#define __declare_index_io_port(type, name, adr) __cast_io_adr_with_type(inline, type, name, adr)
#define __declare_index_io_port_const(type, name, adr) __cast_io_adr_with_type(const inline, type, name, adr)
struct PortIndex0 {
__declare_index_io_port_const(ResponseFifo_t, ResponseFifo, IORegister1Adr);
__declare_index_io_port( CommandFifo_t, CommandFifo, IORegister1Adr);
__declare_index_io_port_const(DataFifo_t, DataFifo, IORegister2Adr);
__declare_index_io_port_const(DataFifo16_t, DataFifo16, IORegister2Adr);
__declare_index_io_port( ParameterFifo_t, ParameterFifo, IORegister2Adr);
__declare_index_io_port_const(InterruptEnableRegister_t, InterruptEnableRegister, IORegister3Adr);
__declare_index_io_port( RequestRegister_t, RequestRegister, IORegister3Adr);
static void change_to() {
IndexStatus.write({static_cast<uint8_t>(Index::Index0)});
}
};
typedef VolatilePOD<uint8_t> ResponseFifo;
typedef VolatilePOD<uint8_t> CommandFifo;
typedef VolatilePOD<uint8_t> DataFifo;
typedef VolatilePOD<uint16_t> DataFifo16;
typedef VolatilePOD<uint8_t> ParameterFifo;
typedef VolatilePOD<uint8_t> SoundMapDataOut;
typedef VolatilePOD<CDDAVolume::Type> VolumeRegister;
typedef VolatileBitMapPOD<InterruptEnable> InterruptEnableRegister;
typedef VolatileBitMapPOD<InterruptFlag> InterruptFlagRegister;
typedef VolatileBitMapPOD<Request> RequestRegister;
typedef VolatileBitMapPOD<SoundMapCoding> SoundMapCodingInfo;
typedef VolatileBitMapPOD<AudioVolumeApply> AudioVolumeApplyChange;
struct PortIndex1 {
__declare_index_io_port_const(ResponseFifo_t, ResponseFifo, IORegister1Adr);
__declare_index_io_port( SoundMapDataOut_t, SoundMapDataOut, IORegister1Adr);
namespace Index0Types {
struct __no_align IndexTriplet {
union __no_align {
const ResponseFifo response_fifo;
CommandFifo command;
};
__declare_index_io_port_const(DataFifo_t, DataFifo, IORegister2Adr);
__declare_index_io_port_const(DataFifo16_t, DataFifo16, IORegister2Adr);
__declare_index_io_port( InterruptEnableRegister_t, InterruptEnableRegister, IORegister2Adr);
union __no_align {
const DataFifo data_fifo;
ParameterFifo parameter_fifo;
};
__declare_index_io_port(InterruptFlagRegister_t, InterruptFlagRegister, IORegister3Adr);
union __no_align {
const InterruptEnableRegister irq_enable;
RequestRegister request;
};
};
static void change_to() {
IndexStatus.write({static_cast<uint8_t>(Index::Index1)});
}
};
static_assert(sizeof(IndexTriplet) == 3);
}
struct PortIndex2 {
__declare_index_io_port_const(ResponseFifo_t, ResponseFifo, IORegister1Adr);
__declare_index_io_port( SoundMapCodingInfo_t, SoundMapCodingInfo, IORegister1Adr);
namespace Index1Types {
struct __no_align IndexTriplet {
union __no_align {
const ResponseFifo response_fifo;
SoundMapDataOut sound_map_data_out;
};
__declare_index_io_port_const(DataFifo_t, DataFifo, IORegister2Adr);
__declare_index_io_port_const(DataFifo16_t, DataFifo16, IORegister2Adr);
__declare_index_io_port( VolumeRegister_t, LeftCD2LeftSPU, IORegister2Adr);
union __no_align {
const DataFifo data_fifo;
InterruptEnableRegister irq_enable;
};
__declare_index_io_port_const(InterruptEnableRegister_t, InterruptEnableRegister, IORegister3Adr);
__declare_index_io_port( VolumeRegister_t, LeftCD2RightSPU, IORegister3Adr);
union __no_align {
InterruptFlagRegister irq_flag;
};
};
static_assert(sizeof(IndexTriplet) == 3);
}
namespace Index2Types {
struct __no_align IndexTriplet {
union __no_align {
const ResponseFifo response_fifo;
SoundMapCodingInfo sound_map_coding_info;
};
union __no_align {
const DataFifo data_fifo;
VolumeRegister left_cd_2_left_spu;
};
union __no_align {
const InterruptEnableRegister irq_enable;
VolumeRegister left_cd_2_right_spu;
};
};
static_assert(sizeof(IndexTriplet) == 3);
}
namespace Index3Types {
struct __no_align IndexTriplet {
union __no_align {
const ResponseFifo response_fifo;
VolumeRegister right_cd_2_right_spu;
};
union __no_align {
const DataFifo data_fifo;
VolumeRegister right_cd_2_left_spu;
};
union __no_align {
const InterruptFlagRegister irq_flag;
AudioVolumeApplyChange audio_volume_change;
};
};
static_assert(sizeof(IndexTriplet) == 3);
}
namespace Helper {
template<typename S>
static S& change_to(Index idx) {
IndexStatus.write({static_cast<uint8_t>(idx)});
return *reinterpret_cast<S*>(0x1F801801);
static void change_to() {
IndexStatus.write({static_cast<uint8_t>(Index::Index2)});
}
}
};
static Index0Types::IndexTriplet& change_to_index0() {
return Helper::change_to<Index0Types::IndexTriplet>(Index::Index0);
}
struct PortIndex3 {
__declare_index_io_port_const(ResponseFifo_t, ResponseFifo, IORegister1Adr);
__declare_index_io_port( VolumeRegister_t, RightCD2RightSPU, IORegister1Adr);
static Index1Types::IndexTriplet& change_to_index1() {
return Helper::change_to<Index1Types::IndexTriplet>(Index::Index1);
}
__declare_index_io_port_const(DataFifo_t, DataFifo, IORegister2Adr);
__declare_index_io_port_const(DataFifo16_t, DataFifo16, IORegister2Adr);
__declare_index_io_port( VolumeRegister_t, RightCD2LeftSPU, IORegister1Adr);
static Index2Types::IndexTriplet& change_to_index2() {
return Helper::change_to<Index2Types::IndexTriplet>(Index::Index2);
}
__declare_index_io_port_const(InterruptFlagRegister_t, InterruptFlagRegister, IORegister3Adr);
__declare_index_io_port( AudioVolumeApplyChange_t, AudioVolumeApplyChange, IORegister3Adr);
static Index3Types::IndexTriplet& change_to_index3() {
return Helper::change_to<Index3Types::IndexTriplet>(Index::Index2);
}
static void change_to() {
IndexStatus.write({static_cast<uint8_t>(Index::Index3)});
}
};
#undef __declare_index_io_port
#undef __declare_index_io_port_const
}
}

View File

@ -80,14 +80,14 @@ namespace JabyEngine {
#define __cast_io_adr_with_type(cv, type, name, adr) static __always_inline cv auto& name = *reinterpret_cast<type*>(__io_port_adr(adr))
#define __declare_io_port_global(type, name, adr) __cast_io_adr_with_type(, VolatileBitMapPOD<type>, name, adr)
#define __declare_io_port_global(type, name, adr) __cast_io_adr_with_type(, VolatileBitMapPOD<type>, name, adr)
#define __declare_io_port_global_const(type, name, adr) __cast_io_adr_with_type(const, VolatileBitMapPOD<type>, name, adr)
#define __declare_io_port_global_simple(type, name, adr) __cast_io_adr_with_type(, VolatilePOD<type>, name, adr)
#define __declare_io_port_global_simple(type, name, adr) __cast_io_adr_with_type(, VolatilePOD<type>, name, adr)
#define __declare_io_port_global_const_simple(type, name, adr) __cast_io_adr_with_type(const, VolatilePOD<type>, name, adr)
#define __declare_io_port_member(type, name, adr) __cast_io_adr_with_type(inline, VolatileBitMapPOD<type>, name, adr)
#define __declare_io_port_member(type, name, adr) __cast_io_adr_with_type(inline, VolatileBitMapPOD<type>, name, adr)
#define __declare_io_port_member_const(type, name, adr) __cast_io_adr_with_type(const inline, VolatileBitMapPOD<type>, name, adr)
#define __declare_io_port_member_simple(type, name, adr) __cast_io_adr_with_type(inline, VolatilePOD<type>, name, adr)
#define __declare_io_port_member_simple(type, name, adr) __cast_io_adr_with_type(inline, VolatilePOD<type>, name, adr)
#define __declare_io_port_member_const_simple(type, name, adr) __cast_io_adr_with_type(const inline, VolatilePOD<type>, name, adr)
#define __declare_io_port_global_array(type, name, adr, size) static __always_inline auto& name = reinterpret_cast<type(&)[size]>(*reinterpret_cast<type*>(__io_port_adr(adr)))

View File

@ -5,12 +5,9 @@ namespace JabyEngine {
namespace boot {
namespace CD {
void setup() {
}
uint16_t miau() {
CD_IO::Index0::DataFifo.read();
return CD_IO::Index0::DataFifo16.read();
CD_IO::PortIndex0::change_to();
CD_IO::PortIndex0::DataFifo.read();
CD_IO::PortIndex0::DataFifo16.read();
}
}
}