libmicroemu 0.2.0
ARM Microcontroller Emulator Library
Loading...
Searching...
No Matches
cpu_accessor.h
1#pragma once
2
5#include "libmicroemu/logger.h"
6#include "libmicroemu/register_id.h"
8#include <array>
9#include <cstddef>
10#include <cstdint>
11#include <string_view>
12#include <type_traits>
13
14namespace libmicroemu::internal {
15
16template <typename TCpuStates, typename RegOps, typename TSpecRegOps, typename TLogger = NullLogger>
17class CpuAccessor : public TCpuStates {
18public:
19 using Reg = RegOps;
20 using SReg = TSpecRegOps;
21
22 // ---- General registers ----
23
24 template <RegisterId Id> inline u32 ReadRegister() const {
25 return RegOps::ReadRegister(*this, Id);
26 }
27
28 inline u32 ReadRegister(const RegisterId id) const { return RegOps::ReadRegister(*this, id); }
29
30 template <RegisterId Id> inline void WriteRegister(const u32 &value) {
31 RegOps::WriteRegister(*this, Id, value);
32 }
33
34 inline void WriteRegister(RegisterId id, u32 value) { RegOps::WriteRegister(*this, id, value); }
35
36 // ---- Special registers ----
37 template <SpecialRegisterId SId> inline u32 ReadSpecialRegister() const {
38 return SReg::template ReadRegister<SId>(*this);
39 }
40
41 inline u32 ReadSpecialRegister(const SpecialRegisterId &reg_id) const {
42 return SReg::ReadRegister(*this, reg_id);
43 }
44
45 template <SpecialRegisterId SId> inline void WriteSpecialRegister(u32 value) {
46 SReg::template WriteRegister<SId>(*this, value);
47 }
48
49 inline void WriteSpecialRegister(const SpecialRegisterId &reg_id, u32 value) {
50 SReg::WriteRegister(*this, reg_id, value);
51 }
52};
53
54} // namespace libmicroemu::internal
Definition cpu_accessor.h:17
Definition reg_ops.h:15
The libmicroemu::internal namespace contains all classes and functions of libmicroemu which are priva...
Definition bkpt_flags.h:6
SpecialRegisterId
Enumeration of special register IDs.
Definition special_register_id.h:18
RegisterId
Enumeration of register IDs.
Definition register_id.h:13
This file contains the declaration of the Predicates class.
Contains the Result class which is used to return the result of a function.
This file contains the declaration of the SpecialRegisterId enumeration and related functions.