1 /*
2  *  linux/include/asm-arm/proc-armo/system.h
3  *
4  *  Copyright (C) 1995, 1996 Russell King
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 #ifndef __ASM_PROC_SYSTEM_H
11 #define __ASM_PROC_SYSTEM_H
12 
13 #include <asm/proc-fns.h>
14 
15 #define vectors_base()	(0)
16 
__xchg(unsigned long x,volatile void * ptr,int size)17 static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
18 {
19 	extern void __bad_xchg(volatile void *, int);
20 
21 	switch (size) {
22 		case 1:	return cpu_xchg_1(x, ptr);
23 		case 4:	return cpu_xchg_4(x, ptr);
24 		default: __bad_xchg(ptr, size);
25 	}
26 	return 0;
27 }
28 
29 /*
30  * We need to turn the caches off before calling the reset vector - RiscOS
31  * messes up if we don't
32  */
33 #define proc_hard_reset()	cpu_proc_fin()
34 
35 /*
36  * A couple of speedups for the ARM
37  */
38 
39 /*
40  * Save the current interrupt enable state & disable IRQs
41  */
42 #define local_save_flags_cli(x)				\
43 	do {						\
44 	  unsigned long temp;				\
45 	  __asm__ __volatile__(				\
46 "	mov	%0, pc		@ save_flags_cli\n"	\
47 "	orr	%1, %0, #0x08000000\n"			\
48 "	and	%0, %0, #0x0c000000\n"			\
49 "	teqp	%1, #0\n"				\
50 	  : "=r" (x), "=r" (temp)			\
51 	  :						\
52 	  : "memory");					\
53 	} while (0)
54 
55 /*
56  * Enable IRQs
57  */
58 #define local_irq_enable()			\
59 	do {					\
60 	  unsigned long temp;			\
61 	  __asm__ __volatile__(			\
62 "	mov	%0, pc		@ sti\n"	\
63 "	bic	%0, %0, #0x08000000\n"		\
64 "	teqp	%0, #0\n"			\
65 	  : "=r" (temp)				\
66 	  :					\
67 	  : "memory");				\
68 	} while(0)
69 
70 /*
71  * Disable IRQs
72  */
73 #define local_irq_disable()			\
74 	do {					\
75 	  unsigned long temp;			\
76 	  __asm__ __volatile__(			\
77 "	mov	%0, pc		@ cli\n"	\
78 "	orr	%0, %0, #0x08000000\n"		\
79 "	teqp	%0, #0\n"			\
80 	  : "=r" (temp)				\
81 	  :					\
82 	  : "memory");				\
83 	} while(0)
84 
85 #define __clf()	do {				\
86 	unsigned long temp;			\
87 	__asm__ __volatile__(			\
88 "	mov	%0, pc		@ clf\n"	\
89 "	orr	%0, %0, #0x04000000\n"		\
90 "	teqp	%0, #0\n"			\
91 	: "=r" (temp));				\
92     } while(0)
93 
94 #define __stf()	do {				\
95 	unsigned long temp;			\
96 	__asm__ __volatile__(			\
97 "	mov	%0, pc		@ stf\n"	\
98 "	bic	%0, %0, #0x04000000\n"		\
99 "	teqp	%0, #0\n"			\
100 	: "=r" (temp));				\
101     } while(0)
102 
103 /*
104  * save current IRQ & FIQ state
105  */
106 #define local_save_flags(x)			\
107 	do {					\
108 	  __asm__ __volatile__(			\
109 "	mov	%0, pc		@ save_flags\n"	\
110 "	and	%0, %0, #0x0c000000\n"		\
111 	  : "=r" (x));				\
112 	} while (0)
113 
114 /*
115  * restore saved IRQ & FIQ state
116  */
117 #define local_irq_restore(x)				\
118 	do {						\
119 	  unsigned long temp;				\
120 	  __asm__ __volatile__(				\
121 "	mov	%0, pc		@ restore_flags\n"	\
122 "	bic	%0, %0, #0x0c000000\n"			\
123 "	orr	%0, %0, %1\n"				\
124 "	teqp	%0, #0\n"				\
125 	  : "=&r" (temp)				\
126 	  : "r" (x)					\
127 	  : "memory");					\
128 	} while (0)
129 
130 #define __save_and_sti(x)	({__save_flags(x);__sti();})
131 
132 #endif
133