* Some architectures map /dev/mem memory in a way that doesn't support * unaligned accesses. Most normal libc memcpy()s aren't safe to use in this * case, so build our own which makes sure to never do unaligned accesses on * *src (*dest is fine since we never map /dev/mem for writing). */
| 135 | * *src (*dest is fine since we never map /dev/mem for writing). |
| 136 | */ |
| 137 | static void *aligned_memcpy(void *dest, const void *src, size_t n) |
| 138 | { |
| 139 | uint8_t *d = dest; |
| 140 | const volatile uint8_t *s = src; /* volatile to prevent optimization */ |
| 141 | |
| 142 | while ((uintptr_t)s & (sizeof(size_t) - 1)) { |
| 143 | if (n-- == 0) |
| 144 | return dest; |
| 145 | *d++ = *s++; |
| 146 | } |
| 147 | |
| 148 | while (n >= sizeof(size_t)) { |
| 149 | *(size_t *)d = *(const volatile size_t *)s; |
| 150 | d += sizeof(size_t); |
| 151 | s += sizeof(size_t); |
| 152 | n -= sizeof(size_t); |
| 153 | } |
| 154 | |
| 155 | while (n-- > 0) |
| 156 | *d++ = *s++; |
| 157 | |
| 158 | return dest; |
| 159 | } |
| 160 | |
| 161 | /* Return < 0 on error, 0 on success. */ |
| 162 | static int parse_cbtable(uint64_t address, size_t table_size) |
no outgoing calls
no test coverage detected