summaryrefslogtreecommitdiff
path: root/bsp/x86
diff options
context:
space:
mode:
authorwuyangyong <[email protected]>2012-02-18 14:49:46 +0000
committerwuyangyong <[email protected]>2012-02-18 14:49:46 +0000
commitec1c89d5ec92db83ac38fabf20c6bc5f3d2475e3 (patch)
treeb8a28ec024c1cd59137636cfb0c22d5f2740e21f /bsp/x86
parent017e673c179ae2187fa43ac5561a5969a7c68018 (diff)
add idle hook, in idle thread, cpu hlt.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1964 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'bsp/x86')
-rw-r--r--bsp/x86/applications/startup.c5
-rw-r--r--bsp/x86/drivers/board.c13
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)