linux-user: fix ppc target_stat64 st_blocks layout
[qemu] / darwin-user / qemu.h
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 #include "qemu-log.h"
113
114 /* commpage.c */
115 void commpage_init(void);
116 void do_commpage(void *cpu_env, int num, uint32_t arg1, uint32_t arg2, uint32_t arg3,
117                 uint32_t arg4, uint32_t arg5, uint32_t arg6, uint32_t arg7, uint32_t arg8);
118
119 /* signal.c */
120 void process_pending_signals(void *cpu_env);
121 void signal_init(void);
122 int queue_signal(int sig, target_siginfo_t *info);
123 void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info);
124 void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo);
125 long do_sigreturn(CPUState *env, int num);
126
127 /* machload.c */
128 int mach_exec(const char * filename, char ** argv, char ** envp,
129                           struct target_pt_regs * regs);
130
131 /* mmap.c */
132 int target_mprotect(unsigned long start, unsigned long len, int prot);
133 long target_mmap(unsigned long start, unsigned long len, int prot,
134                  int flags, int fd, unsigned long offset);
135 int target_munmap(unsigned long start, unsigned long len);
136 long target_mremap(unsigned long old_addr, unsigned long old_size,
137                    unsigned long new_size, unsigned long flags,
138                    unsigned long new_addr);
139 int target_msync(unsigned long start, unsigned long len, int flags);
140
141 /* user access */
142
143 /* XXX: todo protect every memory access */
144 #define lock_user(x,y,z)    (void*)(x)
145 #define unlock_user(x,y,z)
146
147 /* Mac OS X ABI arguments processing */
148 #ifdef TARGET_I386
149 static inline uint32_t get_int_arg(int *i, CPUX86State *cpu_env)
150 {
151     uint32_t *args = (uint32_t*)(cpu_env->regs[R_ESP] + 4 + *i);
152     *i+=4;
153     return tswap32(*args);
154 }
155 static inline uint64_t get_int64_arg(int *i, CPUX86State *cpu_env)
156 {
157     uint64_t *args = (uint64_t*)(cpu_env->regs[R_ESP] + 4 + *i);
158     *i+=8;
159     return tswap64(*args);
160 }
161 #elif defined(TARGET_PPC)
162 static inline uint32_t get_int_arg(int *i, CPUPPCState *cpu_env)
163 {
164     /* XXX: won't work when args goes on stack after gpr10 */
165     uint32_t args = (uint32_t)(cpu_env->gpr[3+(*i & 0xff)/4]);
166     *i+=4;
167     return tswap32(args);
168 }
169 static inline uint64_t get_int64_arg(int *i, CPUPPCState *cpu_env)
170 {
171     /* XXX: won't work when args goes on stack after gpr10 */
172     uint64_t args = (uint64_t)(cpu_env->fpr[1+(*i >> 8)/8]);
173     *i+=(8 << 8) + 8;
174     return tswap64(args);
175 }
176 #endif
177
178 #endif