summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-06-24 02:42:52 +0200
committerGitHub <noreply@github.com>2021-06-24 02:42:52 +0200
commit0087eed235f92847cbc213869b0cf88c22414d9a (patch)
tree281f20d6d24886b513f73f304aed59ac0984bb16 /Source/Core
parentede9f2a76a1fa730f30e058b5ea4284bedf47fac (diff)
parent1d48a33aed06bd02c5c7796bbec8e1f7b88186ce (diff)
Merge pull request #9793 from sepalani/template-mmio
MMIOHandlers: Move method definitions to MMIO.cpp
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/MMIO.cpp36
-rw-r--r--Source/Core/Core/HW/MMIOHandlers.h26
2 files changed, 40 insertions, 22 deletions
diff --git a/Source/Core/Core/HW/MMIO.cpp b/Source/Core/Core/HW/MMIO.cpp
index 41a378990c..ed6ae9c4b1 100644
--- a/Source/Core/Core/HW/MMIO.cpp
+++ b/Source/Core/Core/HW/MMIO.cpp
@@ -291,6 +291,18 @@ void ReadHandler<T>::Visit(ReadHandlingMethodVisitor<T>& visitor)
}
template <typename T>
+T ReadHandler<T>::Read(u32 addr)
+{
+ // Check if the handler has already been initialized. For real
+ // handlers, this will always be the case, so this branch should be
+ // easily predictable.
+ if (!m_Method)
+ InitializeInvalid();
+
+ return m_ReadFunc(addr);
+}
+
+template <typename T>
void ReadHandler<T>::ResetMethod(ReadHandlingMethod<T>* method)
{
m_Method.reset(method);
@@ -320,6 +332,12 @@ void ReadHandler<T>::ResetMethod(ReadHandlingMethod<T>* method)
}
template <typename T>
+void ReadHandler<T>::InitializeInvalid()
+{
+ ResetMethod(InvalidRead<T>());
+}
+
+template <typename T>
WriteHandler<T>::WriteHandler()
{
}
@@ -345,6 +363,18 @@ void WriteHandler<T>::Visit(WriteHandlingMethodVisitor<T>& visitor)
}
template <typename T>
+void WriteHandler<T>::Write(u32 addr, T val)
+{
+ // Check if the handler has already been initialized. For real
+ // handlers, this will always be the case, so this branch should be
+ // easily predictable.
+ if (!m_Method)
+ InitializeInvalid();
+
+ m_WriteFunc(addr, val);
+}
+
+template <typename T>
void WriteHandler<T>::ResetMethod(WriteHandlingMethod<T>* method)
{
m_Method.reset(method);
@@ -373,6 +403,12 @@ void WriteHandler<T>::ResetMethod(WriteHandlingMethod<T>* method)
m_WriteFunc = v.ret;
}
+template <typename T>
+void WriteHandler<T>::InitializeInvalid()
+{
+ ResetMethod(InvalidWrite<T>());
+}
+
// Define all the public specializations that are exported in MMIOHandlers.h.
#define MaybeExtern
MMIO_PUBLIC_SPECIALIZATIONS()
diff --git a/Source/Core/Core/HW/MMIOHandlers.h b/Source/Core/Core/HW/MMIOHandlers.h
index 300ed2909b..dfe1a3cc0e 100644
--- a/Source/Core/Core/HW/MMIOHandlers.h
+++ b/Source/Core/Core/HW/MMIOHandlers.h
@@ -127,16 +127,7 @@ public:
// Entry point for read handling method visitors.
void Visit(ReadHandlingMethodVisitor<T>& visitor);
- T Read(u32 addr)
- {
- // Check if the handler has already been initialized. For real
- // handlers, this will always be the case, so this branch should be
- // easily predictable.
- if (!m_Method)
- InitializeInvalid();
-
- return m_ReadFunc(addr);
- }
+ T Read(u32 addr);
// Internal method called when changing the internal method object. Its
// main role is to make sure the read function is updated at the same time.
@@ -145,7 +136,7 @@ public:
private:
// Initialize this handler to an invalid handler. Done lazily to avoid
// useless initialization of thousands of unused handler objects.
- void InitializeInvalid() { ResetMethod(InvalidRead<T>()); }
+ void InitializeInvalid();
std::unique_ptr<ReadHandlingMethod<T>> m_Method;
std::function<T(u32)> m_ReadFunc;
};
@@ -163,16 +154,7 @@ public:
// Entry point for write handling method visitors.
void Visit(WriteHandlingMethodVisitor<T>& visitor);
- void Write(u32 addr, T val)
- {
- // Check if the handler has already been initialized. For real
- // handlers, this will always be the case, so this branch should be
- // easily predictable.
- if (!m_Method)
- InitializeInvalid();
-
- m_WriteFunc(addr, val);
- }
+ void Write(u32 addr, T val);
// Internal method called when changing the internal method object. Its
// main role is to make sure the write function is updated at the same
@@ -182,7 +164,7 @@ public:
private:
// Initialize this handler to an invalid handler. Done lazily to avoid
// useless initialization of thousands of unused handler objects.
- void InitializeInvalid() { ResetMethod(InvalidWrite<T>()); }
+ void InitializeInvalid();
std::unique_ptr<WriteHandlingMethod<T>> m_Method;
std::function<void(u32, T)> m_WriteFunc;
};