kern SvcGetDebugThreadContext, SvcSetDebugThreadContext

This commit is contained in:
Michael Scire
2020-07-31 02:49:43 -07:00
committed by SciresM
parent 3afd723b92
commit 5c4fbf5c67
10 changed files with 363 additions and 4 deletions

View File

@@ -34,6 +34,12 @@ namespace ams::kern::arch::arm64 {
virtual ~KDebug() { /* ... */ }
static void PostDestroy(uintptr_t arg) { /* ... */ }
public:
virtual Result GetThreadContextImpl(ams::svc::ThreadContext *out, KThread *thread, u32 context_flags) override;
virtual Result SetThreadContextImpl(const ams::svc::ThreadContext &ctx, KThread *thread, u32 context_flags) override;
private:
Result GetFpuContext(ams::svc::ThreadContext *out, KThread *thread, u32 context_flags);
Result SetFpuContext(const ams::svc::ThreadContext &ctx, KThread *thread, u32 context_flags);
public:
static uintptr_t GetProgramCounter(const KThread &thread);
static void SetPreviousProgramCounter();

View File

@@ -74,6 +74,8 @@ namespace ams::kern::arch::arm64 {
void CloneFpuStatus();
void SetFpuRegisters(const u128 *v, bool is_64_bit);
const u128 *GetFpuRegisters() const { return this->fpu_registers; }
public:
static void OnThreadTerminating(const KThread *thread);

View File

@@ -34,6 +34,8 @@ namespace ams::kern {
public:
explicit KDebugBase() { /* ... */ }
virtual ~KDebugBase() { /* ... */ }
protected:
bool Is64Bit() const;
public:
void Initialize();
@@ -47,6 +49,12 @@ namespace ams::kern {
Result ReadMemory(KProcessAddress buffer, KProcessAddress address, size_t size);
Result WriteMemory(KProcessAddress buffer, KProcessAddress address, size_t size);
Result GetThreadContext(ams::svc::ThreadContext *out, u64 thread_id, u32 context_flags);
Result SetThreadContext(const ams::svc::ThreadContext &ctx, u64 thread_id, u32 context_flags);
virtual Result GetThreadContextImpl(ams::svc::ThreadContext *out, KThread *thread, u32 context_flags) = 0;
virtual Result SetThreadContextImpl(const ams::svc::ThreadContext &ctx, KThread *thread, u32 context_flags) = 0;
Result GetRunningThreadInfo(ams::svc::LastThreadContext *out_context, u64 *out_thread_id);
Result GetDebugEventInfo(ams::svc::lp64::DebugEventInfo *out);

View File

@@ -274,6 +274,11 @@ namespace ams::kern {
return this->GetStackParameters().is_calling_svc;
}
ALWAYS_INLINE u8 GetSvcId() const {
MESOSPHERE_ASSERT_THIS();
return this->GetStackParameters().current_svc_id;
}
ALWAYS_INLINE void RegisterDpc(DpcFlag flag) {
this->GetStackParameters().dpc_flags |= flag;
}

View File

@@ -72,6 +72,7 @@ namespace ams::kern::svc {
/* 517 */ using ::ams::svc::ResultInvalidProcessId;
/* 518 */ using ::ams::svc::ResultInvalidThreadId;
/* 519 */ using ::ams::svc::ResultInvalidId;
/* 520 */ using ::ams::svc::ResultProcessTerminated;
}