Kuninori Morimoto | 5933f6d | 2018-12-28 00:32:24 -0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Paul Mundt | 03fdb70 | 2009-10-17 21:06:39 +0900 | [diff] [blame] | 2 | /* |
| 3 | * SHcompact irqflags support |
| 4 | * |
| 5 | * Copyright (C) 2006 - 2009 Paul Mundt |
Paul Mundt | 03fdb70 | 2009-10-17 21:06:39 +0900 | [diff] [blame] | 6 | */ |
| 7 | #include <linux/irqflags.h> |
| 8 | #include <linux/module.h> |
| 9 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 10 | void notrace arch_local_irq_restore(unsigned long flags) |
Paul Mundt | 03fdb70 | 2009-10-17 21:06:39 +0900 | [diff] [blame] | 11 | { |
| 12 | unsigned long __dummy0, __dummy1; |
| 13 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 14 | if (flags == ARCH_IRQ_DISABLED) { |
Paul Mundt | 03fdb70 | 2009-10-17 21:06:39 +0900 | [diff] [blame] | 15 | __asm__ __volatile__ ( |
| 16 | "stc sr, %0\n\t" |
| 17 | "or #0xf0, %0\n\t" |
| 18 | "ldc %0, sr\n\t" |
| 19 | : "=&z" (__dummy0) |
| 20 | : /* no inputs */ |
| 21 | : "memory" |
| 22 | ); |
| 23 | } else { |
| 24 | __asm__ __volatile__ ( |
| 25 | "stc sr, %0\n\t" |
| 26 | "and %1, %0\n\t" |
| 27 | #ifdef CONFIG_CPU_HAS_SR_RB |
| 28 | "stc r6_bank, %1\n\t" |
| 29 | "or %1, %0\n\t" |
| 30 | #endif |
| 31 | "ldc %0, sr\n\t" |
| 32 | : "=&r" (__dummy0), "=r" (__dummy1) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 33 | : "1" (~ARCH_IRQ_DISABLED) |
Paul Mundt | 03fdb70 | 2009-10-17 21:06:39 +0900 | [diff] [blame] | 34 | : "memory" |
| 35 | ); |
| 36 | } |
| 37 | } |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 38 | EXPORT_SYMBOL(arch_local_irq_restore); |
Paul Mundt | 03fdb70 | 2009-10-17 21:06:39 +0900 | [diff] [blame] | 39 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 40 | unsigned long notrace arch_local_save_flags(void) |
Paul Mundt | 03fdb70 | 2009-10-17 21:06:39 +0900 | [diff] [blame] | 41 | { |
| 42 | unsigned long flags; |
| 43 | |
| 44 | __asm__ __volatile__ ( |
| 45 | "stc sr, %0\n\t" |
| 46 | "and #0xf0, %0\n\t" |
| 47 | : "=&z" (flags) |
| 48 | : /* no inputs */ |
| 49 | : "memory" |
| 50 | ); |
| 51 | |
| 52 | return flags; |
| 53 | } |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 54 | EXPORT_SYMBOL(arch_local_save_flags); |