1*3b697b3fSguenther /* $OpenBSD: frame.h,v 1.11 2024/01/31 06:06:28 guenther Exp $ */ 2f5df1827Smickey /* $NetBSD: frame.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */ 3f5df1827Smickey 4f5df1827Smickey /*- 5f5df1827Smickey * Copyright (c) 1998 The NetBSD Foundation, Inc. 6f5df1827Smickey * All rights reserved. 7f5df1827Smickey * 8f5df1827Smickey * This code is derived from software contributed to The NetBSD Foundation 9f5df1827Smickey * by Charles M. Hannum. 10f5df1827Smickey * 11f5df1827Smickey * Redistribution and use in source and binary forms, with or without 12f5df1827Smickey * modification, are permitted provided that the following conditions 13f5df1827Smickey * are met: 14f5df1827Smickey * 1. Redistributions of source code must retain the above copyright 15f5df1827Smickey * notice, this list of conditions and the following disclaimer. 16f5df1827Smickey * 2. Redistributions in binary form must reproduce the above copyright 17f5df1827Smickey * notice, this list of conditions and the following disclaimer in the 18f5df1827Smickey * documentation and/or other materials provided with the distribution. 19f5df1827Smickey * 20f5df1827Smickey * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21f5df1827Smickey * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22f5df1827Smickey * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23f5df1827Smickey * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24f5df1827Smickey * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25f5df1827Smickey * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26f5df1827Smickey * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27f5df1827Smickey * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28f5df1827Smickey * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29f5df1827Smickey * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30f5df1827Smickey * POSSIBILITY OF SUCH DAMAGE. 31f5df1827Smickey */ 32f5df1827Smickey 33f5df1827Smickey /*- 34f5df1827Smickey * Copyright (c) 1990 The Regents of the University of California. 35f5df1827Smickey * All rights reserved. 36f5df1827Smickey * 37f5df1827Smickey * This code is derived from software contributed to Berkeley by 38f5df1827Smickey * William Jolitz. 39f5df1827Smickey * 40f5df1827Smickey * Redistribution and use in source and binary forms, with or without 41f5df1827Smickey * modification, are permitted provided that the following conditions 42f5df1827Smickey * are met: 43f5df1827Smickey * 1. Redistributions of source code must retain the above copyright 44f5df1827Smickey * notice, this list of conditions and the following disclaimer. 45f5df1827Smickey * 2. Redistributions in binary form must reproduce the above copyright 46f5df1827Smickey * notice, this list of conditions and the following disclaimer in the 47f5df1827Smickey * documentation and/or other materials provided with the distribution. 48c5217b0aSjsg * 3. Neither the name of the University nor the names of its contributors 49f5df1827Smickey * may be used to endorse or promote products derived from this software 50f5df1827Smickey * without specific prior written permission. 51f5df1827Smickey * 52f5df1827Smickey * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 53f5df1827Smickey * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 54f5df1827Smickey * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 55f5df1827Smickey * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 56f5df1827Smickey * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 57f5df1827Smickey * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 58f5df1827Smickey * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 59f5df1827Smickey * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 60f5df1827Smickey * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61f5df1827Smickey * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62f5df1827Smickey * SUCH DAMAGE. 63f5df1827Smickey * 64f5df1827Smickey * @(#)frame.h 5.2 (Berkeley) 1/18/91 65f5df1827Smickey */ 66f5df1827Smickey 67f5df1827Smickey /* 68f5df1827Smickey * Adapted for NetBSD/amd64 by fvdl@wasabisystems.com 69f5df1827Smickey */ 70f5df1827Smickey 712fa72412Spirofti #ifndef _MACHINE_FRAME_H_ 722fa72412Spirofti #define _MACHINE_FRAME_H_ 73f5df1827Smickey 74f5df1827Smickey #include <sys/signal.h> 75f5df1827Smickey #include <machine/fpu.h> 76f5df1827Smickey 77f5df1827Smickey /* 78f5df1827Smickey * System stack frames. 79f5df1827Smickey */ 80f5df1827Smickey 81f5df1827Smickey /* 82f5df1827Smickey * Exception/Trap Stack Frame 83f5df1827Smickey */ 84f5df1827Smickey struct trapframe { 85*3b697b3fSguenther int64_t tf_rdi; /* ordered by syscall args... */ 86f5df1827Smickey int64_t tf_rsi; 87f5df1827Smickey int64_t tf_rdx; 88f5df1827Smickey int64_t tf_r10; 89*3b697b3fSguenther int64_t tf_r8; 90*3b697b3fSguenther int64_t tf_r9; /* ...to here */ 91*3b697b3fSguenther int64_t tf_rcx; 92f5df1827Smickey int64_t tf_r11; 93f5df1827Smickey int64_t tf_r12; 94f5df1827Smickey int64_t tf_r13; 95f5df1827Smickey int64_t tf_r14; 96f5df1827Smickey int64_t tf_r15; 97fbad0e3eSguenther int64_t tf_err; /* not the hardware position */ 98f5df1827Smickey int64_t tf_rbx; 99f5df1827Smickey int64_t tf_rax; 100f5df1827Smickey int64_t tf_trapno; 101fbad0e3eSguenther int64_t tf_rbp; /* hardware puts err here, INTRENTRY() moves it up */ 102f5df1827Smickey /* below portion defined in hardware */ 103f5df1827Smickey int64_t tf_rip; 104f5df1827Smickey int64_t tf_cs; 105f5df1827Smickey int64_t tf_rflags; 106f5df1827Smickey /* These are pushed unconditionally on the x86-64 */ 107f5df1827Smickey int64_t tf_rsp; 108f5df1827Smickey int64_t tf_ss; 109f5df1827Smickey }; 110f5df1827Smickey 111f5df1827Smickey /* 112f5df1827Smickey * Interrupt stack frame 113f5df1827Smickey */ 114f5df1827Smickey struct intrframe { 115f5df1827Smickey int64_t if_rdi; 116f5df1827Smickey int64_t if_rsi; 117f5df1827Smickey int64_t if_rdx; 118*3b697b3fSguenther int64_t if_r10; 119f5df1827Smickey int64_t if_r8; 120f5df1827Smickey int64_t if_r9; 121*3b697b3fSguenther int64_t if_rcx; 122f5df1827Smickey int64_t if_r11; 123f5df1827Smickey int64_t if_r12; 124f5df1827Smickey int64_t if_r13; 125f5df1827Smickey int64_t if_r14; 126f5df1827Smickey int64_t if_r15; 1277effbc1fSguenther int64_t if_err; /* IREENT_MAGIC if resume/recurse */ 128f5df1827Smickey int64_t if_rbx; 129f5df1827Smickey int64_t if_rax; 1307effbc1fSguenther int64_t if_ppl; /* previous priority level */ 131fbad0e3eSguenther int64_t if_rbp; 132f5df1827Smickey /* below portion defined in hardware */ 133f5df1827Smickey int64_t if_rip; 134f5df1827Smickey int64_t if_cs; 135f5df1827Smickey int64_t if_rflags; 136f5df1827Smickey /* These are pushed unconditionally on the x86-64 */ 137f5df1827Smickey int64_t if_rsp; 138f5df1827Smickey int64_t if_ss; 139f5df1827Smickey }; 140f5df1827Smickey 141b767b017Sguenther 142b767b017Sguenther /* 143b767b017Sguenther * The trampoline frame used on the kernel stack page which is present 144b767b017Sguenther * but kernel-only, in the page tables used when in userspace. This is 145b767b017Sguenther * the minimum for iretq operation. 146b767b017Sguenther */ 147b767b017Sguenther struct iretq_frame { 148b767b017Sguenther int64_t iretq_rip; 149b767b017Sguenther int64_t iretq_cs; 150b767b017Sguenther int64_t iretq_rflags; 151b767b017Sguenther int64_t iretq_rsp; 152b767b017Sguenther int64_t iretq_ss; 153b767b017Sguenther }; 154b767b017Sguenther 155f5df1827Smickey /* 156f5df1827Smickey * Stack frame inside cpu_switch() 157f5df1827Smickey */ 158f5df1827Smickey struct switchframe { 159f5df1827Smickey int64_t sf_r15; 160f5df1827Smickey int64_t sf_r14; 161f5df1827Smickey int64_t sf_r13; 162f5df1827Smickey int64_t sf_r12; 163f5df1827Smickey int64_t sf_rbp; 164f5df1827Smickey int64_t sf_rbx; 165f5df1827Smickey int64_t sf_rip; 166f5df1827Smickey }; 167f5df1827Smickey 16876c36b79Smpi struct callframe { 16976c36b79Smpi struct callframe *f_frame; 17076c36b79Smpi long f_retaddr; 17176c36b79Smpi long f_arg0; 17276c36b79Smpi }; 17376c36b79Smpi 1742fa72412Spirofti #endif /* _MACHINE_FRAME_H_ */ 175