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
|
/* $OpenBSD: atomic.h,v 1.4 2010/06/27 00:04:44 jsing Exp $ */
/* Public Domain */
#ifndef __HPPA_ATOMIC_H__
#define __HPPA_ATOMIC_H__
#if defined(_KERNEL)
#include <sys/mutex.h>
#ifdef MULTIPROCESSOR
extern struct mutex mtx_atomic;
#define ATOMIC_LOCK mtx_enter(&mtx_atomic)
#define ATOMIC_UNLOCK mtx_leave(&mtx_atomic)
#else
#define ATOMIC_LOCK
#define ATOMIC_UNLOCK
#endif
static __inline void
atomic_setbits_int(__volatile unsigned int *uip, unsigned int v)
{
register_t eiem;
__asm __volatile("mfctl %%cr15, %0": "=r" (eiem));
__asm __volatile("mtctl %r0, %cr15");
ATOMIC_LOCK;
*uip |= v;
ATOMIC_UNLOCK;
__asm __volatile("mtctl %0, %%cr15":: "r" (eiem));
}
static __inline void
atomic_clearbits_int(__volatile unsigned int *uip, unsigned int v)
{
register_t eiem;
__asm __volatile("mfctl %%cr15, %0": "=r" (eiem));
__asm __volatile("mtctl %r0, %cr15");
ATOMIC_LOCK;
*uip &= ~v;
ATOMIC_UNLOCK;
__asm __volatile("mtctl %0, %%cr15":: "r" (eiem));
}
static __inline void
atomic_setbits_long(__volatile unsigned long *uip, unsigned long v)
{
register_t eiem;
__asm __volatile("mfctl %%cr15, %0": "=r" (eiem));
__asm __volatile("mtctl %r0, %cr15");
ATOMIC_LOCK;
*uip |= v;
ATOMIC_UNLOCK;
__asm __volatile("mtctl %0, %%cr15":: "r" (eiem));
}
static __inline void
atomic_clearbits_long(__volatile unsigned long *uip, unsigned long v)
{
register_t eiem;
__asm __volatile("mfctl %%cr15, %0": "=r" (eiem));
__asm __volatile("mtctl %r0, %cr15");
ATOMIC_LOCK;
*uip &= ~v;
ATOMIC_UNLOCK;
__asm __volatile("mtctl %0, %%cr15":: "r" (eiem));
}
#endif /* defined(_KERNEL) */
#endif /* __HPPA_ATOMIC_H__ */
|