static int do_vbexport_test_malloc_size(uint32_t size) { char *mem = VbExMalloc(size); int i, line_size; #if CONFIG_ARM line_size = dcache_get_line_size(); #elif defined CACHE_LINE_SIZE line_size = CACHE_LINE_SIZE; #else line_size = __BIGGEST_ALIGNMENT__; #endif VbExDebug("Trying to malloc a memory block for %lu bytes...", size); if ((uintptr_t)mem % line_size != 0) { VbExDebug("\nMemory not algined with a cache line!\n"); VbExFree(mem); return 1; } for (i = 0; i < size; i++) { mem[i] = i % 0x100; } for (i = 0; i < size; i++) { if (mem[i] != i % 0x100) { VbExDebug("\nMemory verification failed!\n"); VbExFree(mem); return 1; } } VbExFree(mem); VbExDebug(" - SUCCESS\n"); return 0; }
void *cros_memalign_cache(size_t n) { static unsigned int dcache_line_size; if (!dcache_line_size) { /* Select cache line size based on available information */ #ifdef CONFIG_ARM dcache_line_size = dcache_get_line_size(); #elif defined CACHE_LINE_SIZE dcache_line_size = CACHE_LINE_SIZE; #else dcache_line_size = __BIGGEST_ALIGNMENT__; #endif } return memalign(dcache_line_size, n); }