board.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. /**
  27. * This function will init QEMU
  28. *
  29. */
  30. void rt_hw_board_init(void)
  31. {
  32. /* initialize 8253 clock to interrupt 100 times/sec */
  33. outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT);
  34. outb(IO_TIMER1, TIMER_DIV(100) % 256);
  35. outb(IO_TIMER1, TIMER_DIV(100) / 256);
  36. /* install interrupt handler */
  37. rt_hw_interrupt_install(INTTIMER0, rt_timer_handler, RT_NULL);
  38. rt_hw_interrupt_umask(INTTIMER0);
  39. }
  40. #ifdef RT_USING_FINSH
  41. extern void finsh_notify(void);
  42. static void rt_serial_isr(int vector)
  43. {
  44. finsh_notify();
  45. }
  46. /**
  47. * This function will init hardware related in finsh shell
  48. */
  49. void rt_hw_finsh_init()
  50. {
  51. /* install UART isr */
  52. rt_hw_interrupt_install(INTUART0_RX, rt_serial_isr, RT_NULL);
  53. rt_hw_interrupt_umask(INTUART0_RX);
  54. /* install keyboard isr */
  55. rt_hw_interrupt_install(INTKEYBOARD, rt_serial_isr, RT_NULL);
  56. rt_hw_interrupt_umask(INTKEYBOARD);
  57. }
  58. #endif
  59. /*@}*/