1*8ede9625SToomas Soome /*- 2*8ede9625SToomas Soome * Copyright (c) 2003 Peter Wemm. 3*8ede9625SToomas Soome * Copyright (c) 1990 The Regents of the University of California. 4*8ede9625SToomas Soome * All rights reserved. 5*8ede9625SToomas Soome * 6*8ede9625SToomas Soome * This code is derived from software contributed to Berkeley by 7*8ede9625SToomas Soome * William Jolitz. 8*8ede9625SToomas Soome * 9*8ede9625SToomas Soome * Redistribution and use in source and binary forms, with or without 10*8ede9625SToomas Soome * modification, are permitted provided that the following conditions 11*8ede9625SToomas Soome * are met: 12*8ede9625SToomas Soome * 1. Redistributions of source code must retain the above copyright 13*8ede9625SToomas Soome * notice, this list of conditions and the following disclaimer. 14*8ede9625SToomas Soome * 2. Redistributions in binary form must reproduce the above copyright 15*8ede9625SToomas Soome * notice, this list of conditions and the following disclaimer in the 16*8ede9625SToomas Soome * documentation and/or other materials provided with the distribution. 17*8ede9625SToomas Soome * 3. Neither the name of the University nor the names of its contributors 18*8ede9625SToomas Soome * may be used to endorse or promote products derived from this software 19*8ede9625SToomas Soome * without specific prior written permission. 20*8ede9625SToomas Soome * 21*8ede9625SToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22*8ede9625SToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23*8ede9625SToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24*8ede9625SToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25*8ede9625SToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26*8ede9625SToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27*8ede9625SToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28*8ede9625SToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29*8ede9625SToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30*8ede9625SToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31*8ede9625SToomas Soome * SUCH DAMAGE. 32*8ede9625SToomas Soome * 33*8ede9625SToomas Soome * from: @(#)frame.h 5.2 (Berkeley) 1/18/91 34*8ede9625SToomas Soome */ 35*8ede9625SToomas Soome 36*8ede9625SToomas Soome #ifndef _MACHINE_FRAME_H_ 37*8ede9625SToomas Soome #define _MACHINE_FRAME_H_ 1 38*8ede9625SToomas Soome 39*8ede9625SToomas Soome /* 40*8ede9625SToomas Soome * System stack frames. 41*8ede9625SToomas Soome */ 42*8ede9625SToomas Soome 43*8ede9625SToomas Soome #ifdef __i386__ 44*8ede9625SToomas Soome /* 45*8ede9625SToomas Soome * Exception/Trap Stack Frame 46*8ede9625SToomas Soome */ 47*8ede9625SToomas Soome 48*8ede9625SToomas Soome struct trapframe { 49*8ede9625SToomas Soome int tf_fs; 50*8ede9625SToomas Soome int tf_es; 51*8ede9625SToomas Soome int tf_ds; 52*8ede9625SToomas Soome int tf_edi; 53*8ede9625SToomas Soome int tf_esi; 54*8ede9625SToomas Soome int tf_ebp; 55*8ede9625SToomas Soome int tf_isp; 56*8ede9625SToomas Soome int tf_ebx; 57*8ede9625SToomas Soome int tf_edx; 58*8ede9625SToomas Soome int tf_ecx; 59*8ede9625SToomas Soome int tf_eax; 60*8ede9625SToomas Soome int tf_trapno; 61*8ede9625SToomas Soome /* below portion defined in 386 hardware */ 62*8ede9625SToomas Soome int tf_err; 63*8ede9625SToomas Soome int tf_eip; 64*8ede9625SToomas Soome int tf_cs; 65*8ede9625SToomas Soome int tf_eflags; 66*8ede9625SToomas Soome /* below only when crossing rings (user to kernel) */ 67*8ede9625SToomas Soome int tf_esp; 68*8ede9625SToomas Soome int tf_ss; 69*8ede9625SToomas Soome }; 70*8ede9625SToomas Soome 71*8ede9625SToomas Soome /* Superset of trap frame, for traps from virtual-8086 mode */ 72*8ede9625SToomas Soome 73*8ede9625SToomas Soome struct trapframe_vm86 { 74*8ede9625SToomas Soome int tf_fs; 75*8ede9625SToomas Soome int tf_es; 76*8ede9625SToomas Soome int tf_ds; 77*8ede9625SToomas Soome int tf_edi; 78*8ede9625SToomas Soome int tf_esi; 79*8ede9625SToomas Soome int tf_ebp; 80*8ede9625SToomas Soome int tf_isp; 81*8ede9625SToomas Soome int tf_ebx; 82*8ede9625SToomas Soome int tf_edx; 83*8ede9625SToomas Soome int tf_ecx; 84*8ede9625SToomas Soome int tf_eax; 85*8ede9625SToomas Soome int tf_trapno; 86*8ede9625SToomas Soome /* below portion defined in 386 hardware */ 87*8ede9625SToomas Soome int tf_err; 88*8ede9625SToomas Soome int tf_eip; 89*8ede9625SToomas Soome int tf_cs; 90*8ede9625SToomas Soome int tf_eflags; 91*8ede9625SToomas Soome /* below only when crossing rings (user (including vm86) to kernel) */ 92*8ede9625SToomas Soome int tf_esp; 93*8ede9625SToomas Soome int tf_ss; 94*8ede9625SToomas Soome /* below only when crossing from vm86 mode to kernel */ 95*8ede9625SToomas Soome int tf_vm86_es; 96*8ede9625SToomas Soome int tf_vm86_ds; 97*8ede9625SToomas Soome int tf_vm86_fs; 98*8ede9625SToomas Soome int tf_vm86_gs; 99*8ede9625SToomas Soome }; 100*8ede9625SToomas Soome 101*8ede9625SToomas Soome /* 102*8ede9625SToomas Soome * This alias for the MI TRAPF_USERMODE() should be used when we don't 103*8ede9625SToomas Soome * care about user mode itself, but need to know if a frame has stack 104*8ede9625SToomas Soome * registers. The difference is only logical, but on i386 the logic 105*8ede9625SToomas Soome * for using TRAPF_USERMODE() is complicated by sometimes treating vm86 106*8ede9625SToomas Soome * bioscall mode (which is a special ring 3 user mode) as kernel mode. 107*8ede9625SToomas Soome */ 108*8ede9625SToomas Soome #define TF_HAS_STACKREGS(tf) TRAPF_USERMODE(tf) 109*8ede9625SToomas Soome #endif /* __i386__ */ 110*8ede9625SToomas Soome 111*8ede9625SToomas Soome #ifdef __amd64__ 112*8ede9625SToomas Soome /* 113*8ede9625SToomas Soome * Exception/Trap Stack Frame 114*8ede9625SToomas Soome * 115*8ede9625SToomas Soome * The ordering of this is specifically so that we can take first 6 116*8ede9625SToomas Soome * the syscall arguments directly from the beginning of the frame. 117*8ede9625SToomas Soome */ 118*8ede9625SToomas Soome 119*8ede9625SToomas Soome struct trapframe { 120*8ede9625SToomas Soome register_t tf_rdi; 121*8ede9625SToomas Soome register_t tf_rsi; 122*8ede9625SToomas Soome register_t tf_rdx; 123*8ede9625SToomas Soome register_t tf_rcx; 124*8ede9625SToomas Soome register_t tf_r8; 125*8ede9625SToomas Soome register_t tf_r9; 126*8ede9625SToomas Soome register_t tf_rax; 127*8ede9625SToomas Soome register_t tf_rbx; 128*8ede9625SToomas Soome register_t tf_rbp; 129*8ede9625SToomas Soome register_t tf_r10; 130*8ede9625SToomas Soome register_t tf_r11; 131*8ede9625SToomas Soome register_t tf_r12; 132*8ede9625SToomas Soome register_t tf_r13; 133*8ede9625SToomas Soome register_t tf_r14; 134*8ede9625SToomas Soome register_t tf_r15; 135*8ede9625SToomas Soome uint32_t tf_trapno; 136*8ede9625SToomas Soome uint16_t tf_fs; 137*8ede9625SToomas Soome uint16_t tf_gs; 138*8ede9625SToomas Soome register_t tf_addr; 139*8ede9625SToomas Soome uint32_t tf_flags; 140*8ede9625SToomas Soome uint16_t tf_es; 141*8ede9625SToomas Soome uint16_t tf_ds; 142*8ede9625SToomas Soome /* below portion defined in hardware */ 143*8ede9625SToomas Soome register_t tf_err; 144*8ede9625SToomas Soome register_t tf_rip; 145*8ede9625SToomas Soome register_t tf_cs; 146*8ede9625SToomas Soome register_t tf_rflags; 147*8ede9625SToomas Soome /* the amd64 frame always has the stack registers */ 148*8ede9625SToomas Soome register_t tf_rsp; 149*8ede9625SToomas Soome register_t tf_ss; 150*8ede9625SToomas Soome }; 151*8ede9625SToomas Soome 152*8ede9625SToomas Soome #define TF_HASSEGS 0x1 153*8ede9625SToomas Soome #define TF_HASBASES 0x2 154*8ede9625SToomas Soome #define TF_HASFPXSTATE 0x4 155*8ede9625SToomas Soome #endif /* __amd64__ */ 156*8ede9625SToomas Soome 157*8ede9625SToomas Soome #endif /* _MACHINE_FRAME_H_ */ 158