Converted SPU IO
This commit is contained in:
@@ -52,18 +52,20 @@ namespace JabyEngine {
|
||||
typedef volatile T Value;
|
||||
};
|
||||
|
||||
#define __declare_new_io_port(name, adr) \
|
||||
static auto& name = *reinterpret_cast<name##_v*>(adr)
|
||||
#define __declare_new_named_io_port(type, name, adr) \
|
||||
static inline auto& name = *reinterpret_cast<type##_v*>(adr)
|
||||
|
||||
/*constexpr name##_io_base() = default; \
|
||||
\
|
||||
constexpr name##_io_base(type value) : raw_value(value) {} \
|
||||
\*/
|
||||
#define __declare_new_io_port(name, adr) \
|
||||
__declare_new_named_io_port(name, name, adr)
|
||||
|
||||
#define __declare_new_io_port_array(name, adr, size) \
|
||||
static inline auto& name = reinterpret_cast<name##_v(&)[size]>(*reinterpret_cast<name##_v*>(adr))
|
||||
|
||||
#define __declare_io_type(name, type, ...) \
|
||||
template<template<typename> typename T> \
|
||||
struct name##_io_base { \
|
||||
T<type>::Value raw_value = 0; \
|
||||
typedef name##_io_base Self; \
|
||||
\
|
||||
__VA_ARGS__ \
|
||||
template<typename...ARGS> \
|
||||
@@ -173,12 +175,11 @@ namespace JabyEngine {
|
||||
};
|
||||
|
||||
struct __no_align ubus32_t {
|
||||
typedef ComplexBitMap<uint16_t> Base16;
|
||||
__declare_io_type(uint16_t, uint16_t,);
|
||||
uint16_t_v low;
|
||||
uint16_t_v high;
|
||||
|
||||
VolatileBitMapPOD<Base16> low;
|
||||
VolatileBitMapPOD<Base16> high;
|
||||
|
||||
constexpr ubus32_t(uint32_t value) {
|
||||
constexpr ubus32_t(uint32_t value) : low{0}, high{0} {
|
||||
*this = value;
|
||||
}
|
||||
|
||||
@@ -187,12 +188,15 @@ namespace JabyEngine {
|
||||
}
|
||||
|
||||
constexpr operator uint32_t() const {
|
||||
return ((this->high.read_raw() << 16) | this->low.read_raw());
|
||||
const uint32_t high = *this->high;
|
||||
const uint32_t low = *this->low;
|
||||
|
||||
return ((high << 16) | low);
|
||||
}
|
||||
|
||||
constexpr ubus32_t& operator=(uint32_t value) {
|
||||
this->low.write_raw(value & 0xFFFF);
|
||||
this->high.write_raw(value >> 16);
|
||||
this->low = (value & 0xFFFF);
|
||||
this->high = (value >> 16);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user