1 /* 2 * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 * 4 * SPDX-License-Identifier: GPL-2.0-only 5 */ 6 7 #include <config.h> 8 #include <api/debug.h> 9 10 /* 11 * The idle thread does not have a dedicated stack and runs in 12 * the context of the idle thread TCB. Make sure that the compiler 13 * always eliminates the function prologue by declaring the 14 * idle_thread with the naked attribute. 15 */ idle_thread(void)16__attribute__((naked)) NORETURN void idle_thread(void) 17 { 18 /* We cannot use for-loop or while-loop here because they may 19 * involve stack manipulations (the compiler will not allow 20 * them in a naked function anyway). */ 21 asm volatile( 22 "1: hlt\n" 23 "jmp 1b" 24 ); 25 } 26 27 /** DONT_TRANSLATE */ halt(void)28void VISIBLE halt(void) 29 { 30 /* halt is actually, idle thread without the interrupts */ 31 asm volatile("cli"); 32 33 #ifdef CONFIG_PRINTING 34 printf("halting..."); 35 #ifdef CONFIG_DEBUG_BUILD 36 debug_printKernelEntryReason(); 37 #endif 38 #endif 39 idle_thread(); 40 UNREACHABLE(); 41 } 42