system.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (C) 2011 Andes Technology Corporation
  3. * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  21. * MA 02110-1301 USA
  22. */
  23. #ifndef __ASM_NDS_SYSTEM_H
  24. #define __ASM_NDS_SYSTEM_H
  25. /*
  26. * Interrupt configuring macros.
  27. */
  28. extern int irq_flags;
  29. #define local_irq_enable() \
  30. __asm__ __volatile__ ( \
  31. "mfsr %0, $psw\n\t" \
  32. "andi %0, %0, 0x1\n\t" \
  33. "setgie.e\n\t" \
  34. : \
  35. : "r" (irq_flags) \
  36. )
  37. #define local_irq_disable() \
  38. do { \
  39. int __tmp_dummy; \
  40. __asm__ __volatile__ ( \
  41. "mfsr %0, $psw\n\t" \
  42. "andi %0, %0, 0x1\n\t" \
  43. "setgie.d\n\t" \
  44. "dsb\n\t" \
  45. : "=r" (__tmp_dummy) \
  46. ); \
  47. } while (0)
  48. #define local_irq_save(x) \
  49. __asm__ __volatile__ ( \
  50. "mfsr %0, $psw\n\t" \
  51. "andi %0, %0, 0x1\n\t" \
  52. "setgie.d\n\t" \
  53. "dsb\n\t" \
  54. : "=&r" (x) \
  55. )
  56. #define local_save_flags(x) \
  57. __asm__ __volatile__ ( \
  58. "mfsr %0, $psw\n\t" \
  59. "andi %0, %0, 0x1\n\t" \
  60. "setgie.e\n\t" \
  61. "setgie.d\n\t" \
  62. : "=r" (x) \
  63. )
  64. #define irqs_enabled_from_flags(x) ((x) != 0x1f)
  65. #define local_irq_restore(x) \
  66. do { \
  67. if (irqs_enabled_from_flags(x)) \
  68. local_irq_enable(); \
  69. } while (0)
  70. /*
  71. * Force strict CPU ordering.
  72. */
  73. #define nop() asm volatile ("nop;\n\t" : : )
  74. #define mb() asm volatile ("" : : : "memory")
  75. #define rmb() asm volatile ("" : : : "memory")
  76. #define wmb() asm volatile ("" : : : "memory")
  77. #endif /* __ASM_NDS_SYSTEM_H */