xref: /openbsd/sys/arch/riscv64/include/frame.h (revision 431a07c7)
1 /*	$OpenBSD: frame.h,v 1.3 2022/02/24 14:19:10 visa Exp $	*/
2 
3 /*
4  * Copyright (c) 2019 Brian Bamsch <bbamsch@google.com>
5  * Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
6  * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
7  * All rights reserved.
8  *
9  * Portions of this software were developed by SRI International and the
10  * University of Cambridge Computer Laboratory under DARPA/AFRL contract
11  * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
12  *
13  * Portions of this software were developed by the University of Cambridge
14  * Computer Laboratory as part of the CTSRD Project, with support from the
15  * UK Higher Education Innovation Fund (HEIF).
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  * 1. Redistributions of source code must retain the above copyright
21  *    notice, this list of conditions and the following disclaimer.
22  * 2. Redistributions in binary form must reproduce the above copyright
23  *    notice, this list of conditions and the following disclaimer in the
24  *    documentation and/or other materials provided with the distribution.
25  * 3. Neither the name of the copyright holder nor the names of its
26  *    contributors may be used to endorse or promote products derived from
27  *    this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
30  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
33  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39  * SUCH DAMAGE.
40  */
41 
42 #ifndef _MACHINE_FRAME_H_
43 #define _MACHINE_FRAME_H_
44 
45 #ifndef _LOCORE
46 
47 #include <sys/signal.h>
48 
49 /*
50  * Exception/Trap Stack Frame
51  */
52 #define clockframe trapframe
53 typedef struct trapframe {
54 	/* Standard Registers */
55 	register_t tf_ra;
56 	register_t tf_sp;
57 	register_t tf_gp;
58 	register_t tf_tp;
59 	register_t tf_t[7];
60 	register_t tf_s[12];
61 	register_t tf_a[8];
62 	/* Supervisor Trap CSRs */
63 	register_t tf_sepc;
64 	register_t tf_sstatus;
65 	register_t tf_stval;
66 	register_t tf_scause;
67 	register_t tf_pad;
68 } trapframe_t;
69 
70 /*
71  * pushed on stack for signal delivery
72  */
73 struct sigframe {
74 	int sf_signum;
75 	struct sigcontext sf_sc;
76 	siginfo_t sf_si;
77 };
78 
79 /*
80  * System stack frames.
81  */
82 
83 /*
84  * Stack frame inside cpu_switch()
85  */
86 struct switchframe {
87 	register_t sf_s[12];
88 	register_t sf_ra;
89 	register_t sf_pad;
90 };
91 
92 struct callframe {
93 	struct callframe *f_frame;
94 	register_t f_ra;
95 };
96 
97 #endif /* !_LOCORE */
98 
99 #endif /* !_MACHINE_FRAME_H_ */
100