Root/
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 <linux/types.h> |
14 | #include <asm/processor.h> |
15 | #include <asm/cache.h> |
16 | |
17 | /* |
18 | prefetch(x) attempts to pre-emptively get the memory pointed to |
19 | by address "x" into the CPU L1 cache. |
20 | prefetch(x) should not cause any kind of exception, prefetch(0) is |
21 | specifically ok. |
22 | |
23 | prefetch() should be defined by the architecture, if not, the |
24 | #define below provides a no-op define. |
25 | |
26 | There are 3 prefetch() macros: |
27 | |
28 | prefetch(x) - prefetches the cacheline at "x" for read |
29 | prefetchw(x) - prefetches the cacheline at "x" for write |
30 | spin_lock_prefetch(x) - prefetches the spinlock *x for taking |
31 | |
32 | there is also PREFETCH_STRIDE which is the architecure-preferred |
33 | "lookahead" size for prefetching streamed operations. |
34 | |
35 | */ |
36 | |
37 | #ifndef ARCH_HAS_PREFETCH |
38 | #define prefetch(x) __builtin_prefetch(x) |
39 | #endif |
40 | |
41 | #ifndef ARCH_HAS_PREFETCHW |
42 | #define prefetchw(x) __builtin_prefetch(x,1) |
43 | #endif |
44 | |
45 | #ifndef ARCH_HAS_SPINLOCK_PREFETCH |
46 | #define spin_lock_prefetch(x) prefetchw(x) |
47 | #endif |
48 | |
49 | #ifndef PREFETCH_STRIDE |
50 | #define PREFETCH_STRIDE (4*L1_CACHE_BYTES) |
51 | #endif |
52 | |
53 | static inline void prefetch_range(void *addr, size_t len) |
54 | { |
55 | #ifdef ARCH_HAS_PREFETCH |
56 | char *cp; |
57 | char *end = addr + len; |
58 | |
59 | for (cp = addr; cp < end; cp += PREFETCH_STRIDE) |
60 | prefetch(cp); |
61 | #endif |
62 | } |
63 | |
64 | #endif |
65 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9