wdenk | ef3386f | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2004, Psyent Corporation <www.psyent.com> |
| 3 | * Scott McNutt <smcnutt@psyent.com> |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | ef3386f | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 6 | */ |
| 7 | #ifndef __ASM_NIOS2_SYSTEM_H_ |
| 8 | #define __ASM_NIOS2_SYSTEM_H_ |
| 9 | |
Thomas Chou | 84b8f17 | 2010-03-20 07:05:45 +0800 | [diff] [blame] | 10 | #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 Chou | 5975e79 | 2010-08-16 10:49:44 +0800 | [diff] [blame] | 43 | /* indirect call to go beyond 256MB limitation of toolchain */ |
| 44 | #define nios2_callr(addr) __asm__ __volatile__ ( \ |
| 45 | "callr %0" \ |
| 46 | : : "r" (addr)) |
| 47 | |
wdenk | ef3386f | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 48 | #endif /* __ASM_NIOS2_SYSTEM_H */ |