system.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
  3. * Scott McNutt <smcnutt@psyent.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., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef __ASM_NIOS2_SYSTEM_H_
  24. #define __ASM_NIOS2_SYSTEM_H_
  25. #define local_irq_enable() __asm__ __volatile__ ( \
  26. "rdctl r8, status\n" \
  27. "ori r8, r8, 1\n" \
  28. "wrctl status, r8\n" \
  29. : : : "r8")
  30. #define local_irq_disable() __asm__ __volatile__ ( \
  31. "rdctl r8, status\n" \
  32. "andi r8, r8, 0xfffe\n" \
  33. "wrctl status, r8\n" \
  34. : : : "r8")
  35. #define local_save_flags(x) __asm__ __volatile__ ( \
  36. "rdctl r8, status\n" \
  37. "mov %0, r8\n" \
  38. : "=r" (x) : : "r8", "memory")
  39. #define local_irq_restore(x) __asm__ __volatile__ ( \
  40. "mov r8, %0\n" \
  41. "wrctl status, r8\n" \
  42. : : "r" (x) : "r8", "memory")
  43. /* For spinlocks etc */
  44. #define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } \
  45. while (0)
  46. #define irqs_disabled() \
  47. ({ \
  48. unsigned long flags; \
  49. local_save_flags(flags); \
  50. ((flags & NIOS2_STATUS_PIE_MSK) == 0x0); \
  51. })
  52. /* indirect call to go beyond 256MB limitation of toolchain */
  53. #define nios2_callr(addr) __asm__ __volatile__ ( \
  54. "callr %0" \
  55. : : "r" (addr))
  56. #endif /* __ASM_NIOS2_SYSTEM_H */