Kernel+LibC: Modify aarch64's __mcontext to store registers in an array

This commit also removes the unnecessary ifdefs from
sys/arch/aarch64/regs.h. Contributed by konrad, thanks for that.
This commit is contained in:
Timon Kruiper 2023-02-23 00:00:37 +01:00 committed by Idan Horowitz
parent 7440112cd9
commit 200e91cd7f
Notes: sideshowbarker 2024-07-16 22:17:03 +09:00
2 changed files with 3 additions and 57 deletions

View file

@ -13,37 +13,7 @@ extern "C" {
#endif
struct __attribute__((packed)) __mcontext {
uint64_t r0;
uint64_t r1;
uint64_t r2;
uint64_t r3;
uint64_t r4;
uint64_t r5;
uint64_t r6;
uint64_t r7;
uint64_t r8;
uint64_t r9;
uint64_t r10;
uint64_t r11;
uint64_t r12;
uint64_t r13;
uint64_t r14;
uint64_t r15;
uint64_t r16;
uint64_t r17;
uint64_t r18;
uint64_t r19;
uint64_t r20;
uint64_t r21;
uint64_t r22;
uint64_t r23;
uint64_t r24;
uint64_t r25;
uint64_t r26;
uint64_t r27;
uint64_t r28;
uint64_t r29;
uint64_t r30;
uint64_t x[31];
uint64_t sp;
uint64_t pc;
};

View file

@ -21,46 +21,22 @@ struct [[gnu::packed]] PtraceRegisters : public __mcontext {
# if defined(__cplusplus) && defined(__cpp_concepts)
FlatPtr ip() const
{
# if ARCH(X86_64)
return rip;
# elif ARCH(AARCH64)
return pc;
# else
# error Unknown architecture
# endif
}
void set_ip(FlatPtr ip)
{
# if ARCH(X86_64)
rip = ip;
# elif ARCH(AARCH64)
pc = ip;
# else
# error Unknown architecture
# endif
}
FlatPtr bp() const
{
# if ARCH(X86_64)
return rbp;
# elif ARCH(AARCH64)
return r29;
# else
# error Unknown architecture
# endif
return x[29];
}
void set_bp(FlatPtr bp)
{
# if ARCH(X86_64)
rbp = bp;
# elif ARCH(AARCH64)
r29 = bp;
# else
# error Unknown architecture
# endif
x[29] = bp;
}
# endif
};