Skip to content

Commit

Permalink
Fix nasa#1336, Function comment blocks in SB module
Browse files Browse the repository at this point in the history
  • Loading branch information
jphickey committed Apr 27, 2021
1 parent 587d241 commit f2e066e
Show file tree
Hide file tree
Showing 8 changed files with 1,091 additions and 840 deletions.
437 changes: 225 additions & 212 deletions modules/sb/fsw/src/cfe_sb_api.c

Large diffs are not rendered by default.

203 changes: 75 additions & 128 deletions modules/sb/fsw/src/cfe_sb_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,29 @@
*/
#define CFE_SB_BUFFERD_CONTENT_OFFSET (offsetof(CFE_SB_BufferD_t, Content))

/******************************************************************************
/*----------------------------------------------------------------
*
* Helper function to reset/clear the links on a list node (make empty)
*/
* Function: CFE_SB_TrackingListReset
*
* Application-scope internal function
* See description in cfe_sb_priv.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_SB_TrackingListReset(CFE_SB_BufferLink_t *Link)
{
/* A singleton node/empty list points to itself */
Link->Prev = Link;
Link->Next = Link;
}

/******************************************************************************
/*----------------------------------------------------------------
*
* Helper function to remove a node from a tracking list
*/
* Function: CFE_SB_TrackingListRemove
*
* Application-scope internal function
* See description in cfe_sb_priv.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_SB_TrackingListRemove(CFE_SB_BufferLink_t *Node)
{
/* Remove from list */
Expand All @@ -67,10 +75,14 @@ void CFE_SB_TrackingListRemove(CFE_SB_BufferLink_t *Node)
CFE_SB_TrackingListReset(Node);
}

/******************************************************************************
/*----------------------------------------------------------------
*
* Helper function to add a node to a tracking list
*/
* Function: CFE_SB_TrackingListAdd
*
* Application-scope internal function
* See description in cfe_sb_priv.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_SB_TrackingListAdd(CFE_SB_BufferLink_t *List, CFE_SB_BufferLink_t *Node)
{
/* Connect this node to the list at "prev" position (tail) */
Expand All @@ -82,26 +94,14 @@ void CFE_SB_TrackingListAdd(CFE_SB_BufferLink_t *List, CFE_SB_BufferLink_t *Node
Node->Next->Prev = Node;
}

/******************************************************************************
** Function: CFE_SB_GetBufferFromPool()
**
** Purpose:
** Request a buffer from the SB buffer pool. The SB buffer pool is a
** pre-allocated block of memory of size CFE_PLATFORM_SB_BUF_MEMORY_BYTES. It is used
** by the SB to dynamically allocate memory to hold the message and a buffer
** descriptor associated with the message during the sending of a message.
**
** Note:
** This must only be invoked while holding the SB global lock
**
** Arguments:
** MaxMsgSize : Size of the buffer content area in bytes.
**
** Return:
** Pointer to the buffer descriptor for the new buffer, or NULL if the buffer
** could not be allocated.
*/

/*----------------------------------------------------------------
*
* Function: CFE_SB_GetBufferFromPool
*
* Application-scope internal function
* See description in cfe_sb_priv.h for argument/return detail
*
*-----------------------------------------------------------------*/
CFE_SB_BufferD_t *CFE_SB_GetBufferFromPool(size_t MaxMsgSize)
{
int32 stat1;
Expand Down Expand Up @@ -143,26 +143,16 @@ CFE_SB_BufferD_t *CFE_SB_GetBufferFromPool(size_t MaxMsgSize)
CFE_SB_TrackingListReset(&bd->Link);

return bd;
}

} /* CFE_SB_GetBufferFromPool */

/******************************************************************************
** Function: CFE_SB_ReturnBufferToPool()
**
** Purpose:
** This function will return two blocks of memory back to the memory pool.
** One block is the memory used to store the actual message, the other block
** was used to store the buffer descriptor for the message.
**
** Note:
** This must only be invoked while holding the SB global lock
**
** Arguments:
** bd : Pointer to the buffer descriptor.
**
** Return:
** None
*/
/*----------------------------------------------------------------
*
* Function: CFE_SB_ReturnBufferToPool
*
* Application-scope internal function
* See description in cfe_sb_priv.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_SB_ReturnBufferToPool(CFE_SB_BufferD_t *bd)
{
/* Remove from any tracking list (no effect if not in a list) */
Expand All @@ -173,57 +163,33 @@ void CFE_SB_ReturnBufferToPool(CFE_SB_BufferD_t *bd)

/* finally give the buf descriptor back to the buf descriptor pool */
CFE_ES_PutPoolBuf(CFE_SB_Global.Mem.PoolHdl, bd);
}

} /* end CFE_SB_ReturnBufferToPool */

/******************************************************************************
** Function: CFE_SB_IncrBufUseCnt()
**
** Purpose:
** This function will increment the UseCount of a particular buffer.
**
** Note:
** UseCount is a variable in the CFE_SB_BufferD_t and is used only to
** determine when a buffer may be returned to the memory pool.
**
** This must only be invoked while holding the SB global lock
**
** Arguments:
** bd : Pointer to the buffer descriptor.
**
** Return:
** CFE_SUCCESS for normal operation.
*/
/*----------------------------------------------------------------
*
* Function: CFE_SB_IncrBufUseCnt
*
* Application-scope internal function
* See description in cfe_sb_priv.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_SB_IncrBufUseCnt(CFE_SB_BufferD_t *bd)
{
/* range check the UseCount variable */
if (bd->UseCount < 0x7FFF)
{
++bd->UseCount;
}
}

} /* end CFE_SB_DecrBufUseCnt */

