diff --git a/cddl/lib/libdtrace/Makefile b/cddl/lib/libdtrace/Makefile --- a/cddl/lib/libdtrace/Makefile +++ b/cddl/lib/libdtrace/Makefile @@ -133,6 +133,7 @@ .if ${MACHINE_CPUARCH} == "aarch64" SRCS+= instr_size.c +DSRCS+= regs_aarch64.d .endif YFLAGS+=-d diff --git a/cddl/lib/libdtrace/regs_aarch64.d b/cddl/lib/libdtrace/regs_aarch64.d new file mode 100644 --- /dev/null +++ b/cddl/lib/libdtrace/regs_aarch64.d @@ -0,0 +1,74 @@ +/* + * SPDX-License-Identifier: CDDL 1.0 + * + * Copyright 2023 Christos Margiolis + */ + +inline int R_X0 = 0; +#pragma D binding "1.13" R_X0 +inline int R_X1 = 1; +#pragma D binding "1.13" R_X1 +inline int R_X2 = 2; +#pragma D binding "1.13" R_X2 +inline int R_X3 = 3; +#pragma D binding "1.13" R_X3 +inline int R_X4 = 4; +#pragma D binding "1.13" R_X4 +inline int R_X5 = 5; +#pragma D binding "1.13" R_X5 +inline int R_X6 = 6; +#pragma D binding "1.13" R_X6 +inline int R_X7 = 7; +#pragma D binding "1.13" R_X7 +inline int R_X8 = 8; +#pragma D binding "1.13" R_X8 +inline int R_X9 = 9; +#pragma D binding "1.13" R_X9 +inline int R_X10 = 10; +#pragma D binding "1.13" R_X10 +inline int R_X11 = 11; +#pragma D binding "1.13" R_X11 +inline int R_X12 = 12; +#pragma D binding "1.13" R_X12 +inline int R_X13 = 13; +#pragma D binding "1.13" R_X13 +inline int R_X14 = 14; +#pragma D binding "1.13" R_X14 +inline int R_X15 = 15; +#pragma D binding "1.13" R_X15 +inline int R_X16 = 16; +#pragma D binding "1.13" R_X16 +inline int R_X17 = 17; +#pragma D binding "1.13" R_X17 +inline int R_X18 = 18; +#pragma D binding "1.13" R_X18 +inline int R_X19 = 19; +#pragma D binding "1.13" R_X19 +inline int R_X20 = 20; +#pragma D binding "1.13" R_X20 +inline int R_X21 = 21; +#pragma D binding "1.13" R_X21 +inline int R_X22 = 22; +#pragma D binding "1.13" R_X22 +inline int R_X23 = 23; +#pragma D binding "1.13" R_X23 +inline int R_X24 = 24; +#pragma D binding "1.13" R_X24 +inline int R_X25 = 25; +#pragma D binding "1.13" R_X25 +inline int R_X26 = 26; +#pragma D binding "1.13" R_X26 +inline int R_X27 = 27; +#pragma D binding "1.13" R_X27 +inline int R_X28 = 28; +#pragma D binding "1.13" R_X28 +inline int R_X29 = 29; +#pragma D binding "1.13" R_X29 +inline int R_FP= 29; +#pragma D binding "1.13" R_FP +inline int R_LR = 30; +#pragma D binding "1.13" R_LR +inline int R_SP = 31; +#pragma D binding "1.13" R_SP +inline int R_PC = 32; +#pragma D binding "1.13" R_PC diff --git a/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c b/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c --- a/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c +++ b/sys/cddl/dev/dtrace/aarch64/dtrace_isa.c @@ -280,10 +280,20 @@ ulong_t dtrace_getreg(struct trapframe *rp, uint_t reg) { - - printf("IMPLEMENT ME: %s\n", __func__); - - return (0); + switch (reg) { + case REG_X0 ... REG_X29: + return (rp->tf_x[reg]); + case REG_LR: + return (rp->tf_lr); + case REG_SP: + return (rp->tf_sp); + case REG_PC: + return (rp->tf_elr); + default: + DTRACE_CPUFLAG_SET(CPU_DTRACE_ILLOP); + return (0); + } + /* NOTREACHED */ } static int diff --git a/sys/cddl/dev/dtrace/aarch64/regset.h b/sys/cddl/dev/dtrace/aarch64/regset.h --- a/sys/cddl/dev/dtrace/aarch64/regset.h +++ b/sys/cddl/dev/dtrace/aarch64/regset.h @@ -42,7 +42,40 @@ extern "C" { #endif -/* Place here */ +#define REG_X0 0 +#define REG_X1 1 +#define REG_X2 2 +#define REG_X3 3 +#define REG_X4 4 +#define REG_X5 5 +#define REG_X6 6 +#define REG_X7 7 +#define REG_X8 8 +#define REG_X9 9 +#define REG_X10 10 +#define REG_X11 11 +#define REG_X12 12 +#define REG_X13 13 +#define REG_X14 14 +#define REG_X15 15 +#define REG_X16 16 +#define REG_X17 17 +#define REG_X18 18 +#define REG_X19 19 +#define REG_X20 20 +#define REG_X21 21 +#define REG_X22 22 +#define REG_X23 23 +#define REG_X24 24 +#define REG_X25 25 +#define REG_X26 26 +#define REG_X27 27 +#define REG_X28 28 +#define REG_X29 29 +#define REG_FP REG_X29 +#define REG_LR 30 +#define REG_SP 31 +#define REG_PC 32 #ifdef __cplusplus }