00001 #ifndef GEMU_H
00002 #define GEMU_H
00003
00004 #include <signal.h>
00005 #include <string.h>
00006
00007 #include "cpu.h"
00008
00009 #include "thunk.h"
00010
00011 #include "gdbstub.h"
00012
00013 typedef siginfo_t target_siginfo_t;
00014 #define target_sigaction sigaction
00015 #ifdef TARGET_I386
00016 struct target_pt_regs {
00017 long ebx;
00018 long ecx;
00019 long edx;
00020 long esi;
00021 long edi;
00022 long ebp;
00023 long eax;
00024 int xds;
00025 int xes;
00026 long orig_eax;
00027 long eip;
00028 int xcs;
00029 long eflags;
00030 long esp;
00031 int xss;
00032 };
00033 struct target_sigcontext {
00034 int sc_onstack;
00035 int sc_mask;
00036 int sc_eax;
00037 int sc_ebx;
00038 int sc_ecx;
00039 int sc_edx;
00040 int sc_edi;
00041 int sc_esi;
00042 int sc_ebp;
00043 int sc_esp;
00044 int sc_ss;
00045 int sc_eflags;
00046 int sc_eip;
00047 int sc_cs;
00048 int sc_ds;
00049 int sc_es;
00050 int sc_fs;
00051 int sc_gs;
00052 };
00053
00054 #define __USER_CS (0x17)
00055 #define __USER_DS (0x1F)
00056
00057 #elif defined(TARGET_PPC)
00058 struct target_pt_regs {
00059 unsigned long gpr[32];
00060 unsigned long nip;
00061 unsigned long msr;
00062 unsigned long orig_gpr3;
00063 unsigned long ctr;
00064 unsigned long link;
00065 unsigned long xer;
00066 unsigned long ccr;
00067 unsigned long mq;
00068
00069 unsigned long trap;
00070 unsigned long dar;
00071 unsigned long dsisr;
00072 unsigned long result;
00073 };
00074
00075 struct target_sigcontext {
00076 int sc_onstack;
00077 int sc_mask;
00078 int sc_ir;
00079 int sc_psw;
00080 int sc_sp;
00081 void *sc_regs;
00082 };
00083
00084 #endif
00085
00086 typedef struct TaskState {
00087 struct TaskState *next;
00088 int used;
00089 uint8_t stack[0];
00090 } __attribute__((aligned(16))) TaskState;
00091
00092 void syscall_init(void);
00093 long do_mach_syscall(void *cpu_env, int num, uint32_t arg1, uint32_t arg2, uint32_t arg3,
00094 uint32_t arg4, uint32_t arg5, uint32_t arg6, uint32_t arg7, uint32_t arg8);
00095 long do_thread_syscall(void *cpu_env, int num, uint32_t arg1, uint32_t arg2, uint32_t arg3,
00096 uint32_t arg4, uint32_t arg5, uint32_t arg6, uint32_t arg7, uint32_t arg8);
00097 long do_unix_syscall(void *cpu_env, int num);
00098 int do_sigaction(int sig, const struct sigaction *act,
00099 struct sigaction *oact);
00100 int do_sigaltstack(const struct sigaltstack *ss, struct sigaltstack *oss);
00101
00102 void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2)));
00103 void qerror(const char *fmt, ...);
00104
00105 void write_dt(void *ptr, unsigned long addr, unsigned long limit, int flags);
00106
00107 extern CPUState *global_env;
00108 void cpu_loop(CPUState *env);
00109 void init_paths(const char *prefix);
00110 const char *path(const char *pathname);
00111
00112 #include "qemu-log.h"
00113
00114
00115 void commpage_init(void);
00116 void do_commpage(void *cpu_env, int num, uint32_t arg1, uint32_t arg2, uint32_t arg3,
00117 uint32_t arg4, uint32_t arg5, uint32_t arg6, uint32_t arg7, uint32_t arg8);
00118
00119
00120 void process_pending_signals(void *cpu_env);
00121 void signal_init(void);
00122 int queue_signal(int sig, target_siginfo_t *info);
00123 void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info);
00124 void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo);
00125 long do_sigreturn(CPUState *env, int num);
00126
00127
00128 int mach_exec(const char * filename, char ** argv, char ** envp,
00129 struct target_pt_regs * regs);
00130
00131
00132 int target_mprotect(unsigned long start, unsigned long len, int prot);
00133 long target_mmap(unsigned long start, unsigned long len, int prot,
00134 int flags, int fd, unsigned long offset);
00135 int target_munmap(unsigned long start, unsigned long len);
00136 long target_mremap(unsigned long old_addr, unsigned long old_size,
00137 unsigned long new_size, unsigned long flags,
00138 unsigned long new_addr);
00139 int target_msync(unsigned long start, unsigned long len, int flags);
00140
00141
00142
00143
00144 #define lock_user(x,y,z) (void*)(x)
00145 #define unlock_user(x,y,z)
00146
00147
00148 #ifdef TARGET_I386
00149 static inline uint32_t get_int_arg(int *i, CPUX86State *cpu_env)
00150 {
00151 uint32_t *args = (uint32_t*)(cpu_env->regs[R_ESP] + 4 + *i);
00152 *i+=4;
00153 return tswap32(*args);
00154 }
00155 static inline uint64_t get_int64_arg(int *i, CPUX86State *cpu_env)
00156 {
00157 uint64_t *args = (uint64_t*)(cpu_env->regs[R_ESP] + 4 + *i);
00158 *i+=8;
00159 return tswap64(*args);
00160 }
00161 #elif defined(TARGET_PPC)
00162 static inline uint32_t get_int_arg(int *i, CPUPPCState *cpu_env)
00163 {
00164
00165 uint32_t args = (uint32_t)(cpu_env->gpr[3+(*i & 0xff)/4]);
00166 *i+=4;
00167 return tswap32(args);
00168 }
00169 static inline uint64_t get_int64_arg(int *i, CPUPPCState *cpu_env)
00170 {
00171
00172 uint64_t args = (uint64_t)(cpu_env->fpr[1+(*i >> 8)/8]);
00173 *i+=(8 << 8) + 8;
00174 return tswap64(args);
00175 }
00176 #endif
00177
00178 #endif