2 * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
3 * Scott McNutt <smcnutt@psyent.com>
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
23 #ifndef __ASM_NIOS2_SYSTEM_H_
24 #define __ASM_NIOS2_SYSTEM_H_
26 #define local_irq_enable() __asm__ __volatile__ ( \
27 "rdctl r8, status\n" \
29 "wrctl status, r8\n" \
32 #define local_irq_disable() __asm__ __volatile__ ( \
33 "rdctl r8, status\n" \
34 "andi r8, r8, 0xfffe\n" \
35 "wrctl status, r8\n" \
38 #define local_save_flags(x) __asm__ __volatile__ ( \
39 "rdctl r8, status\n" \
41 : "=r" (x) : : "r8", "memory")
43 #define local_irq_restore(x) __asm__ __volatile__ ( \
45 "wrctl status, r8\n" \
46 : : "r" (x) : "r8", "memory")
48 /* For spinlocks etc */
49 #define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } \
52 #define irqs_disabled() \
54 unsigned long flags; \
55 local_save_flags(flags); \
56 ((flags & NIOS2_STATUS_PIE_MSK) == 0x0); \
59 /* indirect call to go beyond 256MB limitation of toolchain */
60 #define nios2_callr(addr) __asm__ __volatile__ ( \
64 #endif /* __ASM_NIOS2_SYSTEM_H */