diff options
Diffstat (limited to 'arch/mn10300/kernel/head.S')
-rw-r--r-- | arch/mn10300/kernel/head.S | 202 |
1 files changed, 198 insertions, 4 deletions
diff --git a/arch/mn10300/kernel/head.S b/arch/mn10300/kernel/head.S index 14f27f3bfaf4..73e00fc78072 100644 --- a/arch/mn10300/kernel/head.S +++ b/arch/mn10300/kernel/head.S | |||
@@ -19,6 +19,12 @@ | |||
19 | #include <asm/frame.inc> | 19 | #include <asm/frame.inc> |
20 | #include <asm/param.h> | 20 | #include <asm/param.h> |
21 | #include <unit/serial.h> | 21 | #include <unit/serial.h> |
22 | #ifdef CONFIG_SMP | ||
23 | #include <asm/smp.h> | ||
24 | #include <asm/intctl-regs.h> | ||
25 | #include <asm/cpu-regs.h> | ||
26 | #include <proc/smp-regs.h> | ||
27 | #endif /* CONFIG_SMP */ | ||
22 | 28 | ||
23 | __HEAD | 29 | __HEAD |
24 | 30 | ||
@@ -30,17 +36,51 @@ | |||
30 | .globl _start | 36 | .globl _start |
31 | .type _start,@function | 37 | .type _start,@function |
32 | _start: | 38 | _start: |
39 | #ifdef CONFIG_SMP | ||
40 | # | ||
41 | # If this is a secondary CPU (AP), then deal with that elsewhere | ||
42 | # | ||
43 | mov (CPUID),d3 | ||
44 | and CPUID_MASK,d3 | ||
45 | bne startup_secondary | ||
46 | |||
47 | # | ||
48 | # We're dealing with the primary CPU (BP) here, then. | ||
49 | # Keep BP's D0,D1,D2 register for boot check. | ||
50 | # | ||
51 | |||
52 | # Set up the Boot IPI for each secondary CPU | ||
53 | mov 0x1,a0 | ||
54 | loop_set_secondary_icr: | ||
55 | mov a0,a1 | ||
56 | asl CROSS_ICR_CPU_SHIFT,a1 | ||
57 | add CROSS_GxICR(SMP_BOOT_IRQ,0),a1 | ||
58 | movhu (a1),d3 | ||
59 | or GxICR_ENABLE|GxICR_LEVEL_0,d3 | ||
60 | movhu d3,(a1) | ||
61 | movhu (a1),d3 # flush | ||
62 | inc a0 | ||
63 | cmp NR_CPUS,a0 | ||
64 | bne loop_set_secondary_icr | ||
65 | #endif /* CONFIG_SMP */ | ||
66 | |||
33 | # save commandline pointer | 67 | # save commandline pointer |
34 | mov d0,a3 | 68 | mov d0,a3 |
35 | 69 | ||
36 | # preload the PGD pointer register | 70 | # preload the PGD pointer register |
37 | mov swapper_pg_dir,d0 | 71 | mov swapper_pg_dir,d0 |
38 | mov d0,(PTBR) | 72 | mov d0,(PTBR) |
73 | clr d0 | ||
74 | movbu d0,(PIDR) | ||
39 | 75 | ||
40 | # turn on the TLBs | 76 | # turn on the TLBs |
41 | mov MMUCTR_IIV|MMUCTR_DIV,d0 | 77 | mov MMUCTR_IIV|MMUCTR_DIV,d0 |
42 | mov d0,(MMUCTR) | 78 | mov d0,(MMUCTR) |
79 | #ifdef CONFIG_AM34_2 | ||
80 | mov MMUCTR_ITE|MMUCTR_DTE|MMUCTR_CE|MMUCTR_WTE,d0 | ||
81 | #else | ||
43 | mov MMUCTR_ITE|MMUCTR_DTE|MMUCTR_CE,d0 | 82 | mov MMUCTR_ITE|MMUCTR_DTE|MMUCTR_CE,d0 |
83 | #endif | ||
44 | mov d0,(MMUCTR) | 84 | mov d0,(MMUCTR) |
45 | 85 | ||
46 | # turn on AM33v2 exception handling mode and set the trap table base | 86 | # turn on AM33v2 exception handling mode and set the trap table base |
@@ -51,6 +91,11 @@ _start: | |||
51 | mov d0,(TBR) | 91 | mov d0,(TBR) |
52 | 92 | ||
53 | # invalidate and enable both of the caches | 93 | # invalidate and enable both of the caches |
94 | #ifdef CONFIG_SMP | ||
95 | mov ECHCTR,a0 | ||
96 | clr d0 | ||
97 | mov d0,(a0) | ||
98 | #endif | ||
54 | mov CHCTR,a0 | 99 | mov CHCTR,a0 |
55 | clr d0 | 100 | clr d0 |
56 | movhu d0,(a0) # turn off first | 101 | movhu d0,(a0) # turn off first |
@@ -61,18 +106,18 @@ _start: | |||
61 | btst CHCTR_ICBUSY|CHCTR_DCBUSY,d0 # wait till not busy | 106 | btst CHCTR_ICBUSY|CHCTR_DCBUSY,d0 # wait till not busy |
62 | lne | 107 | lne |
63 | 108 | ||
64 | #ifndef CONFIG_MN10300_CACHE_DISABLED | 109 | #ifdef CONFIG_MN10300_CACHE_ENABLED |
65 | #ifdef CONFIG_MN10300_CACHE_WBACK | 110 | #ifdef CONFIG_MN10300_CACHE_WBACK |
66 | #ifndef CONFIG_MN10300_CACHE_WBACK_NOWRALLOC | 111 | #ifndef CONFIG_MN10300_CACHE_WBACK_NOWRALLOC |
67 | mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK,d0 | 112 | mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK,d0 |
68 | #else | 113 | #else |
69 | mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK|CHCTR_DCALMD,d0 | 114 | mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK|CHCTR_DCALMD,d0 |
70 | #endif /* CACHE_DISABLED */ | 115 | #endif /* NOWRALLOC */ |
71 | #else | 116 | #else |
72 | mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRTHROUGH,d0 | 117 | mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRTHROUGH,d0 |
73 | #endif /* WBACK */ | 118 | #endif /* WBACK */ |
74 | movhu d0,(a0) # enable | 119 | movhu d0,(a0) # enable |
75 | #endif /* NOWRALLOC */ | 120 | #endif /* ENABLED */ |
76 | 121 | ||
77 | # turn on RTS on the debug serial port if applicable | 122 | # turn on RTS on the debug serial port if applicable |
78 | #ifdef CONFIG_MN10300_UNIT_ASB2305 | 123 | #ifdef CONFIG_MN10300_UNIT_ASB2305 |
@@ -206,6 +251,44 @@ __no_parameters: | |||
206 | call processor_init[],0 | 251 | call processor_init[],0 |
207 | call unit_init[],0 | 252 | call unit_init[],0 |
208 | 253 | ||
254 | #ifdef CONFIG_SMP | ||
255 | # mark the primary CPU in cpu_boot_map | ||
256 | mov cpu_boot_map,a0 | ||
257 | mov 0x1,d0 | ||
258 | mov d0,(a0) | ||
259 | |||
260 | # signal each secondary CPU to begin booting | ||
261 | mov 0x1,d2 # CPU ID | ||
262 | |||
263 | loop_request_boot_secondary: | ||
264 | mov d2,a0 | ||
265 | # send SMP_BOOT_IPI to secondary CPU | ||
266 | asl CROSS_ICR_CPU_SHIFT,a0 | ||
267 | add CROSS_GxICR(SMP_BOOT_IRQ,0),a0 | ||
268 | movhu (a0),d0 | ||
269 | or GxICR_REQUEST|GxICR_DETECT,d0 | ||
270 | movhu d0,(a0) | ||
271 | movhu (a0),d0 # flush | ||
272 | |||
273 | # wait up to 100ms for AP's IPI to be received | ||
274 | clr d3 | ||
275 | wait_on_secondary_boot: | ||
276 | mov DELAY_TIME_BOOT_IPI,d0 | ||
277 | call __delay[],0 | ||
278 | inc d3 | ||
279 | mov cpu_boot_map,a0 | ||
280 | mov (a0),d0 | ||
281 | lsr d2,d0 | ||
282 | btst 0x1,d0 | ||
283 | bne 1f | ||
284 | cmp TIME_OUT_COUNT_BOOT_IPI,d3 | ||
285 | bne wait_on_secondary_boot | ||
286 | 1: | ||
287 | inc d2 | ||
288 | cmp NR_CPUS,d2 | ||
289 | bne loop_request_boot_secondary | ||
290 | #endif /* CONFIG_SMP */ | ||
291 | |||
209 | #ifdef CONFIG_GDBSTUB | 292 | #ifdef CONFIG_GDBSTUB |
210 | call gdbstub_init[],0 | 293 | call gdbstub_init[],0 |
211 | 294 | ||
@@ -217,7 +300,118 @@ __gdbstub_pause: | |||
217 | #endif | 300 | #endif |
218 | 301 | ||
219 | jmp start_kernel | 302 | jmp start_kernel |
220 | .size _start, _start-. | 303 | .size _start,.-_start |
304 | |||
305 | ############################################################################### | ||
306 | # | ||
307 | # Secondary CPU boot point | ||
308 | # | ||
309 | ############################################################################### | ||
310 | #ifdef CONFIG_SMP | ||
311 | startup_secondary: | ||
312 | # preload the PGD pointer register | ||
313 | mov swapper_pg_dir,d0 | ||
314 | mov d0,(PTBR) | ||
315 | clr d0 | ||
316 | movbu d0,(PIDR) | ||
317 | |||
318 | # turn on the TLBs | ||
319 | mov MMUCTR_IIV|MMUCTR_DIV,d0 | ||
320 | mov d0,(MMUCTR) | ||
321 | #ifdef CONFIG_AM34_2 | ||
322 | mov MMUCTR_ITE|MMUCTR_DTE|MMUCTR_CE|MMUCTR_WTE,d0 | ||
323 | #else | ||
324 | mov MMUCTR_ITE|MMUCTR_DTE|MMUCTR_CE,d0 | ||
325 | #endif | ||
326 | mov d0,(MMUCTR) | ||
327 | |||
328 | # turn on AM33v2 exception handling mode and set the trap table base | ||
329 | movhu (CPUP),d0 | ||
330 | or CPUP_EXM_AM33V2,d0 | ||
331 | movhu d0,(CPUP) | ||
332 | |||
333 | # set the interrupt vector table | ||
334 | mov CONFIG_INTERRUPT_VECTOR_BASE,d0 | ||
335 | mov d0,(TBR) | ||
336 | |||
337 | # invalidate and enable both of the caches | ||
338 | mov ECHCTR,a0 | ||
339 | clr d0 | ||
340 | mov d0,(a0) | ||
341 | mov CHCTR,a0 | ||
342 | clr d0 | ||
343 | movhu d0,(a0) # turn off first | ||
344 | mov CHCTR_ICINV|CHCTR_DCINV,d0 | ||
345 | movhu d0,(a0) | ||
346 | setlb | ||
347 | mov (a0),d0 | ||
348 | btst CHCTR_ICBUSY|CHCTR_DCBUSY,d0 # wait till not busy (use CPU loop buffer) | ||
349 | lne | ||
350 | |||
351 | #ifdef CONFIG_MN10300_CACHE_ENABLED | ||
352 | #ifdef CONFIG_MN10300_CACHE_WBACK | ||
353 | #ifndef CONFIG_MN10300_CACHE_WBACK_NOWRALLOC | ||
354 | mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK,d0 | ||
355 | #else | ||
356 | mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK|CHCTR_DCALMD,d0 | ||
357 | #endif /* !NOWRALLOC */ | ||
358 | #else | ||
359 | mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRTHROUGH,d0 | ||
360 | #endif /* WBACK */ | ||
361 | movhu d0,(a0) # enable | ||
362 | #endif /* ENABLED */ | ||
363 | |||
364 | # Clear the boot IPI interrupt for this CPU | ||
365 | movhu (GxICR(SMP_BOOT_IRQ)),d0 | ||
366 | and ~GxICR_REQUEST,d0 | ||
367 | movhu d0,(GxICR(SMP_BOOT_IRQ)) | ||
368 | movhu (GxICR(SMP_BOOT_IRQ)),d0 # flush | ||
369 | |||
370 | /* get stack */ | ||
371 | mov CONFIG_INTERRUPT_VECTOR_BASE + CONFIG_BOOT_STACK_OFFSET,a0 | ||
372 | mov (CPUID),d0 | ||
373 | and CPUID_MASK,d0 | ||
374 | mulu CONFIG_BOOT_STACK_SIZE,d0 | ||
375 | sub d0,a0 | ||
376 | mov a0,sp | ||
377 | |||
378 | # init interrupt for AP | ||
379 | call smp_prepare_cpu_init[],0 | ||
380 | |||
381 | # mark this secondary CPU in cpu_boot_map | ||
382 | mov (CPUID),d0 | ||
383 | mov 0x1,d1 | ||
384 | asl d0,d1 | ||
385 | mov cpu_boot_map,a0 | ||
386 | bset d1,(a0) | ||
387 | |||
388 | or EPSW_IE|EPSW_IM_1,epsw # permit level 0 interrupts | ||
389 | nop | ||
390 | nop | ||
391 | #ifdef CONFIG_MN10300_CACHE_WBACK | ||
392 | # flush the local cache if it's in writeback mode | ||
393 | call mn10300_local_dcache_flush_inv[],0 | ||
394 | setlb | ||
395 | mov (CHCTR),d0 | ||
396 | btst CHCTR_DCBUSY,d0 # wait till not busy (use CPU loop buffer) | ||
397 | lne | ||
398 | #endif | ||
399 | |||
400 | # now sleep waiting for further instructions | ||
401 | secondary_sleep: | ||
402 | mov CPUM_SLEEP,d0 | ||
403 | movhu d0,(CPUM) | ||
404 | nop | ||
405 | nop | ||
406 | bra secondary_sleep | ||
407 | .size startup_secondary,.-startup_secondary | ||
408 | #endif /* CONFIG_SMP */ | ||
409 | |||
410 | ############################################################################### | ||
411 | # | ||
412 | # | ||
413 | # | ||
414 | ############################################################################### | ||
221 | ENTRY(__head_end) | 415 | ENTRY(__head_end) |
222 | 416 | ||
223 | /* | 417 | /* |