/* Common target dependent for AArch64 systems.
- Copyright (C) 2018 Free Software Foundation, Inc.
+ Copyright (C) 2018-2020 Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef AARCH64_SVE_LINUX_PTRACE_H
-#define AARCH64_SVE_LINUX_PTRACE_H
+#ifndef NAT_AARCH64_SVE_LINUX_PTRACE_H
+#define NAT_AARCH64_SVE_LINUX_PTRACE_H
-/* Where indicated, this file contains defines and macros lifted directly from
- the Linux kernel headers, with no modification.
- Refer to Linux kernel documentation for details. */
-
-#include <asm/sigcontext.h>
+#include <signal.h>
#include <sys/utsname.h>
#include <sys/ptrace.h>
#include <asm/ptrace.h>
-/* Read VQ for the given tid using ptrace. If SVE is not supported then zero
- is returned (on a system that supports SVE, then VQ cannot be zero). */
-
-extern unsigned long aarch64_sve_get_vq (int tid);
-
-/* Structures and defines taken from sigcontext.h. */
-
#ifndef SVE_SIG_ZREGS_SIZE
+#include "aarch64-sve-linux-sigcontext.h"
+#endif
+
+/* Indicates whether a SVE ptrace header is followed by SVE registers or a
+ fpsimd structure. */
-#define SVE_VQ_BYTES 16 /* number of bytes per quadword */
+#define HAS_SVE_STATE(header) ((header).flags & SVE_PT_REGS_SVE)
-#define SVE_VQ_MIN 1
-#define SVE_VQ_MAX 512
+/* Read VQ for the given tid using ptrace. If SVE is not supported then zero
+ is returned (on a system that supports SVE, then VQ cannot be zero). */
-#define SVE_VL_MIN (SVE_VQ_MIN * SVE_VQ_BYTES)
-#define SVE_VL_MAX (SVE_VQ_MAX * SVE_VQ_BYTES)
+uint64_t aarch64_sve_get_vq (int tid);
-#define SVE_NUM_ZREGS 32
-#define SVE_NUM_PREGS 16
+/* Set VQ in the kernel for the given tid, using either the value VQ or
+ reading from the register VG in the register buffer. */
-#define sve_vl_valid(vl) \
- ((vl) % SVE_VQ_BYTES == 0 && (vl) >= SVE_VL_MIN && (vl) <= SVE_VL_MAX)
+bool aarch64_sve_set_vq (int tid, uint64_t vq);
+bool aarch64_sve_set_vq (int tid, struct reg_buffer_common *reg_buf);
-#endif /* SVE_SIG_ZREGS_SIZE. */
+/* Read the current SVE register set using ptrace, allocating space as
+ required. */
+extern std::unique_ptr<gdb_byte[]> aarch64_sve_get_sveregs (int tid);
-/* Structures and defines taken from ptrace.h. */
+/* Put the registers from linux structure buf into register buffer. Assumes the
+ vector lengths in the register buffer match the size in the kernel. */
-#ifndef SVE_PT_SVE_ZREG_SIZE
+extern void aarch64_sve_regs_copy_to_reg_buf (struct reg_buffer_common *reg_buf,
+ const void *buf);
-struct user_sve_header {
- __u32 size; /* total meaningful regset content in bytes */
- __u32 max_size; /* maxmium possible size for this thread */
- __u16 vl; /* current vector length */
- __u16 max_vl; /* maximum possible vector length */
- __u16 flags;
- __u16 __reserved;
-};
+/* Put the registers from register buffer into linux structure buf. Assumes the
+ vector lengths in the register buffer match the size in the kernel. */
-#endif /* SVE_PT_SVE_ZREG_SIZE. */
+extern void
+aarch64_sve_regs_copy_from_reg_buf (const struct reg_buffer_common *reg_buf,
+ void *buf);
-#endif /* aarch64-sve-linux-ptrace.h */
+#endif /* NAT_AARCH64_SVE_LINUX_PTRACE_H */