qemu.h 2.4 KB
Newer Older
1 2 3 4 5
#ifndef GEMU_H
#define GEMU_H

#include "thunk.h"

B
bellard 已提交
6 7
#include <signal.h>
#include "syscall_defs.h"
8

B
bellard 已提交
9 10 11
#ifdef TARGET_I386
#include "cpu-i386.h"
#include "syscall-i386.h"
B
bellard 已提交
12 13
#endif

14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
/* This struct is used to hold certain information about the image.
 * Basically, it replicates in user space what would be certain
 * task_struct fields in the kernel
 */
struct image_info {
	unsigned long	start_code;
	unsigned long	end_code;
	unsigned long	end_data;
	unsigned long	start_brk;
	unsigned long	brk;
	unsigned long	start_mmap;
	unsigned long	mmap;
	unsigned long	rss;
	unsigned long	start_stack;
	unsigned long	arg_start;
	unsigned long	arg_end;
	unsigned long	env_start;
	unsigned long	env_end;
	unsigned long	entry;
	int		personality;
};

B
bellard 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
/* Information about the current linux thread */
struct vm86_saved_state {
    uint32_t eax; /* return code */
    uint32_t ebx;
    uint32_t ecx;
    uint32_t edx;
    uint32_t esi;
    uint32_t edi;
    uint32_t ebp;
    uint32_t esp;
    uint32_t eflags;
    uint32_t eip;
    uint16_t cs, ss, ds, es, fs, gs;
};

/* NOTE: we force a big alignment so that the stack stored after is
   aligned too */
typedef struct TaskState {
    struct TaskState *next;
    struct target_vm86plus_struct *target_v86;
    struct vm86_saved_state vm86_saved_regs;
B
bellard 已提交
57 58
    uint32_t v86flags;
    uint32_t v86mask;
B
bellard 已提交
59 60 61 62 63 64
    int used; /* non zero if used */
    uint8_t stack[0];
} __attribute__((aligned(16))) TaskState;

extern TaskState *first_task_state;

B
bellard 已提交
65
int elf_exec(const char * filename, char ** argv, char ** envp, 
B
bellard 已提交
66
             struct target_pt_regs * regs, struct image_info *infop);
67 68 69

void target_set_brk(char *new_brk);
void syscall_init(void);
B
bellard 已提交
70
long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, 
71 72
                long arg4, long arg5, long arg6);
void gemu_log(const char *fmt, ...) __attribute__((format(printf,1,2)));
B
bellard 已提交
73 74
extern CPUX86State *global_env;
void cpu_loop(CPUX86State *env);
B
bellard 已提交
75 76
void process_pending_signals(void *cpu_env);
void signal_init(void);
B
bellard 已提交
77
int queue_signal(int sig, target_siginfo_t *info);
B
bellard 已提交
78 79
void init_paths(const char *prefix);
const char *path(const char *pathname);
B
bellard 已提交
80 81

extern int loglevel;
B
bellard 已提交
82 83 84 85 86 87 88 89 90
extern FILE *logfile;

/* vm86.c */
void save_v86_state(CPUX86State *env);
void do_int(CPUX86State *env, int intno);
void handle_vm86_fault(CPUX86State *env);
int do_vm86(CPUX86State *env, long subfunction, 
            struct target_vm86plus_struct * target_v86);

91
#endif