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

View File

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