irqflags.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * C6X IRQ flag handling
  3. *
  4. * Copyright (C) 2010 Texas Instruments Incorporated
  5. * Written by Mark Salter (msalter@redhat.com)
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public Licence
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the Licence, or (at your option) any later version.
  11. */
  12. #ifndef _ASM_IRQFLAGS_H
  13. #define _ASM_IRQFLAGS_H
  14. #ifndef __ASSEMBLY__
  15. /* read interrupt enabled status */
  16. static inline unsigned long arch_local_save_flags(void)
  17. {
  18. unsigned long flags;
  19. asm volatile (" mvc .s2 CSR,%0\n" : "=b"(flags));
  20. return flags;
  21. }
  22. /* set interrupt enabled status */
  23. static inline void arch_local_irq_restore(unsigned long flags)
  24. {
  25. asm volatile (" mvc .s2 %0,CSR\n" : : "b"(flags) : "memory");
  26. }
  27. /* unconditionally enable interrupts */
  28. static inline void arch_local_irq_enable(void)
  29. {
  30. unsigned long flags = arch_local_save_flags();
  31. flags |= 1;
  32. arch_local_irq_restore(flags);
  33. }
  34. /* unconditionally disable interrupts */
  35. static inline void arch_local_irq_disable(void)
  36. {
  37. unsigned long flags = arch_local_save_flags();
  38. flags &= ~1;
  39. arch_local_irq_restore(flags);
  40. }
  41. /* get status and disable interrupts */
  42. static inline unsigned long arch_local_irq_save(void)
  43. {
  44. unsigned long flags;
  45. flags = arch_local_save_flags();
  46. arch_local_irq_restore(flags & ~1);
  47. return flags;
  48. }
  49. /* test flags */
  50. static inline int arch_irqs_disabled_flags(unsigned long flags)
  51. {
  52. return (flags & 1) == 0;
  53. }
  54. /* test hardware interrupt enable bit */
  55. static inline int arch_irqs_disabled(void)
  56. {
  57. return arch_irqs_disabled_flags(arch_local_save_flags());
  58. }
  59. #endif /* __ASSEMBLY__ */
  60. #endif /* __ASM_IRQFLAGS_H */