2 * $Id: system.h,v 1.47 1999/08/22 12:31:08 paulus Exp $
4 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
9 #include <linux/kdev_t.h>
11 #include <asm/processor.h>
12 #include <asm/atomic.h>
13 #include <asm/irq_control.h>
17 * The sync instruction guarantees that all memory accesses initiated
18 * by this processor have been performed (with respect to all other
19 * mechanisms that access memory). The eieio instruction is a barrier
20 * providing an ordering (separately) for (a) cacheable stores and (b)
21 * loads and stores to non-cacheable memory (e.g. I/O devices).
23 * mb() prevents loads and stores being reordered across this point.
24 * rmb() prevents loads being reordered across this point.
25 * wmb() prevents stores being reordered across this point.
27 * We can use the eieio instruction for wmb, but since it doesn't
28 * give any ordering guarantees about loads, we have to use the
29 * stronger but slower sync instruction for mb and rmb.
31 #define mb() __asm__ __volatile__ ("sync" : : : "memory")
32 #define rmb() __asm__ __volatile__ ("sync" : : : "memory")
33 #define wmb() __asm__ __volatile__ ("eieio" : : : "memory")
35 extern void xmon_irq(int, void *, struct pt_regs
*);
36 extern void xmon(struct pt_regs
*excp
);
39 /* Data cache block flush - write out the cache line containing the
40 specified address and then invalidate it in the cache. */
41 extern __inline__
void dcbf(void *line
)
43 asm("dcbf %0,%1; sync" : : "r" (line
), "r" (0));
46 extern void print_backtrace(unsigned long *);
47 extern void show_regs(struct pt_regs
* regs
);
48 extern void flush_instruction_cache(void);
49 extern void hard_reset_now(void);
50 extern void poweroff_now(void);
51 extern int _get_PVR(void);
52 extern long _get_L2CR(void);
53 extern void _set_L2CR(unsigned long);
54 extern void via_cuda_init(void);
55 extern void pmac_nvram_init(void);
56 extern void read_rtc_time(void);
57 extern void pmac_find_display(void);
58 extern void giveup_fpu(struct task_struct
*);
59 extern void enable_kernel_fp(void);
60 extern void cvt_fd(float *from
, double *to
, unsigned long *fpscr
);
61 extern void cvt_df(double *from
, float *to
, unsigned long *fpscr
);
62 extern int call_rtas(const char *, int, int, unsigned long *, ...);
65 extern void note_scsi_host(struct device_node
*, void *);
68 #define prepare_to_switch() do { } while(0)
69 #define switch_to(prev,next,last) _switch_to((prev),(next),&(last))
70 extern void _switch_to(struct task_struct
*, struct task_struct
*,
71 struct task_struct
**);
74 extern struct task_struct
*_switch(struct thread_struct
*prev
,
75 struct thread_struct
*next
);
77 extern unsigned int rtas_data
;
80 extern void dump_regs(struct pt_regs
*);
86 #define save_flags(flags) __save_flags(flags)
87 #define restore_flags(flags) __restore_flags(flags)
88 #define save_and_cli(flags) __save_and_cli(flags)
92 extern void __global_cli(void);
93 extern void __global_sti(void);
94 extern unsigned long __global_save_flags(void);
95 extern void __global_restore_flags(unsigned long);
96 #define cli() __global_cli()
97 #define sti() __global_sti()
98 #define save_flags(x) ((x)=__global_save_flags())
99 #define restore_flags(x) __global_restore_flags(x)
101 #endif /* !__SMP__ */
103 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
105 extern unsigned long xchg_u64(void *ptr
, unsigned long val
);
106 extern unsigned long xchg_u32(void *ptr
, unsigned long val
);
109 * This function doesn't exist, so you'll get a linker error
110 * if something tries to do an invalid xchg().
112 * This only works if the compiler isn't horribly bad at optimizing.
113 * gcc-2.5.8 reportedly can't handle this, but as that doesn't work
114 * too well on the alpha anyway..
116 extern void __xchg_called_with_bad_pointer(void);
118 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
119 #define tas(ptr) (xchg((ptr),1))
121 static inline unsigned long __xchg(unsigned long x
, void * ptr
, int size
)
125 return (unsigned long )xchg_u32(ptr
, x
);
127 return (unsigned long )xchg_u64(ptr
, x
);
129 __xchg_called_with_bad_pointer();
135 extern inline void * xchg_ptr(void * m
, void * val
)
137 return (void *) xchg_u32(m
, (unsigned long) val
);