Update IOPort code and prepare DMA usage - needs all testing

This commit is contained in:
Jaby
2024-09-06 18:58:36 +01:00
committed by Jaby
parent afbefcce45
commit a6a8b6da65
6 changed files with 14 additions and 41 deletions

View File

@@ -74,41 +74,16 @@ namespace JabyEngine {
}
};
template<typename S, typename T = S::UnderlyingType>
struct IOPortX {
using Value = S;
S read() const {
return S{*const_cast<const volatile T*>(reinterpret_cast<const T*>(this))};
}
void write(S value) {
*const_cast<volatile T*>(reinterpret_cast<T*>(this)) = value.raw;
}
};
template<typename T>
struct IOPortX<T, T> {
T read() const {
return *const_cast<const volatile T*>(reinterpret_cast<const T*>(this));
}
void write(T value) {
*const_cast<volatile T*>(reinterpret_cast<T*>(this)) = value;
}
};
template<typename T>
struct IOPort {
using Value = T;
T value;
T read() const {
return {const_cast<const volatile IOPort<T>*>(this)->value.raw};
return {const_cast<const volatile Value*>(reinterpret_cast<const Value*>(this))->raw};
}
void write(T value) {
const_cast<volatile IOPort<T>*>(this)->value.raw = value.raw;
const_cast<volatile Value*>(reinterpret_cast<Value*>(this))->raw = value.raw;
}
};