xref: /openbmc/qemu/bsd-user/i386/target_syscall.h (revision a10b9d93)
1 /*
2  *  i386 system call definitions
3  *
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
17  */
18 #ifndef TARGET_SYSCALL_H
19 #define TARGET_SYSCALL_H
20 
21 /* default linux values for the selectors */
22 #define __USER_CS	(0x23)
23 #define __USER_DS	(0x2B)
24 
25 struct target_pt_regs {
26 	long ebx;
27 	long ecx;
28 	long edx;
29 	long esi;
30 	long edi;
31 	long ebp;
32 	long eax;
33 	int  xds;
34 	int  xes;
35 	long orig_eax;
36 	long eip;
37 	int  xcs;
38 	long eflags;
39 	long esp;
40 	int  xss;
41 };
42 
43 /* ioctls */
44 
45 #define TARGET_LDT_ENTRIES      8192
46 #define TARGET_LDT_ENTRY_SIZE	8
47 
48 #define TARGET_GDT_ENTRIES             9
49 #define TARGET_GDT_ENTRY_TLS_ENTRIES   3
50 #define TARGET_GDT_ENTRY_TLS_MIN       6
51 #define TARGET_GDT_ENTRY_TLS_MAX       (TARGET_GDT_ENTRY_TLS_MIN + TARGET_GDT_ENTRY_TLS_ENTRIES - 1)
52 
53 struct target_modify_ldt_ldt_s {
54     unsigned int  entry_number;
55     abi_ulong base_addr;
56     unsigned int limit;
57     unsigned int flags;
58 };
59 
60 /* vm86 defines */
61 
62 #define TARGET_BIOSSEG		0x0f000
63 
64 #define TARGET_CPU_086		0
65 #define TARGET_CPU_186		1
66 #define TARGET_CPU_286		2
67 #define TARGET_CPU_386		3
68 #define TARGET_CPU_486		4
69 #define TARGET_CPU_586		5
70 
71 #define TARGET_VM86_SIGNAL	0	/* return due to signal */
72 #define TARGET_VM86_UNKNOWN	1	/* unhandled GP fault - IO-instruction or similar */
73 #define TARGET_VM86_INTx	2	/* int3/int x instruction (ARG = x) */
74 #define TARGET_VM86_STI	3	/* sti/popf/iret instruction enabled virtual interrupts */
75 
76 /*
77  * Additional return values when invoking new vm86()
78  */
79 #define TARGET_VM86_PICRETURN	4	/* return due to pending PIC request */
80 #define TARGET_VM86_TRAP	6	/* return due to DOS-debugger request */
81 
82 /*
83  * function codes when invoking new vm86()
84  */
85 #define TARGET_VM86_PLUS_INSTALL_CHECK	0
86 #define TARGET_VM86_ENTER		1
87 #define TARGET_VM86_ENTER_NO_BYPASS	2
88 #define	TARGET_VM86_REQUEST_IRQ	3
89 #define TARGET_VM86_FREE_IRQ		4
90 #define TARGET_VM86_GET_IRQ_BITS	5
91 #define TARGET_VM86_GET_AND_RESET_IRQ	6
92 
93 /*
94  * This is the stack-layout seen by the user space program when we have
95  * done a translation of "SAVE_ALL" from vm86 mode. The real kernel layout
96  * is 'kernel_vm86_regs' (see below).
97  */
98 
99 struct target_vm86_regs {
100 /*
101  * normal regs, with special meaning for the segment descriptors..
102  */
103 	abi_long ebx;
104 	abi_long ecx;
105 	abi_long edx;
106 	abi_long esi;
107 	abi_long edi;
108 	abi_long ebp;
109 	abi_long eax;
110 	abi_long __null_ds;
111 	abi_long __null_es;
112 	abi_long __null_fs;
113 	abi_long __null_gs;
114 	abi_long orig_eax;
115 	abi_long eip;
116 	unsigned short cs, __csh;
117 	abi_long eflags;
118 	abi_long esp;
119 	unsigned short ss, __ssh;
120 /*
121  * these are specific to v86 mode:
122  */
123 	unsigned short es, __esh;
124 	unsigned short ds, __dsh;
125 	unsigned short fs, __fsh;
126 	unsigned short gs, __gsh;
127 };
128 
129 struct target_revectored_struct {
130 	abi_ulong __map[8];			/* 256 bits */
131 };
132 
133 struct target_vm86_struct {
134 	struct target_vm86_regs regs;
135 	abi_ulong flags;
136 	abi_ulong screen_bitmap;
137 	abi_ulong cpu_type;
138 	struct target_revectored_struct int_revectored;
139 	struct target_revectored_struct int21_revectored;
140 };
141 
142 /*
143  * flags masks
144  */
145 #define TARGET_VM86_SCREEN_BITMAP	0x0001
146 
147 struct target_vm86plus_info_struct {
148         abi_ulong flags;
149 #define TARGET_force_return_for_pic (1 << 0)
150 #define TARGET_vm86dbg_active       (1 << 1)  /* for debugger */
151 #define TARGET_vm86dbg_TFpendig     (1 << 2)  /* for debugger */
152 #define TARGET_is_vm86pus           (1 << 31) /* for vm86 internal use */
153 	unsigned char vm86dbg_intxxtab[32];   /* for debugger */
154 };
155 
156 struct target_vm86plus_struct {
157 	struct target_vm86_regs regs;
158 	abi_ulong flags;
159 	abi_ulong screen_bitmap;
160 	abi_ulong cpu_type;
161 	struct target_revectored_struct int_revectored;
162 	struct target_revectored_struct int21_revectored;
163 	struct target_vm86plus_info_struct vm86plus;
164 };
165 
166 /* FreeBSD sysarch(2) */
167 #define TARGET_FREEBSD_I386_GET_LDT	0
168 #define TARGET_FREEBSD_I386_SET_LDT	1
169 				/* I386_IOPL */
170 #define TARGET_FREEBSD_I386_GET_IOPERM	3
171 #define TARGET_FREEBSD_I386_SET_IOPERM	4
172 				/* xxxxx */
173 #define TARGET_FREEBSD_I386_VM86	6
174 #define TARGET_FREEBSD_I386_GET_FSBASE	7
175 #define TARGET_FREEBSD_I386_SET_FSBASE	8
176 #define TARGET_FREEBSD_I386_GET_GSBASE	9
177 #define TARGET_FREEBSD_I386_SET_GSBASE	10
178 
179 
180 #define UNAME_MACHINE "i386"
181 #define TARGET_HW_MACHINE UNAME_MACHINE
182 #define TARGET_HW_MACHINE_ARCH UNAME_MACHINE
183 
184 #endif /* TARGET_SYSCALL_H */
185