Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | ef3386f | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2004, Psyent Corporation <www.psyent.com> |
| 4 | * Scott McNutt <smcnutt@psyent.com> |
wdenk | ef3386f | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __ASM_NIOS2_SYSTEM_H_ |
| 7 | #define __ASM_NIOS2_SYSTEM_H_ |
| 8 | |
Thomas Chou | 84b8f17 | 2010-03-20 07:05:45 +0800 | [diff] [blame] | 9 | #define local_irq_enable() __asm__ __volatile__ ( \ |
| 10 | "rdctl r8, status\n" \ |
| 11 | "ori r8, r8, 1\n" \ |
| 12 | "wrctl status, r8\n" \ |
| 13 | : : : "r8") |
| 14 | |
| 15 | #define local_irq_disable() __asm__ __volatile__ ( \ |
| 16 | "rdctl r8, status\n" \ |
| 17 | "andi r8, r8, 0xfffe\n" \ |
| 18 | "wrctl status, r8\n" \ |
| 19 | : : : "r8") |
| 20 | |
| 21 | #define local_save_flags(x) __asm__ __volatile__ ( \ |
| 22 | "rdctl r8, status\n" \ |
| 23 | "mov %0, r8\n" \ |
| 24 | : "=r" (x) : : "r8", "memory") |
| 25 | |
| 26 | #define local_irq_restore(x) __asm__ __volatile__ ( \ |
| 27 | "mov r8, %0\n" \ |
| 28 | "wrctl status, r8\n" \ |
| 29 | : : "r" (x) : "r8", "memory") |
| 30 | |
| 31 | /* For spinlocks etc */ |
| 32 | #define local_irq_save(x) do { local_save_flags(x); local_irq_disable(); } \ |
| 33 | while (0) |
| 34 | |
| 35 | #define irqs_disabled() \ |
| 36 | ({ \ |
| 37 | unsigned long flags; \ |
| 38 | local_save_flags(flags); \ |
| 39 | ((flags & NIOS2_STATUS_PIE_MSK) == 0x0); \ |
| 40 | }) |
| 41 | |
Thomas Chou | 5975e79 | 2010-08-16 10:49:44 +0800 | [diff] [blame] | 42 | /* indirect call to go beyond 256MB limitation of toolchain */ |
| 43 | #define nios2_callr(addr) __asm__ __volatile__ ( \ |
| 44 | "callr %0" \ |
| 45 | : : "r" (addr)) |
| 46 | |
Thomas Chou | 36b9c9a | 2015-10-14 08:43:31 +0800 | [diff] [blame] | 47 | void display_sysid(void); |
| 48 | |
wdenk | ef3386f | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 49 | #endif /* __ASM_NIOS2_SYSTEM_H */ |