4 * Copyright (c) 2003-2008 Fabrice Bellard
5 * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "qemu/osdep.h"
23 #include "cpu_loop-common.h"
26 void cpu_loop(CPUHexagonState
*env
)
28 CPUState
*cs
= CPU(hexagon_env_get_cpu(env
));
29 int trapnr
, signum
, sigcode
;
31 target_ulong syscallnum
;
36 trapnr
= cpu_exec(cs
);
38 process_queued_cpu_work(cs
);
46 /* just indicate that signals should be handled asap */
49 syscallnum
= env
->gpr
[6];
50 env
->gpr
[HEX_REG_PC
] += 4;
60 if (ret
== -TARGET_ERESTARTSYS
) {
61 env
->gpr
[HEX_REG_PC
] -= 4;
62 } else if (ret
!= -TARGET_QEMU_ESIGRETURN
) {
66 case HEX_EXCP_FETCH_NO_UPAGE
:
67 case HEX_EXCP_PRIV_NO_UREAD
:
68 case HEX_EXCP_PRIV_NO_UWRITE
:
69 signum
= TARGET_SIGSEGV
;
70 sigcode
= TARGET_SEGV_MAPERR
;
73 cpu_exec_step_atomic(cs
);
76 EXCP_DUMP(env
, "\nqemu: unhandled CPU exception %#x - aborting\n",
82 target_siginfo_t info
= {
86 ._sifields
._sigfault
._addr
= sigaddr
88 queue_signal(env
, info
.si_signo
, QEMU_SI_KILL
, &info
);
91 process_pending_signals(env
);
95 void target_cpu_copy_regs(CPUArchState
*env
, struct target_pt_regs
*regs
)
97 env
->gpr
[HEX_REG_PC
] = regs
->sepc
;
98 env
->gpr
[HEX_REG_SP
] = regs
->sp
;
99 env
->gpr
[HEX_REG_USR
] = 0x56000;