From 954f66092946ed0f14f0da10aa90ac08b8dfdfbd Mon Sep 17 00:00:00 2001 From: Jaby Date: Thu, 12 Jan 2023 21:51:08 +0100 Subject: [PATCH] First proposial for CD support --- include/PSX/System/IOPorts/cd_io.hpp | 55 ++++++++++++++++++- .../include/BootLoader/boot_loader.hpp | 6 ++ src/Library/src/BootLoader/cd_boot.cpp | 10 ++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 src/Library/src/BootLoader/cd_boot.cpp diff --git a/include/PSX/System/IOPorts/cd_io.hpp b/include/PSX/System/IOPorts/cd_io.hpp index ecd6d0e8..857902a1 100644 --- a/include/PSX/System/IOPorts/cd_io.hpp +++ b/include/PSX/System/IOPorts/cd_io.hpp @@ -4,7 +4,60 @@ namespace JabyEngine { namespace CD_IO { - + enum struct Index { + Index0 = 0, + Index1 = 1, + Index2 = 2, + Index3 = 3, + }; + + struct __no_align IndexStatus : public ComplexBitMap { + __io_port_inherit_complex_bit_map(IndexStatus); + + static constexpr auto PortIndex = BitRange::from_to(0, 1); + static constexpr auto HasXAFifoData = Bit(2); + static constexpr auto IsParameterFifoEmpty = Bit(3); + static constexpr auto HasParameterFifoSpace = Bit(4); + static constexpr auto HasResponseFifoData = Bit(5); + static constexpr auto HasDataFifoData = Bit(6); + static constexpr auto IsTransmissionBusy = Bit(7); + }; + + namespace Index0Types { + struct __no_align IndexTriplet { + // Replace with proper types later + union __no_align { + const IOPort response_fifo; + IOPort command; + }; + + union __no_align { + const IOPort data_fifo; + IOPort parameter_fifo; + }; + + union __no_align { + const IOPort irq_enable; + IOPort irq_request; + }; + }; + + static_assert(sizeof(IndexTriplet) == 3); + } + + __declare_io_port_global(struct IndexStatus, IndexStatus, 0x1F801800); + + namespace Helper { + template + static S& change_to(Index idx) { + IndexStatus.write(ComplexBitMap(static_cast(idx))); + return *reinterpret_cast(0x1F801801); + } + } + + static Index0Types::IndexTriplet& change_to_index0() { + return Helper::change_to(Index::Index0); + } } } diff --git a/src/Library/include/BootLoader/boot_loader.hpp b/src/Library/include/BootLoader/boot_loader.hpp index 953688e1..e4c75c08 100644 --- a/src/Library/include/BootLoader/boot_loader.hpp +++ b/src/Library/include/BootLoader/boot_loader.hpp @@ -3,6 +3,12 @@ #include namespace JabyEngine { + //boot namespace? + + namespace CD { + void setup(); + } + namespace GPU { void display_logo(); void setup(); diff --git a/src/Library/src/BootLoader/cd_boot.cpp b/src/Library/src/BootLoader/cd_boot.cpp new file mode 100644 index 00000000..4c2df577 --- /dev/null +++ b/src/Library/src/BootLoader/cd_boot.cpp @@ -0,0 +1,10 @@ +#include "../../include/BootLoader/boot_loader.hpp" +#include + +namespace JabyEngine { + namespace CD { + void setup() { + CD_IO::change_to_index0(); + } + } +} \ No newline at end of file