main.c (d9bbfea646e86426d549bd612cd9f91e49aa50c2) main.c (daa4374a04f9d6f6584f372f532d3e4aa9419255)
1/*
2 * qemu user main
3 *
4 * Copyright (c) 2003-2008 Fabrice Bellard
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 870 unchanged lines hidden (view full) ---

879 */
880 env->exclusive_addr = -1;
881 }
882}
883#endif /* ndef TARGET_ABI32 */
884
885#endif
886
1/*
2 * qemu user main
3 *
4 * Copyright (c) 2003-2008 Fabrice Bellard
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 870 unchanged lines hidden (view full) ---

879 */
880 env->exclusive_addr = -1;
881 }
882}
883#endif /* ndef TARGET_ABI32 */
884
885#endif
886
887#ifdef TARGET_UNICORE32
888
889void cpu_loop(CPUUniCore32State *env)
890{
891 CPUState *cs = CPU(uc32_env_get_cpu(env));
892 int trapnr;
893 unsigned int n, insn;
894 target_siginfo_t info;
895
896 for (;;) {
897 cpu_exec_start(cs);
898 trapnr = cpu_exec(cs);
899 cpu_exec_end(cs);
900 process_queued_cpu_work(cs);
901
902 switch (trapnr) {
903 case UC32_EXCP_PRIV:
904 {
905 /* system call */
906 get_user_u32(insn, env->regs[31] - 4);
907 n = insn & 0xffffff;
908
909 if (n >= UC32_SYSCALL_BASE) {
910 /* linux syscall */
911 n -= UC32_SYSCALL_BASE;
912 if (n == UC32_SYSCALL_NR_set_tls) {
913 cpu_set_tls(env, env->regs[0]);
914 env->regs[0] = 0;
915 } else {
916 abi_long ret = do_syscall(env,
917 n,
918 env->regs[0],
919 env->regs[1],
920 env->regs[2],
921 env->regs[3],
922 env->regs[4],
923 env->regs[5],
924 0, 0);
925 if (ret == -TARGET_ERESTARTSYS) {
926 env->regs[31] -= 4;
927 } else if (ret != -TARGET_QEMU_ESIGRETURN) {
928 env->regs[0] = ret;
929 }
930 }
931 } else {
932 goto error;
933 }
934 }
935 break;
936 case UC32_EXCP_DTRAP:
937 case UC32_EXCP_ITRAP:
938 info.si_signo = TARGET_SIGSEGV;
939 info.si_errno = 0;
940 /* XXX: check env->error_code */
941 info.si_code = TARGET_SEGV_MAPERR;
942 info._sifields._sigfault._addr = env->cp0.c4_faultaddr;
943 queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
944 break;
945 case EXCP_INTERRUPT:
946 /* just indicate that signals should be handled asap */
947 break;
948 case EXCP_DEBUG:
949 {
950 int sig;
951
952 sig = gdb_handlesig(cs, TARGET_SIGTRAP);
953 if (sig) {
954 info.si_signo = sig;
955 info.si_errno = 0;
956 info.si_code = TARGET_TRAP_BRKPT;
957 queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
958 }
959 }
960 break;
961 case EXCP_ATOMIC:
962 cpu_exec_step_atomic(cs);
963 break;
964 default:
965 goto error;
966 }
967 process_pending_signals(env);
968 }
969
970error:
971 EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
972 abort();
973}
974#endif
975
976#ifdef TARGET_SPARC
977#define SPARC64_STACK_BIAS 2047
978
979//#define DEBUG_WIN
980
981/* WARNING: dealing with register windows _is_ complicated. More info
982 can be found at http://www.sics.se/~psm/sparcstack.html */
983static inline int get_reg_index(CPUSPARCState *env, int cwp, int index)

--- 3748 unchanged lines hidden (view full) ---

4732 && (info->elf_flags & EF_ARM_BE8)) {
4733 env->uncached_cpsr |= CPSR_E;
4734 env->cp15.sctlr_el[1] |= SCTLR_E0E;
4735 } else {
4736 env->cp15.sctlr_el[1] |= SCTLR_B;
4737 }
4738#endif
4739 }
887#ifdef TARGET_SPARC
888#define SPARC64_STACK_BIAS 2047
889
890//#define DEBUG_WIN
891
892/* WARNING: dealing with register windows _is_ complicated. More info
893 can be found at http://www.sics.se/~psm/sparcstack.html */
894static inline int get_reg_index(CPUSPARCState *env, int cwp, int index)

--- 3748 unchanged lines hidden (view full) ---

4643 && (info->elf_flags & EF_ARM_BE8)) {
4644 env->uncached_cpsr |= CPSR_E;
4645 env->cp15.sctlr_el[1] |= SCTLR_E0E;
4646 } else {
4647 env->cp15.sctlr_el[1] |= SCTLR_B;
4648 }
4649#endif
4650 }
4740#elif defined(TARGET_UNICORE32)
4741 {
4742 int i;
4743 cpu_asr_write(env, regs->uregs[32], 0xffffffff);
4744 for (i = 0; i < 32; i++) {
4745 env->regs[i] = regs->uregs[i];
4746 }
4747 }
4748#elif defined(TARGET_SPARC)
4749 {
4750 int i;
4751 env->pc = regs->pc;
4752 env->npc = regs->npc;
4753 env->y = regs->y;
4754 for(i = 0; i < 8; i++)
4755 env->gregs[i] = regs->u_regs[i];

--- 213 unchanged lines hidden (view full) ---

4969 }
4970 env->iaoq_f = regs->iaoq[0];
4971 env->iaoq_b = regs->iaoq[1];
4972 }
4973#else
4974#error unsupported target CPU
4975#endif
4976
4651#elif defined(TARGET_SPARC)
4652 {
4653 int i;
4654 env->pc = regs->pc;
4655 env->npc = regs->npc;
4656 env->y = regs->y;
4657 for(i = 0; i < 8; i++)
4658 env->gregs[i] = regs->u_regs[i];

--- 213 unchanged lines hidden (view full) ---

4872 }
4873 env->iaoq_f = regs->iaoq[0];
4874 env->iaoq_b = regs->iaoq[1];
4875 }
4876#else
4877#error unsupported target CPU
4878#endif
4879
4977#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32)
4880#if defined(TARGET_ARM) || defined(TARGET_M68K)
4978 ts->stack_base = info->start_stack;
4979 ts->heap_base = info->brk;
4980 /* This will be filled in on the first SYS_HEAPINFO call. */
4981 ts->heap_limit = 0;
4982#endif
4983
4984 if (gdbstub_port) {
4985 if (gdbserver_start(gdbstub_port) < 0) {
4986 fprintf(stderr, "qemu: could not open gdbserver on port %d\n",
4987 gdbstub_port);
4988 exit(EXIT_FAILURE);
4989 }
4990 gdb_handlesig(cpu, 0);
4991 }
4992 cpu_loop(env);
4993 /* never exits */
4994 return 0;
4995}
4881 ts->stack_base = info->start_stack;
4882 ts->heap_base = info->brk;
4883 /* This will be filled in on the first SYS_HEAPINFO call. */
4884 ts->heap_limit = 0;
4885#endif
4886
4887 if (gdbstub_port) {
4888 if (gdbserver_start(gdbstub_port) < 0) {
4889 fprintf(stderr, "qemu: could not open gdbserver on port %d\n",
4890 gdbstub_port);
4891 exit(EXIT_FAILURE);
4892 }
4893 gdb_handlesig(cpu, 0);
4894 }
4895 cpu_loop(env);
4896 /* never exits */
4897 return 0;
4898}