2 Intel's XScale Microarchitecture provides support for locking of data
3 and instructions into the appropriate caches. This file provides
4 an overview of the API that has been developed to take advantage of this
5 feature from kernel space. Note that there is NO support for user space
8 For example usage of this code, grab:
10 ftp://source.mvista.com/pub/xscale/cache-test.c
12 If you have any questions, comments, patches, etc, please contact me.
14 Deepak Saxena <dsaxena@mvista.com>
21 #include <asm/xscale-lock.h>
23 II. Cache Capability Discovery
27 int cache_query(u8 cache_type,
28 struct cache_capabilities *pcache);
30 struct cache_capabilities
32 u32 flags; /* Flags defining capabilities */
33 u32 cache_size; /* Cache size in K (1024 bytes) */
34 u32 max_lock; /* Maximum lockable region in K */
42 * Bit 0: Cache lockability
43 * Bits 1-31: Reserved for future use
45 #define CACHE_LOCKABLE 0x00000001 /* Cache can be locked */
55 This function fills out the pcache capability identifier for the
56 requested cache. cache_type is either DCACHE or ICACHE. This
57 function is not very useful at the moment as all XScale CPU's
58 have the same size Cache, but is is provided for future XScale
59 based processors that may have larger cache sizes.
63 This function returns 0 if no error occurs, otherwise it returns
64 a negative, errno compatible value.
66 -EIO Unknown hardware error
72 int cache_lock(void *addr, u32 len, u8 cache_type, const char *desc);
76 This function locks a physically contigous portion of memory starting
77 at the virtual address pointed to by addr into the cache referenced
80 The address of the data/instruction that is to be locked must be
81 aligned on a cache line boundary (L1_CACHE_ALIGNEMENT).
83 The desc parameter is an optional (pass NULL if not used) human readable
84 descriptor of the locked memory region that is used by the cache
85 management code to build the /proc/cache_locks table.
87 Note that this function does not check whether the address is valid
88 or not before locking it into the cache. That duty is up to the
89 caller. Also, it does not check for duplicate or overlaping
94 If the function is successful in locking the entry into cache, a
97 If an error occurs, an appropriate error value is returned.
99 -EINVAL The memory address provided was not cache line aligned
100 -ENOMEM Could not allocate memory to complete operation
101 -ENOSPC Not enough space left on cache to lock in requested region
108 int cache_unlock(void *addr)
112 This function unlocks a portion of memory that was previously locked
113 into either the I or D cache.
117 If the entry is cleanly unlocked from the cache, a 0 is returned.
118 In the case of an error, an appropriate error is returned.
120 -ENOENT No entry with given address associated with this cache