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