root / darwin-user / qemu.h @ 50d3eeae
History | View | Annotate | Download (4.9 kB)
1 | 831b7825 | ths | #ifndef GEMU_H
|
---|---|---|---|
2 | 831b7825 | ths | #define GEMU_H
|
3 | 831b7825 | ths | |
4 | 831b7825 | ths | #include "thunk.h" |
5 | 831b7825 | ths | |
6 | 831b7825 | ths | #include <signal.h> |
7 | 831b7825 | ths | #include <string.h> |
8 | 831b7825 | ths | |
9 | 831b7825 | ths | #include "cpu.h" |
10 | 831b7825 | ths | |
11 | 831b7825 | ths | #include "gdbstub.h" |
12 | 831b7825 | ths | |
13 | 831b7825 | ths | typedef siginfo_t target_siginfo_t;
|
14 | 831b7825 | ths | #define target_sigaction sigaction
|
15 | 831b7825 | ths | #ifdef TARGET_I386
|
16 | 831b7825 | ths | struct target_pt_regs {
|
17 | 831b7825 | ths | long ebx;
|
18 | 831b7825 | ths | long ecx;
|
19 | 831b7825 | ths | long edx;
|
20 | 831b7825 | ths | long esi;
|
21 | 831b7825 | ths | long edi;
|
22 | 831b7825 | ths | long ebp;
|
23 | 831b7825 | ths | long eax;
|
24 | 831b7825 | ths | int xds;
|
25 | 831b7825 | ths | int xes;
|
26 | 831b7825 | ths | long orig_eax;
|
27 | 831b7825 | ths | long eip;
|
28 | 831b7825 | ths | int xcs;
|
29 | 831b7825 | ths | long eflags;
|
30 | 831b7825 | ths | long esp;
|
31 | 831b7825 | ths | int xss;
|
32 | 831b7825 | ths | }; |
33 | 831b7825 | ths | struct target_sigcontext {
|
34 | 831b7825 | ths | int sc_onstack;
|
35 | 831b7825 | ths | int sc_mask;
|
36 | 831b7825 | ths | int sc_eax;
|
37 | 831b7825 | ths | int sc_ebx;
|
38 | 831b7825 | ths | int sc_ecx;
|
39 | 831b7825 | ths | int sc_edx;
|
40 | 831b7825 | ths | int sc_edi;
|
41 | 831b7825 | ths | int sc_esi;
|
42 | 831b7825 | ths | int sc_ebp;
|
43 | 831b7825 | ths | int sc_esp;
|
44 | 831b7825 | ths | int sc_ss;
|
45 | 831b7825 | ths | int sc_eflags;
|
46 | 831b7825 | ths | int sc_eip;
|
47 | 831b7825 | ths | int sc_cs;
|
48 | 831b7825 | ths | int sc_ds;
|
49 | 831b7825 | ths | int sc_es;
|
50 | 831b7825 | ths | int sc_fs;
|
51 | 831b7825 | ths | int sc_gs;
|
52 | 831b7825 | ths | }; |
53 | 831b7825 | ths | |
54 | 831b7825 | ths | #define __USER_CS (0x17) |
55 | 831b7825 | ths | #define __USER_DS (0x1F) |
56 | 831b7825 | ths | |
57 | 831b7825 | ths | #elif defined(TARGET_PPC)
|
58 | 831b7825 | ths | struct target_pt_regs {
|
59 | 831b7825 | ths | unsigned long gpr[32]; |
60 | 831b7825 | ths | unsigned long nip; |
61 | 831b7825 | ths | unsigned long msr; |
62 | 831b7825 | ths | unsigned long orig_gpr3; /* Used for restarting system calls */ |
63 | 831b7825 | ths | unsigned long ctr; |
64 | 831b7825 | ths | unsigned long link; |
65 | 831b7825 | ths | unsigned long xer; |
66 | 831b7825 | ths | unsigned long ccr; |
67 | 831b7825 | ths | unsigned long mq; /* 601 only (not used at present) */ |
68 | 831b7825 | ths | /* Used on APUS to hold IPL value. */
|
69 | 831b7825 | ths | unsigned long trap; /* Reason for being here */ |
70 | 831b7825 | ths | unsigned long dar; /* Fault registers */ |
71 | 831b7825 | ths | unsigned long dsisr; |
72 | 831b7825 | ths | unsigned long result; /* Result of a system call */ |
73 | 831b7825 | ths | }; |
74 | 831b7825 | ths | |
75 | 831b7825 | ths | struct target_sigcontext {
|
76 | 831b7825 | ths | int sc_onstack; /* sigstack state to restore */ |
77 | 831b7825 | ths | int sc_mask; /* signal mask to restore */ |
78 | 831b7825 | ths | int sc_ir; /* pc */ |
79 | 831b7825 | ths | int sc_psw; /* processor status word */ |
80 | 831b7825 | ths | int sc_sp; /* stack pointer if sc_regs == NULL */ |
81 | 831b7825 | ths | void *sc_regs; /* (kernel private) saved state */ |
82 | 831b7825 | ths | }; |
83 | 831b7825 | ths | |
84 | 831b7825 | ths | #endif
|
85 | 831b7825 | ths | |
86 | 831b7825 | ths | typedef struct TaskState { |
87 | 831b7825 | ths | struct TaskState *next;
|
88 | 831b7825 | ths | int used; /* non zero if used */ |
89 | 831b7825 | ths | uint8_t stack[0];
|
90 | 831b7825 | ths | } __attribute__((aligned(16))) TaskState;
|
91 | 831b7825 | ths | |
92 | 831b7825 | ths | void syscall_init(void); |
93 | 831b7825 | ths | long do_mach_syscall(void *cpu_env, int num, uint32_t arg1, uint32_t arg2, uint32_t arg3, |
94 | 831b7825 | ths | uint32_t arg4, uint32_t arg5, uint32_t arg6, uint32_t arg7, uint32_t arg8); |
95 | 831b7825 | ths | long do_thread_syscall(void *cpu_env, int num, uint32_t arg1, uint32_t arg2, uint32_t arg3, |
96 | 831b7825 | ths | uint32_t arg4, uint32_t arg5, uint32_t arg6, uint32_t arg7, uint32_t arg8); |
97 | 831b7825 | ths | long do_unix_syscall(void *cpu_env, int num); |
98 | 831b7825 | ths | int do_sigaction(int sig, const struct sigaction *act, |
99 | 831b7825 | ths | struct sigaction *oact);
|
100 | 831b7825 | ths | int do_sigaltstack(const struct sigaltstack *ss, struct sigaltstack *oss); |
101 | 831b7825 | ths | |
102 | 831b7825 | ths | void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2))); |
103 | 831b7825 | ths | void qerror(const char *fmt, ...); |
104 | 831b7825 | ths | |
105 | 831b7825 | ths | void write_dt(void *ptr, unsigned long addr, unsigned long limit, int flags); |
106 | 831b7825 | ths | |
107 | 831b7825 | ths | extern CPUState *global_env;
|
108 | 831b7825 | ths | void cpu_loop(CPUState *env);
|
109 | 831b7825 | ths | void init_paths(const char *prefix); |
110 | 831b7825 | ths | const char *path(const char *pathname); |
111 | 831b7825 | ths | |
112 | 831b7825 | ths | extern int loglevel; |
113 | 831b7825 | ths | extern FILE *logfile;
|
114 | 831b7825 | ths | |
115 | 831b7825 | ths | /* commpage.c */
|
116 | 831b7825 | ths | void commpage_init();
|
117 | 831b7825 | ths | void do_commpage(void *cpu_env, int num, uint32_t arg1, uint32_t arg2, uint32_t arg3, |
118 | 831b7825 | ths | uint32_t arg4, uint32_t arg5, uint32_t arg6, uint32_t arg7, uint32_t arg8); |
119 | 831b7825 | ths | |
120 | 831b7825 | ths | /* signal.c */
|
121 | 831b7825 | ths | void process_pending_signals(void *cpu_env); |
122 | 831b7825 | ths | void signal_init(void); |
123 | 831b7825 | ths | int queue_signal(int sig, target_siginfo_t *info); |
124 | 831b7825 | ths | void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info); |
125 | 831b7825 | ths | void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo); |
126 | 831b7825 | ths | long do_sigreturn(CPUState *env, int num); |
127 | 831b7825 | ths | |
128 | 831b7825 | ths | /* machload.c */
|
129 | 831b7825 | ths | int mach_exec(const char * filename, char ** argv, char ** envp, |
130 | 831b7825 | ths | struct target_pt_regs * regs);
|
131 | 831b7825 | ths | |
132 | 831b7825 | ths | /* mmap.c */
|
133 | 831b7825 | ths | int target_mprotect(unsigned long start, unsigned long len, int prot); |
134 | 831b7825 | ths | long target_mmap(unsigned long start, unsigned long len, int prot, |
135 | 831b7825 | ths | int flags, int fd, unsigned long offset); |
136 | 831b7825 | ths | int target_munmap(unsigned long start, unsigned long len); |
137 | 831b7825 | ths | long target_mremap(unsigned long old_addr, unsigned long old_size, |
138 | 831b7825 | ths | unsigned long new_size, unsigned long flags, |
139 | 831b7825 | ths | unsigned long new_addr); |
140 | 831b7825 | ths | int target_msync(unsigned long start, unsigned long len, int flags); |
141 | 831b7825 | ths | |
142 | 831b7825 | ths | /* user access */
|
143 | 831b7825 | ths | |
144 | 831b7825 | ths | /* XXX: todo protect every memory access */
|
145 | 831b7825 | ths | #define lock_user(x,y,z) (void*)(x) |
146 | 831b7825 | ths | #define unlock_user(x,y,z)
|
147 | 831b7825 | ths | |
148 | 831b7825 | ths | /* Mac OS X ABI arguments processing */
|
149 | 831b7825 | ths | #ifdef TARGET_I386
|
150 | 831b7825 | ths | static inline uint32_t get_int_arg(int *i, CPUX86State *cpu_env) |
151 | 831b7825 | ths | { |
152 | 831b7825 | ths | uint32_t *args = (uint32_t*)(cpu_env->regs[R_ESP] + 4 + *i);
|
153 | 831b7825 | ths | *i+=4;
|
154 | 831b7825 | ths | return tswap32(*args);
|
155 | 831b7825 | ths | } |
156 | 831b7825 | ths | static inline uint64_t get_int64_arg(int *i, CPUX86State *cpu_env) |
157 | 831b7825 | ths | { |
158 | 831b7825 | ths | uint64_t *args = (uint64_t*)(cpu_env->regs[R_ESP] + 4 + *i);
|
159 | 831b7825 | ths | *i+=8;
|
160 | 831b7825 | ths | return tswap64(*args);
|
161 | 831b7825 | ths | } |
162 | 831b7825 | ths | #elif defined(TARGET_PPC)
|
163 | 831b7825 | ths | static inline uint32_t get_int_arg(int *i, CPUPPCState *cpu_env) |
164 | 831b7825 | ths | { |
165 | 831b7825 | ths | /* XXX: won't work when args goes on stack after gpr10 */
|
166 | 831b7825 | ths | uint32_t args = (uint32_t)(cpu_env->gpr[3+(*i & 0xff)/4]); |
167 | 831b7825 | ths | *i+=4;
|
168 | 831b7825 | ths | return tswap32(args);
|
169 | 831b7825 | ths | } |
170 | 831b7825 | ths | static inline uint64_t get_int64_arg(int *i, CPUPPCState *cpu_env) |
171 | 831b7825 | ths | { |
172 | 831b7825 | ths | /* XXX: won't work when args goes on stack after gpr10 */
|
173 | 831b7825 | ths | uint64_t args = (uint64_t)(cpu_env->fpr[1+(*i >> 8)/8]); |
174 | 831b7825 | ths | *i+=(8 << 8) + 8; |
175 | 831b7825 | ths | return tswap64(args);
|
176 | 831b7825 | ths | } |
177 | 831b7825 | ths | #endif
|
178 | 831b7825 | ths | |
179 | 831b7825 | ths | #endif |