xref: /openbsd-src/sys/arch/riscv64/include/frame.h (revision f1dd7b858388b4a23f4f67a4957ec5ff656ebbe8)
1 /*	$OpenBSD: frame.h,v 1.2 2021/05/12 01:20:52 jsg 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 } trapframe_t;
68 
69 /*
70  * pushed on stack for signal delivery
71  */
72 struct sigframe {
73 	int sf_signum;
74 	struct sigcontext sf_sc;
75 	siginfo_t sf_si;
76 };
77 
78 /*
79  * System stack frames.
80  */
81 
82 /*
83  * Stack frame inside cpu_switch()
84  */
85 struct switchframe {
86 	register_t sf_s[12];
87 	register_t sf_ra;
88 };
89 
90 struct callframe {
91 	struct callframe *f_frame;
92 	register_t f_ra;
93 };
94 
95 #endif /* !_LOCORE */
96 
97 #endif /* !_MACHINE_FRAME_H_ */
98