blob: 086d92bb0c946526e5b0606c1e090932b19569d1 [file] [log] [blame]
wdenk5c952cf2004-10-10 21:27:30 +00001/*
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
Thomas Choud8b73df2010-03-20 07:05:45 +080026#define local_irq_enable() __asm__ __volatile__ ( \
27 "rdctl r8, status\n" \
28 "ori r8, r8, 1\n" \
29 "wrctl status, r8\n" \
30 : : : "r8")
31
32#define local_irq_disable() __asm__ __volatile__ ( \
33 "rdctl r8, status\n" \
34 "andi r8, r8, 0xfffe\n" \
35 "wrctl status, r8\n" \
36 : : : "r8")
37
38#define local_save_flags(x) __asm__ __volatile__ ( \
39 "rdctl r8, status\n" \
40 "mov %0, r8\n" \
41 : "=r" (x) : : "r8", "memory")
42
43#define local_irq_restore(x) __asm__ __volatile__ ( \
44 "mov r8, %0\n" \
45 "wrctl status, r8\n" \
46 : : "r" (x) : "r8", "memory")
47
48/* For spinlocks etc */
49#define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } \
50 while (0)
51
52#define irqs_disabled() \
53({ \
54 unsigned long flags; \
55 local_save_flags(flags); \
56 ((flags & NIOS2_STATUS_PIE_MSK) == 0x0); \
57})
58
Thomas Chou7a6a7d12010-08-16 10:49:44 +080059/* indirect call to go beyond 256MB limitation of toolchain */
60#define nios2_callr(addr) __asm__ __volatile__ ( \
61 "callr %0" \
62 : : "r" (addr))
63
wdenk5c952cf2004-10-10 21:27:30 +000064#endif /* __ASM_NIOS2_SYSTEM_H */