Integrate new IO Code into memory_io

This commit is contained in:
Jaby 2023-09-17 08:50:06 +02:00 committed by Jaby
parent 4dcb16ed64
commit a2b8b35b4a
3 changed files with 25 additions and 25 deletions

View File

@ -17,47 +17,47 @@ namespace JabyEngine {
return T{0}.set_va(args...); return T{0}.set_va(args...);
} }
constexpr T& set(Bit bit) { constexpr T& set2(Bit bit) {
this->raw = bit::set(this->raw, bit); this->raw = bit::set(this->raw, bit);
return static_cast<T&>(*this); return static_cast<T&>(*this);
} }
constexpr T& set(ClearBit bit) { constexpr T& set2(ClearBit bit) {
this->raw = bit::set(this->raw, bit); this->raw = bit::set(this->raw, bit);
return *this; 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); this->raw = bit::value::set_normalized(this->raw, bits, value);
return *this; return *this;
} }
template<typename U> template<typename U>
constexpr T& set(const BitRange::RangeValuePair<U>& value) { constexpr T& set2(const BitRange::RangeValuePair<U>& value) {
this->raw = bit::value::set_normalized(this->raw, value); this->raw = bit::value::set_normalized(this->raw, value);
return *this; return *this;
} }
template<typename U> template<typename U>
constexpr T& set_va(const U& head) { constexpr T& set_va(const U& head) {
return this->set(head); return this->set2(head);
} }
template<typename U, typename...ARGS> template<typename U, typename...ARGS>
constexpr T& set_va(const U& head, const ARGS&...tail) { 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<T, S>::UnderlyingType get(BitRange bits) const { constexpr IOValue<T, S>::UnderlyingType get2(BitRange bits) const {
return bit::value::get_normalized(this->raw, bits.pos, bits.length); 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); this->raw = bit::clear(this->raw, bit);
return *this; return *this;
} }
constexpr bool is_set(Bit bit) const { constexpr bool is_set2(Bit bit) const {
return bit::is_set(this->raw, bit); 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<name, type> #define __new_declare_io_value(name, type) struct name : public ::JabyEngine::New::internal::IOValue<struct name, type>
#define __new_declare_io_port_w_type(type, name, adr) static auto& name = *reinterpret_cast<New::IOPort<struct type>*>(IOAdress::patch_adr(adr)) #define __new_declare_io_port_w_type(type, name, adr) static auto& name = *reinterpret_cast<::JabyEngine::New::IOPort<struct type>*>(IOAdress::patch_adr(adr))
#define __new_declare_io_port(name, adr) __new_declare_io_port_w_type(name, name, adr) #define __new_declare_io_port(name, adr) __new_declare_io_port_w_type(name, name, adr)
} }

View File

@ -4,20 +4,20 @@
namespace JabyEngine { namespace JabyEngine {
namespace Memory_IO { namespace Memory_IO {
__declare_io_type(COM_DELAY, uint32_t, __new_declare_io_value(COM_DELAY, uint32_t) {
void setup() { static constexpr COM_DELAY create() {
this->raw_value = 0x1325; return COM_DELAY{0x1325};
} }
); };
__declare_io_type(CD_DELAY, uint32_t, __new_declare_io_value(CD_DELAY, uint32_t) {
void setup() { static constexpr CD_DELAY create() {
this->raw_value = 0x20943; return CD_DELAY{0x20943};
} }
); };
__declare_new_io_port(COM_DELAY, 0x1F801020); __new_declare_io_port(COM_DELAY, 0x1F801020);
__declare_new_io_port(CD_DELAY, 0x1F801018); __new_declare_io_port(CD_DELAY, 0x1F801018);
} }
} }

View File

@ -17,8 +17,8 @@ namespace JabyEngine {
void setup() { void setup() {
__syscall_EnterCriticalSection(); __syscall_EnterCriticalSection();
Memory_IO::COM_DELAY.setup(); Memory_IO::COM_DELAY.write(Memory_IO::COM_DELAY::create());
Memory_IO::CD_DELAY.setup(); Memory_IO::CD_DELAY.write(Memory_IO::CD_DELAY::create());
__syscall_SysEnqIntRP(CdromIoIrq, &::JabyEngine::CD::internal::callback); __syscall_SysEnqIntRP(CdromIoIrq, &::JabyEngine::CD::internal::callback);