18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
28c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_SIGCONTEXT_H
38c2ecf20Sopenharmony_ci#define _ASM_POWERPC_SIGCONTEXT_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/*
68c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or
78c2ecf20Sopenharmony_ci * modify it under the terms of the GNU General Public License
88c2ecf20Sopenharmony_ci * as published by the Free Software Foundation; either version
98c2ecf20Sopenharmony_ci * 2 of the License, or (at your option) any later version.
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci#include <linux/compiler.h>
128c2ecf20Sopenharmony_ci#include <asm/ptrace.h>
138c2ecf20Sopenharmony_ci#ifdef __powerpc64__
148c2ecf20Sopenharmony_ci#include <asm/elf.h>
158c2ecf20Sopenharmony_ci#endif
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistruct sigcontext {
188c2ecf20Sopenharmony_ci	unsigned long	_unused[4];
198c2ecf20Sopenharmony_ci	int		signal;
208c2ecf20Sopenharmony_ci#ifdef __powerpc64__
218c2ecf20Sopenharmony_ci	int		_pad0;
228c2ecf20Sopenharmony_ci#endif
238c2ecf20Sopenharmony_ci	unsigned long	handler;
248c2ecf20Sopenharmony_ci	unsigned long	oldmask;
258c2ecf20Sopenharmony_ci#ifdef __KERNEL__
268c2ecf20Sopenharmony_ci	struct user_pt_regs __user *regs;
278c2ecf20Sopenharmony_ci#else
288c2ecf20Sopenharmony_ci	struct pt_regs	*regs;
298c2ecf20Sopenharmony_ci#endif
308c2ecf20Sopenharmony_ci#ifdef __powerpc64__
318c2ecf20Sopenharmony_ci	elf_gregset_t	gp_regs;
328c2ecf20Sopenharmony_ci	elf_fpregset_t	fp_regs;
338c2ecf20Sopenharmony_ci/*
348c2ecf20Sopenharmony_ci * To maintain compatibility with current implementations the sigcontext is
358c2ecf20Sopenharmony_ci * extended by appending a pointer (v_regs) to a quadword type (elf_vrreg_t)
368c2ecf20Sopenharmony_ci * followed by an unstructured (vmx_reserve) field of 101 doublewords. This
378c2ecf20Sopenharmony_ci * allows the array of vector registers to be quadword aligned independent of
388c2ecf20Sopenharmony_ci * the alignment of the containing sigcontext or ucontext. It is the
398c2ecf20Sopenharmony_ci * responsibility of the code setting the sigcontext to set this pointer to
408c2ecf20Sopenharmony_ci * either NULL (if this processor does not support the VMX feature) or the
418c2ecf20Sopenharmony_ci * address of the first quadword within the allocated (vmx_reserve) area.
428c2ecf20Sopenharmony_ci *
438c2ecf20Sopenharmony_ci * The pointer (v_regs) of vector type (elf_vrreg_t) is type compatible with
448c2ecf20Sopenharmony_ci * an array of 34 quadword entries (elf_vrregset_t).  The entries with
458c2ecf20Sopenharmony_ci * indexes 0-31 contain the corresponding vector registers.  The entry with
468c2ecf20Sopenharmony_ci * index 32 contains the vscr as the last word (offset 12) within the
478c2ecf20Sopenharmony_ci * quadword.  This allows the vscr to be stored as either a quadword (since
488c2ecf20Sopenharmony_ci * it must be copied via a vector register to/from storage) or as a word.
498c2ecf20Sopenharmony_ci * The entry with index 33 contains the vrsave as the first word (offset 0)
508c2ecf20Sopenharmony_ci * within the quadword.
518c2ecf20Sopenharmony_ci *
528c2ecf20Sopenharmony_ci * Part of the VSX data is stored here also by extending vmx_restore
538c2ecf20Sopenharmony_ci * by an additional 32 double words.  Architecturally the layout of
548c2ecf20Sopenharmony_ci * the VSR registers and how they overlap on top of the legacy FPR and
558c2ecf20Sopenharmony_ci * VR registers is shown below:
568c2ecf20Sopenharmony_ci *
578c2ecf20Sopenharmony_ci *                    VSR doubleword 0               VSR doubleword 1
588c2ecf20Sopenharmony_ci *           ----------------------------------------------------------------
598c2ecf20Sopenharmony_ci *   VSR[0]  |             FPR[0]            |                              |
608c2ecf20Sopenharmony_ci *           ----------------------------------------------------------------
618c2ecf20Sopenharmony_ci *   VSR[1]  |             FPR[1]            |                              |
628c2ecf20Sopenharmony_ci *           ----------------------------------------------------------------
638c2ecf20Sopenharmony_ci *           |              ...              |                              |
648c2ecf20Sopenharmony_ci *           |              ...              |                              |
658c2ecf20Sopenharmony_ci *           ----------------------------------------------------------------
668c2ecf20Sopenharmony_ci *   VSR[30] |             FPR[30]           |                              |
678c2ecf20Sopenharmony_ci *           ----------------------------------------------------------------
688c2ecf20Sopenharmony_ci *   VSR[31] |             FPR[31]           |                              |
698c2ecf20Sopenharmony_ci *           ----------------------------------------------------------------
708c2ecf20Sopenharmony_ci *   VSR[32] |                             VR[0]                            |
718c2ecf20Sopenharmony_ci *           ----------------------------------------------------------------
728c2ecf20Sopenharmony_ci *   VSR[33] |                             VR[1]                            |
738c2ecf20Sopenharmony_ci *           ----------------------------------------------------------------
748c2ecf20Sopenharmony_ci *           |                              ...                             |
758c2ecf20Sopenharmony_ci *           |                              ...                             |
768c2ecf20Sopenharmony_ci *           ----------------------------------------------------------------
778c2ecf20Sopenharmony_ci *   VSR[62] |                             VR[30]                           |
788c2ecf20Sopenharmony_ci *           ----------------------------------------------------------------
798c2ecf20Sopenharmony_ci *   VSR[63] |                             VR[31]                           |
808c2ecf20Sopenharmony_ci *           ----------------------------------------------------------------
818c2ecf20Sopenharmony_ci *
828c2ecf20Sopenharmony_ci * FPR/VSR 0-31 doubleword 0 is stored in fp_regs, and VMX/VSR 32-63
838c2ecf20Sopenharmony_ci * is stored at the start of vmx_reserve.  vmx_reserve is extended for
848c2ecf20Sopenharmony_ci * backwards compatility to store VSR 0-31 doubleword 1 after the VMX
858c2ecf20Sopenharmony_ci * registers and vscr/vrsave.
868c2ecf20Sopenharmony_ci */
878c2ecf20Sopenharmony_ci	elf_vrreg_t	__user *v_regs;
888c2ecf20Sopenharmony_ci	long		vmx_reserve[ELF_NVRREG + ELF_NVRREG + 1 + 32];
898c2ecf20Sopenharmony_ci#endif
908c2ecf20Sopenharmony_ci};
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_SIGCONTEXT_H */
93