1*1e3d30b0Scherry /* $NetBSD: frame.h,v 1.22 2019/02/14 08:18:25 cherry Exp $ */ 281918bf8Sfvdl 381918bf8Sfvdl /*- 481918bf8Sfvdl * Copyright (c) 1998 The NetBSD Foundation, Inc. 581918bf8Sfvdl * All rights reserved. 681918bf8Sfvdl * 781918bf8Sfvdl * This code is derived from software contributed to The NetBSD Foundation 881918bf8Sfvdl * by Charles M. Hannum. 981918bf8Sfvdl * 1081918bf8Sfvdl * Redistribution and use in source and binary forms, with or without 1181918bf8Sfvdl * modification, are permitted provided that the following conditions 1281918bf8Sfvdl * are met: 1381918bf8Sfvdl * 1. Redistributions of source code must retain the above copyright 1481918bf8Sfvdl * notice, this list of conditions and the following disclaimer. 1581918bf8Sfvdl * 2. Redistributions in binary form must reproduce the above copyright 1681918bf8Sfvdl * notice, this list of conditions and the following disclaimer in the 1781918bf8Sfvdl * documentation and/or other materials provided with the distribution. 1881918bf8Sfvdl * 1981918bf8Sfvdl * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2081918bf8Sfvdl * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2181918bf8Sfvdl * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2281918bf8Sfvdl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2381918bf8Sfvdl * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2481918bf8Sfvdl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2581918bf8Sfvdl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2681918bf8Sfvdl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2781918bf8Sfvdl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2881918bf8Sfvdl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2981918bf8Sfvdl * POSSIBILITY OF SUCH DAMAGE. 3081918bf8Sfvdl */ 3181918bf8Sfvdl 3281918bf8Sfvdl /*- 3381918bf8Sfvdl * Copyright (c) 1990 The Regents of the University of California. 3481918bf8Sfvdl * All rights reserved. 3581918bf8Sfvdl * 3681918bf8Sfvdl * This code is derived from software contributed to Berkeley by 3781918bf8Sfvdl * William Jolitz. 3881918bf8Sfvdl * 3981918bf8Sfvdl * Redistribution and use in source and binary forms, with or without 4081918bf8Sfvdl * modification, are permitted provided that the following conditions 4181918bf8Sfvdl * are met: 4281918bf8Sfvdl * 1. Redistributions of source code must retain the above copyright 4381918bf8Sfvdl * notice, this list of conditions and the following disclaimer. 4481918bf8Sfvdl * 2. Redistributions in binary form must reproduce the above copyright 4581918bf8Sfvdl * notice, this list of conditions and the following disclaimer in the 4681918bf8Sfvdl * documentation and/or other materials provided with the distribution. 47aad01611Sagc * 3. Neither the name of the University nor the names of its contributors 4881918bf8Sfvdl * may be used to endorse or promote products derived from this software 4981918bf8Sfvdl * without specific prior written permission. 5081918bf8Sfvdl * 5181918bf8Sfvdl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 5281918bf8Sfvdl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 5381918bf8Sfvdl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 5481918bf8Sfvdl * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 5581918bf8Sfvdl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 5681918bf8Sfvdl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 5781918bf8Sfvdl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 5881918bf8Sfvdl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 5981918bf8Sfvdl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 6081918bf8Sfvdl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 6181918bf8Sfvdl * SUCH DAMAGE. 6281918bf8Sfvdl * 6381918bf8Sfvdl * @(#)frame.h 5.2 (Berkeley) 1/18/91 6481918bf8Sfvdl */ 6581918bf8Sfvdl 6681918bf8Sfvdl /* 6781918bf8Sfvdl * Adapted for NetBSD/amd64 by fvdl@wasabisystems.com 6881918bf8Sfvdl */ 6981918bf8Sfvdl 7081918bf8Sfvdl #ifndef _AMD64_FRAME_H_ 7181918bf8Sfvdl #define _AMD64_FRAME_H_ 7281918bf8Sfvdl 73433b5ddeSmrg #ifdef __x86_64__ 74433b5ddeSmrg 7581918bf8Sfvdl #include <sys/signal.h> 76ebf02f52Sdsl #include <sys/ucontext.h> 77abceae99Sdsl #include <machine/frame_regs.h> 7881918bf8Sfvdl 7981918bf8Sfvdl /* 8081918bf8Sfvdl * System stack frames. 8181918bf8Sfvdl */ 8281918bf8Sfvdl 8381918bf8Sfvdl /* 8481918bf8Sfvdl * Exception/Trap Stack Frame 8581918bf8Sfvdl */ 86abceae99Sdsl #define tf(reg, REG, idx) uint64_t tf_##reg; 8781918bf8Sfvdl struct trapframe { 88abceae99Sdsl _FRAME_REG(tf, tf) 8981918bf8Sfvdl }; 90abceae99Sdsl #undef tf 9181918bf8Sfvdl 9281918bf8Sfvdl /* 9381918bf8Sfvdl * Interrupt stack frame 9481918bf8Sfvdl */ 9581918bf8Sfvdl struct intrframe { 96a1e817b5Sdsl uint64_t if_ppl; /* Old interrupt mask level */ 97a1e817b5Sdsl struct trapframe if_tf; 9881918bf8Sfvdl }; 9981918bf8Sfvdl 100*1e3d30b0Scherry #ifdef XEN 101cce7c65fSkre /* 102cce7c65fSkre * Need arch independany way to access IP and CS from intrframe 103cce7c65fSkre */ 104b1b9949aSkre #define _INTRFRAME_CS if_tf.tf_cs 105b1b9949aSkre #define _INTRFRAME_IP if_tf.tf_rip 106cce7c65fSkre #endif 107cce7c65fSkre 10881918bf8Sfvdl /* 109c7c42ec9Sskrll * Stack frame inside cpu_switchto() 11081918bf8Sfvdl */ 11181918bf8Sfvdl struct switchframe { 1124505ad31Sfvdl uint64_t sf_r15; 1134505ad31Sfvdl uint64_t sf_r14; 1144505ad31Sfvdl uint64_t sf_r13; 1154505ad31Sfvdl uint64_t sf_r12; 1164505ad31Sfvdl uint64_t sf_rbx; 1174505ad31Sfvdl uint64_t sf_rip; 11881918bf8Sfvdl }; 11981918bf8Sfvdl 12081918bf8Sfvdl /* 12181918bf8Sfvdl * Signal frame 12281918bf8Sfvdl */ 123b894e42aSfvdl struct sigframe_siginfo { 124b894e42aSfvdl uint64_t sf_ra; /* return address for handler */ 125b894e42aSfvdl siginfo_t sf_si; /* actual saved siginfo */ 126b894e42aSfvdl ucontext_t sf_uc; /* actual saved ucontext */ 127b894e42aSfvdl }; 128b894e42aSfvdl 129b894e42aSfvdl #ifdef _KERNEL 130ebf02f52Sdsl struct lwp; 131b894e42aSfvdl void buildcontext(struct lwp *, void *, void *); 1320944f2f4Schs #define lwp_trapframe(l) ((l)->l_md.md_regs) 133b894e42aSfvdl #endif 134b894e42aSfvdl 135433b5ddeSmrg #else /* __x86_64__ */ 136433b5ddeSmrg 137433b5ddeSmrg #include <i386/frame.h> 138433b5ddeSmrg 139433b5ddeSmrg #endif /* __x86_64__ */ 140433b5ddeSmrg 14181918bf8Sfvdl #endif /* _AMD64_FRAME_H_ */ 142