Adding upstream version 4.00~pre55+dfsg.
[syslinux-debian/hramrach.git] / core / idle.c
blob3f57393b3d72d1c9b71aaa18f1ddddfa8f5f3516
1 /* -*- fundamental -*- ---------------------------------------------------
3 * Copyright 2008 H. Peter Anvin - All Rights Reserved
4 * Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
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, Inc., 51 Franklin St, Fifth Floor,
9 * Boston MA 02110-1301, USA; either version 2 of the License, or
10 * (at your option) any later version; incorporated herein by reference.
12 * ----------------------------------------------------------------------- */
15 * idle.c:
17 * This function provided protected-mode access to the idle handling.
18 * It needs to be carefully coordinated with idle.inc, which provides
19 * idle services to real-mode code.
22 #include "core.h"
23 #include <sys/cpu.h>
25 #define TICKS_TO_IDLE 4 /* Also in idle.inc */
27 extern uint32_t _IdleTimer;
28 extern uint16_t NoHalt;
30 int (*idle_hook_func)(void);
32 void reset_idle(void)
34 _IdleTimer = jiffies();
37 void __idle(void)
39 if (jiffies() - _IdleTimer < TICKS_TO_IDLE)
40 return;
42 if (idle_hook_func && idle_hook_func())
43 return; /* Nonzero return = do not idle */
45 if (NoHalt)
46 cpu_relax();
47 else
48 hlt();