1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the GNU General Public License version 2. Note that NO WARRANTY is provided.
8 * See "LICENSE_GPLv2.txt" for details.
9 *
10 * @TAG(DATA61_GPL)
11 */
12
13#include <config.h>
14#include <mode/machine.h>
15#include <api/debug.h>
16
17void idle_thread(void)
18{
19    while (1) {
20        wfi();
21    }
22}
23
24/** DONT_TRANSLATE */
25void NORETURN NO_INLINE VISIBLE halt(void)
26{
27    /* halt is actually, idle thread without the interrupts */
28    MSR("daif", (DAIF_DEBUG | DAIF_SERROR | DAIF_IRQ | DAIF_FIRQ));
29
30#ifdef CONFIG_PRINTING
31    printf("halting...");
32#ifdef CONFIG_DEBUG_BUILD
33    debug_printKernelEntryReason();
34#endif
35#endif
36    idle_thread();
37    UNREACHABLE();
38}
39