|
6 | 6 |
|
7 | 7 | #include <common.h>
|
8 | 8 | #include <cpu_func.h>
|
| 9 | +#include <malloc.h> |
9 | 10 | #include <asm/cache.h>
|
10 | 11 | #include <asm/cacheops.h>
|
11 | 12 | #include <asm/cm.h>
|
@@ -197,3 +198,45 @@ void dcache_disable(void)
|
197 | 198 | /* ensure the pipeline doesn't contain now-invalid instructions */
|
198 | 199 | instruction_hazard_barrier();
|
199 | 200 | }
|
| 201 | + |
| 202 | +#ifdef CONFIG_SYS_NONCACHED_MEMORY |
| 203 | +static unsigned long noncached_start; |
| 204 | +static unsigned long noncached_end; |
| 205 | +static unsigned long noncached_next; |
| 206 | + |
| 207 | +void noncached_set_region(void) |
| 208 | +{ |
| 209 | +} |
| 210 | + |
| 211 | +int noncached_init(void) |
| 212 | +{ |
| 213 | + phys_addr_t start, end; |
| 214 | + size_t size; |
| 215 | + |
| 216 | + /* If this calculation changes, update board_f.c:reserve_noncached() */ |
| 217 | + end = ALIGN(mem_malloc_start, MMU_SECTION_SIZE) - MMU_SECTION_SIZE; |
| 218 | + size = ALIGN(CONFIG_SYS_NONCACHED_MEMORY, MMU_SECTION_SIZE); |
| 219 | + start = end - size; |
| 220 | + |
| 221 | + debug("mapping memory %pa-%pa non-cached\n", &start, &end); |
| 222 | + |
| 223 | + noncached_start = start; |
| 224 | + noncached_end = end; |
| 225 | + noncached_next = start; |
| 226 | + |
| 227 | + return 0; |
| 228 | +} |
| 229 | + |
| 230 | +phys_addr_t noncached_alloc(size_t size, size_t align) |
| 231 | +{ |
| 232 | + phys_addr_t next = ALIGN(noncached_next, align); |
| 233 | + |
| 234 | + if (next >= noncached_end || (noncached_end - next) < size) |
| 235 | + return 0; |
| 236 | + |
| 237 | + debug("allocated %zu bytes of uncached memory @%pa\n", size, &next); |
| 238 | + noncached_next = next + size; |
| 239 | + |
| 240 | + return CKSEG1ADDR(next); |
| 241 | +} |
| 242 | +#endif /* CONFIG_SYS_NONCACHED_MEMORY */ |
0 commit comments