xref: /linux/arch/sh/kernel/irq_32.c (revision df9ee29270c11dba7d0fe0b83ce47a4d8e8d2101)
103fdb708SPaul Mundt /*
203fdb708SPaul Mundt  * SHcompact irqflags support
303fdb708SPaul Mundt  *
403fdb708SPaul Mundt  * Copyright (C) 2006 - 2009 Paul Mundt
503fdb708SPaul Mundt  *
603fdb708SPaul Mundt  * This file is subject to the terms and conditions of the GNU General Public
703fdb708SPaul Mundt  * License. See the file "COPYING" in the main directory of this archive
803fdb708SPaul Mundt  * for more details.
903fdb708SPaul Mundt  */
1003fdb708SPaul Mundt #include <linux/irqflags.h>
1103fdb708SPaul Mundt #include <linux/module.h>
1203fdb708SPaul Mundt 
13*df9ee292SDavid Howells void notrace arch_local_irq_restore(unsigned long flags)
1403fdb708SPaul Mundt {
1503fdb708SPaul Mundt 	unsigned long __dummy0, __dummy1;
1603fdb708SPaul Mundt 
17*df9ee292SDavid Howells 	if (flags == ARCH_IRQ_DISABLED) {
1803fdb708SPaul Mundt 		__asm__ __volatile__ (
1903fdb708SPaul Mundt 			"stc	sr, %0\n\t"
2003fdb708SPaul Mundt 			"or	#0xf0, %0\n\t"
2103fdb708SPaul Mundt 			"ldc	%0, sr\n\t"
2203fdb708SPaul Mundt 			: "=&z" (__dummy0)
2303fdb708SPaul Mundt 			: /* no inputs */
2403fdb708SPaul Mundt 			: "memory"
2503fdb708SPaul Mundt 		);
2603fdb708SPaul Mundt 	} else {
2703fdb708SPaul Mundt 		__asm__ __volatile__ (
2803fdb708SPaul Mundt 			"stc	sr, %0\n\t"
2903fdb708SPaul Mundt 			"and	%1, %0\n\t"
3003fdb708SPaul Mundt #ifdef CONFIG_CPU_HAS_SR_RB
3103fdb708SPaul Mundt 			"stc	r6_bank, %1\n\t"
3203fdb708SPaul Mundt 			"or	%1, %0\n\t"
3303fdb708SPaul Mundt #endif
3403fdb708SPaul Mundt 			"ldc	%0, sr\n\t"
3503fdb708SPaul Mundt 			: "=&r" (__dummy0), "=r" (__dummy1)
36*df9ee292SDavid Howells 			: "1" (~ARCH_IRQ_DISABLED)
3703fdb708SPaul Mundt 			: "memory"
3803fdb708SPaul Mundt 		);
3903fdb708SPaul Mundt 	}
4003fdb708SPaul Mundt }
41*df9ee292SDavid Howells EXPORT_SYMBOL(arch_local_irq_restore);
4203fdb708SPaul Mundt 
43*df9ee292SDavid Howells unsigned long notrace arch_local_save_flags(void)
4403fdb708SPaul Mundt {
4503fdb708SPaul Mundt 	unsigned long flags;
4603fdb708SPaul Mundt 
4703fdb708SPaul Mundt 	__asm__ __volatile__ (
4803fdb708SPaul Mundt 		"stc	sr, %0\n\t"
4903fdb708SPaul Mundt 		"and	#0xf0, %0\n\t"
5003fdb708SPaul Mundt 		: "=&z" (flags)
5103fdb708SPaul Mundt 		: /* no inputs */
5203fdb708SPaul Mundt 		: "memory"
5303fdb708SPaul Mundt 	);
5403fdb708SPaul Mundt 
5503fdb708SPaul Mundt 	return flags;
5603fdb708SPaul Mundt }
57*df9ee292SDavid Howells EXPORT_SYMBOL(arch_local_save_flags);
58