/* * Copyright (c) 2008-2016 Allwinner Technology Co. Ltd. * All rights reserved. * * File : memoryAdapter.c * Description : * History : * Author : xyliu * Date : 2016/04/13 * Comment : * * */ #include #include #include #include #include #include #include #include #include #include #include #include "memoryAdapter.h" #include "log.h" #include "ionMemory/ionAllocEntry.h" #include "secureMemory/secureAllocEntry.h" #define NODE_DDR_FREQ "/sys/class/devfreq/sunxi-ddrfreq/cur_freq" static int readNodeValue(const char *node, char * strVal, size_t size) { int ret = -1; int fd = open(node, O_RDONLY); if (fd >= 0) { read(fd, strVal, size); close(fd); ret = 0; } return ret; } //* get current ddr frequency, if it is too slow, we will cut some spec off. int MemAdapterGetDramFreq() { CEDARC_UNUSE(MemAdapterGetDramFreq); char freq_val[8] = {0}; if (!readNodeValue(NODE_DDR_FREQ, freq_val, 8)) { return atoi(freq_val); } // unknow freq return -1; } struct ScMemOpsS* MemAdapterGetOpsS() { return __GetIonMemOpsS(); } struct ScMemOpsS* SecureMemAdapterGetOpsS() { #if(PLATFORM_SURPPORT_SECURE_OS == 1) return __GetSecureMemOpsS(); #else loge("platform not surpport secure os, return null"); return NULL; #endif }