@samitouri / QOSamiQemu / commits / 69b2651517

target/hexagon: Implement start/stop helpers, soft reset

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>

Brian Cain committed Jun 22, 2026 at 15:28 UTC 69b265151751e2f69e2f1f321e69e247f3c63fc2
3 files changed +36 -3
target/hexagon/cpu.c
+25 -1
@@ -33,6 +33,7 @@
33 #ifndef CONFIG_USER_ONLY
34 #include "sys_macros.h"
35 #include "accel/tcg/cpu-ldst.h"
36 +#include "qemu/main-loop.h"
37 #endif
38
39 static ObjectClass *hexagon_cpu_class_by_name(const char *cpu_model)
@@ -310,6 +311,28 @@ static void hexagon_restore_state_to_opc(CPUState *cs,
311 }
312
313
314 +#ifndef CONFIG_USER_ONLY
315 +void hexagon_cpu_soft_reset(CPUHexagonState *env)
316 +{
317 + HexagonCPU *cpu;
318 +
319 + BQL_LOCK_GUARD();
320 + env->t_sreg[HEX_SREG_SSR] = 0;
321 + hexagon_ssr_set_cause(env, HEX_CAUSE_RESET);
322 +
323 + cpu = env_archcpu(env);
324 + if (cpu->globalregs) {
325 + uint32_t evb =
326 + hexagon_globalreg_read(cpu->globalregs, HEX_SREG_EVB,
327 + env->threadId);
328 + env->gpr[HEX_REG_PC] = evb;
329 + } else {
330 + env->gpr[HEX_REG_PC] = cpu->boot_addr;
331 + }
332 +}
333 +#endif
334 +
335 +
336 static void hexagon_cpu_reset_hold(Object *obj, ResetType type)
337 {
338 CPUState *cs = CPU(obj);
@@ -339,9 +362,10 @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type)
362
363 env->t_sreg[HEX_SREG_HTID] = cpu->htid;
364 env->threadId = cpu->htid;
365 + hexagon_cpu_soft_reset(env);
366 + env->cause_code = HEX_EVENT_NONE;
367 env->gpr[HEX_REG_PC] = cpu->boot_addr;
368 #endif
344 - env->cause_code = HEX_EVENT_NONE;
369 }
370
371 static void hexagon_cpu_disas_set_info(const CPUState *cs,
target/hexagon/cpu.h
+9
@@ -213,6 +213,15 @@ G_NORETURN void hexagon_raise_exception_err(CPUHexagonState *env,
213 uint32_t exception,
214 uintptr_t pc);
215
216 +#ifndef CONFIG_USER_ONLY
217 +/*
218 + * @return true if the @a thread_env hardware thread is
219 + * not stopped.
220 + */
221 +bool hexagon_thread_is_enabled(CPUHexagonState *thread_env);
222 +void hexagon_cpu_soft_reset(CPUHexagonState *env);
223 +#endif
224 +
225 typedef HexagonCPU ArchCPU;
226
227 void hexagon_translate_init(void);
target/hexagon/op_helper.c
+2 -2
@@ -1479,12 +1479,12 @@ uint32_t HELPER(iassignr)(CPUHexagonState *env, uint32_t src)
1479
1480 void HELPER(start)(CPUHexagonState *env, uint32_t imask)
1481 {
1482 - g_assert_not_reached();
1482 + hexagon_start_threads(env, imask);
1483 }
1484
1485 void HELPER(stop)(CPUHexagonState *env)
1486 {
1487 - g_assert_not_reached();
1487 + hexagon_stop_thread(env);
1488 }
1489
1490 void HELPER(wait)(CPUHexagonState *env, target_ulong PC)