aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuslan Bukin <br@FreeBSD.org>2015-07-01 13:59:26 +0000
committerRuslan Bukin <br@FreeBSD.org>2015-07-01 13:59:26 +0000
commit27e54fb59e46cc309e9bdbd0697cafb11938c23c (patch)
treedf641c79945fd22332a00f95edb13412b05c5f8e
parent2206ec827cdecf0182dc47b238df6a5aab0a2298 (diff)
downloadsrc-27e54fb59e46cc309e9bdbd0697cafb11938c23c.tar.gz
src-27e54fb59e46cc309e9bdbd0697cafb11938c23c.zip
Make libproc compilable on AArch64.
Notes
Notes: svn path=/head/; revision=285003
-rw-r--r--lib/libproc/proc_bkpt.c22
-rw-r--r--lib/libproc/proc_regs.c16
2 files changed, 26 insertions, 12 deletions
diff --git a/lib/libproc/proc_bkpt.c b/lib/libproc/proc_bkpt.c
index 1e4a6cc92835..50d8a9d67908 100644
--- a/lib/libproc/proc_bkpt.c
+++ b/lib/libproc/proc_bkpt.c
@@ -42,18 +42,24 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include "_libproc.h"
-#if defined(__i386__) || defined(__amd64__)
-#define BREAKPOINT_INSTR 0xcc /* int 0x3 */
+#if defined(__aarch64__)
+#define AARCH64_BRK 0xd4200000
+#define AARCH64_BRK_IMM16_SHIFT 5
+#define AARCH64_BRK_IMM16_VAL (0xd << AARCH64_BRK_IMM16_SHIFT)
+#define BREAKPOINT_INSTR (AARCH64_BRK | AARCH64_BRK_IMM16_VAL)
+#define BREAKPOINT_INSTR_SZ 4
+#elif defined(__amd64__) || defined(__i386__)
+#define BREAKPOINT_INSTR 0xcc /* int 0x3 */
#define BREAKPOINT_INSTR_SZ 1
+#elif defined(__arm__)
+#define BREAKPOINT_INSTR 0xe7ffffff /* bkpt */
+#define BREAKPOINT_INSTR_SZ 4
#elif defined(__mips__)
-#define BREAKPOINT_INSTR 0xd /* break */
+#define BREAKPOINT_INSTR 0xd /* break */
#define BREAKPOINT_INSTR_SZ 4
#elif defined(__powerpc__)
-#define BREAKPOINT_INSTR 0x7fe00008 /* trap */
-#define BREAKPOINT_INSTR_SZ 4
-#elif defined(__arm__)
-#define BREAKPOINT_INSTR 0xe7ffffff /* bkpt */
-#define BREAKPOINT_INSTR_SZ 4
+#define BREAKPOINT_INSTR 0x7fe00008 /* trap */
+#define BREAKPOINT_INSTR_SZ 4
#else
#error "Add support for your architecture"
#endif
diff --git a/lib/libproc/proc_regs.c b/lib/libproc/proc_regs.c
index 35d8d386731e..aae43ba17105 100644
--- a/lib/libproc/proc_regs.c
+++ b/lib/libproc/proc_regs.c
@@ -54,7 +54,9 @@ proc_regget(struct proc_handle *phdl, proc_reg_t reg, unsigned long *regvalue)
return (-1);
switch (reg) {
case REG_PC:
-#if defined(__amd64__)
+#if defined(__aarch64__)
+ *regvalue = regs.elr;
+#elif defined(__amd64__)
*regvalue = regs.r_rip;
#elif defined(__arm__)
*regvalue = regs.r_pc;
@@ -67,7 +69,9 @@ proc_regget(struct proc_handle *phdl, proc_reg_t reg, unsigned long *regvalue)
#endif
break;
case REG_SP:
-#if defined(__amd64__)
+#if defined(__aarch64__)
+ *regvalue = regs.sp;
+#elif defined(__amd64__)
*regvalue = regs.r_rsp;
#elif defined(__arm__)
*regvalue = regs.r_sp;
@@ -101,7 +105,9 @@ proc_regset(struct proc_handle *phdl, proc_reg_t reg, unsigned long regvalue)
return (-1);
switch (reg) {
case REG_PC:
-#if defined(__amd64__)
+#if defined(__aarch64__)
+ regs.elr = regvalue;
+#elif defined(__amd64__)
regs.r_rip = regvalue;
#elif defined(__arm__)
regs.r_pc = regvalue;
@@ -114,7 +120,9 @@ proc_regset(struct proc_handle *phdl, proc_reg_t reg, unsigned long regvalue)
#endif
break;
case REG_SP:
-#if defined(__amd64__)
+#if defined(__aarch64__)
+ regs.sp = regvalue;
+#elif defined(__amd64__)
regs.r_rsp = regvalue;
#elif defined(__arm__)
regs.r_sp = regvalue;