From ec1c89d5ec92db83ac38fabf20c6bc5f3d2475e3 Mon Sep 17 00:00:00 2001 From: wuyangyong Date: Sat, 18 Feb 2012 14:49:46 +0000 Subject: [PATCH] add idle hook, in idle thread, cpu hlt. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1964 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/x86/applications/startup.c | 5 ----- bsp/x86/drivers/board.c | 13 ++++++++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bsp/x86/applications/startup.c b/bsp/x86/applications/startup.c index 1449b69de6..c4e50087a7 100644 --- a/bsp/x86/applications/startup.c +++ b/bsp/x86/applications/startup.c @@ -93,11 +93,6 @@ void rtthread_startup() finsh_set_device("console"); #endif -#ifdef RT_USING_HOOK - /* set idle thread hook */ - rt_thread_idle_sethook(RT_NULL); -#endif - /* init idle thread */ rt_thread_idle_init(); diff --git a/bsp/x86/drivers/board.c b/bsp/x86/drivers/board.c index 3aff852b59..8ec05b6747 100644 --- a/bsp/x86/drivers/board.c +++ b/bsp/x86/drivers/board.c @@ -26,7 +26,14 @@ static void rt_timer_handler(int vector) { rt_tick_increase(); +} + +#ifdef RT_USING_HOOK +static void idle_hook(void) +{ + asm volatile("sti; hlt": : :"memory"); } +#endif /** * This function will init QEMU @@ -41,7 +48,11 @@ void rt_hw_board_init(void) /* install interrupt handler */ rt_hw_interrupt_install(INTTIMER0, rt_timer_handler, RT_NULL); - rt_hw_interrupt_umask(INTTIMER0); + rt_hw_interrupt_umask(INTTIMER0); + +#ifdef RT_USING_HOOK + rt_thread_idle_sethook(idle_hook); +#endif } void restart(void)