From fe2787d53f0ddee5a748c41bf1d34322566acf76 Mon Sep 17 00:00:00 2001 From: "lishuang.xie" Date: Sat, 30 Mar 2024 16:23:55 +0800 Subject: [PATCH] update New Feature#1737 from dev_ck_v2.1_featuer#1737# to dev_ck_v2.1 1. modified the function: int32_t osp_read_spe_cfg_file(char* path, uint8_t cellid), add the cellid 2. modified the function: int32_t osp_get_cfg_file(char* name, uint8_t cellid, uint64_t *paddr, uint32_t *psize);, add the cellid 3. modified the interface file 4. modified the testcase which used the functions 5. Test: 5.1 spu_case0_arm_case0_cpri: Pass 5.2 spu_case14_arm_caes20_cpri:Pass 5.3 spu_case20_arm_case20_cpri:Pass 5.4 spu_case24_arm_case24_cpri:Pass 5.5 spu_case34_arm_case5: Pass 5.6 spu_case44_arm_case5: Pass --- interface/arm_interface.h | 6 ++- osp/inc/ospCfgToBin.h | 4 +- osp/src/ospCfgToBin.c | 97 ++++++++++++++++++++++++++---------- test/case0/src/testcase.c | 2 +- test/case20/src/testcase20.c | 2 +- test/case21/src/testcase21.c | 2 +- test/case22/src/testcase22.c | 2 +- test/case23/src/testcase23.c | 2 +- test/case24/src/testcase24.c | 14 +++++- test/case45/src/testcase45.c | 2 +- test/case46/src/testcase46.c | 2 +- test/case48/src/testcase48.c | 2 +- test/case5/src/testcase5.c | 2 +- 13 files changed, 100 insertions(+), 39 deletions(-) diff --git a/interface/arm_interface.h b/interface/arm_interface.h index 18ab48f..aede574 100644 --- a/interface/arm_interface.h +++ b/interface/arm_interface.h @@ -104,18 +104,20 @@ OSP_STATUS osp_arm_log_proc(char *pbuf, uint32_t len ,uint32_t logid, uint32_t m /* name: osp_read_spe_cfg_file para: Input: path: the config file's path +para: Input: cellid: the index of the cell brief: load the spe config file by the path */ -int32_t osp_read_spe_cfg_file(char* path); +int32_t osp_read_spe_cfg_file(char* path, uint8_t cellid); /* name: osp_get_cfg_file para: Input: name: the config file's name +para: Input: cellid: the index of the cell para: Output: paddr: the config file's address para: Output: psize: the config file's size brief: get a config file's address and size */ -int32_t osp_get_cfg_file(char* name, uint64_t *paddr, uint32_t *psize); +int32_t osp_get_cfg_file(char* name, uint8_t cellid, uint64_t *paddr, uint32_t *psize); int32_t get_clock_module_status(volatile clock_module_status_s* clk_module_status_ptr); int32_t set_clk_mode(clk_flag_e pseudo_flag); diff --git a/osp/inc/ospCfgToBin.h b/osp/inc/ospCfgToBin.h index fd7781b..069755b 100644 --- a/osp/inc/ospCfgToBin.h +++ b/osp/inc/ospCfgToBin.h @@ -25,8 +25,8 @@ extern int32_t osp_read_cfg_file(void); /* TestMac interface */ -extern int32_t osp_read_spe_cfg_file(char* path); -extern int32_t osp_get_cfg_file(char* name, uint64_t *paddr, uint32_t *psize); +extern int32_t osp_read_spe_cfg_file(char* path, uint8_t cellid); +extern int32_t osp_get_cfg_file(char* name, uint8_t cellid, uint64_t *paddr, uint32_t *psize); #ifdef HEARTBEAT_ENABLE extern int8_t osp_get_im2ddr_to_file(uint8_t u8CoreId); diff --git a/osp/src/ospCfgToBin.c b/osp/src/ospCfgToBin.c index 753aeb7..7107426 100644 --- a/osp/src/ospCfgToBin.c +++ b/osp/src/ospCfgToBin.c @@ -31,11 +31,25 @@ /***************************************************************************/ /* ARM <---> ARM */ #define ARM_SPE_CFG_PHY_SIZE (0x3000000) /* 改到系统内存,约定大小为128M */ //(0x1400000) /* 约定在20M以内 */ +#define ARM_SPE_CFG_PHY_SIZE0 (0x03000000) +#define ARM_SPE_CFG_PHY_SIZE1 (0x02000000) +#define ARM_SPE_CFG_PHY_SIZE2 (0x01000000) +#define ARM_SPE_CFG_PHY_SIZE3 (0x01000000) #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_FILE_SIZE (ARM_SPE_CFG_PHY_SIZE - ARM_SPE_CFG_INFO_SIZE - ARM_CFG_INDXN) /* 特殊配置文件总长度 */ +#define ARM_SPE_CFG_FILE_SIZE0 (ARM_SPE_CFG_PHY_SIZE0 - ARM_SPE_CFG_INFO_SIZE - ARM_CFG_INDXN) /* 特殊配置文件总长度 */ +#define ARM_SPE_CFG_FILE_SIZE1 (ARM_SPE_CFG_PHY_SIZE1 - ARM_SPE_CFG_INFO_SIZE - ARM_CFG_INDXN) /* 特殊配置文件总长度 */ +#define ARM_SPE_CFG_FILE_SIZE2 (ARM_SPE_CFG_PHY_SIZE2 - ARM_SPE_CFG_INFO_SIZE - ARM_CFG_INDXN) /* 特殊配置文件总长度 */ +#define ARM_SPE_CFG_FILE_SIZE3 (ARM_SPE_CFG_PHY_SIZE3 - ARM_SPE_CFG_INFO_SIZE - ARM_CFG_INDXN) /* 特殊配置文件总长度 */ + #define ARM_SPE_CFG_OFFSET (0x89000000) /* 目前改到APE_PHY段,从0x1000 0000开始,故需要偏移0x8900 0000 */ +#define ARM_SPE_CFG_OFFSET_CELL0 (0x85000000) /* 目前在APE_PHY段,CELL0在0x9500 0000开始48M */ +#define ARM_SPE_CFG_OFFSET_CELL1 (0x88000000) /* 目前在APE_PHY段,CELL1在0x9800 0000开始32M */ +#define ARM_SPE_CFG_OFFSET_CELL2 (0x8A000000) /* 目前在APE_PHY段,CELL2在0x9A00 0000开始16M */ +#define ARM_SPE_CFG_OFFSET_CELL3 (0x8B000000) /* 目前在APE_PHY段,CELL3在0x9B00 0000开始16M */ + #if 0 #define ARM_SPE_CFG_PHY_ADDR (0xB8000000) /* 指定配置文件首地址 */ #define ARM_SPE_CFG_PHY_SIZE (0x10000) /* 指定配置文件区域长度:64K */ @@ -53,9 +67,12 @@ uint64_t g_static_mem_size = 0; /***************************************************************************/ /* ARM <---> ARM */ -osp_spe_cfg_file_reg g_spe_osp_cfg_file_reg[APE_SPE_CFG_FILE_NUM]; -uint32_t g_spe_osp_cfg_file_idx = 0; +#define SPE_OSP_CFG_CELL_ID (4) + +osp_spe_cfg_file_reg g_spe_osp_cfg_file_reg[SPE_OSP_CFG_CELL_ID][APE_SPE_CFG_FILE_NUM]; +uint32_t g_spe_osp_cfg_file_idx[SPE_OSP_CFG_CELL_ID] = {0}; void *g_spe_ptr_static_mem = NULL; +void *g_spe_ptr_static_mem_bycell[SPE_OSP_CFG_CELL_ID] = {0}; uint64_t g_spe_static_mem_size = 0; /***************************************************************************/ @@ -317,11 +334,10 @@ int32_t osp_read_cfg_file(void) /***************************************************************************/ /* ARM <---> ARM */ -int32_t osp_spe_cfg_file_init() +int32_t osp_spe_cfg_file_init(uint8_t cellid) { - memset(&g_spe_osp_cfg_file_reg, 0, sizeof(g_spe_osp_cfg_file_reg)); - g_spe_osp_cfg_file_idx = 0; - //g_spe_static_mem_size = 0; + memset(&g_spe_osp_cfg_file_reg[cellid], 0, sizeof(osp_spe_cfg_file_reg)*APE_SPE_CFG_FILE_NUM); + g_spe_osp_cfg_file_idx[cellid] = 0; #if 0 /* 改成从系统内存中分配128M */ @@ -340,7 +356,11 @@ int32_t osp_spe_cfg_file_init() UCP_PRINT_ERROR("get_static_mem(ARM_STACK) error......\r\n"); return OSP_ERROR; } - g_spe_ptr_static_mem += ARM_SPE_CFG_OFFSET; /* 在内存规划中,配置文件的起始地址需要偏移 */ + g_spe_ptr_static_mem_bycell[0] = g_spe_ptr_static_mem + ARM_SPE_CFG_OFFSET_CELL0; + g_spe_ptr_static_mem_bycell[1] = g_spe_ptr_static_mem + ARM_SPE_CFG_OFFSET_CELL1; + g_spe_ptr_static_mem_bycell[2] = g_spe_ptr_static_mem + ARM_SPE_CFG_OFFSET_CELL2; + g_spe_ptr_static_mem_bycell[3] = g_spe_ptr_static_mem + ARM_SPE_CFG_OFFSET_CELL3; + //g_spe_ptr_static_mem += ARM_SPE_CFG_OFFSET; /* 在内存规划中,配置文件的起始地址需要偏移 */ #endif return OSP_OK; } @@ -437,7 +457,7 @@ int32_t osp_read_spe_cfg_to_bin(char* in_path) return OSP_OK; } -int32_t osp_spe_bin_cfg_file_to_ddr() +int32_t osp_spe_bin_cfg_file_to_ddr(uint8_t cellid) { char *p_line_file_name = NULL; char *p_line_file_name_begin = NULL; @@ -446,10 +466,11 @@ int32_t osp_spe_bin_cfg_file_to_ddr() uint32_t len = 0; uint32_t tmp_len = 0; - uint8_t osp_cfg_file_idx = 0; /* 文件个数 */ + uint8_t osp_cfg_file_idx = 0; /* 文件个数 */ uint32_t ret = 0; /* 返回值判断 */ uint32_t file_len = 0; /* 文件长度 */ uint32_t ddr_offset = 0; + uint32_t u32file_all_size = 0; FILE *file = NULL; FILE *read_file = NULL; @@ -506,7 +527,32 @@ int32_t osp_spe_bin_cfg_file_to_ddr() 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) + if (0 == cellid) + { + u32file_all_size = ARM_SPE_CFG_FILE_SIZE0; + } + else if (1 == cellid) + { + u32file_all_size = ARM_SPE_CFG_FILE_SIZE1; + } + else if (2 == cellid) + { + u32file_all_size = ARM_SPE_CFG_FILE_SIZE2; + } + else if (3 == cellid) + { + u32file_all_size = ARM_SPE_CFG_FILE_SIZE3; + } + else + { + UCP_PRINT_ERROR("[to_ddr]: too much file, no space... \r\n"); + fclose(read_file); + fclose(file); + system("rm tmpfile"); + return OSP_ERROR; + } + + if ((file_len + ddr_offset) > u32file_all_size) { UCP_PRINT_ERROR("[to_ddr]: too much file, no space... \r\n"); fclose(read_file); @@ -522,18 +568,19 @@ int32_t osp_spe_bin_cfg_file_to_ddr() len = 0; while(len < file_len) { - tmp_len = fread((char*)(g_spe_ptr_static_mem+ARM_CFG_INDXN+ARM_SPE_CFG_INFO_SIZE+ddr_offset+len), 1, file_len, read_file); + tmp_len = fread((char*)(g_spe_ptr_static_mem_bycell[cellid]+ARM_CFG_INDXN+ARM_SPE_CFG_INFO_SIZE+ddr_offset+len), 1, file_len, read_file); + //tmp_len = fread((char*)(g_spe_ptr_static_mem+ARM_CFG_INDXN+ARM_SPE_CFG_INFO_SIZE+ddr_offset+len), 1, file_len, read_file); len += tmp_len; } /* 更新全局变量 */ - g_spe_osp_cfg_file_reg[g_spe_osp_cfg_file_idx].len = file_len; - memcpy(g_spe_osp_cfg_file_reg[g_spe_osp_cfg_file_idx].name, file_name, strlen(file_name)); - g_spe_osp_cfg_file_reg[g_spe_osp_cfg_file_idx].vir_addr = (uint64_t)(g_spe_ptr_static_mem + g_spe_osp_cfg_file_reg[cellid][osp_cfg_file_idx].len = file_len; + memcpy(g_spe_osp_cfg_file_reg[cellid][osp_cfg_file_idx].name, file_name, strlen(file_name)); + g_spe_osp_cfg_file_reg[cellid][osp_cfg_file_idx].vir_addr = (uint64_t)(g_spe_ptr_static_mem_bycell[cellid] + ARM_CFG_INDXN + ARM_SPE_CFG_INFO_SIZE + ddr_offset); - g_spe_osp_cfg_file_idx++; + g_spe_osp_cfg_file_idx[cellid]++; ddr_offset += file_len; osp_cfg_file_idx++; @@ -541,9 +588,9 @@ int32_t osp_spe_bin_cfg_file_to_ddr() } /* 更新配置文件头信息 */ - *(uint32_t *)(g_spe_ptr_static_mem+ARM_CFG_NUM) = g_spe_osp_cfg_file_idx; - memcpy((g_spe_ptr_static_mem + ARM_CFG_INDXN), g_spe_osp_cfg_file_reg, ARM_SPE_CFG_INFO_ONE * g_spe_osp_cfg_file_idx); - *(uint32_t *)g_spe_ptr_static_mem = ARM_READ_CFG_FILE_OK; + *(uint32_t *)(g_spe_ptr_static_mem_bycell[cellid]+ARM_CFG_NUM) = g_spe_osp_cfg_file_idx[cellid]; + memcpy((g_spe_ptr_static_mem_bycell[cellid] + ARM_CFG_INDXN), g_spe_osp_cfg_file_reg[cellid], ARM_SPE_CFG_INFO_ONE * g_spe_osp_cfg_file_idx[cellid]); + *(uint32_t *)g_spe_ptr_static_mem_bycell[cellid] = ARM_READ_CFG_FILE_OK; fclose(file); system("rm tmpfile"); @@ -556,12 +603,12 @@ int32_t osp_spe_bin_cfg_file_to_ddr() /********************************************************************/ /* TestMac Interface */ /********************************************************************/ -int32_t osp_read_spe_cfg_file(char* path) +int32_t osp_read_spe_cfg_file(char* path, uint8_t cellid) { uint32_t ret = 0; /* 每次调用前,清空全局变量 */ - ret = osp_spe_cfg_file_init(); + ret = osp_spe_cfg_file_init(cellid); if (OSP_OK != ret) { UCP_PRINT_ERROR("[osp_read_spe_cfg_file]: osp_cfg_file_init return error: %d\r\n", ret); @@ -577,7 +624,7 @@ int32_t osp_read_spe_cfg_file(char* path) } /* 转化 */ - ret = osp_spe_bin_cfg_file_to_ddr(); + ret = osp_spe_bin_cfg_file_to_ddr(cellid); if (OSP_OK != ret) { UCP_PRINT_ERROR("[osp_read_spe_cfg_file]: osp_spe_bin_cfg_file_to_ddr return error: %d\r\n", ret); @@ -586,7 +633,7 @@ int32_t osp_read_spe_cfg_file(char* path) return OSP_OK; } -int32_t osp_get_cfg_file(char* name, uint64_t *paddr, uint32_t *psize) +int32_t osp_get_cfg_file(char* name, uint8_t cellid, uint64_t *paddr, uint32_t *psize) { uint16_t loop = 0; osp_spe_cfg_file_reg *head = NULL; @@ -595,9 +642,9 @@ 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 < g_spe_osp_cfg_file_idx; loop++) + for (loop = 0; loop < g_spe_osp_cfg_file_idx[cellid]; loop++) { - head = g_spe_osp_cfg_file_reg + loop; + head = g_spe_osp_cfg_file_reg[cellid] + loop; if (0 == memcmp(head->name, name, strlen(name))) { /* 物理层需要物理地址,而还是虚拟地址 */ diff --git a/test/case0/src/testcase.c b/test/case0/src/testcase.c index 03cae69..1221aa7 100644 --- a/test/case0/src/testcase.c +++ b/test/case0/src/testcase.c @@ -228,7 +228,7 @@ int32_t test_case(uint32_t argc, int32_t* argvp) { UCP_PRINT_DEBUG("start running testcase 0."); - osp_read_spe_cfg_file("/ramfs/cfgDat"); + osp_read_spe_cfg_file("/ramfs/cfgDat", 0); msg_transfer_mem_init(); msg_transfer_cfg(); diff --git a/test/case20/src/testcase20.c b/test/case20/src/testcase20.c index 31326bb..d281fdb 100644 --- a/test/case20/src/testcase20.c +++ b/test/case20/src/testcase20.c @@ -230,7 +230,7 @@ int32_t test_case(uint32_t argc, int32_t* argvp) { UCP_PRINT_DEBUG("start running testcase 20 (4 ape 30K case)."); - osp_read_spe_cfg_file("/ramfs/cfgDat"); + osp_read_spe_cfg_file("/ramfs/cfgDat", 0); msg_transfer_mem_init(); msg_transfer_cfg(); diff --git a/test/case21/src/testcase21.c b/test/case21/src/testcase21.c index 2ee9e94..3349b96 100644 --- a/test/case21/src/testcase21.c +++ b/test/case21/src/testcase21.c @@ -261,7 +261,7 @@ int32_t test_case(uint32_t argc, int32_t* argvp) { UCP_PRINT_DEBUG("start running testcase 21 (8 ape 30K case)."); - osp_read_spe_cfg_file("/ramfs/cfgDat"); + osp_read_spe_cfg_file("/ramfs/cfgDat", 0); msg_transfer_mem_init(); msg_transfer_cfg(); diff --git a/test/case22/src/testcase22.c b/test/case22/src/testcase22.c index 2b2ea2e..079d57d 100644 --- a/test/case22/src/testcase22.c +++ b/test/case22/src/testcase22.c @@ -260,7 +260,7 @@ int32_t test_case(uint32_t argc, int32_t* argvp) { UCP_PRINT_DEBUG("start running testcase 22 (8 ape 15K case)."); - osp_read_spe_cfg_file("/ramfs/cfgDat"); + osp_read_spe_cfg_file("/ramfs/cfgDat", 0); msg_transfer_mem_init(); msg_transfer_cfg(); diff --git a/test/case23/src/testcase23.c b/test/case23/src/testcase23.c index 74ebd49..2282172 100644 --- a/test/case23/src/testcase23.c +++ b/test/case23/src/testcase23.c @@ -260,7 +260,7 @@ int32_t test_case(uint32_t argc, int32_t* argvp) { UCP_PRINT_DEBUG("start running testcase 23 (dual mode case)."); - osp_read_spe_cfg_file("/ramfs/cfgDat"); + osp_read_spe_cfg_file("/ramfs/cfgDat", 0); msg_transfer_mem_init(); msg_transfer_cfg(); diff --git a/test/case24/src/testcase24.c b/test/case24/src/testcase24.c index 982bdee..0aa7655 100644 --- a/test/case24/src/testcase24.c +++ b/test/case24/src/testcase24.c @@ -352,7 +352,19 @@ int32_t test_case(uint32_t argc, int32_t* argvp) { UCP_PRINT_DEBUG("start running testcase 24 (8 ape 15K case, 4 cells)."); - osp_read_spe_cfg_file("/ramfs/cfgDat"); + uint64_t addr = 0; + uint32_t fsize = 0; + + osp_read_spe_cfg_file("/ramfs/cfgDat", 0); + osp_read_spe_cfg_file("/ramfs/cfgDat", 1); + osp_read_spe_cfg_file("/ramfs/cfgDat", 2); + osp_read_spe_cfg_file("/ramfs/cfgDat", 3); + + + osp_get_cfg_file("nr_csirs_cfg.dat", 0, &addr, &fsize); + osp_get_cfg_file("nr_csirs_lut.dat", 1, &addr, &fsize); + osp_get_cfg_file("nr_csirs_lut.dat", 2, &addr, &fsize); + osp_get_cfg_file("nr_csirs_cfg.dat", 3, &addr, &fsize); msg_transfer_mem_init(); msg_transfer_cfg(); diff --git a/test/case45/src/testcase45.c b/test/case45/src/testcase45.c index 41373c7..a0f021f 100644 --- a/test/case45/src/testcase45.c +++ b/test/case45/src/testcase45.c @@ -307,7 +307,7 @@ int32_t test_case(uint32_t argc, int32_t* argvp) { UCP_PRINT_DEBUG("start running testcase 45."); - osp_read_spe_cfg_file("/ramfs/cfgDat"); + osp_read_spe_cfg_file("/ramfs/cfgDat", 0); msg_transfer_mem_init(); msg_transfer_cfg(); diff --git a/test/case46/src/testcase46.c b/test/case46/src/testcase46.c index a00901c..fabb01c 100644 --- a/test/case46/src/testcase46.c +++ b/test/case46/src/testcase46.c @@ -307,7 +307,7 @@ int32_t test_case(uint32_t argc, int32_t* argvp) { UCP_PRINT_DEBUG("start running testcase 46."); - osp_read_spe_cfg_file("/ramfs/cfgDat"); + osp_read_spe_cfg_file("/ramfs/cfgDat", 0); msg_transfer_mem_init(); msg_transfer_cfg(); diff --git a/test/case48/src/testcase48.c b/test/case48/src/testcase48.c index 68ff906..4ce1f17 100644 --- a/test/case48/src/testcase48.c +++ b/test/case48/src/testcase48.c @@ -235,7 +235,7 @@ int32_t test_case(uint32_t argc, int32_t* argvp) { UCP_PRINT_DEBUG("start running testcase 48."); - osp_read_spe_cfg_file("/ramfs/cfgDat"); + osp_read_spe_cfg_file("/ramfs/cfgDat", 0); msg_transfer_mem_init(); msg_transfer_cfg(); diff --git a/test/case5/src/testcase5.c b/test/case5/src/testcase5.c index c47030f..8d8ca37 100644 --- a/test/case5/src/testcase5.c +++ b/test/case5/src/testcase5.c @@ -228,7 +228,7 @@ int32_t test_case(uint32_t argc, int32_t* argvp) { UCP_PRINT_DEBUG("start running testcase 5."); - osp_read_spe_cfg_file("/ramfs/cfgDat"); + osp_read_spe_cfg_file("/ramfs/cfgDat", 0); msg_transfer_mem_init(); msg_transfer_cfg();