board.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-01-30 lizhirui first version
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include <rtdevice.h>
  13. #include "board.h"
  14. #include "tick.h"
  15. #include "drv_uart.h"
  16. #include "encoding.h"
  17. #include "stack.h"
  18. #include "riscv.h"
  19. #include "stack.h"
  20. #include "riscv_io.h"
  21. #include "plic.h"
  22. #include "interrupt.h"
  23. #ifdef CONFIG_RISCV_S_MODE
  24. #include "sbi.h"
  25. #endif
  26. void primary_cpu_entry(void)
  27. {
  28. extern void entry(void);
  29. /* disable global interrupt */
  30. rt_memset(&__bss_start, 0x0, (rt_uint8_t*)&__bss_end - (rt_uint8_t*)&__bss_start);
  31. rt_hw_interrupt_disable();
  32. entry();
  33. }
  34. void rt_hw_board_init(void)
  35. {
  36. /* initalize interrupt */
  37. rt_hw_interrupt_init();
  38. /* initialize hardware interrupt */
  39. rt_hw_uart_init();
  40. #ifdef RT_USING_HEAP
  41. /* initialize memory system */
  42. rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
  43. #endif
  44. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  45. /* set console device */
  46. rt_console_set_device("uart");
  47. #endif
  48. rt_hw_tick_init();
  49. rt_kprintf("heap: [0x%08x - 0x%08x]\n", (rt_ubase_t) RT_HW_HEAP_BEGIN, (rt_ubase_t) RT_HW_HEAP_END);
  50. #ifdef RT_USING_COMPONENTS_INIT
  51. rt_components_board_init();
  52. #endif
  53. }
  54. #ifdef CONFIG_RISCV_S_MODE
  55. static void cmd_shutdown(void)
  56. {
  57. sbi_shutdown();
  58. while(1);
  59. }
  60. MSH_CMD_EXPORT_ALIAS(cmd_shutdown, shutdown, shutdown qemu-virt64);
  61. #endif