aarch64 - Support for apple exceptions

This commit is contained in:
kd-11 2024-08-24 02:09:22 +03:00 committed by kd-11
parent 4da30e9eca
commit 470f8674df
3 changed files with 24 additions and 2 deletions

View file

@ -53,6 +53,13 @@ namespace aarch64
auto esr_ctx = find_EL1_esr_context(uctx);
return esr_ctx ? esr_ctx->esr : 0;
}
#elif defined(__APPLE__)
u64 _read_ESR_EL1(const ucontext_t* uctx)
{
// Easy to read from mcontext
const auto darwin_ctx = reinterpret_cast<aarch64_darwin_mcontext64*>(uctx->uc_mcontext);
return darwin_ctx->es.ESR;
}
#else
u64 _read_ESR_EL1(const ucontext_t*)
{

View file

@ -8,6 +8,7 @@ namespace aarch64
// Some renamed kernel definitions, we don't need to include kernel headers directly
#pragma pack(push, 1)
#if defined(__linux__)
struct aarch64_cpu_ctx_block
{
u32 magic;
@ -19,6 +20,20 @@ namespace aarch64
aarch64_cpu_ctx_block head;
u64 esr; // Exception syndrome register
};
#elif defined(__APPLE__)
struct aarch64_exception_state
{
u64 FAR; // Fault address reg
u32 ESR; // Exception syndrome reg (ESR_EL1)
u32 exception_id;
};
struct aarch64_darwin_mcontext64
{
aarch64_exception_state es;
// Other states we don't care about follow this field
};
#endif
#pragma pack(pop)