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