From 77f65e8826f98b13a7a0e3f5a44fa57396ae5545 Mon Sep 17 00:00:00 2001 From: "Zone.N" Date: Tue, 18 Jun 2024 17:58:32 +0800 Subject: [PATCH] feat(cpu): update cpu template Signed-off-by: Zone.N --- src/kernel/arch/aarch64/include/cpu.hpp | 24 ++++++++++++------------ src/kernel/arch/riscv64/include/cpu.hpp | 24 ++++++++++++------------ src/kernel/arch/x86_64/include/cpu.hpp | 24 ++++++++++++------------ 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/kernel/arch/aarch64/include/cpu.hpp b/src/kernel/arch/aarch64/include/cpu.hpp index 33c944c9..1983913a 100644 --- a/src/kernel/arch/aarch64/include/cpu.hpp +++ b/src/kernel/arch/aarch64/include/cpu.hpp @@ -61,7 +61,7 @@ namespace { * 只读接口 * @tparam 寄存器类型 */ -template +template class ReadOnlyRegBase { public: /// @name 构造/析构函数 @@ -76,11 +76,11 @@ class ReadOnlyRegBase { /** * 读寄存器 - * @return Reg::DataType 寄存器的值 + * @return RegInfo::DataType 寄存器的值 */ - static __always_inline Reg::DataType Read() { - typename Reg::DataType value{}; - if constexpr (std::is_same::value) { + static __always_inline RegInfo::DataType Read() { + typename RegInfo::DataType value{}; + if constexpr (std::is_same::value) { __asm__ volatile("mov %0, x29" : "=r"(value) : :); } else { Err("No Type\n"); @@ -92,14 +92,14 @@ class ReadOnlyRegBase { /** * () 重载 */ - static __always_inline Reg::DataType operator()() { return Read(); } + static __always_inline RegInfo::DataType operator()() { return Read(); } }; /** * 只写接口 * @tparam 寄存器类型 */ -template +template class WriteOnlyRegBase { public: /// @name 构造/析构函数 @@ -116,8 +116,8 @@ class WriteOnlyRegBase { * 写寄存器 * @param value 要写的值 */ - static __always_inline void Write(Reg::DataType value) { - if constexpr (std::is_same::value) { + static __always_inline void Write(RegInfo::DataType value) { + if constexpr (std::is_same::value) { __asm__ volatile("mv fp, %0" : : "r"(value) :); } else { Err("No Type\n"); @@ -130,9 +130,9 @@ class WriteOnlyRegBase { * 读写接口 * @tparam 寄存器类型 */ -template -class ReadWriteRegBase : public ReadOnlyRegBase, - public WriteOnlyRegBase { +template +class ReadWriteRegBase : public ReadOnlyRegBase, + public WriteOnlyRegBase { public: /// @name 构造/析构函数 /// @{ diff --git a/src/kernel/arch/riscv64/include/cpu.hpp b/src/kernel/arch/riscv64/include/cpu.hpp index 67534066..0dec77fb 100644 --- a/src/kernel/arch/riscv64/include/cpu.hpp +++ b/src/kernel/arch/riscv64/include/cpu.hpp @@ -61,7 +61,7 @@ namespace { * 只读接口 * @tparam 寄存器类型 */ -template +template class ReadOnlyRegBase { public: /// @name 构造/析构函数 @@ -76,11 +76,11 @@ class ReadOnlyRegBase { /** * 读寄存器 - * @return Reg::DataType 寄存器的值 + * @return RegInfo::DataType 寄存器的值 */ - static __always_inline Reg::DataType Read() { - typename Reg::DataType value{}; - if constexpr (std::is_same::value) { + static __always_inline RegInfo::DataType Read() { + typename RegInfo::DataType value{}; + if constexpr (std::is_same::value) { __asm__ volatile("mv %0, fp" : "=r"(value) : :); } else { Err("No Type\n"); @@ -92,14 +92,14 @@ class ReadOnlyRegBase { /** * () 重载 */ - static __always_inline Reg::DataType operator()() { return Read(); } + static __always_inline RegInfo::DataType operator()() { return Read(); } }; /** * 只写接口 * @tparam 寄存器类型 */ -template +template class WriteOnlyRegBase { public: /// @name 构造/析构函数 @@ -116,8 +116,8 @@ class WriteOnlyRegBase { * 写寄存器 * @param value 要写的值 */ - static __always_inline void Write(Reg::DataType value) { - if constexpr (std::is_same::value) { + static __always_inline void Write(RegInfo::DataType value) { + if constexpr (std::is_same::value) { __asm__ volatile("mv fp, %0" : : "r"(value) :); } else { Err("No Type\n"); @@ -130,9 +130,9 @@ class WriteOnlyRegBase { * 读写接口 * @tparam 寄存器类型 */ -template -class ReadWriteRegBase : public ReadOnlyRegBase, - public WriteOnlyRegBase { +template +class ReadWriteRegBase : public ReadOnlyRegBase, + public WriteOnlyRegBase { public: /// @name 构造/析构函数 /// @{ diff --git a/src/kernel/arch/x86_64/include/cpu.hpp b/src/kernel/arch/x86_64/include/cpu.hpp index 09e00725..a5b1f293 100644 --- a/src/kernel/arch/x86_64/include/cpu.hpp +++ b/src/kernel/arch/x86_64/include/cpu.hpp @@ -211,7 +211,7 @@ namespace { * 只读接口 * @tparam 寄存器类型 */ -template +template class ReadOnlyRegBase { public: /// @name 构造/析构函数 @@ -226,11 +226,11 @@ class ReadOnlyRegBase { /** * 读寄存器 - * @return Reg::DataType 寄存器的值 + * @return RegInfo::DataType 寄存器的值 */ - static __always_inline Reg::DataType Read() { - typename Reg::DataType value{}; - if constexpr (std::is_same::value) { + static __always_inline RegInfo::DataType Read() { + typename RegInfo::DataType value{}; + if constexpr (std::is_same::value) { __asm__ volatile("mov %%rbp, %0" : "=r"(value) : :); } else { Err("No Type\n"); @@ -242,14 +242,14 @@ class ReadOnlyRegBase { /** * () 重载 */ - static __always_inline Reg::DataType operator()() { return Read(); } + static __always_inline RegInfo::DataType operator()() { return Read(); } }; /** * 只写接口 * @tparam 寄存器类型 */ -template +template class WriteOnlyRegBase { public: /// @name 构造/析构函数 @@ -266,8 +266,8 @@ class WriteOnlyRegBase { * 写寄存器 * @param value 要写的值 */ - static __always_inline void Write(Reg::DataType value) { - if constexpr (std::is_same::value) { + static __always_inline void Write(RegInfo::DataType value) { + if constexpr (std::is_same::value) { __asm__ volatile("mv fp, %0" : : "r"(value) :); } else { Err("No Type\n"); @@ -280,9 +280,9 @@ class WriteOnlyRegBase { * 读写接口 * @tparam 寄存器类型 */ -template -class ReadWriteRegBase : public ReadOnlyRegBase, - public WriteOnlyRegBase { +template +class ReadWriteRegBase : public ReadOnlyRegBase, + public WriteOnlyRegBase { public: /// @name 构造/析构函数 /// @{