system.h 1.2 KB

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