Skip to content

Commit f946ae9

Browse files
committed
add cpu_io
Signed-off-by: Zone.NiuZH <[email protected]>
1 parent 3e98d05 commit f946ae9

File tree

4 files changed

+20
-29
lines changed

4 files changed

+20
-29
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ repos:
2222
- id: clang-format
2323
args:
2424
- --style=file
25-
- id: clang-tidy
26-
args:
27-
- --checks=.clang-tidy
28-
- -p=/home/ubuntu/github/MRNIU/cpu_io/build_x86_64/compiler_commands.json
29-
- -extra-arg=--std=c++2b
30-
- --fix
31-
- --header-filter=.*
25+
# - id: clang-tidy
26+
# args:
27+
# - --checks=.clang-tidy
28+
# - -p=/home/ubuntu/github/MRNIU/cpu_io/build_aarch64/compiler_commands.json
29+
# - -extra-arg=--std=c++2b
30+
# - --fix
31+
# - --header-filter=.*
3232

3333
- repo: https://github.com/koalaman/shellcheck-precommit
3434
rev: v0.10.0

include/aarch64/cpu.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,15 @@
1414
* </table>
1515
*/
1616

17-
#ifndef SIMPLEKERNEL_SRC_KERNEL_ARCH_AARCH64_INCLUDE_CPU_CPU_HPP_
18-
#define SIMPLEKERNEL_SRC_KERNEL_ARCH_AARCH64_INCLUDE_CPU_CPU_HPP_
17+
#ifndef CPU_IO_INCLUDE_AARCH64_CPU_HPP_
18+
#define CPU_IO_INCLUDE_AARCH64_CPU_HPP_
1919

2020
#include <cstdint>
2121
#include <cstdlib>
2222
#include <type_traits>
2323
#include <typeinfo>
2424

25-
#include "kernel_log.hpp"
2625
#include "regs.hpp"
27-
#include "sk_cstdio"
28-
#include "sk_iostream"
2926

3027
/**
3128
* aarch64 cpu 相关定义
@@ -45,4 +42,4 @@ static __always_inline void SetupFpu() {
4542

4643
} // namespace cpu
4744

48-
#endif // SIMPLEKERNEL_SRC_KERNEL_ARCH_AARCH64_INCLUDE_CPU_CPU_HPP_
45+
#endif // CPU_IO_INCLUDE_AARCH64_CPU_HPP_

include/aarch64/regs.hpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@
1414
* </table>
1515
*/
1616

17-
#ifndef SIMPLEKERNEL_SRC_KERNEL_ARCH_AARCH64_INCLUDE_CPU_REGS_HPP_
18-
#define SIMPLEKERNEL_SRC_KERNEL_ARCH_AARCH64_INCLUDE_CPU_REGS_HPP_
17+
#ifndef CPU_IO_INCLUDE_AARCH64_REGS_HPP_
18+
#define CPU_IO_INCLUDE_AARCH64_REGS_HPP_
1919

2020
#include <cstdint>
2121
#include <cstdlib>
2222
#include <type_traits>
2323
#include <typeinfo>
2424

25-
#include "kernel_log.hpp"
26-
#include "sk_cstdio"
27-
#include "sk_iostream"
28-
2925
/**
3026
* aarch64 cpu Control and Status Registers 相关定义
3127
* @note 寄存器读写设计见 arch/README.md
@@ -83,8 +79,7 @@ class ReadOnlyRegBase {
8379
if constexpr (std::is_same_v<RegInfo, register_info::X29Info>) {
8480
__asm__ volatile("mov %0, x29" : "=r"(value) : :);
8581
} else {
86-
CPU_IO_ERROR("No Type\n");
87-
throw;
82+
static_assert(sizeof(RegInfo) == 0);
8883
}
8984
return value;
9085
}
@@ -122,8 +117,7 @@ class WriteOnlyRegBase {
122117
if constexpr (std::is_same_v<RegInfo, register_info::X29Info>) {
123118
__asm__ volatile("mov x29, %0" : : "r"(value) :);
124119
} else {
125-
CPU_IO_ERROR("No Type\n");
126-
throw;
120+
static_assert(sizeof(RegInfo) == 0);
127121
}
128122
}
129123
};
@@ -153,11 +147,6 @@ class ReadWriteRegBase : public ReadOnlyRegBase<RegInfo>,
153147
namespace regs {
154148
class X29 : public read_write::ReadWriteRegBase<register_info::X29Info> {
155149
public:
156-
friend auto operator<<(sk_std::ostream &os, [[maybe_unused]] const X29 &x29)
157-
-> sk_std::ostream & {
158-
CPU_IO_PRINTF("val: 0x%p", regs::X29::Read());
159-
return os;
160-
}
161150
};
162151

163152
/// 通用寄存器
@@ -172,4 +161,4 @@ struct AllXreg {
172161

173162
}; // namespace cpu
174163

175-
#endif // SIMPLEKERNEL_SRC_KERNEL_ARCH_AARCH64_INCLUDE_CPU_REGS_HPP_
164+
#endif // CPU_IO_INCLUDE_AARCH64_REGS_HPP_

operator.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,4 +434,9 @@ auto operator<<(std::ostream &ostream, const Stimecmp &) -> std::ostream & {
434434
return ostream;
435435
}
436436
#elif __aarch64__
437+
friend auto operator<<(sk_std::ostream &os, [[maybe_unused]] const X29 &x29)
438+
-> sk_std::ostream & {
439+
CPU_IO_PRINTF("val: 0x%p", regs::X29::Read());
440+
return os;
441+
}
437442
#endif

0 commit comments

Comments
 (0)