Skip to content

Commit

Permalink
Merge pull request nasa#1003 from jphickey/fix-663-datatypes
Browse files Browse the repository at this point in the history
Fix nasa#663, more consistent use of data types
  • Loading branch information
astrogeco authored Nov 21, 2020
2 parents 32f3dee + 2cea88d commit 5ae7613
Show file tree
Hide file tree
Showing 47 changed files with 609 additions and 771 deletions.
35 changes: 15 additions & 20 deletions fsw/cfe-core/src/es/cfe_es_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ int32 CFE_ES_GetTaskID(CFE_ES_ResourceID_t *TaskIdPtr)
/*
** Function: CFE_ES_GetAppName - See API and header file for details
*/
int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, uint32 BufferLength)
int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, size_t BufferLength)
{
int32 Result;
CFE_ES_AppRecord_t *AppRecPtr;
Expand Down Expand Up @@ -890,7 +890,7 @@ int32 CFE_ES_GetAppName(char *AppName, CFE_ES_ResourceID_t AppId, uint32 BufferL
/*
** Function: CFE_ES_GetLibName - See API and header file for details
*/
int32 CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, uint32 BufferLength)
int32 CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, size_t BufferLength)
{
int32 Result;
CFE_ES_LibRecord_t *LibRecPtr;
Expand Down Expand Up @@ -932,7 +932,7 @@ int32 CFE_ES_GetLibName(char *LibName, CFE_ES_ResourceID_t LibId, uint32 BufferL
/*
** Function: CFE_ES_GetTaskName - See API and header file for details
*/
int32 CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, uint32 BufferLength)
int32 CFE_ES_GetTaskName(char *TaskName, CFE_ES_ResourceID_t TaskId, size_t BufferLength)
{
int32 Result;
osal_id_t OsalId;
Expand Down Expand Up @@ -1217,9 +1217,9 @@ int32 CFE_ES_GetTaskInfo(CFE_ES_TaskInfo_t *TaskInfo, CFE_ES_ResourceID_t TaskId
int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr,
const char *TaskName,
CFE_ES_ChildTaskMainFuncPtr_t FunctionPtr,
uint32 *StackPtr,
uint32 StackSize,
uint32 Priority,
CFE_ES_StackPointer_t StackPtr,
size_t StackSize,
CFE_ES_TaskPriority_Atom_t Priority,
uint32 Flags)
{

Expand Down Expand Up @@ -1283,14 +1283,6 @@ int32 CFE_ES_CreateChildTask(CFE_ES_ResourceID_t *TaskIdPtr,
ParentTaskId = AppRecPtr->MainTaskId;
if ( CFE_ES_ResourceID_Equal(TaskId, ParentTaskId) )
{
/*
** Truncate the priority if needed
*/
if ( Priority > 255 )
{
Priority = 255;
}

/*
** Step 2: Create the new task using the OS API call
*/
Expand Down Expand Up @@ -1614,7 +1606,7 @@ int32 CFE_ES_WriteToSysLog(const char *SpecStringPtr, ...)
/*
** Function: CFE_ES_CalculateCRC - See API and header file for details
*/
uint32 CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputCRC, uint32 TypeCRC)
uint32 CFE_ES_CalculateCRC(const void *DataPtr, size_t DataLength, uint32 InputCRC, uint32 TypeCRC)
{
uint32 i;
int16 Index;
Expand Down Expand Up @@ -1701,7 +1693,7 @@ uint32 CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputC
** Purpose: Allocate a data block for a Critical Data Store.
**
*/
int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, CFE_ES_CDS_Offset_t BlockSize, const char *Name)
int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, size_t BlockSize, const char *Name)
{
int32 Status;
size_t NameLen;
Expand Down Expand Up @@ -1763,7 +1755,7 @@ int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, CFE_ES_CDS_Offset_t B
if (Status < 0)
{
/* Translate AppID of caller into App Name */
CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME);
CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName));

CFE_EVS_SendEventWithAppID(CFE_ES_CDS_REGISTER_ERR_EID,
CFE_EVS_EventType_ERROR,
Expand Down Expand Up @@ -1821,7 +1813,7 @@ CFE_Status_t CFE_ES_GetCDSBlockIDByName(CFE_ES_ResourceID_t *BlockIdPtr, const c
* Purpose: Obtain CDS Block Name from ID
* See full API description in header file
*/
CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_ResourceID_t BlockId, uint32 BufferLength)
CFE_Status_t CFE_ES_GetCDSBlockName(char *BlockName, CFE_ES_ResourceID_t BlockId, size_t BufferLength)
{
CFE_Status_t Status;
CFE_ES_CDS_RegRec_t *RegRecPtr;
Expand Down Expand Up @@ -2072,7 +2064,7 @@ int32 CFE_ES_GetGenCounterIDByName(CFE_ES_ResourceID_t *CounterIdPtr, const char
* Purpose: Obtain Counter Name from ID
* See full API description in header file
*/
CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_ResourceID_t CounterId, uint32 BufferLength)
CFE_Status_t CFE_ES_GetGenCounterName(char *CounterName, CFE_ES_ResourceID_t CounterId, size_t BufferLength)
{
CFE_ES_GenCounterRecord_t *CountRecPtr;
CFE_Status_t Status;
Expand Down Expand Up @@ -2137,18 +2129,21 @@ int32 CFE_ES_LibID_ToIndex(CFE_ES_ResourceID_t LibId, uint32 *Idx)
int32 CFE_ES_TaskID_ToIndex(CFE_ES_ResourceID_t TaskID, uint32 *Idx)
{
osal_id_t OsalID;
osal_index_t OsalIndex;

if (!CFE_ES_ResourceID_IsDefined(TaskID))
{
return CFE_ES_ERR_RESOURCEID_NOT_VALID;
}

OsalID = CFE_ES_ResourceID_ToOSAL(TaskID);
if (OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, OsalID, Idx) != OS_SUCCESS)
if (OS_ObjectIdToArrayIndex(OS_OBJECT_TYPE_OS_TASK, OsalID, &OsalIndex) != OS_SUCCESS)
{
return CFE_ES_ERR_RESOURCEID_NOT_VALID;
}

*Idx = OsalIndex;

return CFE_SUCCESS;
}

Expand Down
64 changes: 42 additions & 22 deletions fsw/cfe-core/src/es/cfe_es_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens)
const char *AppName;
const char *EntryPoint;
const char *EntryType;
unsigned int Priority;
unsigned int StackSize;
unsigned int ExceptionAction;
unsigned long PriorityIn;
unsigned long StackSizeIn;
unsigned long ExceptionActionIn;
CFE_ES_ResourceID_t ApplicationId;
int32 CreateStatus = CFE_ES_ERR_APP_CREATE;

Expand Down Expand Up @@ -298,10 +298,13 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens)
*
* This permissive parsing should not be relied upon, as it may become more strict again in
* future CFE revisions.
*
* Also note that this uses "unsigned long" as that is the defined output type of strtoul().
* It will be converted to the correct type later.
*/
Priority = strtoul(TokenList[4], NULL, 0);
StackSize = strtoul(TokenList[5], NULL, 0);
ExceptionAction = strtoul(TokenList[7], NULL, 0);
PriorityIn = strtoul(TokenList[4], NULL, 0);
StackSizeIn = strtoul(TokenList[5], NULL, 0);
ExceptionActionIn = strtoul(TokenList[7], NULL, 0);

if(strcmp(EntryType,"CFE_APP")==0)
{
Expand All @@ -314,14 +317,27 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens)
** 1 ( Processor reset ). If it's non-zero, assume it means
** reset CPU.
*/
if ( ExceptionAction > CFE_ES_ExceptionAction_RESTART_APP )
ExceptionAction = CFE_ES_ExceptionAction_PROC_RESTART;
if ( ExceptionActionIn > CFE_ES_ExceptionAction_RESTART_APP )
{
ExceptionActionIn = CFE_ES_ExceptionAction_PROC_RESTART;
}

/*
* Task priority cannot be bigger than OS_MAX_TASK_PRIORITY
*/
if ( PriorityIn > OS_MAX_TASK_PRIORITY )
{
PriorityIn = OS_MAX_TASK_PRIORITY;
}

/*
** Now create the application
*/
CreateStatus = CFE_ES_AppCreate(&ApplicationId, FileName,
EntryPoint, AppName, (uint32) Priority,
(uint32) StackSize, (uint32) ExceptionAction );
EntryPoint, AppName,
PriorityIn,
StackSizeIn,
ExceptionActionIn);
}
else if(strcmp(EntryType,"CFE_LIB")==0)
{
Expand Down Expand Up @@ -522,7 +538,7 @@ int32 CFE_ES_StartAppTask(const CFE_ES_AppStartParams_t* StartParams, CFE_ES_Res
StatusCode = OS_TaskCreate(&OsalTaskId, /* task id */
StartParams->BasicInfo.Name, /* task name */
CFE_ES_AppEntryPoint, /* task function pointer */
NULL, /* stack pointer (allocate) */
OSAL_TASK_STACK_ALLOCATE, /* stack pointer (allocate) */
StartParams->StackSize, /* stack size */
StartParams->Priority, /* task priority */
OS_FP_ENABLED); /* task options */
Expand Down Expand Up @@ -589,9 +605,9 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr,
const char *FileName,
const char *EntryPointName,
const char *AppName,
uint32 Priority,
uint32 StackSize,
uint32 ExceptionAction)
CFE_ES_TaskPriority_Atom_t Priority,
size_t StackSize,
CFE_ES_ExceptionAction_Enum_t ExceptionAction)
{
CFE_Status_t Status;
CFE_ES_ResourceID_t MainTaskId;
Expand Down Expand Up @@ -1556,7 +1572,7 @@ void CFE_ES_CleanupObjectCallback(osal_id_t ObjectId, void *arg)
{
CFE_ES_CleanupState_t *CleanState;
int32 Status;
uint32 ObjType;
osal_objtype_t ObjType;
bool ObjIsValid;

CleanState = (CFE_ES_CleanupState_t *)arg;
Expand Down Expand Up @@ -1750,7 +1766,7 @@ void CFE_ES_CopyModuleBasicInfo(const CFE_ES_ModuleLoadParams_t *ParamsPtr, CFE_
void CFE_ES_CopyModuleStatusInfo(const CFE_ES_ModuleLoadStatus_t *StatusPtr, CFE_ES_AppInfo_t *AppInfoPtr)
{
AppInfoPtr->ModuleId = StatusPtr->ModuleId;
CFE_SB_SET_MEMADDR(AppInfoPtr->StartAddress, StatusPtr->EntryAddress);
AppInfoPtr->StartAddress = CFE_ES_MEMADDRESS_C(StatusPtr->EntryAddress);
}

/*
Expand Down Expand Up @@ -1781,12 +1797,16 @@ void CFE_ES_CopyModuleAddressInfo(osal_id_t ModuleId, CFE_ES_AppInfo_t *AppInfoP
memset(&ModuleInfo, 0, sizeof(ModuleInfo));
}

CFE_SB_SET_MEMADDR(AppInfoPtr->CodeAddress, ModuleInfo.addr.code_address);
CFE_SB_SET_MEMADDR(AppInfoPtr->CodeSize, ModuleInfo.addr.code_size);
CFE_SB_SET_MEMADDR(AppInfoPtr->DataAddress, ModuleInfo.addr.data_address);
CFE_SB_SET_MEMADDR(AppInfoPtr->DataSize, ModuleInfo.addr.data_size);
CFE_SB_SET_MEMADDR(AppInfoPtr->BSSAddress, ModuleInfo.addr.bss_address);
CFE_SB_SET_MEMADDR(AppInfoPtr->BSSSize, ModuleInfo.addr.bss_size);
/*
* Convert the internal size and address to the telemetry format.
* (The telemetry format may be a different bitwidth than the native processor)
*/
AppInfoPtr->CodeAddress = CFE_ES_MEMADDRESS_C(ModuleInfo.addr.code_address);
AppInfoPtr->CodeSize = CFE_ES_MEMOFFSET_C(ModuleInfo.addr.code_size);
AppInfoPtr->DataAddress = CFE_ES_MEMADDRESS_C(ModuleInfo.addr.data_address);
AppInfoPtr->DataSize = CFE_ES_MEMOFFSET_C(ModuleInfo.addr.data_size);
AppInfoPtr->BSSAddress = CFE_ES_MEMADDRESS_C(ModuleInfo.addr.bss_address);
AppInfoPtr->BSSSize = CFE_ES_MEMOFFSET_C(ModuleInfo.addr.bss_size);
}


10 changes: 5 additions & 5 deletions fsw/cfe-core/src/es/cfe_es_apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ typedef struct
/*
* Extra information the pertains to applications only, not libraries.
*/
cpusize StackSize;
uint16 Priority;
size_t StackSize;
CFE_ES_TaskPriority_Atom_t Priority;
CFE_ES_ExceptionAction_Enum_t ExceptionAction;

} CFE_ES_AppStartParams_t;
Expand Down Expand Up @@ -227,9 +227,9 @@ int32 CFE_ES_AppCreate(CFE_ES_ResourceID_t *ApplicationIdPtr,
const char *FileName,
const char *EntryPointName,
const char *AppName,
uint32 Priority,
uint32 StackSize,
uint32 ExceptionAction);
CFE_ES_TaskPriority_Atom_t Priority,
size_t StackSize,
CFE_ES_ExceptionAction_Enum_t ExceptionAction);
/*
** Internal function to load a a new cFE shared Library
*/
Expand Down
2 changes: 1 addition & 1 deletion fsw/cfe-core/src/es/cfe_es_backgroundtask.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

