#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;
}






