TMS320C6678上有L1P L1D L2;
调用malloc,成功申请的内存空间是L2上的吗?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
malloc是从heap上申请内存,请查看map文件中.sysmem分配在哪段空间,即为malloc申请的内存空间。
我正在在看srio_loopback.c的例程,一部分代码如下
t_buff = malloc(TARGET_SIZE);
if(t_buff == NULL) {
printf("Failed to alloc meory !\r\n");
return -1;
}
/* read the DSP Core Number */
core_num = CSL_chipReadReg(CSL_CHIP_DNUM);
/* srio transmit test: srio write(NWRITE) --> srio read(NREAD) */
ret = srio_test(core_num, (uint32_t)Convert_CoreLocal2GlobalAddr((uint32_t)t_buff), TARGET_SIZE, Srio_Ftype_WRITE);
if(ret != 0) {
printf("srio test occur error! \r\n");
return -1;
}
/**
* @brief This function convert L2SARM inter address to global address
*
* @param addr L2SRAM inter address
*
* @return 32bit-addr
*/
uint32_t Convert_CoreLocal2GlobalAddr(uint32_t addr)
{
uint32_t corenum;
/* Get the core number. */
corenum = CSL_chipReadReg(CSL_CHIP_DNUM);
if((addr >= (uint32_t) 0x800000) && (addr < (uint32_t) 0x880000)) {
/* Compute the global address. */
return ((1 << 28) | (corenum << 24) | (addr & 0x00ffffff));
} else {
return addr;
}
}
t_buff在初始化(malloc)后,调用Convert_CoreLocal2GlobalAddr(),进行一次地址转换,为什么这样做?
从函数名来看功能是将local L2的地址转换成global的地址,这样所有的core都能访问该地址。