xref: /netbsd-src/sys/arch/aarch64/include/netbsd32_machdep.h (revision c9e3efd544e82db1c618e7f5895c912d0b319041)
1 /*	$NetBSD: netbsd32_machdep.h,v 1.4 2020/07/02 13:04:47 rin Exp $	*/
2 
3 #ifndef _MACHINE_NETBSD32_H_
4 #define _MACHINE_NETBSD32_H_
5 
6 #include <sys/ucontext.h>
7 #include <compat/sys/ucontext.h>
8 #include <compat/sys/siginfo.h>
9 
10 /*
11  * arm ptrace constants
12  * Please keep in sync with sys/arch/arm/include/ptrace.h.
13  */
14 #define PT32_STEP	(PT_FIRSTMACH + 0) /* Not implemented */
15 #define PT32_GETREGS	(PT_FIRSTMACH + 1)
16 #define PT32_SETREGS	(PT_FIRSTMACH + 2)
17 #define PT32_GETFPREGS	(PT_FIRSTMACH + 5)
18 #define PT32_SETFPREGS	(PT_FIRSTMACH + 6)
19 #define PT32_SETSTEP	(PT_FIRSTMACH + 7) /* Not implemented */
20 #define PT32_CLEARSTEP	(PT_FIRSTMACH + 8) /* Not implemented */
21 
22 #define NETBSD32_POINTER_TYPE uint32_t
23 typedef	struct { NETBSD32_POINTER_TYPE i32; } netbsd32_pointer_t;
24 
25 /* earm has 64bit aligned 64bit integers */
26 #define NETBSD32_INT64_ALIGN __attribute__((__aligned__(8)))
27 
28 typedef netbsd32_pointer_t netbsd32_sigcontextp_t;
29 
30 struct netbsd32_sigcontext13 {
31 	int32_t		sc_onstack;		/* sigstack state to restore */
32 	int32_t		__sc_mask13;		/* signal mask to restore (old style) */
33 
34 	uint32_t	sc_spsr;
35 	uint32_t	sc_r0;
36 	uint32_t	sc_r1;
37 	uint32_t	sc_r2;
38 	uint32_t	sc_r3;
39 	uint32_t	sc_r4;
40 	uint32_t	sc_r5;
41 	uint32_t	sc_r6;
42 	uint32_t	sc_r7;
43 	uint32_t	sc_r8;
44 	uint32_t	sc_r9;
45 	uint32_t	sc_r10;
46 	uint32_t	sc_r11;
47 	uint32_t	sc_r12;
48 	uint32_t	sc_usr_sp;
49 	uint32_t	sc_usr_lr;
50 	uint32_t	sc_svc_lr;
51 	uint32_t	sc_pc;
52 };
53 
54 struct netbsd32_sigcontext {
55 	int32_t		sc_onstack;		/* sigstack state to restore */
56 	int32_t		__sc_mask13;		/* signal mask to restore (old style) */
57 
58 	uint32_t	sc_spsr;
59 	uint32_t	sc_r0;
60 	uint32_t	sc_r1;
61 	uint32_t	sc_r2;
62 	uint32_t	sc_r3;
63 	uint32_t	sc_r4;
64 	uint32_t	sc_r5;
65 	uint32_t	sc_r6;
66 	uint32_t	sc_r7;
67 	uint32_t	sc_r8;
68 	uint32_t	sc_r9;
69 	uint32_t	sc_r10;
70 	uint32_t	sc_r11;
71 	uint32_t	sc_r12;
72 	uint32_t	sc_usr_sp;
73 	uint32_t	sc_usr_lr;
74 	uint32_t	sc_svc_lr;
75 	uint32_t	sc_pc;
76 
77 	sigset_t	sc_mask;		/* signal mask to restore (new style) */
78 };
79 
80 struct netbsd32_sigframe_siginfo {
81 	siginfo32_t sf_si;
82 	ucontext32_t sf_uc;
83 };
84 
85 struct reg32 {
86 	uint32_t r[13];
87 	uint32_t r_sp;
88 	uint32_t r_lr;
89 	uint32_t r_pc;
90 	uint32_t r_cpsr;
91 };
92 
93 struct vfpreg32 {
94 	uint32_t vfp_fpexc;
95 	uint32_t vfp_fpscr;
96 	uint32_t vfp_fpinst;
97 	uint32_t vfp_fpinst2;
98 	uint64_t vfp_regs[33];	/* In case we need fstmx format. */
99 };
100 
101 struct fpreg32 {
102 	struct vfpreg32 fpr_vfp;
103 };
104 
105 /* same as cpustate in arm/arm/core_machdep.c  */
106 struct netbsd32_cpustate {
107 	struct reg32 regs;
108 	struct fpreg32 fpregs;
109 };
110 
111 /* compat netbsd/arm sysarch(2) */
112 #define ARM_SYNC_ICACHE		0
113 #define ARM_DRAIN_WRITEBUF	1
114 #define ARM_VFP_FPSCR		2
115 #define ARM_FPU_USED		3
116 
117 struct netbsd32_arm_sync_icache_args {
118 	uint32_t addr;		/* Virtual start address */
119 	uint32_t len;		/* Region size */
120 };
121 
122 /* Support varying ABI names for netbsd32 */
123 #define PROC_MACHINE_ARCH32(P)	((P)->p_md.md_march32)
124 
125 /* Translate ptrace() PT_* request from 32-bit userland to kernel. */
126 int netbsd32_ptrace_translate_request(int);
127 
128 int netbsd32_process_read_regs(struct lwp *, struct reg32 *);
129 int netbsd32_process_read_fpregs(struct lwp *, struct fpreg32 *, size_t *);
130 
131 int netbsd32_process_write_regs(struct lwp *, const struct reg32 *);
132 int netbsd32_process_write_fpregs(struct lwp *, const struct fpreg32 *, size_t);
133 
134 #endif /* _MACHINE_NETBSD32_H_ */
135