board.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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)
  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);
  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. /*@}*/