root / linux-user / qemu.h @ facc68be
History | View | Annotate | Download (3.3 kB)
1 | 31e31b8a | bellard | #ifndef GEMU_H
|
---|---|---|---|
2 | 31e31b8a | bellard | #define GEMU_H
|
3 | 31e31b8a | bellard | |
4 | 31e31b8a | bellard | #include "thunk.h" |
5 | 31e31b8a | bellard | |
6 | 9de5e440 | bellard | #include <signal.h> |
7 | 9de5e440 | bellard | #include "syscall_defs.h" |
8 | 31e31b8a | bellard | |
9 | 2054396a | bellard | #if defined(TARGET_I386)
|
10 | 2054396a | bellard | #include "cpu-i386.h" |
11 | 2054396a | bellard | #include "syscall-i386.h" |
12 | 2054396a | bellard | #elif defined(TARGET_ARM)
|
13 | 2054396a | bellard | #include "cpu-arm.h" |
14 | 2054396a | bellard | #include "syscall-arm.h" |
15 | 2054396a | bellard | #else
|
16 | 2054396a | bellard | #error unsupported target CPU
|
17 | 2054396a | bellard | #endif
|
18 | 66fb9763 | bellard | |
19 | 31e31b8a | bellard | /* This struct is used to hold certain information about the image.
|
20 | 31e31b8a | bellard | * Basically, it replicates in user space what would be certain
|
21 | 31e31b8a | bellard | * task_struct fields in the kernel
|
22 | 31e31b8a | bellard | */
|
23 | 31e31b8a | bellard | struct image_info {
|
24 | 31e31b8a | bellard | unsigned long start_code; |
25 | 31e31b8a | bellard | unsigned long end_code; |
26 | 31e31b8a | bellard | unsigned long end_data; |
27 | 31e31b8a | bellard | unsigned long start_brk; |
28 | 31e31b8a | bellard | unsigned long brk; |
29 | 31e31b8a | bellard | unsigned long start_mmap; |
30 | 31e31b8a | bellard | unsigned long mmap; |
31 | 31e31b8a | bellard | unsigned long rss; |
32 | 31e31b8a | bellard | unsigned long start_stack; |
33 | 31e31b8a | bellard | unsigned long arg_start; |
34 | 31e31b8a | bellard | unsigned long arg_end; |
35 | 31e31b8a | bellard | unsigned long env_start; |
36 | 31e31b8a | bellard | unsigned long env_end; |
37 | 31e31b8a | bellard | unsigned long entry; |
38 | 31e31b8a | bellard | int personality;
|
39 | 31e31b8a | bellard | }; |
40 | 31e31b8a | bellard | |
41 | b346ff46 | bellard | #ifdef TARGET_I386
|
42 | 851e67a1 | bellard | /* Information about the current linux thread */
|
43 | 851e67a1 | bellard | struct vm86_saved_state {
|
44 | 851e67a1 | bellard | uint32_t eax; /* return code */
|
45 | 851e67a1 | bellard | uint32_t ebx; |
46 | 851e67a1 | bellard | uint32_t ecx; |
47 | 851e67a1 | bellard | uint32_t edx; |
48 | 851e67a1 | bellard | uint32_t esi; |
49 | 851e67a1 | bellard | uint32_t edi; |
50 | 851e67a1 | bellard | uint32_t ebp; |
51 | 851e67a1 | bellard | uint32_t esp; |
52 | 851e67a1 | bellard | uint32_t eflags; |
53 | 851e67a1 | bellard | uint32_t eip; |
54 | 851e67a1 | bellard | uint16_t cs, ss, ds, es, fs, gs; |
55 | 851e67a1 | bellard | }; |
56 | b346ff46 | bellard | #endif
|
57 | 851e67a1 | bellard | |
58 | 851e67a1 | bellard | /* NOTE: we force a big alignment so that the stack stored after is
|
59 | 851e67a1 | bellard | aligned too */
|
60 | 851e67a1 | bellard | typedef struct TaskState { |
61 | 851e67a1 | bellard | struct TaskState *next;
|
62 | b346ff46 | bellard | #ifdef TARGET_I386
|
63 | 851e67a1 | bellard | struct target_vm86plus_struct *target_v86;
|
64 | 851e67a1 | bellard | struct vm86_saved_state vm86_saved_regs;
|
65 | b333af06 | bellard | struct target_vm86plus_struct vm86plus;
|
66 | 631271d7 | bellard | uint32_t v86flags; |
67 | 631271d7 | bellard | uint32_t v86mask; |
68 | b346ff46 | bellard | #endif
|
69 | 851e67a1 | bellard | int used; /* non zero if used */ |
70 | 851e67a1 | bellard | uint8_t stack[0];
|
71 | 851e67a1 | bellard | } __attribute__((aligned(16))) TaskState;
|
72 | 851e67a1 | bellard | |
73 | 851e67a1 | bellard | extern TaskState *first_task_state;
|
74 | 851e67a1 | bellard | |
75 | 32ce6337 | bellard | int elf_exec(const char * filename, char ** argv, char ** envp, |
76 | 01ffc75b | bellard | struct target_pt_regs * regs, struct image_info *infop); |
77 | 31e31b8a | bellard | |
78 | 31e31b8a | bellard | void target_set_brk(char *new_brk); |
79 | 31e31b8a | bellard | void syscall_init(void); |
80 | 6dbad63e | bellard | long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, |
81 | 31e31b8a | bellard | long arg4, long arg5, long arg6); |
82 | 31e31b8a | bellard | void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2))); |
83 | b346ff46 | bellard | extern CPUState *global_env;
|
84 | b346ff46 | bellard | void cpu_loop(CPUState *env);
|
85 | 32ce6337 | bellard | void init_paths(const char *prefix); |
86 | 32ce6337 | bellard | const char *path(const char *pathname); |
87 | 6977fbfd | bellard | |
88 | 6977fbfd | bellard | extern int loglevel; |
89 | 631271d7 | bellard | extern FILE *logfile;
|
90 | 631271d7 | bellard | |
91 | b346ff46 | bellard | /* signal.c */
|
92 | b346ff46 | bellard | void process_pending_signals(void *cpu_env); |
93 | b346ff46 | bellard | void signal_init(void); |
94 | b346ff46 | bellard | int queue_signal(int sig, target_siginfo_t *info); |
95 | b346ff46 | bellard | void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info); |
96 | b346ff46 | bellard | void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo); |
97 | b346ff46 | bellard | long do_sigreturn(CPUState *env);
|
98 | b346ff46 | bellard | long do_rt_sigreturn(CPUState *env);
|
99 | b346ff46 | bellard | |
100 | b346ff46 | bellard | #ifdef TARGET_I386
|
101 | 631271d7 | bellard | /* vm86.c */
|
102 | 631271d7 | bellard | void save_v86_state(CPUX86State *env);
|
103 | 447db213 | bellard | void handle_vm86_trap(CPUX86State *env, int trapno); |
104 | 631271d7 | bellard | void handle_vm86_fault(CPUX86State *env);
|
105 | 631271d7 | bellard | int do_vm86(CPUX86State *env, long subfunction, |
106 | 631271d7 | bellard | struct target_vm86plus_struct * target_v86);
|
107 | b346ff46 | bellard | #endif
|
108 | 631271d7 | bellard | |
109 | 54936004 | bellard | /* mmap.c */
|
110 | 54936004 | bellard | int target_mprotect(unsigned long start, unsigned long len, int prot); |
111 | 54936004 | bellard | long target_mmap(unsigned long start, unsigned long len, int prot, |
112 | 54936004 | bellard | int flags, int fd, unsigned long offset); |
113 | 54936004 | bellard | int target_munmap(unsigned long start, unsigned long len); |
114 | 54936004 | bellard | long target_mremap(unsigned long old_addr, unsigned long old_size, |
115 | 54936004 | bellard | unsigned long new_size, unsigned long flags, |
116 | 54936004 | bellard | unsigned long new_addr); |
117 | 54936004 | bellard | int target_msync(unsigned long start, unsigned long len, int flags); |
118 | 54936004 | bellard | |
119 | 31e31b8a | bellard | #endif |