irqflags.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_GENERIC_IRQFLAGS_H
  3. #define __ASM_GENERIC_IRQFLAGS_H
  4. /*
  5. * All architectures should implement at least the first two functions,
  6. * usually inline assembly will be the best way.
  7. */
  8. #ifndef ARCH_IRQ_DISABLED
  9. #define ARCH_IRQ_DISABLED 0
  10. #define ARCH_IRQ_ENABLED 1
  11. #endif
  12. /* read interrupt enabled status */
  13. #ifndef arch_local_save_flags
  14. unsigned long arch_local_save_flags(void);
  15. #endif
  16. /* set interrupt enabled status */
  17. #ifndef arch_local_irq_restore
  18. void arch_local_irq_restore(unsigned long flags);
  19. #endif
  20. /* get status and disable interrupts */
  21. #ifndef arch_local_irq_save
  22. static inline unsigned long arch_local_irq_save(void)
  23. {
  24. unsigned long flags;
  25. flags = arch_local_save_flags();
  26. arch_local_irq_restore(ARCH_IRQ_DISABLED);
  27. return flags;
  28. }
  29. #endif
  30. /* test flags */
  31. #ifndef arch_irqs_disabled_flags
  32. static inline int arch_irqs_disabled_flags(unsigned long flags)
  33. {
  34. return flags == ARCH_IRQ_DISABLED;
  35. }
  36. #endif
  37. /* unconditionally enable interrupts */
  38. #ifndef arch_local_irq_enable
  39. static inline void arch_local_irq_enable(void)
  40. {
  41. arch_local_irq_restore(ARCH_IRQ_ENABLED);
  42. }
  43. #endif
  44. /* unconditionally disable interrupts */
  45. #ifndef arch_local_irq_disable
  46. static inline void arch_local_irq_disable(void)
  47. {
  48. arch_local_irq_restore(ARCH_IRQ_DISABLED);
  49. }
  50. #endif
  51. /* test hardware interrupt enable bit */
  52. #ifndef arch_irqs_disabled
  53. static inline int arch_irqs_disabled(void)
  54. {
  55. return arch_irqs_disabled_flags(arch_local_save_flags());
  56. }
  57. #endif
  58. #endif /* __ASM_GENERIC_IRQFLAGS_H */