More cleanup
This commit is contained in:
parent
28fb4df469
commit
00fc6fcf15
|
@ -26,15 +26,15 @@ namespace JabyEngine {
|
||||||
__declare_new_io_port(Status, 0x1F801070);
|
__declare_new_io_port(Status, 0x1F801070);
|
||||||
__declare_new_io_port(Mask, 0x1F801074);
|
__declare_new_io_port(Mask, 0x1F801074);
|
||||||
|
|
||||||
static constexpr bool is_irq(Bit irq) {
|
static bool is_irq(Bit irq) {
|
||||||
return Status.is_set(irq);
|
return Status.is_set(irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr void ack_irq(Bit irq) {
|
static void ack_irq(Bit irq) {
|
||||||
Status.clear(irq);
|
Status.clear(irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr void disable_irq(Bit irq) {
|
static void disable_irq(Bit irq) {
|
||||||
Mask.clear(irq);
|
Mask.clear(irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,17 @@ namespace JabyEngine {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace IOAdress {
|
||||||
|
constexpr uintptr_t patch_adr(uintptr_t adr) {
|
||||||
|
constexpr uintptr_t Mask = 0xF0000000;
|
||||||
|
constexpr uintptr_t Base = 0x10000000; // We might want to change this later to 0xB0000000 for caching and stuff (More research needed)
|
||||||
|
|
||||||
|
return (Base + (adr & ~Mask));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define __declare_new_named_io_port(type, name, adr) \
|
#define __declare_new_named_io_port(type, name, adr) \
|
||||||
static inline auto& name = *reinterpret_cast<type##_v*>(adr)
|
static inline auto& name = *reinterpret_cast<type##_v*>(IOAdress::patch_adr(adr))
|
||||||
|
|
||||||
#define __declare_new_io_port(name, adr) \
|
#define __declare_new_io_port(name, adr) \
|
||||||
__declare_new_named_io_port(name, name, adr)
|
__declare_new_named_io_port(name, name, adr)
|
||||||
|
@ -32,8 +41,8 @@ namespace JabyEngine {
|
||||||
#define __declare_new_io_port_array(name, adr, size) \
|
#define __declare_new_io_port_array(name, adr, size) \
|
||||||
static inline auto& name = reinterpret_cast<name##_v(&)[size]>(*reinterpret_cast<name##_v*>(adr))
|
static inline auto& name = reinterpret_cast<name##_v(&)[size]>(*reinterpret_cast<name##_v*>(adr))
|
||||||
|
|
||||||
|
// We need this construct to ensure the types end up being a POD - Inheritance doesn't qualify for a POD
|
||||||
#define __declare_io_type(name, type, ...) \
|
#define __declare_io_type(name, type, ...) \
|
||||||
/*We need this type to be a POD sadly*/ \
|
|
||||||
template<template<typename> typename T> \
|
template<template<typename> typename T> \
|
||||||
struct name##_io_base { \
|
struct name##_io_base { \
|
||||||
typedef T<type>::UnderlyingValue UnderlyingValue; \
|
typedef T<type>::UnderlyingValue UnderlyingValue; \
|
||||||
|
@ -104,19 +113,6 @@ namespace JabyEngine {
|
||||||
typedef name##_io_base<IOPort::IOValueType::Volatile> name##_v; \
|
typedef name##_io_base<IOPort::IOValueType::Volatile> name##_v; \
|
||||||
typedef name##_io_base<IOPort::IOValueType::Normal> name##_t
|
typedef name##_io_base<IOPort::IOValueType::Normal> name##_t
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct VolatilePOD {
|
|
||||||
volatile T raw;
|
|
||||||
|
|
||||||
constexpr T read() const {
|
|
||||||
return this->raw;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr void write(T value) {
|
|
||||||
this->raw = value;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct __no_align ubus32_t {
|
struct __no_align ubus32_t {
|
||||||
__declare_io_type(uint16_t, uint16_t,);
|
__declare_io_type(uint16_t, uint16_t,);
|
||||||
uint16_t_v low;
|
uint16_t_v low;
|
||||||
|
@ -144,24 +140,5 @@ namespace JabyEngine {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static constexpr uintptr_t IO_Base_Mask = 0xF0000000;
|
|
||||||
static constexpr uintptr_t IO_Base_Adr = 0x10000000;
|
|
||||||
|
|
||||||
#define __io_port_adr(adr) (IO_Base_Adr + (adr & ~IO_Base_Mask))
|
|
||||||
#define __cast_io_adr_with_type(cv, type, name, adr) static __always_inline cv auto& name = *reinterpret_cast<type*>(__io_port_adr(adr))
|
|
||||||
|
|
||||||
|
|
||||||
#define __declare_io_port_global(type, name, adr) __cast_io_adr_with_type(, VolatileBitMapPOD<type>, name, adr)
|
|
||||||
#define __declare_io_port_global_const(type, name, adr) __cast_io_adr_with_type(const, VolatileBitMapPOD<type>, name, adr)
|
|
||||||
#define __declare_io_port_global_simple(type, name, adr) __cast_io_adr_with_type(, VolatilePOD<type>, name, adr)
|
|
||||||
#define __declare_io_port_global_const_simple(type, name, adr) __cast_io_adr_with_type(const, VolatilePOD<type>, name, adr)
|
|
||||||
|
|
||||||
#define __declare_io_port_member(type, name, adr) __cast_io_adr_with_type(inline, VolatileBitMapPOD<type>, name, adr)
|
|
||||||
#define __declare_io_port_member_const(type, name, adr) __cast_io_adr_with_type(const inline, VolatileBitMapPOD<type>, name, adr)
|
|
||||||
#define __declare_io_port_member_simple(type, name, adr) __cast_io_adr_with_type(inline, VolatilePOD<type>, name, adr)
|
|
||||||
#define __declare_io_port_member_const_simple(type, name, adr) __cast_io_adr_with_type(const inline, VolatilePOD<type>, name, adr)
|
|
||||||
|
|
||||||
#define __declare_io_port_global_array(type, name, adr, size) static __always_inline auto& name = reinterpret_cast<type(&)[size]>(*reinterpret_cast<type*>(__io_port_adr(adr)))
|
|
||||||
#define __declare_io_port_global_struct(type, name, adr) static __always_inline auto& name = *reinterpret_cast<type*>(__io_port_adr(adr))
|
|
||||||
}
|
}
|
||||||
#endif //!__JABYENGINE_IOPORT_HPP__
|
#endif //!__JABYENGINE_IOPORT_HPP__
|
|
@ -118,9 +118,11 @@ namespace JabyEngine {
|
||||||
static constexpr size_t VoiceCount = 24;
|
static constexpr size_t VoiceCount = 24;
|
||||||
|
|
||||||
struct Key {
|
struct Key {
|
||||||
__cast_io_adr_with_type(inline, ubus32_t, On, 0x1F801D88);
|
typedef ubus32_t ubus32_v;
|
||||||
__cast_io_adr_with_type(inline, ubus32_t, Off, 0x1F801D8C);
|
|
||||||
__cast_io_adr_with_type(inline, ubus32_t, Status, 0x1F801D9C);
|
__declare_new_named_io_port(ubus32, On, 0x1F801D88);
|
||||||
|
__declare_new_named_io_port(ubus32, Off, 0x1F801D8C);
|
||||||
|
__declare_new_named_io_port(ubus32, Status, 0x1F801D9C);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MainVolume {
|
struct MainVolume {
|
||||||
|
|
Loading…
Reference in New Issue