13 typedef siginfo_t target_siginfo_t
;
14 #define target_sigaction sigaction
16 struct target_pt_regs
{
33 struct target_sigcontext
{
54 #define __USER_CS (0x17)
55 #define __USER_DS (0x1F)
57 #elif defined(TARGET_PPC)
58 struct target_pt_regs
{
59 unsigned long gpr
[32];
62 unsigned long orig_gpr3
; /* Used for restarting system calls */
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 */
72 unsigned long result
; /* Result of a system call */
75 struct target_sigcontext
{
76 int sc_onstack
; /* sigstack state to restore */
77 int sc_mask
; /* signal mask to restore */
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 */
86 typedef struct TaskState
{
87 struct TaskState
*next
;
88 int used
; /* non zero if used */
90 } __attribute__((aligned(16))) TaskState
;
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
);
102 void gemu_log(const char *fmt
, ...) __attribute__((format(printf
,1,2)));
103 void qerror(const char *fmt
, ...);
105 void write_dt(void *ptr
, unsigned long addr
, unsigned long limit
, int flags
);
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
);
113 extern FILE *logfile
;
116 void commpage_init();
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
);
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
);
129 int mach_exec(const char * filename
, char ** argv
, char ** envp
,
130 struct target_pt_regs
* regs
);
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
);
144 /* XXX: todo protect every memory access */
145 #define lock_user(x,y,z) (void*)(x)
146 #define unlock_user(x,y,z)
148 /* Mac OS X ABI arguments processing */
150 static inline uint32_t get_int_arg(int *i
, CPUX86State
*cpu_env
)
152 uint32_t *args
= (uint32_t*)(cpu_env
->regs
[R_ESP
] + 4 + *i
);
154 return tswap32(*args
);
156 static inline uint64_t get_int64_arg(int *i
, CPUX86State
*cpu_env
)
158 uint64_t *args
= (uint64_t*)(cpu_env
->regs
[R_ESP
] + 4 + *i
);
160 return tswap64(*args
);
162 #elif defined(TARGET_PPC)
163 static inline uint32_t get_int_arg(int *i
, CPUPPCState
*cpu_env
)
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]);
168 return tswap32(args
);
170 static inline uint64_t get_int64_arg(int *i
, CPUPPCState
*cpu_env
)
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]);
175 return tswap64(args
);