18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASMARM_UCONTEXT_H
38c2ecf20Sopenharmony_ci#define _ASMARM_UCONTEXT_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <asm/fpstate.h>
68c2ecf20Sopenharmony_ci#include <asm/user.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci/*
98c2ecf20Sopenharmony_ci * struct sigcontext only has room for the basic registers, but struct
108c2ecf20Sopenharmony_ci * ucontext now has room for all registers which need to be saved and
118c2ecf20Sopenharmony_ci * restored.  Coprocessor registers are stored in uc_regspace.  Each
128c2ecf20Sopenharmony_ci * coprocessor's saved state should start with a documented 32-bit magic
138c2ecf20Sopenharmony_ci * number, followed by a 32-bit word giving the coproccesor's saved size.
148c2ecf20Sopenharmony_ci * uc_regspace may be expanded if necessary, although this takes some
158c2ecf20Sopenharmony_ci * coordination with glibc.
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistruct ucontext {
198c2ecf20Sopenharmony_ci	unsigned long	  uc_flags;
208c2ecf20Sopenharmony_ci	struct ucontext  *uc_link;
218c2ecf20Sopenharmony_ci	stack_t		  uc_stack;
228c2ecf20Sopenharmony_ci	struct sigcontext uc_mcontext;
238c2ecf20Sopenharmony_ci	sigset_t	  uc_sigmask;
248c2ecf20Sopenharmony_ci	/* Allow for uc_sigmask growth.  Glibc uses a 1024-bit sigset_t.  */
258c2ecf20Sopenharmony_ci	int		  __unused[32 - (sizeof (sigset_t) / sizeof (int))];
268c2ecf20Sopenharmony_ci	/* Last for extensibility.  Eight byte aligned because some
278c2ecf20Sopenharmony_ci	   coprocessors require eight byte alignment.  */
288c2ecf20Sopenharmony_ci 	unsigned long	  uc_regspace[128] __attribute__((__aligned__(8)));
298c2ecf20Sopenharmony_ci};
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#ifdef __KERNEL__
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/*
348c2ecf20Sopenharmony_ci * Coprocessor save state.  The magic values and specific
358c2ecf20Sopenharmony_ci * coprocessor's layouts are part of the userspace ABI.  Each one of
368c2ecf20Sopenharmony_ci * these should be a multiple of eight bytes and aligned to eight
378c2ecf20Sopenharmony_ci * bytes, to prevent unpredictable padding in the signal frame.
388c2ecf20Sopenharmony_ci */
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/*
418c2ecf20Sopenharmony_ci * Dummy padding block: if this magic is encountered, the block should
428c2ecf20Sopenharmony_ci * be skipped using the corresponding size field.
438c2ecf20Sopenharmony_ci */
448c2ecf20Sopenharmony_ci#define DUMMY_MAGIC		0xb0d9ed01
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#ifdef CONFIG_CRUNCH
478c2ecf20Sopenharmony_ci#define CRUNCH_MAGIC		0x5065cf03
488c2ecf20Sopenharmony_ci#define CRUNCH_STORAGE_SIZE	(CRUNCH_SIZE + 8)
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_cistruct crunch_sigframe {
518c2ecf20Sopenharmony_ci	unsigned long	magic;
528c2ecf20Sopenharmony_ci	unsigned long	size;
538c2ecf20Sopenharmony_ci	struct crunch_state	storage;
548c2ecf20Sopenharmony_ci} __attribute__((__aligned__(8)));
558c2ecf20Sopenharmony_ci#endif
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#ifdef CONFIG_IWMMXT
588c2ecf20Sopenharmony_ci/* iwmmxt_area is 0x98 bytes long, preceded by 8 bytes of signature */
598c2ecf20Sopenharmony_ci#define IWMMXT_MAGIC		0x12ef842a
608c2ecf20Sopenharmony_ci#define IWMMXT_STORAGE_SIZE	(IWMMXT_SIZE + 8)
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistruct iwmmxt_sigframe {
638c2ecf20Sopenharmony_ci	unsigned long	magic;
648c2ecf20Sopenharmony_ci	unsigned long	size;
658c2ecf20Sopenharmony_ci	struct iwmmxt_struct storage;
668c2ecf20Sopenharmony_ci} __attribute__((__aligned__(8)));
678c2ecf20Sopenharmony_ci#endif /* CONFIG_IWMMXT */
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#ifdef CONFIG_VFP
708c2ecf20Sopenharmony_ci#define VFP_MAGIC		0x56465001
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_cistruct vfp_sigframe
738c2ecf20Sopenharmony_ci{
748c2ecf20Sopenharmony_ci	unsigned long		magic;
758c2ecf20Sopenharmony_ci	unsigned long		size;
768c2ecf20Sopenharmony_ci	struct user_vfp		ufp;
778c2ecf20Sopenharmony_ci	struct user_vfp_exc	ufp_exc;
788c2ecf20Sopenharmony_ci} __attribute__((__aligned__(8)));
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci/*
818c2ecf20Sopenharmony_ci *  8 byte for magic and size, 264 byte for ufp, 12 bytes for ufp_exc,
828c2ecf20Sopenharmony_ci *  4 bytes padding.
838c2ecf20Sopenharmony_ci */
848c2ecf20Sopenharmony_ci#define VFP_STORAGE_SIZE	sizeof(struct vfp_sigframe)
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#endif /* CONFIG_VFP */
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci/*
898c2ecf20Sopenharmony_ci * Auxiliary signal frame.  This saves stuff like FP state.
908c2ecf20Sopenharmony_ci * The layout of this structure is not part of the user ABI,
918c2ecf20Sopenharmony_ci * because the config options aren't.  uc_regspace is really
928c2ecf20Sopenharmony_ci * one of these.
938c2ecf20Sopenharmony_ci */
948c2ecf20Sopenharmony_cistruct aux_sigframe {
958c2ecf20Sopenharmony_ci#ifdef CONFIG_CRUNCH
968c2ecf20Sopenharmony_ci	struct crunch_sigframe	crunch;
978c2ecf20Sopenharmony_ci#endif
988c2ecf20Sopenharmony_ci#ifdef CONFIG_IWMMXT
998c2ecf20Sopenharmony_ci	struct iwmmxt_sigframe	iwmmxt;
1008c2ecf20Sopenharmony_ci#endif
1018c2ecf20Sopenharmony_ci#ifdef CONFIG_VFP
1028c2ecf20Sopenharmony_ci	struct vfp_sigframe	vfp;
1038c2ecf20Sopenharmony_ci#endif
1048c2ecf20Sopenharmony_ci	/* Something that isn't a valid magic number for any coprocessor.  */
1058c2ecf20Sopenharmony_ci	unsigned long		end_magic;
1068c2ecf20Sopenharmony_ci} __attribute__((__aligned__(8)));
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci#endif
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#endif /* !_ASMARM_UCONTEXT_H */
111