11ccea77eSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 2f27ffc75SLey Foon Tan /* 3f27ffc75SLey Foon Tan * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw> 4f27ffc75SLey Foon Tan */ 5f27ffc75SLey Foon Tan #ifndef _ASM_IRQFLAGS_H 6f27ffc75SLey Foon Tan #define _ASM_IRQFLAGS_H 7f27ffc75SLey Foon Tan 8f27ffc75SLey Foon Tan #include <asm/registers.h> 9f27ffc75SLey Foon Tan 10f27ffc75SLey Foon Tan static inline unsigned long arch_local_save_flags(void) 11f27ffc75SLey Foon Tan { 12f27ffc75SLey Foon Tan return RDCTL(CTL_STATUS); 13f27ffc75SLey Foon Tan } 14f27ffc75SLey Foon Tan 15f27ffc75SLey Foon Tan /* 16f27ffc75SLey Foon Tan * This will restore ALL status register flags, not only the interrupt 17f27ffc75SLey Foon Tan * mask flag. 18f27ffc75SLey Foon Tan */ 19f27ffc75SLey Foon Tan static inline void arch_local_irq_restore(unsigned long flags) 20f27ffc75SLey Foon Tan { 21f27ffc75SLey Foon Tan WRCTL(CTL_STATUS, flags); 22f27ffc75SLey Foon Tan } 23f27ffc75SLey Foon Tan 24f27ffc75SLey Foon Tan static inline void arch_local_irq_disable(void) 25f27ffc75SLey Foon Tan { 26f27ffc75SLey Foon Tan unsigned long flags; 27f27ffc75SLey Foon Tan 28f27ffc75SLey Foon Tan flags = arch_local_save_flags(); 29f27ffc75SLey Foon Tan arch_local_irq_restore(flags & ~STATUS_PIE); 30f27ffc75SLey Foon Tan } 31f27ffc75SLey Foon Tan 32f27ffc75SLey Foon Tan static inline void arch_local_irq_enable(void) 33f27ffc75SLey Foon Tan { 34f27ffc75SLey Foon Tan unsigned long flags; 35f27ffc75SLey Foon Tan 36f27ffc75SLey Foon Tan flags = arch_local_save_flags(); 37f27ffc75SLey Foon Tan arch_local_irq_restore(flags | STATUS_PIE); 38f27ffc75SLey Foon Tan } 39f27ffc75SLey Foon Tan 40f27ffc75SLey Foon Tan static inline int arch_irqs_disabled_flags(unsigned long flags) 41f27ffc75SLey Foon Tan { 42f27ffc75SLey Foon Tan return (flags & STATUS_PIE) == 0; 43f27ffc75SLey Foon Tan } 44f27ffc75SLey Foon Tan 45f27ffc75SLey Foon Tan static inline int arch_irqs_disabled(void) 46f27ffc75SLey Foon Tan { 47f27ffc75SLey Foon Tan return arch_irqs_disabled_flags(arch_local_save_flags()); 48f27ffc75SLey Foon Tan } 49f27ffc75SLey Foon Tan 50f27ffc75SLey Foon Tan static inline unsigned long arch_local_irq_save(void) 51f27ffc75SLey Foon Tan { 52f27ffc75SLey Foon Tan unsigned long flags; 53f27ffc75SLey Foon Tan 54f27ffc75SLey Foon Tan flags = arch_local_save_flags(); 55f27ffc75SLey Foon Tan arch_local_irq_restore(flags & ~STATUS_PIE); 56f27ffc75SLey Foon Tan return flags; 57f27ffc75SLey Foon Tan } 58f27ffc75SLey Foon Tan 59f27ffc75SLey Foon Tan #endif /* _ASM_IRQFLAGS_H */ 60