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