From 37192b537b9a87c6bdafe5d7cd3f9dd4ccd07723 Mon Sep 17 00:00:00 2001 From: Jaby Date: Tue, 14 Mar 2023 22:33:49 +0100 Subject: [PATCH] New concept for IOPorts --- include/PSX/System/IOPorts/ioport.hpp | 12 ++++++++++++ include/PSX/System/IOPorts/memory_io.hpp | 15 +++++++++++---- src/Library/src/BootLoader/cd_boot.cpp | 12 +++++++++++- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/include/PSX/System/IOPorts/ioport.hpp b/include/PSX/System/IOPorts/ioport.hpp index bec6bf78..f877828b 100644 --- a/include/PSX/System/IOPorts/ioport.hpp +++ b/include/PSX/System/IOPorts/ioport.hpp @@ -3,6 +3,18 @@ #include "../../Auxiliary/complex_bitmap.hpp" namespace JabyEngine { + template + struct NormalValue { + typedef T Value; + typedef T NakedValue; + }; + + template + struct VolatileValue { + typedef volatile T Value; + typedef T NakedValue; + }; + template struct VolatilePOD { volatile T raw; diff --git a/include/PSX/System/IOPorts/memory_io.hpp b/include/PSX/System/IOPorts/memory_io.hpp index 104b8d5f..1a701858 100644 --- a/include/PSX/System/IOPorts/memory_io.hpp +++ b/include/PSX/System/IOPorts/memory_io.hpp @@ -4,11 +4,16 @@ namespace JabyEngine { namespace Memory_IO { - struct COM_DELAY { - typedef uint32_t Type; + template typename T> + struct COM_DELAY_base { + T::Value value; - static constexpr uint32_t SetupValue = 0x1325; + void setup() { + this->value = 0x1325; + } }; + typedef COM_DELAY_base COM_DELAY_v; + typedef COM_DELAY_base COM_DELAY_t; struct CD_DELAY { typedef uint32_t Type; @@ -16,7 +21,9 @@ namespace JabyEngine { static constexpr uint32_t SetupValue = 0x20943; }; - __declare_io_port_global_simple(COM_DELAY::Type, COM_DELAY, 0x1F801020); + static auto& COM_DELAY = *reinterpret_cast(0x1F801020); + + //__declare_io_port_global_simple(COM_DELAY::Type, COM_DELAY, 0x1F801020); __declare_io_port_global_simple(CD_DELAY::Type, CD_DELAY, 0x1F801018); } } diff --git a/src/Library/src/BootLoader/cd_boot.cpp b/src/Library/src/BootLoader/cd_boot.cpp index 66a79fe2..9f6e7aa6 100644 --- a/src/Library/src/BootLoader/cd_boot.cpp +++ b/src/Library/src/BootLoader/cd_boot.cpp @@ -16,7 +16,17 @@ namespace JabyEngine { void setup() { __syscall_EnterCriticalSection(); - Memory_IO::COM_DELAY.write(Memory_IO::COM_DELAY::SetupValue); + Memory_IO::COM_DELAY.setup(); + Memory_IO::COM_DELAY.setup(); + Memory_IO::COM_DELAY.setup(); + + Memory_IO::COM_DELAY_t b{Memory_IO::COM_DELAY.value}; + + b.setup(); + b.setup(); + b.setup(); + + //Memory_IO::COM_DELAY.write(Memory_IO::COM_DELAY::SetupValue); Memory_IO::CD_DELAY.write(Memory_IO::CD_DELAY::SetupValue); __syscall_SysEnqIntRP(CdromIoIrq, &::JabyEngine::CD::internal::callback);