2323#include <limits.h>
2424
2525#define DRAM_MAP_START KERNEL_BOOT_ADDR
26- #define DRAM_MAP_SIZE (64 * 1024 * 1024 ) // part of DRAM
26+ #define DRAM_MAP_SIZE MB_SIZE(256 ) // part of DRAM
2727
2828#define MEM_DESC (vaddr_start , size , paddr_start , attr ) \
2929 vaddr_start, (vaddr_start + size - 1uL), paddr_start, attr
3030
31- static volatile unsigned long MMUTable [512 * 4 ] __attribute__((aligned (4 * 1024 )));
31+ // static volatile unsigned long MMUTable[512*2] __attribute__((aligned(4 * 1024)));
32+ extern volatile unsigned long MMUTable [];
3233
33- struct mem_desc platform_mem_desc [] = {
34- {MEM_DESC (DRAM_MAP_START , DRAM_MAP_SIZE , DRAM_MAP_START , NORMAL_MEM )},
35- // {MEM_DESC(LPUART1_BASE, LPUART1_SIZE, LPUART1_BASE , DEVICE_MEM)}, // 0x4438_0000
36- // {MEM_DESC(CCM_CTRL_BASE, CCM_CTRL_SIZE, CCM_CTRL_BASE , DEVICE_MEM)}, // 0x4445_8000
37- // {MEM_DESC(GIC_DISTRIBUTOR_BASE, GIC_DISTRIBUTOR_SIZE, GIC_DISTRIBUTOR_BASE , DEVICE_MEM)}, // 0x4800_0000
38- // {MEM_DESC(GIC_REDISTRIBUTOR_BASE, GIC_REDISTRIBUTOR_SIZE, GIC_REDISTRIBUTOR_BASE, DEVICE_MEM )}, // 0x4804_0000
34+ static struct mem_desc platform_mem_desc [] = {
35+ {MEM_DESC (LPUART1_BASE , LPUART1_SIZE , LPUART1_BASE , DEVICE_MEM )}, // 0x4438_0000
36+ {MEM_DESC (CCM_CTRL_BASE , CCM_CTRL_SIZE , CCM_CTRL_BASE , DEVICE_MEM )}, // 0x4445_8000
37+ {MEM_DESC (GIC_DISTRIBUTOR_BASE , GIC_DISTRIBUTOR_SIZE , GIC_DISTRIBUTOR_BASE , DEVICE_MEM )}, // 0x4800_0000
38+ {MEM_DESC (GIC_REDISTRIBUTOR_BASE , GIC_REDISTRIBUTOR_SIZE , GIC_REDISTRIBUTOR_BASE , DEVICE_MEM )}, // 0x4804_0000
39+ {MEM_DESC (DRAM_MAP_START , DRAM_MAP_SIZE , DRAM_MAP_START , NORMAL_MEM )}, // 0x8000_0000
3940};
4041
41- const rt_uint32_t platform_mem_desc_size = sizeof (platform_mem_desc )/sizeof (platform_mem_desc [0 ]);
42+ static const rt_uint32_t platform_mem_desc_size = sizeof (platform_mem_desc )/sizeof (platform_mem_desc [0 ]);
4243
43- rt_region_t init_page_region = {
44- (rt_size_t )PAGE_START ,
45- (rt_size_t )PAGE_END ,
46- };
44+ static rt_region_t init_page_region ;
4745
4846static rt_base_t get_sctlr_el1 ()
4947{
@@ -57,18 +55,21 @@ static rt_base_t get_sctlr_el1()
5755 */
5856void rt_hw_board_init (void )
5957{
58+ rt_hw_earlycon_ioremap ();
59+ rt_hw_earlycon_print_hex ("sctlr_el1: " , get_sctlr_el1 ());
6060 rt_hw_mmu_map_init (& rt_kernel_space , (void * )0x080000000000 , 0x10000000 , (size_t * ) MMUTable , 0 );
61+
62+ init_page_region .start = BOARD_PAGE_START ;
63+ init_page_region .end = BOARD_PAGE_END ;
6164 rt_page_init (init_page_region );
65+
6266 rt_hw_mmu_setup (& rt_kernel_space , platform_mem_desc , platform_mem_desc_size );
6367
64- #ifdef RT_USING_HEAP
68+ #ifdef RT_USING_HEAP
6569 /* initialize system heap */
66- rt_system_heap_init ((void * )HEAP_BEGIN , (void * )HEAP_END );
70+ rt_system_heap_init ((void * )BOARD_HEAP_BEGIN , (void * )BOARD_HEAP_END );
6771#endif
6872
69- /* map LPUART1/CCM_CTRL/GIC_DISTRIBUTOR/GIC_REDISTRIBUTOR virtual address to equals physical address */
70- rt_ioremap_early ((void * )LPUART1_BASE , GIC_REDISTRIBUTOR_BASE + GIC_REDISTRIBUTOR_SIZE - LPUART1_BASE );
71-
7273 /* initialize hardware interrupt */
7374 rt_hw_interrupt_init ();
7475
@@ -80,7 +81,6 @@ void rt_hw_board_init(void)
8081
8182 rt_components_board_init ();
8283 rt_console_set_device (RT_CONSOLE_DEVICE_NAME );
83- rt_kprintf ("[rt_hw_board_init] rt_kprintf works!\n" );
8484}
8585
8686/*@}*/
0 commit comments