#define CFE_ES_BACKGROUND_SEM_NAME "ES_BG_SEM"
#define CFE_ES_BACKGROUND_CHILD_NAME "ES_BG_TASK"
#define CFE_ES_BACKGROUND_CHILD_STACK_PTR NULL
#define CFE_ES_BACKGROUND_CHILD_STACK_PTR CFE_ES_TASK_STACK_ALLOCATE
#define CFE_ES_BACKGROUND_CHILD_STACK_SIZE CFE_PLATFORM_ES_PERF_CHILD_STACK_SIZE
#define CFE_ES_BACKGROUND_CHILD_PRIORITY CFE_PLATFORM_ES_PERF_CHILD_PRIORITY
#define CFE_ES_BACKGROUND_CHILD_FLAGS 0
Expand Down
35 changes: 18 additions & 17 deletions fsw/cfe-core/src/es/cfe_es_cds.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
int32 CFE_ES_CDS_EarlyInit(void)
{
CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars;
CFE_ES_CDS_Offset_t MinRequiredSize;
uint32 PlatformSize;
size_t MinRequiredSize;
int32 Status;

CFE_ES_Global.CDSIsAvailable = false;
Expand All @@ -77,8 +78,9 @@ int32 CFE_ES_CDS_EarlyInit(void)

CDS->LastCDSBlockId = CFE_ES_ResourceID_FromInteger(CFE_ES_CDSBLOCKID_BASE);

/* Get CDS size from OS BSP */
Status = CFE_PSP_GetCDSSize(&CDS->TotalSize);
/* Get CDS size from PSP. Note that the PSP interface
* uses "uint32" for size here. */
Status = CFE_PSP_GetCDSSize(&PlatformSize);
if (Status != CFE_PSP_SUCCESS)
{
/* Error getting the size of the CDS from the BSP */
Expand All @@ -87,7 +89,7 @@ int32 CFE_ES_CDS_EarlyInit(void)
}

/* Always truncate the size to the nearest 4 byte boundary */
CDS->TotalSize &= 0xfffffffc;
CDS->TotalSize = PlatformSize & 0xfffffffc;

/* Compute the minimum size required for the CDS with the current configuration of the cFE */
MinRequiredSize = CDS_RESERVED_MIN_SIZE;
Expand Down Expand Up @@ -200,8 +202,7 @@ CFE_ES_CDS_RegRec_t* CFE_ES_LocateCDSBlockRecordByID(CFE_ES_ResourceID_t BlockID
* NOTE: For complete prolog information, see 'cfe_es_cds.h'
*/
/*******************************************************************/
int32 CFE_ES_CDS_CacheFetch(CFE_ES_CDS_AccessCache_t *Cache,
CFE_ES_CDS_Offset_t Offset, CFE_ES_CDS_Offset_t Size)
int32 CFE_ES_CDS_CacheFetch(CFE_ES_CDS_AccessCache_t *Cache, size_t Offset, size_t Size)
{
int32 Status;

Expand Down Expand Up @@ -269,7 +270,7 @@ int32 CFE_ES_CDS_CacheFlush(CFE_ES_CDS_AccessCache_t *Cache)
* NOTE: For complete prolog information, see 'cfe_es_cds.h'
*/
/*******************************************************************/
int32 CFE_ES_CDS_CachePreload(CFE_ES_CDS_AccessCache_t *Cache, const void *Source, CFE_ES_CDS_Offset_t Offset, CFE_ES_CDS_Offset_t Size)
int32 CFE_ES_CDS_CachePreload(CFE_ES_CDS_AccessCache_t *Cache, const void *Source, size_t Offset, size_t Size)
{
int32 Status;

Expand Down Expand Up @@ -305,15 +306,15 @@ int32 CFE_ES_CDS_CachePreload(CFE_ES_CDS_AccessCache_t *Cache, const void *Sourc
** NOTE: For complete prolog information, see 'cfe_es_cds.h'
********************************************************************/

int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, CFE_ES_CDS_Offset_t UserBlockSize, const char *Name, bool CriticalTbl)
int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, size_t UserBlockSize, const char *Name, bool CriticalTbl)
{
CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars;
int32 Status;
int32 RegUpdateStatus;
CFE_ES_CDS_RegRec_t *RegRecPtr;
CFE_ES_MemOffset_t BlockOffset;
CFE_ES_MemOffset_t OldBlockSize;
CFE_ES_MemOffset_t NewBlockSize;
size_t BlockOffset;
size_t OldBlockSize;
size_t NewBlockSize;
CFE_ES_ResourceID_t PendingBlockId;
bool IsNewEntry;
bool IsNewOffset;
Expand Down Expand Up @@ -469,8 +470,8 @@ int32 CFE_ES_RegisterCDSEx(CFE_ES_CDSHandle_t *HandlePtr, CFE_ES_CDS_Offset_t Us
int32 CFE_ES_ValidateCDS(void)
{
CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars;
CFE_ES_CDS_Offset_t TrailerOffset;
const CFE_ES_CDS_Offset_t SIG_CDS_SIZE = { CFE_ES_CDS_SIGNATURE_LEN };
size_t TrailerOffset;
const size_t SIG_CDS_SIZE = { CFE_ES_CDS_SIGNATURE_LEN };
int32 Status;

/* Perform 2 checks to validate the CDS Memory Pool */
Expand Down Expand Up @@ -519,7 +520,7 @@ int32 CFE_ES_ValidateCDS(void)
int32 CFE_ES_ClearCDS(void)
{
CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars;
CFE_ES_CDS_Offset_t RemainSize;
size_t RemainSize;
int32 Status;

/* Clear the CDS to ensure everything is gone */
Expand Down Expand Up @@ -564,7 +565,7 @@ int32 CFE_ES_ClearCDS(void)
int32 CFE_ES_InitCDSSignatures(void)
{
CFE_ES_CDS_Instance_t *CDS = &CFE_ES_Global.CDSVars;
CFE_ES_CDS_Offset_t SigOffset;
size_t SigOffset;
int32 Status;

/* Initialize the Validity Check strings */
Expand Down Expand Up @@ -668,7 +669,7 @@ void CFE_ES_FormCDSName(char *FullCDSName, const char *CDSName, CFE_ES_ResourceI
{
char AppName[OS_MAX_API_NAME];

CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME);
CFE_ES_GetAppName(AppName, ThisAppId, sizeof(AppName));

/* Ensure that AppName is null terminated */
AppName[OS_MAX_API_NAME-1] = '\0';
Expand Down Expand Up @@ -844,7 +845,7 @@ int32 CFE_ES_DeleteCDS(const char *CDSName, bool CalledByTblServices)
CFE_ES_ResourceID_t AppId;
uint32 i;
char LogMessage[CFE_ES_MAX_SYSLOG_MSG_SIZE];
CFE_ES_MemOffset_t OldBlockSize;
size_t OldBlockSize;

LogMessage[0] = 0;

Expand Down
Loading

0 comments on commit 5ae7613

Please sign in to comment.