summaryrefslogtreecommitdiffstats
path: root/include/asm-ppc/system.h
blob: a1a3f12a0acd26196db0794293d7a18855219a42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef __PPC_SYSTEM_H
#define __PPC_SYSTEM_H

#if 0
#define mb() \
__asm__ __volatile__("mb": : :"memory")
#endif
#define mb()  __asm__ __volatile__ (""   : : :"memory")


extern void __save_flags(long *flags);
extern void __restore_flags(long flags);
extern void sti(void);
extern void cli(void);
extern int _disable_interrupts(void);
extern void _enable_interrupts(int);

/*extern void memcpy(void *, void *, int);*/

struct task_struct;
extern void switch_to(struct task_struct *prev, struct task_struct *next);

#define save_flags(flags) __save_flags(&(flags))
#define restore_flags(flags) __restore_flags(flags)

#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))

/* this guy lives in arch/ppc/kernel */
extern inline unsigned long *xchg_u32(void *m, unsigned long val);

/*
 *  these guys don't exist.
 *  someone should create them.
 *              -- Cort
 */
extern void *xchg_u64(void *ptr, unsigned long val);
extern int xchg_u8(char *m, char val);

/*
 * This function doesn't exist, so you'll get a linker error
 * if something tries to do an invalid xchg().
 *
 * This only works if the compiler isn't horribly bad at optimizing.
 * gcc-2.5.8 reportedly can't handle this, but as that doesn't work
 * too well on the alpha anyway..
 */
extern void __xchg_called_with_bad_pointer(void);

static inline unsigned long __xchg(unsigned long x, void * ptr, int size)
{
	switch (size) {
		case 4:
			return (unsigned long )xchg_u32(ptr, x);
		case 8:
			return (unsigned long )xchg_u64(ptr, x);
	}
	__xchg_called_with_bad_pointer();
	return x;


}



extern inline int tas(char * m)
{
	return xchg_u8(m,1);
}

extern inline void * xchg_ptr(void * m, void * val)
{
	return (void *) xchg_u32(m, (unsigned long) val);
}

#endif