mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
ARMv7: partial disasm functionality, bugfix
This commit is contained in:
parent
e3f55a75a3
commit
819c955cca
@ -112,7 +112,11 @@ struct FileListener : LogListener
|
||||
|
||||
if (msg.mType == Log::TTY)
|
||||
{
|
||||
text = fmt::escape(text) + "\n";
|
||||
text = fmt::escape(text);
|
||||
if (text[text.length() - 1] != '\n')
|
||||
{
|
||||
text += '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
mFile.Write(text);
|
||||
|
@ -355,7 +355,7 @@ std::string fmt::escape(std::string source)
|
||||
{ "\a", "\\a" },
|
||||
{ "\b", "\\b" },
|
||||
{ "\f", "\\f" },
|
||||
{ "\n", "\\n" },
|
||||
{ "\n", "\\n\n" },
|
||||
{ "\r", "\\r" },
|
||||
{ "\t", "\\t" },
|
||||
{ "\v", "\\v" },
|
||||
@ -365,7 +365,7 @@ std::string fmt::escape(std::string source)
|
||||
|
||||
for (char c = 0; c < 32; c++)
|
||||
{
|
||||
source = fmt::replace_all(source, std::string(1, c), fmt::Format("\\x%02X", c));
|
||||
if (c != '\n') source = fmt::replace_all(source, std::string(1, c), fmt::Format("\\x%02X", c));
|
||||
}
|
||||
|
||||
return source;
|
||||
|
@ -10,17 +10,15 @@ enum ARMv7InstructionSet
|
||||
ThumbEE
|
||||
};
|
||||
|
||||
enum armv7_debug_flags : u32
|
||||
{
|
||||
DF_DISASM = 1 << 0,
|
||||
DF_PRINT = 1 << 1,
|
||||
DF_NO_EXE = 1 << 2,
|
||||
};
|
||||
|
||||
struct ARMv7Context
|
||||
{
|
||||
ARMv7Thread& thread;
|
||||
|
||||
ARMv7Context(ARMv7Thread& thread) : thread(thread) {}
|
||||
|
||||
void write_pc(u32 value);
|
||||
u32 read_pc();
|
||||
u32 get_stack_arg(u32 pos);
|
||||
void fast_call(u32 addr);
|
||||
|
||||
union
|
||||
{
|
||||
u32 GPR[15];
|
||||
@ -127,6 +125,18 @@ struct ARMv7Context
|
||||
|
||||
std::array<perf_counter, 6> counters;
|
||||
|
||||
ARMv7Thread& thread;
|
||||
|
||||
u32 debug; // debug flags
|
||||
std::string debug_str;
|
||||
|
||||
ARMv7Context(ARMv7Thread& thread) : thread(thread), debug(DF_DISASM | DF_PRINT) {}
|
||||
|
||||
void write_pc(u32 value);
|
||||
u32 read_pc();
|
||||
u32 get_stack_arg(u32 pos);
|
||||
void fast_call(u32 addr);
|
||||
|
||||
void write_gpr(u32 n, u32 value)
|
||||
{
|
||||
assert(n < 16);
|
||||
|
@ -35,7 +35,7 @@ const ARMv7_opcode_t ARMv7_opcode_table[] =
|
||||
|
||||
ARMv7_OP4(0xfbe0, 0x8000, 0xf140, 0x0000, T1, ADC_IMM, nullptr),
|
||||
ARMv7_OP4(0x0fe0, 0x0000, 0x02a0, 0x0000, A1, ADC_IMM),
|
||||
ARMv7_OP2(0xffc0, 0x4040, T1, ADC_REG, nullptr),
|
||||
ARMv7_OP2(0xffc0, 0x4140, T1, ADC_REG, nullptr),
|
||||
ARMv7_OP4(0xffe0, 0x8000, 0xeb40, 0x0000, T2, ADC_REG, nullptr),
|
||||
ARMv7_OP4(0x0fe0, 0x0010, 0x00a0, 0x0000, A1, ADC_REG),
|
||||
ARMv7_OP4(0x0fe0, 0x0090, 0x00a0, 0x0010, A1, ADC_RSR),
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,12 +18,11 @@ enum ARMv7_encoding
|
||||
|
||||
enum SRType : u32
|
||||
{
|
||||
SRType_None,
|
||||
SRType_LSL,
|
||||
SRType_LSR,
|
||||
SRType_ASR,
|
||||
SRType_ROR,
|
||||
SRType_RRX
|
||||
SRType_RRX,
|
||||
};
|
||||
|
||||
namespace ARMv7_instrs
|
||||
|
@ -10,7 +10,7 @@ void add_psv_func(psv_func& data)
|
||||
g_psv_func_list.push_back(data);
|
||||
}
|
||||
|
||||
psv_func* get_psv_func_by_nid(u32 nid)
|
||||
const psv_func* get_psv_func_by_nid(u32 nid)
|
||||
{
|
||||
for (auto& f : g_psv_func_list)
|
||||
{
|
||||
@ -23,7 +23,7 @@ psv_func* get_psv_func_by_nid(u32 nid)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
u32 get_psv_func_index(psv_func* func)
|
||||
u32 get_psv_func_index(const psv_func* func)
|
||||
{
|
||||
auto res = func - g_psv_func_list.data();
|
||||
|
||||
@ -32,14 +32,21 @@ u32 get_psv_func_index(psv_func* func)
|
||||
return (u32)res;
|
||||
}
|
||||
|
||||
void execute_psv_func_by_index(ARMv7Context& context, u32 index)
|
||||
const psv_func* get_psv_func_by_index(u32 index)
|
||||
{
|
||||
assert(index < g_psv_func_list.size());
|
||||
|
||||
return &g_psv_func_list[index];
|
||||
}
|
||||
|
||||
void execute_psv_func_by_index(ARMv7Context& context, u32 index)
|
||||
{
|
||||
auto func = get_psv_func_by_index(index);
|
||||
|
||||
auto old_last_syscall = context.thread.m_last_syscall;
|
||||
context.thread.m_last_syscall = g_psv_func_list[index].nid;
|
||||
context.thread.m_last_syscall = func->nid;
|
||||
|
||||
(*g_psv_func_list[index].func)(context);
|
||||
(*func->func)(context);
|
||||
|
||||
context.thread.m_last_syscall = old_last_syscall;
|
||||
}
|
||||
@ -174,7 +181,7 @@ void initialize_psv_modules()
|
||||
// setup special functions (without NIDs)
|
||||
psv_func unimplemented;
|
||||
unimplemented.nid = 0;
|
||||
unimplemented.name = "Special function (unimplemented stub)";
|
||||
unimplemented.name = "UNIMPLEMENTED";
|
||||
unimplemented.func.reset(new psv_func_detail::func_binder<void, ARMv7Context&>([](ARMv7Context& context)
|
||||
{
|
||||
context.thread.m_last_syscall = vm::psv::read32(context.thread.PC + 4);
|
||||
@ -184,7 +191,7 @@ void initialize_psv_modules()
|
||||
|
||||
psv_func hle_return;
|
||||
hle_return.nid = 1;
|
||||
hle_return.name = "Special function (return from HLE)";
|
||||
hle_return.name = "HLE_RETURN";
|
||||
hle_return.func.reset(new psv_func_detail::func_binder<void, ARMv7Context&>([](ARMv7Context& context)
|
||||
{
|
||||
context.thread.FastStop();
|
||||
|
@ -492,9 +492,11 @@ template<typename RT, typename... T> void reg_psv_func(u32 nid, psv_log_base* mo
|
||||
add_psv_func(f);
|
||||
}
|
||||
// Find registered HLE function by its ID
|
||||
psv_func* get_psv_func_by_nid(u32 nid);
|
||||
const psv_func* get_psv_func_by_nid(u32 nid);
|
||||
// Get index of registered HLE function
|
||||
u32 get_psv_func_index(psv_func* func);
|
||||
u32 get_psv_func_index(const psv_func* func);
|
||||
// Find registered HLE function by its index
|
||||
const psv_func* get_psv_func_by_index(u32 index);
|
||||
// Execute registered HLE function by its index
|
||||
void execute_psv_func_by_index(ARMv7Context& context, u32 index);
|
||||
// Register all HLE functions
|
||||
|
@ -349,6 +349,8 @@ void Emulator::Resume()
|
||||
GetCallbackManager().RunPauseCallbacks(false);
|
||||
}
|
||||
|
||||
extern std::map<u32, std::string> g_armv7_dump;
|
||||
|
||||
void Emulator::Stop()
|
||||
{
|
||||
if(IsStopped()) return;
|
||||
@ -365,6 +367,14 @@ void Emulator::Stop()
|
||||
|
||||
finalize_psv_modules();
|
||||
clear_all_psv_objects();
|
||||
|
||||
for (auto& v : g_armv7_dump)
|
||||
{
|
||||
LOG_NOTICE(ARMv7, v.second);
|
||||
}
|
||||
|
||||
g_armv7_dump.clear();
|
||||
|
||||
m_rsx_callback = 0;
|
||||
|
||||
// TODO: check finalization order
|
||||
|
Loading…
Reference in New Issue
Block a user