xref: /netbsd/sys/arch/alpha/include/frame.h (revision 395853bc)
1 /* $NetBSD: frame.h,v 1.10 2019/03/25 19:24:30 maxv Exp $ */
2 
3 /*
4  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Chris G. Demetriou
8  *
9  * Permission to use, copy, modify and distribute this software and
10  * its documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  *
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  */
29 
30 #ifndef _ALPHA_FRAME_H_
31 #define	_ALPHA_FRAME_H_
32 
33 #include <machine/alpha_cpu.h>
34 #include <sys/signal.h>
35 
36 /*
37  * Software trap, exception, and syscall frame.
38  *
39  * Includes "hardware" (PALcode) frame.
40  *
41  * PALcode puts ALPHA_HWFRAME_* fields on stack.  We have to add
42  * all of the general-purpose registers except for zero, for sp
43  * (which is automatically saved in the PCB's USP field for entries
44  * from user mode, and which is implicitly saved and restored by the
45  * calling conventions for entries from kernel mode), and (on traps
46  * and exceptions) for a0, a1, and a2 (which are saved by PALcode).
47  */
48 
49 /* Quadword offsets of the registers to be saved. */
50 #define	FRAME_V0	0
51 #define	FRAME_T0	1
52 #define	FRAME_T1	2
53 #define	FRAME_T2	3
54 #define	FRAME_T3	4
55 #define	FRAME_T4	5
56 #define	FRAME_T5	6
57 #define	FRAME_T6	7
58 #define	FRAME_T7	8
59 #define	FRAME_S0	9
60 #define	FRAME_S1	10
61 #define	FRAME_S2	11
62 #define	FRAME_S3	12
63 #define	FRAME_S4	13
64 #define	FRAME_S5	14
65 #define	FRAME_S6	15
66 #define	FRAME_A3	16
67 #define	FRAME_A4	17
68 #define	FRAME_A5	18
69 #define	FRAME_T8	19
70 #define	FRAME_T9	20
71 #define	FRAME_T10	21
72 #define	FRAME_T11	22
73 #define	FRAME_RA	23
74 #define	FRAME_T12	24
75 #define	FRAME_AT	25
76 #define	FRAME_SP	26
77 
78 #define	FRAME_SW_SIZE	(FRAME_SP + 1)
79 #define	FRAME_HW_OFFSET	FRAME_SW_SIZE
80 
81 #define	FRAME_PS	(FRAME_HW_OFFSET + ALPHA_HWFRAME_PS)
82 #define	FRAME_PC	(FRAME_HW_OFFSET + ALPHA_HWFRAME_PC)
83 #define	FRAME_GP	(FRAME_HW_OFFSET + ALPHA_HWFRAME_GP)
84 #define	FRAME_A0	(FRAME_HW_OFFSET + ALPHA_HWFRAME_A0)
85 #define	FRAME_A1	(FRAME_HW_OFFSET + ALPHA_HWFRAME_A1)
86 #define	FRAME_A2	(FRAME_HW_OFFSET + ALPHA_HWFRAME_A2)
87 
88 #define	FRAME_HW_SIZE	ALPHA_HWFRAME_SIZE
89 #define	FRAME_SIZE	(FRAME_HW_OFFSET + FRAME_HW_SIZE)
90 
91 struct trapframe {
92 	unsigned long	tf_regs[FRAME_SIZE];	/* See above */
93 };
94 
95 #if defined(COMPAT_16) && defined(_KERNEL)
96 struct sigframe_sigcontext {
97 	/*  ra address of trampoline */
98 	/*  a0 signum for handler */
99 	/*  a1 code for handler */
100 	/*  a2 struct	sigcontext for handler */
101 	struct sigcontext sf_sc; /* actual saved context */
102 };
103 #endif
104 
105 struct sigframe_siginfo {
106 	/*  ra address of trampoline */
107         /*  a0 signal number arg for handler */
108 	/*  a1 siginfo_t * arg for handler */
109 	/*  a2 ucontext_t * arg for handler */
110 	siginfo_t sf_si; /* actual saved siginfo */
111 	ucontext_t sf_uc; /* actual saved ucontext */
112 };
113 
114 #ifdef _KERNEL
115 void *getframe(const struct lwp *, int, int *);
116 void buildcontext(struct lwp *, const void *, const void *, const void *);
117 void sendsig_siginfo(const ksiginfo_t *, const sigset_t *);
118 #if defined(COMPAT_16)
119 void sendsig_sigcontext(const ksiginfo_t *, const sigset_t *);
120 #endif
121 #endif
122 
123 #endif /* _ALPHA_FRAME_H_ */
124