mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-01-10 16:38:14 +01:00
Implement public header files
This commit is contained in:
parent
656d4f7252
commit
ed3a686d1d
12 changed files with 100 additions and 47 deletions
35
include/dynarmic/callbacks.h
Normal file
35
include/dynarmic/callbacks.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2016 MerryMage
|
||||
* This software may be used and distributed according to the terms of the GNU
|
||||
* General Public License version 2 or any later version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Dynarmic {
|
||||
|
||||
class Jit;
|
||||
|
||||
/// These function pointers may be inserted into compiled code.
|
||||
struct UserCallbacks {
|
||||
std::uint8_t (*MemoryRead8)(std::uint32_t vaddr);
|
||||
std::uint16_t (*MemoryRead16)(std::uint32_t vaddr);
|
||||
std::uint32_t (*MemoryRead32)(std::uint32_t vaddr);
|
||||
std::uint64_t (*MemoryRead64)(std::uint32_t vaddr);
|
||||
|
||||
void (*MemoryWrite8)(std::uint32_t vaddr, std::uint8_t value);
|
||||
void (*MemoryWrite16)(std::uint32_t vaddr, std::uint16_t value);
|
||||
void (*MemoryWrite32)(std::uint32_t vaddr, std::uint32_t value);
|
||||
void (*MemoryWrite64)(std::uint32_t vaddr, std::uint64_t value);
|
||||
|
||||
bool (*IsReadOnlyMemory)(std::uint32_t vaddr);
|
||||
|
||||
/// The intrepreter must execute only one instruction at PC.
|
||||
void (*InterpreterFallback)(std::uint32_t pc, Jit* jit);
|
||||
|
||||
bool (*CallSVC)(std::uint32_t swi);
|
||||
};
|
||||
|
||||
} // namespace Dynarmic
|
||||
19
include/dynarmic/disassembler.h
Normal file
19
include/dynarmic/disassembler.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2016 MerryMage
|
||||
* This software may be used and distributed according to the terms of the GNU
|
||||
* General Public License version 2 or any later version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace Dynarmic {
|
||||
namespace Arm {
|
||||
|
||||
std::string DisassembleArm(std::uint32_t instruction);
|
||||
std::string DisassembleThumb16(std::uint16_t instruction);
|
||||
|
||||
} // namespace Arm
|
||||
} // namespace Dynarmic
|
||||
89
include/dynarmic/dynarmic.h
Normal file
89
include/dynarmic/dynarmic.h
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2016 MerryMage
|
||||
* This software may be used and distributed according to the terms of the GNU
|
||||
* General Public License version 2 or any later version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include <dynarmic/callbacks.h>
|
||||
|
||||
namespace Dynarmic {
|
||||
|
||||
namespace Arm {
|
||||
struct LocationDescriptor;
|
||||
}
|
||||
|
||||
class Jit final {
|
||||
public:
|
||||
explicit Jit(Dynarmic::UserCallbacks callbacks);
|
||||
~Jit();
|
||||
|
||||
/**
|
||||
* Runs the emulated CPU for about cycle_count cycles.
|
||||
* Cannot be recursively called.
|
||||
* @param cycle_count Estimated number of cycles to run the CPU for.
|
||||
* @returns Actual cycle count.
|
||||
*/
|
||||
std::size_t Run(std::size_t cycle_count);
|
||||
|
||||
/**
|
||||
* Clears the code cache of all compiled code.
|
||||
* Cannot be called from a callback.
|
||||
* @param poison_memory If true, poisons memory to crash if any stray code pointers are called.
|
||||
*/
|
||||
void ClearCache(bool poison_memory = true);
|
||||
|
||||
/**
|
||||
* Reset CPU state to state at startup. Does not clear code cache.
|
||||
* Cannot be called from a callback.
|
||||
*/
|
||||
void Reset();
|
||||
|
||||
/**
|
||||
* Stops execution in Jit::Run.
|
||||
* Can only be called from a callback.
|
||||
*/
|
||||
void HaltExecution();
|
||||
|
||||
/// View and modify registers.
|
||||
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;
|
||||
|
||||
/// View and modify CPSR.
|
||||
std::uint32_t& Cpsr();
|
||||
std::uint32_t Cpsr() const;
|
||||
|
||||
/// View and modify FPSCR.
|
||||
std::uint32_t Fpscr() const;
|
||||
void SetFpscr(std::uint32_t value) const;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param descriptor Basic block descriptor.
|
||||
* @return A string containing disassembly of the host machine code produced for the basic block.
|
||||
*/
|
||||
std::string Disassemble(const Arm::LocationDescriptor& descriptor);
|
||||
|
||||
private:
|
||||
bool is_executing = false;
|
||||
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> impl;
|
||||
};
|
||||
|
||||
} // namespace Dynarmic
|
||||
Loading…
Add table
Add a link
Reference in a new issue