diff --git a/osp/src/ospCfgToBin.c b/osp/src/ospCfgToBin.c index e8fbe61..508a0f4 100644 --- a/osp/src/ospCfgToBin.c +++ b/osp/src/ospCfgToBin.c @@ -30,9 +30,10 @@ /***************************************************************************/ /* ARM <---> ARM */ -#define ARM_SPE_CFG_PHY_SIZE (0x1400000) /* 约定在20M以内 */ +#define ARM_SPE_CFG_PHY_SIZE (0x8000000) /* 改到系统内存,约定大小为128M */ //(0x1400000) /* 约定在20M以内 */ #define ARM_SPE_CFG_INFO_ONE sizeof(osp_spe_cfg_file_reg) #define ARM_SPE_CFG_INFO_SIZE (ARM_SPE_CFG_INFO_ONE * APE_SPE_CFG_FILE_NUM) +#define ARM_SPE_CFG_FILE_SIZE (ARM_SPE_CFG_PHY_SIZE - ARM_SPE_CFG_INFO_SIZE - ARM_CFG_INDXN) /* 特殊配置文件总长度 */ #define ARM_SPE_CFG_OFFSET (0x8A000000) /* 目前改到APE_PHY段,从0x1000 0000开始,故需要偏移0x8A00 0000 */ #if 0 @@ -322,16 +323,19 @@ int32_t osp_spe_cfg_file_init() g_spe_osp_cfg_file_idx = 0; g_spe_static_mem_size = 0; -#if 0 +#if 1 + /* 改成从系统内存中分配128M */ g_spe_ptr_static_mem = malloc(ARM_SPE_CFG_PHY_SIZE); if (NULL == g_spe_ptr_static_mem) { - UCP_PRINT_ERROR("get_static_mem(ARM_STACK) error......\r\n"); + UCP_PRINT_ERROR("malloc(128M) for spe cfg error......\r\n"); return OSP_ERROR; } + g_spe_static_mem_size = ARM_SPE_CFG_PHY_SIZE; return OSP_OK; #endif +#if 0 g_spe_ptr_static_mem = get_static_mem(APE_PHY, &g_spe_static_mem_size); if (0 == g_spe_static_mem_size) { @@ -339,7 +343,7 @@ int32_t osp_spe_cfg_file_init() return OSP_ERROR; } g_spe_ptr_static_mem += ARM_SPE_CFG_OFFSET; /* 在内存规划中,配置文件的起始地址需要偏移 */ - +#endif return OSP_OK; } @@ -503,6 +507,16 @@ int32_t osp_spe_bin_cfg_file_to_ddr() file_len = (uint32_t)ftell(read_file); UCP_PRINT_DEBUG("[to_ddr]: file: %s ,Size: %d\r\n", line_file_full_name, file_len); + /* 保护:文件太多,空间不够 */ + if ((file_len + ddr_offset) > ARM_SPE_CFG_FILE_SIZE) + { + UCP_PRINT_ERROR("[to_ddr]: too much file, no space... \r\n"); + fclose(read_file); + fclose(file); + system("rm tmpfile"); + return OSP_ERROR; + } + /* 回到文件头部 */ ret = fseek(read_file, 0, SEEK_SET); @@ -583,14 +597,14 @@ int32_t osp_get_cfg_file(char* name, uint64_t *paddr, uint32_t *psize) UCP_PRINT_ERROR("[osp_get_cfg_file]: name too long\r\n"); return OSP_ERROR; } - for (loop = 0; loop < APE_SPE_CFG_FILE_NUM; loop++) + for (loop = 0; loop < g_spe_osp_cfg_file_idx; loop++) { head = g_spe_osp_cfg_file_reg + loop; if (0 == memcmp(head->name, name, strlen(name))) { /* 物理层需要物理地址,而还是虚拟地址 */ - osp_virt_to_phy(APE_PHY, head->vir_addr, paddr); - //*paddr = head->vir_addr; + //osp_virt_to_phy(APE_PHY, head->vir_addr, paddr); + *paddr = head->vir_addr; *psize = head->len; return OSP_OK; }