2 * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
3 * Scott McNutt <smcnutt@psyent.com>
5 * SPDX-License-Identifier: GPL-2.0+
7 #ifndef __ASM_NIOS2_SYSTEM_H_
8 #define __ASM_NIOS2_SYSTEM_H_
10 #define local_irq_enable() __asm__ __volatile__ ( \
11 "rdctl r8, status\n" \
13 "wrctl status, r8\n" \
16 #define local_irq_disable() __asm__ __volatile__ ( \
17 "rdctl r8, status\n" \
18 "andi r8, r8, 0xfffe\n" \
19 "wrctl status, r8\n" \
22 #define local_save_flags(x) __asm__ __volatile__ ( \
23 "rdctl r8, status\n" \
25 : "=r" (x) : : "r8", "memory")
27 #define local_irq_restore(x) __asm__ __volatile__ ( \
29 "wrctl status, r8\n" \
30 : : "r" (x) : "r8", "memory")
32 /* For spinlocks etc */
33 #define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } \
36 #define irqs_disabled() \
38 unsigned long flags; \
39 local_save_flags(flags); \
40 ((flags & NIOS2_STATUS_PIE_MSK) == 0x0); \
43 /* indirect call to go beyond 256MB limitation of toolchain */
44 #define nios2_callr(addr) __asm__ __volatile__ ( \
48 #endif /* __ASM_NIOS2_SYSTEM_H */