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