From 46316dbae339b6a602a08f316b8b798fd6532ef0 Mon Sep 17 00:00:00 2001 From: Jaby Date: Sun, 15 Jan 2023 20:16:20 +0100 Subject: [PATCH] Improved names again --- include/PSX/System/IOPorts/cd_io.hpp | 22 ++++---- include/PSX/System/IOPorts/dma_io.hpp | 6 +-- include/PSX/System/IOPorts/ioport.hpp | 70 ++++++++++++++----------- include/PSX/System/IOPorts/spu_io.hpp | 16 +++--- include/PSX/System/IOPorts/timer_io.hpp | 6 +-- 5 files changed, 63 insertions(+), 57 deletions(-) diff --git a/include/PSX/System/IOPorts/cd_io.hpp b/include/PSX/System/IOPorts/cd_io.hpp index 4c219766..1f3d48b9 100644 --- a/include/PSX/System/IOPorts/cd_io.hpp +++ b/include/PSX/System/IOPorts/cd_io.hpp @@ -34,15 +34,15 @@ namespace JabyEngine { }; struct Interrupt { - static void enable_all(IOPortEx& port) { + static void enable_all(VolatileBitMapPOD& port) { port.write({InterruptEnable::with(InterruptEnable::InterruptTypValue.max(), InterruptEnable::UnknownIRQ, InterruptEnable::CommandStartIRQ)}); } - static uint8_t get_type(const IOPortEx& port) { + static uint8_t get_type(const VolatileBitMapPOD& port) { return port.read().get_value(InterruptFlag::InterruptTypValue); } - static void ack(IOPortEx& port) { + static void ack(VolatileBitMapPOD& port) { port.write_range_value(InterruptFlag::InterruptTypValue.max()); } }; @@ -57,22 +57,22 @@ namespace JabyEngine { struct __no_align IndexTriplet { // Replace with proper types later union __no_align { - const IOPort response_fifo; - IOPort command; + const VolatilePOD response_fifo; + VolatilePOD command; }; union __no_align { - const IOPort data_fifo; - IOPort parameter_fifo; + const VolatilePOD data_fifo; + VolatilePOD parameter_fifo; }; union __no_align { - const IOPort irq_enable; - IOPort request; + const VolatileBitMapPOD irq_enable; + VolatileBitMapPOD request; }; - const IOPort& get_data_fifo_16() const { - return *reinterpret_cast*>(&this->data_fifo); + const VolatilePOD& get_data_fifo_16() const { + return *reinterpret_cast*>(&this->data_fifo); } }; diff --git a/include/PSX/System/IOPorts/dma_io.hpp b/include/PSX/System/IOPorts/dma_io.hpp index ea5f6468..7a48a58f 100644 --- a/include/PSX/System/IOPorts/dma_io.hpp +++ b/include/PSX/System/IOPorts/dma_io.hpp @@ -77,9 +77,9 @@ namespace JabyEngine { }; struct __no_align Registers { - IOPortEx adr; - IOPortEx block_ctrl; - IOPortEx channel_ctrl; + VolatileBitMapPOD adr; + VolatileBitMapPOD block_ctrl; + VolatileBitMapPOD channel_ctrl; }; //0: Highest, 7: Lowest diff --git a/include/PSX/System/IOPorts/ioport.hpp b/include/PSX/System/IOPorts/ioport.hpp index c9fb78d5..e89d6e30 100644 --- a/include/PSX/System/IOPorts/ioport.hpp +++ b/include/PSX/System/IOPorts/ioport.hpp @@ -3,50 +3,56 @@ #include "../../Auxiliary/complex_bitmap.hpp" namespace JabyEngine { - template - class __no_align IOPort { - private: - volatile T value; + template + struct VolatilePOD { + volatile T raw; - public: - constexpr T read_raw() const { - return this->value; + constexpr T read() const { + return this->raw; } - constexpr S read() const { - return S{this->value}; - } - - constexpr void write_raw(T value) { - this->value = value; - } - - constexpr void write(const S& value) { - this->value = static_cast(value); + constexpr void write(T value) { + this->raw = value; } }; // For use with ComplexBitMaps or what else satisfies this API template - class __no_align IOPortEx : public IOPort { - private: + struct VolatileBitMapPOD { typedef typename T::UnderlyingType Raw; - public: + VolatilePOD pod; + + constexpr Raw read_raw() const { + return this->pod.read(); + } + + constexpr T read() const { + return T{this->pod.read()}; + } + constexpr Raw read_range_value(const BitRange& range) const { - return IOPort::read().get_value(range); + return VolatileBitMapPOD::read().get_value(range); + } + + constexpr void write_raw(Raw value) { + this->pod.write(value); + } + + constexpr void write(const T& value) { + this->pod.write(static_cast(value)); } constexpr void write_range_value(const BitRangeValue& value) { - IOPort::write(T{T::with(value)}); + VolatileBitMapPOD::write(T{T::with(value)}); } }; struct __no_align ubus32_t { typedef ComplexBitMap Base16; - IOPort low; - IOPort high; + VolatileBitMapPOD low; + VolatileBitMapPOD high; constexpr ubus32_t(uint32_t value) { *this = value; @@ -74,15 +80,15 @@ namespace JabyEngine { #define __cast_io_adr_with_type(cv, type, name, adr) static __always_inline cv auto& name = *reinterpret_cast(__io_port_adr(adr)) - #define __declare_io_port_global(type, name, adr) __cast_io_adr_with_type(, IOPortEx, name, adr) - #define __declare_io_port_global_const(type, name, adr) __cast_io_adr_with_type(const, IOPortEx, name, adr) - #define __declare_io_port_global_simple(type, name, adr) __cast_io_adr_with_type(, IOPort, name, adr) - #define __declare_io_port_global_const_simple(type, name, adr) __cast_io_adr_with_type(const, IOPort, name, adr) + #define __declare_io_port_global(type, name, adr) __cast_io_adr_with_type(, VolatileBitMapPOD, name, adr) + #define __declare_io_port_global_const(type, name, adr) __cast_io_adr_with_type(const, VolatileBitMapPOD, name, adr) + #define __declare_io_port_global_simple(type, name, adr) __cast_io_adr_with_type(, VolatilePOD, name, adr) + #define __declare_io_port_global_const_simple(type, name, adr) __cast_io_adr_with_type(const, VolatilePOD, name, adr) - #define __declare_io_port_member(type, name, adr) __cast_io_adr_with_type(inline, IOPortEx, name, adr) - #define __declare_io_port_member_const(type, name, adr) __cast_io_adr_with_type(const inline, IOPortEx, name, adr) - #define __declare_io_port_member_simple(type, name, adr) __cast_io_adr_with_type(inline, IOPort, name, adr) - #define __declare_io_port_member_const_simple(type, name, adr) __cast_io_adr_with_type(const inline, IOPort, name, adr) + #define __declare_io_port_member(type, name, adr) __cast_io_adr_with_type(inline, VolatileBitMapPOD, name, adr) + #define __declare_io_port_member_const(type, name, adr) __cast_io_adr_with_type(const inline, VolatileBitMapPOD, name, adr) + #define __declare_io_port_member_simple(type, name, adr) __cast_io_adr_with_type(inline, VolatilePOD, name, adr) + #define __declare_io_port_member_const_simple(type, name, adr) __cast_io_adr_with_type(const inline, VolatilePOD, name, adr) #define __declare_io_port_global_array(type, name, adr, size) static __always_inline auto& name = reinterpret_cast(*reinterpret_cast(__io_port_adr(adr))) #define __declare_io_port_global_struct(type, name, adr) static __always_inline auto& name = *reinterpret_cast(__io_port_adr(adr)) diff --git a/include/PSX/System/IOPorts/spu_io.hpp b/include/PSX/System/IOPorts/spu_io.hpp index 5b542909..0e582749 100644 --- a/include/PSX/System/IOPorts/spu_io.hpp +++ b/include/PSX/System/IOPorts/spu_io.hpp @@ -68,14 +68,14 @@ namespace JabyEngine { }; struct __no_align Voice { - IOPort volumeLeft; //Offset: 0x0 - IOPort volumeRight; //Offset: 0x2 - IOPort sampleRate; //Offset: 0x4; - IOPort adr; //Offset: 0x6 - IOPort ad; //Offset: 0x8 - IOPort sr; //Offset: 0xA - IOPort currentVolume; //Offset: 0xC - IOPort repeatAdr; //Offset: 0xE + VolatileBitMapPOD volumeLeft; //Offset: 0x0 + VolatileBitMapPOD volumeRight; //Offset: 0x2 + VolatileBitMapPOD sampleRate; //Offset: 0x4; + VolatilePOD adr; //Offset: 0x6 + VolatileBitMapPOD ad; //Offset: 0x8 + VolatileBitMapPOD sr; //Offset: 0xA + VolatilePOD currentVolume; //Offset: 0xC + VolatilePOD repeatAdr; //Offset: 0xE }; struct ControlRegister : public ComplexBitMap { diff --git a/include/PSX/System/IOPorts/timer_io.hpp b/include/PSX/System/IOPorts/timer_io.hpp index 48521ceb..c8ff6e96 100644 --- a/include/PSX/System/IOPorts/timer_io.hpp +++ b/include/PSX/System/IOPorts/timer_io.hpp @@ -30,9 +30,9 @@ namespace JabyEngine { }; struct __no_align Counter { - IOPortEx value; - IOPortEx mode; - IOPortEx target; + VolatileBitMapPOD value; + VolatileBitMapPOD mode; + VolatileBitMapPOD target; private: uint32_t _unused; };