1 /******************************************************************************
2 * Copyright (c) 2004, 2008 IBM Corporation
4 * This program and the accompanying materials
5 * are made available under the terms of the BSD License
6 * which accompanies this distribution, and is available at
7 * http://www.opensource.org/licenses/bsd-license.php
10 * IBM Corporation - initial implementation
11 *****************************************************************************/
19 #define cache_inhibited_access(type,name) \
20 static inline type ci_read_##name(type * addr) \
28 static inline void ci_write_##name(type * addr, type data) \
35 cache_inhibited_access(uint8_t, 8)
36 cache_inhibited_access(uint16_t, 16)
37 cache_inhibited_access(uint32_t, 32)
38 cache_inhibited_access(uint64_t, 64)
40 #define _FWOVERLAP(s, d, size) ((d >= s) && ((type_u)d < ((type_u)s + size)))
43 #define _FWMOVE(s, d, size, t) \
44 { t *s1=(t *)s, *d1=(t *)d; \
45 while (size > 0) { *d1++ = *s1++; size -= sizeof(t); } }
47 #define _BWMOVE(s, d, size, t) { \
48 t *s1=(t *)((char *)s+size), *d1=(t *)((char *)d+size); \
49 while (size > 0) { *--d1 = *--s1; size -= sizeof(t); } \
53 #define _MOVE(s, d, size, t) if _FWOVERLAP(s, d, size) _BWMOVE(s, d, size, t) else _FWMOVE(s, d, size, t)
55 #define _FASTMOVE(s, d, size) \
56 switch (((type_u)s | (type_u)d | size) & (sizeof(type_u)-1)) { \
57 case 0: _MOVE(s, d, size, type_u); break; \
58 case sizeof(type_l): _MOVE(s, d, size, type_l); break; \
59 case sizeof(type_w): _MOVE(s, d, size, type_w); break; \
60 default: _MOVE(s, d, size, type_c); break; \
63 // Device IO block data helpers
64 #define _FWRMOVE(s, d, size, t) \
65 { t *s1=(t *)s, *d1=(t *)d; SET_CI; \
66 while (size > 0) { *d1++ = *s1++; size -= sizeof(t); } \
70 #define _BWRMOVE(s, d, size, t) { \
71 t *s1=(t *)((char *)s+size), *d1=(t *)((char *)d+size); SET_CI; \
72 while (size > 0) { *--d1 = *--s1; size -= sizeof(t); } \
76 #define _RMOVE(s, d, size, t) if _FWOVERLAP(s, d, size) _BWRMOVE(s, d, size, t) else _FWRMOVE(s, d, size, t)
78 #define _FASTRMOVE(s, d, size) \
79 switch (((type_u)s | (type_u)d | size) & (sizeof(type_u)-1)) { \
80 case 0: _RMOVE(s, d, size, type_u); break; \
81 case sizeof(type_l): _RMOVE(s, d, size, type_l); break; \
82 case sizeof(type_w): _RMOVE(s, d, size, type_w); break; \
83 default: _RMOVE(s, d, size, type_c); break; \