board.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) 2006-2020, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-04-05 bigmagic Initial version
  9. */
  10. #include <rtthread.h>
  11. #include <rthw.h>
  12. #include "mips_regs.h"
  13. #include "mips_fpu.h"
  14. #include "exception.h"
  15. #include "drv_uart.h"
  16. #include "board.h"
  17. /**
  18. * this function will reset CPU
  19. *
  20. */
  21. void rt_hw_cpu_reset(void)
  22. {
  23. rt_kprintf("reboot system...\n");
  24. while (1);
  25. }
  26. /**
  27. * this function will shutdown CPU
  28. *
  29. */
  30. void rt_hw_cpu_shutdown(void)
  31. {
  32. rt_kprintf("shutdown...\n");
  33. while (1);
  34. }
  35. /**
  36. * This is the timer interrupt service routine.
  37. */
  38. void rt_hw_timer_handler(void)
  39. {
  40. unsigned int count;
  41. count = read_c0_compare();
  42. write_c0_compare(count);
  43. write_c0_count(0);
  44. /* increase a OS tick */
  45. rt_tick_increase();
  46. }
  47. /**
  48. * This function will initial OS timer
  49. */
  50. void rt_hw_timer_init(void)
  51. {
  52. write_c0_compare(CPU_HZ/2/RT_TICK_PER_SECOND);
  53. write_c0_count(0);
  54. mips_unmask_cpu_irq(7);
  55. }
  56. /**
  57. * Board level initialization
  58. */
  59. void rt_hw_board_init(void)
  60. {
  61. rt_hw_exception_init();
  62. /* init hardware interrupt */
  63. rt_hw_interrupt_init();
  64. #ifdef RT_USING_FPU
  65. /* init hardware fpu */
  66. rt_hw_fpu_init();
  67. #endif
  68. #ifdef RT_USING_SERIAL
  69. /* init hardware UART device */
  70. rt_hw_uart_init();
  71. /* set console device */
  72. rt_console_set_device("uart");
  73. #endif
  74. #ifdef RT_USING_HEAP
  75. rt_system_heap_init((void*)RT_HW_HEAP_BEGIN, (void*)RT_HW_HEAP_END);
  76. #endif
  77. /* init operating system timer */
  78. rt_hw_timer_init();
  79. #ifdef RT_USING_COMPONENTS_INIT
  80. rt_components_board_init();
  81. #endif
  82. rt_kprintf("Current SR: 0x%08x\n", read_c0_status());
  83. }