MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_hw_common_setup

Function rt_hw_common_setup

libcpu/aarch64/common/setup.c:202–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202void rt_hw_common_setup(void)
203{
204 rt_size_t kernel_start, kernel_end;
205 rt_size_t heap_start, heap_end;
206 rt_size_t init_page_start, init_page_end;
207 rt_size_t fdt_start, fdt_end;
208 rt_region_t init_page_region = { 0 };
209 rt_region_t platform_mem_region = { 0 };
210 static struct mem_desc platform_mem_desc;
211 const rt_ubase_t pv_off = PV_OFFSET;
212
213 system_vectors_init();
214
215#ifdef RT_USING_SMART
216 rt_hw_mmu_map_init(&rt_kernel_space, (void*)0xfffffffff0000000, 0x10000000, MMUTable, pv_off);
217#else
218 rt_hw_mmu_map_init(&rt_kernel_space, (void*)0xffffd0000000, 0x10000000, MMUTable, 0);
219#endif
220
221 kernel_start = RT_ALIGN_DOWN((rt_size_t)rt_kmem_v2p((void *)&_start) - 64, ARCH_PAGE_SIZE);
222 kernel_end = RT_ALIGN((rt_size_t)rt_kmem_v2p((void *)&_end), ARCH_PAGE_SIZE);
223 heap_start = kernel_end;
224 heap_end = RT_ALIGN(heap_start + ARCH_HEAP_SIZE, ARCH_PAGE_SIZE);
225 init_page_start = heap_end;
226 init_page_end = RT_ALIGN(init_page_start + ARCH_INIT_PAGE_SIZE, ARCH_PAGE_SIZE);
227 fdt_start = init_page_end;
228 fdt_end = RT_ALIGN(fdt_start + fdt_size, ARCH_PAGE_SIZE);
229
230 platform_mem_region.start = kernel_start;
231 platform_mem_region.end = fdt_end;
232
233 rt_memblock_reserve_memory("kernel", kernel_start, kernel_end, MEMBLOCK_NONE);
234 rt_memblock_reserve_memory("memheap", heap_start, heap_end, MEMBLOCK_NONE);
235 rt_memblock_reserve_memory("init-page", init_page_start, init_page_end, MEMBLOCK_NONE);
236 rt_memblock_reserve_memory("fdt", fdt_start, fdt_end, MEMBLOCK_NONE);
237
238 /* To virtual address */
239 fdt_ptr = (void *)(fdt_ptr - pv_off);
240#ifdef KERNEL_VADDR_START
241 if ((rt_ubase_t)fdt_ptr + fdt_size - KERNEL_VADDR_START > SIZE_GB)
242 {
243 fdt_ptr = rt_ioremap_early(fdt_ptr + pv_off, fdt_size);
244
245 RT_ASSERT(fdt_ptr != RT_NULL);
246 }
247#endif
248 rt_memmove((void *)(fdt_start - pv_off), fdt_ptr, fdt_size);
249 fdt_ptr = (void *)fdt_start - pv_off;
250
251 rt_system_heap_init((void *)(heap_start - pv_off), (void *)(heap_end - pv_off));
252
253 init_page_region.start = init_page_start - pv_off;
254 init_page_region.end = init_page_end - pv_off;
255 rt_page_init(init_page_region);
256
257 /* create MMU mapping of kernel memory */
258 platform_mem_region.start = RT_ALIGN_DOWN(platform_mem_region.start, ARCH_PAGE_SIZE);
259 platform_mem_region.end = RT_ALIGN(platform_mem_region.end, ARCH_PAGE_SIZE);

Callers 4

rt_hw_board_initFunction · 0.85
rt_hw_board_initFunction · 0.85
rt_hw_board_initFunction · 0.85
rt_hw_board_initFunction · 0.85

Calls 15

system_vectors_initFunction · 0.85
rt_kmem_v2pFunction · 0.85
rt_memmoveFunction · 0.85
rt_system_heap_initFunction · 0.85
rt_page_initFunction · 0.85
rt_fdt_prefetchFunction · 0.85
rt_fdt_scan_initrdFunction · 0.85
rt_fdt_scan_memoryFunction · 0.85
rt_fdt_earlycon_kickFunction · 0.85

Tested by

no test coverage detected