noncached memory
allocnone-cached memory in uboot.1. APIarch\arm\include\asm\system.hvoid noncached_init(void);phys_addr_t noncached_alloc(size_t size, size_t align);2. implementationarch/arm/lib/cache.c#ifdef CONFIG_
·
alloc none-cached memory in uboot.
1. API
arch\arm\include\asm\system.h
void noncached_init(void);
phys_addr_t noncached_alloc(size_t size, size_t align);
2. implementation
arch/arm/lib/cache.c
#ifdef CONFIG_SYS_NONCACHED_MEMORY
/*
* Reserve one MMU section worth of address space below the malloc() area that
* will be mapped uncached.
*/
static unsigned long noncached_start;
static unsigned long noncached_end;
static unsigned long noncached_next;
void noncached_init(void)
{
phys_addr_t start, end;
size_t size;
/* If this calculation changes, update board_f.c:reserve_noncached() */
end = ALIGN(mem_malloc_start, MMU_SECTION_SIZE) - MMU_SECTION_SIZE;
size = ALIGN(CONFIG_SYS_NONCACHED_MEMORY, MMU_SECTION_SIZE);
start = end - size;
debug("mapping memory %pa-%pa non-cached\n", &start, &end);
noncached_start = start;
noncached_end = end;
noncached_next = start;
#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
mmu_set_region_dcache_behaviour(noncached_start, size, DCACHE_OFF);
#endif
}
phys_addr_t noncached_alloc(size_t size, size_t align)
{
phys_addr_t next = ALIGN(noncached_next, align);
if (next >= noncached_end || (noncached_end - next) < size)
return 0;
debug("allocated %zu bytes of uncached memory @%pa\n", size, &next);
noncached_next = next + size;
return next;
}
#endif
init:
board_init_r -> init_sequence_r -> initr_noncached -> noncached_init
3. usage
3.1 define CONFIG_SYS_NONCACHED_MEMORY
include/configs/mc40_common.h
#define CONFIG_SYS_NONCACHED_MEMORY (1 << 20) //1MB noncached memory
3.2 alloc noncached memory
for example, in dwc_eth_qos.c:
static void *eqos_alloc_descs(unsigned int num)
{
#ifdef CONFIG_SYS_NONCACHED_MEMORY
return (void *)noncached_alloc(EQOS_DESCRIPTORS_SIZE,
EQOS_DESCRIPTOR_ALIGN);
#else
return memalign(EQOS_DESCRIPTOR_ALIGN, EQOS_DESCRIPTORS_SIZE);
#endif
}
更多推荐
已为社区贡献2条内容
所有评论(0)