From: Aravind Batni Date: Wed, 8 Jul 2020 16:31:01 +0000 (-0400) Subject: Fixed C++ compile issues X-Git-Tag: REL.CORESDK.07.00.02.01~2 X-Git-Url: https://git.ti.com/gitweb?p=keystone-rtos%2Fsa-lld.git;a=commitdiff_plain;h=b12fa67e569e1b0a7bea9123047f2fa21e960c16 Fixed C++ compile issues Signed-off-by: Aravind Batni --- diff --git a/src/auth/salldsha1.h b/src/auth/salldsha1.h index 87509c2..c81b38c 100644 --- a/src/auth/salldsha1.h +++ b/src/auth/salldsha1.h @@ -339,7 +339,7 @@ static void sha1_block(sha1Inst_t *c, const void *p, tint num); *****************************************************************************/ static void sha1_block(sha1Inst_t *c, const void *p, tint num) { - const tword *data=p; + const tword *data=(const tword *)p; tulong A,B,C,D,E,T,l; tulong XX0,XX1,XX2,XX3,XX4,XX5,XX6,XX7,XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; diff --git a/src/pkafw/firmware_eip29t2.c b/src/pkafw/firmware_eip29t2.c index fafa8b6..83c374a 100644 --- a/src/pkafw/firmware_eip29t2.c +++ b/src/pkafw/firmware_eip29t2.c @@ -1,7 +1,7 @@ /* * TEXAS INSTRUMENTS TEXT FILE LICENSE * - * Copyright (c) 2016-2018 Texas Instruments Incorporated + * Copyright (c) 2016-2020 Texas Instruments Incorporated * * All rights reserved not granted herein. * @@ -2797,8 +2797,6 @@ FirmwareImage_EIP29T2[] = 0x007A08BF }; -const int FirmwareImage_EIP29T2Size = sizeof(FirmwareImage_EIP29T2)/sizeof(uint32_t); - #define ARRAY_ELEMCOUNT(_a) (sizeof(_a) / sizeof(_a[0])) /*---------------------------------------------------------------------------- diff --git a/src/salldpka.c b/src/salldpka.c index 371945d..f153759 100644 --- a/src/salldpka.c +++ b/src/salldpka.c @@ -10,7 +10,7 @@ * * REVISION HISTORY: * - * (C) Copyright 2014, Texas Instruments Inc. + * (C) Copyright 2014-2020, Texas Instruments Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -1155,8 +1155,8 @@ static int16_t salld_pka_op_modexp_setup(salldObj_t *inst, Sa_PkaReqInfo2_t* pPk offset += (offset & 0x01); wsAvail = SA_PKA_RAM_SIZE_IN_WORDS - SA_PKA_RAM_SCRATCHPAD_SIZE_IN_WORDS - offset; - wsSize = max(2*(pPkaReqInfo->bLen + 2 - (pPkaReqInfo->bLen & 0x01)) + 10, - pPkaOp->numOddPowers*(pPkaReqInfo->bLen + 2 - (pPkaReqInfo->bLen & 0x01))); + wsSize = max(2*(pPkaReqInfo->bLen + 2U - (pPkaReqInfo->bLen & 0x01U)) + 10U, + pPkaOp->numOddPowers*(pPkaReqInfo->bLen + 2U - (pPkaReqInfo->bLen & 0x01U))); if (wsAvail < wsSize) { @@ -1294,8 +1294,8 @@ static int16_t salld_pka_op_modexp_crt_setup(salldObj_t *inst, Sa_PkaReqInfo2_t* offset += (offset & 0x1); wsAvail = SA_PKA_RAM_SIZE_IN_WORDS - SA_PKA_RAM_SCRATCHPAD_SIZE_IN_WORDS - offset; - wsSize = max(3*(pPkaReqInfo->bLen + 2 - (pPkaReqInfo->bLen & 0x01)) + 10, - (pPkaOp->numOddPowers + 1)*(pPkaReqInfo->bLen + 2 - (pPkaReqInfo->bLen & 0x01))); + wsSize = max(3*(pPkaReqInfo->bLen + 2U - (pPkaReqInfo->bLen & 0x01U)) + 10U, + (pPkaOp->numOddPowers + 1U)*(pPkaReqInfo->bLen + 2U - (pPkaReqInfo->bLen & 0x01U))); if (wsAvail < wsSize) { diff --git a/test/SaUnitTest/src/common/common2.c b/test/SaUnitTest/src/common/common2.c index 0d9e13e..6df300c 100644 --- a/test/SaUnitTest/src/common/common2.c +++ b/test/SaUnitTest/src/common/common2.c @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2010-2018 Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (C) 2010-2020 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistribution and use in source and binary forms, with or without @@ -172,15 +172,20 @@ void testDispPkts (CSL_UdmapCppi5HMPD *hd) uint8_t errFlags; int32_t index = 0, ret; uint64_t psDataAddr; - + char msg_swInfo[80] = "Software Info: 0x%08x, 0x%08x, 0x%08x \n"; + char msg_tsInfo[80] = "TimeStamp Info: 0x%08x \n"; + char msg1_psInfo[80] = "PS Info[%d] = 0x%08x\n"; + char msg2_psInfo[80] = "PS Info[%d] (remaing %d bytes)= 0x%08x\n"; + char msg_pkt_err[80] = "Packet Error with error code %d\n"; + char msg_pktSize[80] = "Packet of size %d received at 0x%04x\n"; /* Dispaly Software Info */ //Cppi_getSoftwareInfo (Cppi_DescType_HOST, (Cppi_Desc *)hd, (uint8_t **)&swInfo); /* CSL_cppi5GetSoftwareInfo(CSL_CPPI5_DESCRIPTOR_TYPE_HOST, (uintptr_t *) hd, (uint8_t **)&swInfo); */ ret = CSL_udmapCppi5RdEpiData((void *) hd, &pTsInfo, &swInfo[0],&swInfo[1],&swInfo[2]); if (ret == 0) { - salld_sim_print("Software Info: 0x%08x, 0x%08x, 0x%08x \n", swInfo[0], swInfo[1], swInfo[2]); - salld_sim_print("TimeStamp Info: 0x%08x \n", pTsInfo); + salld_sim_print(msg_swInfo, swInfo[0], swInfo[1], swInfo[2]); + salld_sim_print(msg_tsInfo, pTsInfo); } /* Display PS Info if exists */ @@ -197,14 +202,14 @@ void testDispPkts (CSL_UdmapCppi5HMPD *hd) while (infoLen >= 4) { - salld_sim_print("PS Info[%d] = 0x%08x\n", index, psInfo[index]); + salld_sim_print(msg1_psInfo, index, psInfo[index]); index++; infoLen -= 4; } if (infoLen) { - salld_sim_print("PS Info[%d] (remaing %d bytes)= 0x%08x\n", index, infoLen, psInfo[index]); + salld_sim_print(msg2_psInfo, index, infoLen, psInfo[index]); } #endif @@ -212,10 +217,10 @@ void testDispPkts (CSL_UdmapCppi5HMPD *hd) if ((errFlags = CSL_udmapCppi5GetErrorFlags((void *)hd))) { - salld_sim_print("Packet Error with error code %d\n", errFlags); + salld_sim_print(msg_pkt_err, errFlags); } - salld_sim_print("Packet of size %d received at 0x%04x\n", bufLen, bufPtr); + salld_sim_print(msg_pktSize, bufLen, bufPtr); #if SA_GEN_TEST_VECTOR utilOutputPkt(&tFramework, swInfo, infoLen, psInfo, @@ -229,12 +234,12 @@ void testDispPkts (CSL_UdmapCppi5HMPD *hd) * choose whether to skip the test (in case device type does not support) or * preemptively fail and report the failure rather than crashing the test. */ -int testCommonSetTestStatus(void *fxn, saTestStatus_t status) +int testCommonSetTestStatus(void (*fxn)(UArg, UArg), saTestStatus_t status) { int ret = FALSE; int i; - for (i = 0; saTestList[i].testFunction != NULL; i++ ) { + for (i = 0; saTestList[i].testFunction != NULL; i++ ) { if (saTestList[i].testFunction == fxn) { saTestList[i].testStatus = status; @@ -249,12 +254,12 @@ int testCommonSetTestStatus(void *fxn, saTestStatus_t status) * Get the test status. This gives the framework to decide whether to take * action if a test has been bypassed. */ -saTestStatus_t testCommonGetTestStatus(void *fxn) +saTestStatus_t testCommonGetTestStatus(void (*fxn)(UArg, UArg)) { saTestStatus_t status; int i; - for (i = 0; saTestList[i].testFunction != NULL; i++ ) { + for (i = 0; saTestList[i].testFunction != NULL; i++ ) { if (saTestList[i].testFunction == fxn) { status = saTestList[i].testStatus; diff --git a/test/SaUnitTest/src/salldsim/salld_osal.c b/test/SaUnitTest/src/salldsim/salld_osal.c index a99dc4f..d63cce5 100644 --- a/test/SaUnitTest/src/salldsim/salld_osal.c +++ b/test/SaUnitTest/src/salldsim/salld_osal.c @@ -6,7 +6,7 @@ * * \par * ============================================================================ - * @n (C) Copyright 2009-2013, Texas Instruments, Inc. + * @n (C) Copyright 2009-2020, Texas Instruments, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -94,13 +94,14 @@ uint8_t osal_malloc_block[OSAL_MALLOC_BLK_SIZE] __attribute__ ((aligned (128))) void *Osal_malloc (uint32_t size) { void *result; + char msg_malloc[80] = "WARNING: malloc overrun heap!!!\n"; #if defined(OSAL_MALLOC_STATIC) uint32_t index = size_malloced; #endif size_malloced += size; if (size_malloced >= OSAL_MALLOC_BLK_SIZE) { - Sa_osalLog ("WARNING: malloc overrun heap!!!\n"); + Sa_osalLog (msg_malloc); result = (void *) NULL; } else diff --git a/test/SaUnitTest/src/salldsim/salldsim.c b/test/SaUnitTest/src/salldsim/salldsim.c index 12dbf4e..e5d90b7 100644 --- a/test/SaUnitTest/src/salldsim/salldsim.c +++ b/test/SaUnitTest/src/salldsim/salldsim.c @@ -188,6 +188,8 @@ void salldsimDebugInfo (void* mID, uint16_t msgType, uint16_t messageCode, uint16_t id = Sa_chanGetID((Sa_ChanHandle) mID); int chnum = SALLDSIM_GET_CHAN(id); char *string = (char *)(uintptr_t)NULL; + char msg_default[80] = "TEST_EXCEPTION_DBG_DEFAULT"; + char msg_fatal_err[80] = "TEST_EXCEPTION_DBG_FATAL_ERROR"; uint16_t time = 0; uint16_t deltaTime = 0; @@ -211,12 +213,12 @@ void salldsimDebugInfo (void* mID, uint16_t msgType, uint16_t messageCode, break; case sa_DBG_FATAL_ERROR: - string = "TEST_EXCEPTION_DBG_FATAL_ERROR"; + string = msg_fatal_err; salldsimFatalError (id, string); break; default: - string = "TEST_EXCEPTION_DBG_DEFAULT"; + string = msg_default; salldsimFatalError (id, string); break; } @@ -448,7 +450,8 @@ uint16_t salldSim_init_chn (salldSimChannel_t *pSimChan) int i; int16_t ret_code; Bool fShared = ((pSimChan->protocolType == sa_PT_IPSEC_AH) || (pSimChan->protocolType == sa_PT_IPSEC_ESP))? - TRUE:FALSE; + TRUE:FALSE; + char msg_start[80] = "Instantiating SALLD Channel %d ...\n"; /* Check that the channel is not already created */ if (pSimChan->salldInst != (Sa_ChanHandle)0U) { @@ -456,7 +459,7 @@ uint16_t salldSim_init_chn (salldSimChannel_t *pSimChan) } /* Progress (verbose only) */ - salld_sim_iprint ("Instantiating SALLD Channel %d ...\n", index); + salld_sim_iprint (msg_start, index); /* salldGetSizes() parameters */ memset(&sizeCfg, 0, sizeof(Sa_ChanSizeCfg_t)); @@ -493,9 +496,9 @@ uint16_t salldSim_init_chn (salldSimChannel_t *pSimChan) chanCfg.ID = (salld_MOD_ID << 8) | (index + 1); chanCfg.sizeConfig = sizeCfg; #if defined(SAU_PRMOTE_DEMOTE_TEST) - ret_code = Sa_chanCreate (tFrameworkSecure.salld_handle, &chanCfg, (void *) bases, &pSimChan->salldInst); + ret_code = Sa_chanCreate (tFrameworkSecure.salld_handle, &chanCfg, (void **) &bases, &pSimChan->salldInst); #else - ret_code = Sa_chanCreate (tFramework.salld_handle, &chanCfg, (void *) bases, &pSimChan->salldInst); + ret_code = Sa_chanCreate (tFramework.salld_handle, &chanCfg, (void **) &bases, &pSimChan->salldInst); #endif salld_sim_check_rc (salld_SIM_ERR_SALLDINIT, ret_code, sa_ERR_OK); @@ -517,17 +520,22 @@ uint16_t salldSim_open_chn (salldSimChannel_t *pChan, salldOpenConfig_t *cfg) Sa_ChanCtrlInfo_t chanCtrlInfo; Sa_GenCtrlInfo_t *pGenCtrlInfo = &chanCtrlInfo.ctrlInfo.gen; Sa_KeyCtrlInfo_t *pKeyCtrlInfo = &chanCtrlInfo.ctrlInfo.key; - int16_t ret_code; + int16_t ret_code; + char msg_open[80] = "Opening SALLD Channel %d ...\n"; + char msg_genCfg[80] = "SALLD Channel %d: General Configuration\n"; + char msg_keyCfg[80] = "SALLD Channel %d: Key Configuration\n"; + char msg_txChEnable[80] = "SALLD Channel %d: Enable Tx\n"; + char msg_rxChEnable[80] = "SALLD Channel %d: Enable Rx\n"; /* Ensure channel is available */ if (pChan->salldInst == (Sa_ChanHandle)0U) return (salld_SIM_ERR); /* Progress (verbose only) */ - salld_sim_iprint ("Opening SALLD Channel %d ...\n", index); + salld_sim_iprint (msg_open, index); /* Progress (verbose only) */ - salld_sim_iprint ("SALLD Channel %d: General Configuration\n", index); + salld_sim_iprint (msg_genCfg, index); memset(pGenCtrlInfo, 0, sizeof(Sa_GenCtrlInfo_t)); if (cfg->ctrlBitMap & sa_CONTROLINFO_CTRL_RX_ON) @@ -550,7 +558,7 @@ uint16_t salldSim_open_chn (salldSimChannel_t *pChan, salldOpenConfig_t *cfg) salld_sim_check_rc (salld_SIM_ERR_SALLDCONTROL, ret_code, sa_ERR_OK); /* Progress (verbose only) */ - salld_sim_iprint ("SALLD Channel %d: Key Configuration\n", index); + salld_sim_iprint (msg_keyCfg, index); chanCtrlInfo.ctrlType = (uint16_t)sa_CHAN_CTRL_KEY_CONFIG; memset(pKeyCtrlInfo, 0, sizeof(Sa_KeyCtrlInfo_t)); @@ -577,7 +585,7 @@ uint16_t salldSim_open_chn (salldSimChannel_t *pChan, salldOpenConfig_t *cfg) if (cfg->ctrlBitMap & sa_CONTROLINFO_CTRL_TX_ON) { - salld_sim_iprint ("SALLD Channel %d: Enable Tx\n", index); + salld_sim_iprint (msg_txChEnable, index); pGenCtrlInfo->ctrlBitfield = cfg->ctrlBitMap & ~sa_CONTROLINFO_CTRL_RX_ON; @@ -595,7 +603,7 @@ uint16_t salldSim_open_chn (salldSimChannel_t *pChan, salldOpenConfig_t *cfg) Sa_ScReqInfo_t* pReqInfo; #endif - salld_sim_iprint ("SALLD Channel %d: Enable Rx\n", index); + salld_sim_iprint (msg_rxChEnable, index); pGenCtrlInfo->ctrlBitfield = cfg->ctrlBitMap; ret_code = Sa_chanControl ((Sa_ChanHandle)pChan->salldInst, &chanCtrlInfo); @@ -632,14 +640,15 @@ uint16_t salldSim_close_chn (salldSimChannel_t *pChan) int16_t index = SALLDSIM_GET_CHAN(pChan->ID) - 1; int16_t ret_code; void* bases[sa_CHAN_N_BUFS]; - int i; + int i; + char msg_chClose[80] = "Closing SALLD Channel %d ...\n"; /* Ensure channel is open */ if (pChan->salldInst == (Sa_ChanHandle)0U) return (salld_SIM_ERR); /* Progress (verbose only) */ - salld_sim_iprint ("Closing SALLD Channel %d ...\n", index); + salld_sim_iprint (msg_chClose, index); /* Close the SALLD channel */ ret_code = Sa_chanClose (pChan->salldInst, bases); @@ -929,11 +938,12 @@ void salldSim_get_sys_stats (void) *-----------------------------------------------------------------*/ void salld_sim_check_rc (salldSimErr_e id, uint16_t rc, uint16_t pass_code) { + char msg_badRc[80] = "\nERROR Bad Return Code: 0x%4x\n\n"; /* Wait forever */ if (rc != pass_code) { /* Set ID for quick identifcation */ salldSimErrorId = id; - salld_sim_iprint ("\nERROR Bad Return Code: 0x%4x\n\n", (int32_t) id); + salld_sim_iprint (msg_badRc, (int32_t) id); salld_sim_halt (); } } @@ -1342,7 +1352,7 @@ void salld_sim_init_sa (uint8_t limitAccess) ret_code = Sa_getShadowHandle(tFrameworkSecure.salld_handle, &sauShadowHandle); #else - ret_code = Sa_create (&cfg, (void *)bases, &tFramework.salld_handle); + ret_code = Sa_create (&cfg, (void **)bases, &tFramework.salld_handle); salld_sim_check_rc (salld_SIM_ERR_SYSINIT, ret_code, sa_ERR_OK); ret_code = Sa_getShadowHandle(tFramework.salld_handle, &sauShadowHandle); diff --git a/test/SaUnitTest/src/salldsim/salldutil.c b/test/SaUnitTest/src/salldsim/salldutil.c index 1c3ee77..28ea2fd 100644 --- a/test/SaUnitTest/src/salldsim/salldutil.c +++ b/test/SaUnitTest/src/salldsim/salldutil.c @@ -6,7 +6,7 @@ * * \par * ============================================================================ - * @n (C) Copyright 2009-2013, Texas Instruments, Inc. + * @n (C) Copyright 2009-2020, Texas Instruments, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -291,7 +291,7 @@ Bool salld_sim_htob(char* hex_in, uint8_t* bin_out, uint16_t *pSize) void salld_sim_init_pktdesc(Sa_PktDesc_t *pktDesc, int32_t numSegments) { pktDesc->nSegments = numSegments; - pktDesc->segments = (void *)salldSimSegments; + pktDesc->segments = (void **)salldSimSegments; pktDesc->segUsedSizes = salldSimSegUsedSizes; pktDesc->segAllocSizes = salldSimSegAllocSizes; } diff --git a/test/SaUnitTest/src/testMain.c b/test/SaUnitTest/src/testMain.c index f890c15..1fcc971 100644 --- a/test/SaUnitTest/src/testMain.c +++ b/test/SaUnitTest/src/testMain.c @@ -148,7 +148,7 @@ saTest_t saTestList[] = { { saPkaTest, "SA PKA Basic Operation test", SA_TEST_NOT_RUN }, { saPkaTest2, "SA PKA Complex Operation test", SA_TEST_NOT_RUN }, #endif - { NULL, NULL, SA_TEST_NOT_RUN } + { NULL, "", SA_TEST_NOT_RUN } }; #if defined(USE_BIOS) diff --git a/test/SaUnitTest/src/testconn2.c b/test/SaUnitTest/src/testconn2.c index 95160d8..a59ca87 100644 --- a/test/SaUnitTest/src/testconn2.c +++ b/test/SaUnitTest/src/testconn2.c @@ -924,7 +924,7 @@ void sauBookKeepRx(void) } /* Push descriptor to Rx free descriptor queue */ if (hd != NULL) { - CSL_udmapCppi5SetBufferLen((void *) hd, TF_DESC_BUFSIZE); + CSL_udmapCppi5SetBufferLen((CSL_UdmapCppi5HMPD *) hd, TF_DESC_BUFSIZE); RingPush (tFramework.gRxFreeRingHandle, TF_DESC_BUFSIZE, (physptr_t)hd); } @@ -970,7 +970,7 @@ void sauBookKeepRx(void) } /* Push descriptor to Rx free descriptor queue */ if (hd != NULL) { - CSL_udmapCppi5SetBufferLen((void *) hd, TF_DESC_BUFSIZE); + CSL_udmapCppi5SetBufferLen((CSL_UdmapCppi5HMPD *) hd, TF_DESC_BUFSIZE); RingPush (tFramework.gRxFreeRingHandle, TF_DESC_BUFSIZE, (physptr_t)hd); } diff --git a/test/SaUnitTest/src/tests/test5_3.c b/test/SaUnitTest/src/tests/test5_3.c index 4eba8e9..8cd4f7c 100644 --- a/test/SaUnitTest/src/tests/test5_3.c +++ b/test/SaUnitTest/src/tests/test5_3.c @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2012-2013 Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (C) 2012-2020 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistribution and use in source and binary forms, with or without @@ -56,7 +56,7 @@ typedef struct saPkaTestEntry2_s { - char* opDesc; /* Operation description */ + char opDesc[40]; /* Operation description */ Sa_PkaOpTypes_t operation; /* PKA operation */ Sa_PkaOpModes_t mode; /* PKA I/O mode */ uint16_t aLen; /* A length */ diff --git a/test/SaUnitTest/src/testutil.c b/test/SaUnitTest/src/testutil.c index e7dfdfa..24e7025 100644 --- a/test/SaUnitTest/src/testutil.c +++ b/test/SaUnitTest/src/testutil.c @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2010-2015 Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (C) 2010-2020 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistribution and use in source and binary forms, with or without @@ -149,6 +149,7 @@ uint32_t utilgAddr(uint32_t x) void utilInputTestPkts (char* file_name) { FILE *fp; + char msg[80] = "Unable to open file: %s\n"; /* Clear the Pkt memory */ memset(testPktRam, 0, TEST_PKT_RAM_SIZE); @@ -156,7 +157,7 @@ void utilInputTestPkts (char* file_name) if((fp = fopen (file_name, "rb")) == (FILE *)NULL) { - salld_sim_sprint ("Unable to open file: %s\n", file_name); + salld_sim_sprint (msg, file_name); return; } diff --git a/test/SaUnitTest/src/unittest.h b/test/SaUnitTest/src/unittest.h index 1936a69..f433891 100644 --- a/test/SaUnitTest/src/unittest.h +++ b/test/SaUnitTest/src/unittest.h @@ -149,15 +149,15 @@ typedef enum { typedef struct saTest_s { void (*testFunction)(UArg, UArg); /* The code that runs the test */ - char *name; /* The test name */ + char name[80]; /* The test name */ saTestStatus_t testStatus; /* Test status */ } saTest_t; extern saTest_t saTestList[]; -int testCommonSetTestStatus(void *fxn, saTestStatus_t status); -saTestStatus_t testCommonGetTestStatus(void *fxn); +int testCommonSetTestStatus(void (*fxn)(UArg, UArg), saTestStatus_t status); +saTestStatus_t testCommonGetTestStatus(void (*fxn)(UArg, UArg)); #ifdef SOC_C6678