blob: 6213a16eda98d1d573394efb5f725a09b909a86d [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 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenk5c952cf2004-10-10 21:27:30 +00006 */
7#ifndef __ASM_NIOS2_SYSTEM_H_
8#define __ASM_NIOS2_SYSTEM_H_
9
Thomas Choud8b73df2010-03-20 07:05:45 +080010#define local_irq_enable() __asm__ __volatile__ ( \
11 "rdctl r8, status\n" \
12 "ori r8, r8, 1\n" \
13 "wrctl status, r8\n" \
14 : : : "r8")
15
16#define local_irq_disable() __asm__ __volatile__ ( \
17 "rdctl r8, status\n" \
18 "andi r8, r8, 0xfffe\n" \
19 "wrctl status, r8\n" \
20 : : : "r8")
21
22#define local_save_flags(x) __asm__ __volatile__ ( \
23 "rdctl r8, status\n" \
24 "mov %0, r8\n" \
25 : "=r" (x) : : "r8", "memory")
26
27#define local_irq_restore(x) __asm__ __volatile__ ( \
28 "mov r8, %0\n" \
29 "wrctl status, r8\n" \
30 : : "r" (x) : "r8", "memory")
31
32/* For spinlocks etc */
33#define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } \
34 while (0)
35
36#define irqs_disabled() \
37({ \
38 unsigned long flags; \
39 local_save_flags(flags); \
40 ((flags & NIOS2_STATUS_PIE_MSK) == 0x0); \
41})
42
Thomas Chou7a6a7d12010-08-16 10:49:44 +080043/* indirect call to go beyond 256MB limitation of toolchain */
44#define nios2_callr(addr) __asm__ __volatile__ ( \
45 "callr %0" \
46 : : "r" (addr))
47
wdenk5c952cf2004-10-10 21:27:30 +000048#endif /* __ASM_NIOS2_SYSTEM_H */