2013-01-20 09:13:59 +00:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
* Xenia : Xbox 360 Emulator Research Project *
|
|
|
|
******************************************************************************
|
|
|
|
* Copyright 2013 Ben Vanik. All rights reserved. *
|
|
|
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef XENIA_CPU_PROCESSOR_H_
|
|
|
|
#define XENIA_CPU_PROCESSOR_H_
|
|
|
|
|
2013-12-22 08:51:50 +00:00
|
|
|
#include <xenia/core.h>
|
|
|
|
#include <xenia/debug/debug_target.h>
|
2013-01-20 09:13:59 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2013-12-23 01:50:14 +00:00
|
|
|
XEDECLARECLASS2(alloy, runtime, Breakpoint);
|
2013-10-24 03:42:24 +00:00
|
|
|
XEDECLARECLASS1(xe, Emulator);
|
|
|
|
XEDECLARECLASS1(xe, ExportResolver);
|
2013-12-07 06:57:16 +00:00
|
|
|
XEDECLARECLASS2(xe, cpu, XenonMemory);
|
|
|
|
XEDECLARECLASS2(xe, cpu, XenonRuntime);
|
|
|
|
XEDECLARECLASS2(xe, cpu, XenonThreadState);
|
2013-12-25 01:25:29 +00:00
|
|
|
XEDECLARECLASS2(xe, cpu, XexModule);
|
2013-06-01 04:22:00 +00:00
|
|
|
|
|
|
|
|
2013-01-20 09:13:59 +00:00
|
|
|
namespace xe {
|
|
|
|
namespace cpu {
|
|
|
|
|
|
|
|
|
2013-12-22 08:51:50 +00:00
|
|
|
class Processor : public debug::DebugTarget {
|
2013-01-20 09:13:59 +00:00
|
|
|
public:
|
2013-12-07 06:57:16 +00:00
|
|
|
Processor(Emulator* emulator);
|
2013-01-20 09:13:59 +00:00
|
|
|
~Processor();
|
|
|
|
|
2013-10-24 03:42:24 +00:00
|
|
|
ExportResolver* export_resolver() const { return export_resolver_; }
|
2013-12-07 06:57:16 +00:00
|
|
|
XenonRuntime* runtime() const { return runtime_; }
|
|
|
|
Memory* memory() const { return memory_; }
|
2013-01-20 09:13:59 +00:00
|
|
|
|
|
|
|
int Setup();
|
|
|
|
|
2013-12-07 06:57:16 +00:00
|
|
|
int Execute(
|
|
|
|
XenonThreadState* thread_state, uint64_t address);
|
|
|
|
uint64_t Execute(
|
2014-07-02 22:39:30 +00:00
|
|
|
XenonThreadState* thread_state, uint64_t address, uint64_t args[],
|
|
|
|
size_t arg_count);
|
2013-09-25 07:46:09 +00:00
|
|
|
|
2013-10-19 18:50:01 +00:00
|
|
|
uint64_t ExecuteInterrupt(
|
2014-07-02 22:39:30 +00:00
|
|
|
uint32_t cpu, uint64_t address, uint64_t args[], size_t arg_count);
|
2013-01-28 01:49:32 +00:00
|
|
|
|
2013-12-23 03:58:00 +00:00
|
|
|
virtual void OnDebugClientConnected(uint32_t client_id);
|
|
|
|
virtual void OnDebugClientDisconnected(uint32_t client_id);
|
2013-12-22 08:51:50 +00:00
|
|
|
virtual json_t* OnDebugRequest(
|
2013-12-23 03:58:00 +00:00
|
|
|
uint32_t client_id, const char* command, json_t* request,
|
|
|
|
bool& succeeded);
|
2013-12-22 08:51:50 +00:00
|
|
|
|
2013-12-25 01:25:29 +00:00
|
|
|
private:
|
|
|
|
json_t* DumpModule(XexModule* module, bool& succeeded);
|
|
|
|
json_t* DumpFunction(uint64_t address, bool& succeeded);
|
2013-12-26 01:31:53 +00:00
|
|
|
json_t* DumpThreadState(XenonThreadState* thread_state);
|
2013-12-25 01:25:29 +00:00
|
|
|
|
2013-01-20 09:13:59 +00:00
|
|
|
private:
|
2013-12-07 06:57:16 +00:00
|
|
|
Emulator* emulator_;
|
|
|
|
ExportResolver* export_resolver_;
|
|
|
|
|
|
|
|
XenonRuntime* runtime_;
|
|
|
|
Memory* memory_;
|
|
|
|
|
|
|
|
xe_mutex_t* interrupt_thread_lock_;
|
|
|
|
XenonThreadState* interrupt_thread_state_;
|
|
|
|
uint64_t interrupt_thread_block_;
|
2013-12-23 01:50:14 +00:00
|
|
|
|
2013-12-23 03:58:00 +00:00
|
|
|
class DebugClientState {
|
|
|
|
public:
|
|
|
|
DebugClientState(XenonRuntime* runtime);
|
|
|
|
~DebugClientState();
|
|
|
|
|
|
|
|
int AddBreakpoint(const char* breakpoint_id,
|
|
|
|
alloy::runtime::Breakpoint* breakpoint);
|
|
|
|
int RemoveBreakpoint(const char* breakpoint_id);
|
|
|
|
int RemoveAllBreakpoints();
|
|
|
|
|
|
|
|
private:
|
|
|
|
XenonRuntime* runtime_;
|
|
|
|
|
|
|
|
xe_mutex_t* breakpoints_lock_;
|
|
|
|
typedef std::unordered_map<std::string, alloy::runtime::Breakpoint*> BreakpointMap;
|
|
|
|
BreakpointMap breakpoints_;
|
|
|
|
};
|
2013-12-23 22:01:13 +00:00
|
|
|
xe_mutex_t* debug_client_states_lock_;
|
2013-12-23 03:58:00 +00:00
|
|
|
typedef std::unordered_map<uint32_t, DebugClientState*> DebugClientStateMap;
|
|
|
|
DebugClientStateMap debug_client_states_;
|
2013-01-20 09:13:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace cpu
|
|
|
|
} // namespace xe
|
|
|
|
|
|
|
|
|
|
|
|
#endif // XENIA_CPU_PROCESSOR_H_
|