aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Felker <dalias@libc.org>2016-02-15 13:32:31 -0500
committerRich Felker <dalias@libc.org>2016-08-04 23:29:37 -0400
commit4b6ef05b3e89f5bdb888fbd5467e996a9193b884 (patch)
treee6fa08e0eb4c6067324460c9f4bde918362e9192
parent00b73d8d1b7131da03aec73011a7286f566fe87f (diff)
sh: SMP support for SH2 entry.S
The SH2 version of entry.S uses global variables, which need to be cpu-local in order to work with SMP. For ease of access from asm, simply use arrays indexed by cpu number, and require the availability of an address (mmio register or properly setup per-cpu memory) from which the current cpu's index can be read. Signed-off-by: Rich Felker <dalias@libc.org>
-rw-r--r--arch/sh/kernel/cpu/sh2/entry.S50
1 files changed, 50 insertions, 0 deletions
diff --git a/arch/sh/kernel/cpu/sh2/entry.S b/arch/sh/kernel/cpu/sh2/entry.S
index 16bde0efaca3..1ee0a6e774c6 100644
--- a/arch/sh/kernel/cpu/sh2/entry.S
+++ b/arch/sh/kernel/cpu/sh2/entry.S
@@ -47,6 +47,13 @@ ENTRY(exception_handler)
47 mov.l r3,@-sp 47 mov.l r3,@-sp
48 cli 48 cli
49 mov.l $cpu_mode,r2 49 mov.l $cpu_mode,r2
50#ifdef CONFIG_SMP
51 mov.l $cpuid,r3
52 mov.l @r3,r3
53 mov.l @r3,r3
54 shll2 r3
55 add r3,r2
56#endif
50 mov.l @r2,r0 57 mov.l @r2,r0
51 mov.l @(5*4,r15),r3 ! previous SR 58 mov.l @(5*4,r15),r3 ! previous SR
52 or r0,r3 ! set MD 59 or r0,r3 ! set MD
@@ -57,6 +64,13 @@ ENTRY(exception_handler)
57 mov.l __md_bit,r0 64 mov.l __md_bit,r0
58 mov.l r0,@r2 ! enter kernel mode 65 mov.l r0,@r2 ! enter kernel mode
59 mov.l $current_thread_info,r2 66 mov.l $current_thread_info,r2
67#ifdef CONFIG_SMP
68 mov.l $cpuid,r0
69 mov.l @r0,r0
70 mov.l @r0,r0
71 shll2 r0
72 add r0,r2
73#endif
60 mov.l @r2,r2 74 mov.l @r2,r2
61 mov #(THREAD_SIZE >> 8),r0 75 mov #(THREAD_SIZE >> 8),r0
62 shll8 r0 76 shll8 r0
@@ -265,6 +279,13 @@ restore_all:
265 lds.l @r0+,macl 279 lds.l @r0+,macl
266 mov r15,r0 280 mov r15,r0
267 mov.l $cpu_mode,r2 281 mov.l $cpu_mode,r2
282#ifdef CONFIG_SMP
283 mov.l $cpuid,r3
284 mov.l @r3,r3
285 mov.l @r3,r3
286 shll2 r3
287 add r3,r2
288#endif
268 mov #OFF_SR,r3 289 mov #OFF_SR,r3
269 mov.l @(r0,r3),r1 290 mov.l @(r0,r3),r1
270 mov.l __md_bit,r3 291 mov.l __md_bit,r3
@@ -281,6 +302,13 @@ restore_all:
281 mov.l r1,@r2 ! set pc 302 mov.l r1,@r2 ! set pc
282 get_current_thread_info r0, r1 303 get_current_thread_info r0, r1
283 mov.l $current_thread_info,r1 304 mov.l $current_thread_info,r1
305#ifdef CONFIG_SMP
306 mov.l $cpuid,r3
307 mov.l @r3,r3
308 mov.l @r3,r3
309 shll2 r3
310 add r3,r1
311#endif
284 mov.l r0,@r1 312 mov.l r0,@r1
285 mov.l @r15+,r0 313 mov.l @r15+,r0
286 mov.l @r15+,r1 314 mov.l @r15+,r1
@@ -308,19 +336,41 @@ $current_thread_info:
308 .long __current_thread_info 336 .long __current_thread_info
309$cpu_mode: 337$cpu_mode:
310 .long __cpu_mode 338 .long __cpu_mode
339#ifdef CONFIG_SMP
340$cpuid:
341 .long sh2_cpuid_addr
342#endif
311 343
312! common exception handler 344! common exception handler
313#include "../../entry-common.S" 345#include "../../entry-common.S"
346
347#ifdef CONFIG_NR_CPUS
348#define NR_CPUS CONFIG_NR_CPUS
349#else
350#define NR_CPUS 1
351#endif
314 352
315 .data 353 .data
316! cpu operation mode 354! cpu operation mode
317! bit30 = MD (compatible SH3/4) 355! bit30 = MD (compatible SH3/4)
318__cpu_mode: 356__cpu_mode:
357 .rept NR_CPUS
319 .long 0x40000000 358 .long 0x40000000
359 .endr
360
361#ifdef CONFIG_SMP
362.global sh2_cpuid_addr
363sh2_cpuid_addr:
364 .long dummy_cpuid
365dummy_cpuid:
366 .long 0
367#endif
320 368
321 .section .bss 369 .section .bss
322__current_thread_info: 370__current_thread_info:
371 .rept NR_CPUS
323 .long 0 372 .long 0
373 .endr
324 374
325ENTRY(exception_handling_table) 375ENTRY(exception_handling_table)
326 .space 4*32 376 .space 4*32