blob: f6b8d96f44f8abb8ca4790f56e096b6c936f02c0 [file] [log] [blame]
bellard31e31b82003-02-18 22:55:36 +00001#ifndef GEMU_H
2#define GEMU_H
3
4#include "thunk.h"
5
bellard9de5e442003-03-23 16:49:39 +00006#include <signal.h>
7#include "syscall_defs.h"
8
bellard6180a182003-09-30 21:04:53 +00009#include "cpu.h"
10#include "syscall.h"
bellard66fb9762003-03-23 01:06:05 +000011
bellard31e31b82003-02-18 22:55:36 +000012/* This struct is used to hold certain information about the image.
13 * Basically, it replicates in user space what would be certain
14 * task_struct fields in the kernel
15 */
16struct image_info {
17 unsigned long start_code;
18 unsigned long end_code;
19 unsigned long end_data;
20 unsigned long start_brk;
21 unsigned long brk;
22 unsigned long start_mmap;
23 unsigned long mmap;
24 unsigned long rss;
25 unsigned long start_stack;
26 unsigned long arg_start;
27 unsigned long arg_end;
28 unsigned long env_start;
29 unsigned long env_end;
30 unsigned long entry;
31 int personality;
32};
33
bellardb346ff42003-06-15 20:05:50 +000034#ifdef TARGET_I386
bellard851e67a2003-03-29 16:53:14 +000035/* Information about the current linux thread */
36struct vm86_saved_state {
37 uint32_t eax; /* return code */
38 uint32_t ebx;
39 uint32_t ecx;
40 uint32_t edx;
41 uint32_t esi;
42 uint32_t edi;
43 uint32_t ebp;
44 uint32_t esp;
45 uint32_t eflags;
46 uint32_t eip;
47 uint16_t cs, ss, ds, es, fs, gs;
48};
bellardb346ff42003-06-15 20:05:50 +000049#endif
bellard851e67a2003-03-29 16:53:14 +000050
51/* NOTE: we force a big alignment so that the stack stored after is
52 aligned too */
53typedef struct TaskState {
54 struct TaskState *next;
bellardb346ff42003-06-15 20:05:50 +000055#ifdef TARGET_I386
bellard851e67a2003-03-29 16:53:14 +000056 struct target_vm86plus_struct *target_v86;
57 struct vm86_saved_state vm86_saved_regs;
bellardb333af02003-05-14 21:48:51 +000058 struct target_vm86plus_struct vm86plus;
bellard631271d2003-05-10 13:14:52 +000059 uint32_t v86flags;
60 uint32_t v86mask;
bellardb346ff42003-06-15 20:05:50 +000061#endif
bellard851e67a2003-03-29 16:53:14 +000062 int used; /* non zero if used */
63 uint8_t stack[0];
64} __attribute__((aligned(16))) TaskState;
65
66extern TaskState *first_task_state;
67
bellard32ce6332003-04-11 00:16:16 +000068int elf_exec(const char * filename, char ** argv, char ** envp,
bellard01ffc752003-02-18 23:00:51 +000069 struct target_pt_regs * regs, struct image_info *infop);
bellard31e31b82003-02-18 22:55:36 +000070
71void target_set_brk(char *new_brk);
72void syscall_init(void);
bellard6dbad632003-03-16 18:05:05 +000073long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
bellard31e31b82003-02-18 22:55:36 +000074 long arg4, long arg5, long arg6);
75void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2)));
bellardb346ff42003-06-15 20:05:50 +000076extern CPUState *global_env;
77void cpu_loop(CPUState *env);
bellard32ce6332003-04-11 00:16:16 +000078void init_paths(const char *prefix);
79const char *path(const char *pathname);
bellard6977fbf2003-04-29 20:39:23 +000080
81extern int loglevel;
bellard631271d2003-05-10 13:14:52 +000082extern FILE *logfile;
83
bellardb346ff42003-06-15 20:05:50 +000084/* signal.c */
85void process_pending_signals(void *cpu_env);
86void signal_init(void);
87int queue_signal(int sig, target_siginfo_t *info);
88void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info);
89void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo);
90long do_sigreturn(CPUState *env);
91long do_rt_sigreturn(CPUState *env);
92
93#ifdef TARGET_I386
bellard631271d2003-05-10 13:14:52 +000094/* vm86.c */
95void save_v86_state(CPUX86State *env);
bellard447db212003-05-10 15:10:36 +000096void handle_vm86_trap(CPUX86State *env, int trapno);
bellard631271d2003-05-10 13:14:52 +000097void handle_vm86_fault(CPUX86State *env);
98int do_vm86(CPUX86State *env, long subfunction,
99 struct target_vm86plus_struct * target_v86);
bellardb346ff42003-06-15 20:05:50 +0000100#endif
bellard631271d2003-05-10 13:14:52 +0000101
bellard54936002003-05-13 00:25:15 +0000102/* mmap.c */
103int target_mprotect(unsigned long start, unsigned long len, int prot);
104long target_mmap(unsigned long start, unsigned long len, int prot,
105 int flags, int fd, unsigned long offset);
106int target_munmap(unsigned long start, unsigned long len);
107long target_mremap(unsigned long old_addr, unsigned long old_size,
108 unsigned long new_size, unsigned long flags,
109 unsigned long new_addr);
110int target_msync(unsigned long start, unsigned long len, int flags);
111
bellard31e31b82003-02-18 22:55:36 +0000112#endif