1 // SPDX-License-Identifier: GPL-2.0 1 2 // Copyright (C) 2018 Hangzhou C-SKY Microsyst 3 4 #include <linux/console.h> 5 #include <linux/memblock.h> 6 #include <linux/initrd.h> 7 #include <linux/of.h> 8 #include <linux/of_fdt.h> 9 #include <linux/start_kernel.h> 10 #include <linux/dma-map-ops.h> 11 #include <asm/sections.h> 12 #include <asm/mmu_context.h> 13 #include <asm/pgalloc.h> 14 15 static void __init csky_memblock_init(void) 16 { 17 unsigned long lowmem_size = PFN_DOWN(L 18 unsigned long sseg_size = PFN_DOWN(SSE 19 unsigned long max_zone_pfn[MAX_NR_ZONE 20 signed long size; 21 22 memblock_reserve(__pa(_start), _end - 23 24 early_init_fdt_reserve_self(); 25 early_init_fdt_scan_reserved_mem(); 26 27 memblock_dump_all(); 28 29 min_low_pfn = PFN_UP(memblock_start_of 30 max_low_pfn = max_pfn = PFN_DOWN(membl 31 32 size = max_pfn - min_low_pfn; 33 34 if (size >= lowmem_size) { 35 max_low_pfn = min_low_pfn + lo 36 #ifdef CONFIG_PAGE_OFFSET_80000000 37 write_mmu_msa1(read_mmu_msa0() 38 #endif 39 } else if (size > sseg_size) { 40 max_low_pfn = min_low_pfn + ss 41 } 42 43 max_zone_pfn[ZONE_NORMAL] = max_low_pf 44 45 mmu_init(min_low_pfn, max_low_pfn); 46 47 #ifdef CONFIG_HIGHMEM 48 max_zone_pfn[ZONE_HIGHMEM] = max_pfn; 49 50 highstart_pfn = max_low_pfn; 51 highend_pfn = max_pfn; 52 #endif 53 memblock_set_current_limit(PFN_PHYS(ma 54 55 dma_contiguous_reserve(0); 56 57 free_area_init(max_zone_pfn); 58 } 59 60 void __init setup_arch(char **cmdline_p) 61 { 62 *cmdline_p = boot_command_line; 63 64 console_verbose(); 65 66 pr_info("Phys. mem: %ldMB\n", 67 (unsigned long) memblock_phys_ 68 69 setup_initial_init_mm(_start, _etext, 70 71 parse_early_param(); 72 73 csky_memblock_init(); 74 75 unflatten_and_copy_device_tree(); 76 77 #ifdef CONFIG_SMP 78 setup_smp(); 79 #endif 80 81 sparse_init(); 82 83 fixaddr_init(); 84 85 #ifdef CONFIG_HIGHMEM 86 kmap_init(); 87 #endif 88 } 89 90 unsigned long va_pa_offset; 91 EXPORT_SYMBOL(va_pa_offset); 92 93 static inline unsigned long read_mmu_msa(void) 94 { 95 #ifdef CONFIG_PAGE_OFFSET_80000000 96 return read_mmu_msa0(); 97 #endif 98 99 #ifdef CONFIG_PAGE_OFFSET_A0000000 100 return read_mmu_msa1(); 101 #endif 102 } 103 104 asmlinkage __visible void __init csky_start(un 105 vo 106 { 107 /* Clean up bss section */ 108 memset(__bss_start, 0, __bss_stop - __ 109 110 va_pa_offset = read_mmu_msa() & ~(SSEG 111 112 pre_trap_init(); 113 114 if (dtb_start == NULL) 115 early_init_dt_scan(__dtb_start 116 else 117 early_init_dt_scan(dtb_start); 118 119 start_kernel(); 120 121 asm volatile("br .\n"); 122 } 123
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.