2016-07-01 21:01:06 +08:00
|
|
|
/* This file is part of the dynarmic project.
|
|
|
|
* Copyright (c) 2016 MerryMage
|
2020-04-23 15:25:11 +01:00
|
|
|
* SPDX-License-Identifier: 0BSD
|
2016-07-01 21:01:06 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2016-08-25 18:22:08 +01:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
2016-07-04 17:22:11 +08:00
|
|
|
#include <memory>
|
2017-02-16 18:18:29 +00:00
|
|
|
#include <string>
|
2016-07-04 17:22:11 +08:00
|
|
|
|
2018-01-27 22:36:55 +00:00
|
|
|
#include <dynarmic/A32/config.h>
|
2016-07-01 21:01:06 +08:00
|
|
|
|
|
|
|
namespace Dynarmic {
|
2016-09-05 06:54:09 -04:00
|
|
|
namespace IR {
|
|
|
|
class LocationDescriptor;
|
2016-08-06 19:59:09 +01:00
|
|
|
}
|
2018-01-04 21:12:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Dynarmic {
|
|
|
|
namespace A32 {
|
|
|
|
|
|
|
|
struct Context;
|
2016-08-06 19:59:09 +01:00
|
|
|
|
2016-07-04 17:22:11 +08:00
|
|
|
class Jit final {
|
|
|
|
public:
|
2018-01-27 22:36:55 +00:00
|
|
|
explicit Jit(UserConfig conf);
|
2016-07-04 17:22:11 +08:00
|
|
|
~Jit();
|
|
|
|
|
|
|
|
/**
|
2018-01-04 21:12:02 +00:00
|
|
|
* Runs the emulated CPU.
|
2016-07-04 17:22:11 +08:00
|
|
|
* Cannot be recursively called.
|
|
|
|
*/
|
2018-01-04 21:12:02 +00:00
|
|
|
void Run();
|
2016-07-04 17:22:11 +08:00
|
|
|
|
2020-04-06 15:35:43 +01:00
|
|
|
/**
|
|
|
|
* Steps the emulated CPU.
|
|
|
|
* Cannot be recursively called.
|
|
|
|
*/
|
|
|
|
void Step();
|
|
|
|
|
2016-07-04 17:22:11 +08:00
|
|
|
/**
|
|
|
|
* Clears the code cache of all compiled code.
|
2016-09-02 10:58:37 +01:00
|
|
|
* Can be called at any time. Halts execution if called within a callback.
|
2016-07-04 17:22:11 +08:00
|
|
|
*/
|
2016-09-01 04:47:09 -04:00
|
|
|
void ClearCache();
|
2016-07-04 17:22:11 +08:00
|
|
|
|
2017-02-16 18:18:29 +00:00
|
|
|
/**
|
|
|
|
* Invalidate the code cache at a range of addresses.
|
|
|
|
* @param start_address The starting address of the range to invalidate.
|
|
|
|
* @param length The length (in bytes) of the range to invalidate.
|
|
|
|
*/
|
|
|
|
void InvalidateCacheRange(std::uint32_t start_address, std::size_t length);
|
|
|
|
|
2016-08-09 22:45:54 +01:00
|
|
|
/**
|
|
|
|
* Reset CPU state to state at startup. Does not clear code cache.
|
|
|
|
* Cannot be called from a callback.
|
|
|
|
*/
|
|
|
|
void Reset();
|
|
|
|
|
2016-07-04 17:22:11 +08:00
|
|
|
/**
|
|
|
|
* Stops execution in Jit::Run.
|
|
|
|
* Can only be called from a callback.
|
|
|
|
*/
|
|
|
|
void HaltExecution();
|
|
|
|
|
|
|
|
/// View and modify registers.
|
2016-08-25 18:22:08 +01:00
|
|
|
std::array<std::uint32_t, 16>& Regs();
|
|
|
|
const std::array<std::uint32_t, 16>& Regs() const;
|
|
|
|
std::array<std::uint32_t, 64>& ExtRegs();
|
|
|
|
const std::array<std::uint32_t, 64>& ExtRegs() const;
|
2016-07-04 17:22:11 +08:00
|
|
|
|
|
|
|
/// View and modify CPSR.
|
2016-08-25 18:22:08 +01:00
|
|
|
std::uint32_t Cpsr() const;
|
2017-12-02 13:55:04 +00:00
|
|
|
void SetCpsr(std::uint32_t value);
|
2016-07-04 17:22:11 +08:00
|
|
|
|
2016-08-05 18:54:19 +01:00
|
|
|
/// View and modify FPSCR.
|
2016-08-25 18:22:08 +01:00
|
|
|
std::uint32_t Fpscr() const;
|
2017-12-02 13:55:04 +00:00
|
|
|
void SetFpscr(std::uint32_t value);
|
2016-08-05 18:54:19 +01:00
|
|
|
|
2017-12-03 18:25:40 +00:00
|
|
|
Context SaveContext() const;
|
|
|
|
void SaveContext(Context&) const;
|
|
|
|
void LoadContext(const Context&);
|
|
|
|
|
2016-07-04 17:22:11 +08:00
|
|
|
/**
|
|
|
|
* Returns true if Jit::Run was called but hasn't returned yet.
|
|
|
|
* i.e.: We're in a callback.
|
|
|
|
*/
|
|
|
|
bool IsExecuting() const {
|
|
|
|
return is_executing;
|
|
|
|
}
|
|
|
|
|
2016-08-12 18:17:31 +01:00
|
|
|
/**
|
|
|
|
* @param descriptor Basic block descriptor.
|
|
|
|
* @return A string containing disassembly of the host machine code produced for the basic block.
|
|
|
|
*/
|
2016-09-05 06:54:09 -04:00
|
|
|
std::string Disassemble(const IR::LocationDescriptor& descriptor);
|
2016-08-05 01:50:31 +01:00
|
|
|
|
2016-07-04 17:22:11 +08:00
|
|
|
private:
|
|
|
|
bool is_executing = false;
|
2016-07-01 21:01:06 +08:00
|
|
|
|
2016-07-04 17:22:11 +08:00
|
|
|
struct Impl;
|
|
|
|
std::unique_ptr<Impl> impl;
|
2016-07-01 21:01:06 +08:00
|
|
|
};
|
|
|
|
|
2018-01-04 21:12:02 +00:00
|
|
|
} // namespace A32
|
2016-07-01 21:01:06 +08:00
|
|
|
} // namespace Dynarmic
|