system.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
  4. * Scott McNutt <smcnutt@psyent.com>
  5. */
  6. #ifndef __ASM_NIOS2_SYSTEM_H_
  7. #define __ASM_NIOS2_SYSTEM_H_
  8. #define local_irq_enable() __asm__ __volatile__ ( \
  9. "rdctl r8, status\n" \
  10. "ori r8, r8, 1\n" \
  11. "wrctl status, r8\n" \
  12. : : : "r8")
  13. #define local_irq_disable() __asm__ __volatile__ ( \
  14. "rdctl r8, status\n" \
  15. "andi r8, r8, 0xfffe\n" \
  16. "wrctl status, r8\n" \
  17. : : : "r8")
  18. #define local_save_flags(x) __asm__ __volatile__ ( \
  19. "rdctl r8, status\n" \
  20. "mov %0, r8\n" \
  21. : "=r" (x) : : "r8", "memory")
  22. #define local_irq_restore(x) __asm__ __volatile__ ( \
  23. "mov r8, %0\n" \
  24. "wrctl status, r8\n" \
  25. : : "r" (x) : "r8", "memory")
  26. /* For spinlocks etc */
  27. #define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } \
  28. while (0)
  29. #define irqs_disabled() \
  30. ({ \
  31. unsigned long flags; \
  32. local_save_flags(flags); \
  33. ((flags & NIOS2_STATUS_PIE_MSK) == 0x0); \
  34. })
  35. /* indirect call to go beyond 256MB limitation of toolchain */
  36. #define nios2_callr(addr) __asm__ __volatile__ ( \
  37. "callr %0" \
  38. : : "r" (addr))
  39. void display_sysid(void);
  40. #endif /* __ASM_NIOS2_SYSTEM_H */