1 #ifndef __PARISC_SYSTEM_H
2 #define __PARISC_SYSTEM_H
4 #include <linux/config.h>
7 /* The program status word as bitfields. */
39 #define pa_psw(task) ((struct pa_psw *) ((char *) (task) + TASK_PT_PSW + 4))
41 #define pa_psw(task) ((struct pa_psw *) ((char *) (task) + TASK_PT_PSW))
46 extern struct task_struct
*_switch_to(struct task_struct
*, struct task_struct
*);
48 #define switch_to(prev, next, last) do { \
49 (last) = _switch_to(prev, next); \
54 /* interrupt control */
55 #define local_save_flags(x) __asm__ __volatile__("ssm 0, %0" : "=r" (x) : : "memory")
56 #define local_irq_disable() __asm__ __volatile__("rsm %0,%%r0\n" : : "i" (PSW_I) : "memory" )
57 #define local_irq_enable() __asm__ __volatile__("ssm %0,%%r0\n" : : "i" (PSW_I) : "memory" )
59 #define local_irq_save(x) \
60 __asm__ __volatile__("rsm %1,%0" : "=r" (x) :"i" (PSW_I) : "memory" )
61 #define local_irq_restore(x) \
62 __asm__ __volatile__("mtsm %0" : : "r" (x) : "memory" )
64 #define irqs_disabled() \
66 unsigned long flags; \
67 local_save_flags(flags); \
68 (flags & PSW_I) == 0; \
71 #define mfctl(reg) ({ \
73 __asm__ __volatile__( \
74 "mfctl " #reg ",%0" : \
80 #define mtctl(gr, cr) \
81 __asm__ __volatile__("mtctl %0,%1" \
83 : "r" (gr), "i" (cr) : "memory")
85 /* these are here to de-mystefy the calling code, and to provide hooks */
86 /* which I needed for debugging EIEM problems -PB */
87 #define get_eiem() mfctl(15)
88 static inline void set_eiem(unsigned long val
)
93 #define mfsp(reg) ({ \
95 __asm__ __volatile__( \
96 "mfsp " #reg ",%0" : \
102 #define mtsp(gr, cr) \
103 __asm__ __volatile__("mtsp %0,%1" \
105 : "r" (gr), "i" (cr) : "memory")
109 ** This is simply the barrier() macro from linux/kernel.h but when serial.c
110 ** uses tqueue.h uses smp_mb() defined using barrier(), linux/kernel.h
111 ** hasn't yet been included yet so it fails, thus repeating the macro here.
113 ** PA-RISC architecture allows for weakly ordered memory accesses although
114 ** none of the processors use it. There is a strong ordered bit that is
115 ** set in the O-bit of the page directory entry. Operating systems that
116 ** can not tolerate out of order accesses should set this bit when mapping
117 ** pages. The O-bit of the PSW should also be set to 1 (I don't believe any
118 ** of the processor implemented the PSW O-bit). The PCX-W ERS states that
119 ** the TLB O-bit is not implemented so the page directory does not need to
120 ** have the O-bit set when mapping pages (section 3.1). This section also
121 ** states that the PSW Y, Z, G, and O bits are not implemented.
122 ** So it looks like nothing needs to be done for parisc-linux (yet).
123 ** (thanks to chada for the above comment -ggg)
125 ** The __asm__ op below simple prevents gcc/ld from reordering
126 ** instructions across the mb() "call".
128 #define mb() __asm__ __volatile__("":::"memory") /* barrier() */
131 #define smp_mb() mb()
132 #define smp_rmb() mb()
133 #define smp_wmb() mb()
134 #define smp_read_barrier_depends() do { } while(0)
135 #define read_barrier_depends() do { } while(0)
137 #define set_mb(var, value) do { var = value; mb(); } while (0)
138 #define set_wmb(var, value) do { var = value; wmb(); } while (0)
142 /* Because kmalloc only guarantees 8-byte alignment for kmalloc'd data,
143 and GCC only guarantees 8-byte alignment for stack locals, we can't
144 be assured of 16-byte alignment for atomic lock data even if we
145 specify "__attribute ((aligned(16)))" in the type declaration. So,
146 we use a struct containing an array of four ints for the atomic lock
147 type and dynamically select the 16-byte aligned int from the array
148 for the semaphore. */
150 #define __PA_LDCW_ALIGNMENT 16
151 #define __ldcw_align(a) ({ \
152 unsigned long __ret = (unsigned long) &(a)->lock[0]; \
153 __ret = (__ret + __PA_LDCW_ALIGNMENT - 1) & ~(__PA_LDCW_ALIGNMENT - 1); \
154 (volatile unsigned int *) __ret; \
158 #else /*CONFIG_PA20*/
159 /* From: "Jim Hull" <jim.hull of hp.com>
160 I've attached a summary of the change, but basically, for PA 2.0, as
161 long as the ",CO" (coherent operation) completer is specified, then the
162 16-byte alignment requirement for ldcw and ldcd is relaxed, and instead
163 they only require "natural" alignment (4-byte for ldcw, 8-byte for
166 #define __PA_LDCW_ALIGNMENT 4
167 #define __ldcw_align(a) ((volatile unsigned int *)a)
168 #define LDCW "ldcw,co"
170 #endif /*!CONFIG_PA20*/
172 /* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */
173 #define __ldcw(a) ({ \
175 __asm__ __volatile__(LDCW " 0(%1),%0" : "=r" (__ret) : "r" (a)); \
180 # define __lock_aligned __attribute__((__section__(".data.lock_aligned")))
183 #define KERNEL_START (0x10100000 - 0x1000)
184 #define arch_align_stack(x) (x)