xref: /illumos-gate/usr/src/boot/sys/x86/include/frame.h (revision 5642709d)
19c8f3233SToomas Soome /*-
29c8f3233SToomas Soome  * Copyright (c) 2003 Peter Wemm.
39c8f3233SToomas Soome  * Copyright (c) 1990 The Regents of the University of California.
49c8f3233SToomas Soome  * All rights reserved.
59c8f3233SToomas Soome  *
69c8f3233SToomas Soome  * This code is derived from software contributed to Berkeley by
79c8f3233SToomas Soome  * William Jolitz.
89c8f3233SToomas Soome  *
99c8f3233SToomas Soome  * Redistribution and use in source and binary forms, with or without
109c8f3233SToomas Soome  * modification, are permitted provided that the following conditions
119c8f3233SToomas Soome  * are met:
129c8f3233SToomas Soome  * 1. Redistributions of source code must retain the above copyright
139c8f3233SToomas Soome  *    notice, this list of conditions and the following disclaimer.
149c8f3233SToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
159c8f3233SToomas Soome  *    notice, this list of conditions and the following disclaimer in the
169c8f3233SToomas Soome  *    documentation and/or other materials provided with the distribution.
179c8f3233SToomas Soome  * 3. Neither the name of the University nor the names of its contributors
189c8f3233SToomas Soome  *    may be used to endorse or promote products derived from this software
199c8f3233SToomas Soome  *    without specific prior written permission.
209c8f3233SToomas Soome  *
219c8f3233SToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
229c8f3233SToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
239c8f3233SToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
249c8f3233SToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
259c8f3233SToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
269c8f3233SToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
279c8f3233SToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
289c8f3233SToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
299c8f3233SToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
309c8f3233SToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
319c8f3233SToomas Soome  * SUCH DAMAGE.
329c8f3233SToomas Soome  *
339c8f3233SToomas Soome  *	from: @(#)frame.h	5.2 (Berkeley) 1/18/91
349c8f3233SToomas Soome  */
359c8f3233SToomas Soome 
369c8f3233SToomas Soome #ifndef _MACHINE_FRAME_H_
379c8f3233SToomas Soome #define _MACHINE_FRAME_H_ 1
389c8f3233SToomas Soome 
399c8f3233SToomas Soome /*
409c8f3233SToomas Soome  * System stack frames.
419c8f3233SToomas Soome  */
429c8f3233SToomas Soome 
43*5642709dSToomas Soome #if defined(__i386__) && !defined(__amd64__)
449c8f3233SToomas Soome /*
459c8f3233SToomas Soome  * Exception/Trap Stack Frame
469c8f3233SToomas Soome  */
479c8f3233SToomas Soome 
489c8f3233SToomas Soome struct trapframe {
499c8f3233SToomas Soome 	int	tf_fs;
509c8f3233SToomas Soome 	int	tf_es;
519c8f3233SToomas Soome 	int	tf_ds;
529c8f3233SToomas Soome 	int	tf_edi;
539c8f3233SToomas Soome 	int	tf_esi;
549c8f3233SToomas Soome 	int	tf_ebp;
559c8f3233SToomas Soome 	int	tf_isp;
569c8f3233SToomas Soome 	int	tf_ebx;
579c8f3233SToomas Soome 	int	tf_edx;
589c8f3233SToomas Soome 	int	tf_ecx;
599c8f3233SToomas Soome 	int	tf_eax;
609c8f3233SToomas Soome 	int	tf_trapno;
619c8f3233SToomas Soome 	/* below portion defined in 386 hardware */
629c8f3233SToomas Soome 	int	tf_err;
639c8f3233SToomas Soome 	int	tf_eip;
649c8f3233SToomas Soome 	int	tf_cs;
659c8f3233SToomas Soome 	int	tf_eflags;
669c8f3233SToomas Soome 	/* below only when crossing rings (user to kernel) */
679c8f3233SToomas Soome 	int	tf_esp;
689c8f3233SToomas Soome 	int	tf_ss;
699c8f3233SToomas Soome };
709c8f3233SToomas Soome 
719c8f3233SToomas Soome /* Superset of trap frame, for traps from virtual-8086 mode */
729c8f3233SToomas Soome 
739c8f3233SToomas Soome struct trapframe_vm86 {
749c8f3233SToomas Soome 	int	tf_fs;
759c8f3233SToomas Soome 	int	tf_es;
769c8f3233SToomas Soome 	int	tf_ds;
779c8f3233SToomas Soome 	int	tf_edi;
789c8f3233SToomas Soome 	int	tf_esi;
799c8f3233SToomas Soome 	int	tf_ebp;
809c8f3233SToomas Soome 	int	tf_isp;
819c8f3233SToomas Soome 	int	tf_ebx;
829c8f3233SToomas Soome 	int	tf_edx;
839c8f3233SToomas Soome 	int	tf_ecx;
849c8f3233SToomas Soome 	int	tf_eax;
859c8f3233SToomas Soome 	int	tf_trapno;
869c8f3233SToomas Soome 	/* below portion defined in 386 hardware */
879c8f3233SToomas Soome 	int	tf_err;
889c8f3233SToomas Soome 	int	tf_eip;
899c8f3233SToomas Soome 	int	tf_cs;
909c8f3233SToomas Soome 	int	tf_eflags;
919c8f3233SToomas Soome 	/* below only when crossing rings (user (including vm86) to kernel) */
929c8f3233SToomas Soome 	int	tf_esp;
939c8f3233SToomas Soome 	int	tf_ss;
949c8f3233SToomas Soome 	/* below only when crossing from vm86 mode to kernel */
959c8f3233SToomas Soome 	int	tf_vm86_es;
969c8f3233SToomas Soome 	int	tf_vm86_ds;
979c8f3233SToomas Soome 	int	tf_vm86_fs;
989c8f3233SToomas Soome 	int	tf_vm86_gs;
999c8f3233SToomas Soome };
1009c8f3233SToomas Soome 
1019c8f3233SToomas Soome /*
1029c8f3233SToomas Soome  * This alias for the MI TRAPF_USERMODE() should be used when we don't
1039c8f3233SToomas Soome  * care about user mode itself, but need to know if a frame has stack
1049c8f3233SToomas Soome  * registers.  The difference is only logical, but on i386 the logic
1059c8f3233SToomas Soome  * for using TRAPF_USERMODE() is complicated by sometimes treating vm86
1069c8f3233SToomas Soome  * bioscall mode (which is a special ring 3 user mode) as kernel mode.
1079c8f3233SToomas Soome  */
1089c8f3233SToomas Soome #define	TF_HAS_STACKREGS(tf)	TRAPF_USERMODE(tf)
1099c8f3233SToomas Soome #endif /* __i386__ */
1109c8f3233SToomas Soome 
1119c8f3233SToomas Soome #ifdef __amd64__
1129c8f3233SToomas Soome /*
1139c8f3233SToomas Soome  * Exception/Trap Stack Frame
1149c8f3233SToomas Soome  *
1159c8f3233SToomas Soome  * The ordering of this is specifically so that we can take first 6
1169c8f3233SToomas Soome  * the syscall arguments directly from the beginning of the frame.
1179c8f3233SToomas Soome  */
1189c8f3233SToomas Soome 
1199c8f3233SToomas Soome struct trapframe {
1209c8f3233SToomas Soome 	register_t	tf_rdi;
1219c8f3233SToomas Soome 	register_t	tf_rsi;
1229c8f3233SToomas Soome 	register_t	tf_rdx;
1239c8f3233SToomas Soome 	register_t	tf_rcx;
1249c8f3233SToomas Soome 	register_t	tf_r8;
1259c8f3233SToomas Soome 	register_t	tf_r9;
1269c8f3233SToomas Soome 	register_t	tf_rax;
1279c8f3233SToomas Soome 	register_t	tf_rbx;
1289c8f3233SToomas Soome 	register_t	tf_rbp;
1299c8f3233SToomas Soome 	register_t	tf_r10;
1309c8f3233SToomas Soome 	register_t	tf_r11;
1319c8f3233SToomas Soome 	register_t	tf_r12;
1329c8f3233SToomas Soome 	register_t	tf_r13;
1339c8f3233SToomas Soome 	register_t	tf_r14;
1349c8f3233SToomas Soome 	register_t	tf_r15;
1359c8f3233SToomas Soome 	uint32_t	tf_trapno;
1369c8f3233SToomas Soome 	uint16_t	tf_fs;
1379c8f3233SToomas Soome 	uint16_t	tf_gs;
1389c8f3233SToomas Soome 	register_t	tf_addr;
1399c8f3233SToomas Soome 	uint32_t	tf_flags;
1409c8f3233SToomas Soome 	uint16_t	tf_es;
1419c8f3233SToomas Soome 	uint16_t	tf_ds;
1429c8f3233SToomas Soome 	/* below portion defined in hardware */
1439c8f3233SToomas Soome 	register_t	tf_err;
1449c8f3233SToomas Soome 	register_t	tf_rip;
1459c8f3233SToomas Soome 	register_t	tf_cs;
1469c8f3233SToomas Soome 	register_t	tf_rflags;
1479c8f3233SToomas Soome 	/* the amd64 frame always has the stack registers */
1489c8f3233SToomas Soome 	register_t	tf_rsp;
1499c8f3233SToomas Soome 	register_t	tf_ss;
1509c8f3233SToomas Soome };
1519c8f3233SToomas Soome 
1529c8f3233SToomas Soome #define	TF_HASSEGS	0x1
1539c8f3233SToomas Soome #define	TF_HASBASES	0x2
1549c8f3233SToomas Soome #define	TF_HASFPXSTATE	0x4
1559c8f3233SToomas Soome #endif /* __amd64__ */
1569c8f3233SToomas Soome 
1579c8f3233SToomas Soome #endif /* _MACHINE_FRAME_H_ */
158