board.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.fayfayspace.org/license/LICENSE.
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2006-09-15 QiuYi the first version
  13. * 2006-10-10 Bernard add hardware related of finsh
  14. */
  15. #include <rtthread.h>
  16. #include <rthw.h>
  17. #include <bsp.h>
  18. /**
  19. * @addtogroup QEMU
  20. */
  21. /*@{*/
  22. static void rt_timer_handler(int vector, void* param)
  23. {
  24. rt_tick_increase();
  25. }
  26. #ifdef RT_USING_HOOK
  27. static void idle_hook(void)
  28. {
  29. asm volatile("sti; hlt": : :"memory");
  30. }
  31. #endif
  32. /**
  33. * This function will init QEMU
  34. *
  35. */
  36. void rt_hw_board_init(void)
  37. {
  38. /* initialize 8253 clock to interrupt 1000 times/sec */
  39. outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT);
  40. outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) % 256);
  41. outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) / 256);
  42. /* install interrupt handler */
  43. rt_hw_interrupt_install(INTTIMER0, rt_timer_handler, RT_NULL, "tick");
  44. rt_hw_interrupt_umask(INTTIMER0);
  45. #ifdef RT_USING_HOOK
  46. rt_thread_idle_sethook(idle_hook);
  47. #endif
  48. }
  49. void restart(void)
  50. {
  51. outb(KBSTATP, 0xFE); /* pulse reset low */
  52. while(1);
  53. }
  54. #ifdef RT_USING_FINSH
  55. #include <finsh.h>
  56. FINSH_FUNCTION_EXPORT(restart, reboot PC)
  57. void reboot(void)
  58. {
  59. restart();
  60. }
  61. FINSH_FUNCTION_EXPORT(reboot, reboot PC)
  62. #endif
  63. #ifdef RT_USING_DFS
  64. #include <time.h>
  65. time_t time(time_t* tm)
  66. {
  67. (void)tm;
  68. return 0;
  69. }
  70. #endif
  71. /*@}*/