Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh: Convert to asm-generic/irqflags.h.

This simplifies the irqflags support by switching over to the asm-generic
version. The necessary support functions are brought out-of-line for both
SHcompact and SHmedia instruction sets.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>

+168 -214
+3 -28
arch/sh/include/asm/irqflags.h
··· 1 1 #ifndef __ASM_SH_IRQFLAGS_H 2 2 #define __ASM_SH_IRQFLAGS_H 3 3 4 - #ifdef CONFIG_SUPERH32 5 - #include "irqflags_32.h" 6 - #else 7 - #include "irqflags_64.h" 8 - #endif 4 + #define RAW_IRQ_DISABLED 0xf0 5 + #define RAW_IRQ_ENABLED 0x00 9 6 10 - #define raw_local_save_flags(flags) \ 11 - do { (flags) = __raw_local_save_flags(); } while (0) 12 - 13 - static inline int raw_irqs_disabled_flags(unsigned long flags) 14 - { 15 - return (flags != 0); 16 - } 17 - 18 - static inline int raw_irqs_disabled(void) 19 - { 20 - unsigned long flags = __raw_local_save_flags(); 21 - 22 - return raw_irqs_disabled_flags(flags); 23 - } 24 - 25 - #define raw_local_irq_save(flags) \ 26 - do { (flags) = __raw_local_irq_save(); } while (0) 27 - 28 - static inline void raw_local_irq_restore(unsigned long flags) 29 - { 30 - if ((flags & 0xf0) != 0xf0) 31 - raw_local_irq_enable(); 32 - } 7 + #include <asm-generic/irqflags.h> 33 8 34 9 #endif /* __ASM_SH_IRQFLAGS_H */
-99
arch/sh/include/asm/irqflags_32.h
··· 1 - #ifndef __ASM_SH_IRQFLAGS_32_H 2 - #define __ASM_SH_IRQFLAGS_32_H 3 - 4 - static inline void raw_local_irq_enable(void) 5 - { 6 - unsigned long __dummy0, __dummy1; 7 - 8 - __asm__ __volatile__ ( 9 - "stc sr, %0\n\t" 10 - "and %1, %0\n\t" 11 - #ifdef CONFIG_CPU_HAS_SR_RB 12 - "stc r6_bank, %1\n\t" 13 - "or %1, %0\n\t" 14 - #endif 15 - "ldc %0, sr\n\t" 16 - : "=&r" (__dummy0), "=r" (__dummy1) 17 - : "1" (~0x000000f0) 18 - : "memory" 19 - ); 20 - } 21 - 22 - static inline void raw_local_irq_disable(void) 23 - { 24 - unsigned long flags; 25 - 26 - __asm__ __volatile__ ( 27 - "stc sr, %0\n\t" 28 - "or #0xf0, %0\n\t" 29 - "ldc %0, sr\n\t" 30 - : "=&z" (flags) 31 - : /* no inputs */ 32 - : "memory" 33 - ); 34 - } 35 - 36 - static inline void set_bl_bit(void) 37 - { 38 - unsigned long __dummy0, __dummy1; 39 - 40 - __asm__ __volatile__ ( 41 - "stc sr, %0\n\t" 42 - "or %2, %0\n\t" 43 - "and %3, %0\n\t" 44 - "ldc %0, sr\n\t" 45 - : "=&r" (__dummy0), "=r" (__dummy1) 46 - : "r" (0x10000000), "r" (0xffffff0f) 47 - : "memory" 48 - ); 49 - } 50 - 51 - static inline void clear_bl_bit(void) 52 - { 53 - unsigned long __dummy0, __dummy1; 54 - 55 - __asm__ __volatile__ ( 56 - "stc sr, %0\n\t" 57 - "and %2, %0\n\t" 58 - "ldc %0, sr\n\t" 59 - : "=&r" (__dummy0), "=r" (__dummy1) 60 - : "1" (~0x10000000) 61 - : "memory" 62 - ); 63 - } 64 - 65 - static inline unsigned long __raw_local_save_flags(void) 66 - { 67 - unsigned long flags; 68 - 69 - __asm__ __volatile__ ( 70 - "stc sr, %0\n\t" 71 - "and #0xf0, %0\n\t" 72 - : "=&z" (flags) 73 - : /* no inputs */ 74 - : "memory" 75 - ); 76 - 77 - return flags; 78 - } 79 - 80 - static inline unsigned long __raw_local_irq_save(void) 81 - { 82 - unsigned long flags, __dummy; 83 - 84 - __asm__ __volatile__ ( 85 - "stc sr, %1\n\t" 86 - "mov %1, %0\n\t" 87 - "or #0xf0, %0\n\t" 88 - "ldc %0, sr\n\t" 89 - "mov %1, %0\n\t" 90 - "and #0xf0, %0\n\t" 91 - : "=&z" (flags), "=&r" (__dummy) 92 - : /* no inputs */ 93 - : "memory" 94 - ); 95 - 96 - return flags; 97 - } 98 - 99 - #endif /* __ASM_SH_IRQFLAGS_32_H */
-85
arch/sh/include/asm/irqflags_64.h
··· 1 - #ifndef __ASM_SH_IRQFLAGS_64_H 2 - #define __ASM_SH_IRQFLAGS_64_H 3 - 4 - #include <cpu/registers.h> 5 - 6 - #define SR_MASK_LL 0x00000000000000f0LL 7 - #define SR_BL_LL 0x0000000010000000LL 8 - 9 - static inline void raw_local_irq_enable(void) 10 - { 11 - unsigned long long __dummy0, __dummy1 = ~SR_MASK_LL; 12 - 13 - __asm__ __volatile__("getcon " __SR ", %0\n\t" 14 - "and %0, %1, %0\n\t" 15 - "putcon %0, " __SR "\n\t" 16 - : "=&r" (__dummy0) 17 - : "r" (__dummy1)); 18 - } 19 - 20 - static inline void raw_local_irq_disable(void) 21 - { 22 - unsigned long long __dummy0, __dummy1 = SR_MASK_LL; 23 - 24 - __asm__ __volatile__("getcon " __SR ", %0\n\t" 25 - "or %0, %1, %0\n\t" 26 - "putcon %0, " __SR "\n\t" 27 - : "=&r" (__dummy0) 28 - : "r" (__dummy1)); 29 - } 30 - 31 - static inline void set_bl_bit(void) 32 - { 33 - unsigned long long __dummy0, __dummy1 = SR_BL_LL; 34 - 35 - __asm__ __volatile__("getcon " __SR ", %0\n\t" 36 - "or %0, %1, %0\n\t" 37 - "putcon %0, " __SR "\n\t" 38 - : "=&r" (__dummy0) 39 - : "r" (__dummy1)); 40 - 41 - } 42 - 43 - static inline void clear_bl_bit(void) 44 - { 45 - unsigned long long __dummy0, __dummy1 = ~SR_BL_LL; 46 - 47 - __asm__ __volatile__("getcon " __SR ", %0\n\t" 48 - "and %0, %1, %0\n\t" 49 - "putcon %0, " __SR "\n\t" 50 - : "=&r" (__dummy0) 51 - : "r" (__dummy1)); 52 - } 53 - 54 - static inline unsigned long __raw_local_save_flags(void) 55 - { 56 - unsigned long long __dummy = SR_MASK_LL; 57 - unsigned long flags; 58 - 59 - __asm__ __volatile__ ( 60 - "getcon " __SR ", %0\n\t" 61 - "and %0, %1, %0" 62 - : "=&r" (flags) 63 - : "r" (__dummy)); 64 - 65 - return flags; 66 - } 67 - 68 - static inline unsigned long __raw_local_irq_save(void) 69 - { 70 - unsigned long long __dummy0, __dummy1 = SR_MASK_LL; 71 - unsigned long flags; 72 - 73 - __asm__ __volatile__ ( 74 - "getcon " __SR ", %1\n\t" 75 - "or %1, r63, %0\n\t" 76 - "or %1, %2, %1\n\t" 77 - "putcon %1, " __SR "\n\t" 78 - "and %0, %2, %0" 79 - : "=&r" (flags), "=&r" (__dummy0) 80 - : "r" (__dummy1)); 81 - 82 - return flags; 83 - } 84 - 85 - #endif /* __ASM_SH_IRQFLAGS_64_H */
+29
arch/sh/include/asm/system_32.h
··· 232 232 unsigned long r6, unsigned long r7, 233 233 struct pt_regs __regs); 234 234 235 + static inline void set_bl_bit(void) 236 + { 237 + unsigned long __dummy0, __dummy1; 238 + 239 + __asm__ __volatile__ ( 240 + "stc sr, %0\n\t" 241 + "or %2, %0\n\t" 242 + "and %3, %0\n\t" 243 + "ldc %0, sr\n\t" 244 + : "=&r" (__dummy0), "=r" (__dummy1) 245 + : "r" (0x10000000), "r" (0xffffff0f) 246 + : "memory" 247 + ); 248 + } 249 + 250 + static inline void clear_bl_bit(void) 251 + { 252 + unsigned long __dummy0, __dummy1; 253 + 254 + __asm__ __volatile__ ( 255 + "stc sr, %0\n\t" 256 + "and %2, %0\n\t" 257 + "ldc %0, sr\n\t" 258 + : "=&r" (__dummy0), "=r" (__dummy1) 259 + : "1" (~0x10000000) 260 + : "memory" 261 + ); 262 + } 263 + 235 264 #endif /* __ASM_SH_SYSTEM_32_H */
+26
arch/sh/include/asm/system_64.h
··· 12 12 * License. See the file "COPYING" in the main directory of this archive 13 13 * for more details. 14 14 */ 15 + #include <cpu/registers.h> 15 16 #include <asm/processor.h> 16 17 17 18 /* ··· 46 45 static inline reg_size_t register_align(void *val) 47 46 { 48 47 return (unsigned long long)(signed long long)(signed long)val; 48 + } 49 + 50 + #define SR_BL_LL 0x0000000010000000LL 51 + 52 + static inline void set_bl_bit(void) 53 + { 54 + unsigned long long __dummy0, __dummy1 = SR_BL_LL; 55 + 56 + __asm__ __volatile__("getcon " __SR ", %0\n\t" 57 + "or %0, %1, %0\n\t" 58 + "putcon %0, " __SR "\n\t" 59 + : "=&r" (__dummy0) 60 + : "r" (__dummy1)); 61 + 62 + } 63 + 64 + static inline void clear_bl_bit(void) 65 + { 66 + unsigned long long __dummy0, __dummy1 = ~SR_BL_LL; 67 + 68 + __asm__ __volatile__("getcon " __SR ", %0\n\t" 69 + "and %0, %1, %0\n\t" 70 + "putcon %0, " __SR "\n\t" 71 + : "=&r" (__dummy0) 72 + : "r" (__dummy1)); 49 73 } 50 74 51 75 #endif /* __ASM_SH_SYSTEM_64_H */
+2 -2
arch/sh/kernel/Makefile
··· 12 12 CFLAGS_REMOVE_return_address.o = -pg 13 13 14 14 obj-y := debugtraps.o dumpstack.o idle.o io.o io_generic.o irq.o \ 15 - machvec.o nmi_debug.o process_$(BITS).o ptrace_$(BITS).o \ 16 - return_address.o \ 15 + irq_$(BITS).o machvec.o nmi_debug.o process_$(BITS).o \ 16 + ptrace_$(BITS).o return_address.o \ 17 17 setup.o signal_$(BITS).o sys_sh.o sys_sh$(BITS).o \ 18 18 syscalls_$(BITS).o time.o topology.o traps.o \ 19 19 traps_$(BITS).o unwinder.o
+57
arch/sh/kernel/irq_32.c
··· 1 + /* 2 + * SHcompact irqflags support 3 + * 4 + * Copyright (C) 2006 - 2009 Paul Mundt 5 + * 6 + * This file is subject to the terms and conditions of the GNU General Public 7 + * License. See the file "COPYING" in the main directory of this archive 8 + * for more details. 9 + */ 10 + #include <linux/irqflags.h> 11 + #include <linux/module.h> 12 + 13 + void raw_local_irq_restore(unsigned long flags) 14 + { 15 + unsigned long __dummy0, __dummy1; 16 + 17 + if (flags == RAW_IRQ_DISABLED) { 18 + __asm__ __volatile__ ( 19 + "stc sr, %0\n\t" 20 + "or #0xf0, %0\n\t" 21 + "ldc %0, sr\n\t" 22 + : "=&z" (__dummy0) 23 + : /* no inputs */ 24 + : "memory" 25 + ); 26 + } else { 27 + __asm__ __volatile__ ( 28 + "stc sr, %0\n\t" 29 + "and %1, %0\n\t" 30 + #ifdef CONFIG_CPU_HAS_SR_RB 31 + "stc r6_bank, %1\n\t" 32 + "or %1, %0\n\t" 33 + #endif 34 + "ldc %0, sr\n\t" 35 + : "=&r" (__dummy0), "=r" (__dummy1) 36 + : "1" (~RAW_IRQ_DISABLED) 37 + : "memory" 38 + ); 39 + } 40 + } 41 + EXPORT_SYMBOL(raw_local_irq_restore); 42 + 43 + unsigned long __raw_local_save_flags(void) 44 + { 45 + unsigned long flags; 46 + 47 + __asm__ __volatile__ ( 48 + "stc sr, %0\n\t" 49 + "and #0xf0, %0\n\t" 50 + : "=&z" (flags) 51 + : /* no inputs */ 52 + : "memory" 53 + ); 54 + 55 + return flags; 56 + } 57 + EXPORT_SYMBOL(__raw_local_save_flags);
+51
arch/sh/kernel/irq_64.c
··· 1 + /* 2 + * SHmedia irqflags support 3 + * 4 + * Copyright (C) 2006 - 2009 Paul Mundt 5 + * 6 + * This file is subject to the terms and conditions of the GNU General Public 7 + * License. See the file "COPYING" in the main directory of this archive 8 + * for more details. 9 + */ 10 + #include <linux/irqflags.h> 11 + #include <linux/module.h> 12 + #include <cpu/registers.h> 13 + 14 + void raw_local_irq_restore(unsigned long flags) 15 + { 16 + unsigned long long __dummy; 17 + 18 + if (flags == RAW_IRQ_DISABLED) { 19 + __asm__ __volatile__ ( 20 + "getcon " __SR ", %0\n\t" 21 + "or %0, %1, %0\n\t" 22 + "putcon %0, " __SR "\n\t" 23 + : "=&r" (__dummy) 24 + : "r" (RAW_IRQ_DISABLED) 25 + ); 26 + } else { 27 + __asm__ __volatile__ ( 28 + "getcon " __SR ", %0\n\t" 29 + "and %0, %1, %0\n\t" 30 + "putcon %0, " __SR "\n\t" 31 + : "=&r" (__dummy) 32 + : "r" (~RAW_IRQ_DISABLED) 33 + ); 34 + } 35 + } 36 + EXPORT_SYMBOL(raw_local_irq_restore); 37 + 38 + unsigned long __raw_local_save_flags(void) 39 + { 40 + unsigned long flags; 41 + 42 + __asm__ __volatile__ ( 43 + "getcon " __SR ", %0\n\t" 44 + "and %0, %1, %0" 45 + : "=&r" (flags) 46 + : "r" (RAW_IRQ_DISABLED) 47 + ); 48 + 49 + return flags; 50 + } 51 + EXPORT_SYMBOL(__raw_local_save_flags);