aboutsummaryrefslogtreecommitdiff
path: root/linux-user/main.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-03-22 17:31:38 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-03-22 17:31:38 +0000
commit1b6b029e40c4297ce9c27e0f8b8ae177085c990a (patch)
treeffcae72b2e16e395ec983f3718adcf9a981b9a66 /linux-user/main.c
parent612384d77146639cebdc9b71c87ee4a94bf44501 (diff)
basic clone() support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@40 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user/main.c')
-rw-r--r--linux-user/main.c68
1 files changed, 36 insertions, 32 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index 3222629b27..cd08c474c4 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -104,6 +104,40 @@ void write_dt(void *ptr, unsigned long addr, unsigned long limit,
uint64_t gdt_table[6];
+void cpu_loop(struct CPUX86State *env)
+{
+ for(;;) {
+ int err;
+ uint8_t *pc;
+
+ err = cpu_x86_exec(env);
+ pc = env->seg_cache[R_CS].base + env->eip;
+ switch(err) {
+ case EXCP0D_GPF:
+ if (pc[0] == 0xcd && pc[1] == 0x80) {
+ /* syscall */
+ env->eip += 2;
+ env->regs[R_EAX] = do_syscall(env,
+ env->regs[R_EAX],
+ env->regs[R_EBX],
+ env->regs[R_ECX],
+ env->regs[R_EDX],
+ env->regs[R_ESI],
+ env->regs[R_EDI],
+ env->regs[R_EBP]);
+ } else {
+ goto trap_error;
+ }
+ break;
+ default:
+ trap_error:
+ fprintf(stderr, "0x%08lx: Unknown exception %d, aborting\n",
+ (long)pc, err);
+ abort();
+ }
+ }
+}
+
void usage(void)
{
printf("gemu version " GEMU_VERSION ", Copyright (c) 2003 Fabrice Bellard\n"
@@ -113,8 +147,6 @@ void usage(void)
exit(1);
}
-
-
int main(int argc, char **argv)
{
const char *filename;
@@ -193,35 +225,7 @@ int main(int argc, char **argv)
cpu_x86_load_seg(env, R_FS, __USER_DS);
cpu_x86_load_seg(env, R_GS, __USER_DS);
- for(;;) {
- int err;
- uint8_t *pc;
-
- err = cpu_x86_exec(env);
- pc = env->seg_cache[R_CS].base + env->eip;
- switch(err) {
- case EXCP0D_GPF:
- if (pc[0] == 0xcd && pc[1] == 0x80) {
- /* syscall */
- env->eip += 2;
- env->regs[R_EAX] = do_syscall(env,
- env->regs[R_EAX],
- env->regs[R_EBX],
- env->regs[R_ECX],
- env->regs[R_EDX],
- env->regs[R_ESI],
- env->regs[R_EDI],
- env->regs[R_EBP]);
- } else {
- goto trap_error;
- }
- break;
- default:
- trap_error:
- fprintf(stderr, "0x%08lx: Unknown exception %d, aborting\n",
- (long)pc, err);
- abort();
- }
- }
+ cpu_loop(env);
+ /* never exits */
return 0;
}