From a2b8b35b4a118b27eb8da145612d0b249f81085e Mon Sep 17 00:00:00 2001 From: Jaby Date: Sun, 17 Sep 2023 08:50:06 +0200 Subject: [PATCH] Integrate new IO Code into memory_io --- include/PSX/System/IOPorts/ioport.hpp | 22 +++++++++++----------- include/PSX/System/IOPorts/memory_io.hpp | 24 ++++++++++++------------ src/Library/src/BootLoader/cd_boot.cpp | 4 ++-- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/PSX/System/IOPorts/ioport.hpp b/include/PSX/System/IOPorts/ioport.hpp index f74dd8ea..f013cebe 100644 --- a/include/PSX/System/IOPorts/ioport.hpp +++ b/include/PSX/System/IOPorts/ioport.hpp @@ -17,47 +17,47 @@ namespace JabyEngine { return T{0}.set_va(args...); } - constexpr T& set(Bit bit) { + constexpr T& set2(Bit bit) { this->raw = bit::set(this->raw, bit); return static_cast(*this); } - constexpr T& set(ClearBit bit) { + constexpr T& set2(ClearBit bit) { this->raw = bit::set(this->raw, bit); return *this; } - constexpr T& set(BitRange bits, T value) { + constexpr T& set2(BitRange bits, T value) { this->raw = bit::value::set_normalized(this->raw, bits, value); return *this; } template - constexpr T& set(const BitRange::RangeValuePair& value) { + constexpr T& set2(const BitRange::RangeValuePair& value) { this->raw = bit::value::set_normalized(this->raw, value); return *this; } template constexpr T& set_va(const U& head) { - return this->set(head); + return this->set2(head); } template constexpr T& set_va(const U& head, const ARGS&...tail) { - return this->set(head).set_va(tail...); + return this->set2(head).set_va(tail...); } - constexpr IOValue::UnderlyingType get(BitRange bits) const { + constexpr IOValue::UnderlyingType get2(BitRange bits) const { return bit::value::get_normalized(this->raw, bits.pos, bits.length); } - constexpr T& clear(Bit bit) { + constexpr T& clear2(Bit bit) { this->raw = bit::clear(this->raw, bit); return *this; } - constexpr bool is_set(Bit bit) const { + constexpr bool is_set2(Bit bit) const { return bit::is_set(this->raw, bit); } }; @@ -107,8 +107,8 @@ namespace JabyEngine { } }; - #define __new_declare_io_value(name, type) struct name : public New::internal::IOValue - #define __new_declare_io_port_w_type(type, name, adr) static auto& name = *reinterpret_cast*>(IOAdress::patch_adr(adr)) + #define __new_declare_io_value(name, type) struct name : public ::JabyEngine::New::internal::IOValue + #define __new_declare_io_port_w_type(type, name, adr) static auto& name = *reinterpret_cast<::JabyEngine::New::IOPort*>(IOAdress::patch_adr(adr)) #define __new_declare_io_port(name, adr) __new_declare_io_port_w_type(name, name, adr) } diff --git a/include/PSX/System/IOPorts/memory_io.hpp b/include/PSX/System/IOPorts/memory_io.hpp index dd884d23..36140196 100644 --- a/include/PSX/System/IOPorts/memory_io.hpp +++ b/include/PSX/System/IOPorts/memory_io.hpp @@ -4,20 +4,20 @@ namespace JabyEngine { namespace Memory_IO { - __declare_io_type(COM_DELAY, uint32_t, - void setup() { - this->raw_value = 0x1325; - } - ); + __new_declare_io_value(COM_DELAY, uint32_t) { + static constexpr COM_DELAY create() { + return COM_DELAY{0x1325}; + } + }; - __declare_io_type(CD_DELAY, uint32_t, - void setup() { - this->raw_value = 0x20943; - } - ); + __new_declare_io_value(CD_DELAY, uint32_t) { + static constexpr CD_DELAY create() { + return CD_DELAY{0x20943}; + } + }; - __declare_new_io_port(COM_DELAY, 0x1F801020); - __declare_new_io_port(CD_DELAY, 0x1F801018); + __new_declare_io_port(COM_DELAY, 0x1F801020); + __new_declare_io_port(CD_DELAY, 0x1F801018); } } diff --git a/src/Library/src/BootLoader/cd_boot.cpp b/src/Library/src/BootLoader/cd_boot.cpp index b10ae087..00168569 100644 --- a/src/Library/src/BootLoader/cd_boot.cpp +++ b/src/Library/src/BootLoader/cd_boot.cpp @@ -17,8 +17,8 @@ namespace JabyEngine { void setup() { __syscall_EnterCriticalSection(); - Memory_IO::COM_DELAY.setup(); - Memory_IO::CD_DELAY.setup(); + Memory_IO::COM_DELAY.write(Memory_IO::COM_DELAY::create()); + Memory_IO::CD_DELAY.write(Memory_IO::CD_DELAY::create()); __syscall_SysEnqIntRP(CdromIoIrq, &::JabyEngine::CD::internal::callback);