/******************************************************************************
** Function: CFE_SB_DecrBufUseCnt()
**
** Purpose:
** This function will decrement the UseCount of a particular buffer. If the
** the UseCount is decremented to zero, it will return the buffer to the
** memory pool.
**
** Note:
** UseCount is a variable in the CFE_SB_BufferD_t and is used only to
** determine when a buffer may be returned to the memory pool.
**
** This must only be invoked while holding the SB global lock
**
** Arguments:
** bd : Pointer to the buffer descriptor.
**
** Return:
** CFE_SUCCESS for normal operation.
*/
/*----------------------------------------------------------------
*
* Function: CFE_SB_DecrBufUseCnt
*
* Application-scope internal function
* See description in cfe_sb_priv.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_SB_DecrBufUseCnt(CFE_SB_BufferD_t *bd)
{
/* range check the UseCount variable */
Expand All @@ -236,24 +202,16 @@ void CFE_SB_DecrBufUseCnt(CFE_SB_BufferD_t *bd)
CFE_SB_ReturnBufferToPool(bd);
}
}
}

} /* end CFE_SB_DecrBufUseCnt */

/******************************************************************************
** Function: CFE_SB_GetDestinationBlk()
**
** Purpose:
** This function gets a destination descriptor from the SB memory pool.
**
** Note:
** This must only be invoked while holding the SB global lock
**
** Arguments:
** None
**
** Return:
** Pointer to the destination descriptor
*/
/*----------------------------------------------------------------
*
* Function: CFE_SB_GetDestinationBlk
*
* Application-scope internal function
* See description in cfe_sb_priv.h for argument/return detail
*
*-----------------------------------------------------------------*/
CFE_SB_DestinationD_t *CFE_SB_GetDestinationBlk(void)
{
int32 Stat;
Expand All @@ -275,24 +233,16 @@ CFE_SB_DestinationD_t *CFE_SB_GetDestinationBlk(void)
} /* end if */

return Dest;
}

} /* end CFE_SB_GetDestinationBlk */

/******************************************************************************
** Function: CFE_SB_PutDestinationBlk()
**
** Purpose:
** This function returns a destination descriptor to the SB memory pool.
**
** Note:
** This must only be invoked while holding the SB global lock
**
** Arguments:
** None
**
** Return:
** Pointer to the destination descriptor
*/
/*----------------------------------------------------------------
*
* Function: CFE_SB_PutDestinationBlk
*
* Application-scope internal function
* See description in cfe_sb_priv.h for argument/return detail
*
*-----------------------------------------------------------------*/
int32 CFE_SB_PutDestinationBlk(CFE_SB_DestinationD_t *Dest)
{
int32 Stat;
Expand All @@ -311,7 +261,4 @@ int32 CFE_SB_PutDestinationBlk(CFE_SB_DestinationD_t *Dest)
} /* end if */

return CFE_SUCCESS;

} /* end CFE_SB_PutDestinationBlk */

/*****************************************************************************/
}
81 changes: 29 additions & 52 deletions modules/sb/fsw/src/cfe_sb_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,14 @@ const size_t CFE_SB_MemPoolDefSize[CFE_PLATFORM_ES_POOL_MAX_BUCKETS] = {
CFE_PLATFORM_SB_MEM_BLOCK_SIZE_05, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_04, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_03,
CFE_PLATFORM_SB_MEM_BLOCK_SIZE_02, CFE_PLATFORM_SB_MEM_BLOCK_SIZE_01};

/******************************************************************************
** Function: CFE_SB_EarlyInit()
**
** Purpose:
** Initialize the Software Bus routing tables.
**
** Arguments:
**
** Notes:
** This function MUST be called before any SB API's are called.
**
** Return:
** CFE_SUCCESS
*/
/*----------------------------------------------------------------
*
* Function: CFE_SB_EarlyInit
*
* Implemented per public API
* See description in cfe_sb_core_internal.h for argument/return detail
*
*-----------------------------------------------------------------*/
int32 CFE_SB_EarlyInit(void)
{

Expand Down Expand Up @@ -99,23 +93,16 @@ int32 CFE_SB_EarlyInit(void)
sizeof(CFE_SB_Global.StatTlmMsg));

return Stat;

} /* end CFE_SB_EarlyInit */

/******************************************************************************
** Function: CFE_SB_InitBuffers()
**
** Purpose:
** Initialize the Software Bus Buffer Pool.
**
** Arguments:
**
** Notes:
** This function MUST be called before any SB API's are called.
**
** Return:
** none
*/
}

/*----------------------------------------------------------------
*
* Function: CFE_SB_InitBuffers
*
* Application-scope internal function
* See description in cfe_sb_priv.h for argument/return detail
*
*-----------------------------------------------------------------*/
int32 CFE_SB_InitBuffers(void)
{

Expand All @@ -140,27 +127,17 @@ int32 CFE_SB_InitBuffers(void)
CFE_SB_TrackingListReset(&CFE_SB_Global.ZeroCopyList);

return CFE_SUCCESS;

} /* end CFE_SB_InitBuffers */

/******************************************************************************
** Function: CFE_SB_InitPipeTbl()
**
** Purpose:
** Initialize the Software Bus Pipe Table.
**
** Arguments:
**
** Notes:
** This function MUST be called before any SB API's are called.
**
** Return:
** none
*/
}

/*----------------------------------------------------------------
*
* Function: CFE_SB_InitPipeTbl
*
* Application-scope internal function
* See description in cfe_sb_priv.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_SB_InitPipeTbl(void)
{
CFE_SB_Global.LastPipeId = CFE_ResourceId_FromInteger(CFE_SB_PIPEID_BASE);

} /* end CFE_SB_InitPipeTbl */

/*****************************************************************************/
}
Loading

0 comments on commit f2e066e

Please sign in to comment.