board.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) 2006-2024, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-04-11 liYony the first version
  9. */
  10. #include <mmu.h>
  11. #include <board.h>
  12. #include <mm_aspace.h>
  13. #include <mm_page.h>
  14. #include <drv_uart.h>
  15. #include <gtimer.h>
  16. extern size_t MMUTable[];
  17. #ifdef RT_USING_SMART
  18. struct mem_desc platform_mem_desc[] = {
  19. {KERNEL_VADDR_START, KERNEL_VADDR_START + 0x7FF00000 - 1, (rt_size_t)ARCH_MAP_FAILED, NORMAL_MEM}
  20. };
  21. #else
  22. struct mem_desc platform_mem_desc[] =
  23. {
  24. {0x00200000, 0x7FF00000 - 1, 0x00200000, NORMAL_MEM},
  25. {GIC400_DISTRIBUTOR_PPTR, GIC400_DISTRIBUTOR_PPTR + GIC400_SIZE - 1, GIC400_DISTRIBUTOR_PPTR, DEVICE_MEM},
  26. {GIC400_CONTROLLER_PPTR, GIC400_CONTROLLER_PPTR + GIC400_SIZE - 1, GIC400_CONTROLLER_PPTR, DEVICE_MEM},
  27. };
  28. #endif
  29. const rt_uint32_t platform_mem_desc_size = sizeof(platform_mem_desc) / sizeof(platform_mem_desc[0]);
  30. void idle_wfi(void)
  31. {
  32. asm volatile("wfi");
  33. }
  34. void rt_hw_board_init(void)
  35. {
  36. #ifdef RT_USING_SMART
  37. rt_hw_mmu_map_init(&rt_kernel_space, (void *)0xfffffffff0000000, 0x10000000, MMUTable, PV_OFFSET);
  38. #else
  39. rt_hw_mmu_map_init(&rt_kernel_space, (void *)0xffffd0000000, 0x10000000, MMUTable, 0);
  40. #endif
  41. rt_region_t init_page_region;
  42. init_page_region.start = PAGE_START;
  43. init_page_region.end = PAGE_END;
  44. rt_page_init(init_page_region);
  45. rt_hw_mmu_setup(&rt_kernel_space, platform_mem_desc, platform_mem_desc_size);
  46. #ifdef RT_USING_HEAP
  47. /* initialize system heap */
  48. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  49. #endif
  50. /* initialize hardware interrupt */
  51. rt_hw_interrupt_init();
  52. /* initialize uart */
  53. rt_hw_uart_init();
  54. /* initialize timer for os tick */
  55. rt_hw_gtimer_init();
  56. rt_thread_idle_sethook(idle_wfi);
  57. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  58. /* set console device */
  59. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  60. #endif
  61. rt_kprintf("heap: [0x%08x - 0x%08x]\n", HEAP_BEGIN, HEAP_END);
  62. #ifdef RT_USING_COMPONENTS_INIT
  63. rt_components_board_init();
  64. #endif
  65. }