Merge branch 'dev_ck_v2.1_feature_enhancement#1932#' into 'dev_ck_v2.1'

添加获取版本信息接口

See merge request ucp/driver/ucp4008_platform_spu!107
This commit is contained in:
Weihua Li 2024-05-20 01:09:45 +00:00
commit 61683f132f
6 changed files with 112 additions and 0 deletions

View File

@ -27,6 +27,9 @@ test_option="no"
case_id=21
ape_core_mask=0xf
platform_build_data=0x20230926
spu_version=`git log -1 --format="%H"`
spu_tag=`git tag | sed -n '$p'`
spu_build_date=`date +"%Y-%m-%d-%H:%M:%S"`
while [[ "$#" > 0 ]]; do
case $1 in
@ -101,8 +104,13 @@ export test_option=${test_option}
export test_id=${case_id}
export ape_core_mask=$((ape_core_mask))
export platform_build_data=$((platform_build_data))
export spu_version=${spu_version}
export spu_tag=${spu_tag}
export spu_build_date=${spu_build_date}
#echo "# ape_core_mask:$ape_core_mask,platform_build_data:$platform_build_data"
printf "#ape_core_mask[0x%x], #platform_build_data[0x%x]\n" $ape_core_mask $platform_build_data
printf "#spu_version[%s], spu_tag[%s], spu_build_date:[%s]\n" $spu_version $spu_tag $spu_build_date
make -f ${MAKE_DIR}/makefile.lib
makefile_set="makefile.ape_spu makefile.ecs_rfm_spu0 makefile.ecs_rfm_spu1 makefile.pet_rfm_spu0 makefile.pet_rfm_spu1"

View File

@ -2,9 +2,35 @@
#define __OSP_APE_INTERFACE_H__
/****************************UCP2.0 Platform start***********************************/
#define MAX_BUF_VERSION_LEN (128)
typedef struct SpuVersionInfo {
char platform_commit[MAX_BUF_VERSION_LEN];
char platform_tag[MAX_BUF_VERSION_LEN];
char platform_build_date[MAX_BUF_VERSION_LEN/2];
} SpuVersionInfo_t;
/************************************************************************************/
/* shell相关接口定义 */
/************************************************************************************/
/*
* : spu_show_version
* : void
* SPU侧的版本信息
* ret: void
*/
void spu_show_version(void);
/*
* : SPU侧的版本信息
* : pVersion [out]:
* SPU侧版本信息
* ret: 0-success, 1-error
*/
int32_t spu_version_get(SpuVersionInfo_t *pVersion);
/* shell命令回调函数类型 */
typedef unsigned long (*OSP_FUNCPTR)();

View File

@ -0,0 +1,17 @@
#ifndef __SPU_VERSION__
#define __SPU_VERSION__
#define MAX_BUF_VERSION_LEN (128)
typedef struct SpuVersionInfo {
char platform_commit[MAX_BUF_VERSION_LEN];
char platform_tag[MAX_BUF_VERSION_LEN];
char platform_build_date[MAX_BUF_VERSION_LEN/2];
} SpuVersionInfo_t;
void spu_show_version(void);
int32_t spu_version_get(SpuVersionInfo_t *pVersion);
#endif /* __SPU_VERSION__ */

View File

@ -7,6 +7,7 @@
#include "ucp_utility.h"
#include "typedef.h"
#include "phy_para.h"
#include "spu_version.h"
OSP_CMD_RTN gastCmdRtnTblExt[MAX_EXT_CMD_NUM];
@ -147,6 +148,10 @@ int spu_shell_init(void)
spu_insert_cmd_ext("csu_ape", (OSP_FUNCPTR)spu_csu_stop_cfg, "cfg csu info", 2);
spu_insert_cmd_ext("level_ape", (OSP_FUNCPTR)spu_log_level_set, "cfg ape print level", 1);
spu_insert_cmd_ext("slevel_ape", (OSP_FUNCPTR)spu_log_level_get, "get ape print level", 0);
/* 注册版本信息 */
if (11 == g_core_id) {
spu_insert_cmd_ext("ver_spu", (OSP_FUNCPTR)spu_show_version, "show spu soft version", 0);
}
return 0;
}

View File

@ -0,0 +1,51 @@
#include <stdlib.h>
#include <string.h>
#include "spu_shell.h"
#include "ucp_printf.h"
#include "spu_log.h"
#include "ucp_drv_common.h"
#include "ucp_utility.h"
#include "typedef.h"
#include "spu_version.h"
/* print spu软件版本信息 */
void spu_show_version()
{
char pbuf[2048];
int len = 0;
len = sprintf(pbuf, "[SPU]\n\rVersion:\t%s\n\rTag:\t\t%s\n\rBuild Date:\t%s\n\r", SPU_VERSION, SPU_TAG, SPU_BUILD_DATE);
spu_shellinfo_to_arm(pbuf, len, UCP4008_OSP_SHELL);
return ;
}
/*
* @brief: SPU版本信息
* @author: haochen.zhang
* @Date: 2024.5.14
* @param: pVersion [out] :
*/
int32_t spu_version_get(SpuVersionInfo_t *pVersion)
{
if (NULL == pVersion)
return -2;
if ((sizeof(SPU_VERSION) > MAX_BUF_VERSION_LEN) || (sizeof(SPU_TAG) > MAX_BUF_VERSION_LEN) || (sizeof(SPU_TAG) > MAX_BUF_VERSION_LEN/2)) {
return -1;
}
memcpy((void *)&pVersion->platform_commit, (void *)SPU_VERSION, sizeof(SPU_VERSION));
memcpy((void *)&pVersion->platform_tag, (void *)SPU_TAG, sizeof(SPU_TAG));
memcpy((void *)&pVersion->platform_build_date, (void *)SPU_BUILD_DATE, sizeof(SPU_BUILD_DATE));
return 0;
}

View File

@ -15,6 +15,11 @@ endif
#DEFINES += APE_CORE_MASK=\"$(ape_core_mask)\"
DEFINES += APE_CORE_MASK=$(ape_core_mask)
DEFINES += PLATFORM_BUILD_DATA=$(platform_build_data)
DEFINES += SPU_VERSION=\"${spu_version}\"
DEFINES += SPU_TAG=\"${spu_tag}\"
DEFINES += SPU_BUILD_DATE=\"${spu_build_date}\"
ifeq ($(backhaul_option), pcie)
DEFINES += PCIE_BACKHAUL
endif