2018-01-13 19:04:19 +01:00
|
|
|
/* This file is part of the dynarmic project.
|
|
|
|
* Copyright (c) 2018 MerryMage
|
2020-04-23 16:25:11 +02:00
|
|
|
* SPDX-License-Identifier: 0BSD
|
2018-01-13 19:04:19 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <vector>
|
|
|
|
|
2019-05-05 19:43:09 +02:00
|
|
|
#ifdef _MSC_VER
|
2021-05-22 15:51:20 +02:00
|
|
|
# pragma warning(push, 0)
|
|
|
|
# include <unicorn/unicorn.h>
|
|
|
|
# pragma warning(pop)
|
2019-05-05 19:43:09 +02:00
|
|
|
#else
|
2021-05-22 15:51:20 +02:00
|
|
|
# include <unicorn/unicorn.h>
|
2019-05-05 19:43:09 +02:00
|
|
|
#endif
|
2018-01-13 19:04:19 +01:00
|
|
|
|
2021-05-19 18:28:35 +02:00
|
|
|
#include "../A64/testenv.h"
|
|
|
|
#include "dynarmic/common/common_types.h"
|
2018-01-13 19:04:19 +01:00
|
|
|
|
2018-08-11 12:39:53 +02:00
|
|
|
class A64Unicorn final {
|
2018-01-13 19:04:19 +01:00
|
|
|
public:
|
2018-07-13 19:41:19 +02:00
|
|
|
static constexpr size_t num_gprs = 31;
|
|
|
|
using RegisterArray = std::array<u64, num_gprs>;
|
|
|
|
using RegisterPtrArray = std::array<RegisterArray::pointer, num_gprs>;
|
|
|
|
using RegisterConstPtrArray = std::array<RegisterArray::const_pointer, num_gprs>;
|
|
|
|
|
|
|
|
static constexpr size_t num_vecs = 32;
|
|
|
|
using VectorArray = std::array<Vector, num_vecs>;
|
|
|
|
using VectorPtrArray = std::array<VectorArray::pointer, num_vecs>;
|
|
|
|
using VectorConstPtrArray = std::array<VectorArray::const_pointer, num_vecs>;
|
|
|
|
|
2018-08-11 12:39:53 +02:00
|
|
|
explicit A64Unicorn(A64TestEnv& testenv);
|
|
|
|
~A64Unicorn();
|
2018-01-13 19:04:19 +01:00
|
|
|
|
|
|
|
void Run();
|
|
|
|
|
|
|
|
u64 GetSP() const;
|
|
|
|
void SetSP(u64 value);
|
|
|
|
|
|
|
|
u64 GetPC() const;
|
|
|
|
void SetPC(u64 value);
|
|
|
|
|
2018-07-13 19:41:19 +02:00
|
|
|
RegisterArray GetRegisters() const;
|
|
|
|
void SetRegisters(const RegisterArray& value);
|
2018-01-13 19:04:19 +01:00
|
|
|
|
2018-07-13 19:41:19 +02:00
|
|
|
VectorArray GetVectors() const;
|
|
|
|
void SetVectors(const VectorArray& value);
|
2018-01-13 19:04:19 +01:00
|
|
|
|
|
|
|
u32 GetFpcr() const;
|
|
|
|
void SetFpcr(u32 value);
|
|
|
|
|
2018-07-24 17:06:55 +02:00
|
|
|
u32 GetFpsr() const;
|
|
|
|
void SetFpsr(u32 value);
|
|
|
|
|
2018-01-13 19:04:19 +01:00
|
|
|
u32 GetPstate() const;
|
|
|
|
void SetPstate(u32 value);
|
|
|
|
|
|
|
|
void ClearPageCache();
|
|
|
|
|
|
|
|
void DumpMemoryInformation();
|
|
|
|
|
|
|
|
private:
|
|
|
|
static void InterruptHook(uc_engine* uc, u32 interrupt, void* user_data);
|
|
|
|
static bool UnmappedMemoryHook(uc_engine* uc, uc_mem_type type, u64 addr, int size, u64 value, void* user_data);
|
2018-01-26 00:56:57 +01:00
|
|
|
static bool MemoryWriteHook(uc_engine* uc, uc_mem_type type, u64 addr, int size, u64 value, void* user_data);
|
2018-01-13 19:04:19 +01:00
|
|
|
|
|
|
|
struct Page {
|
|
|
|
u64 address;
|
|
|
|
std::array<u8, 4096> data;
|
|
|
|
};
|
|
|
|
|
2018-08-11 12:39:53 +02:00
|
|
|
A64TestEnv& testenv;
|
2018-01-13 19:04:19 +01:00
|
|
|
uc_engine* uc{};
|
|
|
|
uc_hook intr_hook{};
|
|
|
|
uc_hook mem_invalid_hook{};
|
2018-01-26 00:56:57 +01:00
|
|
|
uc_hook mem_write_prot_hook{};
|
2018-01-13 19:04:19 +01:00
|
|
|
|
2018-01-13 19:30:02 +01:00
|
|
|
std::vector<std::unique_ptr<Page>> pages;
|
2018-01-13 19:04:19 +01:00
|
|
|
};
|