Debian Codegraph @

tests/unicorn_emu/a32_unicorn.h

raw symbols SCIP
1 /* This file is part of the dynarmic project.
2 * Copyright (c) 2018 MerryMage
3 * SPDX-License-Identifier: 0BSD
4 */
5
6 #pragma once
7
8 #include <array>
9 #include <vector>
10
11 #ifdef _MSC_VER
12 # pragma warning(push, 0)
13 # include <unicorn/unicorn.h>
14 # pragma warning(pop)
15 #else
16 # include <unicorn/unicorn.h>
17 #endif
18
19 #include <mcl/stdint.hpp>
20
21 #include "../A32/testenv.h"
22
23 namespace Unicorn::A32 {
24 static constexpr size_t num_gprs = 16;
25 static constexpr size_t num_ext_regs = 64;
26
27 using ExtRegArray = std::array<u32, num_ext_regs>;
28 using RegisterArray = std::array<u32, num_gprs>;
29 using RegisterPtrArray = std::array<RegisterArray::pointer, num_gprs>;
30 using RegisterConstPtrArray = std::array<RegisterArray::const_pointer, num_gprs>;
31 } // namespace Unicorn::A32
32
33 template<class TestEnvironment>
34 class A32Unicorn final {
35 public:
36 using ExtRegArray = Unicorn::A32::ExtRegArray;
37 using RegisterArray = Unicorn::A32::RegisterArray;
38
39 explicit A32Unicorn(TestEnvironment& testenv);
40 ~A32Unicorn();
41
42 void Run();
43
44 u32 GetSP() const;
45 void SetSP(u32 value);
46
47 u32 GetPC() const;
48 void SetPC(u32 value);
49
50 RegisterArray GetRegisters() const;
51 void SetRegisters(const RegisterArray& value);
52
53 ExtRegArray GetExtRegs() const;
54 void SetExtRegs(const ExtRegArray& value);
55
56 u32 GetFpscr() const;
57 void SetFpscr(u32 value);
58
59 u32 GetFpexc() const;
60 void SetFpexc(u32 value);
61
62 u32 GetCpsr() const;
63 void SetCpsr(u32 value);
64
65 void EnableFloatingPointAccess();
66
67 void ClearPageCache();
68
69 void DumpMemoryInformation();
70
71 private:
72 static void InterruptHook(uc_engine* uc, u32 interrupt, void* user_data);
73 static bool UnmappedMemoryHook(uc_engine* uc, uc_mem_type type, u32 addr, int size, u64 value, void* user_data);
74 static bool MemoryWriteHook(uc_engine* uc, uc_mem_type type, u32 addr, int size, u64 value, void* user_data);
75
76 struct Page {
77 u32 address;
78 std::array<u8, 4096> data;
79 };
80
81 TestEnvironment& testenv;
82 uc_engine* uc{};
83 uc_hook intr_hook{};
84 uc_hook mem_invalid_hook{};
85 uc_hook mem_write_prot_hook{};
86
87 std::vector<std::unique_ptr<Page>> pages;
88 };