xref: /freebsd/sys/riscv/include/stack.h (revision 367de39efa784fad89fe424d073cebdb2a1091c6)
1d52d6d7cSRuslan Bukin /*-
2d52d6d7cSRuslan Bukin  * Copyright (c) 2016 Ruslan Bukin <br@bsdpad.com>
3d52d6d7cSRuslan Bukin  * All rights reserved.
4d52d6d7cSRuslan Bukin  *
5d52d6d7cSRuslan Bukin  * Portions of this software were developed by SRI International and the
6d52d6d7cSRuslan Bukin  * University of Cambridge Computer Laboratory under DARPA/AFRL contract
7d52d6d7cSRuslan Bukin  * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
8d52d6d7cSRuslan Bukin  *
9d52d6d7cSRuslan Bukin  * Portions of this software were developed by the University of Cambridge
10d52d6d7cSRuslan Bukin  * Computer Laboratory as part of the CTSRD Project, with support from the
11d52d6d7cSRuslan Bukin  * UK Higher Education Innovation Fund (HEIF).
12d52d6d7cSRuslan Bukin  *
13d52d6d7cSRuslan Bukin  * Redistribution and use in source and binary forms, with or without
14d52d6d7cSRuslan Bukin  * modification, are permitted provided that the following conditions
15d52d6d7cSRuslan Bukin  * are met:
16d52d6d7cSRuslan Bukin  * 1. Redistributions of source code must retain the above copyright
17d52d6d7cSRuslan Bukin  *    notice, this list of conditions and the following disclaimer.
18d52d6d7cSRuslan Bukin  * 2. Redistributions in binary form must reproduce the above copyright
19d52d6d7cSRuslan Bukin  *    notice, this list of conditions and the following disclaimer in the
20d52d6d7cSRuslan Bukin  *    documentation and/or other materials provided with the distribution.
21d52d6d7cSRuslan Bukin  *
22d52d6d7cSRuslan Bukin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23d52d6d7cSRuslan Bukin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24d52d6d7cSRuslan Bukin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25d52d6d7cSRuslan Bukin  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26d52d6d7cSRuslan Bukin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27d52d6d7cSRuslan Bukin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28d52d6d7cSRuslan Bukin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29d52d6d7cSRuslan Bukin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30d52d6d7cSRuslan Bukin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31d52d6d7cSRuslan Bukin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32d52d6d7cSRuslan Bukin  * SUCH DAMAGE.
33d52d6d7cSRuslan Bukin  *
34d52d6d7cSRuslan Bukin  * $FreeBSD$
35d52d6d7cSRuslan Bukin  */
36d52d6d7cSRuslan Bukin 
37d52d6d7cSRuslan Bukin #ifndef _MACHINE_STACK_H_
38d52d6d7cSRuslan Bukin #define	_MACHINE_STACK_H_
39d52d6d7cSRuslan Bukin 
40d52d6d7cSRuslan Bukin #define	INKERNEL(va)	((va) >= VM_MIN_KERNEL_ADDRESS && \
41d52d6d7cSRuslan Bukin 			 (va) <= VM_MAX_KERNEL_ADDRESS)
42d52d6d7cSRuslan Bukin 
43d52d6d7cSRuslan Bukin struct unwind_state {
44*367de39eSJohn Baldwin 	uintptr_t fp;
45*367de39eSJohn Baldwin 	uintptr_t sp;
46*367de39eSJohn Baldwin 	uintptr_t pc;
47d52d6d7cSRuslan Bukin };
48d52d6d7cSRuslan Bukin 
49d52d6d7cSRuslan Bukin int unwind_frame(struct unwind_state *);
50d52d6d7cSRuslan Bukin 
51d52d6d7cSRuslan Bukin #endif /* !_MACHINE_STACK_H_ */
52