xref: /openbmc/u-boot/arch/nios2/include/asm/system.h (revision d9b23e26)
1 /*
2  * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
3  * Scott McNutt <smcnutt@psyent.com>
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 #ifndef __ASM_NIOS2_SYSTEM_H_
8 #define __ASM_NIOS2_SYSTEM_H_
9 
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 
43 /* indirect call to go beyond 256MB limitation of toolchain */
44 #define nios2_callr(addr) __asm__ __volatile__ (	\
45 	"callr	%0"					\
46 	: : "r" (addr))
47 
48 void display_sysid(void);
49 
50 #endif /* __ASM_NIOS2_SYSTEM_H */
51