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