mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-30 14:35:17 -04:00
kern: add hardware single step extension
This commit is contained in:
parent
904ab19823
commit
4075d24e0c
10 changed files with 226 additions and 4 deletions
|
@ -14,6 +14,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <mesosphere/kern_build_config.hpp>
|
||||
|
||||
/* TODO: Different header for this? */
|
||||
#define AMS_KERN_NUM_SUPERVISOR_CALLS 0xC0
|
||||
|
@ -30,6 +31,10 @@
|
|||
#define THREAD_STACK_PARAMETERS_IS_IN_EXCEPTION_HANDLER 0x2D
|
||||
#define THREAD_STACK_PARAMETERS_IS_PINNED 0x2E
|
||||
|
||||
#if defined(MESOSPHERE_ENABLE_HARDWARE_SINGLE_STEP)
|
||||
#define THREAD_STACK_PARAMETERS_IS_SINGLE_STEP 0x2F
|
||||
#endif
|
||||
|
||||
/* ams::kern::arch::arm64::KThreadContext, https://github.com/Atmosphere-NX/Atmosphere/blob/master/libraries/libmesosphere/include/mesosphere/arch/arm64/kern_k_thread_context.hpp */
|
||||
#define THREAD_CONTEXT_SIZE 0x290
|
||||
#define THREAD_CONTEXT_CPU_REGISTERS 0x000
|
||||
|
|
|
@ -31,3 +31,4 @@
|
|||
|
||||
//#define MESOSPHERE_BUILD_FOR_TRACING
|
||||
#define MESOSPHERE_ENABLE_PANIC_REGISTER_DUMP
|
||||
#define MESOSPHERE_ENABLE_HARDWARE_SINGLE_STEP
|
||||
|
|
|
@ -92,6 +92,9 @@ namespace ams::kern {
|
|||
bool is_calling_svc;
|
||||
bool is_in_exception_handler;
|
||||
bool is_pinned;
|
||||
#if defined(MESOSPHERE_ENABLE_HARDWARE_SINGLE_STEP)
|
||||
bool is_single_step;
|
||||
#endif
|
||||
};
|
||||
static_assert(alignof(StackParameters) == 0x10);
|
||||
static_assert(sizeof(StackParameters) == THREAD_STACK_PARAMETERS_SIZE);
|
||||
|
@ -106,6 +109,10 @@ namespace ams::kern {
|
|||
static_assert(__builtin_offsetof(StackParameters, is_in_exception_handler) == THREAD_STACK_PARAMETERS_IS_IN_EXCEPTION_HANDLER);
|
||||
static_assert(__builtin_offsetof(StackParameters, is_pinned) == THREAD_STACK_PARAMETERS_IS_PINNED);
|
||||
|
||||
#if defined(MESOSPHERE_ENABLE_HARDWARE_SINGLE_STEP)
|
||||
static_assert(__builtin_offsetof(StackParameters, is_single_step) == THREAD_STACK_PARAMETERS_IS_SINGLE_STEP);
|
||||
#endif
|
||||
|
||||
struct QueueEntry {
|
||||
private:
|
||||
KThread *m_prev;
|
||||
|
@ -325,6 +332,25 @@ namespace ams::kern {
|
|||
return this->GetStackParameters().current_svc_id;
|
||||
}
|
||||
|
||||
#if defined(MESOSPHERE_ENABLE_HARDWARE_SINGLE_STEP)
|
||||
|
||||
ALWAYS_INLINE void SetSingleStep() {
|
||||
MESOSPHERE_ASSERT_THIS();
|
||||
this->GetStackParameters().is_single_step = true;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void ClearSingleStep() {
|
||||
MESOSPHERE_ASSERT_THIS();
|
||||
this->GetStackParameters().is_single_step = false;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool IsSingleStep() const {
|
||||
MESOSPHERE_ASSERT_THIS();
|
||||
return this->GetStackParameters().is_single_step;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ALWAYS_INLINE void RegisterDpc(DpcFlag flag) {
|
||||
this->GetStackParameters().dpc_flags.fetch_or(flag);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue