David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2 | /* |
| 3 | * SHcompact irqflags support |
| 4 | * |
| 5 | * Copyright (C) 2006 - 2009 Paul Mundt |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 6 | */ |
| 7 | #include <linux/irqflags.h> |
| 8 | #include <linux/module.h> |
| 9 | |
| 10 | void notrace arch_local_irq_restore(unsigned long flags) |
| 11 | { |
| 12 | unsigned long __dummy0, __dummy1; |
| 13 | |
| 14 | if (flags == ARCH_IRQ_DISABLED) { |
| 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) |
| 33 | : "1" (~ARCH_IRQ_DISABLED) |
| 34 | : "memory" |
| 35 | ); |
| 36 | } |
| 37 | } |
| 38 | EXPORT_SYMBOL(arch_local_irq_restore); |
| 39 | |
| 40 | unsigned long notrace arch_local_save_flags(void) |
| 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 | } |
| 54 | EXPORT_SYMBOL(arch_local_save_flags); |