8 #include "syscall_defs.h"
13 /* This struct is used to hold certain information about the image.
14 * Basically, it replicates in user space what would be certain
15 * task_struct fields in the kernel
18 unsigned long start_code;
19 unsigned long end_code;
20 unsigned long end_data;
21 unsigned long start_brk;
23 unsigned long start_mmap;
26 unsigned long start_stack;
27 unsigned long arg_start;
28 unsigned long arg_end;
29 unsigned long env_start;
30 unsigned long env_end;
36 /* Information about the current linux thread */
37 struct vm86_saved_state {
38 uint32_t eax; /* return code */
48 uint16_t cs, ss, ds, es, fs, gs;
54 #include "nwfpe/fpa11.h"
57 /* NOTE: we force a big alignment so that the stack stored after is
59 typedef struct TaskState {
60 struct TaskState *next;
66 struct target_vm86plus_struct *target_v86;
67 struct vm86_saved_state vm86_saved_regs;
68 struct target_vm86plus_struct vm86plus;
72 int used; /* non zero if used */
74 } __attribute__((aligned(16))) TaskState;
76 extern TaskState *first_task_state;
78 int elf_exec(const char * filename, char ** argv, char ** envp,
79 struct target_pt_regs * regs, struct image_info *infop);
81 void target_set_brk(char *new_brk);
82 void syscall_init(void);
83 long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
84 long arg4, long arg5, long arg6);
85 void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2)));
86 extern CPUState *global_env;
87 void cpu_loop(CPUState *env);
88 void init_paths(const char *prefix);
89 const char *path(const char *pathname);
95 void process_pending_signals(void *cpu_env);
96 void signal_init(void);
97 int queue_signal(int sig, target_siginfo_t *info);
98 void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info);
99 void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo);
100 long do_sigreturn(CPUState *env);
101 long do_rt_sigreturn(CPUState *env);
105 void save_v86_state(CPUX86State *env);
106 void handle_vm86_trap(CPUX86State *env, int trapno);
107 void handle_vm86_fault(CPUX86State *env);
108 int do_vm86(CPUX86State *env, long subfunction,
109 struct target_vm86plus_struct * target_v86);
113 int target_mprotect(unsigned long start, unsigned long len, int prot);
114 long target_mmap(unsigned long start, unsigned long len, int prot,
115 int flags, int fd, unsigned long offset);
116 int target_munmap(unsigned long start, unsigned long len);
117 long target_mremap(unsigned long old_addr, unsigned long old_size,
118 unsigned long new_size, unsigned long flags,
119 unsigned long new_addr);
120 int target_msync(unsigned long start, unsigned long len, int flags);
124 #define VERIFY_READ 0
125 #define VERIFY_WRITE 1
127 #define access_ok(type,addr,size) (1)
129 #define __put_user(x,ptr)\
131 int size = sizeof(*ptr);\
134 stb(ptr, (typeof(*ptr))(x));\
137 stw(ptr, (typeof(*ptr))(x));\
140 stl(ptr, (typeof(*ptr))(x));\
143 stq(ptr, (typeof(*ptr))(x));\
151 #define __get_user(x, ptr) \
153 int size = sizeof(*ptr);\
156 x = (typeof(*ptr))ldub((void *)ptr);\
159 x = (typeof(*ptr))lduw((void *)ptr);\
162 x = (typeof(*ptr))ldl((void *)ptr);\
165 x = (typeof(*ptr))ldq((void *)ptr);\
173 static inline unsigned long __copy_to_user(void *dst, const void *src,
176 memcpy(dst, src, size);
180 static inline unsigned long __copy_from_user(void *dst, const void *src,
183 memcpy(dst, src, size);
187 static inline unsigned long __clear_user(void *dst, unsigned long size)
189 memset(dst, 0, size);
193 #define put_user(x,ptr)\
196 if (access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)))\
197 __ret = __put_user(x, ptr);\
203 #define get_user(x,ptr)\
206 if (access_ok(VERIFY_READ, ptr, sizeof(*ptr)))\
207 __ret = __get_user(x, ptr);\
213 static inline unsigned long copy_to_user(void *dst, const void *src,
216 if (access_ok(VERIFY_WRITE, dst, size))
217 return __copy_to_user(dst, src, size);
222 static inline unsigned long copy_from_user(void *dst, const void *src,
225 if (access_ok(VERIFY_READ, src, size))
226 return __copy_from_user(dst, src, size);
231 static inline unsigned long clear_user(void *dst, unsigned long size)
233 if (access_ok(VERIFY_WRITE, dst, size))
234 return __clear_user(dst, size);