Explorar o código

add idle hook, in idle thread, cpu hlt.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1964 bbd45198-f89e-11dd-88c7-29a3b14d5316
wuyangyong %!s(int64=13) %!d(string=hai) anos
pai
achega
ec1c89d5ec
Modificáronse 2 ficheiros con 12 adicións e 6 borrados
  1. 0 5
      bsp/x86/applications/startup.c
  2. 12 1
      bsp/x86/drivers/board.c

+ 0 - 5
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();
 

+ 12 - 1
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)