[修改] 增加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,4 @@
#include "FreeRTOS_DHCP.h"
eDHCPCallbackAnswer_t xApplicationDHCPHook( eDHCPCallbackPhase_t eDHCPPhase,
uint32_t ulIPAddress );

View File

@ -0,0 +1,170 @@
/* Include Unity header */
#include <unity.h>
/* Include standard libraries */
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "FreeRTOS.h"
#include "task.h"
#include "list.h"
#include "FreeRTOS_IP.h"
#include "FreeRTOS_IP_Private.h"
volatile BaseType_t xInsideInterrupt = pdFALSE;
/** @brief The expected IP version and header length coded into the IP header itself. */
#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 )
UDPPacketHeader_t xDefaultPartUDPPacketHeader =
{
/* .ucBytes : */
{
0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */
0x08, 0x00, /* Ethernet frame type. */
ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */
0x00, /* ucDifferentiatedServicesCode. */
0x00, 0x00, /* usLength. */
0x00, 0x00, /* usIdentification. */
0x00, 0x00, /* usFragmentOffset. */
ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */
ipPROTOCOL_UDP, /* ucProtocol. */
0x00, 0x00, /* usHeaderChecksum. */
0x00, 0x00, 0x00, 0x00 /* Source IP address. */
}
};
/*
* IP-clash detection is currently only used internally. When DHCP doesn't respond, the
* driver can try out a random LinkLayer IP address (169.254.x.x). It will send out a
* gratuitous ARP message and, after a period of time, check the variables here below:
*/
#if ( ipconfigARP_USE_CLASH_DETECTION != 0 )
/* Becomes non-zero if another device responded to a gratuitous ARP message. */
BaseType_t xARPHadIPClash;
/* MAC-address of the other device containing the same IP-address. */
MACAddress_t xARPClashMacAddress;
#endif /* ipconfigARP_USE_CLASH_DETECTION */
/** @brief For convenience, a MAC address of all 0xffs is defined const for quick
* reference. */
const MACAddress_t xBroadcastMACAddress = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } };
/** @brief Structure that stores the netmask, gateway address and DNS server addresses. */
NetworkAddressingParameters_t xNetworkAddressing =
{
0xC0C0C0C0, /* 192.192.192.192 - Default IP address. */
0xFFFFFF00, /* 255.255.255.0 - Netmask. */
0xC0C0C001, /* 192.192.192.1 - Gateway Address. */
0x01020304, /* 1.2.3.4 - DNS server address. */
0xC0C0C0FF
}; /* 192.192.192.255 - Broadcast address. */
/** @brief Structure that stores the netmask, gateway address and DNS server addresses. */
NetworkAddressingParameters_t xDefaultAddressing =
{
0xC0C0C0C0, /* 192.192.192.192 - Default IP address. */
0xFFFFFF00, /* 255.255.255.0 - Netmask. */
0xC0C0C001, /* 192.192.192.1 - Gateway Address. */
0x01020304, /* 1.2.3.4 - DNS server address. */
0xC0C0C0FF
};
size_t xPortGetMinimumEverFreeHeapSize( void )
{
return 0;
}
BaseType_t xApplicationDNSQueryHook( const char * pcName )
{
}
StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
StackType_t * pxEndOfStack,
TaskFunction_t pxCode,
void * pvParameters )
{
}
uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
uint16_t usSourcePort,
uint32_t ulDestinationAddress,
uint16_t usDestinationPort )
{
}
BaseType_t xNetworkInterfaceInitialise( void )
{
}
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
}
void vApplicationDaemonTaskStartupHook( void )
{
}
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
StackType_t ** ppxTimerTaskStackBuffer,
uint32_t * pulTimerTaskStackSize )
{
}
void vPortDeleteThread( void * pvTaskToDelete )
{
}
void vApplicationIdleHook( void )
{
}
void vApplicationTickHook( void )
{
}
unsigned long ulGetRunTimeCounterValue( void )
{
}
void vPortEndScheduler( void )
{
}
BaseType_t xPortStartScheduler( void )
{
}
void vPortEnterCritical( void )
{
}
void vPortExitCritical( void )
{
}
void * pvPortMalloc( size_t xWantedSize )
{
return malloc( xWantedSize );
}
void vPortFree( void * pv )
{
free( pv );
}
void vPortGenerateSimulatedInterrupt( uint32_t ulInterruptNumber )
{
}
void vPortCloseRunningThread( void * pvTaskToDelete,
volatile BaseType_t * pxPendYield )
{
}
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
StackType_t ** ppxIdleTaskStackBuffer,
uint32_t * pulIdleTaskStackSize )
{
}
void vConfigureTimerForRunTimeStats( void )
{
}
BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer,
BaseType_t bReleaseAfterSend )
{
return pdPASS;
}
/*-----------------------------------------------------------*/

View File

@ -0,0 +1,95 @@
# Include filepaths for source and include.
include( ${MODULE_ROOT_DIR}/test/unit-test/TCPFilePaths.cmake )
# ==================== Define your project name (edit) ========================
set( project_name "FreeRTOS_DHCP" )
message( STATUS "${project_name}" )
# ===================== Create your mock here (edit) ========================
set(mock_list "")
# list the files to mock here
list(APPEND mock_list
"${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/task.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Sockets.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_UDP_IP.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ARP.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Private.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Timers.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/NetworkBufferManagement.h"
"${MODULE_ROOT_DIR}/test/unit-test/${project_name}/FreeRTOS_DHCP_mock.h"
)
# list the directories your mocks need
list(APPEND mock_include_list
.
${TCP_INCLUDE_DIRS}
${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include
${MODULE_ROOT_DIR}/test/unit-test/ConfigFiles
)
#list the definitions of your mocks to control what to be included
list(APPEND mock_define_list
""
)
# ================= Create the library under test here (edit) ==================
# list the files you would like to test here
list(APPEND real_source_files
${MODULE_ROOT_DIR}/source/FreeRTOS_DHCP.c
)
# list the directories the module under test includes
list(APPEND real_include_directories
.
${TCP_INCLUDE_DIRS}
${MODULE_ROOT_DIR}/test/unit-test/ConfigFiles
${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include
${CMOCK_DIR}/vendor/unity/src
)
# ===================== Create UnitTest Code here (edit) =====================
# list the directories your test needs to include
list(APPEND test_include_directories
.
${CMOCK_DIR}/vendor/unity/src
${TCP_INCLUDE_DIRS}
${MODULE_ROOT_DIR}/test/unit-test/${project_name}
)
# ============================= (end edit) ===================================
set(mock_name "${project_name}_mock")
set(real_name "${project_name}_real")
create_mock_list(${mock_name}
"${mock_list}"
"${MODULE_ROOT_DIR}/test/unit-test/cmock/project.yml"
"${mock_include_list}"
"${mock_define_list}"
)
create_real_library(${real_name}
"${real_source_files}"
"${real_include_directories}"
"${mock_name}"
)
list(APPEND utest_link_list
-l${mock_name}
lib${real_name}.a
)
list(APPEND utest_dep_list
${real_name}
)
set(utest_name "${project_name}_utest")
set(utest_source "${project_name}/${project_name}_utest.c")
create_test(${utest_name}
${utest_source}
"${utest_link_list}"
"${utest_dep_list}"
"${test_include_directories}"
)