[修改] 增加freeRTOS

1. 版本FreeRTOSv202212.01,命名为kernel;
This commit is contained in:
2023-05-06 16:43:01 +00:00
commit a345df017b
20944 changed files with 11094377 additions and 0 deletions

View File

@ -0,0 +1,55 @@
{
"ENTRY": "ReadNameField",
################################################################
#Enable DNS callbacks or else ReadNameField is not defined
"callbacks": "1",
################################################################
# This is the network buffer size. Set to any positive value.
"NETWORK_BUFFER_SIZE" : "10",
################################################################
# This is the size of the buffer into which the name is copied.
# Set to any positive value.
# In the source, NAME_SIZE=254 and NETWORK_BUFFER_SIZE >> NAME_SIZE
# In the proof, NAME_SIZE >= 4 required for good coverage.
"NAME_SIZE": "6",
################################################################
# Loop prvReadNameField.0:
# should be min of buffer size and name size
# but loop must be unwound at least once, so max of this and 1+1
"READLOOP0": "DNS_ReadNameField.0",
"READLOOP0_UNWIND": "__eval max(2, min({NETWORK_BUFFER_SIZE}, {NAME_SIZE}+1))",
################################################################
# Loop prvReadNameField.1:
# should be min of buffer size and name size
# but loop must be unwound at least twice, so max of this and 2+1
"READLOOP1": "DNS_ReadNameField.1",
"READLOOP1_UNWIND": "__eval max(3, min({NETWORK_BUFFER_SIZE}, {NAME_SIZE}))",
################################################################
"CBMCFLAGS":
[
"--unwind 1",
"--unwindset {READLOOP0}:{READLOOP0_UNWIND},{READLOOP1}:{READLOOP1_UNWIND}"
],
"OBJS":
[
"$(ENTRY)_harness.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_DNS.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_DNS_Parser.goto"
],
"DEF":
[
"NETWORK_BUFFER_SIZE={NETWORK_BUFFER_SIZE}",
"NAME_SIZE={NAME_SIZE}",
"ipconfigDNS_USE_CALLBACKS={callbacks}",
"ipconfigDNS_CACHE_NAME_LENGTH=254"
]
}

View File

@ -0,0 +1,102 @@
/* Standard includes. */
#include <stdint.h>
/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "list.h"
#include "semphr.h"
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_IP_Private.h"
#include "FreeRTOS_UDP_IP.h"
#include "FreeRTOS_DNS.h"
#include "NetworkBufferManagement.h"
#include "NetworkInterface.h"
#include "IPTraceMacroDefaults.h"
#include "cbmc.h"
/****************************************************************
* Signature of function under test
****************************************************************/
size_t DNS_ReadNameField( const uint8_t * pucByte,
size_t uxRemainingBytes,
char * pcName,
size_t uxDestLen );
/****************************************************************
* The function under test is not defined in all configurations
****************************************************************/
#if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 )
/* DNS_ReadNameField is defined in this configuration */
#else
/* DNS_ReadNameField is not defined in this configuration, stub it. */
size_t DNS_ReadNameField( const uint8_t * pucByte,
size_t uxRemainingBytes,
char * pcName,
size_t uxDestLen )
{
return 0;
}
#endif /* if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 ) */
/****************************************************************
* Proof of DNS_ReadNameField function contract
****************************************************************/
void harness()
{
__CPROVER_assert( NETWORK_BUFFER_SIZE < CBMC_MAX_OBJECT_SIZE,
"NETWORK_BUFFER_SIZE < CBMC_MAX_OBJECT_SIZE" );
__CPROVER_assert( NAME_SIZE < CBMC_MAX_OBJECT_SIZE,
"NAME_SIZE < CBMC_MAX_OBJECT_SIZE" );
__CPROVER_assert( NAME_SIZE >= 4,
"NAME_SIZE >= 4 required for good coverage." );
size_t uxRemainingBytes;
size_t uxDestLen;
uint8_t * pucByte = malloc( uxRemainingBytes );
char * pcName = malloc( uxDestLen );
/* Preconditions */
__CPROVER_assume( uxRemainingBytes < CBMC_MAX_OBJECT_SIZE );
__CPROVER_assume( uxDestLen < CBMC_MAX_OBJECT_SIZE );
__CPROVER_assume( uxRemainingBytes <= NETWORK_BUFFER_SIZE );
__CPROVER_assume( uxDestLen <= NAME_SIZE );
__CPROVER_assume( pucByte != NULL );
__CPROVER_assume( pcName != NULL );
/* Avoid overflow on uxSourceLen - 1U with uxSourceLen == uxRemainingBytes */
/*__CPROVER_assume(uxRemainingBytes > 0); */
/* Avoid overflow on uxDestLen - 1U */
__CPROVER_assume( uxDestLen > 0 );
size_t index = DNS_ReadNameField( pucByte,
uxRemainingBytes,
pcName,
uxDestLen );
/* Postconditions */
__CPROVER_assert( index <= uxDestLen + 1 && index <= uxRemainingBytes,
"DNS_ReadNameField : index <= uxDestLen+1" );
}