1/*
2 *  Generic cache management functions. Everything is arch-specific,
3 *  but this header exists to make sure the defines/functions can be
4 *  used in a generic way.
5 *
6 *  2000-11-13  Arjan van de Ven   <arjan@fenrus.demon.nl>
7 *
8 */
9
10#ifndef _LINUX_PREFETCH_H
11#define _LINUX_PREFETCH_H
12
13#include <asm/processor.h>
14#include <asm/cache.h>
15
16/*
17	prefetch(x) attempts to pre-emptively get the memory pointed to
18	by address "x" into the CPU L1 cache.
19	prefetch(x) should not cause any kind of exception, prefetch(0) is
20	specifically ok.
21
22	prefetch() should be defined by the architecture, if not, the
23	#define below provides a no-op define.
24
25	There are 3 prefetch() macros:
26
27	prefetch(x)  	- prefetches the cacheline at "x" for read
28	prefetchw(x)	- prefetches the cacheline at "x" for write
29	spin_lock_prefetch(x) - prefectches the spinlock *x for taking
30
31	there is also PREFETCH_STRIDE which is the architecure-prefered
32	"lookahead" size for prefetching streamed operations.
33
34*/
35
36/*
37 *	These cannot be do{}while(0) macros. See the mental gymnastics in
38 *	the loop macro.
39 */
40
41#ifndef ARCH_HAS_PREFETCH
42#define ARCH_HAS_PREFETCH
43static inline void prefetch(const void *x) {;}
44#endif
45
46#ifndef ARCH_HAS_PREFETCHW
47#define ARCH_HAS_PREFETCHW
48static inline void prefetchw(const void *x) {;}
49#endif
50
51#ifndef ARCH_HAS_SPINLOCK_PREFETCH
52#define ARCH_HAS_SPINLOCK_PREFETCH
53#define spin_lock_prefetch(x) prefetchw(x)
54#endif
55
56#ifndef PREFETCH_STRIDE
57#define PREFETCH_STRIDE (4*L1_CACHE_BYTES)
58#endif
59
60#endif
61