Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Jul 2015 13:59:26 +0000 (UTC)
From:      Ruslan Bukin <br@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285003 - head/lib/libproc
Message-ID:  <201507011359.t61DxQEB041405@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: br
Date: Wed Jul  1 13:59:26 2015
New Revision: 285003
URL: https://svnweb.freebsd.org/changeset/base/285003

Log:
  Make libproc compilable on AArch64.

Modified:
  head/lib/libproc/proc_bkpt.c
  head/lib/libproc/proc_regs.c

Modified: head/lib/libproc/proc_bkpt.c
==============================================================================
--- head/lib/libproc/proc_bkpt.c	Wed Jul  1 11:28:42 2015	(r285002)
+++ head/lib/libproc/proc_bkpt.c	Wed Jul  1 13:59:26 2015	(r285003)
@@ -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

Modified: head/lib/libproc/proc_regs.c
==============================================================================
--- head/lib/libproc/proc_regs.c	Wed Jul  1 11:28:42 2015	(r285002)
+++ head/lib/libproc/proc_regs.c	Wed Jul  1 13:59:26 2015	(r285003)
@@ -54,7 +54,9 @@ proc_regget(struct proc_handle *phdl, pr
 		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, pr
 #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, pr
 		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, pr
 #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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507011359.t61DxQEB041405>