5 #include "mem_layout.h"
7 //---------------------------------------------------------------------------
12 //---------------------------------------------------------------------------
13 IMPLEMENTATION [arm && armv5]:
17 Section_cachable = 0x40e,
18 Section_no_cache = 0x402,
27 //---------------------------------------------------------------------------
28 IMPLEMENTATION [arm && armv6plus && (mpcore || armca9)]:
32 Section_shared = 1UL << 16,
35 //---------------------------------------------------------------------------
36 IMPLEMENTATION [arm && armv6plus && !(mpcore || armca9)]:
44 //---------------------------------------------------------------------------
45 IMPLEMENTATION [arm && (armv6 || armv7)]:
49 Section_cachable = 0x5406 | Section_shared,
50 Section_no_cache = 0x0402 | Section_shared,
51 Section_local = (1 << 17),
58 asm volatile ("MCR p15, 0, %0, c13, c0, 1" : : "r" (0)); // ASID 0
61 //---------------------------------------------------------------------------
62 IMPLEMENTATION [arm && arm1176_cache_alias_fix]:
65 do_arm_1176_cache_alias_workaround()
68 asm volatile ("mrc p15, 0, %0, c0, c0, 1 \n" : "=r" (v));
69 if (v & ((1 << 23) | (1 << 11)))
71 asm volatile ("mrc p15, 0, r0, c1, c0, 1 \n"
72 "orr r0, r0, #(1 << 6) \n"
73 "mcr p15, 0, r0, c1, c0, 1 \n"
78 //---------------------------------------------------------------------------
79 IMPLEMENTATION [arm && !arm1176_cache_alias_fix]:
81 static void do_arm_1176_cache_alias_workaround() {}
83 //---------------------------------------------------------------------------
86 #include "kmem_space.h"
87 #include "pagetable.h"
90 map_1mb(void *pd, Address va, Address pa, bool cache, bool local)
92 Unsigned32 *const p = (Unsigned32*)pd;
93 p[va >> 20] = (pa & 0xfff00000)
94 | (cache ? Section_cachable : Section_no_cache)
95 | (local ? Section_local : Section_global);
100 ".section .text.init,#alloc,#execinstr \n"
103 " ldr sp, __init_data \n"
104 " bl bootstrap_main \n"
118 #include "globalconfig.h"
120 extern char bootstrap_bss_start[];
121 extern char bootstrap_bss_end[];
122 extern char __bss_start[];
123 extern char __bss_end[];
127 Virt_ofs = Mem_layout::Sdram_phys_base - Mem_layout::Map_base,
130 extern "C" void bootstrap_main()
132 extern char kernel_page_directory[];
133 void *const page_dir = kernel_page_directory + Virt_ofs;
136 // map sdram linear from 0xf0000000
137 for (va = Mem_layout::Map_base, pa = Mem_layout::Sdram_phys_base;
138 va < Mem_layout::Map_base + (4 << 20); va += 0x100000, pa += 0x100000)
139 map_1mb(page_dir, va, pa, true, false);
142 for (va = Mem_layout::Sdram_phys_base;
143 va < Mem_layout::Sdram_phys_base + (4 << 20); va += 0x100000)
144 map_1mb(page_dir, va, va, true, true);
148 unsigned domains = 0x55555555; // client for all domains
149 unsigned control = Config::cache_enabled
150 ? Cpu::Cp15_c1_cache_enabled : Cpu::Cp15_c1_cache_disabled;
152 Mmu<Cache_flush_area, true>::flush_cache();
154 extern char _start_kernel[];
156 do_arm_1176_cache_alias_workaround();
160 "mcr p15, 0, %[null], c8, c7, 0x00 \n" // TLB flush
161 "mcr p15, 0, %[doms], c3, c0 \n" // domains
162 "mcr p15, 0, %[pdir], c2, c0 \n" // pdbr
163 "mcr p15, 0, %[control], c1, c0 \n" // control
165 "mrc p15, 0, r0, c2, c0, 0 \n" // arbitrary read of cp15
166 "mov r0, r0 \n" // wait for result
169 "mov pc, %[start] \n"
171 [pdir] "r"((Mword)page_dir | Page_table::Ttbr_bits),
173 [control] "r"(control),
174 [start] "r"(_start_kernel),