diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2009-11-24 14:35:41 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2009-12-16 20:57:32 -0500 |
commit | 137f6f3e284e8215a940cf20dbf2aef449fe5a60 (patch) | |
tree | a8243dc24c2e00eb2d6b0c924b2dde3910912eb0 /arch | |
parent | 69f3a7de1f1ec935924b1b13f83812f8b30e92ce (diff) |
MIPS: Cleanup signal code initialization
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Patchwork: http://patchwork.linux-mips.org/patch/709/
Diffstat (limited to 'arch')
-rw-r--r-- | arch/mips/include/asm/fpu.h | 8 | ||||
-rw-r--r-- | arch/mips/kernel/signal.c | 46 | ||||
-rw-r--r-- | arch/mips/kernel/signal32.c | 24 | ||||
-rw-r--r-- | arch/mips/kernel/traps.c | 76 |
4 files changed, 70 insertions, 84 deletions
diff --git a/arch/mips/include/asm/fpu.h b/arch/mips/include/asm/fpu.h index 8a3ef247659a..7fcef8ef3fab 100644 --- a/arch/mips/include/asm/fpu.h +++ b/arch/mips/include/asm/fpu.h | |||
@@ -28,15 +28,7 @@ | |||
28 | struct sigcontext; | 28 | struct sigcontext; |
29 | struct sigcontext32; | 29 | struct sigcontext32; |
30 | 30 | ||
31 | extern asmlinkage int (*save_fp_context)(struct sigcontext __user *sc); | ||
32 | extern asmlinkage int (*restore_fp_context)(struct sigcontext __user *sc); | ||
33 | |||
34 | extern asmlinkage int (*save_fp_context32)(struct sigcontext32 __user *sc); | ||
35 | extern asmlinkage int (*restore_fp_context32)(struct sigcontext32 __user *sc); | ||
36 | |||
37 | extern void fpu_emulator_init_fpu(void); | 31 | extern void fpu_emulator_init_fpu(void); |
38 | extern int fpu_emulator_save_context(struct sigcontext __user *sc); | ||
39 | extern int fpu_emulator_restore_context(struct sigcontext __user *sc); | ||
40 | extern void _init_fpu(void); | 32 | extern void _init_fpu(void); |
41 | extern void _save_fp(struct task_struct *); | 33 | extern void _save_fp(struct task_struct *); |
42 | extern void _restore_fp(struct task_struct *); | 34 | extern void _restore_fp(struct task_struct *); |
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c index 6254041b942f..d0c68b5d717b 100644 --- a/arch/mips/kernel/signal.c +++ b/arch/mips/kernel/signal.c | |||
@@ -35,6 +35,15 @@ | |||
35 | 35 | ||
36 | #include "signal-common.h" | 36 | #include "signal-common.h" |
37 | 37 | ||
38 | static int (*save_fp_context)(struct sigcontext __user *sc); | ||
39 | static int (*restore_fp_context)(struct sigcontext __user *sc); | ||
40 | |||
41 | extern asmlinkage int _save_fp_context(struct sigcontext __user *sc); | ||
42 | extern asmlinkage int _restore_fp_context(struct sigcontext __user *sc); | ||
43 | |||
44 | extern asmlinkage int fpu_emulator_save_context(struct sigcontext __user *sc); | ||
45 | extern asmlinkage int fpu_emulator_restore_context(struct sigcontext __user *sc); | ||
46 | |||
38 | /* | 47 | /* |
39 | * Horribly complicated - with the bloody RM9000 workarounds enabled | 48 | * Horribly complicated - with the bloody RM9000 workarounds enabled |
40 | * the signal trampolines is moving to the end of the structure so we can | 49 | * the signal trampolines is moving to the end of the structure so we can |
@@ -709,3 +718,40 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused, | |||
709 | key_replace_session_keyring(); | 718 | key_replace_session_keyring(); |
710 | } | 719 | } |
711 | } | 720 | } |
721 | |||
722 | #ifdef CONFIG_SMP | ||
723 | static int smp_save_fp_context(struct sigcontext __user *sc) | ||
724 | { | ||
725 | return raw_cpu_has_fpu | ||
726 | ? _save_fp_context(sc) | ||
727 | : fpu_emulator_save_context(sc); | ||
728 | } | ||
729 | |||
730 | static int smp_restore_fp_context(struct sigcontext __user *sc) | ||
731 | { | ||
732 | return raw_cpu_has_fpu | ||
733 | ? _restore_fp_context(sc) | ||
734 | : fpu_emulator_restore_context(sc); | ||
735 | } | ||
736 | #endif | ||
737 | |||
738 | static int signal_setup(void) | ||
739 | { | ||
740 | #ifdef CONFIG_SMP | ||
741 | /* For now just do the cpu_has_fpu check when the functions are invoked */ | ||
742 | save_fp_context = smp_save_fp_context; | ||
743 | restore_fp_context = smp_restore_fp_context; | ||
744 | #else | ||
745 | if (cpu_has_fpu) { | ||
746 | save_fp_context = _save_fp_context; | ||
747 | restore_fp_context = _restore_fp_context; | ||
748 | } else { | ||
749 | save_fp_context = fpu_emulator_save_context; | ||
750 | restore_fp_context = fpu_emulator_restore_context; | ||
751 | } | ||
752 | #endif | ||
753 | |||
754 | return 0; | ||
755 | } | ||
756 | |||
757 | arch_initcall(signal_setup); | ||
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c index 2e74075ac0ca..03abaf048f09 100644 --- a/arch/mips/kernel/signal32.c +++ b/arch/mips/kernel/signal32.c | |||
@@ -35,6 +35,15 @@ | |||
35 | 35 | ||
36 | #include "signal-common.h" | 36 | #include "signal-common.h" |
37 | 37 | ||
38 | static int (*save_fp_context32)(struct sigcontext32 __user *sc); | ||
39 | static int (*restore_fp_context32)(struct sigcontext32 __user *sc); | ||
40 | |||
41 | extern asmlinkage int _save_fp_context32(struct sigcontext32 __user *sc); | ||
42 | extern asmlinkage int _restore_fp_context32(struct sigcontext32 __user *sc); | ||
43 | |||
44 | extern asmlinkage int fpu_emulator_save_context32(struct sigcontext32 __user *sc); | ||
45 | extern asmlinkage int fpu_emulator_restore_context32(struct sigcontext32 __user *sc); | ||
46 | |||
38 | /* | 47 | /* |
39 | * Including <asm/unistd.h> would give use the 64-bit syscall numbers ... | 48 | * Including <asm/unistd.h> would give use the 64-bit syscall numbers ... |
40 | */ | 49 | */ |
@@ -828,3 +837,18 @@ SYSCALL_DEFINE5(32_waitid, int, which, compat_pid_t, pid, | |||
828 | info.si_code |= __SI_CHLD; | 837 | info.si_code |= __SI_CHLD; |
829 | return copy_siginfo_to_user32(uinfo, &info); | 838 | return copy_siginfo_to_user32(uinfo, &info); |
830 | } | 839 | } |
840 | |||
841 | static int signal32_init(void) | ||
842 | { | ||
843 | if (cpu_has_fpu) { | ||
844 | save_fp_context32 = _save_fp_context32; | ||
845 | restore_fp_context32 = _restore_fp_context32; | ||
846 | } else { | ||
847 | save_fp_context32 = fpu_emulator_save_context32; | ||
848 | restore_fp_context32 = fpu_emulator_restore_context32; | ||
849 | } | ||
850 | |||
851 | return 0; | ||
852 | } | ||
853 | |||
854 | arch_initcall(signal32_init); | ||
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 9fe21fb65305..308e43460864 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c | |||
@@ -1395,77 +1395,6 @@ void *set_vi_handler(int n, vi_handler_t addr) | |||
1395 | return set_vi_srs_handler(n, addr, 0); | 1395 | return set_vi_srs_handler(n, addr, 0); |
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | /* | ||
1399 | * This is used by native signal handling | ||
1400 | */ | ||
1401 | asmlinkage int (*save_fp_context)(struct sigcontext __user *sc); | ||
1402 | asmlinkage int (*restore_fp_context)(struct sigcontext __user *sc); | ||
1403 | |||
1404 | extern asmlinkage int _save_fp_context(struct sigcontext __user *sc); | ||
1405 | extern asmlinkage int _restore_fp_context(struct sigcontext __user *sc); | ||
1406 | |||
1407 | extern asmlinkage int fpu_emulator_save_context(struct sigcontext __user *sc); | ||
1408 | extern asmlinkage int fpu_emulator_restore_context(struct sigcontext __user *sc); | ||
1409 | |||
1410 | #ifdef CONFIG_SMP | ||
1411 | static int smp_save_fp_context(struct sigcontext __user *sc) | ||
1412 | { | ||
1413 | return raw_cpu_has_fpu | ||
1414 | ? _save_fp_context(sc) | ||
1415 | : fpu_emulator_save_context(sc); | ||
1416 | } | ||
1417 | |||
1418 | static int smp_restore_fp_context(struct sigcontext __user *sc) | ||
1419 | { | ||
1420 | return raw_cpu_has_fpu | ||
1421 | ? _restore_fp_context(sc) | ||
1422 | : fpu_emulator_restore_context(sc); | ||
1423 | } | ||
1424 | #endif | ||
1425 | |||
1426 | static inline void signal_init(void) | ||
1427 | { | ||
1428 | #ifdef CONFIG_SMP | ||
1429 | /* For now just do the cpu_has_fpu check when the functions are invoked */ | ||
1430 | save_fp_context = smp_save_fp_context; | ||
1431 | restore_fp_context = smp_restore_fp_context; | ||
1432 | #else | ||
1433 | if (cpu_has_fpu) { | ||
1434 | save_fp_context = _save_fp_context; | ||
1435 | restore_fp_context = _restore_fp_context; | ||
1436 | } else { | ||
1437 | save_fp_context = fpu_emulator_save_context; | ||
1438 | restore_fp_context = fpu_emulator_restore_context; | ||
1439 | } | ||
1440 | #endif | ||
1441 | } | ||
1442 | |||
1443 | #ifdef CONFIG_MIPS32_COMPAT | ||
1444 | |||
1445 | /* | ||
1446 | * This is used by 32-bit signal stuff on the 64-bit kernel | ||
1447 | */ | ||
1448 | asmlinkage int (*save_fp_context32)(struct sigcontext32 __user *sc); | ||
1449 | asmlinkage int (*restore_fp_context32)(struct sigcontext32 __user *sc); | ||
1450 | |||
1451 | extern asmlinkage int _save_fp_context32(struct sigcontext32 __user *sc); | ||
1452 | extern asmlinkage int _restore_fp_context32(struct sigcontext32 __user *sc); | ||
1453 | |||
1454 | extern asmlinkage int fpu_emulator_save_context32(struct sigcontext32 __user *sc); | ||
1455 | extern asmlinkage int fpu_emulator_restore_context32(struct sigcontext32 __user *sc); | ||
1456 | |||
1457 | static inline void signal32_init(void) | ||
1458 | { | ||
1459 | if (cpu_has_fpu) { | ||
1460 | save_fp_context32 = _save_fp_context32; | ||
1461 | restore_fp_context32 = _restore_fp_context32; | ||
1462 | } else { | ||
1463 | save_fp_context32 = fpu_emulator_save_context32; | ||
1464 | restore_fp_context32 = fpu_emulator_restore_context32; | ||
1465 | } | ||
1466 | } | ||
1467 | #endif | ||
1468 | |||
1469 | extern void cpu_cache_init(void); | 1398 | extern void cpu_cache_init(void); |
1470 | extern void tlb_init(void); | 1399 | extern void tlb_init(void); |
1471 | extern void flush_tlb_handlers(void); | 1400 | extern void flush_tlb_handlers(void); |
@@ -1779,11 +1708,6 @@ void __init trap_init(void) | |||
1779 | else | 1708 | else |
1780 | memcpy((void *)(ebase + 0x080), &except_vec3_generic, 0x80); | 1709 | memcpy((void *)(ebase + 0x080), &except_vec3_generic, 0x80); |
1781 | 1710 | ||
1782 | signal_init(); | ||
1783 | #ifdef CONFIG_MIPS32_COMPAT | ||
1784 | signal32_init(); | ||
1785 | #endif | ||
1786 | |||
1787 | local_flush_icache_range(ebase, ebase + 0x400); | 1711 | local_flush_icache_range(ebase, ebase + 0x400); |
1788 | flush_tlb_handlers(); | 1712 | flush_tlb_handlers(); |
1789 | 1713 | ||