board.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 "exception.h"
  14. #include "drv_uart.h"
  15. #include "board.h"
  16. /**
  17. * this function will reset CPU
  18. *
  19. */
  20. void rt_hw_cpu_reset(void)
  21. {
  22. rt_kprintf("reboot system...\n");
  23. while (1);
  24. }
  25. /**
  26. * this function will shutdown CPU
  27. *
  28. */
  29. void rt_hw_cpu_shutdown(void)
  30. {
  31. rt_kprintf("shutdown...\n");
  32. while (1);
  33. }
  34. /**
  35. * This is the timer interrupt service routine.
  36. */
  37. void rt_hw_timer_handler(void)
  38. {
  39. unsigned int count;
  40. count = read_c0_compare();
  41. write_c0_compare(count);
  42. write_c0_count(0);
  43. /* increase a OS tick */
  44. rt_tick_increase();
  45. }
  46. /**
  47. * This function will initial OS timer
  48. */
  49. void rt_hw_timer_init(void)
  50. {
  51. write_c0_compare(CPU_HZ/2/RT_TICK_PER_SECOND);
  52. write_c0_count(0);
  53. mips_unmask_cpu_irq(7);
  54. }
  55. /**
  56. * Board level initialization
  57. */
  58. void rt_hw_board_init(void)
  59. {
  60. rt_hw_exception_init();
  61. /* init hardware interrupt */
  62. rt_hw_interrupt_init();
  63. #ifdef RT_USING_FPU
  64. /* init hardware fpu */
  65. rt_hw_fpu_init();
  66. #endif
  67. #ifdef RT_USING_SERIAL
  68. /* init hardware UART device */
  69. rt_hw_uart_init();
  70. /* set console device */
  71. rt_console_set_device("uart");
  72. #endif
  73. #ifdef RT_USING_HEAP
  74. rt_system_heap_init((void*)RT_HW_HEAP_BEGIN, (void*)RT_HW_HEAP_END);
  75. #endif
  76. /* init operating system timer */
  77. rt_hw_timer_init();
  78. #ifdef RT_USING_COMPONENTS_INIT
  79. rt_components_board_init();
  80. #endif
  81. rt_kprintf("Current SR: 0x%08x\n", read_c0_status());
  82. }