diff --git a/.vscode/settings.json b/.vscode/settings.json index b977c74b64a5898065c19e043b22f252a3c4fa80..51b1293042abf70cb72b91816dd1860126ee533f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -38,6 +38,9 @@ "tcpip.h": "c", "init.h": "c", "ethernet.h": "c", - "stdio.h": "c" + "stdio.h": "c", + "semphr.h": "c", + "portmacro.h": "c", + "fwdt.h": "c" } } \ No newline at end of file diff --git a/README.md b/README.md index 830e7cc64a0f6f8f7c73bf051998d3e153fe87a2..fcb1ef871b1bdc6ca05277dcdbdba7ffe5320ea6 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ * * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-06-30 10:35:37 - * @LastEditTime: 2021-07-22 15:02:51 + * @Date: 2021-10-30 10:35:37 + * @LastEditTime: 2021-11-01 15:02:51 * @Description:  This files is for * * @Modify History: @@ -14,93 +14,75 @@ # Phytium-FreeRTOS-SDK ## 1. 介绍 + 本项目发布了Phytium系列CPU的FreeRTOS源代码,参考例程以及配置构建工具 +--- -## 2. Ubuntu 20.04 x86_64环境下安装FreeRTOS SDK -### 2.1. 选择在线方式安装SDK +## 2. 快速入门 -- 通过Gitee拉取FreeRTOS SDK源代码 -``` -$ git clone https://gitee.com/phytium_embedded/phytium-free-rtos-sdk.git ~/freertos_sdk -$ cd ~/freertos_sdk -``` +- 目前支持在Windows和Linux上使用SDK,支持在x86_64和arm aarch64设备上完成交叉编译 -- 检查install.sh的执行权限, 如果没有执行权限`x`,需要利用`chmod +x ./install.sh`添加执行权限 -``` -$ ls ./install.sh -l --rwxrwxrwx 1 usr usr 6353 Jul 21 10:13 ./install.sh -``` +![windows](https://images.gitee.com/uploads/images/2021/1019/153036_3fab0761_8736513.png "windows.png =100x100")![linux](https://images.gitee.com/uploads/images/2021/1019/153045_651dfe45_8736513.png "linux.png")![输入图片说明](https://images.gitee.com/uploads/images/2021/1019/160938_5b34865e_8736513.png "屏幕截图.png") -- 在线下载源代码和编译环境,完成FreeRTOS SDK安装 -``` -$ ./install.sh -online -``` -### 2.2. 选择离线方式安装SDK -- 下载[Phytium Standalone SDK](https://gitee.com/phytium_embedded/phytium-standalone-sdk)源代码 -- 下载[Phytium FreeRTOS SDK](https://gitee.com/phytium_embedded/phytium-free-rtos-sdk)源代码 -- 下载[AARCH32](https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776847/download/gcc-arm-x86_64-none-eabi-10-2020-q4-major.tar.xz)编译器 -- 下载[AARCH64](https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776846/download/gcc-arm-x86_64-aarch64-none-elf-10.2-2020.11.tar.xz)编译器 +- 参考如下说明搭建Phytium FreeRTOS SDK的软件环境 -- 解压phytium_freertos_sdk.zip为`~/freertos_sdk`(路径名可以自定义) -- 解压phytium_standalone_sdk.zip为`~/freertos_sdk/standalone`(必须放置在standalone路径下),除了bsp和lib两个目录及其文件外,`~/freertos_sdk/standalone`中其它的目录及文件不需要使用,可以删除 -- 将AARCH32、AARCH64编译器压缩包放置在`~/freertos_sdk/tools`(必须放置在tools路径下) -- 确保install.sh有执行权限,`~/freertos_sdk`目录下在运行以下命令,完成FreeRTOS SDK安装 -``` -$ ./install.sh -``` + [Windows10 快速入门](./docs/reference/usr/install_windows.md) -- **安装完成后重启系统,生效FreeRTOS SDK环境** + [Linux x86_64 快速入门](./docs/reference/usr/install_linux_x86_64.md) -# 3. 使用FreeRTOS SDK + [Linux arm aarch64 快速入门](./docs/reference/usr/install_linux_aarch64.md) -## 3.1 快速使用例程 -### 3.1.1 使用FT2000-4开发板,启动FreeRTOS ->freertos_sdk/example/function_test -- 加载FT2000-4 aarch32的,默认配置 -``` -$ make config_ft2004_aarch32 -``` +- 参考[使用说明](./docs/reference/usr/usage.md), 新建Phytium FreeRTOS SDK的应用工程,与开发板建立连接 -- 如果需要修改配置,例如修改编译输出文件的名字 -``` -$ make menuconfig -``` -![menuconfig](https://images.gitee.com/uploads/images/2021/0722/093202_781126bc_8736513.png "屏幕截图.png") +--- -- 进入Project Configuration → Build Target Name +## 3. 硬件参考 -- 编译例程 -``` -$ make -``` -![输入图片说明](https://images.gitee.com/uploads/images/2021/0722/093410_25ad64a4_8736513.png "屏幕截图.png") +### 3.1 FT2000-4 -- 将*.bin通过TFTP服务器烧写到开发板,跳转启动 -``` -sudo service tftpd-hpa restart //重启host侧tftp服务器 -``` +FT-2000/4 是一款面向桌面应用的高性能通用 4 核处理器。每 2 个核构成 1 个处理器核簇(Cluster),并共享 L2 Cache。主要技术特征如下: -``` -setenv ipaddr 192.168.4.20 //配置开发板侧的ip -setenv serverip 192.168.4.50 -setenv gatewayip 192.168.4.1 -tftpboot 80100000 ft2004_freertos.bin //通过tftp服务加载编译二进制文件 -dcache flush -go 0x80100000 // 跳转执行 -``` +- 兼容 ARM v8 64 位指令系统,兼容 32 位指令 +- 支持单精度、双精度浮点运算指令 +- 支持 ASIMD 处理指令 +- 集成 2 个 DDR4 通道,可对 DDR 存储数据进行实时加密 +- 集成 34 Lane PCIE3.0 接口:2 个 X16(每个可拆分成 2 个 X8),2 个 X1 +- 集成 2 个 GMAC,RGMII 接口,支持 10/100/1000 自适应 +- 集成 1 个 SD 卡控制器,兼容 SD 2.0 规范 +- 集成 1 个 HDAudio,支持音频输出,可同时支持最多 4 个 Codec +- 集成 SM2、SM3、SM4 模块 +- 集成 4 个 UART,1 个 LPC,32 个 GPIO,4 个 I2C,1 个 QSPI,2 个通 用 SPI,2 个 WDT,16 个外部中断(和 GPIO 共用 IO) +- 集成温度传感器 -![输入图片说明](https://images.gitee.com/uploads/images/2021/0722/093443_cc4d8166_8736513.png "屏幕截图.png") +### 3.2 D2000 -## 参考资料 +D2000 是一款面向桌面应用的高性能通用 8 核处理器。每 2 个核构成 1 个处理器核簇(Cluster),并共享 L2 Cache。存储系统包含 Cache 子系统和 DDR,I/O 系统包含 PCIe、高速 IO 子系统、千兆位以太网 GMAC 和低速 IO 子系统,主要技术特征如下, + +- 兼容 ARM v8 64 位指令系统,兼容 32 位指令 +- 支持单精度、双精度浮点运算指令 +- 支持 ASIMD 处理指令 +- 集成 2 个 DDR 通道,支持 DDR4 和 LPDDR4,可对 DDR 存储数据进行实时加密 +- 集成 34 Lane PCIE3.0 接口:2 个 X16(每个可拆分成 2 个 X8),2 个 X1 +- 集成 2 个 GMAC,RGMII 接口,支持 10/100/1000 自适应 +- 集成 1 个 SD 卡控制器,兼容 SD 2.0 规范 +- 集成 1 个 HDAudio,支持音频输出,可同时支持最多 4 个 Codec +- 集成 SM2、SM3、SM4、SM9 模块 +- 集成 4 个 UART,1 个 LPC,32 个 GPIO,4 个 I2C,1 个 QSPI,2 个通用 SPI,2 个 WDT,16 个外部中断(和 GPIO 共用 IO) +- 集成 2 个温度传感器 + +--- + +## 4. 参考资料 - The FreeRTOS Reference Manual API Functions and Configuration Options - Mastering the FreeRTOS Real Time Kernel A Hands-On Tutorial Guide +--- -## 7. 贡献方法 +## 5. 贡献方法 请联系飞腾嵌入式软件部 @@ -108,8 +90,10 @@ huanghe@phytium.com.cn zhugengyu@phytium.com.cn +wangxiaodong1030@phytium.com.cn + --- -## 8. 许可协议 +## 6. 许可协议 Apache-2.0 \ No newline at end of file diff --git a/configs/d2000_aarch32_defconfig b/configs/d2000_aarch32_defconfig index 8749cbe9b8e2b3544055140d2b36a394fb5b44b4..15b70295b43e2cce9f15f5135761beb793bc5c61 100644 --- a/configs/d2000_aarch32_defconfig +++ b/configs/d2000_aarch32_defconfig @@ -19,6 +19,8 @@ CONFIG_TARGET_ARMV8_AARCH32=y CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y +# CONFIG_USE_SYS_TICK is not set +CONFIG_USE_AARCH64_L1_TO_AARCH32=y # end of Arch Configuration # @@ -36,7 +38,7 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_EBABLE_GICV3=y -CONFIG_USE_USART=y +# CONFIG_USE_SERIAL is not set # # Usart Configuration @@ -67,10 +69,13 @@ CONFIG_ENABLE_F_GMAC=y # CONFIG_USE_TIMER is not set # CONFIG_USE_SDMMC is not set # CONFIG_USE_PCIE is not set +# CONFIG_USE_WDT is not set # CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set # end of Components Configuration -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y +# CONFIG_USE_NEW_LIBC is not set # end of Standalone Setting # @@ -98,6 +103,14 @@ CONFIG_LOG_INFO=y CONFIG_AARCH32_RAM_LD=y # CONFIG_AARCH64_RAM_LD is not set # CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0x80100000 +CONFIG_ROM_SIZE_MB=1 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0x81000000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=0x100000 +CONFIG_STACK_SIZE=0x100000 # end of GNU Linker Setting # end of Building Option diff --git a/configs/d2000_aarch64_defconfig b/configs/d2000_aarch64_defconfig index 89696a9ea6865e8f5020b07e3b62216add22ceec..9471b8bdeded298a56ebe903847b1502c895982a 100644 --- a/configs/d2000_aarch64_defconfig +++ b/configs/d2000_aarch64_defconfig @@ -39,7 +39,7 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_EBABLE_GICV3=y -CONFIG_USE_USART=y +# CONFIG_USE_SERIAL is not set # # Usart Configuration @@ -73,13 +73,13 @@ CONFIG_F_GMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # end of Components Configuration -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y +# CONFIG_USE_NEW_LIBC is not set # end of Standalone Setting # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y # # Cross-Compiler Setting @@ -101,7 +101,15 @@ CONFIG_LOG_INFO=y # CONFIG_AARCH32_RAM_LD is not set CONFIG_AARCH64_RAM_LD=y # CONFIG_USER_DEFINED_LD is not set -# end of GNU Linker Setting +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0x80100000 +CONFIG_ROM_SIZE_MB=1 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0x81000000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=0x100000 +CONFIG_STACK_TOP_ADDR=0x82000000 +# end of Linker Options # end of Building Option # diff --git a/configs/ft2004_aarch32_defconfig b/configs/ft2004_aarch32_defconfig index 69f9cd19287fdcb72fb3c212fe3a5ade3d2830ef..3e86c9957c25636d1401a2abc39bbcbffa7c3556 100644 --- a/configs/ft2004_aarch32_defconfig +++ b/configs/ft2004_aarch32_defconfig @@ -40,7 +40,7 @@ CONFIG_TARGET_F2000_4=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_EBABLE_GICV3=y -CONFIG_USE_USART=y +# CONFIG_USE_SERIAL is not set # # Usart Configuration @@ -62,7 +62,7 @@ CONFIG_ENABLE_F_GMAC=y # F_GMAC Configuration # # CONFIG_F_GMAC_PHY_COMMON is not set -CONFIG_F_GMAC_PHY_AR803X=y +# CONFIG_F_GMAC_PHY_AR803X is not set # end of F_GMAC Configuration # end of Eth Configuration @@ -103,6 +103,14 @@ CONFIG_LOG_INFO=y CONFIG_AARCH32_RAM_LD=y # CONFIG_AARCH64_RAM_LD is not set # CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0x80100000 +CONFIG_ROM_SIZE_MB=1 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0x81000000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=0x100000 +CONFIG_STACK_SIZE=0x100000 # end of GNU Linker Setting # end of Building Option diff --git a/configs/ft2004_aarch64_defconfig b/configs/ft2004_aarch64_defconfig index d7919c98d404aff1e19b60deb642be8b7850c206..84c05b885af2b4174301eded55a4599f2b95a349 100644 --- a/configs/ft2004_aarch64_defconfig +++ b/configs/ft2004_aarch64_defconfig @@ -38,7 +38,7 @@ CONFIG_TARGET_F2000_4=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_EBABLE_GICV3=y -CONFIG_USE_USART=y +# CONFIG_USE_SERIAL is not set # # Usart Configuration @@ -60,7 +60,7 @@ CONFIG_ENABLE_F_GMAC=y # F_GMAC Configuration # # CONFIG_F_GMAC_PHY_COMMON is not set -CONFIG_F_GMAC_PHY_AR803X=y +# CONFIG_F_GMAC_PHY_AR803X is not set # end of F_GMAC Configuration # end of Eth Configuration @@ -101,7 +101,15 @@ CONFIG_LOG_INFO=y # CONFIG_AARCH32_RAM_LD is not set CONFIG_AARCH64_RAM_LD=y # CONFIG_USER_DEFINED_LD is not set -# end of GNU Linker Setting +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0x80100000 +CONFIG_ROM_SIZE_MB=1 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0x81000000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=0x100000 +CONFIG_STACK_TOP_ADDR=0x82000000 +# end of Linker Options # end of Building Option # diff --git a/docs/Changlog.md b/docs/Changlog.md index bbf66703451279bb18dd94ce5f0d10bb5743ccfb..7d93c22a57ddd0dae2f5f38b0e0f0a449e97f853 100644 --- a/docs/Changlog.md +++ b/docs/Changlog.md @@ -3,14 +3,23 @@ * * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-02 11:09:17 - * @LastEditTime: 2021-09-24 10:10:16 + * @Date: 2021-11-02 11:40:17 + * @LastEditTime: 2021-11-02 12:10:16 * @Description:  This files is for * * @Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- --> +# Phytium FreeRTOS SDK v0.0.5 ChangeLog + +Change Log sinc 0.0.4, 2021.11.2 + +## example + +- add freertos function test examples +- change Compile environment and installation script + # Phytium FreeRTOS SDK v0.0.4 ChangeLog Change Log sinc 0.0.3, 2021.9.24 @@ -53,4 +62,4 @@ Change Log sinc init - add simple bootloader for qemu application - import freertos v10.0.1 source code -- add ft20004/e2000/qemu port code \ No newline at end of file +- add ft20004/e2000/qemu port code diff --git a/docs/reference/usr/install_linux_aarch64.md b/docs/reference/usr/install_linux_aarch64.md new file mode 100644 index 0000000000000000000000000000000000000000..04df0b150619dda4d4dce118211b3243d7906718 --- /dev/null +++ b/docs/reference/usr/install_linux_aarch64.md @@ -0,0 +1,93 @@ + + +# 1. Linux arm aarch64 SDK安装方法 + +Linux arm aarch64下通过下载SDK开发工具包完成安装,运行脚本`source ./setup_dev.sh`完成安装,安装前请先确认当前设备属于`Linux arm aarch64` + +![linux-aarch64](https://images.gitee.com/uploads/images/2021/1019/171438_af96408a_8736513.png "linux-aarch64.png") + +Linux arm aarch64安装包集成了, +- `gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf.tar.xz`和`gcc-arm-10.3-2021.07-aarch64-arm-none-eabi.tar.xz`,aarch64交叉编译链,SDK安装过程中会被解压到DEV目录的`cross_tool`目录下 +- `setup_dev.py`, 安装脚本,主要的功能包括创建sdk的profile文件,创建`PHYTIUM_DEV_PATH`环境变量,通过git拉取SDK源码,以及完成SDK安装 + + +## 1.1 获取SDK的开发环境 + +- [Linux arm aarch64](https://pan.baidu.com/s/1lQC4n8wRDSLAMTXvzPn98g) + +> 提取码:LA64 + +- Linux环境下可以用unzip命令解压 +- Linux环境下需要通过`sudo apt-get install build-essential`安装git, make和python3等工具 + +## 1.2 安装SDK开发环境 + +- (1). 解压开发环境压缩包,形成DEV目录 + +- (2). 进入DEV目录,运行`./setup_dev.py`,安装开发环境 + +![安装开发环境](https://images.gitee.com/uploads/images/2021/1101/100708_6eafde33_8736513.png "安装开发环境.png") + +- (3). 通过git拉取Phytium FreeRTOS SDK的代码,如 + +``` +git clone https://gitee.com/phytium_embedded/phytium-free-rtos-sdk.git ./phytium-free-rtos-sdk + +``` + +- (4). 进入Phytium FreeRTOS SDK代码目录,运行`./install.py` + +``` +cd ./phytium-free-rtos-sdk +./install.py +``` + +![输入图片说明](./pic/x86_install.png "x86_install.png") + +- (5). 安装完成后重启系统 + +### Q: 如果当前环境无法连接互联网 + +- 在执行第(2)步前,需要手动下载Phytium FreeRTOS SDK,放置在DEV目录下 +- https://gitee.com/phytium_embedded/phytium-free-rtos-sdk +- 需要手动下载Phytium Standalone SDK,放置在DEV的standalone目录下 +- https://gitee.com/phytium_embedded/phytium-standalone-sdk +## 1.3 检查安装是否成功 + +- 打印下列环境变量,观察各变量是否存在,指向的目录是否正确 +> `PHYTIUM_DEV_PATH`指向DEV目录 + +> `FREERTOS_SDK_ROOT`指向SDK源文件目录 + +> `AARCH32_CROSS_PATH`指向32位交叉编译链目录 + +> `AARCH64_CROSS_PATH`指向64位交叉编译链目录 + +``` +echo $PHYTIUM_DEV_PATH +echo $FREERTOS_SDK_ROOT +echo $AARCH32_CROSS_PATH +echo $AARCH64_CROSS_PATH +``` +![检查环境变量](https://images.gitee.com/uploads/images/2021/1019/181052_1ceab431_8736513.png "检查环境变量.png") + +- 环境变量打印正确无误,表示**安装成功** +## 1.4 卸载开发环境 + +- 在DEV目录运行`./uninstall.py`完成SDK卸载 + +- 运行`rm /etc/profile.d/phytium_dev.sh`,删除SDK配置文件 + +- 重启系统完成卸载 \ No newline at end of file diff --git a/docs/reference/usr/install_linux_x86_64.md b/docs/reference/usr/install_linux_x86_64.md new file mode 100644 index 0000000000000000000000000000000000000000..e5c1c9bf271522be9af5bf21b06c5e70350afd79 --- /dev/null +++ b/docs/reference/usr/install_linux_x86_64.md @@ -0,0 +1,91 @@ + + +# 1. Linux x86_64 SDK安装方法 + +Linux x86_64下通过下载SDK开发工具包完成安装,运行脚本`source ./setup_dev.sh`完成安装,安装前请先确认当前设备属于`Linux x86_64` + +![linux-x86_64](https://images.gitee.com/uploads/images/2021/1019/095533_a960e2a6_8736513.png "linux-x86_64.png") + +Linux x86_64安装包集成了, +- `gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz`和`gcc-arm-10.3-2021.07-x86_64-arm-none-eabi.tar.xz`,aarch64交叉编译链,SDK安装过程中会被解压到DEV目录的`cross_tool`目录下 +- `setup_dev.py`, 安装脚本,主要的功能包括创建sdk的profile文件,创建`PHYTIUM_DEV_PATH`环境变量,通过git拉取SDK源码,以及完成SDK安装 + +## 1.1 获取SDK的开发环境 + +- [Linux x86_64](https://pan.baidu.com/s/1KsGcHoqOJ8nv4G1G-L5gtQ) + +>提取码:LX64 + +- Linux环境下可以用unzip命令解压 +- Linux环境下需要通过`sudo apt-get install build-essential`安装git, make和python3等工具 + +## 1.2 安装SDK开发环境 + +- (1). 解压开发环境压缩包,形成DEV目录 + +![解压DEV](./pic/x86_unzip_ls.png "x86_unzip_ls.png") + +- (2). 进入DEV目录,运行`./setup_dev.py`,安装开发环境 + +![安装开发环境](./pic/x86_setup_dev.png "x86_setup_dev.png") +![安装开发环境](./pic/x86_setup_dev1.png "x86_setup_dev1.png") + +-(3). 通过git拉取Phytium FreeRTOS SDK的代码,如 + +``` +git clone https://gitee.com/phytium_embedded/phytium-free-rtos-sdk.git ./phytium-free-rtos-sdk +``` + +- (4). 进入Phytium FreeRTOS SDK代码目录,运行`./install.py` + +``` +cd ./phytium-free-rtos-sdk +./install.py +``` +![安装完成](./pic/x86_install.png "x86_install.png") + +- (3). 安装完成后重启系统 + +### Q: 如果当前环境无法连接互联网 + +- 在执行第(2)步前,需要手动下载Phytium FreeRTOS SDK,放置在DEV目录下 +- https://gitee.com/phytium_embedded/phytium-free-rtos-sdk +- 需要手动下载Phytium Standalone SDK,放置在DEV的standalone目录下 +- https://gitee.com/phytium_embedded/phytium-standalone-sdk + +## 1.3 检查安装是否成功 + +- 打印下列环境变量,观察各变量是否存在,指向的目录是否正确 +> `PHYTIUM_DEV_PATH`指向DEV目录 + +> `FREERTOS_SDK_ROOT`指向SDK源文件目录 + +> `AARCH32_CROSS_PATH`指向32位交叉编译链目录 + +> `AARCH64_CROSS_PATH`指向64位交叉编译链目录 + +``` +echo $PHYTIUM_DEV_PATH $FREERTOS_SDK_ROOT $AARCH32_CROSS_PATH $AARCH64_CROSS_PATH +``` +![检查环境变量](./pic/x86_path.png "x86_path.png") + +- 环境变量打印正确无误,表示**安装成功** +## 1.4 卸载开发环境 + +- 在DEV目录运行`./uninstall.py`完成SDK卸载 + +- 运行`rm /etc/profile.d/phytium_dev.sh`,删除SDK配置文件 + +- 重启系统完成卸载 diff --git a/docs/reference/usr/install_windows.md b/docs/reference/usr/install_windows.md new file mode 100644 index 0000000000000000000000000000000000000000..e5c29f02792314c9ffba5dd3b4b8300a68acb11c --- /dev/null +++ b/docs/reference/usr/install_windows.md @@ -0,0 +1,158 @@ + +# 1. Windows10 SDK安装方法 + +Windows 10 SDK开发环境集成了, +- `msys64`,Msys2 portable环境, 主要提供Windows上的shell命令行开发环境,包括了Cygwin (POSIX 兼容性层) 和 MinGW-w64(从"MinGW-生成") +- `setup_dev.py`, 安装脚本,主要的功能包括创建sdk的profile文件,创建`PHYTIUM_DEV_PATH`环境变量,通过git拉取SDK源码,以及完成SDK安装 +- `gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf.tar.xz`和`gcc-arm-10.3-2021.07-mingw-w64-i686-arm-none-eabi.tar.xz`, mingw64交叉编译链, SDK安装过程中会被解压到DEV目录的`cross_tool`目录下 +- `tftp`, tftp工具, 提供tftp服务,用于开发板下载二进制镜像文件,主要的功能包括安装tftp32服务和配置tftp目录 +- `run_msys2.cmd`,用于打开和配置msys2 shell的脚本,需要设置`PHYTIUM_DEV_PATH`后才能使用 +- `run_tftd.cmd`,用于打开tftpd工具的脚本,需要设置`PHYTIUM_DEV_PATH`后才能使用 +- `tftp/reinstall.cmd`, 用于安装和配置tftpd服务的脚本 +- `tftp/uninstall.cmd`, 用于卸载tftpd服务的脚本 + +## 1.1 获取SDK的开发环境 + +- [Windows10](https://pan.baidu.com/s/1V96isNcPq4F7nKi3_8GoGg) +>提取码:WX64 + +- Windows环境下可以用通用的unzip工具解压,如7zip和winrar + +## 1.2 安装SDK开发环境 + +- (1). 添加Windows环境变量,`PHYTIUM_DEV_PATH`(环境变量名**不能自定义**),例如,指向文件夹`E:\phytium-dev-windows-nt`(可以自定义) + +![配置环境变量](https://images.gitee.com/uploads/images/2021/1019/105259_18e64169_8736513.png "配置环境变量.png") + +- (2). 进入DEV目录,双击脚本`run_msys2.cmd`, 进入msys2控制台, 运行`./setup_dev.py`,注册开发环境 + +![安装开发环境](./pic/setup_dev.png "setup_dev.png") + +-(3). DEV目录注册完成后,通过git拉取Phytium FreeRTOS SDK的代码,如 + +``` +git clone https://gitee.com/phytium_embedded/phytium-free-rtos-sdk.git ./phytium-free-rtos-sdk + +``` + +- (4). 进入Phytium FreeRTOS SDK代码目录,运行`./install.py` + +``` +cd ./phytium-free-rtos-sdk +./install.py +``` + +![开发环境安装完成](./pic/install.png "install.png") + +- (5). 安装完成后重启系统 + +### Q: 如果当前环境无法连接互联网 + +- 在执行第(2)步前,需要手动下载Phytium FreeRTOS SDK,放置在DEV目录下 +- https://gitee.com/phytium_embedded/phytium-free-rtos-sdk +- 需要手动下载Phytium Standalone SDK,放置在DEV的standalone目录下 +- https://gitee.com/phytium_embedded/phytium-standalone-sdk + +![手动下载SDK](./pic/download.png "download.png") + +## 1.3 检查安装是否成功 + +- 打印下列环境变量,观察各变量是否存在,指向的目录是否正确 +> `PHYTIUM_DEV_PATH`指向DEV目录 + +> `FREERTOS_SDK_ROOT`指向SDK源文件目录 + +> `AARCH32_CROSS_PATH`指向32位交叉编译链目录 + +> `AARCH64_CROSS_PATH`指向64位交叉编译链目录 + +``` +echo $PHYTIUM_DEV_PATH $FREERTOS_SDK_ROOT $AARCH32_CROSS_PATH $AARCH64_CROSS_PATH +``` + +- 环境变量打印正确无误,表示**安装成功** +## 1.4 Windows 10安装Msys2(可选) + +- (1). 获取[Windows环境安装包](https://pan.baidu.com/s/17WX5hec7t8_ubAKzFCwQAA) + +> 提取码:MGW6 + +- msys2, `msys2-x86_64-20210725.exe` +- mingw64-arm交叉编译链, `gcc-arm-10.3-2021.07-mingw-w64-i686-arm-none-eabi.tar.xz`, `gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf.tar.xz` +- tftp工具,`tftp.zip` + +- (2). 创建Windows集成开发环境(DEV目录),如`D:/phytium-dev`, 将DEV目录添加在Windows环境变量中,变量名为`PHYTIUM_DEV_PATH`,如下图所示,保存环境变量, + +> 对于Windows 10,在桌面左下角系统搜索框中输入“环境变量”即可进入环境变量编辑界面 + +> DEV目录中不要留空格 + +![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/192453_4e609b79_8736513.png "配置环境变量.png") + +- (3). 保存DEV环境变量后,打开一个控制台,输入`echo %PHYTIUM_DEV_PATH%`,检查环境变量是否设置成功, + +![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/164646_3fbc5df8_8736513.png "检查环境变量.png") + +- (4). 双击`msys2-x86_64-20210725.exe`,设置`Msys2`的安装路径在DEV路径下,其余设置按默认安装,注意安装完成后不要马上启动,最后一步取消勾选“马上启动Msys2” + +![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/164805_4169d4d2_8736513.png "安装Msys2.png") + +![Msys2安装过程](https://images.gitee.com/uploads/images/2021/1013/135101_c8fc0454_8736513.png "Msys2安装过程.png") + +- (5). `Msys2`安装完成后,需要添加国内软件源,否则下载速度会很慢,进入`D:\phytium-dev\msys64\etc\pacman.d`目录下,找到以下三个文件,在文件末尾分别添加对应的软件源 + +- mirrorlist.mingw32 +``` +Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/i686 +``` + +- mirrorlist.mingw64 +``` +Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/x86_64 +``` + +- mirrorlist.msys +``` +Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/msys/$arch +``` + +- (6). 进入`D:\phytium-dev\msys64`目录,双击`msys2_shell.cmd`启动运行`Msys2`,输入以下命令,更新`Msys2`软件,安装必要组件 + +> 如果执行失败,可以多次尝试,直到没有报错 + +> 安装过程全部选用默认方式`default`或选择`y`,注意如果没有`default = all`,需要输入`y` + +``` +$ pacman -Syu +$ pacman -S mingw-w64-x86_64-toolchain +$ pacman -S base-devel git python3 python3-pip +``` + +![更新Msys2软件源](https://images.gitee.com/uploads/images/2021/1013/140545_6cda8ecc_8736513.png "更新Msys2软件源.png") + +- (7). 运行以下命令,检查组件是否安装完全 +``` +$ pacman -Q make git wget python3 python3-pip +``` + +## 1.5 卸载开发环境 + +- 在DEV目录下双击`run_msys2.cmd`, 启动`Msys2`控制台,在控制台输入`./uninstall.py`完成SDK卸载 + +- 在`Msys2`控制台运行`rm /etc/profile.d/phytium_dev.sh`,删除SDK配置文件 + +- 在DEV目录`D:\phytium-dev\tftp`下以**管理员权限**打开Windows命令行中断,运行`uninstall.cmd`完成Tftd卸载 + +- 重启系统完成卸载 \ No newline at end of file diff --git a/docs/reference/usr/pic/download.png b/docs/reference/usr/pic/download.png new file mode 100644 index 0000000000000000000000000000000000000000..281696ad8bb7888b4958f64b868e819767f1d47f Binary files /dev/null and b/docs/reference/usr/pic/download.png differ diff --git a/docs/reference/usr/pic/install.png b/docs/reference/usr/pic/install.png new file mode 100644 index 0000000000000000000000000000000000000000..5efa2cbd0c7cca0cbce102001641081a2594a10f Binary files /dev/null and b/docs/reference/usr/pic/install.png differ diff --git a/docs/reference/usr/pic/setup_dev.png b/docs/reference/usr/pic/setup_dev.png new file mode 100644 index 0000000000000000000000000000000000000000..24fb336a0171d5bea1c3cafc29bf40d91cbc9874 Binary files /dev/null and b/docs/reference/usr/pic/setup_dev.png differ diff --git a/docs/reference/usr/pic/usage_config.png b/docs/reference/usr/pic/usage_config.png new file mode 100644 index 0000000000000000000000000000000000000000..51fb29ac708f8296a38895b8e2fc2182f02ab642 Binary files /dev/null and b/docs/reference/usr/pic/usage_config.png differ diff --git a/docs/reference/usr/pic/usage_hello.png b/docs/reference/usr/pic/usage_hello.png new file mode 100644 index 0000000000000000000000000000000000000000..663c2579da0f4426475334acba5710b251f114e9 Binary files /dev/null and b/docs/reference/usr/pic/usage_hello.png differ diff --git a/docs/reference/usr/pic/usage_make.png b/docs/reference/usr/pic/usage_make.png new file mode 100644 index 0000000000000000000000000000000000000000..00626a9d098c039d934cd6f6280ca5f1b2d464ce Binary files /dev/null and b/docs/reference/usr/pic/usage_make.png differ diff --git a/docs/reference/usr/pic/x86_install.png b/docs/reference/usr/pic/x86_install.png new file mode 100644 index 0000000000000000000000000000000000000000..500d2d816ea3dd6ad7a115aa1bc23379e75a6c82 Binary files /dev/null and b/docs/reference/usr/pic/x86_install.png differ diff --git a/docs/reference/usr/pic/x86_path.png b/docs/reference/usr/pic/x86_path.png new file mode 100644 index 0000000000000000000000000000000000000000..b96c510a02a6ada6a98df339da55ed18e078dfb2 Binary files /dev/null and b/docs/reference/usr/pic/x86_path.png differ diff --git a/docs/reference/usr/pic/x86_setup_dev.png b/docs/reference/usr/pic/x86_setup_dev.png new file mode 100644 index 0000000000000000000000000000000000000000..a06fa12450ef555fc165b24629fd1cd2979e2cde Binary files /dev/null and b/docs/reference/usr/pic/x86_setup_dev.png differ diff --git a/docs/reference/usr/pic/x86_setup_dev1.png b/docs/reference/usr/pic/x86_setup_dev1.png new file mode 100644 index 0000000000000000000000000000000000000000..70a76619b81ea7701d14de9dd105ca712cca3c22 Binary files /dev/null and b/docs/reference/usr/pic/x86_setup_dev1.png differ diff --git a/docs/reference/usr/pic/x86_unzip_ls.png b/docs/reference/usr/pic/x86_unzip_ls.png new file mode 100644 index 0000000000000000000000000000000000000000..e9327fc7f0435c9bdcfbabfd35ffddfe4cd1fdfc Binary files /dev/null and b/docs/reference/usr/pic/x86_unzip_ls.png differ diff --git a/docs/reference/usr/usage.md b/docs/reference/usr/usage.md new file mode 100644 index 0000000000000000000000000000000000000000..0be6754aa259bb1cd2833d4ec3e220de32a1d145 --- /dev/null +++ b/docs/reference/usr/usage.md @@ -0,0 +1,193 @@ + + +# 1. 使用方法 + +## 1.1 新建一个 freertos 应用工程 + +### 1.1.1 选择工程模板 + +- 复制`~/free-rtos-sdk/example/template`目录,作为 freertos 应用工程 + +> `*` 表示可选文件/目录 + +``` +$ ls +Kconfig --> 应用工程配置menu文件 +makefile --> makefile +main.c --> 包含main函数 +sdkconfig --> 配置输出 +sdkconfig.h --> 配置输出 +inc --> 用户头文件* +src --> 用户源文件* +``` + +>请注意使用小写makefile,使用Makefile在部分平台不能被识别 + +### 1.1.2 选择目标平台 + +- 切换目标平台, e.g `FT2000/4 AARCH32`, 加载默认配置 + +``` +make config_ft2004_aarch32 +``` + +> 使用`FT2000-4`作为目标编译平台,通过`make config_ft2004_aarch32`和`make config_ft2004_aarch64`加载默认配置 + +> 使用`D2000`作为目标编译平台,通过`make config_d2000_aarch32`和`make config_d2000_aarch64`加载默认配置 + +- 编译应用工程, 生成`*.bin`文件用于下载到开发板 + +``` +$ make +$ ls +template.bin --> 二进制文件 +template.dis --> 反汇编文件 +template.elf --> ELF文件 +template.map --> 内存布局文件 +``` + +![输入图片说明](./pic/usage_config.png "usage_config.png") + +## 1.2 快速使用例程 + +> ~/free-rtos-sdk/example/hello_world + +![输入图片说明](./pic/usage_hello.png "usage_hello.png") + +## 1.3 下载镜像跳转启动 + +### 1.3.1 在 host 侧(Ubuntu 20.04)配置 tftp 服务 + +- 在开发环境`host`侧安装`tftp`服务 + +``` +sudo apt-get install tftp-hpa tftpd-hpa +sudo apt-get install xinetd +``` + +- 新建 tftboot 目录, `/mnt/d/tftboot`, 确保 tftboot 目录有执行权限`chmod 777 /**/tftboot` + +- 配置主机 tftpboot 服务, 新建并配置文件`/etc/xinetd.d/tftp` + +``` +# /etc/xinetd.d/tftp + +server tftp +{ + socket_type = dgram + protocol = udp + wait = yes + user = root + server = /usr/sbin/in.tftpd + server_args = -s /mnt/d/tftboot + disable = no + per_source = 11 + cps = 100 2 + flags = IPv4 +} +``` + +- 启动主机`tftp`服务,生成默认配置 + +``` +$ sudo service tftpd-hpa start +``` + +- 修改主机`tftp`配置,指向`tftboot`目录 + 修改/etc/default/tftpd-hpa + +``` +$ sudo nano /etc/default/tftpd-hpa +# /etc/default/tftpd-hpa + +TFTP_USERNAME="tftp" +TFTP_DIRECTORY="/mnt/d/tftboot" +TFTP_ADDRESS=":69" +TFTP_OPTIONS="-l -c -s" +``` + +- 重启主机`tftp`服务 + +``` +$ sudo service tftpd-hpa restart +``` + +- 测试主机`tftp`服务的可用性 + > 登录`tftp`服务,获取`tftboot`目录下的一个文件 + +``` +$ tftp 192.168.4.50 +tftp> get test1234 +tftp> q +``` + +### 1.3.2 在 host 侧(Windows)配置 tftp 服务 + +- 将2.1.1章下载的`tftp.zip`解压到开发环境,如`D:\phytium-dev\tftp` +- 以**管理员权限**打开Windows cmd,进入`D:\phytium-dev\tftp`,运行`.\reinstall.cmd`完成Tftpd服务安装 + +![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/193051_97e9949e_8736513.png "管理员权限打开.png") + +![输入图片说明](https://images.gitee.com/uploads/images/2021/1014/111121_2be64492_8736513.png "屏幕截图.png") + +- 之后每次使用前,进入Windows服务,手动将一下服务打开 + +![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/152422_b398ef37_8736513.png "启动tftpd服务.png") + +- 进入SDK,双击`D:\phytium-dev\phytium-free-rtos-sdk`目录下的`run_tftd.cmd`,启动tftp工具,设置tftp目录和ip + +![输入图片说明](https://images.gitee.com/uploads/images/2021/1013/152524_2db6cb31_8736513.png "tftpd配置工具.png") + +- 将镜像文件放置在上图所示的`%PHYTIUM_IDE_PATH%\tftp`目录下,开发板即可通过`tftpboot`加载镜像 + +> 在`template_mingw64`工程中,通过定义`USR_BOOT_DIR`可以将编译的镜像自动拷贝带tftp目录下 + +### 1.3.3 配置开发板 ip,连通 host 下载启动镜像 + +- 将`BIN`文件或者`ELF`文件复制到`tftpboot`目录 + +``` +$ cp ./freertos.bin /mnt/d/tftboot +``` + +``` +$ cp ./freertos.elf /mnt/d/tftboot +``` + +- 连通开发板串口,进入`u-boot`界面,配置开发板`ip`,`host`侧`ip`和网关地址 + +``` +# setenv ipaddr 192.168.4.20 +# setenv serverip 192.168.4.50 +# setenv gatewayip 192.168.4.1 +``` + +> 镜像启动的地址为`0x80100000`, 对于`BIN`文件,需要直接加载到`0x80100000`,对于`ELF`文件,启动地址会自动获取,需要加载到`DRAM`中一段可用的地址,这里选择`0x90100000` + +- 支持使用以下几种方式跳转启动 +- 1. `AARCH32/AARCH64`支持加载`BIN`文件到启动地址,刷新缓存后,通过`go`命令跳转启动 + +``` +# tftpboot 0x80100000 freertos.bin +# dcache flush +# go 0x80100000 +``` + +- 2. `AARCH32/AARCH64`支持加载`ELF`文件到`DRAM`,通过`bootelf`解析跳转启动 + +``` +# tftpboot 0x90100000 freertos.elf +# bootelf -p 0x90100000 +``` \ No newline at end of file diff --git a/example/Makefile b/example/Makefile deleted file mode 100644 index e96a58060618dfb7dea7e05877cddee1bae7dcc5..0000000000000000000000000000000000000000 --- a/example/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# Compiling all examples -TOPTARGETS := all clean - -#SUBDIRS := $(wildcard */.) -SUBDIRS := function_test \ - hello_world \ - start_up \ - buffer \ - template - -$(TOPTARGETS): $(SUBDIRS) - @for i in $(SUBDIRS); do \ - echo -e "\033[44;37;1m +++ Compiling $$i...\033[0m"; \ - $(MAKE) -C $$i $(MAKECMDGOALS) > /dev/null || exit $$?; \ - echo -e "\033[44;37;1m +++ Compiled OK $$i...\033[0m"; \ - done - -.PHONY: $(TOPTARGETS) $(SUBDIRS) \ No newline at end of file diff --git a/example/freertos_test/Kconfig b/example/freertos_test/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..2a4d9f32a52224720d7dc80c9a6c2a3a3c762489 --- /dev/null +++ b/example/freertos_test/Kconfig @@ -0,0 +1,25 @@ +mainmenu "Phytium FreeRTOS Configuration" + + menu "Project Configuration" + + config TARGET_NAME + string "Build Target Name" + default "baremetal" + help + Build Target name for the demo + choice LWIP_TEST_ITEMS + prompt "Select Test Item" + default LWIP_POLL_TEST + help + Select arch for build + + config LWIP_POLL_TEST + bool "Poll Wait" + + config LWIP_INTRRUPT_TEST + bool "Poll Intrrupt" + + endchoice #LWIP_TEST_ITEMS + endmenu + +source "$(FREERTOS_SDK_ROOT)/Kconfig" diff --git a/example/freertos_test/README.md b/example/freertos_test/README.md new file mode 100644 index 0000000000000000000000000000000000000000..557c184eed7a3c1724d305354ce07dd59d24bb4a --- /dev/null +++ b/example/freertos_test/README.md @@ -0,0 +1,127 @@ + +# function test base on freertos + +## 1. 例程介绍 + +本例程示范了freertos环境下的功能性能测试。 +主要包括中断中的浮点计算,任务优先级,静态任务、定时器、队列、信号量的创建,任务状态追踪获取,绝对延时,钩子函数,流式缓冲测试等。 + +## 2. 如何使用例程 + +本例程需要用到 +- Phytium开发板(FT2000-4/D2000) +- [Phytium freeRTOS SDK](https://gitee.com/phytium_embedded/phytium-free-rtos-sdk) +- [Phytium standalone SDK](https://gitee.com/phytium_embedded/phytium-standalone-sdk) + +### 2.1 硬件配置方法 + +本例程支持的硬件平台包括 + +- FT2000-4 +- D2000 + +对应的配置项是, + +- CONFIG_TARGET_F2000_4 +- CONFIG_TARGET_D2000 + +### 2.2 SDK配置方法 + +由于使用到了看门狗中断配合进行测试,本例程需要 + +- 使能wdt模块 + +对应的配置项是, + +- Use FWDT + +具体的测试项见main.c的宏定义,可根据具体的测试需求修改宏定义的值,以下对测试项宏的具体含义进行简单说明 +``` +ISR_FLOAT_TEST----测试中断处理函数中的浮点数计算 +BACKPORT_TEST----静态内存分配API的测试,xTaskCreateStatic等函数 +DEBUG_QUEUE_REGISTER_TEST----队列queue registry测试 +EVENT_GROUPS_TEST----事件组event_groups测试 +TASK_GET_STATE_TEST----获取任务运行状态测试 +MUTEX_TEST----互斥信号量测试 +SCHEDULING_TIME_TEST----调度时间测试 +TASK_DELAY_UNTIL_TEST----绝对延时测试 +DELETE_TASK_TEST----任务删除测试 +TASK_NOTIFY_TEST----任务通知测试 +TRACE_FACILITY_TEST----任务状态追踪测试 +ISR_LATENCY_TEST----中断延时测试 +HOOK_TEST----钩子函数测试 +NEWLIB_REENT_TEST----函数重入测试 +PANIC_TEST----cpu报错测试 +QUEUE_SET_GET_TEST----队列发送接收测试 +STREAM_TEST----流缓存区测试 +PRIORITY_TEST----任务优先级测试 +THREAD_LOCAL_TEST----线程局部存储thread local storage测试 +TIMER_TEST----定时器测试 +``` +### 2.3 构建和下载 + +#### 2.3.1 构建过程 + +- 在host侧完成配置 +>配置成D2000,对于其它平台,使用对于的默认配置,如FT2000-4 `make config_ft2004_configs` +``` +$ make config_d2000_configs +$ make menuconfig +``` + +- 在host侧完成构建 +``` +$ make +``` + +#### 2.3.2 下载过程 + +- host侧设置重启host侧tftp服务器 +``` +sudo service tftpd-hpa restart +``` + +- 开发板侧使用bootelf命令跳转 +``` +setenv ipaddr 192.168.4.20 +setenv serverip 192.168.4.50 +setenv gatewayip 192.168.4.1 +tftpboot 0x90100000 freertos.elf +bootelf -p 0x90100000 +``` + +### 2.4 输出与实验现象 + +- 启动进入后,cpu运行所有的测试任务,打印任务运行信息 + +![freertos_test打印](./pic/freertos_test.png "freertos_test.png") + + +## 3. 如何解决问题 + +Q: 程序运行过程中报exception错误 + +A: 考虑以下任务创建时分配的栈空间大小和优先级设置 + +Q: 程序运行过程中优先级报错 + +A: 考虑任务创建时的优先级设置是否过大 + + +## 4. 修改历史记录 + +v0.0.5 合入freertos_test测试 + + diff --git a/example/freertos_test/float_in_isr.c b/example/freertos_test/float_in_isr.c new file mode 100644 index 0000000000000000000000000000000000000000..a1ec04b8689eb4f0814646da0bf926ca62bcf6c1 --- /dev/null +++ b/example/freertos_test/float_in_isr.c @@ -0,0 +1,89 @@ +/* + * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * + * SPDX-License-Identifier: Apache-2.0. + * + * @Date: 2021-07-05 10:28:22 + * @LastEditTime: 2021-07-22 09:05:53 + * @Description:  This files is for + * + * @Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "timers.h" +#include "math.h" + +/* ---------------------Test 1: Backported Timer functions----------------------- + * Test xTimerCreateStatic(), vTimerSetTimerId(), xTimerGetPeriod(), xTimerGetExpiryTime() + * + * This test creates a one-shot static timer, sets/checks the timer's id and period. Then ensures + * the timer cb is executed in a timely fashion. + */ + +#define TMR_PERIOD_TICKS 1000 +#define TIMER_ID 0xFF +#define TICK_DELTA 5 + +static TaskHandle_t appTaskCreateHand = NULL; +static StaticTimer_t timer_buffer; +static TickType_t tmr_ideal_exp; + +static void TimerHandler(TimerHandle_t xtimer) +{ + static float expected = 0.5f; + /*Check cb is called in timely fashion*/ + printf("isr xTaskGetTickCount()=%d\n", xTaskGetTickCount()); + + expected = expected * 1.002f * cosf(0.0f); + + printf("isr expected=%f\n", expected); +} + +void TestFloatInIsr(void) +{ + /*进入临界区*/ + taskENTER_CRITICAL(); + + TimerHandle_t tmr_handle = xTimerCreateStatic("static_tmr", TMR_PERIOD_TICKS, pdTRUE, NULL, TimerHandler, &timer_buffer); + + printf("xTimerGetPeriod=%d\n",xTimerGetPeriod(tmr_handle)); + + vTimerSetTimerID(tmr_handle, (void *)TIMER_ID); + + /*Start Timer*/ + xTimerStart(tmr_handle, 1); + + /*Calculate ideal expiration time*/ + tmr_ideal_exp = xTaskGetTickCount() + TMR_PERIOD_TICKS; + + /*Need to yield to allow daemon task to process start command, or else expiration time will be NULL*/ + vTaskDelay(2); + + printf("xTimerGetExpiryTime(tmr_handle)=%d\n", xTimerGetExpiryTime(tmr_handle)); + + vTaskDelete(appTaskCreateHand); + + taskEXIT_CRITICAL(); + +} + +BaseType_t TestFloatIsrEntry(void) +{ + BaseType_t ret = pdPASS;/* 定义一个创建信息返回值,默认为 pdPASS */ + + ret = xTaskCreate((TaskFunction_t )TestFloatInIsr, /* 任务入口函数 */ + (const char* )"FloatTaskCreate",/* 任务名字 */ + (uint16_t )512, /* 任务栈大小 */ + (void* )NULL,/* 任务入口函数参数 */ + (UBaseType_t )1, /* 任务的优先级 */ + (TaskHandle_t* )&appTaskCreateHand); /* 任务控制 */ + + return ret; +} \ No newline at end of file diff --git a/example/freertos_test/freertos_backported_functions.c b/example/freertos_test/freertos_backported_functions.c new file mode 100644 index 0000000000000000000000000000000000000000..5362ed2b5fd736e814d201fdbc390e06b77b142c --- /dev/null +++ b/example/freertos_test/freertos_backported_functions.c @@ -0,0 +1,252 @@ +/* + * Test features that are backported from version FreeRTOS 9.0.0. + * + * 1) Test backported timer functions + * - xTimerCreateStatic(), vTimerSetTimerId(), xTimerGetPeriod(), xTimerGetExpiryTime() + * 2) Test backported queue/semaphore functions + * - xQueueCreateStatic() + * - xSemaphoreCreateBinaryStatic(), xSemaphoreCreateCountingStatic(), uxSemaphoreGetCount() + * - xSemaphoreCreateMutexStatic(), xSemaphoreCreateRecursiveMutexStatic() + * 3) Test static allocation of tasks + * - xTaskCreateStaticPinnedToCore() + * 4) Test static allocation of event group + * - xEventGroupCreateStatic() + * 5) Test Thread Local Storage Pointers and Deletion Callbacks + * - vTaskSetThreadLocalStoragePointerAndDelCallback() + * - pvTaskGetThreadLocalStoragePointer() + * + * Note: The *pcQueueGetName() function is also backported, but is not tested in + * the following test cases (see Queue Registry test cases instead) + */ +#include +#include "FreeRTOS.h" +#include "task.h" +#include "timers.h" +#include "queue.h" +#include "semphr.h" +#include "event_groups.h" +#include "ft_assert.h" + +/* ---------------------Test 1: Backported Timer functions----------------------- + * Test xTimerCreateStatic(), vTimerSetTimerId(), xTimerGetPeriod(), xTimerGetExpiryTime() + * + * This test creates a one-shot static timer, sets/checks the timer's id and period. Then ensures + * the timer cb is executed in a timely fashion. + */ +#define TMR_PERIOD_TICKS 1000 +#define TIMER_ID 0xFF +#define TICK_DELTA 5 + +static StaticTimer_t timer_buffer; +static TickType_t tmr_ideal_exp; + +static void TimerCallback(TimerHandle_t xtimer) +{ + /*Check cb is called in timely fashion*/ + printf("xTaskGetTickCount()=%d\n", xTaskGetTickCount()); +} + +void TimerFuncTest(void) +{ + /*进入临界区*/ + taskENTER_CRITICAL(); + /*Create one shot static timer with period TMR_PERIOD_TICKS*/ + TimerHandle_t tmr_handle = xTimerCreateStatic("static_tmr", TMR_PERIOD_TICKS, pdTRUE, NULL, TimerCallback, &timer_buffer); + printf("xTimerGetPeriod(tmr_handle)=%d\n", xTimerGetPeriod(tmr_handle)); + + vTimerSetTimerID(tmr_handle, (void *)TIMER_ID); + printf("pvTimerGetTimerID(tmr_handle)=%d\n", pvTimerGetTimerID(tmr_handle)); + + /*Start Timer*/ + xTimerStart(tmr_handle, 1); + + /*Calculate ideal expiration time*/ + tmr_ideal_exp = xTaskGetTickCount() + TMR_PERIOD_TICKS; + + /*Need to yield to allow daemon task to process start command, or else expiration time will be NULL*/ + vTaskDelay(2); + + printf("xTimerGetExpiryTime(tmr_handle)=%d\n", xTimerGetExpiryTime(tmr_handle)); + /*Delay until one shot timer has triggered*/ + vTaskDelay(2*TMR_PERIOD_TICKS); + + vTaskDelete(NULL); + /*退出临界区*/ + taskEXIT_CRITICAL(); + + while(1) + { + vTaskDelay(200); + } + +} + + +/* ---------------Test backported queue/semaphore functions------------------- + * xQueueCreateStatic() + * xSemaphoreCreateBinaryStatic(), xSemaphoreCreateCountingStatic() + * xSemaphoreCreateMutexStatic(), xSemaphoreCreateRecursiveMutexStatic() + * uxSemaphoreGetCount() is also tested on the static counting semaphore + * + * This test creates various static queue/semphrs listed above and tests them by + * doing a simple send/give and rec/take. + */ + +#define ITEM_SIZE 3 +#define NO_OF_ITEMS 3 +#define DELAY_TICKS 2 +/*Queues, Semaphores, and Mutex use the same queue structure*/ +static StaticQueue_t queue_buffer; +/*Queue storage provided in separate buffer to queue struct*/ +static u8 queue_storage_area[(ITEM_SIZE*NO_OF_ITEMS)]; + +void QueueFuncTest(void) +{ + /*Test static queue*/ + uint8_t queue_item_to_send[ITEM_SIZE]; + uint8_t queue_item_received[ITEM_SIZE]; + int i = 0; + + for(i = 0; i < ITEM_SIZE; i++) + { + queue_item_to_send[i] = (0xF << i); + } + + QueueHandle_t handle = xQueueCreateStatic(NO_OF_ITEMS, ITEM_SIZE,(uint8_t*) &queue_storage_area, &queue_buffer); + + FT_ASSERTVOID(pdTRUE==xQueueSendToBack(handle, &queue_item_to_send, DELAY_TICKS)); + vTaskDelay(1); + + FT_ASSERTVOID(pdTRUE==xQueueReceive(handle, queue_item_received, DELAY_TICKS)); + vTaskDelay(1); + + for(i = 0; i < ITEM_SIZE; i++) + { + /*Check received contents are correct*/ + FT_ASSERTVOID(queue_item_to_send[i]==queue_item_received[i]); + } + + /*Technically not needed as deleting static queue/semphr doesn't clear static memory*/ + vQueueDelete(handle); + + /*Test static binary semaphore*/ + handle = xSemaphoreCreateBinaryStatic(&queue_buffer); + + /*Queue and Semphr handles are the same*/ + FT_ASSERTVOID(pdTRUE==xSemaphoreGive(handle)); + vTaskDelay(1); + + FT_ASSERTVOID(pdTRUE==xSemaphoreTake(handle, DELAY_TICKS)); + vTaskDelay(1); + + vSemaphoreDelete(handle); + + /*Test static counting semaphore and uxSemaphoreGetCount()*/ + handle = xSemaphoreCreateCountingStatic(NO_OF_ITEMS, 0, &queue_buffer); + for(i = 0; i < NO_OF_ITEMS; i++) + { + FT_ASSERTVOID(pdTRUE==xSemaphoreGive(handle)); + } + vTaskDelay(1); + /*Test uxSemaphoreGetCount()*/ + FT_ASSERTVOID(NO_OF_ITEMS== uxSemaphoreGetCount(handle)); + for(i = 0; i < NO_OF_ITEMS; i++) + { + FT_ASSERTVOID(pdTRUE==xSemaphoreTake(handle, DELAY_TICKS)); + } + vTaskDelay(1); + FT_ASSERTVOID(0==uxSemaphoreGetCount(handle)); + vSemaphoreDelete(handle); + + /*Test static mutex*/ + handle = xSemaphoreCreateMutexStatic(&queue_buffer); + FT_ASSERTVOID(pdTRUE==xSemaphoreTake(handle, DELAY_TICKS)); + vTaskDelay(1); + + /*Current task should now hold mutex*/ + FT_ASSERTVOID(((void *)xTaskGetCurrentTaskHandle()) == xSemaphoreGetMutexHolder(handle)); + FT_ASSERTVOID(pdTRUE==xSemaphoreGive(handle)); + vTaskDelay(1); + /*Mutex should have been released*/ + FT_ASSERTVOID(NULL==xSemaphoreGetMutexHolder(handle)); + vSemaphoreDelete(handle); + + /*Test static mutex recursive*/ + handle = xSemaphoreCreateRecursiveMutexStatic(&queue_buffer); + for(i = 0; i < NO_OF_ITEMS; i++) + { + FT_ASSERTVOID(pdTRUE==xSemaphoreTakeRecursive(handle, DELAY_TICKS)); + } + vTaskDelay(1); + /*Current task should hold mutex*/ + FT_ASSERTVOID(((void *)xTaskGetCurrentTaskHandle())==xSemaphoreGetMutexHolder(handle)); + for(i = 0; i < NO_OF_ITEMS; i++) + { + FT_ASSERTVOID(pdTRUE==xSemaphoreGiveRecursive(handle)); + } + vTaskDelay(1); + /*Mutex should have been released*/ + FT_ASSERTVOID(NULL==xSemaphoreGetMutexHolder(handle)); + vSemaphoreDelete(handle); + + while(1) + { + vTaskDelay(200); + } + +} + +/* -----------------Test backported static task allocation ------------------- + * Test xTaskCreateStaticPinnedToCore() but creating static task on each core + * and checking the task cb has run successfully. + */ + +#define STACK_SIZE 1024 /*Task stack size*/ +static StackType_t task_stack[STACK_SIZE]; /*Static buffer for task stack*/ +static StaticTask_t task_buffer; /*Static buffer for TCB*/ +static u8 has_run; + +static void Task(void *arg) +{ + has_run = TRUE; /*Signify static task cb has run*/ + vTaskDelete(NULL); +} + +void StaticTaskCreateTest(void) +{ + has_run = FALSE; /*Clear has_run flag*/ + + TaskHandle_t handle = xTaskCreateStatic(Task, "static task", STACK_SIZE, NULL, + 3, (StackType_t *)&task_stack, + (StaticTask_t *)&task_buffer); + + vTaskDelay(5); /*Allow for static task to run, delete, and idle to clean up*/ + + FT_ASSERTVOID(NULL!= handle); /*Check static task was successfully allocated*/ + FT_ASSERTVOID(has_run); /*Check static task has run*/ + + while(1) + { + vTaskDelay(200); + } +} + + +/* ------------- Test backported static event group allocation ------------------- + * Test xEventGroupCreateStatic() but creating static event group then waiting + * for an event. + */ + +#define WAIT_BITS 0x01 /*Wait for first bit*/ + +static StaticEventGroup_t event_group; +static EventGroupHandle_t eg_handle; + +void StaticEventGroupTest(void) +{ + eg_handle = xEventGroupCreateStatic((StaticEventGroup_t *)&event_group); + xEventGroupSetBits(eg_handle, WAIT_BITS); + FT_ASSERTVOID(WAIT_BITS==xEventGroupWaitBits(eg_handle, WAIT_BITS, pdTRUE, pdTRUE, portMAX_DELAY)); + /*Cleanup static event*/ + vEventGroupDelete(eg_handle); +} diff --git a/example/freertos_test/freertos_debug_functions.c b/example/freertos_test/freertos_debug_functions.c new file mode 100644 index 0000000000000000000000000000000000000000..9dda1ee7ecf48f064ffbcb8993f4ee48555ad9d5 --- /dev/null +++ b/example/freertos_test/freertos_debug_functions.c @@ -0,0 +1,119 @@ +/* + * Test FreeRTOS debug functions and utilities. + * - Queue registry functions vQueueAddToRegistry(), vQueueUnregisterQueue(), + * and pcQueueGetName(backported) + * + * + */ +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "queue.h" +#include "unity.h" + +#define NO_OF_QUEUES_ON_CORE 2 /*Save space for some preallocated tasks*/ +#define NO_OF_QUEUES_TOTAL NO_OF_QUEUES_ON_CORE +#define QUEUE_NAME_MAX_LENGTH 30 + +static SemaphoreHandle_t start_sem; +static SemaphoreHandle_t done_sem = NULL; +static char *names[NO_OF_QUEUES_TOTAL]; +static QueueHandle_t handles[NO_OF_QUEUES_TOTAL]; + +void TestQueueRegistryTask(void *arg) +{ + int i = 0; + /*Create queues and accompanying queue names*/ + for(i = 0; i < NO_OF_QUEUES_ON_CORE; i++) + { + handles[i] = xQueueCreate(1,1); /*Create queues*/ + names[i] = calloc(QUEUE_NAME_MAX_LENGTH, sizeof(char)); + sprintf(names[i], "Queue%d", i); + } + + xSemaphoreTake(start_sem, portMAX_DELAY); /*Wait for start vQueueAddToRegistry()*/ + for(i = 0; i < NO_OF_QUEUES_ON_CORE; i++) + { + vQueueAddToRegistry(handles[i] , names[i]); /*Register queues to queue registry*/ + } + xSemaphoreGive(done_sem); /*Signal that vQueueAddToRegistry() has completed*/ + + vTaskDelay(1); + + xSemaphoreTake(start_sem, portMAX_DELAY); /*Wait to start vQueueUnregisterQueue()*/ + for(i = 0; i < NO_OF_QUEUES_ON_CORE; i++) + { + vQueueDelete(handles[i]); /*Internally calls vQueueUnregisterQueue*/ + } + xSemaphoreGive(done_sem); /*Signal done*/ + + vTaskDelete(NULL); /*Delete self*/ +} + +void QueueRegistryDebugTest(void) +{ + int i = 0; + /*Create synchronization semaphores and tasks to test queue registry*/ + done_sem = xSemaphoreCreateCounting(1, 0); + if(done_sem == NULL) + { + printf("xSemaphoreCreateCounting failed\n"); + return; + } + + start_sem = xSemaphoreCreateBinary(); + if(start_sem == NULL) + { + printf("xSemaphoreCreateBinary failed\n"); + return; + } + + xTaskCreate(TestQueueRegistryTask, "testing task", 4096, NULL, 1, NULL); + + portDISABLE_INTERRUPTS(); + xSemaphoreGive(start_sem); /*Trigger start*/ + + portENABLE_INTERRUPTS(); + xSemaphoreTake(done_sem, portMAX_DELAY); /*Wait for tasks to complete vQueueAddToRegistry*/ + + for(i = 0; i < NO_OF_QUEUES_TOTAL; i++) + { + const char *addr = pcQueueGetName(handles[i]); + + TEST_ASSERT(addr == names[i]); /*Check vQueueAddToRegistry was successful*/ + } + + portDISABLE_INTERRUPTS(); + xSemaphoreGive(start_sem); /*Trigger start*/ + + portENABLE_INTERRUPTS(); + xSemaphoreTake(done_sem, portMAX_DELAY); /*Wait for tasks to complete vQueueUnregisterQueue*/ + + for(i = 0; i < NO_OF_QUEUES_TOTAL; i++) + { + const char *addr = pcQueueGetName(handles[i]); + TEST_ASSERT(addr == NULL); /*Check vQueueUnregisterQueue was successful*/ + handles[i] = NULL; + } + + /*Cleanup*/ + for(i = 0; i < NO_OF_QUEUES_TOTAL; i++) + { + free(names[i]); + names[i] = NULL; + } + + vSemaphoreDelete(start_sem); + start_sem = NULL; + + vSemaphoreDelete(done_sem); + done_sem = NULL; + + while(1) + { + vTaskDelay(200); + } + +} diff --git a/example/freertos_test/freertos_eventgroups.c b/example/freertos_test/freertos_eventgroups.c new file mode 100644 index 0000000000000000000000000000000000000000..c495abf89c36be42bf9985d1c27da61e917e9699 --- /dev/null +++ b/example/freertos_test/freertos_eventgroups.c @@ -0,0 +1,204 @@ +#include + +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "queue.h" +#include "event_groups.h" +#include "timers.h" +#include "ft_debug.h" +#include "unity.h" +#include "interrupt.h" +#include "gicv3.h" +#include "parameters.h" +#include "fwdt.h" +#include "fwdt_hw.h" + +static const int NUM_TASKS = 8; +static const int COUNT = 1000; +static EventGroupHandle_t eg; +static SemaphoreHandle_t done_sem; + +#define BIT_CALL (1 << 0) +#define BIT_RESPONSE(TASK) (1 << (TASK+1)) +#define ALL_RESPONSE_BITS (((1 << NUM_TASKS) - 1) << 1) + +static void TaskEventGroupResponse(void *param) +{ + TEST_ASSERT(param != NULL); + int task_num = *(intptr*)param; + int i = 0; + + for (i = 0; i < COUNT; i++) + { + /* Wait until the common "call" bit is set, starts off all tasks + (clear on return) */ + TEST_ASSERT( xEventGroupWaitBits(eg, BIT_CALL, TRUE, FALSE, portMAX_DELAY) ); + /* Set our individual "response" bit */ + xEventGroupSetBits(eg, BIT_RESPONSE(task_num)); + vTaskDelay(10); + } + xSemaphoreGive(done_sem); + vTaskDelete(NULL); +} + +void EventGroupsTest(void) +{ + int i = 0; + eg = xEventGroupCreate(); + done_sem = xSemaphoreCreateCounting(NUM_TASKS, 0); + + /* Note: task_event_group_call_response all have higher priority than this task, so on this core + they will always preempt this task. + This is important because we need to know all tasks have blocked on BIT_CALL each time we signal it, + or they get out of sync. + */ + for (i = 0; i < NUM_TASKS; i++) + { + xTaskCreate(TaskEventGroupResponse, "tsk_call_resp", 4096, (void *)&i, UNITY_FREERTOS_PRIORITY - 1, NULL); + } + + /* Tasks all start instantly, but this task will resume running at the same time as the higher priority tasks on the + other processor may still be setting up, so allow time for them to also block on BIT_CALL... */ + vTaskDelay(10); + + for (i = 0; i < COUNT; i++) + { + /* signal all tasks with "CALL" bit... */ + xEventGroupSetBits(eg, BIT_CALL); + + /* Only wait for 1 tick, the wakeup should be immediate... */ + TEST_ASSERT_EQUAL_HEX16(ALL_RESPONSE_BITS, xEventGroupWaitBits(eg, ALL_RESPONSE_BITS, TRUE, TRUE, 1)); + vTaskDelay(10); + } + + /* Ensure all tasks cleaned up correctly */ + for (i = 0; i < NUM_TASKS; i++) + { + TEST_ASSERT( xSemaphoreTake(done_sem, 100/portTICK_PERIOD_MS) ); + } + + vSemaphoreDelete(done_sem); + vEventGroupDelete(eg); + printf("--------------------------------------------------------\n"); + while (1) + { + vTaskDelay(200); + } +} + + +/*-----------------Test case for event group trace facilities-----------------*/ +/* + * Test event group Trace Facility functions such as + * xEventGroupClearBitsFromISR(), xEventGroupSetBitsFromISR() + */ + +//Use a wdt to trigger an ISr +#define BITS 0xAA + +static bool test_set_bits; +static bool test_clear_bits; +static FWdtCtrl wdt_ctrl; +/* wdt num: 0 or 1 */ +static u8 wdt_id = 0; + +/** + * @name: WdtInterrupt + * @msg: This function handle wdt timeout interrupt, use it to refresh wdt. + * @return {void} + * @param {s32} vector, the interrupt number + * @param {void} *param, pointer to a WdtCtrl structure that contains + * the configuration information for the specified wdt module. + */ +static void FWdtInterrupt(s32 vector, void *param) +{ + FWdtRefresh((FWdtCtrl *)param); + printf("FWdtInterrupt\n"); + + portBASE_TYPE task_woken = pdFALSE; + + if(test_set_bits) + { + xEventGroupSetBitsFromISR(eg, BITS, &task_woken); + test_set_bits = FALSE; + } + else if (test_clear_bits) + { + xEventGroupClearBitsFromISR(eg, BITS); + xSemaphoreGiveFromISR(done_sem, &task_woken); + test_clear_bits = FALSE; + } + + //Switch context if necessary + if(task_woken == pdTRUE) + { + portYIELD_FROM_ISR(task_woken); + } +} + +/** + * @name: WdtRefreshTest + * @msg: Set wdt interrupt to refresh wdt, set timeout value, start wdt. + * @return {void} + * @param {WdtCtrl} *pctrl, pointer to a WdtCtrl structure that contains + * the configuration information for the specified wdt module. + */ + +static void FWdtRefreshTest(FWdtCtrl *pctrl) +{ + FWdtConfig *pconfig = &pctrl->config; + /* interrupt init */ + InterruptSetPriority(pconfig->irq_num, /*pconfig->irq_prority*/((0x8 << 4) + 4 * 16)); + InterruptInstall(pconfig->irq_num, FWdtInterrupt, (void*)pctrl, pconfig->instance_name); + InterruptUmask(pconfig->irq_num); + FWdtSetTimeout(pctrl, 3); + FWdtStart(pctrl); +} + +/** + * @name: WdtNoRefreshTest + * @msg: Set wdt timeout value, start wdt, no refresh. + * @return {void} + * @param {WdtCtrl} *pctrl, pointer to a WdtCtrl structure that contains + * the configuration information for the specified wdt module. + */ +static void WdtTaskCreate(void) +{ + FWdtCtrl *pctrl = &wdt_ctrl; + pctrl->config = *FWdtLookupConfig(wdt_id); + FWdtRefreshTest(pctrl); +} + +void EventGroupIsrTest(void) +{ + done_sem = xSemaphoreCreateBinary(); + eg = xEventGroupCreate(); + test_set_bits = FALSE; + test_clear_bits = FALSE; + + WdtTaskCreate(); + //Test set bits + test_set_bits = TRUE; + + TEST_ASSERT(BITS==xEventGroupWaitBits(eg, BITS, pdFALSE, pdTRUE, portMAX_DELAY)); //Let ISR set event group bits + + //Test clear bits + xEventGroupSetBits(eg, BITS); //Set bits to be cleared + test_clear_bits = TRUE; + + xSemaphoreTake(done_sem, portMAX_DELAY); //Wait for ISR to clear bits + vTaskDelay(10); //Event group clear bits runs via daemon task, delay so daemon can run + TEST_ASSERT(0==xEventGroupGetBits(eg)); //Check bits are cleared + + //Clean up + vEventGroupDelete(eg); + vSemaphoreDelete(done_sem); + vTaskDelay(10); //Give time for idle task to clear up deleted tasks + + printf("EventGroupIsrTest end\n"); + while(1) + { + vTaskDelay(200); + } +} diff --git a/example/freertos_test/freertos_get_state.c b/example/freertos_test/freertos_get_state.c new file mode 100644 index 0000000000000000000000000000000000000000..7ecdcfc0aa6c9877e189d02ffb14204ae8bf599c --- /dev/null +++ b/example/freertos_test/freertos_get_state.c @@ -0,0 +1,70 @@ +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "unity.h" +#include "ft_types.h" + +static TaskHandle_t blocked_task_handle; +static TaskHandle_t suspended_task_handle; +static SemaphoreHandle_t done_sem; + +void TaskGetState(void* arg) +{ + /*Current task should return eRunning*/ + TEST_ASSERT(eTaskGetState(xTaskGetCurrentTaskHandle()) == eRunning); + /*Idle task of current core should return eReady*/ + TEST_ASSERT(eTaskGetState(xTaskGetIdleTaskHandle()) == eReady); + /*Blocked Task should return eBlocked*/ + TEST_ASSERT(eTaskGetState(blocked_task_handle) == /*eBlocked*/eSuspended); + /*Suspended Task should return eSuspended*/ + TEST_ASSERT(eTaskGetState(suspended_task_handle) == eSuspended); + + xSemaphoreGive(done_sem); + vTaskDelete(NULL); +} + +void BlockedTask(void *arg) +{ + u32 notify_value; + + while(1) + { + xTaskNotifyWait(0, 0xFFFFFFFF, ¬ify_value, portMAX_DELAY); + } +} + +void SuspendedTask(void *arg) +{ + while(1) + { + vTaskSuspend(NULL); + } +} + +void TaskGetStateTest(void) +{ + done_sem = xQueueCreateCountingSemaphore(1, 0); + /*Create blocked and suspended task*/ + xTaskCreate(BlockedTask, "Blocked task", 1024, NULL, TSK_PRIORITY, &blocked_task_handle); + xTaskCreate(SuspendedTask, "Suspended task", 1024, NULL, TSK_PRIORITY, &suspended_task_handle); + + /*Create testing task*/ + xTaskCreate(TaskGetState, "Test task", 1024, NULL, TSK_PRIORITY, NULL); + + /*Wait until done*/ + xSemaphoreTake(done_sem, portMAX_DELAY); + + /*Clean up blocked and suspended tasks*/ + vTaskDelete(blocked_task_handle); + blocked_task_handle = NULL; + vTaskDelete(suspended_task_handle); + suspended_task_handle = NULL; + vSemaphoreDelete(done_sem); + printf("end TaskGetStateTest \n"); + while (1) + { + vTaskDelay(200); + } +} diff --git a/example/freertos_test/freertos_mutex.c b/example/freertos_test/freertos_mutex.c new file mode 100644 index 0000000000000000000000000000000000000000..4c91c979d6547ac3e5390bf814b455cab0a05748 --- /dev/null +++ b/example/freertos_test/freertos_mutex.c @@ -0,0 +1,28 @@ + +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "unity.h" + +SemaphoreHandle_t mutex; + +static void MutexReleaseTask(void) +{ + xSemaphoreTake(mutex, portMAX_DELAY); + xSemaphoreGive(mutex); + vTaskDelete(NULL); +} + +void MutexTest(void) +{ + mutex = xSemaphoreCreateMutex(); + + xTaskCreate((TaskFunction_t )MutexReleaseTask, "mutex_release", 2048, (void* )NULL, UNITY_FREERTOS_PRIORITY, NULL); + vTaskDelay(1); + + printf("MutexTest end\n"); + while(1) + { + vTaskDelay(150 / portTICK_PERIOD_MS); + } +} diff --git a/example/freertos_test/freertos_scheduling_time.c b/example/freertos_test/freertos_scheduling_time.c new file mode 100644 index 0000000000000000000000000000000000000000..ded57360caaf0ead205b7c8b6a515fab72c57ecd --- /dev/null +++ b/example/freertos_test/freertos_scheduling_time.c @@ -0,0 +1,80 @@ + +#include +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "queue.h" +#include "unity.h" +#include "portmacro.h" +#include "ft_types.h" + +#define NUMBER_OF_ITERATIONS 10 +#define SCHEDULING_TIME 10 + +typedef struct +{ + SemaphoreHandle_t end_sema; + u32 before_sched; + u32 cycles_to_sched; + TaskHandle_t t1_handle; +} test_context_t; + +static void test_task_1(void *arg) +{ + TEST_ASSERT(arg != NULL); + test_context_t *context = (test_context_t *)arg; + + for( ;; ) { + context->before_sched = portGET_RUN_TIME_COUNTER_VALUE(); + taskYIELD(); + } + vTaskDelete(NULL); +} + +static void test_task_2(void *arg) +{ + TEST_ASSERT(arg != NULL); + int i = 0; + test_context_t *context = (test_context_t *)arg; + u64 accumulator = 0; + + vTaskPrioritySet(NULL, 5); + vTaskPrioritySet(context->t1_handle, 5); + + taskYIELD(); + + for(i = 0; i < NUMBER_OF_ITERATIONS; i++) + { + accumulator += (portGET_RUN_TIME_COUNTER_VALUE() - context->before_sched); + taskYIELD(); + } + + context->cycles_to_sched = accumulator / NUMBER_OF_ITERATIONS; + vTaskDelete(context->t1_handle); + xSemaphoreGive(context->end_sema); + vTaskDelete(NULL); +} + + +void ScheduleTimeTest(void) +{ + test_context_t context; + + context.end_sema = xSemaphoreCreateBinary(); + TEST_ASSERT(context.end_sema != NULL); + + xTaskCreate(test_task_1, "test1" , 4096, &context, 1, &context.t1_handle); + xTaskCreate(test_task_2, "test2" , 4096, &context, 1, NULL); + + BaseType_t result = xSemaphoreTake(context.end_sema, portMAX_DELAY); + TEST_ASSERT_EQUAL_HEX32(pdTRUE, result); + + TEST_ASSERT(SCHEDULING_TIME > context.cycles_to_sched); + + printf("ScheduleTimeTest end\n"); + while (1) + { + vTaskDelay(200); + } + +} diff --git a/example/freertos_test/freertos_task_delay_until.c b/example/freertos_test/freertos_task_delay_until.c new file mode 100644 index 0000000000000000000000000000000000000000..2e4ca7e58b0d14254217d2686ce0013d038154b4 --- /dev/null +++ b/example/freertos_test/freertos_task_delay_until.c @@ -0,0 +1,79 @@ +/* + Test for FreeRTOS vTaskDelayUntil() function by comparing the delay period of + the function to comparing it to ref clock. +*/ + +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "unity.h" +#include "ft_types.h" + +#define NO_OF_CYCLES 5 +#define NO_OF_TASKS_PER_CORE 2 +#define TICKS_TO_DELAY 10 +#define TICK_RATE configTICK_RATE_HZ +#define TICK_PERIOD_US (1000000/TICK_RATE) +#define IDEAL_DELAY_PERIOD_MS ((1000*TICKS_TO_DELAY)/TICK_RATE) +#define IDEAL_DELAY_PERIOD_US (IDEAL_DELAY_PERIOD_MS*1000) + +#define TICKS_TO_MS(x) (((x)*1000)/TICK_RATE) +#define REF_TO_ROUND_MS(x) (((x)+500)/1000) + +static SemaphoreHandle_t task_delete_semphr; + +static void DelayingTask(void* arg) +{ + int i = 0; + u64 ref_prev=0; + u64 ref_current=0; + TickType_t last_wake_time; + TickType_t ticks_before_delay; + + vTaskDelay(1); /*Delay until next tick to synchronize operations to tick boundaries*/ + + last_wake_time = xTaskGetTickCount(); + ticks_before_delay = last_wake_time; + + for(i = 0; i < NO_OF_CYCLES; i++) + { + /*Delay of TICKS_TO_DELAY*/ + vTaskDelayUntil(&last_wake_time, TICKS_TO_DELAY); + + /*Get current ref clock*/ + TEST_ASSERT_EQUAL(IDEAL_DELAY_PERIOD_MS, TICKS_TO_MS(xTaskGetTickCount() - ticks_before_delay)); + + ref_prev = ref_current; + ticks_before_delay = last_wake_time; + } + + /*Delete Task after prescribed number of cycles*/ + xSemaphoreGive(task_delete_semphr); + vTaskDelete(NULL); +} + +void TaskDelayUntilTest(void) +{ + int i = 0; + task_delete_semphr = xQueueCreateCountingSemaphore(NO_OF_TASKS_PER_CORE, 0); + + xTaskCreate(DelayingTask, "delay_pinned", 1024, NULL, 1, NULL); + xTaskCreate(DelayingTask, "delay_no_aff", 1024, NULL, 1, NULL); + + for(i = 0; i < NO_OF_TASKS_PER_CORE; i++) + { + xSemaphoreTake(task_delete_semphr, portMAX_DELAY); + } + + /*Cleanup*/ + vSemaphoreDelete(task_delete_semphr); + + printf("TaskDelayUntilTest end\n"); + while(1) + { + vTaskDelay(200); + } + +} diff --git a/example/freertos_test/freertos_task_delete.c b/example/freertos_test/freertos_task_delete.c new file mode 100644 index 0000000000000000000000000000000000000000..9a390fcc021bdb4ebb289d7edba949d7346be0bb --- /dev/null +++ b/example/freertos_test/freertos_task_delete.c @@ -0,0 +1,148 @@ +/* + * Test backported deletion behavior by creating tasks of various affinities and + * check if the task memory is freed immediately under the correct conditions. + * + * The behavior of vTaskDelete() results in the immediate freeing of task memory + * and the immediate execution of deletion callbacks for tasks which are not + * running, provided they are not pinned to the other core (due to FPU cleanup + * requirements). + * + * If the condition is not met, freeing of task memory and execution of + * deletion callbacks will still be carried out by the Idle Task. + */ +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "unity.h" +#include "fsleep.h" +#include "math.h" + +#define NO_OF_TSKS 3 +#define DELAY_TICKS 2 +/* Caps of all memory which is allocated from when a task is created */ +#define HEAP_CAPS (portTcbMemoryCaps | portStackMemoryCaps) + +#define DELAY_US_ITERATIONS 1000 + +/*Deleting self means deleting currently running task*/ +static void TaskSelfDel(void *param) +{ + vTaskDelete(NULL); +} +/*Await external deletion*/ +static void TaskExternDel(void *param) +{ + vTaskDelay(portMAX_DELAY); +} + +static void TaskSelfDelDelay(void *param) +{ + u32 delay = *((uint32_t*)param); + fsleep_microsec(delay); + vTaskDelete(NULL); +} + +void DeleteTaskTest(void) +{ + /* Test vTaskDelete() on currently running tasks*/ + u32 before_count = uxTaskGetNumberOfTasks(); + int i = 0; + + for(i = 0; i < NO_OF_TSKS; i++) + { + TEST_ASSERT_EQUAL(pdTRUE, xTaskCreate(TaskSelfDel, "tsk_self", 1024, NULL, configMAX_PRIORITIES - 1, NULL)); + } + + /*Minimal delay to see if Idle task cleans up all tasks awaiting deletion in a single tick*/ + vTaskDelay(DELAY_TICKS); + + /* Test vTaskDelete() on not currently running tasks */ + TaskHandle_t handles[NO_OF_TSKS]; + + for(i = 0 ; i < NO_OF_TSKS; i++) + { + TEST_ASSERT_EQUAL(pdTRUE, xTaskCreate(TaskExternDel, "tsk_extern", 4096, NULL, configMAX_PRIORITIES - 1, &handles[i] )); + } + + /*Delete the tasks, memory should be freed immediately*/ + for(i = 0; i < NO_OF_TSKS; i++) + { + vTaskDelete(handles[i]); + } + + /* Test self deleting no affinity task is not removed by idle task of other core before context switch */ + for(i = 0; i < DELAY_US_ITERATIONS; i+= 10) + { + /*Sync to next tick interrupt*/ + vTaskDelay(1); + xTaskCreate(TaskSelfDelDelay, "delay", 1024, (void *)&i, configMAX_PRIORITIES - 1, NULL); + /*Busy wait to ensure no affinity task runs*/ + fsleep_microsec(10); + } + + printf("DeleteTaskTest end\n"); + while(1) + { + vTaskDelay(200); + } + +} + +typedef struct +{ + SemaphoreHandle_t sem; + /* Check the deleted task doesn't keep running after being deleted*/ + volatile u8 deleted; +} TaskBlocksParam_t; + +/* Task blocks as often as possible + (two or more of these can share the same semaphore and "juggle" it around) +*/ +static void TaskBlocksFrequently(void *param) +{ + TEST_ASSERT(param != NULL); + TaskBlocksParam_t *p = (TaskBlocksParam_t *)param; + SemaphoreHandle_t sem = p->sem; + srand(xTaskGetTickCount() ^ (*(TickType_t*)xTaskGetCurrentTaskHandle())); + while (1) + { + TEST_ASSERT(!p->deleted); + fsleep_microsec(rand() % 10); + TEST_ASSERT(!p->deleted); + xSemaphoreTake(sem, portMAX_DELAY); + TEST_ASSERT(!p->deleted); + fsleep_microsec(rand() % 10); + TEST_ASSERT(!p->deleted); + xSemaphoreGive(sem); + } +} + +void DeleteBlockTaskTest(void) +{ + TaskHandle_t blocking_tasks; + TaskBlocksParam_t params = { 0 }; + u8 iter = 0; + for( iter = 0; iter < 10; iter++) + { + SemaphoreHandle_t sem = xSemaphoreCreateMutex(); + params.deleted = FALSE; + params.sem = sem; + TEST_ASSERT_EQUAL(pdTRUE, xTaskCreate(TaskBlocksFrequently, "tsk_block", 4096, ¶ms, + configMAX_PRIORITIES - 1, &blocking_tasks)); + /*Let the tasks juggle the mutex for a bit*/ + vTaskDelay(5); + vTaskDelete(blocking_tasks); + params.deleted = TRUE; + + /* Yield to the idle task for cleanup */ + vTaskDelay(4); + vSemaphoreDelete(sem); + } + + while(1) + { + vTaskDelay(200); + } +} diff --git a/example/freertos_test/freertos_task_notify.c b/example/freertos_test/freertos_task_notify.c new file mode 100644 index 0000000000000000000000000000000000000000..cfa047ce2f90afaa622b90e5275fc7fbb4eb88bc --- /dev/null +++ b/example/freertos_test/freertos_task_notify.c @@ -0,0 +1,165 @@ +/* + Test of FreeRTOS task notifications. This test creates a sender and receiver + task under different core permutations. For each permutation, the sender task + will test the xTaskNotify(), xTaskNotifyGive(), xTaskNotifyFromISR(), and + vTaskNotifyGiveFromISR(), whereas the receiver task will test + xTaskNotifyWait() and ulTaskNotifyTake(). +*/ +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "unity.h" +#include "parameters.h" +#include "ft_types.h" + +#define NO_OF_NOTIFS 4 +#define NO_OF_TASKS 2 +#define TIMER_DIVIDER 10000 +#define TIMER_COUNT 100 +#define MESSAGE 0xFF + +static uint32_t send_core_message = 0; +static TaskHandle_t rec_task_handle; +static u8 isr_give = FALSE; + +static SemaphoreHandle_t trigger_send_semphr; +static SemaphoreHandle_t task_delete_semphr; + +/*Test tracking vars*/ +static volatile uint32_t notifs_sent = 0; +static volatile uint32_t notifs_rec = 0; +static u8 wrong_core = FALSE; + +static void SenderTask (void* arg){ + + /*Test xTaskNotify*/ + xSemaphoreTake(trigger_send_semphr, portMAX_DELAY); + notifs_sent++; + + xTaskNotify(rec_task_handle, (MESSAGE), eSetValueWithOverwrite); + + /*Test xTaskNotifyGive*/ + xSemaphoreTake(trigger_send_semphr, portMAX_DELAY); + + notifs_sent++; + xTaskNotifyGive(rec_task_handle); + + /*Test xTaskNotifyFromISR*/ + xSemaphoreTake(trigger_send_semphr, portMAX_DELAY); + isr_give = FALSE; + vTaskDelay(20); + + /*Test vTaskNotifyGiveFromISR*/ + xSemaphoreTake(trigger_send_semphr, portMAX_DELAY); + isr_give = TRUE; + vTaskDelay(20); + + /*Delete Task and Semaphores*/ + xSemaphoreGive(task_delete_semphr); + vTaskDelete(NULL); +} + +static void ReceiverTask (void* arg){ + uint32_t notify_value; + + /*Test xTaskNotifyWait from task*/ + xTaskNotifyWait(0, 0xFFFFFFFF, ¬ify_value, portMAX_DELAY); + if(notify_value != send_core_message) + { + wrong_core = TRUE; + } + notifs_rec++; + + /*Test ulTaskNotifyTake from task*/ + xSemaphoreGive(trigger_send_semphr); + ulTaskNotifyTake(pdTRUE, portMAX_DELAY); + notifs_rec++; + + /*Test xTaskNotifyWait from ISR*/ + xSemaphoreGive(trigger_send_semphr); + + xTaskNotifyWait(0, 0xFFFFFFFF, ¬ify_value, portMAX_DELAY); + if(notify_value != send_core_message) + { + wrong_core = TRUE; + } + notifs_rec++; + + /*Test ulTaskNotifyTake from ISR*/ + xSemaphoreGive(trigger_send_semphr); + ulTaskNotifyTake(pdTRUE, portMAX_DELAY); + notifs_rec++; + + /*Test complete, stop timer and delete task*/ + xSemaphoreGive(task_delete_semphr); + vTaskDelete(NULL); +} + +static void sender_ISR(void *arg) +{ + while(1) + { + if(isr_give) + { + /*Test vTaskNotifyGiveFromISR()*/ + notifs_sent++; + xTaskNotifyGive(rec_task_handle); + } + else + { + /*Test xTaskNotifyFromISR()*/ + notifs_sent++; + xTaskNotify(rec_task_handle, (MESSAGE), eSetValueWithOverwrite); + } + portYIELD(); + } + +} + +void TaskNotifyTest(void) +{ + static TaskHandle_t appTaskCreateHand; + + BaseType_t ret = xTaskCreate(sender_ISR, "tsk_call_resp", 4096, \ + NULL, 2, &appTaskCreateHand); + + trigger_send_semphr = xSemaphoreCreateBinary(); + task_delete_semphr = xQueueCreateCountingSemaphore(NO_OF_TASKS, 0); + + /*Reset Values*/ + notifs_sent = 0; + notifs_rec = 0; + wrong_core = FALSE; + + send_core_message = 0xFF; + + xTaskCreate(ReceiverTask, "rec task", 1000, NULL, 2, &rec_task_handle); + xTaskCreate(SenderTask, "send task", 1000, NULL, 2, NULL); + + /*Wait for task creation to complete*/ + vTaskDelay(5); + + /*Trigger sender task*/ + xSemaphoreGive(trigger_send_semphr); + for(int k = 0; k < NO_OF_TASKS; k++) + { + /*Wait for sender and receiver task deletion*/ + TEST_ASSERT( xSemaphoreTake(task_delete_semphr, 1000 / portTICK_PERIOD_MS) ); + } + /*Give time tasks to delete*/ + vTaskDelay(5); + + /*Delete Semaphroes and timer ISRs*/ + vSemaphoreDelete(trigger_send_semphr); + vSemaphoreDelete(task_delete_semphr); + + printf("TaskNotifyTest end\n"); + + while(1) + { + vTaskDelay(200); + } + +} diff --git a/example/freertos_test/freertos_trace_utilities.c b/example/freertos_test/freertos_trace_utilities.c new file mode 100644 index 0000000000000000000000000000000000000000..31eb7ec4dfa72c9e1035dbc0542a53d508d10164 --- /dev/null +++ b/example/freertos_test/freertos_trace_utilities.c @@ -0,0 +1,122 @@ +/* + * Test FreeRTOS trace facility functions. These following functions are enabled + * when configUSE_TRACE_FACILITY is defined 1 in FreeRTOS. + * Tasks: uxTaskGetTaskNumber(), uxTaskSetTaskNumber() + * Queues: ucQueueGetQueueType(), vQueueSetQueueNumber(), uxQueueGetQueueNumber() + * Event Groups: xEventGroupSetBitsFromISR(), xEventGroupClearBitsFromISR(), uxEventGroupGetNumber() + * + * Note: uxTaskGetSystemState() is tested in a separate unit test + */ +#include +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "event_groups.h" +#include "unity.h" +#include "ft_types.h" + + /*Expected Queue Type*/ +#define BIN_SEM_QUEUE_TYPE queueQUEUE_TYPE_BINARY_SEMAPHORE + +static QueueHandle_t test_queues; +static TaskHandle_t task_handles; + +void taskTraceUtilities(void *arg) +{ + + TEST_ASSERT(arg != NULL); + u32 id = (u32)(intptr)arg; + + TaskHandle_t handle = xTaskGetCurrentTaskHandle(); + + /*cast and store id as task number*/ + vTaskSetTaskNumber(handle, (UBaseType_t)id); + /*store id as queue number*/ + vQueueSetQueueNumber(test_queues, id); + + /*Wait to start*/ + xSemaphoreTake(test_queues, portMAX_DELAY); + + TEST_ASSERT(uxTaskGetTaskNumber(task_handles) == (UBaseType_t)(0x0F)); + TEST_ASSERT(uxQueueGetQueueNumber(test_queues) == (UBaseType_t)(0x0F)); + TEST_ASSERT(ucQueueGetQueueType(test_queues) == BIN_SEM_QUEUE_TYPE); + + /*Signal done*/ + xSemaphoreGive(test_queues); + vTaskDelete(NULL); +} + +void TraceFacilityTest(void) +{ + /*Create a queue as binary semaphore */ + test_queues = xSemaphoreCreateBinary(); + xTaskCreate(taskTraceUtilities, "Test Task", 4096, (void *)(0x0F), TSK_PRIORITY, &task_handles); + vTaskDelay(10); + + /*Start the tasks*/ + xSemaphoreGive(test_queues); + + /*Small delay to ensure semaphores are taken*/ + vTaskDelay(10); + + /*Wait for done*/ + xSemaphoreTake(test_queues, portMAX_DELAY); + vSemaphoreDelete(test_queues); + + printf("TraceFacilityTest end\n"); + while(1){ + vTaskDelay(200); + } +} + + +#define MAX_TASKS 15 +#define TASKS_TO_CREATE 5 + +static TaskHandle_t created_handles[TASKS_TO_CREATE]; +static TaskStatus_t *tsk_status_array; + +void CreatedTask(void* arg) +{ + while(1){ + vTaskDelay(100); + } +} + +void TaskGetSystemState(void) +{ + tsk_status_array = calloc(MAX_TASKS, sizeof(TaskStatus_t)); + for(int i = 0; i < TASKS_TO_CREATE; i++){ + xTaskCreate(CreatedTask, "Created Task", 1024, NULL, TSK_PRIORITY, &created_handles[i]); + } + + /*Get System states*/ + int no_of_tasks = uxTaskGetSystemState(tsk_status_array, MAX_TASKS, NULL); + TEST_ASSERT((no_of_tasks > 0) && (no_of_tasks <= MAX_TASKS)); + + /*Check if get system state has got all created tasks*/ + u8 not_found = FALSE; + for(int i = 0; i < TASKS_TO_CREATE; i++){ + u8 found = FALSE; + for(int j = 0; j < MAX_TASKS; j++){ + if(tsk_status_array[j].xHandle == created_handles[i]){ + found = TRUE; + break; + } + } + if(!found){ + not_found = TRUE; + break; + } + } + TEST_ASSERT(not_found == FALSE); + + /*Cleanup*/ + for(int i = 0; i < TASKS_TO_CREATE; i++){ + vTaskDelete(created_handles[i]); + } + free(tsk_status_array); + vTaskDelay(10); +} diff --git a/example/freertos_test/get_cpu_stats.c b/example/freertos_test/get_cpu_stats.c new file mode 100644 index 0000000000000000000000000000000000000000..1e6c3ab342e3dfd90630fa852f27d6aa4144db40 --- /dev/null +++ b/example/freertos_test/get_cpu_stats.c @@ -0,0 +1,84 @@ +/* + * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * + * SPDX-License-Identifier: Apache-2.0. + * + * @Date: 2021-07-05 10:28:22 + * @LastEditTime: 2021-07-22 09:05:53 + * @Description:  This files is for + * + * @Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "ft_types.h" + +static TaskHandle_t cpuStatsTaskHandle = NULL; +static void CpuStatsTask(void* parameter) +{ + u8 CPU_RunInfo[400]; /*保存任务运行时间信息*/ + + while (1) + { + memset(CPU_RunInfo,0,400); /*信息缓冲区清零*/ + vTaskList((char *)&CPU_RunInfo); /*获取任务运行时间信息*/ + + printf("---------------------------------------------\r\n"); + printf("task_name task_state priority stack task_num\r\n"); + printf("%s", CPU_RunInfo); + printf("---------------------------------------------\r\n"); + + memset(CPU_RunInfo, 0, 400); /*信息缓冲区清零*/ + + vTaskGetRunTimeStats((char *)&CPU_RunInfo); + + printf("task_name\trun_time_count\tusage_rate\r\n"); + printf("%s", CPU_RunInfo); + printf("---------------------------------------------\r\n\n"); + vTaskDelay(2000); /* 延时 */ + } +} + +static TaskHandle_t appTaskCreateHandle = NULL; +static void AppTaskCreate(void) +{ + BaseType_t ret = pdPASS;/* 定义一个创建信息返回值,默认为 pdPASS */ + + taskENTER_CRITICAL(); /*进入临界区*/ + + /* 创建 CPU stats 任务 */ + ret = xTaskCreate((TaskFunction_t )CpuStatsTask, /* 任务入口函数 */ + (const char* )"CPU_STATS_Task",/* 任务名字 */ + (uint16_t )1024, /* 任务栈大小 */ + (void* )NULL, /* 任务入口函数参数 */ + (UBaseType_t )configMAX_PRIORITIES - 1, /* 任务的优先级 */ + (TaskHandle_t* )&cpuStatsTaskHandle);/* 任务控制块指针 */ + + if (pdPASS == ret) + { + printf("create cpu stats task success!\r\n"); + } + + vTaskDelete(appTaskCreateHandle); /*删除 AppTaskCreate 任务*/ + + taskEXIT_CRITICAL(); /*退出临界区*/ +} + +BaseType_t TestCpuStatsEntry() +{ + BaseType_t ret = pdPASS;/* 定义一个创建信息返回值,默认为 pdPASS */ + + ret = xTaskCreate((TaskFunction_t )AppTaskCreate, /* 任务入口函数 */ + (const char* )"AppTaskCreate",/* 任务名字 */ + (uint16_t )512, /* 任务栈大小 */ + (void* )NULL,/* 任务入口函数参数 */ + (UBaseType_t )configMAX_PRIORITIES - 1, /* 任务的优先级 */ + (TaskHandle_t* )&appTaskCreateHandle); /* 任务控制 */ + + return ret; +} \ No newline at end of file diff --git a/example/freertos_test/main.c b/example/freertos_test/main.c new file mode 100644 index 0000000000000000000000000000000000000000..fcde60fdb14379cf4f0999beb9b51566debefc3c --- /dev/null +++ b/example/freertos_test/main.c @@ -0,0 +1,245 @@ +/* + * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * + * SPDX-License-Identifier: Apache-2.0. + * + * @Date: 2021-07-09 08:08:39 + * @LastEditTime: 2021-08-25 18:40:20 + * @Description:  This files is for freertos test + * + * @Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ +#include +#include "parameters.h" +#include "ft_types.h" +#include "FreeRTOS.h" +#include "task.h" +#include "unity.h" + +// #define EVENT_GROUPS_TEST 1 +// #define TRACE_FACILITY_TEST 1 +#if 1 +#define ISR_FLOAT_TEST 1 +#define BACKPORT_TEST 1 +#define DEBUG_QUEUE_REGISTER_TEST 1 +#define EVENT_GROUPS_TEST 1 +#define TASK_GET_STATE_TEST 1 +#define MUTEX_TEST 1 +#define SCHEDULING_TIME_TEST 1 +#define TASK_DELAY_UNTIL_TEST 1 +#define DELETE_TASK_TEST 1 +#define TASK_NOTIFY_TEST 1 +#define TRACE_FACILITY_TEST 1 +#define ISR_LATENCY_TEST 1 +#define HOOK_TEST 1 +#define NEWLIB_REENT_TEST 1 +#define PANIC_TEST 1 +#define QUEUE_SET_GET_TEST 1 +#define STREAM_TEST 1 +#define PRIORITY_TEST 1 +#define THREAD_LOCAL_TEST 1 +#define TIMER_TEST 1 +#endif + +#if ISR_FLOAT_TEST +extern BaseType_t TestFloatIsrEntry(void); +extern BaseType_t TestWdtIsrFloatEntry(void); +#endif + +#if BACKPORT_TEST +extern void StaticTaskCreateTest(void); +extern void TimerFuncTest(void); +extern void QueueFuncTest(void); +#endif + +#if DEBUG_QUEUE_REGISTER_TEST +extern void QueueRegistryDebugTest(void); +#endif + +#if EVENT_GROUPS_TEST +extern void EventGroupsTest(void); +extern void EventGroupIsrTest(void); +#endif + +#if NEWLIB_REENT_TEST +extern void NewLibTest(void); +#endif + +#if SCHEDULING_TIME_TEST +extern void ScheduleTimeTest(void); +#endif + +#if TASK_GET_STATE_TEST +extern void TaskGetStateTest(void); +#endif + +#if MUTEX_TEST +extern void MutexTest(void); +#endif + +#if TASK_DELAY_UNTIL_TEST +extern void TaskDelayUntilTest(void); +#endif + +#if DELETE_TASK_TEST +extern void DeleteTaskTest(void); +extern void DeleteBlockTaskTest(void); +#endif + +#if TASK_NOTIFY_TEST +extern void TaskNotifyTest(void); +#endif + +#if TRACE_FACILITY_TEST +extern void TraceFacilityTest(void); +#endif + +#if ISR_LATENCY_TEST +extern void IsrLatencyTest(void); +#endif + +#if HOOK_TEST +extern void IdleHookTest(void); +extern void TickHookTest(void); +extern void CleanUpHookTest(void); +#endif + +#if PANIC_TEST +extern void PanicHandler(void); +#endif + +#if QUEUE_SET_GET_TEST +extern void TestQueueSetTest(void); +extern void QueueSetThreadSafetyTest(void); +#endif + +#if STREAM_TEST +extern void SendRecvStreamTest(void); +#endif + +#if PRIORITY_TEST +extern void GetAndSetPriorityTest(void); +#endif + +#if THREAD_LOCAL_TEST +extern void ThreadLocalStorageTest(void); +#endif + +#if TIMER_TEST +extern void OneshotTimersTest(void); +extern void RecurringTimersTest(void); +extern void StaticTimersTest(void); +#endif + + +int main(void) +{ + BaseType_t ret = pdPASS; + + #if ISR_FLOAT_TEST + /* Floating point usage in timer ISR */ + TestFloatIsrEntry(); + /* Floating point usage in wdt ISR */ + /* TestWdtIsrFloatEntry();*/ + #endif + + #if BACKPORT_TEST + xTaskCreate((TaskFunction_t )TimerFuncTest, (const char* )"TimerFuncTest", 4096, (void* )NULL, 3, NULL); + xTaskCreate((TaskFunction_t )QueueFuncTest, (const char* )"QueueFuncTest", 1024, (void* )NULL, 3, NULL); + xTaskCreate((TaskFunction_t )StaticTaskCreateTest, (const char* )"StaticTaskCreateTest", 8192, (void* )NULL, 3, NULL); + #endif + + #if DEBUG_QUEUE_REGISTER_TEST + xTaskCreate((TaskFunction_t )QueueRegistryDebugTest, (const char* )"QueueRegistryDebugTest", 1024, (void* )NULL, 1, NULL); + #endif + + + #if EVENT_GROUPS_TEST + xTaskCreate((TaskFunction_t )EventGroupsTest, (const char* )"EventGroupsTest", 1024, (void* )NULL, 3, NULL); + /* xTaskCreate((TaskFunction_t )EventGroupIsrTest, (const char* )"EventGroupIsrTest", 1024, (void* )NULL, 3, NULL);*/ + #endif + + + #if TASK_GET_STATE_TEST + xTaskCreate((TaskFunction_t )TaskGetStateTest, (const char* )"TaskGetStateTest", 1024, (void* )NULL, 3, NULL); + #endif + + + #if SCHEDULING_TIME_TEST + xTaskCreate((TaskFunction_t )ScheduleTimeTest, (const char* )"ScheduleTimeTest", 1024, (void* )NULL, 4, NULL); + #endif + + + #if MUTEX_TEST + xTaskCreate((TaskFunction_t )MutexTest, (const char* )"MutexTest", 1024, (void* )NULL, 3, NULL); + #endif + + #if TASK_DELAY_UNTIL_TEST + xTaskCreate((TaskFunction_t )TaskDelayUntilTest, (const char* )"TaskDelayUntilTest", 1024, (void* )NULL, 3, NULL); + #endif + + #if DELETE_TASK_TEST + xTaskCreate((TaskFunction_t )DeleteTaskTest, (const char* )"DeleteTaskTest", 1024, (void* )NULL, 1, NULL); + /* xTaskCreate((TaskFunction_t )DeleteBlockTaskTest, (const char* )"DeleteBlockTaskTest", 1024, (void* )NULL, 1, NULL);*/ + #endif + + #if TASK_NOTIFY_TEST + xTaskCreate((TaskFunction_t )TaskNotifyTest, (const char* )"TaskNotifyTest", 4096, (void* )NULL, 2, NULL); + #endif + + #if TRACE_FACILITY_TEST + xTaskCreate((TaskFunction_t )TraceFacilityTest, (const char* )"TraceFacilityTest", 1024, (void* )NULL, 3, NULL); + #endif + + #if ISR_LATENCY_TEST + xTaskCreate((TaskFunction_t )IsrLatencyTest, (const char* )"IsrLatencyTest", 1024, (void* )NULL, 3, NULL); + #endif + + #if HOOK_TEST + xTaskCreate((TaskFunction_t )IdleHookTest, (const char* )"IdleHookTest", 1024, (void* )NULL, 1, NULL); + xTaskCreate((TaskFunction_t )TickHookTest, (const char* )"TickHookTest", 1024, (void* )NULL, 1, NULL); + xTaskCreate((TaskFunction_t )CleanUpHookTest, (const char* )"CleanUpHookTest", 1024, (void* )NULL, 1, NULL); + #endif + + #if NEWLIB_REENT_TEST + /* new_lib_test reentrant */ + xTaskCreate((TaskFunction_t )NewLibTest, (const char* )"NewLibTest", 1024, (void* )NULL, 3, NULL); + #endif + + #if PANIC_TEST + xTaskCreate((TaskFunction_t )PanicHandler, (const char* )"PanicHandler", 1024, (void* )NULL, 3, NULL); + #endif + + #if QUEUE_SET_GET_TEST + xTaskCreate((TaskFunction_t )TestQueueSetTest, (const char* )"TestQueueSetTest", 1024, (void* )NULL, 3, NULL); + xTaskCreate((TaskFunction_t )QueueSetThreadSafetyTest, (const char* )"QueueSetThreadSafetyTest", 1024, (void* )NULL, 3, NULL); + #endif + + #if STREAM_TEST + xTaskCreate((TaskFunction_t )SendRecvStreamTest, (const char* )"SendRecvStreamTest", 1024, (void* )NULL, 3, NULL); + #endif + + #if PRIORITY_TEST + xTaskCreate((TaskFunction_t )GetAndSetPriorityTest, (const char* )"GetAndSetPriorityTest", 4096, (void* )NULL, UNITY_FREERTOS_PRIORITY, NULL); + #endif + + #if THREAD_LOCAL_TEST + xTaskCreate((TaskFunction_t )ThreadLocalStorageTest, (const char* )"ThreadLocalStorageTest", 8192, (void* )NULL, 3, NULL); + #endif + + #if TIMER_TEST + xTaskCreate((TaskFunction_t )OneshotTimersTest, (const char* )"OneshotTimersTest", 1024, (void* )NULL, UNITY_FREERTOS_PRIORITY, NULL); + xTaskCreate((TaskFunction_t )RecurringTimersTest, (const char* )"RecurringTimersTest", 1024, (void* )NULL, UNITY_FREERTOS_PRIORITY, NULL); + xTaskCreate((TaskFunction_t )StaticTimersTest, (const char* )"StaticTimersTest", 1024, (void* )NULL, UNITY_FREERTOS_PRIORITY, NULL); + #endif + + vTaskStartScheduler(); /* 启动任务,开启调度 */ + while (1); /* 正常不会执行到这里 */ + +FAIL_EXIT: + printf("failed 0x%x \r\n", ret); + + return 0; +} \ No newline at end of file diff --git a/example/lwip_test/Makefile b/example/freertos_test/makefile similarity index 82% rename from example/lwip_test/Makefile rename to example/freertos_test/makefile index c08496482e9a35f63d7be04b430b553efc1bfd97..d8b858a95db430b15d9dec91957b2d01981d1198 100644 --- a/example/lwip_test/Makefile +++ b/example/freertos_test/makefile @@ -7,10 +7,15 @@ export USR_INC_DIR ?= . \ ./inc # 用户定义的编译目标文件上传路径 -USR_BOOT_DIR ?= /mnt/d/tftboot/ +ifeq ($(OS),Windows_NT) +USR_BOOT_DIR ?= /d/tftboot +else +USR_BOOT_DIR ?= /mnt/d/tftboot +endif + # 设置启动镜像名 -BOOT_IMG_NAME ?= lwip +BOOT_IMG_NAME ?= freertos # 指定编译freertos项目使用的makefile include $(FREERTOS_SDK_ROOT)/make/build_freertos.mk diff --git a/example/freertos_test/pic/freertos_test.png b/example/freertos_test/pic/freertos_test.png new file mode 100644 index 0000000000000000000000000000000000000000..a2f94395238f3203d5908a6ea82ef275e14c8fe2 Binary files /dev/null and b/example/freertos_test/pic/freertos_test.png differ diff --git a/example/freertos_test/sdkconfig b/example/freertos_test/sdkconfig new file mode 100644 index 0000000000000000000000000000000000000000..a4853dd591e2151b0b2ee2a6b5393ecc8b53ea44 --- /dev/null +++ b/example/freertos_test/sdkconfig @@ -0,0 +1,133 @@ + +# +# Project Configuration +# +CONFIG_TARGET_NAME="d2000_freertos" +CONFIG_LWIP_POLL_TEST=y +# CONFIG_LWIP_INTRRUPT_TEST is not set +# end of Project Configuration + +# +# Standalone Setting +# +CONFIG_USE_FREERTOS=y + +# +# Arch Configuration +# +# CONFIG_TARGET_ARMV8_AARCH32 is not set +CONFIG_TARGET_ARMV8_AARCH64=y +# CONFIG_TARGET_ARMV7 is not set +CONFIG_USE_CACHE=y +CONFIG_USE_L3CACHE=y +CONFIG_USE_MMU=y +CONFIG_USE_SYS_TICK=y +# end of Arch Configuration + +# +# Board Configuration +# +# CONFIG_TARGET_F2000_4 is not set +# CONFIG_TARGET_E2000 is not set +CONFIG_TARGET_D2000=y +# end of Board Configuration + +# +# Components Configuration +# +# CONFIG_USE_SPI is not set +# CONFIG_USE_QSPI is not set +CONFIG_USE_GIC=y +CONFIG_EBABLE_GICV3=y +# CONFIG_USE_SERIAL is not set +# CONFIG_USE_GPIO is not set +# CONFIG_USE_IOMUX is not set +CONFIG_USE_ETH=y + +# +# Eth Configuration +# +# CONFIG_ENABLE_F_XMAC is not set +CONFIG_ENABLE_F_GMAC=y + +# +# F_GMAC Configuration +# +CONFIG_F_GMAC_PHY_COMMON=y +# CONFIG_F_GMAC_PHY_AR803X is not set +# end of F_GMAC Configuration +# end of Eth Configuration + +# CONFIG_USE_CAN is not set +# CONFIG_USE_I2C is not set +# CONFIG_USE_TIMER is not set +# CONFIG_USE_SDMMC is not set +# CONFIG_USE_PCIE is not set +CONFIG_USE_WDT=y + +# +# FWDT Configuration +# +CONFIG_ENABLE_FWDT=y +# end of FWDT Configuration + +# CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set +# end of Components Configuration + +CONFIG_USE_G_LIBC=y +# CONFIG_USE_NEW_LIBC is not set +# end of Standalone Setting + +# +# Building Option +# + +# +# Cross-Compiler Setting +# +CONFIG_COMPILER_NO_STD_STARUP=y +# CONFIG_USE_EXT_COMPILER is not set +# end of Cross-Compiler Setting + +# CONFIG_LOG_VERBOS is not set +# CONFIG_LOG_DEBUG is not set +CONFIG_LOG_INFO=y +# CONFIG_LOG_WARN is not set +# CONFIG_LOG_ERROR is not set +# CONFIG_LOG_NONE is not set + +# +# Linker Options +# +# CONFIG_AARCH32_RAM_LD is not set +CONFIG_AARCH64_RAM_LD=y +# CONFIG_QEMU_AARCH32_RAM_LD is not set +# CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0x80100000 +CONFIG_ROM_SIZE_MB=1 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0x81000000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=0x100000 +CONFIG_STACK_TOP_ADDR=0x82000000 +# end of Linker Options +# end of Building Option + +# +# Component Configuration +# + +# +# Freertos Drivers +# +CONFIG_FREERTOS_USE_UART=y +# end of Freertos Drivers +# end of Component Configuration + +# +# FreeRTOS Setting +# +# CONFIG_USE_LWIP is not set +# end of FreeRTOS Setting diff --git a/example/freertos_test/sdkconfig.h b/example/freertos_test/sdkconfig.h new file mode 100644 index 0000000000000000000000000000000000000000..76216d099a0b2c0684db80396c1931fc06ec9736 --- /dev/null +++ b/example/freertos_test/sdkconfig.h @@ -0,0 +1,117 @@ +#ifndef SDK_CONFIG_H__ +#define SDK_CONFIG_H__ + +/* Project Configuration */ + +#define CONFIG_TARGET_NAME "d2000_freertos" +#define CONFIG_LWIP_POLL_TEST +/* CONFIG_LWIP_INTRRUPT_TEST is not set */ +/* end of Project Configuration */ + +/* Standalone Setting */ + +#define CONFIG_USE_FREERTOS + +/* Arch Configuration */ + +/* CONFIG_TARGET_ARMV8_AARCH32 is not set */ +#define CONFIG_TARGET_ARMV8_AARCH64 +/* CONFIG_TARGET_ARMV7 is not set */ +#define CONFIG_USE_CACHE +#define CONFIG_USE_L3CACHE +#define CONFIG_USE_MMU +#define CONFIG_USE_SYS_TICK +/* end of Arch Configuration */ + +/* Board Configuration */ + +/* CONFIG_TARGET_F2000_4 is not set */ +/* CONFIG_TARGET_E2000 is not set */ +#define CONFIG_TARGET_D2000 +/* end of Board Configuration */ + +/* Components Configuration */ + +/* CONFIG_USE_SPI is not set */ +/* CONFIG_USE_QSPI is not set */ +#define CONFIG_USE_GIC +#define CONFIG_EBABLE_GICV3 +/* CONFIG_USE_SERIAL is not set */ +/* CONFIG_USE_GPIO is not set */ +/* CONFIG_USE_IOMUX is not set */ +#define CONFIG_USE_ETH + +/* Eth Configuration */ + +/* CONFIG_ENABLE_F_XMAC is not set */ +#define CONFIG_ENABLE_F_GMAC + +/* F_GMAC Configuration */ + +#define CONFIG_F_GMAC_PHY_COMMON +/* CONFIG_F_GMAC_PHY_AR803X is not set */ +/* end of F_GMAC Configuration */ +/* end of Eth Configuration */ +/* CONFIG_USE_CAN is not set */ +/* CONFIG_USE_I2C is not set */ +/* CONFIG_USE_TIMER is not set */ +/* CONFIG_USE_SDMMC is not set */ +/* CONFIG_USE_PCIE is not set */ +#define CONFIG_USE_WDT + +/* FWDT Configuration */ + +#define CONFIG_ENABLE_FWDT +/* end of FWDT Configuration */ +/* CONFIG_USE_DMA is not set */ +/* CONFIG_USE_NAND is not set */ +/* end of Components Configuration */ +#define CONFIG_USE_G_LIBC +/* CONFIG_USE_NEW_LIBC is not set */ +/* end of Standalone Setting */ + +/* Building Option */ + +/* Cross-Compiler Setting */ + +#define CONFIG_COMPILER_NO_STD_STARUP +/* CONFIG_USE_EXT_COMPILER is not set */ +/* end of Cross-Compiler Setting */ +/* CONFIG_LOG_VERBOS is not set */ +/* CONFIG_LOG_DEBUG is not set */ +#define CONFIG_LOG_INFO +/* CONFIG_LOG_WARN is not set */ +/* CONFIG_LOG_ERROR is not set */ +/* CONFIG_LOG_NONE is not set */ + +/* Linker Options */ + +/* CONFIG_AARCH32_RAM_LD is not set */ +#define CONFIG_AARCH64_RAM_LD +/* CONFIG_QEMU_AARCH32_RAM_LD is not set */ +/* CONFIG_USER_DEFINED_LD is not set */ +#define CONFIG_LINK_SCRIPT_ROM +#define CONFIG_ROM_START_UP_ADDR 0x80100000 +#define CONFIG_ROM_SIZE_MB 1 +#define CONFIG_LINK_SCRIPT_RAM +#define CONFIG_RAM_START_UP_ADDR 0x81000000 +#define CONFIG_RAM_SIZE_MB 64 +#define CONFIG_HEAP_SIZE 0x100000 +#define CONFIG_STACK_TOP_ADDR 0x82000000 +/* end of Linker Options */ +/* end of Building Option */ + +/* Component Configuration */ + +/* Freertos Drivers */ + +#define CONFIG_FREERTOS_USE_UART +/* end of Freertos Drivers */ +/* end of Component Configuration */ + +/* FreeRTOS Setting */ + +/* CONFIG_USE_LWIP is not set */ +/* end of FreeRTOS Setting */ + +#endif diff --git a/example/freertos_test/test_isr_latency.c b/example/freertos_test/test_isr_latency.c new file mode 100644 index 0000000000000000000000000000000000000000..2f0b3c6f9f51d985f594f2a34c5b68af58ffa68a --- /dev/null +++ b/example/freertos_test/test_isr_latency.c @@ -0,0 +1,124 @@ +#include +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "queue.h" +#include +#include +#include "interrupt.h" +#include "gicv3.h" +#include "parameters.h" +#include "fwdt.h" +#include "fwdt_hw.h" +#include "ft_types.h" +#include "math.h" +#include "unity.h" + +#define SW_ISR_LEVEL_1 7 +#define ISR_ENTER_CYCLES 10 +#define ISR_EXIT_CYCLES 10 + +static SemaphoreHandle_t sync; +static SemaphoreHandle_t end_sema; +static u32 cycle_before_trigger; +static u32 cycle_before_exit; +static u32 delta_enter_cycles = 0; +static u32 delta_exit_cycles = 0; + +static FWdtCtrl wdt_ctrl; + +/* wdt num: 0 or 1 */ +static u8 wdt_id = 0; + +/** + * @name: WdtInterrupt + * @msg: This function handle wdt timeout interrupt, use it to refresh wdt. + * @return {void} + * @param {s32} vector, the interrupt number + * @param {void} *param, pointer to a WdtCtrl structure that contains + * the configuration information for the specified wdt module. + */ +static void FWdtInterrupt(s32 vector, void *param) +{ + FWdtRefresh((FWdtCtrl *)param); + BaseType_t yield; + delta_enter_cycles += portGET_RUN_TIME_COUNTER_VALUE() - cycle_before_trigger; + printf("test_task: delta_enter_cycles=%d\n", delta_enter_cycles); + + xSemaphoreGiveFromISR(sync, &yield); + portYIELD_FROM_ISR(yield); + + cycle_before_exit = portGET_RUN_TIME_COUNTER_VALUE(); + +} + +/** + * @name: WdtRefreshTest + * @msg: Set wdt interrupt to refresh wdt, set timeout value, start wdt. + * @return {void} + * @param {WdtCtrl} *pctrl, pointer to a WdtCtrl structure that contains + * the configuration information for the specified wdt module. + */ + +static void FWdtRefreshTest(FWdtCtrl *pctrl) +{ + FWdtConfig *pconfig = &pctrl->config; + /* interrupt init */ + InterruptSetPriority(pconfig->irq_num, /*pconfig->irq_prority*/((0x8 << 4) + 4 * 16)); + InterruptInstall(pconfig->irq_num, FWdtInterrupt, (void*)pctrl, pconfig->instance_name); + InterruptUmask(pconfig->irq_num); + FWdtSetTimeout(pctrl, 1); + FWdtStart(pctrl); +} + +/** + * @name: WdtNoRefreshTest + * @msg: Set wdt timeout value, start wdt, no refresh. + * @return {void} + * @param {WdtCtrl} *pctrl, pointer to a WdtCtrl structure that contains + * the configuration information for the specified wdt module. + */ +static void WdtTaskCreate(void) +{ + FWdtCtrl *pctrl = &wdt_ctrl; + pctrl->config = *FWdtLookupConfig(wdt_id); + FWdtRefreshTest(pctrl); +} + +static void TestTask(void *arg) { + + for(int i = 0; i < 20; i++) + { + cycle_before_trigger = portGET_RUN_TIME_COUNTER_VALUE(); + xSemaphoreTake(sync, portMAX_DELAY); + delta_exit_cycles += portGET_RUN_TIME_COUNTER_VALUE() - cycle_before_exit; + + } + delta_enter_cycles /= 20; + delta_exit_cycles /= 20; + + xSemaphoreGive(end_sema); + vTaskDelete(NULL); +} + + +void IsrLatencyTest(void) +{ + WdtTaskCreate(); + sync = xSemaphoreCreateBinary(); + TEST_ASSERT(sync != NULL); + end_sema = xSemaphoreCreateBinary(); + TEST_ASSERT(end_sema != NULL); + xTaskCreate(TestTask, "tst" , 4096, NULL, 1, NULL); + vTaskDelay(100); + BaseType_t result = xSemaphoreTake(end_sema, portMAX_DELAY); + TEST_ASSERT_EQUAL_HEX32(pdTRUE, result); + printf("delta_enter_cycles=%d\n", delta_enter_cycles); + printf("delta_exit_cycles=%d\n", delta_exit_cycles); + printf("IsrLatencyTest end\n"); + + while(1) + { + vTaskDelay(200); + } +} diff --git a/example/freertos_test/test_legacy_hooks.c b/example/freertos_test/test_legacy_hooks.c new file mode 100644 index 0000000000000000000000000000000000000000..b54d968e8643e1899a2045f48361e031c099db86 --- /dev/null +++ b/example/freertos_test/test_legacy_hooks.c @@ -0,0 +1,73 @@ +/* + Test of FreeRTOS "legacy" hook functions, and delete hook + + Only compiled in if the relevant options are enabled. +*/ +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "unity.h" + +static volatile unsigned idle_count; + +void IdleHookTest(void) +{ + idle_count = 0; + vTaskDelay(10); + /* The legacy idle hook should be called at least once*/ + TEST_ASSERT_NOT_EQUAL(0, idle_count); + + printf("IdleHookTest end\n"); + while(1){ + vTaskDelay(200); + } +} + +static volatile unsigned tick_count; + +void TickHookTest(void) +{ + unsigned before = xTaskGetTickCount(); + const unsigned SLEEP_FOR = 20; + tick_count = before; + vTaskDelay(SLEEP_FOR); + printf("TickHookTest end\n"); + while(1){ + vTaskDelay(200); + } +} + +static volatile void *deleted_tcb; + +static void taskDeletesItself(void *ignored) +{ + vTaskDelete(NULL); +} + +void vPortCleanUpTCB(void *pxTCB) +{ + deleted_tcb = pxTCB; +} + +void CleanUpHookTest(void) +{ + + TaskHandle_t new_task = NULL; + deleted_tcb = NULL; + xTaskCreate(taskDeletesItself, "delete", 2048, NULL, 1, &new_task); + + /* xTaskCreate(vPortCleanUpTCB, "vPortCleanUpTCB", 2048, &new_task, 1, NULL);*/ + vPortCleanUpTCB((void *)new_task); + vTaskDelay(5); + + /* TCB & TaskHandle are the same in FreeRTOS*/ + TEST_ASSERT_EQUAL_PTR(deleted_tcb, new_task); + + printf("CleanUpHookTest end\n"); + while(1) + { + vTaskDelay(200); + } +} diff --git a/example/freertos_test/test_newlib_reent.c b/example/freertos_test/test_newlib_reent.c new file mode 100644 index 0000000000000000000000000000000000000000..408be0c71b2c06e8515a9fb85eff970eb81beaa9 --- /dev/null +++ b/example/freertos_test/test_newlib_reent.c @@ -0,0 +1,50 @@ +/* + Test for multicore FreeRTOS. This test spins up threads, fiddles with queues etc. +*/ + +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "queue.h" +#include "unity.h" + +static int done; +static int error; +int l = 0; + +static void tskTestRand(void) +{ + srand(0x1234); + vTaskDelay(10); + l = rand(); + if (l != 869320854) { + error++; + } + vTaskDelay(2); + l = rand(); + if (l != 1148737841) { + error++; + } + done++; + + while (1) { + vTaskDelay(1000); + } +} + +/* split this thing into separate orthogonal tests*/ +void NewLibTest(void) +{ + + xTaskCreate((TaskFunction_t )tskTestRand, (const char* )"tsk1", 1024, (void* )NULL, 3, NULL); + xTaskCreate((TaskFunction_t )tskTestRand, (const char* )"tsk2", 1024, (void* )NULL, 3, NULL); + xTaskCreate((TaskFunction_t )tskTestRand, (const char* )"tsk3", 1024, (void* )NULL, 3, NULL); + xTaskCreate((TaskFunction_t )tskTestRand, (const char* )"tsk4", 1024, (void* )NULL, 3, NULL); + vTaskDelay(1000); + printf("NewLibTest end\n"); + while (1) { + vTaskDelay(1000); + } +} diff --git a/example/freertos_test/test_panic.c b/example/freertos_test/test_panic.c new file mode 100644 index 0000000000000000000000000000000000000000..046563deadd57dc9f7309c74e09740f4a0a29a69 --- /dev/null +++ b/example/freertos_test/test_panic.c @@ -0,0 +1,21 @@ +/* + Test for FreeRTOS. This test whether the cpu debug error info. +*/ + +#include +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "queue.h" +#include "unity.h" + +void PanicHandler(void) +{ + volatile int *i; + i = (volatile int *)0x0; + *i = 1; + printf("PanicHandler end\n"); + while(1){ + vTaskDelay(200); + } +} diff --git a/example/freertos_test/test_queuesets.c b/example/freertos_test/test_queuesets.c new file mode 100644 index 0000000000000000000000000000000000000000..941a1ab074bd1aa249e46bf30a2908b400234a27 --- /dev/null +++ b/example/freertos_test/test_queuesets.c @@ -0,0 +1,135 @@ +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" +#include "semphr.h" +#include "unity.h" +#include "ft_types.h" + +/* + * Basic queue set tests. Multiple queues are added to a queue set then each + * queue is filled in a sequential order. The members returned from the queue + * set must adhered to the order in which the queues were filled. + */ +#define NO_OF_QUEUES 5 +#define QUEUE_LEN 4 +#define ITEM_SIZE sizeof(uint32_t) + +static QueueHandle_t handles[NO_OF_QUEUES]; +static QueueSetHandle_t set_handle; + +void TestQueueSetTest(void) +{ + /*Create queue set, queues, and add queues to queue set*/ + set_handle = xQueueCreateSet(NO_OF_QUEUES * QUEUE_LEN); + for (int i = 0; i < NO_OF_QUEUES; i++) { + handles[i] = xQueueCreate(QUEUE_LEN, ITEM_SIZE); + TEST_ASSERT_MESSAGE(handles[i] != NULL, "Failed to create queue"); + TEST_ASSERT_MESSAGE(xQueueAddToSet(handles[i], set_handle) == pdPASS, "Failed to add to queue set"); + } + + /*Fill queue set via filling each queue*/ + for (int i = 0; i < NO_OF_QUEUES; i++) { + for (int j = 0; j < QUEUE_LEN; j++) { + uint32_t item_num = (i * QUEUE_LEN) + j; + TEST_ASSERT_MESSAGE(xQueueSendToBack(handles[i], &item_num, portMAX_DELAY) == pdTRUE, "Failed to send to queue"); + } + } + + /*Check queue set is notified in correct order*/ + for (int i = 0; i < NO_OF_QUEUES; i++) { + for (int j = 0; j < QUEUE_LEN; j++) { + QueueSetMemberHandle_t member = xQueueSelectFromSet(set_handle, portMAX_DELAY); + TEST_ASSERT_EQUAL_MESSAGE(handles[i], member, "Incorrect queue set member returned"); + uint32_t item; + xQueueReceive((QueueHandle_t)member, &item, 0); + TEST_ASSERT_EQUAL_MESSAGE(((i * QUEUE_LEN) + j), item, "Incorrect item value"); + } + } + + /*Remove queues from queue set and delete queues*/ + for (int i = 0; i < NO_OF_QUEUES; i++) { + TEST_ASSERT_MESSAGE(xQueueRemoveFromSet(handles[i], set_handle), "Failed to remove from queue set"); + vQueueDelete(handles[i]); + } + vQueueDelete(set_handle); + + printf("TestQueueSetTest end\n"); + while(1){ + vTaskDelay(200); + } +} + +/* + * Queue set thread safety test. Test the SMP thread safety by adding two queues + * to a queue set and have a task on each core send to the queues simultaneously. + * Check returned queue set members are valid. + */ + +static volatile bool sync_flags; +static SemaphoreHandle_t sync_sem; + +static void send_task(void *arg) +{ + TEST_ASSERT(arg != NULL); + QueueHandle_t queue = (QueueHandle_t)arg; + + /*Wait until task on the other core starts running*/ + xSemaphoreTake(sync_sem, portMAX_DELAY); + sync_flags = true; + + /*Fill queue*/ + for (int i = 0; i < QUEUE_LEN; i++) { + u32 item = i; + xQueueSendToBack(queue, &item, portMAX_DELAY); + } + + xSemaphoreGive(sync_sem); + vTaskDelete(NULL); +} + +void QueueSetThreadSafetyTest(void) +{ + /*Create queue set, queues, and a send task*/ + sync_sem = xSemaphoreCreateCounting(1, 0); + QueueHandle_t queue_handles; + QueueSetHandle_t queueset_handle = xQueueCreateSet(QUEUE_LEN); + + sync_flags = false; + queue_handles = xQueueCreate(QUEUE_LEN, ITEM_SIZE); + TEST_ASSERT_MESSAGE(xQueueAddToSet(queue_handles, queueset_handle) == pdPASS, "Failed to add to queue set"); + xTaskCreate(send_task, "send", 1024, (void *)queue_handles, 1, NULL); + + vTaskDelay(2); + xSemaphoreGive(sync_sem); + vTaskDelay(2); + + /*Check returned queue set members are valid*/ + u32 expect_0 = 0; + u32 expect_1 = 0; + for (int i = 0; i < (QUEUE_LEN); i++) { + QueueSetMemberHandle_t member = xQueueSelectFromSet(queueset_handle, portMAX_DELAY); + u32 item; + if (member == queue_handles) { + xQueueReceive((QueueHandle_t)member, &item, 0); + TEST_ASSERT_EQUAL_MESSAGE(expect_0, item, "Incorrect item value"); + expect_0++; + } else { + TEST_ASSERT_MESSAGE(0, "Incorrect queue set member returned"); + } + } + + xSemaphoreTake(sync_sem, portMAX_DELAY); + + xQueueRemoveFromSet(queueset_handle, handles); + vQueueDelete(queue_handles); + vQueueDelete(queueset_handle); + + printf("QueueSetThreadSafetyTest end\n"); + while(1) + { + vTaskDelay(200); + } +} + diff --git a/example/freertos_test/test_stream_buffers.c b/example/freertos_test/test_stream_buffers.c new file mode 100644 index 0000000000000000000000000000000000000000..c9232c5a47357f738b5fa603e8c39c76f4ee5366 --- /dev/null +++ b/example/freertos_test/test_stream_buffers.c @@ -0,0 +1,110 @@ +#include +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "semphr.h" +#include "stream_buffer.h" +#include "message_buffer.h" +#include "unity.h" +#include "ft_types.h" + +typedef struct { + StreamBufferHandle_t sb; + SemaphoreHandle_t end_test; + bool send_fail; + bool receive_fail; + bool produce_isr; +}test_context; + +static void producer_task(void *arg) +{ + TEST_ASSERT(arg != NULL); + test_context *tc = arg; + u8 produced = 0; + printf("Starting sender task... \n"); + + while(produced < 100) { + + if(!tc->produce_isr) { + BaseType_t result = xStreamBufferSend(tc->sb, &produced, 1, 0); + if(!result) { + tc->send_fail = true; + xSemaphoreGive(tc->end_test); + vTaskDelete(NULL); + } else { + produced++; + } + } + + vTaskDelay(1); + } + + tc->send_fail = false; + vTaskDelete(NULL); +} + +static void receiver_task(void *arg) +{ + TEST_ASSERT(arg != NULL); + test_context *tc = arg; + u8 expected_consumed = 0; + printf("Starting receiver task... \n"); + + for(;;){ + u8 read_byte = 0xFF; + u32 result = xStreamBufferReceive(tc->sb, &read_byte, 1, 1000); + + if((read_byte != expected_consumed) || !result) { + tc->receive_fail = true; + xSemaphoreGive(tc->end_test); + vTaskDelete(NULL); + } else { + expected_consumed++; + if(expected_consumed == 99) { + break; + } + } + } + printf("expected_consumed=%d\r\n", expected_consumed); + tc->receive_fail = false; + xSemaphoreGive(tc->end_test); + vTaskDelete(NULL); +} + +void SendRecvStreamTest(void) +{ + BaseType_t result; + test_context tc; + + tc.sb = xStreamBufferCreate(128, 1); + tc.end_test = xSemaphoreCreateBinary(); + + TEST_ASSERT(tc.sb); + TEST_ASSERT(tc.end_test); + + tc.send_fail = false; + tc.receive_fail = false; + tc.produce_isr = false; + + result = xTaskCreate(producer_task, "sender", 4096, &tc, UNITY_FREERTOS_PRIORITY , NULL); + TEST_ASSERT(result == pdTRUE); + result = xTaskCreate(receiver_task, "receiver", 4096, &tc, UNITY_FREERTOS_PRIORITY, NULL); + TEST_ASSERT(result == pdTRUE); + + result = xSemaphoreTake(tc.end_test, 2000); + TEST_ASSERT(result == pdTRUE); + + vTaskDelay(1); + + TEST_ASSERT(tc.send_fail == false); + TEST_ASSERT(tc.receive_fail == false); + + vStreamBufferDelete(tc.sb); + vSemaphoreDelete(tc.end_test); + + printf("SendRecvStreamTest end\n"); + while(1){ + vTaskDelay(200); + } +} diff --git a/example/freertos_test/test_task_priorities.c b/example/freertos_test/test_task_priorities.c new file mode 100644 index 0000000000000000000000000000000000000000..34d263287ea29fa9475d6cfbec7d6757119d3653 --- /dev/null +++ b/example/freertos_test/test_task_priorities.c @@ -0,0 +1,72 @@ +/* + Unit tests for FreeRTOS task priority get/set +*/ + +#include +#include +#include "FreeRTOS.h" +#include "task.h" +#include "unity.h" +#include "ft_types.h" + +static void CounterTask(void *param) +{ + TEST_ASSERT(param != NULL); + volatile u32 *counter = (volatile u32 *)param; + while (1) { + (*counter)++; + } +} + +void GetAndSetPriorityTest(void) +{ + /* Two tasks per processor */ + TaskHandle_t tasks[2] = { 0 }; + unsigned volatile counters[2] = { 0 }; + + TEST_ASSERT_EQUAL(UNITY_FREERTOS_PRIORITY, uxTaskPriorityGet(NULL)); + + /* create a matrix of counter tasks on each core */ + for (int task = 0; task < 2; task++) { + xTaskCreate(CounterTask, "count", 2048, (void *)&(counters[task]), UNITY_FREERTOS_PRIORITY - task, &(tasks[task])); + } + + /* check they were created with the expected priorities */ + for (int task = 0; task < 2; task++) { + TEST_ASSERT_EQUAL(UNITY_FREERTOS_PRIORITY - task, uxTaskPriorityGet(tasks[task])); + } + vTaskDelay(10); + + /* at this point, only the higher priority tasks (first index) should be counting */ + printf("counters=%d, %d\n", counters[0], counters[1]); + + /* swap priorities! */ + vTaskPrioritySet(tasks[0], UNITY_FREERTOS_PRIORITY - 1); + vTaskPrioritySet(tasks[1], UNITY_FREERTOS_PRIORITY); + + /* check priorities have swapped... */ + TEST_ASSERT_EQUAL(UNITY_FREERTOS_PRIORITY-1, uxTaskPriorityGet(tasks[0])); + TEST_ASSERT_EQUAL(UNITY_FREERTOS_PRIORITY, uxTaskPriorityGet(tasks[1])); + + /* check the tasks which are counting have also swapped now... */ + unsigned old_counters[2]; + old_counters[0] = counters[0]; + old_counters[1] = counters[1]; + + vTaskDelay(10); + TEST_ASSERT_EQUAL(old_counters[0], counters[0]); + TEST_ASSERT_NOT_EQUAL(old_counters[1], counters[1]); + + + /* clean up */ + for (int task = 0; task < 2; task++) { + vTaskDelete(tasks[task]); + } + + printf("GetAndSetPriorityTest end\n"); + while(1) + { + vTaskDelay(200); + } + +} diff --git a/example/freertos_test/test_thread_local.c b/example/freertos_test/test_thread_local.c new file mode 100644 index 0000000000000000000000000000000000000000..517ae7e810f09680680c2a9e7bca1f93c56b9fe7 --- /dev/null +++ b/example/freertos_test/test_thread_local.c @@ -0,0 +1,114 @@ +/* + Test for thread local storage support. +*/ + +#include +#include + +#include "FreeRTOS.h" +#include "ft_types.h" +#include "task.h" +#include "unity.h" +#include "ft_assert.h" + +static __thread int tl_test_var1; +static __thread u8 tl_test_var2 = 55; +static __thread u16 tl_test_var3 = 44; +static __thread u8 tl_test_arr_var[10]; +static __thread struct test_tls_var { + int f32; + u8 f8; + u16 f16; + u8 farr[10]; +} tl_test_struct_var; + +static void TaskTestTls(void *arg) +{ + TEST_ASSERT(arg != NULL); + bool *running = (bool *)arg; + u32 tp = (u32) -1; + int test_var1_old = 0; + u8 test_var2_old = 0; + u16 test_var3_old = 0; + int f32_old = 0; + u8 f8_old = 0; + u16 f16_old = 0; + + srand(*(TickType_t*)xTaskGetCurrentTaskHandle()); + int step = (rand() % 10) + 1; + for (int i = 0; i < 5; i++) { + // printf("Task[%x]: var = 0x%x 0x%x step=%d\n", tp, tl_test_var1, tl_test_var2, step); + if (i == 0) { + TEST_ASSERT_EQUAL(0, tl_test_var1); + TEST_ASSERT_EQUAL(55, tl_test_var2); + TEST_ASSERT_EQUAL(44, tl_test_var3); + for (u8 k = 0; k < sizeof(tl_test_arr_var); k++) { + TEST_ASSERT_EQUAL(0, tl_test_arr_var[k]); + } + TEST_ASSERT_EQUAL(0, tl_test_struct_var.f32); + TEST_ASSERT_EQUAL(0, tl_test_struct_var.f8); + TEST_ASSERT_EQUAL(0, tl_test_struct_var.f16); + for (u8 k = 0; k < sizeof(tl_test_struct_var.farr); k++) { + TEST_ASSERT_EQUAL(0, tl_test_struct_var.farr[k]); + } + } else { + TEST_ASSERT_EQUAL(test_var1_old + step, tl_test_var1); + TEST_ASSERT_EQUAL(test_var2_old + step, tl_test_var2); + TEST_ASSERT_EQUAL(test_var3_old + step, tl_test_var3); + for (u8 k = 0; k < sizeof(tl_test_arr_var); k++) { + TEST_ASSERT_EQUAL((i - 1) * step, tl_test_arr_var[k]); + } + TEST_ASSERT_EQUAL(f32_old + step, tl_test_struct_var.f32); + TEST_ASSERT_EQUAL(f8_old + step, tl_test_struct_var.f8); + TEST_ASSERT_EQUAL(f16_old + step, tl_test_struct_var.f16); + for (u8 k = 0; k < sizeof(tl_test_struct_var.farr); k++) { + TEST_ASSERT_EQUAL((i - 1) * step, tl_test_struct_var.farr[k]); + } + } + + test_var1_old = tl_test_var1; + test_var2_old = tl_test_var2; + test_var3_old = tl_test_var3; + f32_old = tl_test_struct_var.f32; + f8_old = tl_test_struct_var.f8; + f16_old = tl_test_struct_var.f16; + tl_test_var1 += step; + tl_test_var2 += step; + tl_test_var3 += step; + memset(tl_test_arr_var, i * step, sizeof(tl_test_arr_var)); + tl_test_struct_var.f32 += step; + tl_test_struct_var.f8 += step; + tl_test_struct_var.f16 += step; + memset(tl_test_struct_var.farr, i * step, sizeof(tl_test_struct_var.farr)); + vTaskDelay(10); + } + + if (running) { + *running = false; + vTaskDelete(NULL); + } +} + +void ThreadLocalStorageTest(void) +{ + + const size_t stack_size = 1024; + StackType_t s_stack[stack_size]; /* with 8KB test task stack (default) this test still has ~3KB headroom */ + StaticTask_t s_task; + bool running= true; + + TaskHandle_t handle = xTaskCreateStatic(TaskTestTls, "task_test_tls", stack_size, &running, + 3, s_stack, &s_task); + + /*Check static task was successfully allocated*/ + FT_ASSERTVOID(NULL!= handle); + + /* Make sure idle task can clean up s_task, before it goes out of scope */ + vTaskDelay(10); + + printf("ThreadLocalStorageTest end\n"); + while(1) + { + vTaskDelay(200); + } +} diff --git a/example/freertos_test/test_timers.c b/example/freertos_test/test_timers.c new file mode 100644 index 0000000000000000000000000000000000000000..849bb95eb7a9fe70ca6c2061db96e118a2b52304 --- /dev/null +++ b/example/freertos_test/test_timers.c @@ -0,0 +1,112 @@ +/* FreeRTOS timer tests*/ +#include +#include "unity.h" +#include "FreeRTOS.h" +#include "task.h" +#include "timers.h" + +static void TimerCallback(TimerHandle_t timer) +{ + volatile int *count; + count = (volatile int *)pvTimerGetTimerID( timer ); + (*count)++; + printf("Callback timer %p count %p = %d\n", timer, count, *count); +} + +void OneshotTimersTest(void) +{ + volatile int count = 0; + TimerHandle_t oneshot = xTimerCreate("oneshot", 100 / portTICK_PERIOD_MS, pdFALSE, + (void *)&count, TimerCallback); + TEST_ASSERT(oneshot); + TEST_ASSERT_EQUAL(pdFALSE, xTimerIsTimerActive(oneshot)); + TEST_ASSERT_EQUAL(0, count); + + TEST_ASSERT( xTimerStart(oneshot, 1) ); + /* give the timer task a chance to process the message */ + vTaskDelay(2); + + TEST_ASSERT_EQUAL(pdTRUE, xTimerIsTimerActive(oneshot)); + TEST_ASSERT_EQUAL(0, count); + + /* 2.5 timer periods*/ + vTaskDelay(250 / portTICK_PERIOD_MS); + + TEST_ASSERT_EQUAL(1, count); + TEST_ASSERT_EQUAL(pdFALSE, xTimerIsTimerActive(oneshot)); + + TEST_ASSERT( xTimerDelete(oneshot, 1) ); + + printf("OneshotTimersTest end\n"); + while(1) + { + vTaskDelay(200); + } +} + +void RecurringTimersTest(void) +{ + volatile int count = 0; + TimerHandle_t recurring = xTimerCreate("oneshot", 100 / portTICK_PERIOD_MS, pdTRUE, + (void *)&count, TimerCallback); + TEST_ASSERT(recurring); + TEST_ASSERT_EQUAL(pdFALSE, xTimerIsTimerActive(recurring)); + TEST_ASSERT_EQUAL(0, count); + TEST_ASSERT( xTimerStart(recurring, 1) ); + + /* let timer task process the queue*/ + vTaskDelay(2); + TEST_ASSERT_EQUAL(pdTRUE, xTimerIsTimerActive(recurring)); + TEST_ASSERT_EQUAL(0, count); + + /*2.5 timer periods*/ + vTaskDelay(250 / portTICK_PERIOD_MS); + + TEST_ASSERT_EQUAL(2, count); + TEST_ASSERT_EQUAL(pdTRUE, xTimerIsTimerActive(recurring)); + + TEST_ASSERT( xTimerStop(recurring, 1) ); + + TEST_ASSERT_EQUAL(2, count); + + /* One more timer period*/ + vTaskDelay(100 / portTICK_PERIOD_MS); + + /* hasn't gone up*/ + TEST_ASSERT_EQUAL(2, count); + TEST_ASSERT_EQUAL(pdFALSE, xTimerIsTimerActive(recurring)); + TEST_ASSERT( xTimerDelete(recurring, 1) ); + + printf("RecurringTimersTest end\n"); + while(1) + { + vTaskDelay(200); + } +} + +void StaticTimersTest(void) +{ + /*进入临界区*/ + taskENTER_CRITICAL(); + StaticTimer_t static_timer; + TimerHandle_t created_timer; + volatile int count = 0; + + created_timer = xTimerCreateStatic("oneshot", 1000 / portTICK_PERIOD_MS, + pdTRUE, + (void *)&count, + TimerCallback, + &static_timer); + /*Start Timer*/ + xTimerStart(created_timer, 1); + + TEST_ASSERT_NOT_NULL(created_timer); + /*退出临界区*/ + taskEXIT_CRITICAL(); + + printf("StaticTimersTest end\r\n"); + while(1) + { + vTaskDelay(200); + } +} diff --git a/example/freertos_test/unity.c b/example/freertos_test/unity.c new file mode 100644 index 0000000000000000000000000000000000000000..652f1c04536330cc07259c0b32c5fa075a5727ea --- /dev/null +++ b/example/freertos_test/unity.c @@ -0,0 +1,2110 @@ +/* ========================================================================= + Unity Project - A Test Framework for C + Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +============================================================================ */ + +#include "unity.h" +#include + +#ifdef AVR +#include +#else +#define PROGMEM +#endif + +/* If omitted from header, declare overrideable prototypes here so they're ready for use */ +#ifdef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION +void UNITY_OUTPUT_CHAR(int); +#endif + +/* Helpful macros for us to use here in Assert functions */ +#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } +#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; UNITY_OUTPUT_FLUSH(); TEST_ABORT(); } +#define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) TEST_ABORT() + +struct UNITY_STORAGE_T Unity; + +#ifdef UNITY_OUTPUT_COLOR +const char PROGMEM UnityStrOk[] = "\033[42mOK\033[00m"; +const char PROGMEM UnityStrPass[] = "\033[42mPASS\033[00m"; +const char PROGMEM UnityStrFail[] = "\033[41mFAIL\033[00m"; +const char PROGMEM UnityStrIgnore[] = "\033[43mIGNORE\033[00m"; +#else +const char PROGMEM UnityStrOk[] = "OK"; +const char PROGMEM UnityStrPass[] = "PASS"; +const char PROGMEM UnityStrFail[] = "FAIL"; +const char PROGMEM UnityStrIgnore[] = "IGNORE"; +#endif +static const char PROGMEM UnityStrNull[] = "NULL"; +static const char PROGMEM UnityStrSpacer[] = ". "; +static const char PROGMEM UnityStrExpected[] = " Expected "; +static const char PROGMEM UnityStrWas[] = " Was "; +static const char PROGMEM UnityStrGt[] = " to be greater than "; +static const char PROGMEM UnityStrLt[] = " to be less than "; +static const char PROGMEM UnityStrOrEqual[] = "or equal to "; +static const char PROGMEM UnityStrNotEqual[] = " to be not equal to "; +static const char PROGMEM UnityStrElement[] = " Element "; +static const char PROGMEM UnityStrByte[] = " Byte "; +static const char PROGMEM UnityStrMemory[] = " Memory Mismatch."; +static const char PROGMEM UnityStrDelta[] = " Values Not Within Delta "; +static const char PROGMEM UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless."; +static const char PROGMEM UnityStrNullPointerForExpected[] = " Expected pointer to be NULL"; +static const char PROGMEM UnityStrNullPointerForActual[] = " Actual pointer was NULL"; +#ifndef UNITY_EXCLUDE_FLOAT +static const char PROGMEM UnityStrNot[] = "Not "; +static const char PROGMEM UnityStrInf[] = "Infinity"; +static const char PROGMEM UnityStrNegInf[] = "Negative Infinity"; +static const char PROGMEM UnityStrNaN[] = "NaN"; +static const char PROGMEM UnityStrDet[] = "Determinate"; +static const char PROGMEM UnityStrInvalidFloatTrait[] = "Invalid Float Trait"; +#endif +const char PROGMEM UnityStrErrShorthand[] = "Unity Shorthand Support Disabled"; +const char PROGMEM UnityStrErrFloat[] = "Unity Floating Point Disabled"; +const char PROGMEM UnityStrErrDouble[] = "Unity Double Precision Disabled"; +const char PROGMEM UnityStrErr64[] = "Unity 64-bit Support Disabled"; +static const char PROGMEM UnityStrBreaker[] = "-----------------------"; +static const char PROGMEM UnityStrResultsTests[] = " Tests "; +static const char PROGMEM UnityStrResultsFailures[] = " Failures "; +static const char PROGMEM UnityStrResultsIgnored[] = " Ignored "; +#ifndef UNITY_EXCLUDE_DETAILS +static const char PROGMEM UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " "; +static const char PROGMEM UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " "; +#endif +/*----------------------------------------------- + * Pretty Printers & Test Result Output Handlers + *-----------------------------------------------*/ + +/*-----------------------------------------------*/ +/* Local helper function to print characters. */ +static void UnityPrintChar(const char* pch) +{ + /* printable characters plus CR & LF are printed */ + if ((*pch <= 126) && (*pch >= 32)) + { + UNITY_OUTPUT_CHAR(*pch); + } + /* write escaped carriage returns */ + else if (*pch == 13) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('r'); + } + /* write escaped line feeds */ + else if (*pch == 10) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('n'); + } + /* unprintable characters are shown as codes */ + else + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)*pch, 2); + } +} + +/*-----------------------------------------------*/ +/* Local helper function to print ANSI escape strings e.g. "\033[42m". */ +#ifdef UNITY_OUTPUT_COLOR +static UNITY_UINT UnityPrintAnsiEscapeString(const char* string) +{ + const char* pch = string; + UNITY_UINT count = 0; + + while (*pch && (*pch != 'm')) + { + UNITY_OUTPUT_CHAR(*pch); + pch++; + count++; + } + UNITY_OUTPUT_CHAR('m'); + count++; + + return count; +} +#endif + +/*-----------------------------------------------*/ +void UnityPrint(const char* string) +{ + const char* pch = string; + + if (pch != NULL) + { + while (*pch) + { +#ifdef UNITY_OUTPUT_COLOR + /* print ANSI escape code */ + if ((*pch == 27) && (*(pch + 1) == '[')) + { + pch += UnityPrintAnsiEscapeString(pch); + continue; + } +#endif + UnityPrintChar(pch); + pch++; + } + } +} +/*-----------------------------------------------*/ +void UnityPrintLen(const char* string, const UNITY_UINT32 length) +{ + const char* pch = string; + + if (pch != NULL) + { + while (*pch && ((UNITY_UINT32)(pch - string) < length)) + { + /* printable characters plus CR & LF are printed */ + if ((*pch <= 126) && (*pch >= 32)) + { + UNITY_OUTPUT_CHAR(*pch); + } + /* write escaped carriage returns */ + else if (*pch == 13) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('r'); + } + /* write escaped line feeds */ + else if (*pch == 10) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('n'); + } + /* unprintable characters are shown as codes */ + else + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)*pch, 2); + } + pch++; + } + } +} + +/*-----------------------------------------------*/ +void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style) +{ + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + if (style == UNITY_DISPLAY_STYLE_CHAR) + { + /* printable characters plus CR & LF are printed */ + UNITY_OUTPUT_CHAR('\''); + if ((number <= 126) && (number >= 32)) + { + UNITY_OUTPUT_CHAR((int)number); + } + /* write escaped carriage returns */ + else if (number == 13) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('r'); + } + /* write escaped line feeds */ + else if (number == 10) + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('n'); + } + /* unprintable characters are shown as codes */ + else + { + UNITY_OUTPUT_CHAR('\\'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)number, 2); + } + UNITY_OUTPUT_CHAR('\''); + } + else + { + UnityPrintNumber(number); + } + } + else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT) + { + UnityPrintNumberUnsigned((UNITY_UINT)number); + } + else + { + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)number, (char)((style & 0xF) * 2)); + } +} + +/*-----------------------------------------------*/ +void UnityPrintNumber(const UNITY_INT number_to_print) +{ + UNITY_UINT number = (UNITY_UINT)number_to_print; + + if (number_to_print < 0) + { + /* A negative number, including MIN negative */ + UNITY_OUTPUT_CHAR('-'); + number = (~number) + 1; + } + UnityPrintNumberUnsigned(number); +} + +/*----------------------------------------------- + * basically do an itoa using as little ram as possible */ +void UnityPrintNumberUnsigned(const UNITY_UINT number) +{ + UNITY_UINT divisor = 1; + + /* figure out initial divisor */ + while (number / divisor > 9) + { + divisor *= 10; + } + + /* now mod and print, then divide divisor */ + do + { + UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10))); + divisor /= 10; + } while (divisor > 0); +} + +/*-----------------------------------------------*/ +void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print) +{ + int nibble; + char nibbles = nibbles_to_print; + + if ((unsigned)nibbles > UNITY_MAX_NIBBLES) + { + nibbles = UNITY_MAX_NIBBLES; + } + + while (nibbles > 0) + { + nibbles--; + nibble = (int)(number >> (nibbles * 4)) & 0x0F; + if (nibble <= 9) + { + UNITY_OUTPUT_CHAR((char)('0' + nibble)); + } + else + { + UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble)); + } + } +} + +/*-----------------------------------------------*/ +void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number) +{ + UNITY_UINT current_bit = (UNITY_UINT)1 << (UNITY_INT_WIDTH - 1); + UNITY_INT32 i; + + for (i = 0; i < UNITY_INT_WIDTH; i++) + { + if (current_bit & mask) + { + if (current_bit & number) + { + UNITY_OUTPUT_CHAR('1'); + } + else + { + UNITY_OUTPUT_CHAR('0'); + } + } + else + { + UNITY_OUTPUT_CHAR('X'); + } + current_bit = current_bit >> 1; + } +} + +/*-----------------------------------------------*/ +#ifndef UNITY_EXCLUDE_FLOAT_PRINT +/* + * This function prints a floating-point value in a format similar to + * printf("%.7g") on a single-precision machine or printf("%.9g") on a + * double-precision machine. The 7th digit won't always be totally correct + * in single-precision operation (for that level of accuracy, a more + * complicated algorithm would be needed). + */ +void UnityPrintFloat(const UNITY_DOUBLE input_number) +{ +#ifdef UNITY_INCLUDE_DOUBLE + static const int sig_digits = 9; + static const UNITY_INT32 min_scaled = 100000000; + static const UNITY_INT32 max_scaled = 1000000000; +#else + static const int sig_digits = 7; + static const UNITY_INT32 min_scaled = 1000000; + static const UNITY_INT32 max_scaled = 10000000; +#endif + + UNITY_DOUBLE number = input_number; + + /* print minus sign (does not handle negative zero) */ + if (number < 0.0f) + { + UNITY_OUTPUT_CHAR('-'); + number = -number; + } + + /* handle zero, NaN, and +/- infinity */ + if (number == 0.0f) + { + UnityPrint("0"); + } + else if (isnan(number)) + { + UnityPrint("nan"); + } + else if (isinf(number)) + { + UnityPrint("inf"); + } + else + { + UNITY_INT32 n_int = 0, n; + int exponent = 0; + int decimals, digits; + char buf[16] = {0}; + + /* + * Scale up or down by powers of 10. To minimize rounding error, + * start with a factor/divisor of 10^10, which is the largest + * power of 10 that can be represented exactly. Finally, compute + * (exactly) the remaining power of 10 and perform one more + * multiplication or division. + */ + if (number < 1.0f) + { + UNITY_DOUBLE factor = 1.0f; + + while (number < (UNITY_DOUBLE)max_scaled / 1e10f) { number *= 1e10f; exponent -= 10; } + while (number * factor < (UNITY_DOUBLE)min_scaled) { factor *= 10.0f; exponent--; } + + number *= factor; + } + else if (number > (UNITY_DOUBLE)max_scaled) + { + UNITY_DOUBLE divisor = 1.0f; + + while (number > (UNITY_DOUBLE)min_scaled * 1e10f) { number /= 1e10f; exponent += 10; } + while (number / divisor > (UNITY_DOUBLE)max_scaled) { divisor *= 10.0f; exponent++; } + + number /= divisor; + } + else + { + /* + * In this range, we can split off the integer part before + * doing any multiplications. This reduces rounding error by + * freeing up significant bits in the fractional part. + */ + UNITY_DOUBLE factor = 1.0f; + n_int = (UNITY_INT32)number; + number -= (UNITY_DOUBLE)n_int; + + while (n_int < min_scaled) { n_int *= 10; factor *= 10.0f; exponent--; } + + number *= factor; + } + + /* round to nearest integer */ + n = ((UNITY_INT32)(number + number) + 1) / 2; + +#ifndef UNITY_ROUND_TIES_AWAY_FROM_ZERO + /* round to even if exactly between two integers */ + if ((n & 1) && (((UNITY_DOUBLE)n - number) == 0.5f)) + n--; +#endif + + n += n_int; + + if (n >= max_scaled) + { + n = min_scaled; + exponent++; + } + + /* determine where to place decimal point */ + decimals = ((exponent <= 0) && (exponent >= -(sig_digits + 3))) ? (-exponent) : (sig_digits - 1); + exponent += decimals; + + /* truncate trailing zeroes after decimal point */ + while ((decimals > 0) && ((n % 10) == 0)) + { + n /= 10; + decimals--; + } + + /* build up buffer in reverse order */ + digits = 0; + while ((n != 0) || (digits <= decimals)) + { + buf[digits++] = (char)('0' + n % 10); + n /= 10; + } + while (digits > 0) + { + if (digits == decimals) { UNITY_OUTPUT_CHAR('.'); } + UNITY_OUTPUT_CHAR(buf[--digits]); + } + + /* print exponent if needed */ + if (exponent != 0) + { + UNITY_OUTPUT_CHAR('e'); + + if (exponent < 0) + { + UNITY_OUTPUT_CHAR('-'); + exponent = -exponent; + } + else + { + UNITY_OUTPUT_CHAR('+'); + } + + digits = 0; + while ((exponent != 0) || (digits < 2)) + { + buf[digits++] = (char)('0' + exponent % 10); + exponent /= 10; + } + while (digits > 0) + { + UNITY_OUTPUT_CHAR(buf[--digits]); + } + } + } +} +#endif /* ! UNITY_EXCLUDE_FLOAT_PRINT */ + +/*-----------------------------------------------*/ +static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line) +{ +#ifdef UNITY_OUTPUT_FOR_ECLIPSE + UNITY_OUTPUT_CHAR('('); + UnityPrint(file); + UNITY_OUTPUT_CHAR(':'); + UnityPrintNumber((UNITY_INT)line); + UNITY_OUTPUT_CHAR(')'); + UNITY_OUTPUT_CHAR(' '); + UnityPrint(Unity.CurrentTestName); + UNITY_OUTPUT_CHAR(':'); +#else +#ifdef UNITY_OUTPUT_FOR_IAR_WORKBENCH + UnityPrint("'); + UnityPrint(Unity.CurrentTestName); + UnityPrint(" "); +#else +#ifdef UNITY_OUTPUT_FOR_QT_CREATOR + UnityPrint("file://"); + UnityPrint(file); + UNITY_OUTPUT_CHAR(':'); + UnityPrintNumber((UNITY_INT)line); + UNITY_OUTPUT_CHAR(' '); + UnityPrint(Unity.CurrentTestName); + UNITY_OUTPUT_CHAR(':'); +#else + UnityPrint(file); + UNITY_OUTPUT_CHAR(':'); + UnityPrintNumber((UNITY_INT)line); + UNITY_OUTPUT_CHAR(':'); + UnityPrint(Unity.CurrentTestName); + UNITY_OUTPUT_CHAR(':'); +#endif +#endif +#endif +} + +/*-----------------------------------------------*/ +static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line) +{ + UnityTestResultsBegin(Unity.TestFile, line); + UnityPrint(UnityStrFail); + UNITY_OUTPUT_CHAR(':'); +} + +/*-----------------------------------------------*/ +void UnityConcludeTest(void) +{ + if (Unity.CurrentTestIgnored) + { + Unity.TestIgnores++; + } + else if (!Unity.CurrentTestFailed) + { + UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber); + UnityPrint(UnityStrPass); + } + else + { + Unity.TestFailures++; + } + + Unity.CurrentTestFailed = 0; + Unity.CurrentTestIgnored = 0; + UNITY_PRINT_EXEC_TIME(); + UNITY_PRINT_EOL(); + UNITY_FLUSH_CALL(); +} + +/*-----------------------------------------------*/ +static void UnityAddMsgIfSpecified(const char* msg) +{ + if (msg) + { + UnityPrint(UnityStrSpacer); + +#ifdef UNITY_PRINT_TEST_CONTEXT + UNITY_PRINT_TEST_CONTEXT(); +#endif +#ifndef UNITY_EXCLUDE_DETAILS + if (Unity.CurrentDetail1) + { + UnityPrint(UnityStrDetail1Name); + UnityPrint(Unity.CurrentDetail1); + if (Unity.CurrentDetail2) + { + UnityPrint(UnityStrDetail2Name); + UnityPrint(Unity.CurrentDetail2); + } + UnityPrint(UnityStrSpacer); + } +#endif + UnityPrint(msg); + } +} + +/*-----------------------------------------------*/ +static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual) +{ + UnityPrint(UnityStrExpected); + if (expected != NULL) + { + UNITY_OUTPUT_CHAR('\''); + UnityPrint(expected); + UNITY_OUTPUT_CHAR('\''); + } + else + { + UnityPrint(UnityStrNull); + } + UnityPrint(UnityStrWas); + if (actual != NULL) + { + UNITY_OUTPUT_CHAR('\''); + UnityPrint(actual); + UNITY_OUTPUT_CHAR('\''); + } + else + { + UnityPrint(UnityStrNull); + } +} + +/*-----------------------------------------------*/ +static void UnityPrintExpectedAndActualStringsLen(const char* expected, + const char* actual, + const UNITY_UINT32 length) +{ + UnityPrint(UnityStrExpected); + if (expected != NULL) + { + UNITY_OUTPUT_CHAR('\''); + UnityPrintLen(expected, length); + UNITY_OUTPUT_CHAR('\''); + } + else + { + UnityPrint(UnityStrNull); + } + UnityPrint(UnityStrWas); + if (actual != NULL) + { + UNITY_OUTPUT_CHAR('\''); + UnityPrintLen(actual, length); + UNITY_OUTPUT_CHAR('\''); + } + else + { + UnityPrint(UnityStrNull); + } +} + +/*----------------------------------------------- + * Assertion & Control Helpers + *-----------------------------------------------*/ + +/*-----------------------------------------------*/ +static int UnityIsOneArrayNull(UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_LINE_TYPE lineNumber, + const char* msg) +{ + /* Both are NULL or same pointer */ + if (expected == actual) { return 0; } + + /* print and return true if just expected is NULL */ + if (expected == NULL) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrNullPointerForExpected); + UnityAddMsgIfSpecified(msg); + return 1; + } + + /* print and return true if just actual is NULL */ + if (actual == NULL) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrNullPointerForActual); + UnityAddMsgIfSpecified(msg); + return 1; + } + + return 0; /* return false if neither is NULL */ +} + +/*----------------------------------------------- + * Assertion Functions + *-----------------------------------------------*/ + +/*-----------------------------------------------*/ +void UnityAssertBits(const UNITY_INT mask, + const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if ((mask & expected) != (mask & actual)) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintMask((UNITY_UINT)mask, (UNITY_UINT)expected); + UnityPrint(UnityStrWas); + UnityPrintMask((UNITY_UINT)mask, (UNITY_UINT)actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertEqualNumber(const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if (expected != actual) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(expected, style); + UnityPrint(UnityStrWas); + UnityPrintNumberByStyle(actual, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, + const UNITY_INT actual, + const UNITY_COMPARISON_T compare, + const char *msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) +{ + int failed = 0; + RETURN_IF_FAIL_OR_IGNORE; + + if ((threshold == actual) && (compare & UNITY_EQUAL_TO)) { return; } + if ((threshold == actual)) { failed = 1; } + + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + if ((actual > threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } + if ((actual < threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } + } + else /* UINT or HEX */ + { + if (((UNITY_UINT)actual > (UNITY_UINT)threshold) && (compare & UNITY_SMALLER_THAN)) { failed = 1; } + if (((UNITY_UINT)actual < (UNITY_UINT)threshold) && (compare & UNITY_GREATER_THAN)) { failed = 1; } + } + + if (failed) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(actual, style); + if (compare & UNITY_GREATER_THAN) { UnityPrint(UnityStrGt); } + if (compare & UNITY_SMALLER_THAN) { UnityPrint(UnityStrLt); } + if (compare & UNITY_EQUAL_TO) { UnityPrint(UnityStrOrEqual); } + if (compare == UNITY_NOT_EQUAL) { UnityPrint(UnityStrNotEqual); } + UnityPrintNumberByStyle(threshold, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +#define UnityPrintPointlessAndBail() \ +{ \ + UnityTestResultsFailBegin(lineNumber); \ + UnityPrint(UnityStrPointless); \ + UnityAddMsgIfSpecified(msg); \ + UNITY_FAIL_AND_BAIL; } + +/*-----------------------------------------------*/ +void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style, + const UNITY_FLAGS_T flags) +{ + UNITY_UINT32 elements = num_elements; + unsigned int length = style & 0xF; + unsigned int increment = 0; + + RETURN_IF_FAIL_OR_IGNORE; + + if (num_elements == 0) + { + UnityPrintPointlessAndBail(); + } + + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + + if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) + { + UNITY_FAIL_AND_BAIL; + } + + while ((elements > 0) && (elements--)) + { + UNITY_INT expect_val; + UNITY_INT actual_val; + + switch (length) + { + case 1: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual; + increment = sizeof(UNITY_INT8); + break; + + case 2: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual; + increment = sizeof(UNITY_INT16); + break; + +#ifdef UNITY_SUPPORT_64 + case 8: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual; + increment = sizeof(UNITY_INT64); + break; +#endif + + default: /* default is length 4 bytes */ + case 4: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; + increment = sizeof(UNITY_INT32); + length = 4; + break; + } + + if (expect_val != actual_val) + { + if ((style & UNITY_DISPLAY_RANGE_UINT) && (length < (UNITY_INT_WIDTH / 8))) + { /* For UINT, remove sign extension (padding 1's) from signed type casts above */ + UNITY_INT mask = 1; + mask = (mask << 8 * length) - 1; + expect_val &= mask; + actual_val &= mask; + } + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrElement); + UnityPrintNumberUnsigned(num_elements - elements - 1); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(expect_val, style); + UnityPrint(UnityStrWas); + UnityPrintNumberByStyle(actual_val, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } + /* Walk through array by incrementing the pointers */ + if (flags == UNITY_ARRAY_TO_ARRAY) + { + expected = (UNITY_INTERNAL_PTR)((const char*)expected + increment); + } + actual = (UNITY_INTERNAL_PTR)((const char*)actual + increment); + } +} + +/*-----------------------------------------------*/ +#ifndef UNITY_EXCLUDE_FLOAT +/* Wrap this define in a function with variable types as float or double */ +#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \ + if (isinf(expected) && isinf(actual) && (((expected) < 0) == ((actual) < 0))) return 1; \ + if (UNITY_NAN_CHECK) return 1; \ + (diff) = (actual) - (expected); \ + if ((diff) < 0) (diff) = -(diff); \ + if ((delta) < 0) (delta) = -(delta); \ + return !(isnan(diff) || isinf(diff) || ((diff) > (delta))) + /* This first part of this condition will catch any NaN or Infinite values */ +#ifndef UNITY_NAN_NOT_EQUAL_NAN + #define UNITY_NAN_CHECK isnan(expected) && isnan(actual) +#else + #define UNITY_NAN_CHECK 0 +#endif + +#ifndef UNITY_EXCLUDE_FLOAT_PRINT + #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \ + { \ + UnityPrint(UnityStrExpected); \ + UnityPrintFloat(expected); \ + UnityPrint(UnityStrWas); \ + UnityPrintFloat(actual); } +#else + #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \ + UnityPrint(UnityStrDelta) +#endif /* UNITY_EXCLUDE_FLOAT_PRINT */ + +/*-----------------------------------------------*/ +static int UnityFloatsWithin(UNITY_FLOAT delta, UNITY_FLOAT expected, UNITY_FLOAT actual) +{ + UNITY_FLOAT diff; + UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); +} + +/*-----------------------------------------------*/ +void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags) +{ + UNITY_UINT32 elements = num_elements; + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_expected = expected; + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_actual = actual; + + RETURN_IF_FAIL_OR_IGNORE; + + if (elements == 0) + { + UnityPrintPointlessAndBail(); + } + + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + + if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) + { + UNITY_FAIL_AND_BAIL; + } + + while (elements--) + { + if (!UnityFloatsWithin(*ptr_expected * UNITY_FLOAT_PRECISION, *ptr_expected, *ptr_actual)) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrElement); + UnityPrintNumberUnsigned(num_elements - elements - 1); + UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)*ptr_expected, (UNITY_DOUBLE)*ptr_actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } + if (flags == UNITY_ARRAY_TO_ARRAY) + { + ptr_expected++; + } + ptr_actual++; + } +} + +/*-----------------------------------------------*/ +void UnityAssertFloatsWithin(const UNITY_FLOAT delta, + const UNITY_FLOAT expected, + const UNITY_FLOAT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + RETURN_IF_FAIL_OR_IGNORE; + + + if (!UnityFloatsWithin(delta, expected, actual)) + { + UnityTestResultsFailBegin(lineNumber); + UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)expected, (UNITY_DOUBLE)actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertFloatSpecial(const UNITY_FLOAT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLOAT_TRAIT_T style) +{ + const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet}; + UNITY_INT should_be_trait = ((UNITY_INT)style & 1); + UNITY_INT is_trait = !should_be_trait; + UNITY_INT trait_index = (UNITY_INT)(style >> 1); + + RETURN_IF_FAIL_OR_IGNORE; + + switch (style) + { + case UNITY_FLOAT_IS_INF: + case UNITY_FLOAT_IS_NOT_INF: + is_trait = isinf(actual) && (actual > 0); + break; + case UNITY_FLOAT_IS_NEG_INF: + case UNITY_FLOAT_IS_NOT_NEG_INF: + is_trait = isinf(actual) && (actual < 0); + break; + + case UNITY_FLOAT_IS_NAN: + case UNITY_FLOAT_IS_NOT_NAN: + is_trait = isnan(actual) ? 1 : 0; + break; + + case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */ + case UNITY_FLOAT_IS_NOT_DET: + is_trait = !isinf(actual) && !isnan(actual); + break; + + default: /* including UNITY_FLOAT_INVALID_TRAIT */ + trait_index = 0; + trait_names[0] = UnityStrInvalidFloatTrait; + break; + } + + if (is_trait != should_be_trait) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + if (!should_be_trait) + { + UnityPrint(UnityStrNot); + } + UnityPrint(trait_names[trait_index]); + UnityPrint(UnityStrWas); +#ifndef UNITY_EXCLUDE_FLOAT_PRINT + UnityPrintFloat((UNITY_DOUBLE)actual); +#else + if (should_be_trait) + { + UnityPrint(UnityStrNot); + } + UnityPrint(trait_names[trait_index]); +#endif + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +#endif /* not UNITY_EXCLUDE_FLOAT */ + +/*-----------------------------------------------*/ +#ifndef UNITY_EXCLUDE_DOUBLE +static int UnityDoublesWithin(UNITY_DOUBLE delta, UNITY_DOUBLE expected, UNITY_DOUBLE actual) +{ + UNITY_DOUBLE diff; + UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); +} + +/*-----------------------------------------------*/ +void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected, + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags) +{ + UNITY_UINT32 elements = num_elements; + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_expected = expected; + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_actual = actual; + + RETURN_IF_FAIL_OR_IGNORE; + + if (elements == 0) + { + UnityPrintPointlessAndBail(); + } + + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + + if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) + { + UNITY_FAIL_AND_BAIL; + } + + while (elements--) + { + if (!UnityDoublesWithin(*ptr_expected * UNITY_DOUBLE_PRECISION, *ptr_expected, *ptr_actual)) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrElement); + UnityPrintNumberUnsigned(num_elements - elements - 1); + UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(*ptr_expected, *ptr_actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } + if (flags == UNITY_ARRAY_TO_ARRAY) + { + ptr_expected++; + } + ptr_actual++; + } +} + +/*-----------------------------------------------*/ +void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, + const UNITY_DOUBLE expected, + const UNITY_DOUBLE actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if (!UnityDoublesWithin(delta, expected, actual)) + { + UnityTestResultsFailBegin(lineNumber); + UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLOAT_TRAIT_T style) +{ + const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet}; + UNITY_INT should_be_trait = ((UNITY_INT)style & 1); + UNITY_INT is_trait = !should_be_trait; + UNITY_INT trait_index = (UNITY_INT)(style >> 1); + + RETURN_IF_FAIL_OR_IGNORE; + + switch (style) + { + case UNITY_FLOAT_IS_INF: + case UNITY_FLOAT_IS_NOT_INF: + is_trait = isinf(actual) && (actual > 0); + break; + case UNITY_FLOAT_IS_NEG_INF: + case UNITY_FLOAT_IS_NOT_NEG_INF: + is_trait = isinf(actual) && (actual < 0); + break; + + case UNITY_FLOAT_IS_NAN: + case UNITY_FLOAT_IS_NOT_NAN: + is_trait = isnan(actual) ? 1 : 0; + break; + + case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */ + case UNITY_FLOAT_IS_NOT_DET: + is_trait = !isinf(actual) && !isnan(actual); + break; + + default: /* including UNITY_FLOAT_INVALID_TRAIT */ + trait_index = 0; + trait_names[0] = UnityStrInvalidFloatTrait; + break; + } + + if (is_trait != should_be_trait) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrExpected); + if (!should_be_trait) + { + UnityPrint(UnityStrNot); + } + UnityPrint(trait_names[trait_index]); + UnityPrint(UnityStrWas); +#ifndef UNITY_EXCLUDE_FLOAT_PRINT + UnityPrintFloat(actual); +#else + if (should_be_trait) + { + UnityPrint(UnityStrNot); + } + UnityPrint(trait_names[trait_index]); +#endif + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +#endif /* not UNITY_EXCLUDE_DOUBLE */ + +/*-----------------------------------------------*/ +void UnityAssertNumbersWithin(const UNITY_UINT delta, + const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style) +{ + RETURN_IF_FAIL_OR_IGNORE; + + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + if (actual > expected) + { + Unity.CurrentTestFailed = (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta); + } + else + { + Unity.CurrentTestFailed = (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta); + } + } + else + { + if ((UNITY_UINT)actual > (UNITY_UINT)expected) + { + Unity.CurrentTestFailed = (((UNITY_UINT)actual - (UNITY_UINT)expected) > delta); + } + else + { + Unity.CurrentTestFailed = (((UNITY_UINT)expected - (UNITY_UINT)actual) > delta); + } + } + + if (Unity.CurrentTestFailed) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrDelta); + UnityPrintNumberByStyle((UNITY_INT)delta, style); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(expected, style); + UnityPrint(UnityStrWas); + UnityPrintNumberByStyle(actual, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, + UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style, + const UNITY_FLAGS_T flags) +{ + UNITY_UINT32 elements = num_elements; + unsigned int length = style & 0xF; + unsigned int increment = 0; + + RETURN_IF_FAIL_OR_IGNORE; + + if (num_elements == 0) + { + UnityPrintPointlessAndBail(); + } + + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + + if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) + { + UNITY_FAIL_AND_BAIL; + } + + while ((elements > 0) && (elements--)) + { + UNITY_INT expect_val; + UNITY_INT actual_val; + + switch (length) + { + case 1: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual; + increment = sizeof(UNITY_INT8); + break; + + case 2: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual; + increment = sizeof(UNITY_INT16); + break; + +#ifdef UNITY_SUPPORT_64 + case 8: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual; + increment = sizeof(UNITY_INT64); + break; +#endif + + default: /* default is length 4 bytes */ + case 4: + expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; + actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; + increment = sizeof(UNITY_INT32); + length = 4; + break; + } + + if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) + { + if (actual_val > expect_val) + { + Unity.CurrentTestFailed = (((UNITY_UINT)actual_val - (UNITY_UINT)expect_val) > delta); + } + else + { + Unity.CurrentTestFailed = (((UNITY_UINT)expect_val - (UNITY_UINT)actual_val) > delta); + } + } + else + { + if ((UNITY_UINT)actual_val > (UNITY_UINT)expect_val) + { + Unity.CurrentTestFailed = (((UNITY_UINT)actual_val - (UNITY_UINT)expect_val) > delta); + } + else + { + Unity.CurrentTestFailed = (((UNITY_UINT)expect_val - (UNITY_UINT)actual_val) > delta); + } + } + + if (Unity.CurrentTestFailed) + { + if ((style & UNITY_DISPLAY_RANGE_UINT) && (length < (UNITY_INT_WIDTH / 8))) + { /* For UINT, remove sign extension (padding 1's) from signed type casts above */ + UNITY_INT mask = 1; + mask = (mask << 8 * length) - 1; + expect_val &= mask; + actual_val &= mask; + } + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrDelta); + UnityPrintNumberByStyle((UNITY_INT)delta, style); + UnityPrint(UnityStrElement); + UnityPrintNumberUnsigned(num_elements - elements - 1); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(expect_val, style); + UnityPrint(UnityStrWas); + UnityPrintNumberByStyle(actual_val, style); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } + /* Walk through array by incrementing the pointers */ + if (flags == UNITY_ARRAY_TO_ARRAY) + { + expected = (UNITY_INTERNAL_PTR)((const char*)expected + increment); + } + actual = (UNITY_INTERNAL_PTR)((const char*)actual + increment); + } +} + +/*-----------------------------------------------*/ +void UnityAssertEqualString(const char* expected, + const char* actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + UNITY_UINT32 i; + + RETURN_IF_FAIL_OR_IGNORE; + + /* if both pointers not null compare the strings */ + if (expected && actual) + { + for (i = 0; expected[i] || actual[i]; i++) + { + if (expected[i] != actual[i]) + { + Unity.CurrentTestFailed = 1; + break; + } + } + } + else + { /* handle case of one pointers being null (if both null, test should pass) */ + if (expected != actual) + { + Unity.CurrentTestFailed = 1; + } + } + + if (Unity.CurrentTestFailed) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrintExpectedAndActualStrings(expected, actual); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertEqualStringLen(const char* expected, + const char* actual, + const UNITY_UINT32 length, + const char* msg, + const UNITY_LINE_TYPE lineNumber) +{ + UNITY_UINT32 i; + + RETURN_IF_FAIL_OR_IGNORE; + + /* if both pointers not null compare the strings */ + if (expected && actual) + { + for (i = 0; (i < length) && (expected[i] || actual[i]); i++) + { + if (expected[i] != actual[i]) + { + Unity.CurrentTestFailed = 1; + break; + } + } + } + else + { /* handle case of one pointers being null (if both null, test should pass) */ + if (expected != actual) + { + Unity.CurrentTestFailed = 1; + } + } + + if (Unity.CurrentTestFailed) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrintExpectedAndActualStringsLen(expected, actual, length); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } +} + +/*-----------------------------------------------*/ +void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected, + const char** actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags) +{ + UNITY_UINT32 i = 0; + UNITY_UINT32 j = 0; + const char* expd = NULL; + const char* act = NULL; + + RETURN_IF_FAIL_OR_IGNORE; + + /* if no elements, it's an error */ + if (num_elements == 0) + { + UnityPrintPointlessAndBail(); + } + + if ((const void*)expected == (const void*)actual) + { + return; /* Both are NULL or same pointer */ + } + + if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) + { + UNITY_FAIL_AND_BAIL; + } + + if (flags != UNITY_ARRAY_TO_ARRAY) + { + expd = (const char*)expected; + } + + do + { + act = actual[j]; + if (flags == UNITY_ARRAY_TO_ARRAY) + { + expd = ((const char* const*)expected)[j]; + } + + /* if both pointers not null compare the strings */ + if (expd && act) + { + for (i = 0; expd[i] || act[i]; i++) + { + if (expd[i] != act[i]) + { + Unity.CurrentTestFailed = 1; + break; + } + } + } + else + { /* handle case of one pointers being null (if both null, test should pass) */ + if (expd != act) + { + Unity.CurrentTestFailed = 1; + } + } + + if (Unity.CurrentTestFailed) + { + UnityTestResultsFailBegin(lineNumber); + if (num_elements > 1) + { + UnityPrint(UnityStrElement); + UnityPrintNumberUnsigned(j); + } + UnityPrintExpectedAndActualStrings(expd, act); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } + } while (++j < num_elements); +} + +/*-----------------------------------------------*/ +void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 length, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags) +{ + UNITY_PTR_ATTRIBUTE const unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected; + UNITY_PTR_ATTRIBUTE const unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE const unsigned char*)actual; + UNITY_UINT32 elements = num_elements; + UNITY_UINT32 bytes; + + RETURN_IF_FAIL_OR_IGNORE; + + if ((elements == 0) || (length == 0)) + { + UnityPrintPointlessAndBail(); + } + + if (expected == actual) + { + return; /* Both are NULL or same pointer */ + } + + if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) + { + UNITY_FAIL_AND_BAIL; + } + + while (elements--) + { + bytes = length; + while (bytes--) + { + if (*ptr_exp != *ptr_act) + { + UnityTestResultsFailBegin(lineNumber); + UnityPrint(UnityStrMemory); + if (num_elements > 1) + { + UnityPrint(UnityStrElement); + UnityPrintNumberUnsigned(num_elements - elements - 1); + } + UnityPrint(UnityStrByte); + UnityPrintNumberUnsigned(length - bytes - 1); + UnityPrint(UnityStrExpected); + UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8); + UnityPrint(UnityStrWas); + UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8); + UnityAddMsgIfSpecified(msg); + UNITY_FAIL_AND_BAIL; + } + ptr_exp++; + ptr_act++; + } + if (flags == UNITY_ARRAY_TO_VAL) + { + ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected; + } + } +} + +/*-----------------------------------------------*/ + +static union +{ + UNITY_INT8 i8; + UNITY_INT16 i16; + UNITY_INT32 i32; +#ifdef UNITY_SUPPORT_64 + UNITY_INT64 i64; +#endif +#ifndef UNITY_EXCLUDE_FLOAT + float f; +#endif +#ifndef UNITY_EXCLUDE_DOUBLE + double d; +#endif +} UnityQuickCompare; + +UNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size) +{ + switch(size) + { + case 1: + UnityQuickCompare.i8 = (UNITY_INT8)num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i8); + + case 2: + UnityQuickCompare.i16 = (UNITY_INT16)num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i16); + +#ifdef UNITY_SUPPORT_64 + case 8: + UnityQuickCompare.i64 = (UNITY_INT64)num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i64); +#endif + + default: /* 4 bytes */ + UnityQuickCompare.i32 = (UNITY_INT32)num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i32); + } +} + +#ifndef UNITY_EXCLUDE_FLOAT +/*-----------------------------------------------*/ +UNITY_INTERNAL_PTR UnityFloatToPtr(const float num) +{ + UnityQuickCompare.f = num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.f); +} +#endif + +#ifndef UNITY_EXCLUDE_DOUBLE +/*-----------------------------------------------*/ +UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num) +{ + UnityQuickCompare.d = num; + return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.d); +} +#endif + +/*----------------------------------------------- + * printf helper function + *-----------------------------------------------*/ +#ifdef UNITY_INCLUDE_PRINT_FORMATTED +static void UnityPrintFVA(const char* format, va_list va) +{ + const char* pch = format; + if (pch != NULL) + { + while (*pch) + { + /* format identification character */ + if (*pch == '%') + { + pch++; + + if (pch != NULL) + { + switch (*pch) + { + case 'd': + case 'i': + { + const int number = va_arg(va, int); + UnityPrintNumber((UNITY_INT)number); + break; + } +#ifndef UNITY_EXCLUDE_FLOAT_PRINT + case 'f': + case 'g': + { + const double number = va_arg(va, double); + UnityPrintFloat((UNITY_DOUBLE)number); + break; + } +#endif + case 'u': + { + const unsigned int number = va_arg(va, unsigned int); + UnityPrintNumberUnsigned((UNITY_UINT)number); + break; + } + case 'b': + { + const unsigned int number = va_arg(va, unsigned int); + const UNITY_UINT mask = (UNITY_UINT)0 - (UNITY_UINT)1; + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('b'); + UnityPrintMask(mask, (UNITY_UINT)number); + break; + } + case 'x': + case 'X': + case 'p': + { + const unsigned int number = va_arg(va, unsigned int); + UNITY_OUTPUT_CHAR('0'); + UNITY_OUTPUT_CHAR('x'); + UnityPrintNumberHex((UNITY_UINT)number, 8); + break; + } + case 'c': + { + const int ch = va_arg(va, int); + UnityPrintChar((const char *)&ch); + break; + } + case 's': + { + const char * string = va_arg(va, const char *); + UnityPrint(string); + break; + } + case '%': + { + UnityPrintChar(pch); + break; + } + default: + { + /* print the unknown format character */ + UNITY_OUTPUT_CHAR('%'); + UnityPrintChar(pch); + break; + } + } + } + } +#ifdef UNITY_OUTPUT_COLOR + /* print ANSI escape code */ + else if ((*pch == 27) && (*(pch + 1) == '[')) + { + pch += UnityPrintAnsiEscapeString(pch); + continue; + } +#endif + else if (*pch == '\n') + { + UNITY_PRINT_EOL(); + } + else + { + UnityPrintChar(pch); + } + + pch++; + } + } +} + +void UnityPrintF(const UNITY_LINE_TYPE line, const char* format, ...) +{ + UnityTestResultsBegin(Unity.TestFile, line); + UnityPrint("INFO"); + if(format != NULL) + { + UnityPrint(": "); + va_list va; + va_start(va, format); + UnityPrintFVA(format, va); + va_end(va); + } + UNITY_PRINT_EOL(); +} +#endif /* ! UNITY_INCLUDE_PRINT_FORMATTED */ + + +/*----------------------------------------------- + * Control Functions + *-----------------------------------------------*/ + +/*-----------------------------------------------*/ +void UnityFail(const char* msg, const UNITY_LINE_TYPE line) +{ + RETURN_IF_FAIL_OR_IGNORE; + + UnityTestResultsBegin(Unity.TestFile, line); + UnityPrint(UnityStrFail); + if (msg != NULL) + { + UNITY_OUTPUT_CHAR(':'); + +#ifdef UNITY_PRINT_TEST_CONTEXT + UNITY_PRINT_TEST_CONTEXT(); +#endif +#ifndef UNITY_EXCLUDE_DETAILS + if (Unity.CurrentDetail1) + { + UnityPrint(UnityStrDetail1Name); + UnityPrint(Unity.CurrentDetail1); + if (Unity.CurrentDetail2) + { + UnityPrint(UnityStrDetail2Name); + UnityPrint(Unity.CurrentDetail2); + } + UnityPrint(UnityStrSpacer); + } +#endif + if (msg[0] != ' ') + { + UNITY_OUTPUT_CHAR(' '); + } + UnityPrint(msg); + } + + UNITY_FAIL_AND_BAIL; +} + +/*-----------------------------------------------*/ +void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line) +{ + RETURN_IF_FAIL_OR_IGNORE; + + UnityTestResultsBegin(Unity.TestFile, line); + UnityPrint(UnityStrIgnore); + if (msg != NULL) + { + UNITY_OUTPUT_CHAR(':'); + UNITY_OUTPUT_CHAR(' '); + UnityPrint(msg); + } + UNITY_IGNORE_AND_BAIL; +} + +/*-----------------------------------------------*/ +void UnityMessage(const char* msg, const UNITY_LINE_TYPE line) +{ + UnityTestResultsBegin(Unity.TestFile, line); + UnityPrint("INFO"); + if (msg != NULL) + { + UNITY_OUTPUT_CHAR(':'); + UNITY_OUTPUT_CHAR(' '); + UnityPrint(msg); + } + UNITY_PRINT_EOL(); +} + +/*-----------------------------------------------*/ +/* If we have not defined our own test runner, then include our default test runner to make life easier */ +#ifndef UNITY_SKIP_DEFAULT_RUNNER +void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum) +{ + Unity.CurrentTestName = FuncName; + Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum; + Unity.NumberOfTests++; + UNITY_CLR_DETAILS(); + UNITY_EXEC_TIME_START(); + if (TEST_PROTECT()) + { + // setUp(); + // Func(); + } + if (TEST_PROTECT()) + { + // tearDown(); + } + UNITY_EXEC_TIME_STOP(); + UnityConcludeTest(); +} +#endif + +/*-----------------------------------------------*/ +void UnitySetTestFile(const char* filename) +{ + Unity.TestFile = filename; +} + +/*-----------------------------------------------*/ +void UnityBegin(const char* filename) +{ + Unity.TestFile = filename; + Unity.CurrentTestName = NULL; + Unity.CurrentTestLineNumber = 0; + Unity.NumberOfTests = 0; + Unity.TestFailures = 0; + Unity.TestIgnores = 0; + Unity.CurrentTestFailed = 0; + Unity.CurrentTestIgnored = 0; + + UNITY_CLR_DETAILS(); + UNITY_OUTPUT_START(); +} + +/*-----------------------------------------------*/ +int UnityEnd(void) +{ + UNITY_PRINT_EOL(); + UnityPrint(UnityStrBreaker); + UNITY_PRINT_EOL(); + UnityPrintNumber((UNITY_INT)(Unity.NumberOfTests)); + UnityPrint(UnityStrResultsTests); + UnityPrintNumber((UNITY_INT)(Unity.TestFailures)); + UnityPrint(UnityStrResultsFailures); + UnityPrintNumber((UNITY_INT)(Unity.TestIgnores)); + UnityPrint(UnityStrResultsIgnored); + UNITY_PRINT_EOL(); + if (Unity.TestFailures == 0U) + { + UnityPrint(UnityStrOk); + } + else + { + UnityPrint(UnityStrFail); +#ifdef UNITY_DIFFERENTIATE_FINAL_FAIL + UNITY_OUTPUT_CHAR('E'); UNITY_OUTPUT_CHAR('D'); +#endif + } + UNITY_PRINT_EOL(); + UNITY_FLUSH_CALL(); + UNITY_OUTPUT_COMPLETE(); + return (int)(Unity.TestFailures); +} + +/*----------------------------------------------- + * Command Line Argument Support + *-----------------------------------------------*/ +#ifdef UNITY_USE_COMMAND_LINE_ARGS + +char* UnityOptionIncludeNamed = NULL; +char* UnityOptionExcludeNamed = NULL; +int UnityVerbosity = 1; + +/*-----------------------------------------------*/ +int UnityParseOptions(int argc, char** argv) +{ + int i; + UnityOptionIncludeNamed = NULL; + UnityOptionExcludeNamed = NULL; + + for (i = 1; i < argc; i++) + { + if (argv[i][0] == '-') + { + switch (argv[i][1]) + { + case 'l': /* list tests */ + return -1; + case 'n': /* include tests with name including this string */ + case 'f': /* an alias for -n */ + if (argv[i][2] == '=') + { + UnityOptionIncludeNamed = &argv[i][3]; + } + else if (++i < argc) + { + UnityOptionIncludeNamed = argv[i]; + } + else + { + UnityPrint("ERROR: No Test String to Include Matches For"); + UNITY_PRINT_EOL(); + return 1; + } + break; + case 'q': /* quiet */ + UnityVerbosity = 0; + break; + case 'v': /* verbose */ + UnityVerbosity = 2; + break; + case 'x': /* exclude tests with name including this string */ + if (argv[i][2] == '=') + { + UnityOptionExcludeNamed = &argv[i][3]; + } + else if (++i < argc) + { + UnityOptionExcludeNamed = argv[i]; + } + else + { + UnityPrint("ERROR: No Test String to Exclude Matches For"); + UNITY_PRINT_EOL(); + return 1; + } + break; + default: + UnityPrint("ERROR: Unknown Option "); + UNITY_OUTPUT_CHAR(argv[i][1]); + UNITY_PRINT_EOL(); + return 1; + } + } + } + + return 0; +} + +/*-----------------------------------------------*/ +int IsStringInBiggerString(const char* longstring, const char* shortstring) +{ + const char* lptr = longstring; + const char* sptr = shortstring; + const char* lnext = lptr; + + if (*sptr == '*') + { + return 1; + } + + while (*lptr) + { + lnext = lptr + 1; + + /* If they current bytes match, go on to the next bytes */ + while (*lptr && *sptr && (*lptr == *sptr)) + { + lptr++; + sptr++; + + /* We're done if we match the entire string or up to a wildcard */ + if (*sptr == '*') + return 1; + if (*sptr == ',') + return 1; + if (*sptr == '"') + return 1; + if (*sptr == '\'') + return 1; + if (*sptr == ':') + return 2; + if (*sptr == 0) + return 1; + } + + /* Otherwise we start in the long pointer 1 character further and try again */ + lptr = lnext; + sptr = shortstring; + } + + return 0; +} + +/*-----------------------------------------------*/ +int UnityStringArgumentMatches(const char* str) +{ + int retval; + const char* ptr1; + const char* ptr2; + const char* ptrf; + + /* Go through the options and get the substrings for matching one at a time */ + ptr1 = str; + while (ptr1[0] != 0) + { + if ((ptr1[0] == '"') || (ptr1[0] == '\'')) + { + ptr1++; + } + + /* look for the start of the next partial */ + ptr2 = ptr1; + ptrf = 0; + do + { + ptr2++; + if ((ptr2[0] == ':') && (ptr2[1] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ',')) + { + ptrf = &ptr2[1]; + } + } while ((ptr2[0] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ',')); + + while ((ptr2[0] != 0) && ((ptr2[0] == ':') || (ptr2[0] == '\'') || (ptr2[0] == '"') || (ptr2[0] == ','))) + { + ptr2++; + } + + /* done if complete filename match */ + retval = IsStringInBiggerString(Unity.TestFile, ptr1); + if (retval == 1) + { + return retval; + } + + /* done if testname match after filename partial match */ + if ((retval == 2) && (ptrf != 0)) + { + if (IsStringInBiggerString(Unity.CurrentTestName, ptrf)) + { + return 1; + } + } + + /* done if complete testname match */ + if (IsStringInBiggerString(Unity.CurrentTestName, ptr1) == 1) + { + return 1; + } + + ptr1 = ptr2; + } + + /* we couldn't find a match for any substrings */ + return 0; +} + +/*-----------------------------------------------*/ +int UnityTestMatches(void) +{ + /* Check if this test name matches the included test pattern */ + int retval; + if (UnityOptionIncludeNamed) + { + retval = UnityStringArgumentMatches(UnityOptionIncludeNamed); + } + else + { + retval = 1; + } + + /* Check if this test name matches the excluded test pattern */ + if (UnityOptionExcludeNamed) + { + if (UnityStringArgumentMatches(UnityOptionExcludeNamed)) + { + retval = 0; + } + } + + return retval; +} + +#endif /* UNITY_USE_COMMAND_LINE_ARGS */ +/*-----------------------------------------------*/ diff --git a/example/freertos_test/unity.h b/example/freertos_test/unity.h new file mode 100644 index 0000000000000000000000000000000000000000..338df0b55397710aefdabb0fbaa27a3159c298e4 --- /dev/null +++ b/example/freertos_test/unity.h @@ -0,0 +1,661 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#ifndef UNITY_FRAMEWORK_H +#define UNITY_FRAMEWORK_H +#define UNITY + +#define UNITY_VERSION_MAJOR 2 +#define UNITY_VERSION_MINOR 5 +#define UNITY_VERSION_BUILD 4 +#define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD) + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "unity_internals.h" + +/*------------------------------------------------------- + * Test Setup / Teardown + *-------------------------------------------------------*/ + +/* These functions are intended to be called before and after each test. + * If using unity directly, these will need to be provided for each test + * executable built. If you are using the test runner generator and/or + * Ceedling, these are optional. */ +void setUp(void); +void tearDown(void); + +/* These functions are intended to be called at the beginning and end of an + * entire test suite. suiteTearDown() is passed the number of tests that + * failed, and its return value becomes the exit code of main(). If using + * Unity directly, you're in charge of calling these if they are desired. + * If using Ceedling or the test runner generator, these will be called + * automatically if they exist. */ +void suiteSetUp(void); +int suiteTearDown(int num_failures); + +/*------------------------------------------------------- + * Test Reset and Verify + *-------------------------------------------------------*/ + +/* These functions are intended to be called before during tests in order + * to support complex test loops, etc. Both are NOT built into Unity. Instead + * the test runner generator will create them. resetTest will run teardown and + * setup again, verifying any end-of-test needs between. verifyTest will only + * run the verification. */ +void resetTest(void); +void verifyTest(void); + +/*------------------------------------------------------- + * Configuration Options + *------------------------------------------------------- + * All options described below should be passed as a compiler flag to all files using Unity. If you must add #defines, place them BEFORE the #include above. + + * Integers/longs/pointers + * - Unity attempts to automatically discover your integer sizes + * - define UNITY_EXCLUDE_STDINT_H to stop attempting to look in + * - define UNITY_EXCLUDE_LIMITS_H to stop attempting to look in + * - If you cannot use the automatic methods above, you can force Unity by using these options: + * - define UNITY_SUPPORT_64 + * - set UNITY_INT_WIDTH + * - set UNITY_LONG_WIDTH + * - set UNITY_POINTER_WIDTH + + * Floats + * - define UNITY_EXCLUDE_FLOAT to disallow floating point comparisons + * - define UNITY_FLOAT_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_FLOAT + * - define UNITY_FLOAT_TYPE to specify doubles instead of single precision floats + * - define UNITY_INCLUDE_DOUBLE to allow double floating point comparisons + * - define UNITY_EXCLUDE_DOUBLE to disallow double floating point comparisons (default) + * - define UNITY_DOUBLE_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_DOUBLE + * - define UNITY_DOUBLE_TYPE to specify something other than double + * - define UNITY_EXCLUDE_FLOAT_PRINT to trim binary size, won't print floating point values in errors + + * Output + * - by default, Unity prints to standard out with putchar. define UNITY_OUTPUT_CHAR(a) with a different function if desired + * - define UNITY_DIFFERENTIATE_FINAL_FAIL to print FAILED (vs. FAIL) at test end summary - for automated search for failure + + * Optimization + * - by default, line numbers are stored in unsigned shorts. Define UNITY_LINE_TYPE with a different type if your files are huge + * - by default, test and failure counters are unsigned shorts. Define UNITY_COUNTER_TYPE with a different type if you want to save space or have more than 65535 Tests. + + * Test Cases + * - define UNITY_SUPPORT_TEST_CASES to include the TEST_CASE macro, though really it's mostly about the runner generator script + + * Parameterized Tests + * - you'll want to create a define of TEST_CASE(...) which basically evaluates to nothing + + * Tests with Arguments + * - you'll want to define UNITY_USE_COMMAND_LINE_ARGS if you have the test runner passing arguments to Unity + + *------------------------------------------------------- + * Basic Fail and Ignore + *-------------------------------------------------------*/ + +#define TEST_FAIL_MESSAGE(message) UNITY_TEST_FAIL(__LINE__, (message)) +#define TEST_FAIL() UNITY_TEST_FAIL(__LINE__, NULL) +#define TEST_IGNORE_MESSAGE(message) UNITY_TEST_IGNORE(__LINE__, (message)) +#define TEST_IGNORE() UNITY_TEST_IGNORE(__LINE__, NULL) +#define TEST_MESSAGE(message) UnityMessage((message), __LINE__) +#define TEST_ONLY() +#ifdef UNITY_INCLUDE_PRINT_FORMATTED +#define TEST_PRINTF(message, ...) UnityPrintF(__LINE__, (message), __VA_ARGS__) +#endif + +/* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails. + * This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */ +#define TEST_PASS() TEST_ABORT() +#define TEST_PASS_MESSAGE(message) do { UnityMessage((message), __LINE__); TEST_ABORT(); } while(0) + +/* This macro does nothing, but it is useful for build tools (like Ceedling) to make use of this to figure out + * which files should be linked to in order to perform a test. Use it like TEST_FILE("sandwiches.c") */ +#define TEST_FILE(a) + +/*------------------------------------------------------- + * Test Asserts (simple) + *-------------------------------------------------------*/ + +/* Boolean */ +#define TEST_ASSERT(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expression Evaluated To FALSE") +#define TEST_ASSERT_TRUE(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expected TRUE Was FALSE") +#define TEST_ASSERT_UNLESS(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expression Evaluated To TRUE") +#define TEST_ASSERT_FALSE(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expected FALSE Was TRUE") +#define TEST_ASSERT_NULL(pointer) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, " Expected NULL") +#define TEST_ASSERT_NOT_NULL(pointer) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, " Expected Non-NULL") +#define TEST_ASSERT_EMPTY(pointer) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, " Expected Empty") +#define TEST_ASSERT_NOT_EMPTY(pointer) UNITY_TEST_ASSERT_NOT_EMPTY((pointer), __LINE__, " Expected Non-Empty") + +/* Integers (of all sizes) */ +#define TEST_ASSERT_EQUAL_INT(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_size_t(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX8(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX16(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX32(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX64(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_CHAR(expected, actual) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_BITS(mask, expected, actual) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(-1), (actual), __LINE__, NULL) +#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(0), (actual), __LINE__, NULL) +#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(-1), (actual), __LINE__, NULL) +#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(0), (actual), __LINE__, NULL) + +/* Integer Not Equal To (of all sizes) */ +#define TEST_ASSERT_NOT_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, NULL) + +/* Integer Greater Than/ Less Than (of all sizes) */ +#define TEST_ASSERT_GREATER_THAN(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_THAN_CHAR(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_CHAR((threshold), (actual), __LINE__, NULL) + +#define TEST_ASSERT_LESS_THAN(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_THAN_CHAR(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_CHAR((threshold), (actual), __LINE__, NULL) + +#define TEST_ASSERT_GREATER_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_GREATER_OR_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, NULL) + +#define TEST_ASSERT_LESS_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) +#define TEST_ASSERT_LESS_OR_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, NULL) + +/* Integer Ranges (of all sizes) */ +#define TEST_ASSERT_INT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_INT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_INT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT16_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_INT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT32_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_INT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT64_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_UINT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_UINT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT8_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_UINT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_UINT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_UINT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_size_t_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_HEX_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_HEX8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_HEX16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_HEX32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_HEX64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_CHAR_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_CHAR_WITHIN((delta), (expected), (actual), __LINE__, NULL) + +/* Integer Array Ranges (of all sizes) */ +#define TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_size_t_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) +#define TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL) + + +/* Structs and Strings */ +#define TEST_ASSERT_EQUAL_PTR(expected, actual) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_STRING(expected, actual) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_STRING_LEN((expected), (actual), (len), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_MEMORY(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_MEMORY((expected), (actual), (len), __LINE__, NULL) + +/* Arrays */ +#define TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_size_t_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_CHAR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) + +/* Arrays Compared To Single Value */ +#define TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_size_t(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_HEX(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_CHAR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_CHAR((expected), (actual), (num_elements), __LINE__, NULL) + +/* Floating Point (If Enabled) */ +#define TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_NOT_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN((actual), __LINE__, NULL) +#define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE((actual), __LINE__, NULL) + +/* Double (If Enabled) */ +#define TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_NOT_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, NULL) +#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, NULL) + +/* Shorthand */ +#ifdef UNITY_SHORTHAND_AS_OLD +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal") +#endif +#ifdef UNITY_SHORTHAND_AS_INT +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif +#ifdef UNITY_SHORTHAND_AS_MEM +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, NULL) +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif +#ifdef UNITY_SHORTHAND_AS_RAW +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, " Expected Equal") +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal") +#endif +#ifdef UNITY_SHORTHAND_AS_NONE +#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif + +/*------------------------------------------------------- + * Test Asserts (with additional messages) + *-------------------------------------------------------*/ + +/* Boolean */ +#define TEST_ASSERT_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, (message)) +#define TEST_ASSERT_TRUE_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, (message)) +#define TEST_ASSERT_UNLESS_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message)) +#define TEST_ASSERT_FALSE_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message)) +#define TEST_ASSERT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, (message)) +#define TEST_ASSERT_NOT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, (message)) +#define TEST_ASSERT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, (message)) +#define TEST_ASSERT_NOT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_EMPTY((pointer), __LINE__, (message)) + +/* Integers (of all sizes) */ +#define TEST_ASSERT_EQUAL_INT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_size_t_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_BITS_MESSAGE(mask, expected, actual, message) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_BITS_HIGH_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(-1), (actual), __LINE__, (message)) +#define TEST_ASSERT_BITS_LOW_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, (message)) +#define TEST_ASSERT_BIT_HIGH_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, (message)) +#define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_CHAR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, (message)) + +/* Integer Not Equal To (of all sizes) */ +#define TEST_ASSERT_NOT_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, (message)) + + +/* Integer Greater Than/ Less Than (of all sizes) */ +#define TEST_ASSERT_GREATER_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_THAN_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_CHAR((threshold), (actual), __LINE__, (message)) + +#define TEST_ASSERT_LESS_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_THAN_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_CHAR((threshold), (actual), __LINE__, (message)) + +#define TEST_ASSERT_GREATER_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_GREATER_OR_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, (message)) + +#define TEST_ASSERT_LESS_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message)) +#define TEST_ASSERT_LESS_OR_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, (message)) + +/* Integer Ranges (of all sizes) */ +#define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_INT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_INT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT16_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_INT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT32_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_INT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT64_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_UINT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_UINT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT8_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_UINT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_UINT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_UINT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_size_t_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_HEX_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_HEX8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_HEX16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_HEX32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_HEX64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_CHAR_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_CHAR_WITHIN((delta), (expected), (actual), __LINE__, (message)) + +/* Integer Array Ranges (of all sizes) */ +#define TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_INT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_size_t_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) +#define TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message)) + + +/* Structs and Strings */ +#define TEST_ASSERT_EQUAL_PTR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_STRING_LEN((expected), (actual), (len), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_MEMORY_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_MEMORY((expected), (actual), (len), __LINE__, (message)) + +/* Arrays */ +#define TEST_ASSERT_EQUAL_INT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_INT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_UINT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_size_t_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_HEX64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_PTR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_STRING_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_MEMORY_ARRAY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_CHAR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) + +/* Arrays Compared To Single Value*/ +#define TEST_ASSERT_EACH_EQUAL_INT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_INT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_INT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_INT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_INT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_UINT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_UINT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_UINT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_UINT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_UINT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_size_t_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_HEX_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_HEX8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_HEX16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_HEX32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_HEX64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_PTR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_STRING_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_MEMORY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_CHAR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_CHAR((expected), (actual), (num_elements), __LINE__, (message)) + +/* Floating Point (If Enabled) */ +#define TEST_ASSERT_FLOAT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_FLOAT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_FLOAT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN((actual), __LINE__, (message)) +#define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE((actual), __LINE__, (message)) + +/* Double (If Enabled) */ +#define TEST_ASSERT_DOUBLE_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_EACH_EQUAL_DOUBLE_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, (message)) +#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, (message)) + +/* Shorthand */ +#ifdef UNITY_SHORTHAND_AS_OLD +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message)) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, (message)) +#endif +#ifdef UNITY_SHORTHAND_AS_INT +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, message) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif +#ifdef UNITY_SHORTHAND_AS_MEM +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, message) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif +#ifdef UNITY_SHORTHAND_AS_RAW +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, message) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, message) +#endif +#ifdef UNITY_SHORTHAND_AS_NONE +#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand) +#endif + +/* end of UNITY_FRAMEWORK_H */ +#ifdef __cplusplus +} +#endif +#endif diff --git a/example/freertos_test/unity_internals.h b/example/freertos_test/unity_internals.h new file mode 100644 index 0000000000000000000000000000000000000000..35eb463e83473cb39a75b6962e0e648d15ef3f2b --- /dev/null +++ b/example/freertos_test/unity_internals.h @@ -0,0 +1,1061 @@ +/* ========================================== + Unity Project - A Test Framework for C + Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams + [Released under MIT License. Please refer to license.txt for details] +========================================== */ + +#ifndef UNITY_INTERNALS_H +#define UNITY_INTERNALS_H + +#ifdef UNITY_INCLUDE_CONFIG_H +#include "unity_config.h" +#endif + +#ifndef UNITY_EXCLUDE_SETJMP_H +#include +#endif + +#ifndef UNITY_EXCLUDE_MATH_H +#include +#endif + +#ifndef UNITY_EXCLUDE_STDDEF_H +#include +#endif + +#ifdef UNITY_INCLUDE_PRINT_FORMATTED +#include +#endif + +/* Unity Attempts to Auto-Detect Integer Types + * Attempt 1: UINT_MAX, ULONG_MAX in , or default to 32 bits + * Attempt 2: UINTPTR_MAX in , or default to same size as long + * The user may override any of these derived constants: + * UNITY_INT_WIDTH, UNITY_LONG_WIDTH, UNITY_POINTER_WIDTH */ +#ifndef UNITY_EXCLUDE_STDINT_H +#include +#endif + +#ifndef UNITY_EXCLUDE_LIMITS_H +#include +#endif + +#if defined(__GNUC__) || defined(__clang__) + #define UNITY_FUNCTION_ATTR(a) __attribute__((a)) +#else + #define UNITY_FUNCTION_ATTR(a) /* ignore */ +#endif + +#ifndef UNITY_NORETURN + #if defined(__cplusplus) + #if __cplusplus >= 201103L + #define UNITY_NORETURN [[ noreturn ]] + #endif + #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + #include + #define UNITY_NORETURN noreturn + #endif +#endif +#ifndef UNITY_NORETURN + #define UNITY_NORETURN UNITY_FUNCTION_ATTR(noreturn) +#endif + +/*------------------------------------------------------- + * Guess Widths If Not Specified + *-------------------------------------------------------*/ + +/* Determine the size of an int, if not already specified. + * We cannot use sizeof(int), because it is not yet defined + * at this stage in the translation of the C program. + * Also sizeof(int) does return the size in addressable units on all platforms, + * which may not necessarily be the size in bytes. + * Therefore, infer it from UINT_MAX if possible. */ +#ifndef UNITY_INT_WIDTH + #ifdef UINT_MAX + #if (UINT_MAX == 0xFFFF) + #define UNITY_INT_WIDTH (16) + #elif (UINT_MAX == 0xFFFFFFFF) + #define UNITY_INT_WIDTH (32) + #elif (UINT_MAX == 0xFFFFFFFFFFFFFFFF) + #define UNITY_INT_WIDTH (64) + #endif + #else /* Set to default */ + #define UNITY_INT_WIDTH (32) + #endif /* UINT_MAX */ +#endif + +/* Determine the size of a long, if not already specified. */ +#ifndef UNITY_LONG_WIDTH + #ifdef ULONG_MAX + #if (ULONG_MAX == 0xFFFF) + #define UNITY_LONG_WIDTH (16) + #elif (ULONG_MAX == 0xFFFFFFFF) + #define UNITY_LONG_WIDTH (32) + #elif (ULONG_MAX == 0xFFFFFFFFFFFFFFFF) + #define UNITY_LONG_WIDTH (64) + #endif + #else /* Set to default */ + #define UNITY_LONG_WIDTH (32) + #endif /* ULONG_MAX */ +#endif + +/* Determine the size of a pointer, if not already specified. */ +#ifndef UNITY_POINTER_WIDTH + #ifdef UINTPTR_MAX + #if (UINTPTR_MAX <= 0xFFFF) + #define UNITY_POINTER_WIDTH (16) + #elif (UINTPTR_MAX <= 0xFFFFFFFF) + #define UNITY_POINTER_WIDTH (32) + #elif (UINTPTR_MAX <= 0xFFFFFFFFFFFFFFFF) + #define UNITY_POINTER_WIDTH (64) + #endif + #else /* Set to default */ + #define UNITY_POINTER_WIDTH UNITY_LONG_WIDTH + #endif /* UINTPTR_MAX */ +#endif + +/*------------------------------------------------------- + * Int Support (Define types based on detected sizes) + *-------------------------------------------------------*/ + +#if (UNITY_INT_WIDTH == 32) + typedef unsigned char UNITY_UINT8; + typedef unsigned short UNITY_UINT16; + typedef unsigned int UNITY_UINT32; + typedef signed char UNITY_INT8; + typedef signed short UNITY_INT16; + typedef signed int UNITY_INT32; +#elif (UNITY_INT_WIDTH == 16) + typedef unsigned char UNITY_UINT8; + typedef unsigned int UNITY_UINT16; + typedef unsigned long UNITY_UINT32; + typedef signed char UNITY_INT8; + typedef signed int UNITY_INT16; + typedef signed long UNITY_INT32; +#else + #error Invalid UNITY_INT_WIDTH specified! (16 or 32 are supported) +#endif + +/*------------------------------------------------------- + * 64-bit Support + *-------------------------------------------------------*/ + +/* Auto-detect 64 Bit Support */ +#ifndef UNITY_SUPPORT_64 + #if UNITY_LONG_WIDTH == 64 || UNITY_POINTER_WIDTH == 64 + #define UNITY_SUPPORT_64 + #endif +#endif + +/* 64-Bit Support Dependent Configuration */ +#ifndef UNITY_SUPPORT_64 + /* No 64-bit Support */ + typedef UNITY_UINT32 UNITY_UINT; + typedef UNITY_INT32 UNITY_INT; + #define UNITY_MAX_NIBBLES (8) /* Maximum number of nibbles in a UNITY_(U)INT */ +#else + /* 64-bit Support */ + #if (UNITY_LONG_WIDTH == 32) + typedef unsigned long long UNITY_UINT64; + typedef signed long long UNITY_INT64; + #elif (UNITY_LONG_WIDTH == 64) + typedef unsigned long UNITY_UINT64; + typedef signed long UNITY_INT64; + #else + #error Invalid UNITY_LONG_WIDTH specified! (32 or 64 are supported) + #endif + typedef UNITY_UINT64 UNITY_UINT; + typedef UNITY_INT64 UNITY_INT; + #define UNITY_MAX_NIBBLES (16) /* Maximum number of nibbles in a UNITY_(U)INT */ +#endif + +/*------------------------------------------------------- + * Pointer Support + *-------------------------------------------------------*/ + +#if (UNITY_POINTER_WIDTH == 32) + #define UNITY_PTR_TO_INT UNITY_INT32 + #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX32 +#elif (UNITY_POINTER_WIDTH == 64) + #define UNITY_PTR_TO_INT UNITY_INT64 + #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX64 +#elif (UNITY_POINTER_WIDTH == 16) + #define UNITY_PTR_TO_INT UNITY_INT16 + #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX16 +#else + #error Invalid UNITY_POINTER_WIDTH specified! (16, 32 or 64 are supported) +#endif + +#ifndef UNITY_PTR_ATTRIBUTE + #define UNITY_PTR_ATTRIBUTE +#endif + +#ifndef UNITY_INTERNAL_PTR + #define UNITY_INTERNAL_PTR UNITY_PTR_ATTRIBUTE const void* +#endif + +/*------------------------------------------------------- + * Float Support + *-------------------------------------------------------*/ + +#ifdef UNITY_EXCLUDE_FLOAT + +/* No Floating Point Support */ +#ifndef UNITY_EXCLUDE_DOUBLE +#define UNITY_EXCLUDE_DOUBLE /* Remove double when excluding float support */ +#endif +#ifndef UNITY_EXCLUDE_FLOAT_PRINT +#define UNITY_EXCLUDE_FLOAT_PRINT +#endif + +#else + +/* Floating Point Support */ +#ifndef UNITY_FLOAT_PRECISION +#define UNITY_FLOAT_PRECISION (0.00001f) +#endif +#ifndef UNITY_FLOAT_TYPE +#define UNITY_FLOAT_TYPE float +#endif +typedef UNITY_FLOAT_TYPE UNITY_FLOAT; + +/* isinf & isnan macros should be provided by math.h */ +#ifndef isinf +/* The value of Inf - Inf is NaN */ +#define isinf(n) (isnan((n) - (n)) && !isnan(n)) +#endif + +#ifndef isnan +/* NaN is the only floating point value that does NOT equal itself. + * Therefore if n != n, then it is NaN. */ +#define isnan(n) ((n != n) ? 1 : 0) +#endif + +#endif + +/*------------------------------------------------------- + * Double Float Support + *-------------------------------------------------------*/ + +/* unlike float, we DON'T include by default */ +#if defined(UNITY_EXCLUDE_DOUBLE) || !defined(UNITY_INCLUDE_DOUBLE) + + /* No Floating Point Support */ + #ifndef UNITY_EXCLUDE_DOUBLE + #define UNITY_EXCLUDE_DOUBLE + #else + #undef UNITY_INCLUDE_DOUBLE + #endif + + #ifndef UNITY_EXCLUDE_FLOAT + #ifndef UNITY_DOUBLE_TYPE + #define UNITY_DOUBLE_TYPE double + #endif + typedef UNITY_FLOAT UNITY_DOUBLE; + /* For parameter in UnityPrintFloat(UNITY_DOUBLE), which aliases to double or float */ + #endif + +#else + + /* Double Floating Point Support */ + #ifndef UNITY_DOUBLE_PRECISION + #define UNITY_DOUBLE_PRECISION (1e-12) + #endif + + #ifndef UNITY_DOUBLE_TYPE + #define UNITY_DOUBLE_TYPE double + #endif + typedef UNITY_DOUBLE_TYPE UNITY_DOUBLE; + +#endif + +/*------------------------------------------------------- + * Output Method: stdout (DEFAULT) + *-------------------------------------------------------*/ +#ifndef UNITY_OUTPUT_CHAR + /* Default to using putchar, which is defined in stdio.h */ + #include + #define UNITY_OUTPUT_CHAR(a) (void)putchar(a) +#else + /* If defined as something else, make sure we declare it here so it's ready for use */ + #ifdef UNITY_OUTPUT_CHAR_HEADER_DECLARATION + extern void UNITY_OUTPUT_CHAR_HEADER_DECLARATION; + #endif +#endif + +#ifndef UNITY_OUTPUT_FLUSH + #ifdef UNITY_USE_FLUSH_STDOUT + /* We want to use the stdout flush utility */ + #include + #define UNITY_OUTPUT_FLUSH() (void)fflush(stdout) + #else + /* We've specified nothing, therefore flush should just be ignored */ + #define UNITY_OUTPUT_FLUSH() + #endif +#else + /* If defined as something else, make sure we declare it here so it's ready for use */ + #ifdef UNITY_OUTPUT_FLUSH_HEADER_DECLARATION + extern void UNITY_OUTPUT_FLUSH_HEADER_DECLARATION; + #endif +#endif + +#ifndef UNITY_OUTPUT_FLUSH +#define UNITY_FLUSH_CALL() +#else +#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH() +#endif + +#ifndef UNITY_PRINT_EOL +#define UNITY_PRINT_EOL() UNITY_OUTPUT_CHAR('\n') +#endif + +#ifndef UNITY_OUTPUT_START +#define UNITY_OUTPUT_START() +#endif + +#ifndef UNITY_OUTPUT_COMPLETE +#define UNITY_OUTPUT_COMPLETE() +#endif + +#ifdef UNITY_INCLUDE_EXEC_TIME + #if !defined(UNITY_EXEC_TIME_START) && \ + !defined(UNITY_EXEC_TIME_STOP) && \ + !defined(UNITY_PRINT_EXEC_TIME) && \ + !defined(UNITY_TIME_TYPE) + /* If none any of these macros are defined then try to provide a default implementation */ + + #if defined(UNITY_CLOCK_MS) + /* This is a simple way to get a default implementation on platforms that support getting a millisecond counter */ + #define UNITY_TIME_TYPE UNITY_UINT + #define UNITY_EXEC_TIME_START() Unity.CurrentTestStartTime = UNITY_CLOCK_MS() + #define UNITY_EXEC_TIME_STOP() Unity.CurrentTestStopTime = UNITY_CLOCK_MS() + #define UNITY_PRINT_EXEC_TIME() { \ + UNITY_UINT execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); \ + UnityPrint(" ("); \ + UnityPrintNumberUnsigned(execTimeMs); \ + UnityPrint(" ms)"); \ + } + #elif defined(_WIN32) + #include + #define UNITY_TIME_TYPE clock_t + #define UNITY_GET_TIME(t) t = (clock_t)((clock() * 1000) / CLOCKS_PER_SEC) + #define UNITY_EXEC_TIME_START() UNITY_GET_TIME(Unity.CurrentTestStartTime) + #define UNITY_EXEC_TIME_STOP() UNITY_GET_TIME(Unity.CurrentTestStopTime) + #define UNITY_PRINT_EXEC_TIME() { \ + UNITY_UINT execTimeMs = (Unity.CurrentTestStopTime - Unity.CurrentTestStartTime); \ + UnityPrint(" ("); \ + UnityPrintNumberUnsigned(execTimeMs); \ + UnityPrint(" ms)"); \ + } + #elif defined(__unix__) || defined(__APPLE__) + #include + #define UNITY_TIME_TYPE struct timespec + #define UNITY_GET_TIME(t) clock_gettime(CLOCK_MONOTONIC, &t) + #define UNITY_EXEC_TIME_START() UNITY_GET_TIME(Unity.CurrentTestStartTime) + #define UNITY_EXEC_TIME_STOP() UNITY_GET_TIME(Unity.CurrentTestStopTime) + #define UNITY_PRINT_EXEC_TIME() { \ + UNITY_UINT execTimeMs = ((Unity.CurrentTestStopTime.tv_sec - Unity.CurrentTestStartTime.tv_sec) * 1000L); \ + execTimeMs += ((Unity.CurrentTestStopTime.tv_nsec - Unity.CurrentTestStartTime.tv_nsec) / 1000000L); \ + UnityPrint(" ("); \ + UnityPrintNumberUnsigned(execTimeMs); \ + UnityPrint(" ms)"); \ + } + #endif + #endif +#endif + +#ifndef UNITY_EXEC_TIME_START +#define UNITY_EXEC_TIME_START() do{}while(0) +#endif + +#ifndef UNITY_EXEC_TIME_STOP +#define UNITY_EXEC_TIME_STOP() do{}while(0) +#endif + +#ifndef UNITY_TIME_TYPE +#define UNITY_TIME_TYPE UNITY_UINT +#endif + +#ifndef UNITY_PRINT_EXEC_TIME +#define UNITY_PRINT_EXEC_TIME() do{}while(0) +#endif + +/*------------------------------------------------------- + * Footprint + *-------------------------------------------------------*/ + +#ifndef UNITY_LINE_TYPE +#define UNITY_LINE_TYPE UNITY_UINT +#endif + +#ifndef UNITY_COUNTER_TYPE +#define UNITY_COUNTER_TYPE UNITY_UINT +#endif + +/*------------------------------------------------------- + * Internal Structs Needed + *-------------------------------------------------------*/ + +typedef void (*UnityTestFunction)(void); + +#define UNITY_DISPLAY_RANGE_INT (0x10) +#define UNITY_DISPLAY_RANGE_UINT (0x20) +#define UNITY_DISPLAY_RANGE_HEX (0x40) +#define UNITY_DISPLAY_RANGE_CHAR (0x80) + +typedef enum +{ + UNITY_DISPLAY_STYLE_INT = (UNITY_INT_WIDTH / 8) + UNITY_DISPLAY_RANGE_INT, + UNITY_DISPLAY_STYLE_INT8 = 1 + UNITY_DISPLAY_RANGE_INT, + UNITY_DISPLAY_STYLE_INT16 = 2 + UNITY_DISPLAY_RANGE_INT, + UNITY_DISPLAY_STYLE_INT32 = 4 + UNITY_DISPLAY_RANGE_INT, +#ifdef UNITY_SUPPORT_64 + UNITY_DISPLAY_STYLE_INT64 = 8 + UNITY_DISPLAY_RANGE_INT, +#endif + + UNITY_DISPLAY_STYLE_UINT = (UNITY_INT_WIDTH / 8) + UNITY_DISPLAY_RANGE_UINT, + UNITY_DISPLAY_STYLE_UINT8 = 1 + UNITY_DISPLAY_RANGE_UINT, + UNITY_DISPLAY_STYLE_UINT16 = 2 + UNITY_DISPLAY_RANGE_UINT, + UNITY_DISPLAY_STYLE_UINT32 = 4 + UNITY_DISPLAY_RANGE_UINT, +#ifdef UNITY_SUPPORT_64 + UNITY_DISPLAY_STYLE_UINT64 = 8 + UNITY_DISPLAY_RANGE_UINT, +#endif + + UNITY_DISPLAY_STYLE_HEX8 = 1 + UNITY_DISPLAY_RANGE_HEX, + UNITY_DISPLAY_STYLE_HEX16 = 2 + UNITY_DISPLAY_RANGE_HEX, + UNITY_DISPLAY_STYLE_HEX32 = 4 + UNITY_DISPLAY_RANGE_HEX, +#ifdef UNITY_SUPPORT_64 + UNITY_DISPLAY_STYLE_HEX64 = 8 + UNITY_DISPLAY_RANGE_HEX, +#endif + + UNITY_DISPLAY_STYLE_CHAR = 1 + UNITY_DISPLAY_RANGE_CHAR + UNITY_DISPLAY_RANGE_INT, + + UNITY_DISPLAY_STYLE_UNKNOWN +} UNITY_DISPLAY_STYLE_T; + +typedef enum +{ + UNITY_WITHIN = 0x0, + UNITY_EQUAL_TO = 0x1, + UNITY_GREATER_THAN = 0x2, + UNITY_GREATER_OR_EQUAL = 0x2 + UNITY_EQUAL_TO, + UNITY_SMALLER_THAN = 0x4, + UNITY_SMALLER_OR_EQUAL = 0x4 + UNITY_EQUAL_TO, + UNITY_NOT_EQUAL = 0x0, + UNITY_UNKNOWN +} UNITY_COMPARISON_T; + +#ifndef UNITY_EXCLUDE_FLOAT +typedef enum UNITY_FLOAT_TRAIT +{ + UNITY_FLOAT_IS_NOT_INF = 0, + UNITY_FLOAT_IS_INF, + UNITY_FLOAT_IS_NOT_NEG_INF, + UNITY_FLOAT_IS_NEG_INF, + UNITY_FLOAT_IS_NOT_NAN, + UNITY_FLOAT_IS_NAN, + UNITY_FLOAT_IS_NOT_DET, + UNITY_FLOAT_IS_DET, + UNITY_FLOAT_INVALID_TRAIT +} UNITY_FLOAT_TRAIT_T; +#endif + +typedef enum +{ + UNITY_ARRAY_TO_VAL = 0, + UNITY_ARRAY_TO_ARRAY, + UNITY_ARRAY_UNKNOWN +} UNITY_FLAGS_T; + +struct UNITY_STORAGE_T +{ + const char* TestFile; + const char* CurrentTestName; +#ifndef UNITY_EXCLUDE_DETAILS + const char* CurrentDetail1; + const char* CurrentDetail2; +#endif + UNITY_LINE_TYPE CurrentTestLineNumber; + UNITY_COUNTER_TYPE NumberOfTests; + UNITY_COUNTER_TYPE TestFailures; + UNITY_COUNTER_TYPE TestIgnores; + UNITY_COUNTER_TYPE CurrentTestFailed; + UNITY_COUNTER_TYPE CurrentTestIgnored; +#ifdef UNITY_INCLUDE_EXEC_TIME + UNITY_TIME_TYPE CurrentTestStartTime; + UNITY_TIME_TYPE CurrentTestStopTime; +#endif +#ifndef UNITY_EXCLUDE_SETJMP_H + jmp_buf AbortFrame; +#endif +}; + +extern struct UNITY_STORAGE_T Unity; + +/*------------------------------------------------------- + * Test Suite Management + *-------------------------------------------------------*/ + +void UnityBegin(const char* filename); +int UnityEnd(void); +void UnitySetTestFile(const char* filename); +void UnityConcludeTest(void); + +#ifndef RUN_TEST +void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum); +#else +#define UNITY_SKIP_DEFAULT_RUNNER +#endif + +/*------------------------------------------------------- + * Details Support + *-------------------------------------------------------*/ + +#ifdef UNITY_EXCLUDE_DETAILS +#define UNITY_CLR_DETAILS() +#define UNITY_SET_DETAIL(d1) +#define UNITY_SET_DETAILS(d1,d2) +#else +#define UNITY_CLR_DETAILS() { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; } +#define UNITY_SET_DETAIL(d1) { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = 0; } +#define UNITY_SET_DETAILS(d1,d2) { Unity.CurrentDetail1 = (d1); Unity.CurrentDetail2 = (d2); } + +#ifndef UNITY_DETAIL1_NAME +#define UNITY_DETAIL1_NAME "Function" +#endif + +#ifndef UNITY_DETAIL2_NAME +#define UNITY_DETAIL2_NAME "Argument" +#endif +#endif + +#ifdef UNITY_PRINT_TEST_CONTEXT +void UNITY_PRINT_TEST_CONTEXT(void); +#endif + +/*------------------------------------------------------- + * Test Output + *-------------------------------------------------------*/ + +void UnityPrint(const char* string); + +#ifdef UNITY_INCLUDE_PRINT_FORMATTED +void UnityPrintF(const UNITY_LINE_TYPE line, const char* format, ...); +#endif + +void UnityPrintLen(const char* string, const UNITY_UINT32 length); +void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number); +void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style); +void UnityPrintNumber(const UNITY_INT number_to_print); +void UnityPrintNumberUnsigned(const UNITY_UINT number); +void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print); + +#ifndef UNITY_EXCLUDE_FLOAT_PRINT +void UnityPrintFloat(const UNITY_DOUBLE input_number); +#endif + +/*------------------------------------------------------- + * Test Assertion Functions + *------------------------------------------------------- + * Use the macros below this section instead of calling + * these directly. The macros have a consistent naming + * convention and will pull in file and line information + * for you. */ + +void UnityAssertEqualNumber(const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); + +void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, + const UNITY_INT actual, + const UNITY_COMPARISON_T compare, + const char *msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); + +void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style, + const UNITY_FLAGS_T flags); + +void UnityAssertBits(const UNITY_INT mask, + const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + +void UnityAssertEqualString(const char* expected, + const char* actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + +void UnityAssertEqualStringLen(const char* expected, + const char* actual, + const UNITY_UINT32 length, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + +void UnityAssertEqualStringArray( UNITY_INTERNAL_PTR expected, + const char** actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags); + +void UnityAssertEqualMemory( UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 length, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags); + +void UnityAssertNumbersWithin(const UNITY_UINT delta, + const UNITY_INT expected, + const UNITY_INT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style); + +void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, + UNITY_INTERNAL_PTR expected, + UNITY_INTERNAL_PTR actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_DISPLAY_STYLE_T style, + const UNITY_FLAGS_T flags); + +#ifndef UNITY_EXCLUDE_SETJMP_H +UNITY_NORETURN void UnityFail(const char* message, const UNITY_LINE_TYPE line); +UNITY_NORETURN void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); +#else +void UnityFail(const char* message, const UNITY_LINE_TYPE line); +void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); +#endif + +void UnityMessage(const char* message, const UNITY_LINE_TYPE line); + +#ifndef UNITY_EXCLUDE_FLOAT +void UnityAssertFloatsWithin(const UNITY_FLOAT delta, + const UNITY_FLOAT expected, + const UNITY_FLOAT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + +void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, + UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags); + +void UnityAssertFloatSpecial(const UNITY_FLOAT actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLOAT_TRAIT_T style); +#endif + +#ifndef UNITY_EXCLUDE_DOUBLE +void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, + const UNITY_DOUBLE expected, + const UNITY_DOUBLE actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber); + +void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected, + UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual, + const UNITY_UINT32 num_elements, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLAGS_T flags); + +void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, + const char* msg, + const UNITY_LINE_TYPE lineNumber, + const UNITY_FLOAT_TRAIT_T style); +#endif + +/*------------------------------------------------------- + * Helpers + *-------------------------------------------------------*/ + +UNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size); +#ifndef UNITY_EXCLUDE_FLOAT +UNITY_INTERNAL_PTR UnityFloatToPtr(const float num); +#endif +#ifndef UNITY_EXCLUDE_DOUBLE +UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num); +#endif + +/*------------------------------------------------------- + * Error Strings We Might Need + *-------------------------------------------------------*/ + +extern const char UnityStrOk[]; +extern const char UnityStrPass[]; +extern const char UnityStrFail[]; +extern const char UnityStrIgnore[]; + +extern const char UnityStrErrFloat[]; +extern const char UnityStrErrDouble[]; +extern const char UnityStrErr64[]; +extern const char UnityStrErrShorthand[]; + +/*------------------------------------------------------- + * Test Running Macros + *-------------------------------------------------------*/ + +#ifndef UNITY_EXCLUDE_SETJMP_H +#define TEST_PROTECT() (setjmp(Unity.AbortFrame) == 0) +#define TEST_ABORT() longjmp(Unity.AbortFrame, 1) +#else +#define TEST_PROTECT() 1 +#define TEST_ABORT() return +#endif + +/* This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) */ +#ifndef RUN_TEST +#ifdef __STDC_VERSION__ +#if __STDC_VERSION__ >= 199901L +#define UNITY_SUPPORT_VARIADIC_MACROS +#endif +#endif +#ifdef UNITY_SUPPORT_VARIADIC_MACROS +#define RUN_TEST(...) RUN_TEST_AT_LINE(__VA_ARGS__, __LINE__, throwaway) +#define RUN_TEST_AT_LINE(func, line, ...) UnityDefaultTestRun(func, #func, line) +#endif +#endif + +/* If we can't do the tricky version, we'll just have to require them to always include the line number */ +#ifndef RUN_TEST +#ifdef CMOCK +#define RUN_TEST(func, num) UnityDefaultTestRun(func, #func, num) +#else +#define RUN_TEST(func) UnityDefaultTestRun(func, #func, __LINE__) +#endif +#endif + +#define TEST_LINE_NUM (Unity.CurrentTestLineNumber) +#define TEST_IS_IGNORED (Unity.CurrentTestIgnored) +#define UNITY_NEW_TEST(a) \ + Unity.CurrentTestName = (a); \ + Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)(__LINE__); \ + Unity.NumberOfTests++; + +#ifndef UNITY_BEGIN +#define UNITY_BEGIN() UnityBegin(__FILE__) +#endif + +#ifndef UNITY_END +#define UNITY_END() UnityEnd() +#endif + +#ifndef UNITY_SHORTHAND_AS_INT +#ifndef UNITY_SHORTHAND_AS_MEM +#ifndef UNITY_SHORTHAND_AS_NONE +#ifndef UNITY_SHORTHAND_AS_RAW +#define UNITY_SHORTHAND_AS_OLD +#endif +#endif +#endif +#endif + +/*----------------------------------------------- + * Command Line Argument Support + *-----------------------------------------------*/ + +#ifdef UNITY_USE_COMMAND_LINE_ARGS +int UnityParseOptions(int argc, char** argv); +int UnityTestMatches(void); +#endif + +/*------------------------------------------------------- + * Basic Fail and Ignore + *-------------------------------------------------------*/ + +#define UNITY_TEST_FAIL(line, message) UnityFail( (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_IGNORE(line, message) UnityIgnore( (message), (UNITY_LINE_TYPE)(line)) + +/*------------------------------------------------------- + * Test Asserts + *-------------------------------------------------------*/ + +#define UNITY_TEST_ASSERT(condition, line, message) do {if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message));}} while(0) +#define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) == 0), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_NOT_EMPTY(pointer, line, message) UNITY_TEST_ASSERT(((pointer[0]) != 0), (UNITY_LINE_TYPE)(line), (message)) + +#define UNITY_TEST_ASSERT_EQUAL_INT(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_EQUAL_INT8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_EQUAL_INT16(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_EQUAL_INT32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_EQUAL_UINT(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_EQUAL_UINT8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_EQUAL_UINT16(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_EQUAL_UINT32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_EQUAL_CHAR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) +#define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((UNITY_INT)(mask), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line)) + +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_NOT_EQUAL_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_GREATER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_GREATER_THAN_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_SMALLER_THAN_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 ) (threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16) (threshold), (UNITY_INT)(UNITY_INT16) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32) (threshold), (UNITY_INT)(UNITY_INT32) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 ) (threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT) (threshold), (UNITY_INT) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 ) (actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin( (delta), (UNITY_INT) (expected), (UNITY_INT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) +#define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) +#define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_INT16) (expected), (UNITY_INT)(UNITY_INT16) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) +#define UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_INT32) (expected), (UNITY_INT)(UNITY_INT32) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) +#define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin( (delta), (UNITY_INT) (expected), (UNITY_INT) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) +#define UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) +#define UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) +#define UNITY_TEST_ASSERT_UINT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) +#define UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) +#define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) +#define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) +#define UNITY_TEST_ASSERT_CHAR_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 ) (expected), (UNITY_INT)(UNITY_INT8 ) (actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR) + +#define UNITY_TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin( (delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT16)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT32)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT8 )(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), ((UNITY_UINT32)(num_elements)), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_ARRAY) + + +#define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_PTR_TO_INT)(expected), (UNITY_PTR_TO_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER) +#define UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len, line, message) UnityAssertEqualStringLen((const char*)(expected), (const char*)(actual), (UNITY_UINT32)(len), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), 1, (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) + +#define UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((UNITY_INTERNAL_PTR)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_ARRAY) + +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) (expected), (UNITY_INT_WIDTH / 8)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) (expected), (UNITY_INT_WIDTH / 8)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT16)(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT32)(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )(expected), 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )(expected), 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_PTR_TO_INT) (expected), (UNITY_POINTER_WIDTH / 8)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((UNITY_INTERNAL_PTR)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_CHAR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )(expected), 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_CHAR, UNITY_ARRAY_TO_VAL) + +#ifdef UNITY_SUPPORT_64 +#define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)(expected), 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_NOT_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_NOT_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) +#define UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT64)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT64)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UnityAssertNumbersArrayWithin((UNITY_UINT64)(delta), (UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY) +#else +#define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_THAN_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_THAN_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#define UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) +#endif + +#ifdef UNITY_EXCLUDE_FLOAT +#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) +#else +#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsWithin((UNITY_FLOAT)(delta), (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray((UNITY_FLOAT*)(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray(UnityFloatToPtr(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF) +#define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF) +#define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN) +#define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_DET) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_INF) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_NEG_INF) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_NAN) +#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_DET) +#endif + +#ifdef UNITY_EXCLUDE_DOUBLE +#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) +#else +#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line)) +#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (UNITY_LINE_TYPE)(line), (message)) +#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) +#define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray(UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) +#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN) +#define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_DET) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_INF) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_NEG_INF) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_NAN) +#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_DET) +#endif + +#define portNUM_PROCESSORS 1 + +#define UNITY_FREERTOS_PRIORITY (configMAX_PRIORITIES-1) +#define TSK_PRIORITY (configMAX_PRIORITIES - 1) +#define true 1 +#define false 0 +#define bool uint8_t + +/* End of UNITY_INTERNALS_H */ +#endif diff --git a/example/freertos_test/wdt_isr.c b/example/freertos_test/wdt_isr.c new file mode 100644 index 0000000000000000000000000000000000000000..6453e7ad3b2efdbc57c60a129a9808adb389d224 --- /dev/null +++ b/example/freertos_test/wdt_isr.c @@ -0,0 +1,117 @@ +/* + * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * + * SPDX-License-Identifier: Apache-2.0. + * + * @Date: 2021-07-09 08:08:39 + * @LastEditTime: 2021-07-09 13:55:27 + * @Description:  This files is for + * + * @Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ +#include +#include +#include +#include "interrupt.h" +#include "gicv3.h" +#include "parameters.h" +#include "fwdt.h" +#include "fwdt_hw.h" +#include "FreeRTOS.h" +#include "task.h" +#include "ft_types.h" +#include "math.h" + +FWdtCtrl wdt_ctrl; + +/* wdt num: 0 or 1 */ +u8 wdt_id = 0; + +static TaskHandle_t wdtTaskCreateHandle = NULL; + +/** + * @name: WdtInterrupt + * @msg: This function handle wdt timeout interrupt, use it to refresh wdt. + * @return {void} + * @param {s32} vector, the interrupt number + * @param {void} *param, pointer to a WdtCtrl structure that contains + * the configuration information for the specified wdt module. + */ +void FWdtInterrupt(s32 vector, void *param) +{ + FWdtRefresh((FWdtCtrl *)param); + + static float expected = 0.5f; + + expected = expected * 1.1f * cosf(0.0f); + + printf("wdt isr expected=%f\n", expected); +} + +/** + * @name: WdtRefreshTest + * @msg: Set wdt interrupt to refresh wdt, set timeout value, start wdt. + * @return {void} + * @param {WdtCtrl} *pctrl, pointer to a WdtCtrl structure that contains + * the configuration information for the specified wdt module. + */ + +void FWdtRefreshTest(FWdtCtrl *pctrl) +{ + FWdtConfig *pconfig = &pctrl->config; + + /* interrupt init */ + InterruptSetPriority(pconfig->irq_num, pconfig->irq_prority); + InterruptInstall(pconfig->irq_num, FWdtInterrupt, (void*)pctrl, pconfig->instance_name); + InterruptUmask(pconfig->irq_num); + + FWdtSetTimeout(pctrl, 2); + + FWdtStart(pctrl); + +} + +/** + * @name: WdtNoRefreshTest + * @msg: Set wdt timeout value, start wdt, no refresh. + * @return {void} + * @param {WdtCtrl} *pctrl, pointer to a WdtCtrl structure that contains + * the configuration information for the specified wdt module. + */ +void WdtTaskCreate(void) +{ + FWdtCtrl *pctrl = &wdt_ctrl; + + pctrl->config = *FWdtLookupConfig(wdt_id); + + FWdtRefreshTest(pctrl); + + while (1) + { + vTaskDelay(100); + } +} + +BaseType_t TestWdtIsrFloatEntry(void) +{ + u32 count = 0; + printf("ft wdt isr float test.\n"); + + BaseType_t ret = pdPASS;/* 定义一个创建信息返回值,默认为 pdPASS */ + + taskENTER_CRITICAL(); //进入临界区 + + ret = xTaskCreate((TaskFunction_t )WdtTaskCreate, /* 任务入口函数 */ + (const char* )"WdtTaskCreate",/* 任务名字 */ + (uint16_t )512, /* 任务栈大小 */ + (void* )NULL,/* 任务入口函数参数 */ + (UBaseType_t )1, /* 任务的优先级 */ + (TaskHandle_t* )&wdtTaskCreateHandle); /* 任务控制 */ + + taskEXIT_CRITICAL(); //退出临界区 + + return ret; + +} diff --git a/example/function_test/Readme.md b/example/function_test/Readme.md index 562cf21c768694f81be9c05f97502ddd07128f77..90c24b0ffae7827ab3263e3b0d0b3ff26f29ed05 100644 --- a/example/function_test/Readme.md +++ b/example/function_test/Readme.md @@ -32,21 +32,19 @@ dcache off setenv ipaddr 192.168.4.20 setenv serverip 192.168.4.50 setenv gatewayip 192.168.4.1 -tftpboot 80100000 ft2004_freertos.bin +tftpboot 0x80100000 freertos.bin dcache flush go 0x80100000 ``` -``` -tftpboot 80100000 ft2004_test_irq.bin -``` -## 使用bootvx32命令跳转 +## 使用bootelf命令跳转 - 下载新版本到FT2000-4 ``` setenv ipaddr 192.168.4.20 setenv serverip 192.168.4.50 setenv gatewayip 192.168.4.1 -tftpboot 80100000 ft2004_baremetal.bin -bootvx32 -``` \ No newline at end of file +tftpboot 0x90100000 freertos.elf +bootelf -p 0x90100000 +``` + diff --git a/example/template/Makefile b/example/function_test/makefile similarity index 59% rename from example/template/Makefile rename to example/function_test/makefile index f2d0bfb68fd73aa3e1bfe158781d402024fea35b..d8b858a95db430b15d9dec91957b2d01981d1198 100644 --- a/example/template/Makefile +++ b/example/function_test/makefile @@ -1,19 +1,28 @@ -# 指定工程项目根目录为当前(只能指定一个目录) -export PROJECT_DIR ?= . -# 用户添加的源文件夹和头文件夹(可以指定多个) -export USR_SRC_DIR ?= . \ - ./src -export USR_INC_DIR ?= . \ - ./inc - -# 用户定义的编译目标文件上传路径 -USR_BOOT_DIR ?= /mnt/d/tftboot/ - -# 指定编译freertos项目使用的makefile -include $(FREERTOS_SDK_ROOT)/make/build_freertos.mk - -# 完成编译 -boot: - make - @cp ./$(CONFIG_TARGET_NAME).bin $(USR_BOOT_DIR) - cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/freertos.elf \ No newline at end of file +# 指定工程项目根目录为当前(只能指定一个目录) +export PROJECT_DIR ?= . +# 用户添加的源文件夹和头文件夹(可以指定多个) +export USR_SRC_DIR ?= . \ + ./src +export USR_INC_DIR ?= . \ + ./inc + +# 用户定义的编译目标文件上传路径 +ifeq ($(OS),Windows_NT) +USR_BOOT_DIR ?= /d/tftboot +else +USR_BOOT_DIR ?= /mnt/d/tftboot +endif + + +# 设置启动镜像名 +BOOT_IMG_NAME ?= freertos + +# 指定编译freertos项目使用的makefile +include $(FREERTOS_SDK_ROOT)/make/build_freertos.mk + +# 完成编译 +boot: + make +# @echo tar $(CONFIG_TARGET_NAME) +# @echo img $(BOOT_IMG_NAME) + cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf diff --git a/example/function_test/sdkconfig b/example/function_test/sdkconfig index c8abe558a8c998f6b7494233a2e39f20da065a5b..bf666aa6a42ab9dcb5e025bc64b7b55ef398c817 100644 --- a/example/function_test/sdkconfig +++ b/example/function_test/sdkconfig @@ -3,6 +3,8 @@ # Project Configuration # CONFIG_TARGET_NAME="ft2004_freertos" +#CONFIG_LWIP_POLL_TEST=y +# CONFIG_LWIP_INTRRUPT_TEST is not set # end of Project Configuration # @@ -13,13 +15,14 @@ CONFIG_USE_FREERTOS=y # # Arch Configuration # -# CONFIG_TARGET_ARMV8_AARCH32 is not set -CONFIG_TARGET_ARMV8_AARCH64=y +CONFIG_TARGET_ARMV8_AARCH32=y +# CONFIG_TARGET_ARMV8_AARCH64 is not set # CONFIG_TARGET_ARMV7 is not set CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y CONFIG_USE_SYS_TICK=y +CONFIG_USE_AARCH64_L1_TO_AARCH32=y # end of Arch Configuration # @@ -37,7 +40,7 @@ CONFIG_TARGET_F2000_4=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_EBABLE_GICV3=y -CONFIG_USE_USART=y +CONFIG_USE_SERIAL=y # # Usart Configuration @@ -97,9 +100,17 @@ CONFIG_LOG_INFO=y # # GNU Linker Setting # -# CONFIG_AARCH32_RAM_LD is not set -CONFIG_AARCH64_RAM_LD=y +CONFIG_AARCH32_RAM_LD=y +# CONFIG_AARCH64_RAM_LD is not set # CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0x80100000 +CONFIG_ROM_SIZE_MB=1 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0x81000000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=0x100000 +CONFIG_STACK_SIZE=0x100000 # end of GNU Linker Setting # end of Building Option @@ -117,5 +128,11 @@ CONFIG_FREERTOS_USE_UART=y # # FreeRTOS Setting # -# CONFIG_USE_LWIP is not set +#CONFIG_USE_LWIP=y + +# +# LWIP Configuration +# +#CONFIG_LWIP_F_GMAC=y +# end of LWIP Configuration # end of FreeRTOS Setting diff --git a/example/function_test/sdkconfig.h b/example/function_test/sdkconfig.h index 12708ef4a3f0ef99c9e94dd7e18be6d0203ce8ea..179f0caef381934ba8bccccfb3858c2cd8693a37 100644 --- a/example/function_test/sdkconfig.h +++ b/example/function_test/sdkconfig.h @@ -4,6 +4,8 @@ /* Project Configuration */ #define CONFIG_TARGET_NAME "ft2004_freertos" +/*CONFIG_LWIP_POLL_TEST=y */ +/* CONFIG_LWIP_INTRRUPT_TEST is not set */ /* end of Project Configuration */ /* Standalone Setting */ @@ -12,13 +14,14 @@ /* Arch Configuration */ -/* CONFIG_TARGET_ARMV8_AARCH32 is not set */ -#define CONFIG_TARGET_ARMV8_AARCH64 +#define CONFIG_TARGET_ARMV8_AARCH32 +/* CONFIG_TARGET_ARMV8_AARCH64 is not set */ /* CONFIG_TARGET_ARMV7 is not set */ #define CONFIG_USE_CACHE #define CONFIG_USE_L3CACHE #define CONFIG_USE_MMU #define CONFIG_USE_SYS_TICK +#define CONFIG_USE_AARCH64_L1_TO_AARCH32 /* end of Arch Configuration */ /* Board Configuration */ @@ -34,7 +37,7 @@ /* CONFIG_USE_QSPI is not set */ #define CONFIG_USE_GIC #define CONFIG_EBABLE_GICV3 -#define CONFIG_USE_USART +#define CONFIG_USE_SERIAL /* Usart Configuration */ @@ -84,9 +87,17 @@ /* GNU Linker Setting */ -/* CONFIG_AARCH32_RAM_LD is not set */ -#define CONFIG_AARCH64_RAM_LD +#define CONFIG_AARCH32_RAM_LD +/* CONFIG_AARCH64_RAM_LD is not set */ /* CONFIG_USER_DEFINED_LD is not set */ +#define CONFIG_LINK_SCRIPT_ROM +#define CONFIG_ROM_START_UP_ADDR 0x80100000 +#define CONFIG_ROM_SIZE_MB 1 +#define CONFIG_LINK_SCRIPT_RAM +#define CONFIG_RAM_START_UP_ADDR 0x81000000 +#define CONFIG_RAM_SIZE_MB 64 +#define CONFIG_HEAP_SIZE 0x100000 +#define CONFIG_STACK_SIZE 0x100000 /* end of GNU Linker Setting */ /* end of Building Option */ @@ -100,7 +111,12 @@ /* FreeRTOS Setting */ -/* CONFIG_USE_LWIP is not set */ +/*CONFIG_USE_LWIP=y */ + +/* LWIP Configuration */ + +/*CONFIG_LWIP_F_GMAC=y */ +/* end of LWIP Configuration */ /* end of FreeRTOS Setting */ #endif diff --git a/example/function_test/src/get_cpu_stats.c b/example/function_test/src/get_cpu_stats.c index 83d855d7b7766b59e9a0db89ae28dedc1d698eb9..1a250751501952e31ef27d800acbee7d5bdb063a 100644 --- a/example/function_test/src/get_cpu_stats.c +++ b/example/function_test/src/get_cpu_stats.c @@ -136,7 +136,7 @@ static void AppTaskCreate(void) (const char* )"CPU_STATS_Task",/* 任务名字 */ (uint16_t )1024, /* 任务栈大小 */ (void* )NULL, /* 任务入口函数参数 */ - (UBaseType_t )4, /* 任务的优先级 */ + (UBaseType_t )2, /* 任务的优先级 */ (TaskHandle_t* )&cpuStatsTaskHandle);/* 任务控制块指针 */ if (pdPASS == xReturn) diff --git a/example/hello_world/Readme.md b/example/hello_world/Readme.md index 3171fba935233025fbc9533f49be4f505011919c..90c24b0ffae7827ab3263e3b0d0b3ff26f29ed05 100644 --- a/example/hello_world/Readme.md +++ b/example/hello_world/Readme.md @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0. * * @Date: 2021-06-23 18:47:28 - * @LastEditTime: 2021-07-21 11:02:19 + * @LastEditTime: 2021-07-21 11:21:41 * @Description:  This files is for * * @Modify History: @@ -32,21 +32,19 @@ dcache off setenv ipaddr 192.168.4.20 setenv serverip 192.168.4.50 setenv gatewayip 192.168.4.1 -tftpboot 80100000 ft2004_freertos.bin +tftpboot 0x80100000 freertos.bin dcache flush go 0x80100000 ``` -``` -tftpboot 80100000 ft2004_test_irq.bin -``` -## 使用bootvx32命令跳转 +## 使用bootelf命令跳转 - 下载新版本到FT2000-4 ``` setenv ipaddr 192.168.4.20 setenv serverip 192.168.4.50 setenv gatewayip 192.168.4.1 -tftpboot 80100000 ft2004_baremetal.bin -bootvx32 -``` \ No newline at end of file +tftpboot 0x90100000 freertos.elf +bootelf -p 0x90100000 +``` + diff --git a/example/hello_world/makefile b/example/hello_world/makefile index c0a85168d3312867790096fc89bce3b8e1461b41..17dc4729dac953dbab35c736e5e6eb4a232b1295 100644 --- a/example/hello_world/makefile +++ b/example/hello_world/makefile @@ -1,9 +1,28 @@ +# 指定工程项目根目录为当前(只能指定一个目录) export PROJECT_DIR ?= . +# 用户添加的源文件夹和头文件夹(可以指定多个) +export USR_SRC_DIR ?= . \ + ./src +export USR_INC_DIR ?= . \ + ./inc -# prepare output dir and start make +# 用户定义的编译目标文件上传路径 +ifeq ($(OS),Windows_NT) +USR_BOOT_DIR ?= /d/tftboot +else +USR_BOOT_DIR ?= /mnt/d/tftboot +endif + + +# 设置启动镜像名 +BOOT_IMG_NAME ?= freertos + +# 指定编译freertos项目使用的makefile include $(FREERTOS_SDK_ROOT)/make/build_freertos.mk -# make and copy image to TFTP folder +# 完成编译 boot: make - cp ./$(CONFIG_TARGET_NAME).elf /mnt/d/tftboot/freertos.elf \ No newline at end of file +# @echo tar $(CONFIG_TARGET_NAME) +# @echo img $(BOOT_IMG_NAME) + cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf diff --git a/example/hello_world/sdkconfig b/example/hello_world/sdkconfig index 8a6d2116527055437bdc0bdc6dedba7b1cb6293c..bf666aa6a42ab9dcb5e025bc64b7b55ef398c817 100644 --- a/example/hello_world/sdkconfig +++ b/example/hello_world/sdkconfig @@ -2,12 +2,9 @@ # # Project Configuration # - -# -# FT2000-4 AARCH32 FreeRTOS Configuration -# CONFIG_TARGET_NAME="ft2004_freertos" -# end of FT2000-4 AARCH32 FreeRTOS Configuration +#CONFIG_LWIP_POLL_TEST=y +# CONFIG_LWIP_INTRRUPT_TEST is not set # end of Project Configuration # @@ -18,13 +15,14 @@ CONFIG_USE_FREERTOS=y # # Arch Configuration # -# CONFIG_TARGET_ARMV8_AARCH32 is not set -CONFIG_TARGET_ARMV8_AARCH64=y +CONFIG_TARGET_ARMV8_AARCH32=y +# CONFIG_TARGET_ARMV8_AARCH64 is not set # CONFIG_TARGET_ARMV7 is not set CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y CONFIG_USE_SYS_TICK=y +CONFIG_USE_AARCH64_L1_TO_AARCH32=y # end of Arch Configuration # @@ -42,7 +40,7 @@ CONFIG_TARGET_F2000_4=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_EBABLE_GICV3=y -CONFIG_USE_USART=y +CONFIG_USE_SERIAL=y # # Usart Configuration @@ -102,9 +100,17 @@ CONFIG_LOG_INFO=y # # GNU Linker Setting # -# CONFIG_AARCH32_RAM_LD is not set -CONFIG_AARCH64_RAM_LD=y +CONFIG_AARCH32_RAM_LD=y +# CONFIG_AARCH64_RAM_LD is not set # CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0x80100000 +CONFIG_ROM_SIZE_MB=1 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0x81000000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=0x100000 +CONFIG_STACK_SIZE=0x100000 # end of GNU Linker Setting # end of Building Option @@ -122,5 +128,11 @@ CONFIG_FREERTOS_USE_UART=y # # FreeRTOS Setting # -# CONFIG_USE_LWIP is not set +#CONFIG_USE_LWIP=y + +# +# LWIP Configuration +# +#CONFIG_LWIP_F_GMAC=y +# end of LWIP Configuration # end of FreeRTOS Setting diff --git a/example/hello_world/sdkconfig.h b/example/hello_world/sdkconfig.h index f5f49ea4b22d3bc3727e369867b272da640a3e2d..179f0caef381934ba8bccccfb3858c2cd8693a37 100644 --- a/example/hello_world/sdkconfig.h +++ b/example/hello_world/sdkconfig.h @@ -3,10 +3,9 @@ /* Project Configuration */ -/* FT2000-4 AARCH32 FreeRTOS Configuration */ - #define CONFIG_TARGET_NAME "ft2004_freertos" -/* end of FT2000-4 AARCH32 FreeRTOS Configuration */ +/*CONFIG_LWIP_POLL_TEST=y */ +/* CONFIG_LWIP_INTRRUPT_TEST is not set */ /* end of Project Configuration */ /* Standalone Setting */ @@ -15,13 +14,14 @@ /* Arch Configuration */ -/* CONFIG_TARGET_ARMV8_AARCH32 is not set */ -#define CONFIG_TARGET_ARMV8_AARCH64 +#define CONFIG_TARGET_ARMV8_AARCH32 +/* CONFIG_TARGET_ARMV8_AARCH64 is not set */ /* CONFIG_TARGET_ARMV7 is not set */ #define CONFIG_USE_CACHE #define CONFIG_USE_L3CACHE #define CONFIG_USE_MMU #define CONFIG_USE_SYS_TICK +#define CONFIG_USE_AARCH64_L1_TO_AARCH32 /* end of Arch Configuration */ /* Board Configuration */ @@ -37,7 +37,7 @@ /* CONFIG_USE_QSPI is not set */ #define CONFIG_USE_GIC #define CONFIG_EBABLE_GICV3 -#define CONFIG_USE_USART +#define CONFIG_USE_SERIAL /* Usart Configuration */ @@ -87,9 +87,17 @@ /* GNU Linker Setting */ -/* CONFIG_AARCH32_RAM_LD is not set */ -#define CONFIG_AARCH64_RAM_LD +#define CONFIG_AARCH32_RAM_LD +/* CONFIG_AARCH64_RAM_LD is not set */ /* CONFIG_USER_DEFINED_LD is not set */ +#define CONFIG_LINK_SCRIPT_ROM +#define CONFIG_ROM_START_UP_ADDR 0x80100000 +#define CONFIG_ROM_SIZE_MB 1 +#define CONFIG_LINK_SCRIPT_RAM +#define CONFIG_RAM_START_UP_ADDR 0x81000000 +#define CONFIG_RAM_SIZE_MB 64 +#define CONFIG_HEAP_SIZE 0x100000 +#define CONFIG_STACK_SIZE 0x100000 /* end of GNU Linker Setting */ /* end of Building Option */ @@ -103,7 +111,12 @@ /* FreeRTOS Setting */ -/* CONFIG_USE_LWIP is not set */ +/*CONFIG_USE_LWIP=y */ + +/* LWIP Configuration */ + +/*CONFIG_LWIP_F_GMAC=y */ +/* end of LWIP Configuration */ /* end of FreeRTOS Setting */ #endif diff --git a/example/lwip_test/README.md b/example/lwip_test/README.md index af54c7ab152a02680ce6bc2c43b7a8d0a9045763..745924a93445bdd7b959d1cb4d7af70875050259 100644 --- a/example/lwip_test/README.md +++ b/example/lwip_test/README.md @@ -74,7 +74,7 @@ sudo service tftpd-hpa restart setenv ipaddr 192.168.4.20 setenv serverip 192.168.4.50 setenv gatewayip 192.168.4.1 -tftpboot 0x90100000 baremetal.elf +tftpboot 0x90100000 freertos.elf bootelf -p 0x90100000 ``` diff --git a/example/lwip_test/get_cpu_stats.c b/example/lwip_test/get_cpu_stats.c index c03a4d44a8e3584f57c4cb67711ebd5c5c2820be..8c2281d37fce382d9ed5874d1eb3d2c85aabecab 100644 --- a/example/lwip_test/get_cpu_stats.c +++ b/example/lwip_test/get_cpu_stats.c @@ -27,7 +27,7 @@ static void CpuStatsTask(void* parameter) { memset(CPU_RunInfo,0,400); //信息缓冲区清零 vTaskList((char *)&CPU_RunInfo); //获取任务运行时间信息 - + printf("---------------------------------------------\r\n"); printf("task_name task_state priority stack task_num\r\n"); printf("%s", CPU_RunInfo); @@ -40,7 +40,6 @@ static void CpuStatsTask(void* parameter) printf("task_name\trun_time_count\tusage_rate\r\n"); printf("%s", CPU_RunInfo); printf("---------------------------------------------\r\n\n"); - vTaskDelay(2000); /* 延时 */ } } diff --git a/example/function_test/Makefile b/example/lwip_test/makefile similarity index 43% rename from example/function_test/Makefile rename to example/lwip_test/makefile index c2e25eaea4bfd9bfae0d1af64696824dcbee7ff0..d8b858a95db430b15d9dec91957b2d01981d1198 100644 --- a/example/function_test/Makefile +++ b/example/lwip_test/makefile @@ -1,33 +1,28 @@ -# 指定工程项目根目录为当前(只能指定一个目录) -export PROJECT_DIR ?= . -# 用户添加的源文件夹和头文件夹(可以指定多个) -export USR_SRC_DIR ?= . \ - ./src -export USR_INC_DIR ?= . \ - ./inc - -# 定义不同平台的默认配置文件 -ifeq ($(MAKECMDGOALS),config_ft2004_aarch32) -export DEF_KCONFIG=ft2004_aarch32_deconfig -endif - -ifeq ($(MAKECMDGOALS),config_ft2004_aarch64) -export DEF_KCONFIG=ft2004_aarch64_deconfig -endif - -# 用户定义的编译目标文件上传路径 -USR_BOOT_DIR ?= /mnt/d/tftboot/ - -# 指定编译freertos项目使用的makefile -include $(FREERTOS_SDK_ROOT)/make/build_freertos.mk - -.PHONY: boot config_ft2004_aarch32 - -# 完成编译 -boot: - make - @cp ./$(CONFIG_TARGET_NAME).bin $(USR_BOOT_DIR) - -# 加载默认配置,然后生成sdkconfig.h文件,最后清空之前的编译输出 -config_ft2004_aarch32: lddefconfig genconfig clean -config_ft2004_aarch64: lddefconfig genconfig clean +# 指定工程项目根目录为当前(只能指定一个目录) +export PROJECT_DIR ?= . +# 用户添加的源文件夹和头文件夹(可以指定多个) +export USR_SRC_DIR ?= . \ + ./src +export USR_INC_DIR ?= . \ + ./inc + +# 用户定义的编译目标文件上传路径 +ifeq ($(OS),Windows_NT) +USR_BOOT_DIR ?= /d/tftboot +else +USR_BOOT_DIR ?= /mnt/d/tftboot +endif + + +# 设置启动镜像名 +BOOT_IMG_NAME ?= freertos + +# 指定编译freertos项目使用的makefile +include $(FREERTOS_SDK_ROOT)/make/build_freertos.mk + +# 完成编译 +boot: + make +# @echo tar $(CONFIG_TARGET_NAME) +# @echo img $(BOOT_IMG_NAME) + cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf diff --git a/example/lwip_test/sdkconfig b/example/lwip_test/sdkconfig index 9807fc0ce94edf0d53aacaf755334dbe51969950..fdd0967c51b27a1161fd88c8f09e025e54979e43 100644 --- a/example/lwip_test/sdkconfig +++ b/example/lwip_test/sdkconfig @@ -39,7 +39,7 @@ CONFIG_TARGET_F2000_4=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_EBABLE_GICV3=y -CONFIG_USE_USART=y +CONFIG_USE_SERIAL=y # # Usart Configuration @@ -72,15 +72,16 @@ CONFIG_F_GMAC_PHY_AR803X=y # CONFIG_USE_PCIE is not set # CONFIG_USE_WDT is not set # CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set # end of Components Configuration -CONFIG_USE_LIBC=y +CONFIG_USE_G_LIBC=y +# CONFIG_USE_NEW_LIBC is not set # end of Standalone Setting # # Building Option # -CONFIG_ENVI_UBUNTU_20_04=y # # Cross-Compiler Setting @@ -97,12 +98,21 @@ CONFIG_LOG_INFO=y # CONFIG_LOG_NONE is not set # -# GNU Linker Setting +# Linker Options # # CONFIG_AARCH32_RAM_LD is not set CONFIG_AARCH64_RAM_LD=y +# CONFIG_QEMU_AARCH32_RAM_LD is not set # CONFIG_USER_DEFINED_LD is not set -# end of GNU Linker Setting +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0x80100000 +CONFIG_ROM_SIZE_MB=1 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0x81000000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=0x100000 +CONFIG_STACK_TOP_ADDR=0x82000000 +# end of Linker Options # end of Building Option # diff --git a/example/lwip_test/sdkconfig.h b/example/lwip_test/sdkconfig.h index 7d3c40a1c3d896159c2d58bc2ae6bb08d8d6b07d..df7a5732aa8ebf803ccda3bf4aa58326a01c795a 100644 --- a/example/lwip_test/sdkconfig.h +++ b/example/lwip_test/sdkconfig.h @@ -36,7 +36,7 @@ /* CONFIG_USE_QSPI is not set */ #define CONFIG_USE_GIC #define CONFIG_EBABLE_GICV3 -#define CONFIG_USE_USART +#define CONFIG_USE_SERIAL /* Usart Configuration */ @@ -64,14 +64,14 @@ /* CONFIG_USE_PCIE is not set */ /* CONFIG_USE_WDT is not set */ /* CONFIG_USE_DMA is not set */ +/* CONFIG_USE_NAND is not set */ /* end of Components Configuration */ -#define CONFIG_USE_LIBC +#define CONFIG_USE_G_LIBC +/* CONFIG_USE_NEW_LIBC is not set */ /* end of Standalone Setting */ /* Building Option */ -#define CONFIG_ENVI_UBUNTU_20_04 - /* Cross-Compiler Setting */ #define CONFIG_COMPILER_NO_STD_STARUP @@ -84,12 +84,21 @@ /* CONFIG_LOG_ERROR is not set */ /* CONFIG_LOG_NONE is not set */ -/* GNU Linker Setting */ +/* Linker Options */ /* CONFIG_AARCH32_RAM_LD is not set */ #define CONFIG_AARCH64_RAM_LD +/* CONFIG_QEMU_AARCH32_RAM_LD is not set */ /* CONFIG_USER_DEFINED_LD is not set */ -/* end of GNU Linker Setting */ +#define CONFIG_LINK_SCRIPT_ROM +#define CONFIG_ROM_START_UP_ADDR 0x80100000 +#define CONFIG_ROM_SIZE_MB 1 +#define CONFIG_LINK_SCRIPT_RAM +#define CONFIG_RAM_START_UP_ADDR 0x81000000 +#define CONFIG_RAM_SIZE_MB 64 +#define CONFIG_HEAP_SIZE 0x100000 +#define CONFIG_STACK_TOP_ADDR 0x82000000 +/* end of Linker Options */ /* end of Building Option */ /* Component Configuration */ diff --git a/example/makefile b/example/makefile index ecaa9f49a4cb4cc135507ee15eae64c0dfb47cde..42bc76c96a5b72d96ef56540dc795796ae35705a 100644 --- a/example/makefile +++ b/example/makefile @@ -1,18 +1,19 @@ -# Compiling all examples -TOPTARGETS := all clean - -#SUBDIRS := $(wildcard */.) -SUBDIRS := function_test \ - hello_world \ - start_up \ - template \ - lwip_test - -$(TOPTARGETS): $(SUBDIRS) - @for i in $(SUBDIRS); do \ - echo -e "\033[44;37;1m +++ Compiling $$i...\033[0m"; \ - $(MAKE) -C $$i $(MAKECMDGOALS) > /dev/null || exit $$?; \ - echo -e "\033[44;37;1m +++ Compiled OK $$i...\033[0m"; \ - done - +# Compiling all examples +TOPTARGETS := all clean + +#SUBDIRS := $(wildcard */.) +SUBDIRS := function_test \ + hello_world \ + start_up \ + freertos_test \ + lwip_test \ + template + +$(TOPTARGETS): $(SUBDIRS) + @for i in $(SUBDIRS); do \ + echo -e "\033[44;37;1m +++ Compiling $$i...\033[0m"; \ + $(MAKE) -C $$i $(MAKECMDGOALS) > /dev/null || exit $$?; \ + echo -e "\033[44;37;1m +++ Compiled OK $$i...\033[0m"; \ + done + .PHONY: $(TOPTARGETS) $(SUBDIRS) \ No newline at end of file diff --git a/example/start_up/Readme.md b/example/start_up/Readme.md index 562cf21c768694f81be9c05f97502ddd07128f77..90c24b0ffae7827ab3263e3b0d0b3ff26f29ed05 100644 --- a/example/start_up/Readme.md +++ b/example/start_up/Readme.md @@ -32,21 +32,19 @@ dcache off setenv ipaddr 192.168.4.20 setenv serverip 192.168.4.50 setenv gatewayip 192.168.4.1 -tftpboot 80100000 ft2004_freertos.bin +tftpboot 0x80100000 freertos.bin dcache flush go 0x80100000 ``` -``` -tftpboot 80100000 ft2004_test_irq.bin -``` -## 使用bootvx32命令跳转 +## 使用bootelf命令跳转 - 下载新版本到FT2000-4 ``` setenv ipaddr 192.168.4.20 setenv serverip 192.168.4.50 setenv gatewayip 192.168.4.1 -tftpboot 80100000 ft2004_baremetal.bin -bootvx32 -``` \ No newline at end of file +tftpboot 0x90100000 freertos.elf +bootelf -p 0x90100000 +``` + diff --git a/example/start_up/makefile b/example/start_up/makefile index d19a8dd37d0e7588d398eac6460b7cbe32effaa1..17dc4729dac953dbab35c736e5e6eb4a232b1295 100644 --- a/example/start_up/makefile +++ b/example/start_up/makefile @@ -1,9 +1,28 @@ - +# 指定工程项目根目录为当前(只能指定一个目录) export PROJECT_DIR ?= . +# 用户添加的源文件夹和头文件夹(可以指定多个) +export USR_SRC_DIR ?= . \ + ./src +export USR_INC_DIR ?= . \ + ./inc + +# 用户定义的编译目标文件上传路径 +ifeq ($(OS),Windows_NT) +USR_BOOT_DIR ?= /d/tftboot +else +USR_BOOT_DIR ?= /mnt/d/tftboot +endif + + +# 设置启动镜像名 +BOOT_IMG_NAME ?= freertos -# prepare output dir and start make +# 指定编译freertos项目使用的makefile include $(FREERTOS_SDK_ROOT)/make/build_freertos.mk +# 完成编译 boot: make - @cp ./$(CONFIG_TARGET_NAME).elf /mnt/d/tftboot/freertos.elf \ No newline at end of file +# @echo tar $(CONFIG_TARGET_NAME) +# @echo img $(BOOT_IMG_NAME) + cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf diff --git a/example/start_up/sdkconfig b/example/start_up/sdkconfig index 4e90b04871c85742816f9520f1df956d0384920a..bf666aa6a42ab9dcb5e025bc64b7b55ef398c817 100644 --- a/example/start_up/sdkconfig +++ b/example/start_up/sdkconfig @@ -2,16 +2,9 @@ # # Project Configuration # - -# -# FT2000-4 AARCH32 FreeRTOS Configuration -# CONFIG_TARGET_NAME="ft2004_freertos" -# CONFIG_DEMO_HELLO_WORLD is not set -# CONFIG_DEMO_GET_CPU_STATS is not set -CONFIG_DEMO_MSG_QUEUE=y -# CONFIG_DEMO_SEMAPHORE is not set -# end of FT2000-4 AARCH32 FreeRTOS Configuration +#CONFIG_LWIP_POLL_TEST=y +# CONFIG_LWIP_INTRRUPT_TEST is not set # end of Project Configuration # @@ -47,7 +40,7 @@ CONFIG_TARGET_F2000_4=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_EBABLE_GICV3=y -CONFIG_USE_USART=y +CONFIG_USE_SERIAL=y # # Usart Configuration @@ -110,6 +103,14 @@ CONFIG_LOG_INFO=y CONFIG_AARCH32_RAM_LD=y # CONFIG_AARCH64_RAM_LD is not set # CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0x80100000 +CONFIG_ROM_SIZE_MB=1 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0x81000000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=0x100000 +CONFIG_STACK_SIZE=0x100000 # end of GNU Linker Setting # end of Building Option @@ -127,5 +128,11 @@ CONFIG_FREERTOS_USE_UART=y # # FreeRTOS Setting # -# CONFIG_USE_LWIP is not set +#CONFIG_USE_LWIP=y + +# +# LWIP Configuration +# +#CONFIG_LWIP_F_GMAC=y +# end of LWIP Configuration # end of FreeRTOS Setting diff --git a/example/start_up/sdkconfig.h b/example/start_up/sdkconfig.h index 1a0aa9b523ecb9f336f3354712a6915fcd55d884..179f0caef381934ba8bccccfb3858c2cd8693a37 100644 --- a/example/start_up/sdkconfig.h +++ b/example/start_up/sdkconfig.h @@ -3,14 +3,9 @@ /* Project Configuration */ -/* FT2000-4 AARCH32 FreeRTOS Configuration */ - #define CONFIG_TARGET_NAME "ft2004_freertos" -/* CONFIG_DEMO_HELLO_WORLD is not set */ -/* CONFIG_DEMO_GET_CPU_STATS is not set */ -#define CONFIG_DEMO_MSG_QUEUE -/* CONFIG_DEMO_SEMAPHORE is not set */ -/* end of FT2000-4 AARCH32 FreeRTOS Configuration */ +/*CONFIG_LWIP_POLL_TEST=y */ +/* CONFIG_LWIP_INTRRUPT_TEST is not set */ /* end of Project Configuration */ /* Standalone Setting */ @@ -42,7 +37,7 @@ /* CONFIG_USE_QSPI is not set */ #define CONFIG_USE_GIC #define CONFIG_EBABLE_GICV3 -#define CONFIG_USE_USART +#define CONFIG_USE_SERIAL /* Usart Configuration */ @@ -95,6 +90,14 @@ #define CONFIG_AARCH32_RAM_LD /* CONFIG_AARCH64_RAM_LD is not set */ /* CONFIG_USER_DEFINED_LD is not set */ +#define CONFIG_LINK_SCRIPT_ROM +#define CONFIG_ROM_START_UP_ADDR 0x80100000 +#define CONFIG_ROM_SIZE_MB 1 +#define CONFIG_LINK_SCRIPT_RAM +#define CONFIG_RAM_START_UP_ADDR 0x81000000 +#define CONFIG_RAM_SIZE_MB 64 +#define CONFIG_HEAP_SIZE 0x100000 +#define CONFIG_STACK_SIZE 0x100000 /* end of GNU Linker Setting */ /* end of Building Option */ @@ -108,7 +111,12 @@ /* FreeRTOS Setting */ -/* CONFIG_USE_LWIP is not set */ +/*CONFIG_USE_LWIP=y */ + +/* LWIP Configuration */ + +/*CONFIG_LWIP_F_GMAC=y */ +/* end of LWIP Configuration */ /* end of FreeRTOS Setting */ #endif diff --git a/example/start_up/test_uart.c b/example/start_up/test_uart.c index a3e66cbc47f8ec50e17ebd7e8d44baf32c367611..4091994d47e85961727673f4427a2428418e69c3 100644 --- a/example/start_up/test_uart.c +++ b/example/start_up/test_uart.c @@ -11,7 +11,7 @@ * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ - +#include #include "ft_types.h" #include "pl011_uart.h" #include "gicv3.h" diff --git a/example/template/Readme.md b/example/template/Readme.md new file mode 100644 index 0000000000000000000000000000000000000000..2a1e169192e77731cc91eecf8863c75959612f6e --- /dev/null +++ b/example/template/Readme.md @@ -0,0 +1,50 @@ + + +# host侧设置 +- 重启host侧tftp服务器 +``` +sudo service tftpd-hpa restart +``` + +# 开发板侧设置 + +## 使用go命令跳转 +- 关闭D-cache和I-cache +``` +icache off +dcache off +``` + +- 下载新版本到FT2000-4 +``` +setenv ipaddr 192.168.4.20 +setenv serverip 192.168.4.50 +setenv gatewayip 192.168.4.1 +tftpboot 0x80100000 freertos.bin +dcache flush +go 0x80100000 +``` + + +## 使用bootelf命令跳转 +- 下载新版本到FT2000-4 +``` +setenv ipaddr 192.168.4.20 +setenv serverip 192.168.4.50 +setenv gatewayip 192.168.4.1 +tftpboot 0x90100000 freertos.elf +bootelf -p 0x90100000 +``` + diff --git a/example/template/makefile b/example/template/makefile new file mode 100644 index 0000000000000000000000000000000000000000..d8b858a95db430b15d9dec91957b2d01981d1198 --- /dev/null +++ b/example/template/makefile @@ -0,0 +1,28 @@ +# 指定工程项目根目录为当前(只能指定一个目录) +export PROJECT_DIR ?= . +# 用户添加的源文件夹和头文件夹(可以指定多个) +export USR_SRC_DIR ?= . \ + ./src +export USR_INC_DIR ?= . \ + ./inc + +# 用户定义的编译目标文件上传路径 +ifeq ($(OS),Windows_NT) +USR_BOOT_DIR ?= /d/tftboot +else +USR_BOOT_DIR ?= /mnt/d/tftboot +endif + + +# 设置启动镜像名 +BOOT_IMG_NAME ?= freertos + +# 指定编译freertos项目使用的makefile +include $(FREERTOS_SDK_ROOT)/make/build_freertos.mk + +# 完成编译 +boot: + make +# @echo tar $(CONFIG_TARGET_NAME) +# @echo img $(BOOT_IMG_NAME) + cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf diff --git a/example/template/sdkconfig b/example/template/sdkconfig index 5bda35c59eeb9504c2ed209b305a09a0a097890e..bf666aa6a42ab9dcb5e025bc64b7b55ef398c817 100644 --- a/example/template/sdkconfig +++ b/example/template/sdkconfig @@ -2,12 +2,9 @@ # # Project Configuration # - -# -# Template Configuration -# CONFIG_TARGET_NAME="ft2004_freertos" -# end of Template Configuration +#CONFIG_LWIP_POLL_TEST=y +# CONFIG_LWIP_INTRRUPT_TEST is not set # end of Project Configuration # @@ -18,13 +15,14 @@ CONFIG_USE_FREERTOS=y # # Arch Configuration # -# CONFIG_TARGET_ARMV8_AARCH32 is not set -CONFIG_TARGET_ARMV8_AARCH64=y +CONFIG_TARGET_ARMV8_AARCH32=y +# CONFIG_TARGET_ARMV8_AARCH64 is not set # CONFIG_TARGET_ARMV7 is not set CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y CONFIG_USE_SYS_TICK=y +CONFIG_USE_AARCH64_L1_TO_AARCH32=y # end of Arch Configuration # @@ -42,7 +40,7 @@ CONFIG_TARGET_F2000_4=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_EBABLE_GICV3=y -CONFIG_USE_USART=y +CONFIG_USE_SERIAL=y # # Usart Configuration @@ -102,9 +100,17 @@ CONFIG_LOG_INFO=y # # GNU Linker Setting # -# CONFIG_AARCH32_RAM_LD is not set -CONFIG_AARCH64_RAM_LD=y +CONFIG_AARCH32_RAM_LD=y +# CONFIG_AARCH64_RAM_LD is not set # CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0x80100000 +CONFIG_ROM_SIZE_MB=1 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0x81000000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=0x100000 +CONFIG_STACK_SIZE=0x100000 # end of GNU Linker Setting # end of Building Option @@ -122,5 +128,11 @@ CONFIG_FREERTOS_USE_UART=y # # FreeRTOS Setting # -# CONFIG_USE_LWIP is not set +#CONFIG_USE_LWIP=y + +# +# LWIP Configuration +# +#CONFIG_LWIP_F_GMAC=y +# end of LWIP Configuration # end of FreeRTOS Setting diff --git a/example/template/sdkconfig.h b/example/template/sdkconfig.h index 1cbca96cd5855dc1b87a59d64032f40c207b03de..179f0caef381934ba8bccccfb3858c2cd8693a37 100644 --- a/example/template/sdkconfig.h +++ b/example/template/sdkconfig.h @@ -3,10 +3,9 @@ /* Project Configuration */ -/* Template Configuration */ - #define CONFIG_TARGET_NAME "ft2004_freertos" -/* end of Template Configuration */ +/*CONFIG_LWIP_POLL_TEST=y */ +/* CONFIG_LWIP_INTRRUPT_TEST is not set */ /* end of Project Configuration */ /* Standalone Setting */ @@ -15,13 +14,14 @@ /* Arch Configuration */ -/* CONFIG_TARGET_ARMV8_AARCH32 is not set */ -#define CONFIG_TARGET_ARMV8_AARCH64 +#define CONFIG_TARGET_ARMV8_AARCH32 +/* CONFIG_TARGET_ARMV8_AARCH64 is not set */ /* CONFIG_TARGET_ARMV7 is not set */ #define CONFIG_USE_CACHE #define CONFIG_USE_L3CACHE #define CONFIG_USE_MMU #define CONFIG_USE_SYS_TICK +#define CONFIG_USE_AARCH64_L1_TO_AARCH32 /* end of Arch Configuration */ /* Board Configuration */ @@ -37,7 +37,7 @@ /* CONFIG_USE_QSPI is not set */ #define CONFIG_USE_GIC #define CONFIG_EBABLE_GICV3 -#define CONFIG_USE_USART +#define CONFIG_USE_SERIAL /* Usart Configuration */ @@ -87,9 +87,17 @@ /* GNU Linker Setting */ -/* CONFIG_AARCH32_RAM_LD is not set */ -#define CONFIG_AARCH64_RAM_LD +#define CONFIG_AARCH32_RAM_LD +/* CONFIG_AARCH64_RAM_LD is not set */ /* CONFIG_USER_DEFINED_LD is not set */ +#define CONFIG_LINK_SCRIPT_ROM +#define CONFIG_ROM_START_UP_ADDR 0x80100000 +#define CONFIG_ROM_SIZE_MB 1 +#define CONFIG_LINK_SCRIPT_RAM +#define CONFIG_RAM_START_UP_ADDR 0x81000000 +#define CONFIG_RAM_SIZE_MB 64 +#define CONFIG_HEAP_SIZE 0x100000 +#define CONFIG_STACK_SIZE 0x100000 /* end of GNU Linker Setting */ /* end of Building Option */ @@ -103,7 +111,12 @@ /* FreeRTOS Setting */ -/* CONFIG_USE_LWIP is not set */ +/*CONFIG_USE_LWIP=y */ + +/* LWIP Configuration */ + +/*CONFIG_LWIP_F_GMAC=y */ +/* end of LWIP Configuration */ /* end of FreeRTOS Setting */ #endif diff --git a/install.py b/install.py new file mode 100644 index 0000000000000000000000000000000000000000..1beee3228681b82fba00421f2d4891438c2ae94a --- /dev/null +++ b/install.py @@ -0,0 +1,164 @@ +#!/usr/bin/env python3 + +import sys +import os +import pwd +import stat +import platform +import getpass +import tarfile +import re +import shutil + +### platform constant +platform_tags = ["Linux_X86_64" "Linux_AARCH64" "Msys2"] +linux_x86 = 0 +linux_aarch64 = 1 +windows_msys2 = 2 + +### environment constant +sdk_profile_path = "/etc/profile.d/phytium_dev.sh" + +def rm_line(str, file_path): + with open(file_path,'r+') as f: + lines = [line for line in f.readlines() if str not in line] + f.seek(0) + f.truncate(0) + f.writelines(lines) + +def ap_line(str, file_path): + with open(file_path, 'a') as f: + f.write(str + '\n') + +# STEP 1: Check environment +# check install environment +if (platform.system() == 'Linux' ) and (platform.processor() == 'x86_64'): + install_platform = linux_x86 +elif (platform.system() == 'Linux' ) and (platform.processor() == 'aarch64'): # Arm64 computer + install_platform = linux_aarch64 +elif (re.search('MSYS_NT', platform.system()).span() == (0, len('MSYS_NT'))): + install_platform = windows_msys2 +else: + print("[1]: Platform not support !!! ") + exit() + + +# create '/etc/profile.d/phytium_standalone_sdk.sh' need sudo right, ask user to create it first +if not os.path.exists(sdk_profile_path): + if (install_platform == linux_x86) or (install_platform == linux_aarch64): + print("[1]: Please create sdk profile with 'sudo touch {}' first".format(sdk_profile_path)) + print("then 'sudo chmod 666 {}'".format(sdk_profile_path)) + else: # for Windows msys2 + print("[1]: Please create sdk profile with 'touch {}' first".format(sdk_profile_path)) + print("then 'chmod 666 {}'".format(sdk_profile_path)) + + exit() + +# get current user to install, profile depends on user +usr = getpass.getuser() +if (install_platform == windows_msys2): + # arch is not able to get for msys2 + print("[1]: Usr: {}, OS: {}, Type: {}".format(usr, platform.system(), install_platform)) +else: + print("[1]: Usr: {}, OS: {}, Arch: {}, Type: {}".format(usr, platform.system(), platform.processor(), install_platform)) + +print("[1]: Enviroment variables will set at {}".format(sdk_profile_path)) + +# get absoulte path current pwd to install sdk +install_path, install_script = os.path.split(os.path.abspath(__file__)) +curr_path = os.getcwd() +freertos_sdk_path = '' + +# in case user call this script not from current path +if (curr_path != install_path): + print("[1]: Please cd to install script path first !!!") + exit() + +# get absolute path of sdk install dir +freertos_sdk_path = install_path +print("[1]: Standalone SDK at {}".format(freertos_sdk_path)) + + +# make sure sdk scripts are executable +os.system("chmod +x ./*.sh --silent ") +os.system("chmod +x ./scripts/*.sh --silent ") +os.system("chmod +x ./make/*.mk --silent ") +os.system("chmod +x ./lib/Kconfiglib/*.py --silent ") + +# Add standalone sdk +standalone_sdk_v="v0.1.8" +standalone_path=freertos_sdk_path + '/standalone' +standalone_branche="master" +standalone_remote="https://gitee.com/phytium_embedded/phytium-standalone-sdk.git" + +if not os.path.exists(standalone_path): + current_path = os.getcwd() + + os.system("git clone {} {}".format(standalone_remote,standalone_path)) + os.chdir(standalone_path) # 切换工作路径至standalone 路径 + os.system("git config core.sparsecheckout true") + os.system("git config advice.detachedHead false") + os.system("echo \"arch/*\" >> {}".format(r'.git/info/sparse-checkout')) + os.system("echo \"board/*\" >> {}".format(r'.git/info/sparse-checkout')) + os.system("echo \"common/*\" >> {}".format(r'.git/info/sparse-checkout')) + os.system("echo \"drivers/*\" >> {}".format(r'.git/info/sparse-checkout')) + os.system("echo \"standalone.mk\" >> {}".format(r'.git/info/sparse-checkout')) + os.system("echo \"lib/*\" >> {}".format(r'.git/info/sparse-checkout')) + + os.system("git checkout {}".format(standalone_sdk_v)) + print('[1]: Standalone sdk download is succeed') + os.chdir(current_path) # 切换回当前路径 +else: + print('[1]: Standalone sdk is exist') + pass + +## STEP 2: reset environment +# remove environment variables + +try: + sdk_profile = open(sdk_profile_path, "r+") + sdk_profile.close() + +except Exception as ex: + print(ex) + print("[1]: Create SDK profile {} failed !!!!".format(sdk_profile_path)) + exit() + + +rm_line("### PHYTIUM FREERTOS SDK SETTING START",sdk_profile_path) +rm_line("export FREERTOS_SDK_ROOT="+freertos_sdk_path,sdk_profile_path) +rm_line("export FREERTOS_STANDALONE="+standalone_path,sdk_profile_path) +rm_line("### PHYTIUM FREERTOS SDK SETTING END",sdk_profile_path) + + + +print("[2]: Reset environment") + +## STEP 3: get cross-platform compiler + + +######################################### +if not os.path.exists(os.environ.get('AARCH32_CROSS_PATH')): + print("[3]: Failed, AARCH32 CC package {} non found !!!".format('AARCH32_CROSS_PATH')) + exit() + +if not os.path.exists(os.environ.get('AARCH64_CROSS_PATH')): + print("[3]: Failed, AARCH64 CC package {} non found !!!".format('AARCH64_CROSS_PATH')) + exit() + +print("[4]: GNU CC version: 10.3.1-2021.07") + +## STEP 4: write environment variables +os.environ['FREERTOS_SDK_ROOT'] = freertos_sdk_path + +os.system("echo \"### PHYTIUM FREERTOS SDK SETTING START\" >> {}".format(sdk_profile_path)) +os.system("echo \"export FREERTOS_SDK_ROOT={}\" >> {}".format(freertos_sdk_path, sdk_profile_path)) +os.system("echo \"export FREERTOS_STANDALONE={}\" >> {}".format(standalone_path, sdk_profile_path)) +os.system("echo \"### PHYTIUM FREERTOS SDK SETTING END\" >> {}".format(sdk_profile_path)) + +## STEP 5: display success message and enable environment +print("[5]: Success!!! Standalone SDK is Install at {}".format(freertos_sdk_path)) +print("[5]: SDK Environment Variables is in {}".format(sdk_profile_path)) +print("[5]: Phytium FREERTOS SDK Setup Done for {}!!!".format(usr)) +print("[5]: Input 'source {}' or Reboot System to Active SDK".format(sdk_profile_path)) + diff --git a/install.sh b/install.sh deleted file mode 100755 index 1badb526fe119eec7933b7275acf7dbbc7869800..0000000000000000000000000000000000000000 --- a/install.sh +++ /dev/null @@ -1,195 +0,0 @@ -### - # @ : Copyright (c) 2021 Phytium Information Technology, Inc. - # - # SPDX-License-Identifier: Apache-2.0. - # - # @Date: 2021-06-30 15:45:19 - # @LastEditTime: 2021-07-22 16:03:21 - # @Description:  This files is for - # - # @Modify History: - # Ver   Who        Date         Changes - # ----- ------     --------    -------------------------------------- -### -#!/bin/sh -if [ "$1" = "-online" ]; then - OFFLINE_INSTALL=0 -else - OFFLINE_INSTALL=1 -fi - -# profile to save environment variables -PROFILE_PATH=~/.profile -chmod +x $PROFILE_PATH - -# get absoulte path of script -FREERTOS_SDK_ABS=$(readlink -f "$0") -export FREERTOS_SDK_ROOT=$(dirname $FREERTOS_SDK_ABS) -echo "[1]: FreeRTOS SDK at "$FREERTOS_SDK_ROOT - -#export FREERTOS_SDK_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -INSTALL_PATH=$FREERTOS_SDK_ROOT/tools - -# remove environment variables -sed -i '/export FREERTOS_AARCH32_CROSS_PATH=/d' $PROFILE_PATH -sed -i '/export PATH=\$FREERTOS_AARCH32_CROSS_PATH/d' $PROFILE_PATH -sed -i '/export FREERTOS_AARCH64_CROSS_PATH=/d' $PROFILE_PATH -sed -i '/export PATH=\$FREERTOS_AARCH64_CROSS_PATH/d' $PROFILE_PATH -sed -i '/export FREERTOS_STANDALONE=/d' $PROFILE_PATH -sed -i '/export FREERTOS_SDK_ROOT=/d' $PROFILE_PATH -echo "[2]: Reset Environment" - -#####################################Install BSP#################################################### -STANDALONE_SDK_V=v0.1.2 -STANDALONE_PATH=$FREERTOS_SDK_ROOT/standalone -STANDALONE_BRANCHE=master -STANDALONE_REMOTE=https://gitee.com/phytium_embedded/phytium-standalone-sdk.git - -# no fetch history commits -if [ ! -d $STANDALONE_PATH ]; then - echo "[3]: Fetch BSP" - git clone $STANDALONE_REMOTE $STANDALONE_PATH -else - echo "[3]: BSP Already Exists" -fi - -if [ $? -ne 0 ] && [ -d $STANDALONE_PATH ]; then - echo "[3]: Failed when Fetch Bsp !!!" - exit -fi - -# fetch part of dirs -cd $STANDALONE_PATH -# enable checkout part of standalone -git config core.sparsecheckout true -# supress part checkout warnning -git config advice.detachedHead false -echo "arch/" >> .git/info/sparse-checkout -echo "board/" >> .git/info/sparse-checkout -echo "common/" >> .git/info/sparse-checkout -echo "drivers/" >> .git/info/sparse-checkout -echo "standalone.mk" >> .git/info/sparse-checkout -echo "lib/" >> .git/info/sparse-checkout -echo "[3]: BSP Version is" $STANDALONE_SDK_V -git checkout $STANDALONE_SDK_V - -if [ $? -ne 0 ]; then - echo "[3]: Failed when Checkout Bsp !!!" - exit -fi - -# assign execute premission -# make sure bsp scripts are executable -chmod +x $FREERTOS_SDK_ROOT/*.sh --silent -chmod +x $FREERTOS_SDK_ROOT/scripts/*.sh --silent -chmod +x $FREERTOS_SDK_ROOT/make/*.mk --silent -chmod +x $STANDALONE_PATH/lib/Kconfiglib/*.py --silent -#find $STANDALONE_PATH/lib/Kconfiglib/*.py -type f -exec dos2unix {} \; -if [ $? -ne 0 ]; then - echo "[3]: Failed when assign file premission !!!" - exit -fi - -#####################################Install GCC Tools############################################## - -# name of cc -AARCH32_CC=gcc-arm-x86_64-none-eabi-10-2020-q4-major -AARCH64_CC=gcc-arm-x86_64-aarch64-none-elf-10.2-2020.11 - -# url of cc package -AARCH32_URL=https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776847/download/gcc-arm-x86_64-none-eabi-10-2020-q4-major.tar.xz -AARCH64_URL=https://gitee.com/phytium_embedded/phytium-standalone-sdk/attach_files/776846/download/gcc-arm-x86_64-aarch64-none-elf-10.2-2020.11.tar.xz - -# cc package name -AARCH32_CC_PACK=$AARCH32_CC.tar.xz -AARCH64_CC_PACK=$AARCH64_CC.tar.xz - -# cc package name during download -AARCH32_CC_DL=$AARCH32_CC.tmp.tar.xz -AARCH64_CC_DL=$AARCH64_CC.tmp.tar.xz - -# cc install path -export FREERTOS_AARCH32_CROSS_PATH=$INSTALL_PATH/$AARCH32_CC -export FREERTOS_AARCH64_CROSS_PATH=$INSTALL_PATH/$AARCH64_CC - -echo "[4]: Install CC...." - -# remove tmp load package -[ -f $INSTALL_PATH/$AARCH32_CC_DL ] && rm $INSTALL_PATH/$AARCH32_CC_DL -[ -f $INSTALL_PATH/$AARCH64_CC_DL ] && rm $INSTALL_PATH/$AARCH64_CC_DL - -# do not download if package exists -# do not download if compiler already installed -if [ $OFFLINE_INSTALL -ne 1 ]; then - if [ ! -d $FREERTOS_AARCH32_CROSS_PATH ] && [ ! -f $INSTALL_PATH/$AARCH32_CC_PACK ]; then - wget $AARCH32_URL -O $INSTALL_PATH/$AARCH32_CC_DL -c -t 0 -# rename downlaod cc package in case download process is intrrupted - if [ -f $INSTALL_PATH/$AARCH32_CC_DL ]; then - mv $INSTALL_PATH/$AARCH32_CC_DL $INSTALL_PATH/$AARCH32_CC_PACK - echo "[4]: Got CC "$INSTALL_PATH/$AARCH32_CC_PACK - fi - else - echo "[4]: AARCH32 CC Already Exists" - fi - - if [ ! -d $FREERTOS_AARCH64_CROSS_PATH ] && [ ! -f $INSTALL_PATH/$AARCH64_CC_PACK ]; then - wget $AARCH64_URL -O $INSTALL_PATH/$AARCH64_CC_DL -c -t 0 - if [ -f $INSTALL_PATH/$AARCH64_CC_DL ]; then - mv $INSTALL_PATH/$AARCH64_CC_DL $INSTALL_PATH/$AARCH64_CC_PACK - echo "[4]: Got CC "$INSTALL_PATH/$AARCH64_CC_PACK - fi - else - echo "[4]: AARCH64 CC Already Exists" - fi -fi - -if [ ! -f $INSTALL_PATH/$AARCH32_CC_PACK ]; then - echo "[4]: Failed, AARCH32 CC Package Non Found !!!" - exit -fi -if [ ! -f $INSTALL_PATH/$AARCH64_CC_PACK ]; then - echo "[4]: Failed, AARCH64 CC Package Non Found !!!" - exit -fi - -# untar aarch32 cc -echo "[4]: Untar AARCH32 CC in process.." -if [ ! -d $FREERTOS_AARCH32_CROSS_PATH ]; then - tar -C $INSTALL_PATH/ -jxf $INSTALL_PATH/$AARCH32_CC_PACK - if [ $? -ne 0 ]; then - echo "[4]: Failed when Untar AARCH32 CC !!!" - exit - fi -fi - -# write aarch32 cc path -echo "[4]: AARCH32 CC Install Success at "$FREERTOS_AARCH32_CROSS_PATH - -# untar aarch64 cc -echo "[4]: Untar AARCH64 CC in process.." -if [ ! -d $FREERTOS_AARCH64_CROSS_PATH ]; then - tar -C $INSTALL_PATH/ -vxf $INSTALL_PATH/$AARCH64_CC_PACK - if [ $? -ne 0 ]; then - echo "[4]: Failed when Untar AARCH64 CC !!!" - exit - fi -fi - -# write aarch64 cc path -echo "[4]: AARCH64 CC Install Success at "$FREERTOS_AARCH64_CROSS_PATH - -# write environment variables -echo "export FREERTOS_AARCH32_CROSS_PATH=$FREERTOS_AARCH32_CROSS_PATH" >> $PROFILE_PATH -echo "export PATH=\$FREERTOS_AARCH32_CROSS_PATH/bin:\$PATH" >> $PROFILE_PATH -echo "export FREERTOS_AARCH64_CROSS_PATH=$FREERTOS_AARCH64_CROSS_PATH" >> $PROFILE_PATH -echo "export PATH=\$FREERTOS_AARCH64_CROSS_PATH/bin:\$PATH" >> $PROFILE_PATH -echo "export FREERTOS_STANDALONE=$STANDALONE_PATH" >> $PROFILE_PATH -echo "export FREERTOS_SDK_ROOT=$FREERTOS_SDK_ROOT" >> $PROFILE_PATH -if [ $? -ne 0 ]; then - echo "[4]: Failed when Update Environment Variables !!!" - exit -fi - -# show success info -echo "[5]: Success!!! FreeRTOS SDK is Install at "$FREERTOS_SDK_ROOT -echo "[5]: Phytium FreeRTOS SDK Setup Done!!!" \ No newline at end of file diff --git a/make/complier.mk b/make/complier.mk index 7dd726946049ecb06db7cbc3df8cf6106598462b..e874333d0557ed54b083fd3d2bdff12ecc14876b 100755 --- a/make/complier.mk +++ b/make/complier.mk @@ -12,6 +12,8 @@ # DEFINES -D MYDEFINE #include $(FREERTOS_SDK_ROOT)/make/preconfig.mk +export USR_SRC_DIR ?= $(PROJECT_DIR) +export USR_INC_DIR ?= $(PROJECT_DIR) APP ?= $(CONFIG_TARGET_NAME) @@ -31,9 +33,7 @@ ifdef CONFIG_TARGET_ARMV7 ARCH = armv7-a endif - DEBUG_FLAGS = -g - CPPFLAGS_EXTRA := ifndef FREERTOS_SDK_ROOT @@ -48,7 +48,7 @@ ifdef CONFIG_TARGET_ARMV8_AARCH64 ifdef CONFIG_USE_EXT_COMPILER CROSS_PATH := $(CONFIG_EXT_COMPILER_PREFIX) else - CROSS_PATH := $(FREERTOS_AARCH64_CROSS_PATH) + CROSS_PATH := $(AARCH64_CROSS_PATH) endif CROSS_COMPILE := $(CROSS_PATH)/bin/aarch64-none-elf- endif @@ -57,7 +57,7 @@ ifdef CONFIG_TARGET_ARMV8_AARCH32 ifdef CONFIG_USE_EXT_COMPILER CROSS_PATH := $(CONFIG_EXT_COMPILER_PREFIX) else - CROSS_PATH := $(FREERTOS_AARCH32_CROSS_PATH) + CROSS_PATH := $(AARCH32_CROSS_PATH) endif CROSS_COMPILE := $(CROSS_PATH)/bin/arm-none-eabi- endif @@ -84,19 +84,16 @@ include $(FREERTOS_SDK_ROOT)/third-party/third-party.mk INC_DIR := $(INC_DIR) $(USR_INC_DIR) INCLUDES := $(patsubst %, -I %, $(INC_DIR)) +# 使用ld.o作为后缀,区分临时用的linkscript +PROJ_LD := $(OUTPUT_DIR)/linkscript.ld.o +TEMP_LD := $(OUTPUT_DIR)/linkscript.ld.c define EOL = endef -ifeq ($(OS),Windows_NT) -RM_FILES = $(foreach file,$(1),if exist $(file) del /q $(file)$(EOL)) -RM_D -IRS = $(foreach dir,$(1),if exist $(dir) rmdir /s /q $(dir)$(EOL)) -else RM_FILES = $(foreach file,$(1),rm -f $(file)$(EOL)) RM_DIRS = $(foreach dir,$(1),rm -rf $(dir)$(EOL)) -endif DEPEND_FLAGS = -MD -MF $@.d @@ -104,25 +101,6 @@ CPPFLAGS = $(DEFINES) $(INCLUDES) $(DEPEND_FLAGS) $(CPPFLAGS_EXTRA) CFLAGS = $(DEBUG_FLAGS) -DGUEST -ffreestanding -Wextra -g -O$(OPT_LEVEL) ASFLAGS = $(CFLAGS) -LIBC ?= -LIBPATH ?= -ifdef CONFIG_TARGET_ARMV8_AARCH32 - LIBPATH += $(CROSS_PATH)/arm-none-eabi/lib/thumb/v7/nofp -# support float and div, turn on by default for aarch64 - ASFLAGS := $(ASFLAGS) -mfpu=vfpv3-fp16 -ftree-vectorize -mfloat-abi=softfp -ffast-math -fsingle-precision-constant -march=$(ARCH) - CFLAGS := $(CFLAGS) -mfpu=vfpv3-fp16 -mfloat-abi=softfp -march=$(ARCH) -endif - -LDFLAGS = -T$(LDSNAME) -Wl,--build-id=none -ifdef CONFIG_USE_LIBC -ifdef CONFIG_TARGET_ARMV8_AARCH32 -LDFLAGS += -lgcc -L $(LIBPATH) -endif -else -LDFLAGS += -nostdlib -nostartfiles -endif - -TARGET_ARCH = -march=$(ARCH) #mkdir 创建输出文件目录 SRC_DIR := $(SRC_DIR) $(USR_SRC_DIR) @@ -140,32 +118,83 @@ OBJ_FILES += $(LIBC) DEP_FILES := $(OBJ_FILES:%=%.d) +LIBC ?= +LIBPATH ?= +CC_VERSION = 10.3.1 +ifdef CONFIG_TARGET_ARMV8_AARCH32 +# support float and div, turn on by default for aarch64 -mfpu=crypto-neon-fp-armv8。 + ASFLAGS := $(ASFLAGS) -mfpu=crypto-neon-fp-armv8 -ftree-vectorize -mfloat-abi=softfp -ffast-math -fsingle-precision-constant -march=$(ARCH) + CFLAGS := $(CFLAGS) -mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp -march=$(ARCH) +endif + + +# 使用编译链自带的Glibc +ifdef CONFIG_USE_G_LIBC + ifdef CONFIG_TARGET_ARMV8_AARCH32 + LIBPATH += $(CROSS_PATH)/arm-none-eabi/lib/thumb/v7/nofp + LDFLAGS += -lgcc -L $(LIBPATH) + INC_DIR := $(INC_DIR) $(CROSS_PATH)/arm-none-eabi/include + OBJ_FILES += $(CROSS_PATH)/arm-none-eabi/lib/thumb/v7/nofp/libc.a \ + $(CROSS_PATH)/lib/gcc/arm-none-eabi/$(CC_VERSION)/libgcc.a + endif +endif + +TEST_DATA ?= +# 使用外链的NewLibc +ifdef CONFIG_USE_NEW_LIBC + ifdef CONFIG_TARGET_ARMV8_AARCH32 + LIBPATH := $(CROSS_PATH)/newlib/arm-none-eabi/newlib + INC_DIR := $(INC_DIR) $(CROSS_PATH)/newlib/newlib/libc/include + OBJ_FILES += $(CROSS_PATH)/newlib/arm-none-eabi/newlib/libc.a \ + $(CROSS_PATH)/lib/gcc/arm-none-eabi/$(CC_VERSION)/libgcc.a + endif + + ifdef CONFIG_TARGET_ARMV8_AARCH64 + LIBPATH := $(CROSS_PATH)/newlib/aarch64-none-elf/newlib + INC_DIR := $(INC_DIR) $(CROSS_PATH)/newlib/newlib/libc/include + OBJ_FILES += $(CROSS_PATH)/newlib/aarch64-none-elf/newlib/libc.a \ + $(CROSS_PATH)/lib/gcc/aarch64-none-elf/$(CC_VERSION)/libgcc.a + endif + + LDFLAGS += -nostdlib -nostartfiles + LDFLAGS += -lgcc -L $(LIBPATH) +endif + +# 不使用Libc库 +ifdef CONFIG_USE_NOSTD_LIBC + LDFLAGS += -nostdlib -nostartfiles +endif + + ifdef CONFIG_DUMMY_COMPILE DO_ECHO = @echo else DO_ECHO = endif -.phony: all clean rebuild +.phony: all linkscript clean rebuild all: $(APP) -$(APP): $(OBJ_FILES) $(LDSNAME) +linkscript: +# 如果用户指定了linkscript,跳过使用用户指定的linkscript +ifndef CONFIG_USER_DEFINED_LD + @cp -f $(LDSNAME) $(TEMP_LD) + $(DO_ECHO) $(QUIET) $(CC) -P -E $(TEMP_LD) -o $(PROJ_LD) -I $(PROJECT_DIR) + @rm -f $(TEMP_LD) +else + PROJ_LD := $(EXT_LDSNAME) +endif + +$(APP): $(OBJ_FILES) linkscript @echo Linking $@.elf @echo Dumping $@.map - - $(DO_ECHO) $(QUIET) $(CC) $(TARGET_ARCH) $(LDFLAGS) --output $@.elf -Wl,-Map=$@.map $(OBJ_FILES) -lm + $(DO_ECHO) $(QUIET) $(CC) $(TARGET_ARCH) $(LDFLAGS) -T $(PROJ_LD) --output $@.elf -Wl,-Map=$@.map $(OBJ_FILES) -lm @echo Objcopying $@.bin $(DO_ECHO) $(QUIET) $(OC) -v -O binary $@.elf $@.bin $(DO_ECHO) $(QUIET) $(OD) -D $@.elf > $@.dis @echo Done. -clean: - $(call RM_DIRS,$(OUTPUT_DIR)) - $(call RM_FILES,*.elf) - $(call RM_FILES,*.bin) - $(call RM_FILES,*.dis) - $(call RM_FILES,*.map) - $(call RM_FILES,*.tar.gz) + $(X_OUTPUT_DIRS): @mkdir -p $@ @@ -178,6 +207,14 @@ $(OUTPUT_DIR)/%.o : %.c | $(X_OUTPUT_DIRS) $(PROGRESS) $(QUIET) $(CC) -c $(TARGET_ARCH) $(CPPFLAGS) $(CFLAGS) -o $@ $< +clean: + $(call RM_DIRS,$(OUTPUT_DIR)) + $(call RM_FILES,*.elf) + $(call RM_FILES,*.bin) + $(call RM_FILES,*.dis) + $(call RM_FILES,*.map) + $(call RM_FILES,*.tar.gz) + # Make sure everything is rebuilt if this makefile is changed $(OBJ_FILES) $(APP): makefile diff --git a/make/ld/Kconfig b/make/ld/Kconfig index e99a5528927aa517351904e969b2f01191eca610..46a76361508ef2acbaad8525370e4bf08c9bc32b 100644 --- a/make/ld/Kconfig +++ b/make/ld/Kconfig @@ -1,24 +1,105 @@ # entry of menuconfig -menu "GNU Linker Setting" - choice - prompt "Select GNU linker for project" +menu "Linker Options" + choice + prompt "Select Linker Script Template" optional + default QEMU_AARCH32_RAM_LD if TARGET_AARCH32_QEMU + config AARCH32_RAM_LD - bool "Use e2000_ft2004_aarch32_ram.ld" + bool "Use aarch32_ram.ld" help - Use linkscript booting AARCH32 E2000/FT2000-4 from DDR + Use linkscript for booting AARCH32 Baremetal Image from DDR config AARCH64_RAM_LD - bool "Use e2000_ft2004_aarch64_ram.ld" + bool "Use aarch64_ram.ld" + help + Use linkscript for booting AARCH64 Baremetal Image from DDR + + if USE_BAREMETAL_AMP + config AARCH32_AMP_RAM_MASTER_LD + bool "Use aarch32_amp_master_ram.ld" + help + Use linkscript for booting AARCH32 Master Baremetal Image from DDR + + config AARCH32_AMP_RAM_SLAVE_LD + bool "Use aarch32_amp_slave_ram.ld" + help + Use linkscript for booting AARCH32 Slave Baremetal Image from DDR + endif + + config QEMU_AARCH32_RAM_LD + bool "Use qemu_aarch32_ram.ld" help - Use linkscript booting AARCH64 E2000/FT2000-4 from DDR - + Use linkscript booting AARCH32 Qemu from DDR + config USER_DEFINED_LD bool "Other link script" help Use other link script provided by User endchoice + + config LINK_SCRIPT_ROM + bool "Allocate ROM" + default y + help + Allocate ROM for link scripts + + if LINK_SCRIPT_ROM + config ROM_START_UP_ADDR + hex "ROM Start up Address" + default "0x80100000" + help + Assign Start up Address for ROM in Linkscript + + config ROM_SIZE_MB + int "ROM Size (MB)" + default "1" + help + Assign ROM size for Master Core in Linkscript + endif + + config LINK_SCRIPT_RAM + bool "Allocate RAM" + default y + help + Allocate RAM for link scripts + + if LINK_SCRIPT_RAM + config RAM_START_UP_ADDR + hex "RAM Start up Address" + default "0x81000000" + help + Assign Start up Address for RAM in Linkscript + + config RAM_SIZE_MB + int "RAM Size (MB)" + default "64" + help + Assign RAM size in Linkscript + endif + + config HEAP_SIZE + hex "Heap Size" + default "0x100000" + help + Assign Heap size in Linkscript + + if TARGET_ARMV8_AARCH32 + config STACK_SIZE + hex "Stack Size" + default "0x100000" + help + Assign Stack size in Linkscript + endif + + if TARGET_ARMV8_AARCH64 + config STACK_TOP_ADDR + hex "Stack Top Address" + default "0x82000000" + help + Assign Stack top address in Linkscript + endif endmenu diff --git a/make/ld/aarch32_ram.ld b/make/ld/aarch32_ram.ld index 5c1f9de4079f91ee30810c93244637e7e1155348..9d1ff19292012b344a83be1eaf4f7a1dffece349 100644 --- a/make/ld/aarch32_ram.ld +++ b/make/ld/aarch32_ram.ld @@ -1,18 +1,20 @@ +#include "sdkconfig.h" + OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) ENTRY(Startup_Aarch32) -HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400; +HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : CONFIG_HEAP_SIZE; /* pretend that 0x80100000 is ROM, 0x81000000 is RAM */ /* because vexpress-qemu is not able to emulate flash memory as ROM */ /* space is significant to avoid syntax error when linking */ MEMORY { - ROM (rx) : ORIGIN = 0x80100000, LENGTH = 1M - RAM (rwx): ORIGIN = 0x81000000, LENGTH = 32M + ROM (rx) : ORIGIN = CONFIG_ROM_START_UP_ADDR, LENGTH = CONFIG_ROM_SIZE_MB * 1M + RAM (rwx): ORIGIN = CONFIG_RAM_START_UP_ADDR, LENGTH = CONFIG_RAM_SIZE_MB * 1M } SECTIONS @@ -38,6 +40,11 @@ SECTIONS .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) + + . = ALIGN(8); + _shell_command_start = .; + KEEP (*(shellCommand)) + _shell_command_end = .; } > ROM .init : @@ -113,25 +120,25 @@ SECTIONS . = ALIGN(8); __end__ = .; PROVIDE(end = .); - __HeapBase = .; + HeapBase = .; + _heap_start = .; . += HEAP_SIZE; - . = ALIGN(4096); /* align to page size */ - __HeapLimit = .; - __heap_limit = .; /* Add for _sbrk */ + _heap_end = .; + HeapLimit = .; /* Add for _sbrk */ } > RAM _fiq_stack_start = ADDR(.heap) + SIZEOF(.heap); - _fiq_stack_end = _fiq_stack_start + 0x1000; /* 64 KB */ + _fiq_stack_end = _fiq_stack_start + CONFIG_STACK_SIZE; /* 64 KB */ _irq_stack_start = _fiq_stack_end; - _irq_stack_end = _irq_stack_start + 0x1000; /* 64 KB */ + _irq_stack_end = _irq_stack_start + CONFIG_STACK_SIZE; /* 64 KB */ _sys_stack_start = _irq_stack_end; - _sys_stack_end = _sys_stack_start + 0x1000; /* 64 KB */ + _sys_stack_end = _sys_stack_start + CONFIG_STACK_SIZE; /* 64 KB */ /* put svc at end and start up with SVC mode */ _svc_stack_start = _sys_stack_end; - _svc_stack_end = _svc_stack_start + 0x1000; /* 64 KB */ + _svc_stack_end = _svc_stack_start + CONFIG_STACK_SIZE; /* 64 KB */ _irq_stack_size = _irq_stack_end - _irq_stack_start; _fiq_stack_size = _fiq_stack_end - _fiq_stack_start; diff --git a/make/ld/aarch64_ram.ld b/make/ld/aarch64_ram.ld index b3426b968c343a5ef97994def8e063c5b1b889b6..ea919ee5dd4e910b7991bc5106032589d5b1de04 100644 --- a/make/ld/aarch64_ram.ld +++ b/make/ld/aarch64_ram.ld @@ -1,10 +1,15 @@ +#include "sdkconfig.h" ENTRY(_boot) MEMORY { - ROM (rx) : ORIGIN = 0x80100000, LENGTH = 1M - RAM (rwx): ORIGIN = 0x81000000, LENGTH = 32M +#if defined(CONFIG_LINK_SCRIPT_ROM) + ROM (rx) : ORIGIN = CONFIG_ROM_START_UP_ADDR, LENGTH = CONFIG_ROM_SIZE_MB * 1M +#endif +#if defined(CONFIG_LINK_SCRIPT_RAM) + RAM (rwx): ORIGIN = CONFIG_RAM_START_UP_ADDR, LENGTH = CONFIG_RAM_SIZE_MB * 1M +#endif } @@ -24,6 +29,11 @@ SECTIONS .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) + + . = ALIGN(8); + _shell_command_start = .; + KEEP (*(shellCommand)) + _shell_command_end = .; } > ROM .init : @@ -101,11 +111,15 @@ SECTIONS . = ALIGN(64); __end__ = .; PROVIDE(end = .); - . = . + 0x1000; + HeapBase = .; + _heap_start = .; + . = . + CONFIG_HEAP_SIZE; + _heap_end = .; + HeapLimit = .; } > RAM - . = 0x82000000 ; /* stack memory */ + . = CONFIG_STACK_TOP_ADDR ; /* stack memory */ stack_top = .; diff --git a/make/ld/qemu_aarch32_ram.ld b/make/ld/qemu_aarch32_ram.ld deleted file mode 100644 index c8057deebffdb109435255afd6dfab9c6ec4d868..0000000000000000000000000000000000000000 --- a/make/ld/qemu_aarch32_ram.ld +++ /dev/null @@ -1,81 +0,0 @@ -OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") -OUTPUT_ARCH(arm) - -ENTRY(system_vectors) - -HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400; - -MEMORY -{ - ROM (rx) : ORIGIN = 0x60000000, LENGTH = 0x100000 - RAM (rwx): ORIGIN = 0x70000000, LENGTH = 0x3200000 -} - -SECTIONS -{ - .text : { - _text_start = .; - /*KEEP(*(.Startup_Aarch32))*/ - *(.vector_table) - *(.text*) - *(.rodata*) /* make life easier without rodata section */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - } > ROM /* .text should linked to ROM */ - . = ALIGN(8); - - /* .ARM.exidx is sorted, so has to go in its own output section. */ - .ARM : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - /* This is used by the startup in order to initialize the .data secion */ - } > ROM - . = ALIGN(4096); /* align to page size */ - _text_end = .; - - /* data segment, contains data that can be modified by the program at run-time, - global and static variables that have a non-zero initial value will normally go here */ - .data : AT(_text_end){ - _data_start = .; /* .data section will be redise at runtime */ - *(.data) - . = ALIGN(4096); /* align to page size */ - _data_end = .; - } > RAM /* link it all to RAM */ - - /* unitialized data segment, variables explicitly initialized with zero to BSS */ - .bss : { - _bss_start = .; - *(.bss) - . = ALIGN(4096); /* align to page size */ - _bss_end = .; - } > RAM - - .heap : - { - . = ALIGN(8); - __end__ = .; - PROVIDE(end = .); - __HeapBase = .; - . += HEAP_SIZE; - __HeapLimit = .; - __heap_limit = .; /* Add for _sbrk */ - } > RAM - - _fiq_stack_start = ADDR(.heap) + SIZEOF(.heap); - _fiq_stack_end = _fiq_stack_start + 0x1000; /* 64 KB */ - - _irq_stack_start = _fiq_stack_end; - _irq_stack_end = _irq_stack_start + 0x1000; /* 64 KB */ - - _sys_stack_start = _irq_stack_end; - _sys_stack_end = _sys_stack_start + 0x1000; /* 64 KB */ - - /* put svc at end and start up with SVC mode */ - _svc_stack_start = _sys_stack_end; - _svc_stack_end = _svc_stack_start + 0x1000; /* 64 KB */ - - _irq_stack_size = _irq_stack_end - _irq_stack_start; - _fiq_stack_size = _fiq_stack_end - _fiq_stack_start; - _sys_stack_size = _sys_stack_end - _sys_stack_start; - _svc_stack_size = _svc_stack_end - _svc_stack_start; -} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..3f98e05d60e2e931347a142449bac7df13852df6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,232 @@ +alabaster==0.7.12 +anaconda-client==1.7.2 +anaconda-navigator==1.9.12 +anaconda-project==0.8.3 +applaunchservices==0.2.1 +appnope==0.1.0 +appscript==1.0.1 +argh==0.26.2 +asn1crypto==1.3.0 +astroid==2.3.3 +astropy==4.0 +atomicwrites==1.3.0 +attrs==19.3.0 +autopep8==1.4.4 +Babel==2.8.0 +backcall==0.1.0 +backports.functools-lru-cache==1.6.1 +backports.shutil-get-terminal-size==1.0.0 +backports.tempfile==1.0 +backports.weakref==1.0.post1 +beautifulsoup4==4.8.2 +bitarray==1.2.1 +bkcharts==0.2 +bleach==3.1.0 +bokeh==1.4.0 +boto==2.49.0 +Bottleneck==1.3.2 +certifi==2019.11.28 +cffi==1.14.0 +chardet==3.0.4 +Click==7.0 +cloudpickle==1.3.0 +clyent==1.2.2 +colorama==0.4.3 +conda==4.8.3 +conda-build==3.18.11 +conda-package-handling==1.6.0 +conda-verify==3.4.2 +contextlib2==0.6.0.post1 +cryptography==2.8 +cycler==0.10.0 +Cython==0.29.15 +cytoolz==0.10.1 +dask==2.11.0 +decorator==4.4.1 +defusedxml==0.6.0 +diff-match-patch==20181111 +distributed==2.11.0 +docutils==0.16 +entrypoints==0.3 +et-xmlfile==1.0.1 +fastcache==1.1.0 +filelock==3.0.12 +flake8==3.7.9 +Flask==1.1.1 +fsspec==0.6.2 +future==0.18.2 +gevent==1.4.0 +glob2==0.7 +gmpy2==2.0.8 +greenlet==0.4.15 +h5py==2.10.0 +HeapDict==1.0.1 +html5lib==1.0.1 +hypothesis==5.5.4 +idna==2.8 +imageio==2.6.1 +imagesize==1.2.0 +importlib-metadata==1.5.0 +intervaltree==3.0.2 +ipykernel==5.1.4 +ipython==7.12.0 +ipython-genutils==0.2.0 +ipywidgets==7.5.1 +isort==4.3.21 +itsdangerous==1.1.0 +jdcal==1.4.1 +jedi==0.14.1 +Jinja2==2.11.1 +joblib==0.14.1 +json5==0.9.1 +jsonschema==3.2.0 +jupyter==1.0.0 +jupyter-client==5.3.4 +jupyter-console==6.1.0 +jupyter-core==4.6.1 +jupyterlab==1.2.6 +jupyterlab-server==1.0.6 +keyring==21.1.0 +kiwisolver==1.1.0 +lazy-object-proxy==1.4.3 +libarchive-c==2.8 +lief==0.9.0 +llvmlite==0.31.0 +locket==0.2.0 +lxml==4.5.0 +MarkupSafe==1.1.1 +matplotlib==3.1.3 +mccabe==0.6.1 +mistune==0.8.4 +mkl-fft==1.0.15 +mkl-random==1.1.0 +mkl-service==2.3.0 +mock==4.0.1 +more-itertools==8.2.0 +mpmath==1.1.0 +msgpack==0.6.1 +multipledispatch==0.6.0 +navigator-updater==0.2.1 +nbconvert==5.6.1 +nbformat==5.0.4 +networkx==2.4 +nltk==3.4.5 +nose==1.3.7 +notebook==6.0.3 +numba==0.48.0 +numexpr==2.7.1 +numpy==1.18.1 +numpydoc==0.9.2 +olefile==0.46 +openpyxl==3.0.3 +packaging==20.1 +pandas==1.0.1 +pandocfilters==1.4.2 +parso==0.5.2 +partd==1.1.0 +path==13.1.0 +pathlib2==2.3.5 +pathtools==0.1.2 +patsy==0.5.1 +pep8==1.7.1 +pexpect==4.8.0 +pickleshare==0.7.5 +Pillow==7.0.0 +pkginfo==1.5.0.1 +pluggy==0.13.1 +ply==3.11 +prometheus-client==0.7.1 +prompt-toolkit==3.0.3 +psutil==5.6.7 +ptyprocess==0.6.0 +py==1.8.1 +pycodestyle==2.5.0 +pycosat==0.6.3 +pycparser==2.19 +pycrypto==2.6.1 +pycurl==7.43.0.5 +pydocstyle==4.0.1 +pyflakes==2.1.1 +Pygments==2.5.2 +pylint==2.4.4 +pymssql==2.1.4 +pyodbc===4.0.0-unsupported +pyOpenSSL==19.1.0 +pyparsing==2.4.6 +pyrsistent==0.15.7 +PySocks==1.7.1 +pytest==5.3.5 +pytest-arraydiff==0.3 +pytest-astropy==0.8.0 +pytest-astropy-header==0.1.2 +pytest-doctestplus==0.5.0 +pytest-openfiles==0.4.0 +pytest-remotedata==0.3.2 +python-dateutil==2.8.1 +python-jsonrpc-server==0.3.4 +python-language-server==0.31.7 +pytz==2019.3 +PyWavelets==1.1.1 +PyYAML==5.3 +pyzmq==18.1.1 +QDarkStyle==2.8 +QtAwesome==0.6.1 +qtconsole==4.6.0 +QtPy==1.9.0 +requests==2.22.0 +rope==0.16.0 +Rtree==0.9.3 +ruamel-yaml==0.15.87 +scikit-image==0.16.2 +scikit-learn==0.22.1 +scipy==1.4.1 +seaborn==0.10.0 +Send2Trash==1.5.0 +simplegeneric==0.8.1 +singledispatch==3.4.0.3 +six==1.14.0 +snowballstemmer==2.0.0 +sortedcollections==1.1.2 +sortedcontainers==2.1.0 +soupsieve==1.9.5 +Sphinx==2.4.0 +sphinxcontrib-applehelp==1.0.1 +sphinxcontrib-devhelp==1.0.1 +sphinxcontrib-htmlhelp==1.0.2 +sphinxcontrib-jsmath==1.0.1 +sphinxcontrib-qthelp==1.0.2 +sphinxcontrib-serializinghtml==1.1.3 +sphinxcontrib-websupport==1.2.0 +spyder==4.0.1 +spyder-kernels==1.8.1 +SQLAlchemy==1.3.13 +statsmodels==0.11.0 +sympy==1.5.1 +tables==3.6.1 +tblib==1.6.0 +terminado==0.8.3 +testpath==0.4.4 +toolz==0.10.0 +tornado==6.0.3 +tqdm==4.42.1 +traitlets==4.3.3 +ujson==1.35 +unicodecsv==0.14.1 +urllib3==1.25.8 +watchdog==0.10.2 +wcwidth==0.1.8 +webencodings==0.5.1 +Werkzeug==1.0.0 +wget==3.2 +widgetsnbextension==3.5.1 +wrapt==1.11.2 +wurlitzer==2.0.0 +xlrd==1.2.0 +XlsxWriter==1.2.7 +xlwings==0.17.1 +xlwt==1.3.0 +xmltodict==0.12.0 +yapf==0.28.0 +zict==1.0.0 +zipp==2.2.0 + diff --git a/third-party/bootloader/Makefile b/third-party/bootloader/makefile similarity index 100% rename from third-party/bootloader/Makefile rename to third-party/bootloader/makefile diff --git a/third-party/freertos/include/FreeRTOS.h b/third-party/freertos/include/FreeRTOS.h index 05642b7537997de8f7f0fb1f3d36364e34024c08..9997bf9a0b442be6537e58975db855d39f0ddf61 100644 --- a/third-party/freertos/include/FreeRTOS.h +++ b/third-party/freertos/include/FreeRTOS.h @@ -807,6 +807,10 @@ extern "C" #define configUSE_TASK_NOTIFICATIONS 1 #endif +#ifndef configUSE_POSIX_ERRNO + #define configUSE_POSIX_ERRNO 0 +#endif + #ifndef portTICK_TYPE_IS_ATOMIC #define portTICK_TYPE_IS_ATOMIC 0 #endif @@ -1027,6 +1031,9 @@ point support. */ #if (INCLUDE_xTaskAbortDelay == 1) uint8_t ucDummy21; #endif +#if ( configUSE_POSIX_ERRNO == 1 ) + int iDummy22; + #endif } StaticTask_t; diff --git a/third-party/freertos/include/task.h b/third-party/freertos/include/task.h index d0ee06811b7aa24d7b86a7be769a1e693dbff291..69c18143a1bffad544ded05661a5abb29f089d2d 100644 --- a/third-party/freertos/include/task.h +++ b/third-party/freertos/include/task.h @@ -138,6 +138,22 @@ typedef struct xTASK_STATUS uint16_t usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */ } TaskStatus_t; + +/** + * Used with the uxTaskGetSnapshotAll() function to save memory snapshot of each task in the system. + * We need this struct because TCB_t is defined (hidden) in tasks.c. + */ +typedef struct xTASK_SNAPSHOT +{ + void *pxTCB; /*!< Address of task control block. */ + StackType_t *pxTopOfStack; /*!< Points to the location of the last item placed on the tasks stack. */ + StackType_t *pxEndOfStack; /*!< Points to the end of the stack. pxTopOfStack < pxEndOfStack, stack grows hi2lo + pxTopOfStack > pxEndOfStack, stack grows lo2hi*/ +} TaskSnapshot_t; + +/** @endcond */ + + /* Possible return values for eTaskConfirmSleepModeStatus(). */ typedef enum { diff --git a/third-party/freertos/portable/GCC/d2000_aarch32/FreeRTOSConfig.h b/third-party/freertos/portable/GCC/d2000_aarch32/FreeRTOSConfig.h deleted file mode 100644 index e2943062caeb580a86bd7f482f80267b65645afd..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/d2000_aarch32/FreeRTOSConfig.h +++ /dev/null @@ -1,272 +0,0 @@ -/* - * FreeRTOS V202011.00 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -#ifndef FREERTOS_CONFIG_H -#define FREERTOS_CONFIG_H - -// #include "ft_types.h" -// #include "parameters.h" - -/*----------------------------------------------------------- - * Application specific definitions. - * - * These definitions should be adjusted for your particular hardware and - * application requirements. - * - * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE - * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. - * - * See http://www.freertos.org/a00110.html - *----------------------------------------------------------*/ - -/* - * The FreeRTOS Cortex-A port implements a full interrupt nesting model. - * - * Interrupts that are assigned a priority at or below - * configMAX_API_CALL_INTERRUPT_PRIORITY (which counter-intuitively in the ARM - * generic interrupt controller [GIC] means a priority that has a numerical - * value above configMAX_API_CALL_INTERRUPT_PRIORITY) can call FreeRTOS safe API - * functions and will nest. - * - * Interrupts that are assigned a priority above - * configMAX_API_CALL_INTERRUPT_PRIORITY (which in the GIC means a numerical - * value below configMAX_API_CALL_INTERRUPT_PRIORITY) cannot call any FreeRTOS - * API functions, will nest, and will not be masked by FreeRTOS critical - * sections (although it is necessary for interrupts to be globally disabled - * extremely briefly as the interrupt mask is updated in the GIC). - * - * FreeRTOS functions that can be called from an interrupt are those that end in - * "FromISR". FreeRTOS maintains a separate interrupt safe API to enable - * interrupt entry to be shorter, faster, simpler and smaller. - * - */ -#define configMAX_API_CALL_INTERRUPT_PRIORITY 0xb // 在不安全group1 中 ,0x8 ~0xb 不可以使用安全api(优先级越低越高) -#define configKERNEL_INTERRUPT_PRIORITY ((0x8 << 4) + 3 * 16) // 在不安全group1 中,16 is steps ,3 是其中等级 - - -#define configCPU_CLOCK_HZ 100000000UL // 100MHz -#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 //Method to select the next task -#define configUSE_TICKLESS_IDLE 0 //disable tickless mode -#define configTICK_RATE_HZ ((TickType_t)1000) //system timer rate 10ms -#define configUSE_PREEMPTION 1 //preemption task -#define configUSE_IDLE_HOOK 1 -#define configUSE_TICK_HOOK 1 -#define configMAX_PRIORITIES (7) -#define configMINIMAL_STACK_SIZE ((unsigned short)256) //min task stack size 100*4 bytes -#define configTOTAL_HEAP_SIZE (4096 * 1024) //total heap size -#define configMAX_TASK_NAME_LEN (20) -#define configUSE_TRACE_FACILITY 1 //启用可视化跟踪调试 -/* 与宏 configUSE_TRACE_FACILITY 同时为 1 时会编译下面 3 个函数 -* prvWriteNameToBuffer() -* vTaskList(), -* vTaskGetRunTimeStats() -*/ -#define configUSE_16_BIT_TICKS 0 //use 32 bit ticktype -#define configIDLE_SHOULD_YIELD 1 //idle task would not yield for task with same priority -#define configUSE_MUTEXES 1 -#define configQUEUE_REGISTRY_SIZE 8 //max queue and semp member -#define configCHECK_FOR_STACK_OVERFLOW 0 -#define configUSE_RECURSIVE_MUTEXES 1 -#define configUSE_MALLOC_FAILED_HOOK 1 -#define configUSE_APPLICATION_TASK_TAG 0 -#define configUSE_COUNTING_SEMAPHORES 1 -#define configUSE_QUEUE_SETS 1 -#define configSUPPORT_STATIC_ALLOCATION 0 //use dynamic memory allocation -#define configSUPPORT_DYNAMIC_ALLOCATION 1 - -/* Include the query-heap CLI command to query the free heap space. */ -#define configINCLUDE_QUERY_HEAP_COMMAND 1 - -/* Co-routine definitions. */ -#define configUSE_CO_ROUTINES 0 //disable co-routines -#define configMAX_CO_ROUTINE_PRIORITIES (2) - -/* Software timer definitions. */ -#define configUSE_TIMERS 1 //use software timer -#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) -#define configTIMER_QUEUE_LENGTH 5 -#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2) - -/* If configUSE_TASK_FPU_SUPPORT is set to 1 (or undefined) then each task will -be created without an FPU context, and a task must call vTaskUsesFPU() before -making use of any FPU registers. If configUSE_TASK_FPU_SUPPORT is set to 2 then -tasks are created with an FPU context by default, and calling vTaskUsesFPU() has -no effect. */ -#define configUSE_TASK_FPU_SUPPORT 1 - -/* Set the following definitions to 1 to include the API function, or zero -to exclude the API function. */ -#define INCLUDE_vTaskPrioritySet 1 -#define INCLUDE_uxTaskPriorityGet 1 -#define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskCleanUpResources 1 -#define INCLUDE_vTaskSuspend 1 -#define INCLUDE_vTaskDelayUntil 1 -#define INCLUDE_vTaskDelay 1 -#define INCLUDE_xTimerPendFunctionCall 1 -#define INCLUDE_eTaskGetState 1 -#define INCLUDE_xTaskAbortDelay 1 -#define INCLUDE_xTaskGetTaskHandle 1 -#define INCLUDE_xTaskGetHandle 1 -#define INCLUDE_xSemaphoreGetMutexHolder 1 - -/* This demo makes use of one or more example stats formatting functions. These -format the raw data provided by the uxTaskGetSystemState() function in to human -readable ASCII form. See the notes in the implementation of vTaskList() within -FreeRTOS/Source/tasks.c for limitations. */ -#define configUSE_STATS_FORMATTING_FUNCTIONS 1 - -/* Run time stats are not generated. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS and -portGET_RUN_TIME_COUNTER_VALUE must be defined if configGENERATE_RUN_TIME_STATS -is set to 1. */ -#define configGENERATE_RUN_TIME_STATS 1 //启用运行时间统计功能 -#ifndef __ASSEMBLER__ // skip when preprocess asm -extern volatile unsigned int gCpuRuntime; -#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() (gCpuRuntime = 0ul) -#define portGET_RUN_TIME_COUNTER_VALUE() gCpuRuntime -#endif - -/* The size of the global output buffer that is available for use when there -are multiple command interpreters running at once (for example, one on a UART -and one on TCP/IP). This is done to prevent an output buffer being defined by -each implementation - which would waste RAM. In this case, there is only one -command interpreter running. */ -#define configCOMMAND_INT_MAX_OUTPUT_SIZE 2096 - -/* Normal assert() semantics without relying on the provision of an assert.h -header file. */ -// void vAssertCalled(const char *pcFile, unsigned long ulLine); -// #define configASSERT(x) -// if ((x) == 0) -// vAssertCalled(__FILE__, __LINE__); -// void vMainAssertCalled(const char *pcFileName, uint32_t ulLineNumber); -// #define configASSERT(x) \ -// if ((x) == 0) \ -// { \ -// vMainAssertCalled(__FILE__, __LINE__); \ -// } -#define configASSERT(x) \ - do \ - { \ - void vMainAssertCalled(const char *pcFileName, uint32_t ulLineNumber);\ - if ((x) == 0) \ - { \ - vMainAssertCalled(__FILE__, __LINE__);\ - } \ - } while (0); - - -/* If configTASK_RETURN_ADDRESS is not defined then a task that attempts to -return from its implementing function will end up in a "task exit error" -function - which contains a call to configASSERT(). However this can give GCC -some problems when it tries to unwind the stack, as the exit error function has -nothing to return to. To avoid this define configTASK_RETURN_ADDRESS to 0. */ -#define configTASK_RETURN_ADDRESS NULL - -/****** Hardware specific settings. *******************************************/ - -/* - * The application must provide a function that configures a peripheral to - * create the FreeRTOS tick interrupt, then define configSETUP_TICK_INTERRUPT() - * in FreeRTOSConfig.h to call the function. FreeRTOS_Tick_Handler() must - * be installed as the peripheral's interrupt handler. - */ - -// #define configSETUP_TICK_INTERRUPT() \ -// do \ -// { \ -// void SystemSetupSystick(u32 tickRateHz, void *tickHandler, u32 intPriority); \ -// /* Setup systick with lowest priority */ \ -// SystemSetupSystick(configTICK_RATE_HZ, (void *)FreeRTOS_Tick_Handler, (configUNIQUE_INTERRUPT_PRIORITIES - 2) << portPRIORITY_SHIFT); \ -// } while (0) - -// #define configCLEAR_TICK_INTERRUPT() \ -// do \ -// { \ -// } while (0) -// void vConfigureTickInterrupt(void); -// #define configSETUP_TICK_INTERRUPT() vConfigureTickInterrupt() -#define configSETUP_TICK_INTERRUPT() \ - do \ - { \ - void vConfigureTickInterrupt(void);\ - vConfigureTickInterrupt(); \ - } while (0) - - -// void vClearTickInterrupt(void); -// #define configCLEAR_TICK_INTERRUPT() vClearTickInterrupt() -#define configCLEAR_TICK_INTERRUPT() \ - do \ - { \ - void vClearTickInterrupt(void);\ - vClearTickInterrupt(); \ - }while (0) - -#define FreeRTOS_IRQ_Handler IRQ_Handler -#define FreeRTOS_SWI_Handler SWI_Handler - -#define configINTERRUPT_CONTROLLER_BASE_ADDRESS (0x71800000) -#define configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET (0x2000UL) -#define configUNIQUE_INTERRUPT_PRIORITIES 16 - -/****** Network configuration settings - only used when the lwIP example is -built. See the page that documents this demo on the http://www.FreeRTOS.org -website for more information. ***********************************************/ - -/* The priority for the task that unblocked by the MAC interrupt to process -received packets. */ -#define configMAC_INPUT_TASK_PRIORITY (configMAX_PRIORITIES - 1) - -/* The priority of the task that runs the lwIP stack. */ -#define configLWIP_TASK_PRIORITY (configMAX_PRIORITIES - 2) - -/* The priority of the task that uses lwIP sockets to provide a simple command -line interface. */ -#define configCLI_TASK_PRIORITY (tskIDLE_PRIORITY) - -/* MAC address configuration. */ -#define configMAC_ADDR0 0x00 -#define configMAC_ADDR1 0x13 -#define configMAC_ADDR2 0x14 -#define configMAC_ADDR3 0x15 -#define configMAC_ADDR4 0x15 -#define configMAC_ADDR5 0x16 - -/* IP address configuration. */ -#define configIP_ADDR0 172 -#define configIP_ADDR1 25 -#define configIP_ADDR2 218 -#define configIP_ADDR3 200 - -/* Netmask configuration. */ -#define configNET_MASK0 255 -#define configNET_MASK1 255 -#define configNET_MASK2 255 -#define configNET_MASK3 0 - -#endif /* FREERTOS_CONFIG_H */ diff --git a/third-party/freertos/portable/GCC/d2000_aarch32/port.c b/third-party/freertos/portable/GCC/d2000_aarch32/port.c deleted file mode 100644 index aa766a1ddd1d52826dae2312e21a3662023692ad..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/d2000_aarch32/port.c +++ /dev/null @@ -1,549 +0,0 @@ -/* - * FreeRTOS Kernel V10.4.2 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * https://www.FreeRTOS.org - * https://github.com/FreeRTOS - * - * 1 tab == 4 spaces! - */ - -/* Standard includes. */ -#include -#include -#include "aarch32.h" - -/* Scheduler includes. */ -#include "FreeRTOS.h" -#include "task.h" - -#ifndef configINTERRUPT_CONTROLLER_BASE_ADDRESS -#error configINTERRUPT_CONTROLLER_BASE_ADDRESS must be defined. See https://www.FreeRTOS.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif - -#ifndef configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET -#error configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET must be defined. See https://www.FreeRTOS.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif - -#ifndef configUNIQUE_INTERRUPT_PRIORITIES -#error configUNIQUE_INTERRUPT_PRIORITIES must be defined. See https://www.FreeRTOS.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif - -#ifndef configSETUP_TICK_INTERRUPT -#error configSETUP_TICK_INTERRUPT() must be defined. See https://www.FreeRTOS.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif /* configSETUP_TICK_INTERRUPT */ - -#ifndef configMAX_API_CALL_INTERRUPT_PRIORITY -#error configMAX_API_CALL_INTERRUPT_PRIORITY must be defined. See https://www.FreeRTOS.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif - -#if configMAX_API_CALL_INTERRUPT_PRIORITY == 0 -#error configMAX_API_CALL_INTERRUPT_PRIORITY must not be set to 0 -#endif - -#if configMAX_API_CALL_INTERRUPT_PRIORITY > configUNIQUE_INTERRUPT_PRIORITIES -#error configMAX_API_CALL_INTERRUPT_PRIORITY must be less than or equal to configUNIQUE_INTERRUPT_PRIORITIES as the lower the numeric priority value the higher the logical interrupt priority -#endif - -#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 -/* Check the configuration. */ -#if (configMAX_PRIORITIES > 32) -#error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice. -#endif -#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ - -/* In case security extensions are implemented. */ -#if configMAX_API_CALL_INTERRUPT_PRIORITY <= (configUNIQUE_INTERRUPT_PRIORITIES / 2) -#error configMAX_API_CALL_INTERRUPT_PRIORITY must be greater than ( configUNIQUE_INTERRUPT_PRIORITIES / 2 ) -#endif - -/* Some vendor specific files default configCLEAR_TICK_INTERRUPT() in -portmacro.h. */ -#ifndef configCLEAR_TICK_INTERRUPT -#define configCLEAR_TICK_INTERRUPT() -#endif - -/* A critical section is exited when the critical section nesting count reaches -this value. */ -#define portNO_CRITICAL_NESTING ((uint32_t)0) - -/* In all GICs 255 can be written to the priority mask register to unmask all -(but the lowest) interrupt priority. */ -#define portUNMASK_VALUE (0xF0UL) - -/* Tasks are not created with a floating point context, but can be given a -floating point context after they have been created. A variable is stored as -part of the tasks context that holds portNO_FLOATING_POINT_CONTEXT if the task -does not have an FPU context, or any other value if the task does have an FPU -context. */ -#define portNO_FLOATING_POINT_CONTEXT ((StackType_t)0) - -/* Constants required to setup the initial task context. */ -#define portINITIAL_SPSR ((StackType_t)0x1f) /* System mode, ARM mode, IRQ enabled FIQ enabled. */ -#define portTHUMB_MODE_BIT ((StackType_t)0x20) -#define portINTERRUPT_ENABLE_BIT (0x80UL) -#define portTHUMB_MODE_ADDRESS (0x01UL) - -/* Used by portASSERT_IF_INTERRUPT_PRIORITY_INVALID() when ensuring the binary -point is zero. */ -#define portBINARY_POINT_BITS ((uint8_t)0x03) - -/* Masks all bits in the APSR other than the mode bits. */ -#define portAPSR_MODE_BITS_MASK (0x1F) - -/* The value of the mode bits in the APSR when the CPU is executing in user -mode. */ -#define portAPSR_USER_MODE (0x10) - -/* The critical section macros only mask interrupts up to an application -determined priority level. Sometimes it is necessary to turn interrupt off in -the CPU itself before modifying certain hardware registers. */ -#define portCPU_IRQ_DISABLE() \ - __asm volatile("CPSID i" :: \ - : "memory"); \ - __asm volatile("DSB"); \ - __asm volatile("ISB"); - -#define portCPU_IRQ_ENABLE() \ - __asm volatile("CPSIE i" :: \ - : "memory"); \ - __asm volatile("DSB"); \ - __asm volatile("ISB"); - -/* Macro to unmask all interrupt priorities. */ -#define portCLEAR_INTERRUPT_MASK() \ - { \ - portCPU_IRQ_DISABLE(); \ - sys_icc_pmr_set(portUNMASK_VALUE); \ - __asm volatile("DSB \n" \ - "ISB \n"); \ - portCPU_IRQ_ENABLE(); \ - } - -#define portINTERRUPT_PRIORITY_REGISTER_OFFSET 0x400UL -#define portMAX_8_BIT_VALUE ((uint8_t)0xff) -#define portBIT_0_SET ((uint8_t)0x01) - -/* Let the user override the pre-loading of the initial LR with the address of -prvTaskExitError() in case it messes up unwinding of the stack in the -debugger. */ -#ifdef configTASK_RETURN_ADDRESS -#define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS -#else -#define portTASK_RETURN_ADDRESS prvTaskExitError -#endif - -/* The space on the stack required to hold the FPU registers. This is 32 64-bit -registers, plus a 32-bit status register. */ -#define portFPU_REGISTER_WORDS ((32 * 2) + 1) - -/*-----------------------------------------------------------*/ - -/* - * Starts the first task executing. This function is necessarily written in - * assembly code so is implemented in portASM.s. - */ -extern void vPortRestoreTaskContext(void); - -/* - * Used to catch tasks that attempt to return from their implementing function. - */ -static void prvTaskExitError(void); - -/* - * If the application provides an implementation of vApplicationIRQHandler(), - * then it will get called directly without saving the FPU registers on - * interrupt entry, and this weak implementation of - * vApplicationFPUSafeIRQHandler() is just provided to remove linkage errors - - * it should never actually get called so its implementation contains a - * call to configASSERT() that will always fail. - * - * If the application provides its own implementation of - * vApplicationFPUSafeIRQHandler() then the implementation of - * vApplicationIRQHandler() provided in portASM.S will save the FPU registers - * before calling it. - * - * Therefore, if the application writer wants FPU registers to be saved on - * interrupt entry their IRQ handler must be called - * vApplicationFPUSafeIRQHandler(), and if the application writer does not want - * FPU registers to be saved on interrupt entry their IRQ handler must be - * called vApplicationIRQHandler(). - */ -void vApplicationFPUSafeIRQHandler(uint32_t ulICCIAR) __attribute__((weak)); - -/*-----------------------------------------------------------*/ - -/* A variable is used to keep track of the critical section nesting. This -variable has to be stored as part of the task context and must be initialised to -a non zero value to ensure interrupts don't inadvertently become unmasked before -the scheduler starts. As it is stored as part of the task context it will -automatically be set to 0 when the first task is started. */ -volatile uint32_t ulCriticalNesting = 9999UL; - -/* Saved as part of the task context. If ulPortTaskHasFPUContext is non-zero then -a floating point context must be saved and restored for the task. */ -volatile uint32_t ulPortTaskHasFPUContext = pdFALSE; - -/* Set to 1 to pend a context switch from an ISR. */ -volatile uint32_t ulPortYieldRequired = pdFALSE; - -/* Counts the interrupt nesting depth. A context switch is only performed if -if the nesting depth is 0. */ -volatile uint32_t ulPortInterruptNesting = 0UL; - -/* Used in the asm file. */ -// __attribute__((used)) const uint32_t ulICCIAR = portICCIAR_INTERRUPT_ACKNOWLEDGE_REGISTER_ADDRESS; -// __attribute__((used)) const uint32_t ulICCEOIR = portICCEOIR_END_OF_INTERRUPT_REGISTER_ADDRESS; -// __attribute__((used)) const uint32_t ulICCPMR = portICCPMR_PRIORITY_MASK_REGISTER_ADDRESS; -__attribute__((used)) const uint32_t ulMaxAPIPriorityMask = (configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT); - -/*-----------------------------------------------------------*/ - -/* - * See header file for description. - */ -StackType_t *pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters) -{ - /* Setup the initial stack of the task. The stack is set exactly as - expected by the portRESTORE_CONTEXT() macro. - - The fist real value on the stack is the status register, which is set for - system mode, with interrupts enabled. A few NULLs are added first to ensure - GDB does not try decoding a non-existent return address. */ - *pxTopOfStack = (StackType_t)NULL; - pxTopOfStack--; - *pxTopOfStack = (StackType_t)NULL; - pxTopOfStack--; - *pxTopOfStack = (StackType_t)NULL; - pxTopOfStack--; - *pxTopOfStack = (StackType_t)portINITIAL_SPSR; - - if (((uint32_t)pxCode & portTHUMB_MODE_ADDRESS) != 0x00UL) - { - /* The task will start in THUMB mode. */ - *pxTopOfStack |= portTHUMB_MODE_BIT; - } - - pxTopOfStack--; - - /* Next the return address, which in this case is the start of the task. */ - *pxTopOfStack = (StackType_t)pxCode; - pxTopOfStack--; - - /* Next all the registers other than the stack pointer. */ - *pxTopOfStack = (StackType_t)portTASK_RETURN_ADDRESS; /* R14 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x12121212; /* R12 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x11111111; /* R11 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x10101010; /* R10 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x09090909; /* R9 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x08080808; /* R8 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x07070707; /* R7 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x06060606; /* R6 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x05050505; /* R5 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x04040404; /* R4 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x03030303; /* R3 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x02020202; /* R2 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x01010101; /* R1 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)pvParameters; /* R0 */ - pxTopOfStack--; - - /* The task will start with a critical nesting count of 0 as interrupts are - enabled. */ - *pxTopOfStack = portNO_CRITICAL_NESTING; - -#if (configUSE_TASK_FPU_SUPPORT == 1) - { - /* The task will start without a floating point context. A task that - uses the floating point hardware must call vPortTaskUsesFPU() before - executing any floating point instructions. */ - pxTopOfStack--; - *pxTopOfStack = portNO_FLOATING_POINT_CONTEXT; - } -#elif (configUSE_TASK_FPU_SUPPORT == 2) - { - /* The task will start with a floating point context. Leave enough - space for the registers - and ensure they are initialised to 0. */ - pxTopOfStack -= portFPU_REGISTER_WORDS; - memset(pxTopOfStack, 0x00, portFPU_REGISTER_WORDS * sizeof(StackType_t)); - - pxTopOfStack--; - *pxTopOfStack = pdTRUE; - ulPortTaskHasFPUContext = pdTRUE; - } -#else - { -#error Invalid configUSE_TASK_FPU_SUPPORT setting - configUSE_TASK_FPU_SUPPORT must be set to 1, 2, or left undefined. - } -#endif - - return pxTopOfStack; -} -/*-----------------------------------------------------------*/ - -static void prvTaskExitError(void) -{ - /* A function that implements a task must not exit or attempt to return to - its caller as there is nothing to return to. If a task wants to exit it - should instead call vTaskDelete( NULL ). - - Artificially force an assert() to be triggered if configASSERT() is - defined, then stop here so application writers can catch the error. */ - configASSERT(ulPortInterruptNesting == ~0UL); - portDISABLE_INTERRUPTS(); - for (;;) - ; -} -/*-----------------------------------------------------------*/ - -BaseType_t xPortStartScheduler(void) -{ - uint32_t ulAPSR; - - /* Only continue if the CPU is not in User mode. The CPU must be in a - Privileged mode for the scheduler to start. */ - __asm volatile("MRS %0, APSR" - : "=r"(ulAPSR)::"memory"); - - ulAPSR &= portAPSR_MODE_BITS_MASK; - - configASSERT(ulAPSR != portAPSR_USER_MODE); - - if (ulAPSR != portAPSR_USER_MODE) - { - /* Only continue if the binary point value is set to its lowest possible - setting. See the comments in vPortValidateInterruptPriority() below for - more information. */ - printf("sys_icc_bpr_get() is %x \r\n",sys_icc_bpr_get()); - - - configASSERT((sys_icc_bpr_get() & portBINARY_POINT_BITS) <= portMAX_BINARY_POINT_VALUE); - - if ((sys_icc_bpr_get() & portBINARY_POINT_BITS) <= portMAX_BINARY_POINT_VALUE) - { - /* Interrupts are turned off in the CPU itself to ensure tick does - not execute while the scheduler is being started. Interrupts are - automatically turned back on in the CPU when the first task starts - executing. */ - portCPU_IRQ_DISABLE(); - - /* Start the timer that generates the tick ISR. */ - configSETUP_TICK_INTERRUPT(); - - /* Start the first task executing. */ - vPortRestoreTaskContext(); - - } - } - - /* Will only get here if vTaskStartScheduler() was called with the CPU in - a non-privileged mode or the binary point register was not set to its lowest - possible value. prvTaskExitError() is referenced to prevent a compiler - warning about it being defined but not referenced in the case that the user - defines their own exit address. */ - (void)prvTaskExitError; - return 0; -} -/*-----------------------------------------------------------*/ - -void vPortEndScheduler(void) -{ - /* Not implemented in ports where there is nothing to return to. - Artificially force an assert. */ - configASSERT(ulCriticalNesting == 1000UL); -} -/*-----------------------------------------------------------*/ - -void vPortEnterCritical(void) -{ - /* Mask interrupts up to the max syscall interrupt priority. */ - ulPortSetInterruptMask(); - - /* Now interrupts are disabled ulCriticalNesting can be accessed - directly. Increment ulCriticalNesting to keep a count of how many times - portENTER_CRITICAL() has been called. */ - ulCriticalNesting++; - - /* This is not the interrupt safe version of the enter critical function so - assert() if it is being called from an interrupt context. Only API - functions that end in "FromISR" can be used in an interrupt. Only assert if - the critical nesting count is 1 to protect against recursive calls if the - assert function also uses a critical section. */ - if (ulCriticalNesting == 1) - { - configASSERT(ulPortInterruptNesting == 0); - } -} -/*-----------------------------------------------------------*/ - -void vPortExitCritical(void) -{ - if (ulCriticalNesting > portNO_CRITICAL_NESTING) - { - /* Decrement the nesting count as the critical section is being - exited. */ - ulCriticalNesting--; - - /* If the nesting level has reached zero then all interrupt - priorities must be re-enabled. */ - if (ulCriticalNesting == portNO_CRITICAL_NESTING) - { - /* Critical nesting has reached zero so all interrupt priorities - should be unmasked. */ - portCLEAR_INTERRUPT_MASK(); - } - } -} -/*-----------------------------------------------------------*/ - -void FreeRTOS_Tick_Handler(void) -{ - /* Set interrupt mask before altering scheduler structures. The tick - handler runs at the lowest priority, so interrupts cannot already be masked, - so there is no need to save and restore the current mask value. It is - necessary to turn off interrupts in the CPU itself while the ICCPMR is being - updated. */ - portCPU_IRQ_DISABLE(); - sys_icc_pmr_set((uint32_t)(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT)); - // portICCPMR_PRIORITY_MASK_REGISTER = (uint32_t)(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT); - __asm volatile("dsb \n" - "isb \n" :: - : "memory"); - portCPU_IRQ_ENABLE(); - /* Increment the RTOS tick. */ - if (xTaskIncrementTick() != pdFALSE) - { - ulPortYieldRequired = pdTRUE; - } - - /* Ensure all interrupt priorities are active again. */ - portCLEAR_INTERRUPT_MASK(); - configCLEAR_TICK_INTERRUPT(); -} -/*-----------------------------------------------------------*/ - -#if (configUSE_TASK_FPU_SUPPORT != 2) - -void vPortTaskUsesFPU(void) -{ - uint32_t ulInitialFPSCR = 0; - - /* A task is registering the fact that it needs an FPU context. Set the - FPU flag (which is saved as part of the task context). */ - ulPortTaskHasFPUContext = pdTRUE; - - /* Initialise the floating point status register. */ - __asm volatile("FMXR FPSCR, %0" ::"r"(ulInitialFPSCR) - : "memory"); -} - -#endif /* configUSE_TASK_FPU_SUPPORT */ -/*-----------------------------------------------------------*/ - -void vPortClearInterruptMask(uint32_t ulNewMaskValue) -{ - if (ulNewMaskValue == pdFALSE) - { - portCLEAR_INTERRUPT_MASK(); - } -} -/*-----------------------------------------------------------*/ - -uint32_t ulPortSetInterruptMask(void) -{ - uint32_t ulReturn; - - /* Interrupt in the CPU must be turned off while the ICCPMR is being - updated. */ - portCPU_IRQ_DISABLE(); - if (sys_icc_pmr_get() == (uint32_t)(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT)) - { - /* Interrupts were already masked. */ - ulReturn = pdTRUE; - } - else - { - ulReturn = pdFALSE; - sys_icc_pmr_set((uint32_t)(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT)); - // portICCPMR_PRIORITY_MASK_REGISTER = (uint32_t)(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT); - __asm volatile("dsb \n" - "isb \n" :: - : "memory"); - } - portCPU_IRQ_ENABLE(); - - return ulReturn; -} -/*-----------------------------------------------------------*/ - -#if (configASSERT_DEFINED == 1) - -void vPortValidateInterruptPriority(void) -{ - /* The following assertion will fail if a service routine (ISR) for - an interrupt that has been assigned a priority above - configMAX_SYSCALL_INTERRUPT_PRIORITY calls an ISR safe FreeRTOS API - function. ISR safe FreeRTOS API functions must *only* be called - from interrupts that have been assigned a priority at or below - configMAX_SYSCALL_INTERRUPT_PRIORITY. - - Numerically low interrupt priority numbers represent logically high - interrupt priorities, therefore the priority of the interrupt must - be set to a value equal to or numerically *higher* than - configMAX_SYSCALL_INTERRUPT_PRIORITY. - - FreeRTOS maintains separate thread and ISR API functions to ensure - interrupt entry is as fast and simple as possible. */ - //Ft_printf("sys_icc_rpr_get() %d \r\n", sys_icc_rpr_get()); - configASSERT(sys_icc_rpr_get() >= (uint32_t)(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT)); - - /* Priority grouping: The interrupt controller (GIC) allows the bits - that define each interrupt's priority to be split between bits that - define the interrupt's pre-emption priority bits and bits that define - the interrupt's sub-priority. For simplicity all bits must be defined - to be pre-emption priority bits. The following assertion will fail if - this is not the case (if some bits represent a sub-priority). - - The priority grouping is configured by the GIC's binary point register - (ICCBPR). Writting 0 to ICCBPR will ensure it is set to its lowest - possible value (which may be above 0). */ - configASSERT((sys_icc_bpr_get() & portBINARY_POINT_BITS) <= portMAX_BINARY_POINT_VALUE); -} - -#endif /* configASSERT_DEFINED */ -/*-----------------------------------------------------------*/ - -void vApplicationFPUSafeIRQHandler(uint32_t ulICCIAR) -{ - (void)ulICCIAR; - configASSERT((volatile void *)NULL); -} diff --git a/third-party/freertos/portable/GCC/d2000_aarch64/FreeRTOSConfig.h b/third-party/freertos/portable/GCC/d2000_aarch64/FreeRTOSConfig.h deleted file mode 100644 index 96e1b4ab122600d00e0a356052acc969e3638724..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/d2000_aarch64/FreeRTOSConfig.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -#ifndef FREERTOS_CONFIG_H -#define FREERTOS_CONFIG_H - -#include "parameters.h" - -/*----------------------------------------------------------- - * Application specific definitions. - * - * These definitions should be adjusted for your particular hardware and - * application requirements. - * - * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE - * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. - * - * See http://www.freertos.org/a00110.html. - *----------------------------------------------------------*/ - -/* - * The FreeRTOS Cortex-A port implements a full interrupt nesting model. - * - * Interrupts that are assigned a priority at or below - * configMAX_API_CALL_INTERRUPT_PRIORITY (which counter-intuitively in the ARM - * generic interrupt controller [GIC] means a priority that has a numerical - * value above configMAX_API_CALL_INTERRUPT_PRIORITY) can call FreeRTOS safe API - * functions and will nest. - * - * Interrupts that are assigned a priority above - * configMAX_API_CALL_INTERRUPT_PRIORITY (which in the GIC means a numerical - * value below configMAX_API_CALL_INTERRUPT_PRIORITY) cannot call any FreeRTOS - * API functions, will nest, and will not be masked by FreeRTOS critical - * sections (although it is necessary for interrupts to be globally disabled - * extremely briefly as the interrupt mask is updated in the GIC). - * - * FreeRTOS functions that can be called from an interrupt are those that end in - * "FromISR". FreeRTOS maintains a separate interrupt safe API to enable - * interrupt entry to be shorter, faster, simpler and smaller. - * - * For the purpose of setting configMAX_API_CALL_INTERRUPT_PRIORITY 255 - * represents the lowest priority. - */ -#define configMAX_API_CALL_INTERRUPT_PRIORITY 0xb // 在不安全group1 中 ,0x8 ~0xb 不可以使用安全api(优先级越低越高) -#define configKERNEL_INTERRUPT_PRIORITY ((0x8 << 4) + 3 * 16) // 在不安全group1 中,16 is steps ,3 是其中等级 - -#define configCPU_CLOCK_HZ 100000000UL -#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 -#define configUSE_TICKLESS_IDLE 0 -#define configTICK_RATE_HZ ((TickType_t)1000) -#define configPERIPHERAL_CLOCK_HZ (33333000UL) -#define configUSE_PREEMPTION 1 -#define configUSE_IDLE_HOOK 1 -#define configUSE_TICK_HOOK 1 -#define configMAX_PRIORITIES (8) -#define configMINIMAL_STACK_SIZE ((unsigned short)1024) -#define configTOTAL_HEAP_SIZE (1024 * 1024) -#define configMAX_TASK_NAME_LEN (10) -#define configUSE_16_BIT_TICKS 0 -#define configIDLE_SHOULD_YIELD 1 -#define configUSE_MUTEXES 1 -#define configQUEUE_REGISTRY_SIZE 8 -#define configUSE_RECURSIVE_MUTEXES 1 -#define configUSE_APPLICATION_TASK_TAG 0 -#define configUSE_COUNTING_SEMAPHORES 1 -#define configUSE_QUEUE_SETS 1 - -/* This demo creates RTOS objects using both static and dynamic allocation. */ -#define configSUPPORT_STATIC_ALLOCATION 0 -#define configSUPPORT_DYNAMIC_ALLOCATION 1 /* Defaults to 1 anyway. */ - -/* Co-routine definitions. */ -#define configUSE_CO_ROUTINES 0 -#define configMAX_CO_ROUTINE_PRIORITIES (2) - -/* Software timer definitions. */ -#define configUSE_TIMERS 1 -#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) -#define configTIMER_QUEUE_LENGTH 5 -#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2) - -/* Set the following definitions to 1 to include the API function, or zero -to exclude the API function. */ -#define INCLUDE_vTaskPrioritySet 1 -#define INCLUDE_uxTaskPriorityGet 1 -#define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskCleanUpResources 1 -#define INCLUDE_vTaskSuspend 1 -#define INCLUDE_vTaskDelayUntil 1 -#define INCLUDE_vTaskDelay 1 -#define INCLUDE_xTimerPendFunctionCall 1 -#define INCLUDE_eTaskGetState 1 -#define INCLUDE_xTaskAbortDelay 1 -#define INCLUDE_xTaskGetHandle 1 - -/* This demo makes use of one or more example stats formatting functions. These -format the raw data provided by the uxTaskGetSystemState() function in to human -readable ASCII form. See the notes in the implementation of vTaskList() within -FreeRTOS/Source/tasks.c for limitations. */ -#define configUSE_STATS_FORMATTING_FUNCTIONS 1 - -/* Run time stats are not generated. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS and -portGET_RUN_TIME_COUNTER_VALUE must be defined if configGENERATE_RUN_TIME_STATS -is set to 1. */ -#define configGENERATE_RUN_TIME_STATS 1 //启用运行时间统计功能 -extern volatile unsigned int gCpuRuntime; -#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() (gCpuRuntime = 0ul) -#define portGET_RUN_TIME_COUNTER_VALUE() gCpuRuntime - -/* The size of the global output buffer that is available for use when there -are multiple command interpreters running at once (for example, one on a UART -and one on TCP/IP). This is done to prevent an output buffer being defined by -each implementation - which would waste RAM. In this case, there is only one -command interpreter running. */ -#define configCOMMAND_INT_MAX_OUTPUT_SIZE 2096 - -/* Normal assert() semantics without relying on the provision of an assert.h -header file. */ -void vMainAssertCalled(const char *pcFileName, uint32_t ulLineNumber); -#define configASSERT(x) \ - if ((x) == 0) \ - { \ - vMainAssertCalled(__FILE__, __LINE__); \ - } - -/* If configTASK_RETURN_ADDRESS is not defined then a task that attempts to -return from its implementing function will end up in a "task exit error" -function - which contains a call to configASSERT(). However this can give GCC -some problems when it tries to unwind the stack, as the exit error function has -nothing to return to. To avoid this define configTASK_RETURN_ADDRESS to 0. */ -#define configTASK_RETURN_ADDRESS NULL - -/* Bump up the priority of recmuCONTROLLING_TASK_PRIORITY to prevent false -positive errors being reported considering the priority of other tasks in the -system. */ -#define recmuCONTROLLING_TASK_PRIORITY (configMAX_PRIORITIES - 2) - -/****** Hardware specific settings. *******************************************/ - -/* - * The application must provide a function that configures a peripheral to - * create the FreeRTOS tick interrupt, then define configSETUP_TICK_INTERRUPT() - * in FreeRTOSConfig.h to call the function. This file contains a function - * that is suitable for use on the Zynq MPU. FreeRTOS_Tick_Handler() must - * be installed as the peripheral's interrupt handler. - */ -void vConfigureTickInterrupt(void); -#define configSETUP_TICK_INTERRUPT() vConfigureTickInterrupt() - -void vClearTickInterrupt(void); -#define configCLEAR_TICK_INTERRUPT() vClearTickInterrupt() - -/* The following constant describe the hardware, and are correct for the -QEMU-Virt. */ -#define configINTERRUPT_CONTROLLER_BASE_ADDRESS (GICV3_DISTRIBUTOR_BASEADDRESS) -#define configUNIQUE_INTERRUPT_PRIORITIES 16 - -#define fabs(x) __builtin_fabs(x) - -#define configUSE_TRACE_FACILITY 1 - -#endif /* FREERTOS_CONFIG_H */ diff --git a/third-party/freertos/portable/GCC/d2000_aarch64/debug_print_freertos.c b/third-party/freertos/portable/GCC/d2000_aarch64/debug_print_freertos.c deleted file mode 100644 index 71fda224f44d6e872ee2a25612d798d078b73f13..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/d2000_aarch64/debug_print_freertos.c +++ /dev/null @@ -1,128 +0,0 @@ - -// #include "printf-stdarg.h" -#include "ft_types.h" -#include "exception.h" -#include -#include "aarch64.h" - -u64 raw_read_elr_el1(void) -{ - u64 elr_el1; - - __asm__ __volatile__("mrs %0, ELR_EL1\n\t" - : "=r"(elr_el1) - : - : "memory"); - - return elr_el1; -} - -u64 raw_read_sp_el1(void) -{ - // u64 sp_el1; - - // __asm__ __volatile__("mrs %0, sp\n\t" - // : "=r"(sp_el1) - // : - // : "memory"); - - return 0; -} - -void _origin_print(void) -{ - printf("check is here \r\n"); -} - -void test_freertos_print(u64 x0, u64 x1, u64 x2) -{ - printf("x0 %x \r\n", x0); - printf("x1 %x \r\n", x1); - printf("x2 %x \r\n", x2); - printf("esr_el1 %x \r\n", get_esr_el1()); - // printf("elr_el1 %x \r\n", raw_read_elr_el1()); - // printf("spsr_el1 %x \r\n", raw_read_spsr_el1()); - // printf("sp_el1 %x \r\n", raw_read_sp_el1()); - while (1) - { - /* code */ - } -} - -void handle_exception(exception_frame *exc) -{ - printf("elr_el1 %x \r\n", raw_read_elr_el1()); - printf("An exception occur:\r\n"); - printf("exc_type: "); - printf("%x", exc->exc_type); - printf("\r\nESR: "); - printf("%x", exc->exc_esr); - printf(" SP: "); - printf("%x", exc->exc_sp); - printf(" ELR: "); - printf("%x", exc->exc_elr); - printf(" SPSR: "); - printf("%x", exc->exc_spsr); - printf("\r\n x0: "); - printf("%x", exc->x0); - printf(" x1: "); - printf("%x", exc->x1); - printf(" x2: "); - printf("%x", exc->x2); - printf(" x3: "); - printf("%x", exc->x3); - printf("\r\n x4: "); - printf("%x", exc->x4); - printf(" x5: "); - printf("%x", exc->x5); - printf(" x6: "); - printf("%x", exc->x6); - printf(" x7: "); - printf("%x", exc->x7); - printf("\r\n x8: "); - printf("%x", exc->x8); - printf(" x9: "); - printf("%x", exc->x9); - printf(" x10: "); - printf("%x", exc->x10); - printf(" x11: "); - printf("%x", exc->x11); - printf("\r\nx12: "); - printf("%x", exc->x12); - printf(" x13: "); - printf("%x", exc->x13); - printf(" x14: "); - printf("%x", exc->x14); - printf(" x15: "); - printf("%x", exc->x15); - printf("\r\nx16: "); - printf("%x", exc->x16); - printf(" x17: "); - printf("%x", exc->x17); - printf(" x18: "); - printf("%x", exc->x18); - printf(" x19: "); - printf("%x", exc->x19); - printf("\r\nx20: "); - printf("%x", exc->x20); - printf(" x21: "); - printf("%x", exc->x21); - printf(" x22: "); - printf("%x", exc->x22); - printf(" x23: "); - printf("%x", exc->x23); - printf("\r\nx24: "); - printf("%x", exc->x24); - printf(" x25: "); - printf("%x", exc->x25); - printf(" x26: "); - printf("%x", exc->x26); - printf(" x27: "); - printf("%x", exc->x27); - printf("\r\nx28: "); - printf("%x", exc->x28); - printf(" x29: "); - printf("%x", exc->x29); - printf(" x30: "); - printf("%x", exc->x30); -} \ No newline at end of file diff --git a/third-party/freertos/portable/GCC/d2000_aarch64/portASM.S b/third-party/freertos/portable/GCC/d2000_aarch64/portASM.S deleted file mode 100644 index baeb0c9c07667611d4bd55790b3e3f91f8785820..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/d2000_aarch64/portASM.S +++ /dev/null @@ -1,439 +0,0 @@ -/* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ -#include "gicv3_aliases.h" - - .text - - /* Variables and functions. */ - .extern ullMaxAPIPriorityMask - .extern pxCurrentTCB - .extern vTaskSwitchContext - .extern vApplicationIRQHandler - .extern ullPortInterruptNesting - .extern ullPortTaskHasFPUContext - .extern ullCriticalNesting - .extern ullPortYieldRequired - .extern ullICCEOIR - .extern ullICCIAR - .extern _freertos_vector_table - - .global FreeRTOS_IRQ_Handler - .global FreeRTOS_SWI_Handler - .global vPortRestoreTaskContext - - - - -.macro portSAVE_CONTEXT - /* Switch to use the EL0 stack pointer. */ - MSR SPSEL, #0 - - /* Save the entire context. */ - STP X0, X1, [SP, #-0x10]! - STP X2, X3, [SP, #-0x10]! - STP X4, X5, [SP, #-0x10]! - STP X6, X7, [SP, #-0x10]! - STP X8, X9, [SP, #-0x10]! - STP X10, X11, [SP, #-0x10]! - STP X12, X13, [SP, #-0x10]! - STP X14, X15, [SP, #-0x10]! - STP X16, X17, [SP, #-0x10]! - STP X18, X19, [SP, #-0x10]! - STP X20, X21, [SP, #-0x10]! - STP X22, X23, [SP, #-0x10]! - STP X24, X25, [SP, #-0x10]! - STP X26, X27, [SP, #-0x10]! - STP X28, X29, [SP, #-0x10]! - STP X30, XZR, [SP, #-0x10]! - - /* Save the SPSR. */ -#if defined( GUEST ) - MRS X3, SPSR_EL1 - MRS X2, ELR_EL1 -#else - MRS X3, SPSR_EL3 - /* Save the ELR. */ - MRS X2, ELR_EL3 -#endif - - STP X2, X3, [SP, #-0x10]! - - /* Save the critical section nesting depth. */ - LDR X0, ullCriticalNestingConst - LDR X3, [X0] - - /* Save the FPU context indicator. */ - LDR X0, ullPortTaskHasFPUContextConst - LDR X2, [X0] - - /* Save the FPU context, if any (32 128-bit registers). */ - CMP X2, #0 - B.EQ 1f - STP Q0, Q1, [SP,#-0x20]! - STP Q2, Q3, [SP,#-0x20]! - STP Q4, Q5, [SP,#-0x20]! - STP Q6, Q7, [SP,#-0x20]! - STP Q8, Q9, [SP,#-0x20]! - STP Q10, Q11, [SP,#-0x20]! - STP Q12, Q13, [SP,#-0x20]! - STP Q14, Q15, [SP,#-0x20]! - STP Q16, Q17, [SP,#-0x20]! - STP Q18, Q19, [SP,#-0x20]! - STP Q20, Q21, [SP,#-0x20]! - STP Q22, Q23, [SP,#-0x20]! - STP Q24, Q25, [SP,#-0x20]! - STP Q26, Q27, [SP,#-0x20]! - STP Q28, Q29, [SP,#-0x20]! - STP Q30, Q31, [SP,#-0x20]! - -1: - /* Store the critical nesting count and FPU context indicator. */ - STP X2, X3, [SP, #-0x10]! - - LDR X0, pxCurrentTCBConst - LDR X1, [X0] - MOV X0, SP /* Move SP into X0 for saving. */ - STR X0, [X1] - - /* Switch to use the ELx stack pointer. */ - MSR SPSEL, #1 - - .endm - -; /**********************************************************************/ - - - - -.macro portRESTORE_CONTEXT - - /* Switch to use the EL0 stack pointer. */ - MSR SPSEL, #0 - - /* Set the SP to point to the stack of the task being restored. */ - LDR X0, pxCurrentTCBConst - LDR X1, [X0] - LDR X0, [X1] - MOV SP, X0 - - LDP X2, X3, [SP], #0x10 /* Critical nesting and FPU context. */ - - /* Set the PMR register to be correct for the current critical nesting - depth. */ - LDR X0, ullCriticalNestingConst /* X0 holds the address of ullCriticalNesting. */ - MOV X1, #255 /* X1 holds the unmask value. */ - CMP X3, #0 - B.EQ 1f - LDR X6, ullMaxAPIPriorityMaskConst - LDR X1, [X6] /* X1 holds the mask value. */ -1: - //STR W1, [X5] /* Write the mask value to ICCPMR. */ - MSR S3_0_C4_C6_0, X1 - DSB SY /* _RB_Barriers probably not required here. */ - ISB SY - STR X3, [X0] /* Restore the task's critical nesting count. */ - - /* Restore the FPU context indicator. */ - LDR X0, ullPortTaskHasFPUContextConst - STR X2, [X0] - - /* Restore the FPU context, if any. */ - CMP X2, #0 - B.EQ 1f - - LDP Q30, Q31, [SP], #0x20 - LDP Q28, Q29, [SP], #0x20 - LDP Q26, Q27, [SP], #0x20 - LDP Q24, Q25, [SP], #0x20 - LDP Q22, Q23, [SP], #0x20 - LDP Q20, Q21, [SP], #0x20 - LDP Q18, Q19, [SP], #0x20 - LDP Q16, Q17, [SP], #0x20 - LDP Q14, Q15, [SP], #0x20 - LDP Q12, Q13, [SP], #0x20 - LDP Q10, Q11, [SP], #0x20 - LDP Q8, Q9, [SP], #0x20 - LDP Q6, Q7, [SP], #0x20 - LDP Q4, Q5, [SP], #0x20 - LDP Q2, Q3, [SP], #0x20 - LDP Q0, Q1, [SP], #0x20 -1: - LDP X2, X3, [SP], #0x10 /* SPSR and ELR. */ - -#if defined( GUEST ) - /* Restore the SPSR. */ - MSR SPSR_EL1, X3 - /* Restore the ELR. */ - MSR ELR_EL1, X2 -#else - /* Restore the SPSR. */ - MSR SPSR_EL3, X3 /*_RB_ Assumes started in EL3. */ - /* Restore the ELR. */ - MSR ELR_EL3, X2 -#endif - - LDP X30, XZR, [SP], #0x10 - LDP X28, X29, [SP], #0x10 - LDP X26, X27, [SP], #0x10 - LDP X24, X25, [SP], #0x10 - LDP X22, X23, [SP], #0x10 - LDP X20, X21, [SP], #0x10 - LDP X18, X19, [SP], #0x10 - LDP X16, X17, [SP], #0x10 - LDP X14, X15, [SP], #0x10 - LDP X12, X13, [SP], #0x10 - LDP X10, X11, [SP], #0x10 - LDP X8, X9, [SP], #0x10 - LDP X6, X7, [SP], #0x10 - LDP X4, X5, [SP], #0x10 - LDP X2, X3, [SP], #0x10 - LDP X0, X1, [SP], #0x10 - - /* Switch to use the ELx stack pointer. _RB_ Might not be required. */ - MSR SPSEL, #1 - - ERET - - .endm - - -/****************************************************************************** - * FreeRTOS_SWI_Handler handler is used to perform a context switch. - *****************************************************************************/ -.align 8 -.type FreeRTOS_SWI_Handler, %function -FreeRTOS_SWI_Handler: - /* Save the context of the current task and select a new task to run. */ - portSAVE_CONTEXT -#if defined( GUEST ) - MRS X0, ESR_EL1 -#else - MRS X0, ESR_EL3 -#endif - - LSR X1, X0, #26 - -#if defined( GUEST ) - CMP X1, #0x15 /* 0x15 = SVC instruction. */ -#else - CMP X1, #0x17 /* 0x17 = SMC instruction. */ -#endif - B.NE FreeRTOS_Abort - BL vTaskSwitchContext - - portRESTORE_CONTEXT - -FreeRTOS_Abort: - /* Full ESR is in X0, exception class code is in X1. */ - B . - -/****************************************************************************** - * vPortRestoreTaskContext is used to start the scheduler. - *****************************************************************************/ -.align 8 -.type vPortRestoreTaskContext, %function -vPortRestoreTaskContext: -.set freertos_vector_base, _freertos_vector_table - - /* Install the FreeRTOS interrupt handlers. */ - LDR X1, =freertos_vector_base -#if defined( GUEST ) - MSR VBAR_EL1, X1 -#else - MSR VBAR_EL3, X1 -#endif - DSB SY - ISB SY - - /* Start the first task. */ - portRESTORE_CONTEXT - - -/****************************************************************************** - * FreeRTOS_IRQ_Handler handles IRQ entry and exit. - *****************************************************************************/ -.align 8 -.type FreeRTOS_IRQ_Handler, %function -FreeRTOS_IRQ_Handler: - /* Save volatile registers. */ - STP X0, X1, [SP, #-0x10]! - STP X2, X3, [SP, #-0x10]! - STP X4, X5, [SP, #-0x10]! - STP X6, X7, [SP, #-0x10]! - STP X8, X9, [SP, #-0x10]! - STP X10, X11, [SP, #-0x10]! - STP X12, X13, [SP, #-0x10]! - STP X14, X15, [SP, #-0x10]! - STP X16, X17, [SP, #-0x10]! - STP X18, X19, [SP, #-0x10]! - STP X29, X30, [SP, #-0x10]! - - /* Save the SPSR and ELR. */ -#if defined( GUEST ) - MRS X3, SPSR_EL1 - MRS X2, ELR_EL1 -#else - MRS X3, SPSR_EL3 - MRS X2, ELR_EL3 -#endif - STP X2, X3, [SP, #-0x10]! - - /* Increment the interrupt nesting counter. */ - LDR X5, ullPortInterruptNestingConst - LDR X1, [X5] /* Old nesting count in X1. */ - ADD X6, X1, #1 - STR X6, [X5] /* Address of nesting count variable in X5. */ - - /* Maintain the interrupt nesting information across the function call. */ - STP X1, X5, [SP, #-0x10]! - - - /* Read value from the interrupt acknowledge register, which is stored in W0 - for future parameter and interrupt clearing use. */ - - MRS X0, ICC_IAR1_EL1 - - // LDR X2, ullICCIARConst - // LDR X3, [X2] - // LDR W0, [X3] /* ICCIAR in W0 as parameter. */ - - /* Maintain the ICCIAR value across the function call. */ - STP X0, X1, [SP, #-0x10]! - - /* Call the C handler. */ - BL vApplicationIRQHandler - - /* Disable interrupts. */ - MSR DAIFSET, #2 - DSB SY - ISB SY - - /* Restore the ICCIAR value. */ - LDP X0, X1, [SP], #0x10 - - /* End IRQ processing by writing ICCIAR to the EOI register. */ - // LDR X4, ullICCEOIRConst - // LDR X4, [X4] - // STR W0, [X4] - MSR ICC_EOIR1_EL1, x0 - - - /* Restore the critical nesting count. */ - LDP X1, X5, [SP], #0x10 - STR X1, [X5] - - /* Has interrupt nesting unwound? */ - CMP X1, #0 - B.NE Exit_IRQ_No_Context_Switch - - /* Is a context switch required? */ - LDR X0, ullPortYieldRequiredConst - LDR X1, [X0] - CMP X1, #0 - B.EQ Exit_IRQ_No_Context_Switch - - /* Reset ullPortYieldRequired to 0. */ - MOV X2, #0 - STR X2, [X0] - - /* Restore volatile registers. */ - LDP X4, X5, [SP], #0x10 /* SPSR and ELR. */ -#if defined( GUEST ) - MSR SPSR_EL1, X5 - MSR ELR_EL1, X4 -#else - MSR SPSR_EL3, X5 /*_RB_ Assumes started in EL3. */ - MSR ELR_EL3, X4 -#endif - DSB SY - ISB SY - - LDP X29, X30, [SP], #0x10 - LDP X18, X19, [SP], #0x10 - LDP X16, X17, [SP], #0x10 - LDP X14, X15, [SP], #0x10 - LDP X12, X13, [SP], #0x10 - LDP X10, X11, [SP], #0x10 - LDP X8, X9, [SP], #0x10 - LDP X6, X7, [SP], #0x10 - LDP X4, X5, [SP], #0x10 - LDP X2, X3, [SP], #0x10 - LDP X0, X1, [SP], #0x10 - - /* Save the context of the current task and select a new task to run. */ - portSAVE_CONTEXT - BL vTaskSwitchContext - portRESTORE_CONTEXT - -Exit_IRQ_No_Context_Switch: - /* Restore volatile registers. */ - LDP X4, X5, [SP], #0x10 /* SPSR and ELR. */ -#if defined( GUEST ) - MSR SPSR_EL1, X5 - MSR ELR_EL1, X4 -#else - MSR SPSR_EL3, X5 /*_RB_ Assumes started in EL3. */ - MSR ELR_EL3, X4 -#endif - DSB SY - ISB SY - - LDP X29, X30, [SP], #0x10 - LDP X18, X19, [SP], #0x10 - LDP X16, X17, [SP], #0x10 - LDP X14, X15, [SP], #0x10 - LDP X12, X13, [SP], #0x10 - LDP X10, X11, [SP], #0x10 - LDP X8, X9, [SP], #0x10 - LDP X6, X7, [SP], #0x10 - LDP X4, X5, [SP], #0x10 - LDP X2, X3, [SP], #0x10 - LDP X0, X1, [SP], #0x10 - - ERET - - - - -.align 8 -pxCurrentTCBConst: .dword pxCurrentTCB -ullCriticalNestingConst: .dword ullCriticalNesting -ullPortTaskHasFPUContextConst: .dword ullPortTaskHasFPUContext -ullMaxAPIPriorityMaskConst: .dword ullMaxAPIPriorityMask -vApplicationIRQHandlerConst: .dword vApplicationIRQHandler -ullPortInterruptNestingConst: .dword ullPortInterruptNesting -ullPortYieldRequiredConst: .dword ullPortYieldRequired - - - - -.end - - - - - diff --git a/third-party/freertos/portable/GCC/e2000_aarch64/FreeRTOSConfig.h b/third-party/freertos/portable/GCC/e2000_aarch64/FreeRTOSConfig.h deleted file mode 100644 index 38cb360888e1bcc7939c0b368e4de81fcaf69fea..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/e2000_aarch64/FreeRTOSConfig.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -#ifndef FREERTOS_CONFIG_H -#define FREERTOS_CONFIG_H - -#include "_parameters.h" - -/*----------------------------------------------------------- - * Application specific definitions. - * - * These definitions should be adjusted for your particular hardware and - * application requirements. - * - * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE - * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. - * - * See http://www.freertos.org/a00110.html. - *----------------------------------------------------------*/ - -/* - * The FreeRTOS Cortex-A port implements a full interrupt nesting model. - * - * Interrupts that are assigned a priority at or below - * configMAX_API_CALL_INTERRUPT_PRIORITY (which counter-intuitively in the ARM - * generic interrupt controller [GIC] means a priority that has a numerical - * value above configMAX_API_CALL_INTERRUPT_PRIORITY) can call FreeRTOS safe API - * functions and will nest. - * - * Interrupts that are assigned a priority above - * configMAX_API_CALL_INTERRUPT_PRIORITY (which in the GIC means a numerical - * value below configMAX_API_CALL_INTERRUPT_PRIORITY) cannot call any FreeRTOS - * API functions, will nest, and will not be masked by FreeRTOS critical - * sections (although it is necessary for interrupts to be globally disabled - * extremely briefly as the interrupt mask is updated in the GIC). - * - * FreeRTOS functions that can be called from an interrupt are those that end in - * "FromISR". FreeRTOS maintains a separate interrupt safe API to enable - * interrupt entry to be shorter, faster, simpler and smaller. - * - * For the purpose of setting configMAX_API_CALL_INTERRUPT_PRIORITY 255 - * represents the lowest priority. - */ -#define configMAX_API_CALL_INTERRUPT_PRIORITY 0xb // 在不安全group1 中 ,0x8 ~0xb 不可以使用安全api(优先级越低越高) -#define configKERNEL_INTERRUPT_PRIORITY ((0x8 << 4) + 3 * 16) // 在不安全group1 中,16 is steps ,3 是其中等级 - -#define configCPU_CLOCK_HZ 100000000UL -#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 -#define configUSE_TICKLESS_IDLE 0 -#define configTICK_RATE_HZ ((TickType_t)100) -#define configPERIPHERAL_CLOCK_HZ (33333000UL) -#define configUSE_PREEMPTION 1 -#define configUSE_IDLE_HOOK 1 -#define configUSE_TICK_HOOK 1 -#define configMAX_PRIORITIES (8) -#define configMINIMAL_STACK_SIZE ((unsigned short)200) -#define configTOTAL_HEAP_SIZE (1024 * 1024) -#define configMAX_TASK_NAME_LEN (10) -#define configUSE_16_BIT_TICKS 0 -#define configIDLE_SHOULD_YIELD 1 -#define configUSE_MUTEXES 1 -#define configQUEUE_REGISTRY_SIZE 8 -#define configUSE_RECURSIVE_MUTEXES 1 -#define configUSE_APPLICATION_TASK_TAG 0 -#define configUSE_COUNTING_SEMAPHORES 1 -#define configUSE_QUEUE_SETS 1 - -/* This demo creates RTOS objects using both static and dynamic allocation. */ -#define configSUPPORT_STATIC_ALLOCATION 0 -#define configSUPPORT_DYNAMIC_ALLOCATION 1 /* Defaults to 1 anyway. */ - -/* Co-routine definitions. */ -#define configUSE_CO_ROUTINES 0 -#define configMAX_CO_ROUTINE_PRIORITIES (2) - -/* Software timer definitions. */ -#define configUSE_TIMERS 1 -#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) -#define configTIMER_QUEUE_LENGTH 5 -#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2) - -/* Set the following definitions to 1 to include the API function, or zero -to exclude the API function. */ -#define INCLUDE_vTaskPrioritySet 1 -#define INCLUDE_uxTaskPriorityGet 1 -#define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskCleanUpResources 1 -#define INCLUDE_vTaskSuspend 1 -#define INCLUDE_vTaskDelayUntil 1 -#define INCLUDE_vTaskDelay 1 -#define INCLUDE_xTimerPendFunctionCall 1 -#define INCLUDE_eTaskGetState 1 -#define INCLUDE_xTaskAbortDelay 1 -#define INCLUDE_xTaskGetHandle 1 - -/* This demo makes use of one or more example stats formatting functions. These -format the raw data provided by the uxTaskGetSystemState() function in to human -readable ASCII form. See the notes in the implementation of vTaskList() within -FreeRTOS/Source/tasks.c for limitations. */ -#define configUSE_STATS_FORMATTING_FUNCTIONS 1 - -/* Run time stats are not generated. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS and -portGET_RUN_TIME_COUNTER_VALUE must be defined if configGENERATE_RUN_TIME_STATS -is set to 1. */ -#define configGENERATE_RUN_TIME_STATS 1 -extern volatile unsigned int gCpuRuntime; -#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() (gCpuRuntime = 0ul) -#define portGET_RUN_TIME_COUNTER_VALUE() gCpuRuntime - -/* The size of the global output buffer that is available for use when there -are multiple command interpreters running at once (for example, one on a UART -and one on TCP/IP). This is done to prevent an output buffer being defined by -each implementation - which would waste RAM. In this case, there is only one -command interpreter running. */ -#define configCOMMAND_INT_MAX_OUTPUT_SIZE 2096 - -/* Normal assert() semantics without relying on the provision of an assert.h -header file. */ -void vMainAssertCalled(const char *pcFileName, uint32_t ulLineNumber); -#define configASSERT(x) \ - if ((x) == 0) \ - { \ - vMainAssertCalled(__FILE__, __LINE__); \ - } - -/* If configTASK_RETURN_ADDRESS is not defined then a task that attempts to -return from its implementing function will end up in a "task exit error" -function - which contains a call to configASSERT(). However this can give GCC -some problems when it tries to unwind the stack, as the exit error function has -nothing to return to. To avoid this define configTASK_RETURN_ADDRESS to 0. */ -#define configTASK_RETURN_ADDRESS NULL - -/* Bump up the priority of recmuCONTROLLING_TASK_PRIORITY to prevent false -positive errors being reported considering the priority of other tasks in the -system. */ -#define recmuCONTROLLING_TASK_PRIORITY (configMAX_PRIORITIES - 2) - -/****** Hardware specific settings. *******************************************/ - -/* - * The application must provide a function that configures a peripheral to - * create the FreeRTOS tick interrupt, then define configSETUP_TICK_INTERRUPT() - * in FreeRTOSConfig.h to call the function. This file contains a function - * that is suitable for use on the Zynq MPU. FreeRTOS_Tick_Handler() must - * be installed as the peripheral's interrupt handler. - */ -void vConfigureTickInterrupt(void); -#define configSETUP_TICK_INTERRUPT() vConfigureTickInterrupt() - -void vClearTickInterrupt(void); -#define configCLEAR_TICK_INTERRUPT() vClearTickInterrupt() - -/* The following constant describe the hardware, and are correct for the -QEMU-Virt. */ -#define configINTERRUPT_CONTROLLER_BASE_ADDRESS (GICV3_DISTRIBUTOR_BASEADDRESS) -#define configUNIQUE_INTERRUPT_PRIORITIES 16 - -#define fabs(x) __builtin_fabs(x) - -#define configUSE_TRACE_FACILITY 1 - -#endif /* FREERTOS_CONFIG_H */ diff --git a/third-party/freertos/portable/GCC/e2000_aarch64/debug_print_freertos.c b/third-party/freertos/portable/GCC/e2000_aarch64/debug_print_freertos.c deleted file mode 100644 index 12ae72a37680210ac71238996d21b9a1bb9f2595..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/e2000_aarch64/debug_print_freertos.c +++ /dev/null @@ -1,126 +0,0 @@ - -// #include "printf-stdarg.h" -#include "ft_types.h" -#include "exception.h" - -u64 raw_read_elr_el1(void) -{ - u64 elr_el1; - - __asm__ __volatile__("mrs %0, ELR_EL1\n\t" - : "=r"(elr_el1) - : - : "memory"); - - return elr_el1; -} - -u64 raw_read_sp_el1(void) -{ - u64 sp_el1; - - // __asm__ __volatile__("mrs %0, sp\n\t" - // : "=r"(sp_el1) - // : - // : "memory"); - - return sp_el1; -} - -void _origin_print(void) -{ - printf("check is here \r\n"); -} - -void test_freertos_print(u64 x0, u64 x1, u64 x2) -{ - printf("x0 %x \r\n", x0); - printf("x1 %x \r\n", x1); - printf("x2 %x \r\n", x2); - - // printf("elr_el1 %x \r\n", raw_read_elr_el1()); - // printf("spsr_el1 %x \r\n", raw_read_spsr_el1()); - // printf("sp_el1 %x \r\n", raw_read_sp_el1()); - while (1) - { - /* code */ - } -} - -void handle_exception(exception_frame *exc) -{ - printf("elr_el1 %x \r\n", raw_read_elr_el1()); - printf("An exception occur:\r\n"); - printf("exc_type: "); - printf("%x", exc->exc_type); - printf("\r\nESR: "); - printf("%x", exc->exc_esr); - printf(" SP: "); - printf("%x", exc->exc_sp); - printf(" ELR: "); - printf("%x", exc->exc_elr); - printf(" SPSR: "); - printf("%x", exc->exc_spsr); - printf("\r\n x0: "); - printf("%x", exc->x0); - printf(" x1: "); - printf("%x", exc->x1); - printf(" x2: "); - printf("%x", exc->x2); - printf(" x3: "); - printf("%x", exc->x3); - printf("\r\n x4: "); - printf("%x", exc->x4); - printf(" x5: "); - printf("%x", exc->x5); - printf(" x6: "); - printf("%x", exc->x6); - printf(" x7: "); - printf("%x", exc->x7); - printf("\r\n x8: "); - printf("%x", exc->x8); - printf(" x9: "); - printf("%x", exc->x9); - printf(" x10: "); - printf("%x", exc->x10); - printf(" x11: "); - printf("%x", exc->x11); - printf("\r\nx12: "); - printf("%x", exc->x12); - printf(" x13: "); - printf("%x", exc->x13); - printf(" x14: "); - printf("%x", exc->x14); - printf(" x15: "); - printf("%x", exc->x15); - printf("\r\nx16: "); - printf("%x", exc->x16); - printf(" x17: "); - printf("%x", exc->x17); - printf(" x18: "); - printf("%x", exc->x18); - printf(" x19: "); - printf("%x", exc->x19); - printf("\r\nx20: "); - printf("%x", exc->x20); - printf(" x21: "); - printf("%x", exc->x21); - printf(" x22: "); - printf("%x", exc->x22); - printf(" x23: "); - printf("%x", exc->x23); - printf("\r\nx24: "); - printf("%x", exc->x24); - printf(" x25: "); - printf("%x", exc->x25); - printf(" x26: "); - printf("%x", exc->x26); - printf(" x27: "); - printf("%x", exc->x27); - printf("\r\nx28: "); - printf("%x", exc->x28); - printf(" x29: "); - printf("%x", exc->x29); - printf(" x30: "); - printf("%x", exc->x30); -} \ No newline at end of file diff --git a/third-party/freertos/portable/GCC/e2000_aarch64/port.c b/third-party/freertos/portable/GCC/e2000_aarch64/port.c deleted file mode 100644 index 1fcf62e1cc33991b7e5567f625e1aa2d96d75cc2..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/e2000_aarch64/port.c +++ /dev/null @@ -1,508 +0,0 @@ -/* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -/* Standard includes. */ -#include - -/* Scheduler includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "ft_types.h" - -#ifndef configUNIQUE_INTERRUPT_PRIORITIES -#error configUNIQUE_INTERRUPT_PRIORITIES must be defined. See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif - -#ifndef configSETUP_TICK_INTERRUPT -#error configSETUP_TICK_INTERRUPT() must be defined. See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif /* configSETUP_TICK_INTERRUPT */ - -#ifndef configMAX_API_CALL_INTERRUPT_PRIORITY -#error configMAX_API_CALL_INTERRUPT_PRIORITY must be defined. See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif - -#if configMAX_API_CALL_INTERRUPT_PRIORITY == 0 -#error configMAX_API_CALL_INTERRUPT_PRIORITY must not be set to 0 -#endif - -#if configMAX_API_CALL_INTERRUPT_PRIORITY > configUNIQUE_INTERRUPT_PRIORITIES -#error configMAX_API_CALL_INTERRUPT_PRIORITY must be less than or equal to configUNIQUE_INTERRUPT_PRIORITIES as the lower the numeric priority value the higher the logical interrupt priority -#endif - -#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 -/* Check the configuration. */ -#if (configMAX_PRIORITIES > 32) -#error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice. -#endif -#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ - -/* In case security extensions are implemented. */ -#if configMAX_API_CALL_INTERRUPT_PRIORITY <= (configUNIQUE_INTERRUPT_PRIORITIES / 2) -#error configMAX_API_CALL_INTERRUPT_PRIORITY must be greater than ( configUNIQUE_INTERRUPT_PRIORITIES / 2 ) -#endif - -/* Some vendor specific files default configCLEAR_TICK_INTERRUPT() in -portmacro.h. */ -#ifndef configCLEAR_TICK_INTERRUPT -#define configCLEAR_TICK_INTERRUPT() -#endif - -/* A critical section is exited when the critical section nesting count reaches -this value. */ -#define portNO_CRITICAL_NESTING ((size_t)0) - -/* In all GICs 255 can be written to the priority mask register to unmask all -(but the lowest) interrupt priority. */ -#define portUNMASK_VALUE (0xF0UL) - -/* Tasks are not created with a floating point context, but can be given a -floating point context after they have been created. A variable is stored as -part of the tasks context that holds portNO_FLOATING_POINT_CONTEXT if the task -does not have an FPU context, or any other value if the task does have an FPU -context. */ -#define portNO_FLOATING_POINT_CONTEXT ((StackType_t)0) - -/* Constants required to setup the initial task context. */ -#define portSP_ELx ((StackType_t)0x01) -#define portSP_EL0 ((StackType_t)0x00) - -#if defined(GUEST) -#define portEL1 ((StackType_t)0x04) -#define portINITIAL_PSTATE (portEL1 | portSP_EL0) -#else -#define portEL3 ((StackType_t)0x0c) -/* At the time of writing, the BSP only supports EL3. */ -#define portINITIAL_PSTATE (portEL3 | portSP_EL0) -#endif - -/* Used by portASSERT_IF_INTERRUPT_PRIORITY_INVALID() when ensuring the binary -point is zero. */ -#define portBINARY_POINT_BITS ((uint8_t)0x03) - -/* Masks all bits in the APSR other than the mode bits. */ -#define portAPSR_MODE_BITS_MASK (0x0C) - -/* The I bit in the DAIF bits. */ -#define portDAIF_I (0x80) - -/* Macro to unmask all interrupt priorities. */ -#define portCLEAR_INTERRUPT_MASK() \ - { \ - portDISABLE_INTERRUPTS(); \ - setPriorityMask(portUNMASK_VALUE); \ - __asm volatile("DSB SY \n" \ - "ISB SY \n"); \ - portENABLE_INTERRUPTS(); \ - } - -/* Hardware specifics used when sanity checking the configuration. */ -#define portINTERRUPT_PRIORITY_REGISTER_OFFSET (0x400UL + 32UL) // -#define portMAX_8_BIT_VALUE ((uint8_t)0xff) -#define portBIT_0_SET ((uint8_t)0x01) - -/*-----------------------------------------------------------*/ - -/* - * Starts the first task executing. This function is necessarily written in - * assembly code so is implemented in portASM.s. - */ -extern void vPortRestoreTaskContext(void); - -/*-----------------------------------------------------------*/ - -/* A variable is used to keep track of the critical section nesting. This -variable has to be stored as part of the task context and must be initialised to -a non zero value to ensure interrupts don't inadvertently become unmasked before -the scheduler starts. As it is stored as part of the task context it will -automatically be set to 0 when the first task is started. */ -volatile uint64_t ullCriticalNesting = 9999ULL; - -/* Saved as part of the task context. If ullPortTaskHasFPUContext is non-zero -then floating point context must be saved and restored for the task. */ -uint64_t ullPortTaskHasFPUContext = pdFALSE; - -/* Set to 1 to pend a context switch from an ISR. */ -uint64_t ullPortYieldRequired = pdFALSE; - -/* Counts the interrupt nesting depth. A context switch is only performed if -if the nesting depth is 0. */ -uint64_t ullPortInterruptNesting = pdFALSE; - -/* Used in the ASM code. */ -__attribute__((used)) const uint64_t ullMaxAPIPriorityMask = (configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT); - -/*-----------------------------------------------------------*/ - -/* - * See header file for description. - */ -StackType_t *pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters) -{ - /* Setup the initial stack of the task. The stack is set exactly as - expected by the portRESTORE_CONTEXT() macro. */ - - /* First all the general purpose registers. */ - pxTopOfStack--; - *pxTopOfStack = 0x0101010101010101ULL; /* R1 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)pvParameters; /* R0 */ - pxTopOfStack--; - *pxTopOfStack = 0x0303030303030303ULL; /* R3 */ - pxTopOfStack--; - *pxTopOfStack = 0x0202020202020202ULL; /* R2 */ - pxTopOfStack--; - *pxTopOfStack = 0x0505050505050505ULL; /* R5 */ - pxTopOfStack--; - *pxTopOfStack = 0x0404040404040404ULL; /* R4 */ - pxTopOfStack--; - *pxTopOfStack = 0x0707070707070707ULL; /* R7 */ - pxTopOfStack--; - *pxTopOfStack = 0x0606060606060606ULL; /* R6 */ - pxTopOfStack--; - *pxTopOfStack = 0x0909090909090909ULL; /* R9 */ - pxTopOfStack--; - *pxTopOfStack = 0x0808080808080808ULL; /* R8 */ - pxTopOfStack--; - *pxTopOfStack = 0x1111111111111111ULL; /* R11 */ - pxTopOfStack--; - *pxTopOfStack = 0x1010101010101010ULL; /* R10 */ - pxTopOfStack--; - *pxTopOfStack = 0x1313131313131313ULL; /* R13 */ - pxTopOfStack--; - *pxTopOfStack = 0x1212121212121212ULL; /* R12 */ - pxTopOfStack--; - *pxTopOfStack = 0x1515151515151515ULL; /* R15 */ - pxTopOfStack--; - *pxTopOfStack = 0x1414141414141414ULL; /* R14 */ - pxTopOfStack--; - *pxTopOfStack = 0x1717171717171717ULL; /* R17 */ - pxTopOfStack--; - *pxTopOfStack = 0x1616161616161616ULL; /* R16 */ - pxTopOfStack--; - *pxTopOfStack = 0x1919191919191919ULL; /* R19 */ - pxTopOfStack--; - *pxTopOfStack = 0x1818181818181818ULL; /* R18 */ - pxTopOfStack--; - *pxTopOfStack = 0x2121212121212121ULL; /* R21 */ - pxTopOfStack--; - *pxTopOfStack = 0x2020202020202020ULL; /* R20 */ - pxTopOfStack--; - *pxTopOfStack = 0x2323232323232323ULL; /* R23 */ - pxTopOfStack--; - *pxTopOfStack = 0x2222222222222222ULL; /* R22 */ - pxTopOfStack--; - *pxTopOfStack = 0x2525252525252525ULL; /* R25 */ - pxTopOfStack--; - *pxTopOfStack = 0x2424242424242424ULL; /* R24 */ - pxTopOfStack--; - *pxTopOfStack = 0x2727272727272727ULL; /* R27 */ - pxTopOfStack--; - *pxTopOfStack = 0x2626262626262626ULL; /* R26 */ - pxTopOfStack--; - *pxTopOfStack = 0x2929292929292929ULL; /* R29 */ - pxTopOfStack--; - *pxTopOfStack = 0x2828282828282828ULL; /* R28 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x00; /* XZR - has no effect, used so there are an even number of registers. */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x00; /* R30 - procedure call link register. */ - pxTopOfStack--; - - *pxTopOfStack = portINITIAL_PSTATE; - pxTopOfStack--; - - *pxTopOfStack = (StackType_t)pxCode; /* Exception return address. */ - pxTopOfStack--; - - /* The task will start with a critical nesting count of 0 as interrupts are - enabled. */ - *pxTopOfStack = portNO_CRITICAL_NESTING; - pxTopOfStack--; - - /* The task will start without a floating point context. A task that uses - the floating point hardware must call vPortTaskUsesFPU() before executing - any floating point instructions. */ - *pxTopOfStack = portNO_FLOATING_POINT_CONTEXT; - - return pxTopOfStack; -} -/*-----------------------------------------------------------*/ - -BaseType_t xPortStartScheduler(void) -{ - uint32_t ulAPSR; - -#if (configASSERT_DEFINED == 1) - { - volatile uint32_t ulOriginalPriority; - volatile uint8_t *const pucFirstUserPriorityRegister = (volatile uint8_t *const)(configINTERRUPT_CONTROLLER_BASE_ADDRESS + portINTERRUPT_PRIORITY_REGISTER_OFFSET); - volatile uint8_t ucMaxPriorityValue; - - /* Determine how many priority bits are implemented in the GIC. - Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = *pucFirstUserPriorityRegister; - /* Determine the number of priority bits available. First write to - all possible bits. */ - *pucFirstUserPriorityRegister = portMAX_8_BIT_VALUE; - - /* Read the value back to see how many bits stuck. */ - ucMaxPriorityValue = *pucFirstUserPriorityRegister; - /* Shift to the least significant bits. */ - while ((ucMaxPriorityValue & portBIT_0_SET) != portBIT_0_SET) - { - ucMaxPriorityValue >>= (uint8_t)0x01; - } - /* Sanity check configUNIQUE_INTERRUPT_PRIORITIES matches the read - value. */ - configASSERT(ucMaxPriorityValue >= portLOWEST_INTERRUPT_PRIORITY); - - /* Restore the clobbered interrupt priority register to its original - value. */ - *pucFirstUserPriorityRegister = ulOriginalPriority; - } -#endif /* conifgASSERT_DEFINED */ - - /* At the time of writing, the BSP only supports EL1. */ - __asm volatile("MRS %0, CurrentEL" - : "=r"(ulAPSR)); - ulAPSR &= portAPSR_MODE_BITS_MASK; - printf("ulAPSR %x \r\n", ulAPSR); -#if defined(GUEST) - - configASSERT(ulAPSR == portEL1); - if (ulAPSR == portEL1) -#else - configASSERT(ulAPSR == portEL3); - if (ulAPSR == portEL3) -#endif - { - /* Only continue if the binary point value is set to its lowest possible - setting. See the comments in vPortValidateInterruptPriority() below for - more information. */ - // configASSERT((portICCBPR_BINARY_POINT_REGISTER & portBINARY_POINT_BITS) <= portMAX_BINARY_POINT_VALUE); - configASSERT((getBPR1() & portBINARY_POINT_BITS) <= portMAX_BINARY_POINT_VALUE); - - // if ((portICCBPR_BINARY_POINT_REGISTER & portBINARY_POINT_BITS) <= portMAX_BINARY_POINT_VALUE) - if ((getBPR1() & portBINARY_POINT_BITS) <= portMAX_BINARY_POINT_VALUE) - { - /* Interrupts are turned off in the CPU itself to ensure a tick does - not execute while the scheduler is being started. Interrupts are - automatically turned back on in the CPU when the first task starts - executing. */ - portDISABLE_INTERRUPTS(); - - /* Start the timer that generates the tick ISR. */ - configSETUP_TICK_INTERRUPT(); - - /* Start the first task executing. */ - vPortRestoreTaskContext(); - } - } - - return 0; -} -/*-----------------------------------------------------------*/ - -void vPortEndScheduler(void) -{ - /* Not implemented in ports where there is nothing to return to. - Artificially force an assert. */ - configASSERT(ullCriticalNesting == 1000ULL); -} -/*-----------------------------------------------------------*/ - -void vPortEnterCritical(void) -{ - /* Mask interrupts up to the max syscall interrupt priority. */ - uxPortSetInterruptMask(); - - /* Now interrupts are disabled ullCriticalNesting can be accessed - directly. Increment ullCriticalNesting to keep a count of how many times - portENTER_CRITICAL() has been called. */ - ullCriticalNesting++; - - /* This is not the interrupt safe version of the enter critical function so - assert() if it is being called from an interrupt context. Only API - functions that end in "FromISR" can be used in an interrupt. Only assert if - the critical nesting count is 1 to protect against recursive calls if the - assert function also uses a critical section. */ - if (ullCriticalNesting == 1ULL) - { - configASSERT(ullPortInterruptNesting == 0); - } -} -/*-----------------------------------------------------------*/ - -void vPortExitCritical(void) -{ - if (ullCriticalNesting > portNO_CRITICAL_NESTING) - { - /* Decrement the nesting count as the critical section is being - exited. */ - ullCriticalNesting--; - - /* If the nesting level has reached zero then all interrupt - priorities must be re-enabled. */ - if (ullCriticalNesting == portNO_CRITICAL_NESTING) - { - /* Critical nesting has reached zero so all interrupt priorities - should be unmasked. */ - portCLEAR_INTERRUPT_MASK(); - } - } -} -/*-----------------------------------------------------------*/ - -void FreeRTOS_Tick_Handler(void) -{ -/* Interrupts should not be enabled before this point. */ -#if (configASSERT_DEFINED == 1) - { - uint32_t ulMaskBits; - - __asm volatile("mrs %0, daif" - : "=r"(ulMaskBits)::"memory"); - configASSERT((ulMaskBits & portDAIF_I) != 0); - } -#endif /* configASSERT_DEFINED */ - - /* Set interrupt mask before altering scheduler structures. The tick - handler runs at the lowest priority, so interrupts cannot already be masked, - so there is no need to save and restore the current mask value. It is - necessary to turn off interrupts in the CPU itself while the ICCPMR is being - updated. */ - - setPriorityMask(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT); - __asm volatile("dsb sy \n" - "isb sy \n" :: - : "memory"); - - /* Ok to enable interrupts after the interrupt source has been cleared. */ - configCLEAR_TICK_INTERRUPT(); - portENABLE_INTERRUPTS(); - - /* Increment the RTOS tick. */ - if (xTaskIncrementTick() != pdFALSE) - { - ullPortYieldRequired = pdTRUE; - } - - /* Ensure all interrupt priorities are active again. */ - portCLEAR_INTERRUPT_MASK(); -} -/*-----------------------------------------------------------*/ - -void vPortTaskUsesFPU(void) -{ - /* A task is registering the fact that it needs an FPU context. Set the - FPU flag (which is saved as part of the task context). */ - ullPortTaskHasFPUContext = pdTRUE; - printf("ullPortTaskHasFPUContext %x \r\n", ullPortTaskHasFPUContext); - /* Consider initialising the FPSR here - but probably not necessary in - AArch64. */ -} -/*-----------------------------------------------------------*/ - -void vPortClearInterruptMask(UBaseType_t uxNewMaskValue) -{ - if (uxNewMaskValue == pdFALSE) - { - portCLEAR_INTERRUPT_MASK(); - } -} -/*-----------------------------------------------------------*/ - -UBaseType_t uxPortSetInterruptMask(void) -{ - uint32_t ulReturn; - - /* Interrupt in the CPU must be turned off while the ICCPMR is being - updated. */ - portDISABLE_INTERRUPTS(); - if (getPriorityMask() == (uint32_t)(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT)) - { - /* Interrupts were already masked. */ - ulReturn = pdTRUE; - } - else - { - ulReturn = pdFALSE; - setPriorityMask(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT); - // portICCPMR_PRIORITY_MASK_REGISTER = (uint32_t)(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT); - __asm volatile("dsb sy \n" - "isb sy \n" :: - : "memory"); - } - portENABLE_INTERRUPTS(); - - return ulReturn; -} -/*-----------------------------------------------------------*/ - -#if (configASSERT_DEFINED == 1) - -void vPortValidateInterruptPriority(void) -{ - /* The following assertion will fail if a service routine (ISR) for - an interrupt that has been assigned a priority above - configMAX_SYSCALL_INTERRUPT_PRIORITY calls an ISR safe FreeRTOS API - function. ISR safe FreeRTOS API functions must *only* be called - from interrupts that have been assigned a priority at or below - configMAX_SYSCALL_INTERRUPT_PRIORITY. - - Numerically low interrupt priority numbers represent logically high - interrupt priorities, therefore the priority of the interrupt must - be set to a value equal to or numerically *higher* than - configMAX_SYSCALL_INTERRUPT_PRIORITY. - - FreeRTOS maintains separate thread and ISR API functions to ensure - interrupt entry is as fast and simple as possible. */ - configASSERT(getRunningPriority() >= (uint32_t)(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT)); - - /* Priority grouping: The interrupt controller (GIC) allows the bits - that define each interrupt's priority to be split between bits that - define the interrupt's pre-emption priority bits and bits that define - the interrupt's sub-priority. For simplicity all bits must be defined - to be pre-emption priority bits. The following assertion will fail if - this is not the case (if some bits represent a sub-priority). - - The priority grouping is configured by the GIC's binary point register - (ICCBPR). Writting 0 to ICCBPR will ensure it is set to its lowest - possible value (which may be above 0). */ - configASSERT((getBPR1() & portBINARY_POINT_BITS) <= portMAX_BINARY_POINT_VALUE); -} - -#endif /* configASSERT_DEFINED */ -/*-----------------------------------------------------------*/ - -_WEAK void vApplicationTickHook(void) -{ -} - -_WEAK void vApplicationIdleHook(void) -{ -} diff --git a/third-party/freertos/portable/GCC/e2000_aarch64/portmacro.h b/third-party/freertos/portable/GCC/e2000_aarch64/portmacro.h deleted file mode 100644 index ad1b13647688783f28d95f26411cbcde5aecd275..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/e2000_aarch64/portmacro.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -#ifndef PORTMACRO_H -#define PORTMACRO_H - -#ifdef __cplusplus -extern "C" -{ -#endif -#include "ft_types.h" -/*----------------------------------------------------------- - * Port specific definitions. - * - * The settings in this file configure FreeRTOS correctly for the given hardware - * and compiler. - * - * These settings should not be altered. - *----------------------------------------------------------- - */ - -/* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE double -#define portLONG long -#define portSHORT short -#define portSTACK_TYPE size_t -#define portBASE_TYPE long - - typedef portSTACK_TYPE StackType_t; - typedef portBASE_TYPE BaseType_t; - typedef uint64_t UBaseType_t; - - typedef uint64_t TickType_t; -#define portMAX_DELAY ((TickType_t)0xffffffffffffffff) - -/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do -not need to be guarded with a critical section. */ -#define portTICK_TYPE_IS_ATOMIC 1 - -/*-----------------------------------------------------------*/ - -/* Hardware specifics. */ -#define portSTACK_GROWTH (-1) -#define portTICK_PERIOD_MS ((TickType_t)1000 / configTICK_RATE_HZ) -#define portBYTE_ALIGNMENT 16 -#define portPOINTER_SIZE_TYPE uint64_t - -/*-----------------------------------------------------------*/ - -/* Task utilities. */ - -/* Called at the end of an ISR that can cause a context switch. */ -#define portEND_SWITCHING_ISR(xSwitchRequired) \ - { \ - extern uint64_t ullPortYieldRequired; \ - \ - if (xSwitchRequired != pdFALSE) \ - { \ - ullPortYieldRequired = pdTRUE; \ - } \ - } - -#define portYIELD_FROM_ISR(x) portEND_SWITCHING_ISR(x) -#if defined(GUEST) -#define portYIELD() __asm volatile("SVC 0" :: \ - : "memory") -#else -#define portYIELD() __asm volatile("SMC 0" :: \ - : "memory") -#endif - /*----------------------------------------------------------- - * Critical section control - *----------------------------------------------------------*/ - - extern void vPortEnterCritical(void); - extern void vPortExitCritical(void); - extern UBaseType_t uxPortSetInterruptMask(void); - extern void vPortClearInterruptMask(UBaseType_t uxNewMaskValue); - extern void vPortInstallFreeRTOSVectorTable(void); - -#define portDISABLE_INTERRUPTS() \ - __asm volatile("MSR DAIFSET, #2" :: \ - : "memory"); \ - __asm volatile("DSB SY"); \ - __asm volatile("ISB SY"); - -#define portENABLE_INTERRUPTS() \ - __asm volatile("MSR DAIFCLR, #2" :: \ - : "memory"); \ - __asm volatile("DSB SY"); \ - __asm volatile("ISB SY"); - -/* These macros do not globally disable/enable interrupts. They do mask off -interrupts that have a priority below configMAX_API_CALL_INTERRUPT_PRIORITY. */ -#define portENTER_CRITICAL() vPortEnterCritical(); -#define portEXIT_CRITICAL() vPortExitCritical(); -#define portSET_INTERRUPT_MASK_FROM_ISR() uxPortSetInterruptMask() -#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x) - -/*-----------------------------------------------------------*/ - -/* Task function macros as described on the FreeRTOS.org WEB site. These are -not required for this port but included in case common demo code that uses these -macros is used. */ -#define portTASK_FUNCTION_PROTO(vFunction, pvParameters) void vFunction(void *pvParameters) -#define portTASK_FUNCTION(vFunction, pvParameters) void vFunction(void *pvParameters) - - /* Prototype of the FreeRTOS tick handler. This must be installed as the -handler for whichever peripheral is used to generate the RTOS tick. */ - void FreeRTOS_Tick_Handler(void); - - /* Any task that uses the floating point unit MUST call vPortTaskUsesFPU() -before any floating point instructions are executed. */ - void vPortTaskUsesFPU(void); -#define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU() - -#define portLOWEST_INTERRUPT_PRIORITY (((uint32_t)configUNIQUE_INTERRUPT_PRIORITIES) - 1UL) -#define portLOWEST_USABLE_INTERRUPT_PRIORITY (portLOWEST_INTERRUPT_PRIORITY - 1UL) - -/* Architecture specific optimisations. */ -#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION -#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 -#endif - -#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 - -/* Store/clear the ready priorities in a bit map. */ -#define portRECORD_READY_PRIORITY(uxPriority, uxReadyPriorities) (uxReadyPriorities) |= (1UL << (uxPriority)) -#define portRESET_READY_PRIORITY(uxPriority, uxReadyPriorities) (uxReadyPriorities) &= ~(1UL << (uxPriority)) - - /*-----------------------------------------------------------*/ - -#define portGET_HIGHEST_PRIORITY(uxTopPriority, uxReadyPriorities) uxTopPriority = (31 - __builtin_clz(uxReadyPriorities)) - -#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ - -#ifdef configASSERT - void vPortValidateInterruptPriority(void); -#define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority() -#endif /* configASSERT */ - -#define portNOP() __asm volatile("NOP") -#define portINLINE __inline - -#ifdef __cplusplus -} /* extern C */ -#endif - -/* The number of bits to shift for an interrupt priority is dependent on the -number of bits implemented by the interrupt controller. */ -#if configUNIQUE_INTERRUPT_PRIORITIES == 16 -#define portPRIORITY_SHIFT 4 -#define portMAX_BINARY_POINT_VALUE 3 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 32 -#define portPRIORITY_SHIFT 3 -#define portMAX_BINARY_POINT_VALUE 2 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 64 -#define portPRIORITY_SHIFT 2 -#define portMAX_BINARY_POINT_VALUE 1 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 128 -#define portPRIORITY_SHIFT 1 -#define portMAX_BINARY_POINT_VALUE 0 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 256 -#define portPRIORITY_SHIFT 0 -#define portMAX_BINARY_POINT_VALUE 0 -#else -#error Invalid configUNIQUE_INTERRUPT_PRIORITIES setting. configUNIQUE_INTERRUPT_PRIORITIES must be set to the number of unique priorities implemented by the target hardware -#endif - -/* Interrupt controller access addresses. */ -#define portICCPMR_PRIORITY_MASK_OFFSET (0x04) -#define portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET (0x0C) -#define portICCEOIR_END_OF_INTERRUPT_OFFSET (0x10) -#define portICCBPR_BINARY_POINT_OFFSET (0x08) -#define portICCRPR_RUNNING_PRIORITY_OFFSET (0x14) - -// #define portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS (GIC_GICC_BASE) -// #define portICCPMR_PRIORITY_MASK_REGISTER (*((volatile uint32_t *)(portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET))) -// #define portICCIAR_INTERRUPT_ACKNOWLEDGE_REGISTER_ADDRESS (portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET) -// #define portICCEOIR_END_OF_INTERRUPT_REGISTER_ADDRESS (portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCEOIR_END_OF_INTERRUPT_OFFSET) -// #define portICCPMR_PRIORITY_MASK_REGISTER_ADDRESS (portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET) -// #define portICCBPR_BINARY_POINT_REGISTER (*((const volatile uint32_t *)(portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCBPR_BINARY_POINT_OFFSET))) -// #define portICCRPR_RUNNING_PRIORITY_REGISTER (*((const volatile uint32_t *)(portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCRPR_RUNNING_PRIORITY_OFFSET))) - -#endif /* PORTMACRO_H */ diff --git a/third-party/freertos/portable/GCC/ft2004_aarch32/portASM.S b/third-party/freertos/portable/GCC/ft2004_aarch32/portASM.S deleted file mode 100644 index aa5745a93c6b9ba724e1bafb413a76369ebd60c1..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/ft2004_aarch32/portASM.S +++ /dev/null @@ -1,361 +0,0 @@ -/* - * FreeRTOS Kernel V10.4.2 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * https://www.FreeRTOS.org - * https://github.com/FreeRTOS - * - * 1 tab == 4 spaces! - */ - #include "FreeRTOSConfig.h" - - .eabi_attribute Tag_ABI_align_preserved, 1 - .text - .arm - - .set SYS_MODE, 0x1f - .set SVC_MODE, 0x13 - .set IRQ_MODE, 0x12 - - /* Hardware registers. */ - /*.extern ulICCIAR*/ - /*.extern ulICCEOIR*/ - /*.extern ulICCPMR*/ - - /* Variables and functions. */ - .extern ulMaxAPIPriorityMask - .extern _freertos_vector_table - .extern pxCurrentTCB - .extern vTaskSwitchContext - .extern vApplicationIRQHandler - .extern ulPortInterruptNesting - .extern ulPortTaskHasFPUContext - - .global FreeRTOS_IRQ_Handler - .global FreeRTOS_SWI_Handler - .global vPortRestoreTaskContext - - -.macro portSAVE_CONTEXT - - /* Save the LR and SPSR onto the system mode stack before switching to - system mode to save the remaining system mode registers. */ - SRSDB sp!, #SYS_MODE - CPS #SYS_MODE - PUSH {R0-R12, R14} - - /* Push the critical nesting count. */ - LDR R2, ulCriticalNestingConst - LDR R1, [R2] - PUSH {R1} - - /* Does the task have a floating point context that needs saving? If - ulPortTaskHasFPUContext is 0 then no. */ - LDR R2, ulPortTaskHasFPUContextConst - LDR R3, [R2] - CMP R3, #0 - - /* Save the floating point context, if any. */ - FMRXNE R1, FPSCR - VPUSHNE {D0-D15} - VPUSHNE {D16-D31} - PUSHNE {R1} - - - /* Save ulPortTaskHasFPUContext itself. */ - PUSH {R3} - - - /* Save the stack pointer in the TCB. */ - LDR R0, pxCurrentTCBConst - LDR R1, [R0] - STR SP, [R1] - - .endm - -; /**********************************************************************/ - -.macro portRESTORE_CONTEXT - /* Set the SP to point to the stack of the task being restored. */ - LDR R0, pxCurrentTCBConst - LDR R1, [R0] - LDR SP, [R1] - - /* Is there a floating point context to restore? If the restored - ulPortTaskHasFPUContext is zero then no. */ - LDR R0, ulPortTaskHasFPUContextConst - POP {R1} - STR R1, [R0] - CMP R1, #0 - - - /* Restore the floating point context, if any. */ - POPNE {R0} - VPOPNE {D16-D31} - VPOPNE {D0-D15} - VMSRNE FPSCR, R0 - - - /* Restore the critical section nesting depth. */ - LDR R0, ulCriticalNestingConst - POP {R1} - STR R1, [R0] - - - /* Ensure the priority mask is correct for the critical nesting depth. */ - /*LDR R2, ulICCPMRConst - LDR R2, [R2] - CMP R1, #0 - MOVEQ R4, #255 - LDRNE R4, ulMaxAPIPriorityMaskConst - LDRNE R4, [R4] - STR R4, [R2] */ - - CMP R1, #0 - MOVEQ R4, #255 - LDRNE R4, ulMaxAPIPriorityMaskConst - LDRNE R4, [R4] - MCR P15, 0, R4, C4, C6, 0 - ISB - - - /* Restore all system mode registers other than the SP (which is already - being used). */ - POP {R0-R12, R14} - - /* Return to the task code, loading CPSR on the way. */ - RFEIA sp! - - .endm - - - - -/****************************************************************************** - * SVC handler is used to start the scheduler. - *****************************************************************************/ -.align 4 -.type FreeRTOS_SWI_Handler, %function -FreeRTOS_SWI_Handler: - /* Save the context of the current task and select a new task to run. */ - portSAVE_CONTEXT - LDR R0, vTaskSwitchContextConst - BLX R0 - portRESTORE_CONTEXT - - -/****************************************************************************** - * vPortRestoreTaskContext is used to start the scheduler. - *****************************************************************************/ -.type vPortRestoreTaskContext, %function -vPortRestoreTaskContext: - /* Switch to system mode. */ - CPS #SYS_MODE - portRESTORE_CONTEXT - -.align 4 -.type FreeRTOS_IRQ_Handler, %function -FreeRTOS_IRQ_Handler: - /* Return to the interrupted instruction. */ - SUB lr, lr, #4 - - /* Push the return address and SPSR. */ - PUSH {lr} - MRS lr, SPSR - PUSH {lr} - - /* Change to supervisor mode to allow reentry. */ - CPS #SVC_MODE - - /* Push used registers. */ - PUSH {r0-r4, r12} - - /* Increment nesting count. r3 holds the address of ulPortInterruptNesting - for future use. r1 holds the original ulPortInterruptNesting value for - future use. */ - LDR r3, ulPortInterruptNestingConst - LDR r1, [r3] - ADD r4, r1, #1 - STR r4, [r3] - - /* Read value from the interrupt acknowledge register, which is stored in r0 - for future parameter and interrupt clearing use. - LDR r2, ulICCIARConst - LDR r2, [r2] - LDR r0, [r2,#0xC] - - */ - - mrc p15, 0, r0, c12, c12, 0 - isb - - /* Ensure bit 2 of the stack pointer is clear. r2 holds the bit 2 value for - future use. _RB_ Does this ever actually need to be done provided the start - of the stack is 8-byte aligned? */ - MOV r2, sp - AND r2, r2, #4 - SUB sp, sp, r2 - - /* Call the interrupt handler. r4 pushed to maintain alignment. */ - PUSH {r0-r4, lr} - LDR r1, vApplicationIRQHandlerConst - BLX r1 - POP {r0-r4, lr} - ADD sp, sp, r2 - - CPSID i - DSB - ISB - - /* Write the value read from ICCIAR to ICCEOIR. - LDR r4, ulICCEOIRConst - LDR r4, [r4] - STR r0, [r4] - */ - - mcr p15, 0, r0, c12, c12, 1 - isb - - /* Restore the old nesting count. */ - STR r1, [r3] - - /* A context switch is never performed if the nesting count is not 0. */ - CMP r1, #0 - BNE exit_without_switch - - /* Did the interrupt request a context switch? r1 holds the address of - ulPortYieldRequired and r0 the value of ulPortYieldRequired for future - use. */ - LDR r1, =ulPortYieldRequired - LDR r0, [r1] - CMP r0, #0 - BNE switch_before_exit - -exit_without_switch: - /* No context switch. Restore used registers, LR_irq and SPSR before - returning. */ - POP {r0-r4, r12} - CPS #IRQ_MODE - POP {LR} - MSR SPSR_cxsf, LR - POP {LR} - MOVS PC, LR - -switch_before_exit: - /* A context swtich is to be performed. Clear the context switch pending - flag. */ - MOV r0, #0 - STR r0, [r1] - - /* Restore used registers, LR-irq and SPSR before saving the context - to the task stack. */ - POP {r0-r4, r12} - CPS #IRQ_MODE - POP {LR} - MSR SPSR_cxsf, LR - POP {LR} - portSAVE_CONTEXT - - /* Call the function that selects the new task to execute. - vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD - instructions, or 8 byte aligned stack allocated data. LR does not need - saving as a new LR will be loaded by portRESTORE_CONTEXT anyway. */ - LDR R0, vTaskSwitchContextConst - BLX R0 - - /* Restore the context of, and branch to, the task selected to execute - next. */ - portRESTORE_CONTEXT - -/****************************************************************************** - * If the application provides an implementation of vApplicationIRQHandler(), - * then it will get called directly without saving the FPU registers on - * interrupt entry, and this weak implementation of - * vApplicationIRQHandler() will not get called. - * - * If the application provides its own implementation of - * vApplicationFPUSafeIRQHandler() then this implementation of - * vApplicationIRQHandler() will be called, save the FPU registers, and then - * call vApplicationFPUSafeIRQHandler(). - * - * Therefore, if the application writer wants FPU registers to be saved on - * interrupt entry their IRQ handler must be called - * vApplicationFPUSafeIRQHandler(), and if the application writer does not want - * FPU registers to be saved on interrupt entry their IRQ handler must be - * called vApplicationIRQHandler(). - *****************************************************************************/ - -.align 4 -.weak vApplicationIRQHandler -.type vApplicationIRQHandler, %function -vApplicationIRQHandler: - PUSH {LR} - FMRX R1, FPSCR - VPUSH {D0-D15} - VPUSH {D16-D31} - PUSH {R1} - - LDR r1, vApplicationFPUSafeIRQHandlerConst - BLX r1 - - POP {R0} - VPOP {D16-D31} - VPOP {D0-D15} - VMSR FPSCR, R0 - - POP {PC} - -/****************************************************************************** - * If the application provides an implementation of vApplicationIRQHandler(), - * then it will get called directly without saving the FPU registers on - * interrupt entry, and this weak implementation of - * vApplicationIRQHandler() will not get called. - * - * If the application provides its own implementation of - * vApplicationFPUSafeIRQHandler() then this implementation of - * vApplicationIRQHandler() will be called, save the FPU registers, and then - * call vApplicationFPUSafeIRQHandler(). - * - * Therefore, if the application writer wants FPU registers to be saved on - * interrupt entry their IRQ handler must be called - * vApplicationFPUSafeIRQHandler(), and if the application writer does not want - * FPU registers to be saved on interrupt entry their IRQ handler must be - * called vApplicationIRQHandler(). - *****************************************************************************/ - - -/* ulICCIARConst: .word ulICCIAR */ -/* ulICCEOIRConst: .word ulICCEOIR */ -/* ulICCPMRConst: .word ulICCPMR */ -pxCurrentTCBConst: .word pxCurrentTCB -ulCriticalNestingConst: .word ulCriticalNesting -ulPortTaskHasFPUContextConst: .word ulPortTaskHasFPUContext -ulMaxAPIPriorityMaskConst: .word ulMaxAPIPriorityMask -vTaskSwitchContextConst: .word vTaskSwitchContext -vApplicationIRQHandlerConst: .word vApplicationIRQHandler -ulPortInterruptNestingConst: .word ulPortInterruptNesting -vApplicationFPUSafeIRQHandlerConst: .word vApplicationFPUSafeIRQHandler - -.end - - - - - diff --git a/third-party/freertos/portable/GCC/ft2004_aarch32/portmacro.h b/third-party/freertos/portable/GCC/ft2004_aarch32/portmacro.h deleted file mode 100644 index 24b9acc2e868006764318dddcff55afb0d5331a2..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/ft2004_aarch32/portmacro.h +++ /dev/null @@ -1,208 +0,0 @@ -/* - * FreeRTOS Kernel V10.4.2 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * https://www.FreeRTOS.org - * https://github.com/FreeRTOS - * - * 1 tab == 4 spaces! - */ - -#ifndef PORTMACRO_H -#define PORTMACRO_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -/*----------------------------------------------------------- - * Port specific definitions. - * - * The settings in this file configure FreeRTOS correctly for the given hardware - * and compiler. - * - * These settings should not be altered. - *----------------------------------------------------------- - */ - -/* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE double -#define portLONG long -#define portSHORT short -#define portSTACK_TYPE uint32_t -#define portBASE_TYPE long - - typedef portSTACK_TYPE StackType_t; - typedef long BaseType_t; - typedef unsigned long UBaseType_t; - - typedef uint32_t TickType_t; -#define portMAX_DELAY (TickType_t)0xffffffffUL - -/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do -not need to be guarded with a critical section. */ -#define portTICK_TYPE_IS_ATOMIC 1 - -/*-----------------------------------------------------------*/ - -/* Hardware specifics. */ -#define portSTACK_GROWTH (-1) -#define portTICK_PERIOD_MS ((TickType_t)1000 / configTICK_RATE_HZ) -#define portBYTE_ALIGNMENT 32 - -/*-----------------------------------------------------------*/ - -/* Task utilities. */ - -/* Called at the end of an ISR that can cause a context switch. */ -#define portEND_SWITCHING_ISR(xSwitchRequired) \ - { \ - extern uint32_t ulPortYieldRequired; \ - \ - if (xSwitchRequired != pdFALSE) \ - { \ - ulPortYieldRequired = pdTRUE; \ - } \ - } - -#define portYIELD_FROM_ISR(x) portEND_SWITCHING_ISR(x) -#define portYIELD() __asm volatile("SWI 0" :: \ - : "memory"); - - /*----------------------------------------------------------- - * Critical section control - *----------------------------------------------------------*/ - - extern void vPortEnterCritical(void); - extern void vPortExitCritical(void); - extern uint32_t ulPortSetInterruptMask(void); - extern void vPortClearInterruptMask(uint32_t ulNewMaskValue); - extern void vPortInstallFreeRTOSVectorTable(void); - -/* These macros do not globally disable/enable interrupts. They do mask off -interrupts that have a priority below configMAX_API_CALL_INTERRUPT_PRIORITY. */ -#define portENTER_CRITICAL() vPortEnterCritical(); -#define portEXIT_CRITICAL() vPortExitCritical(); -#define portDISABLE_INTERRUPTS() ulPortSetInterruptMask() -#define portENABLE_INTERRUPTS() vPortClearInterruptMask(0) -#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortSetInterruptMask() -#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x) - -/*-----------------------------------------------------------*/ - -/* Task function macros as described on the FreeRTOS.org WEB site. These are -not required for this port but included in case common demo code that uses these -macros is used. */ -#define portTASK_FUNCTION_PROTO(vFunction, pvParameters) void vFunction(void *pvParameters) -#define portTASK_FUNCTION(vFunction, pvParameters) void vFunction(void *pvParameters) - - /* Prototype of the FreeRTOS tick handler. This must be installed as the -handler for whichever peripheral is used to generate the RTOS tick. */ - void FreeRTOS_Tick_Handler(void); - -/* If configUSE_TASK_FPU_SUPPORT is set to 1 (or left undefined) then tasks are -created without an FPU context and must call vPortTaskUsesFPU() to give -themselves an FPU context before using any FPU instructions. If -configUSE_TASK_FPU_SUPPORT is set to 2 then all tasks will have an FPU context -by default. */ -#if (configUSE_TASK_FPU_SUPPORT != 2) - void vPortTaskUsesFPU(void); -#else -/* Each task has an FPU context already, so define this function away to - nothing to prevent it being called accidentally. */ -#define vPortTaskUsesFPU() -#endif -#define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU() - -#define portLOWEST_INTERRUPT_PRIORITY (((uint32_t)configUNIQUE_INTERRUPT_PRIORITIES) - 1UL) -#define portLOWEST_USABLE_INTERRUPT_PRIORITY (portLOWEST_INTERRUPT_PRIORITY - 1UL) - -/* Architecture specific optimisations. */ -#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION -#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 -#endif - -#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 - -/* Store/clear the ready priorities in a bit map. */ -#define portRECORD_READY_PRIORITY(uxPriority, uxReadyPriorities) (uxReadyPriorities) |= (1UL << (uxPriority)) -#define portRESET_READY_PRIORITY(uxPriority, uxReadyPriorities) (uxReadyPriorities) &= ~(1UL << (uxPriority)) - - /*-----------------------------------------------------------*/ - -#define portGET_HIGHEST_PRIORITY(uxTopPriority, uxReadyPriorities) uxTopPriority = (31UL - (uint32_t)__builtin_clz(uxReadyPriorities)) - -#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ - -#ifdef configASSERT - void vPortValidateInterruptPriority(void); -#define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority() -#endif /* configASSERT */ - -#define portNOP() __asm volatile("NOP") -#define portINLINE __inline - -#ifdef __cplusplus -} /* extern C */ -#endif - -/* The number of bits to shift for an interrupt priority is dependent on the -number of bits implemented by the interrupt controller. */ -#if configUNIQUE_INTERRUPT_PRIORITIES == 16 -#define portPRIORITY_SHIFT 4 -#define portMAX_BINARY_POINT_VALUE 3 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 32 -#define portPRIORITY_SHIFT 3 -#define portMAX_BINARY_POINT_VALUE 2 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 64 -#define portPRIORITY_SHIFT 2 -#define portMAX_BINARY_POINT_VALUE 1 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 128 -#define portPRIORITY_SHIFT 1 -#define portMAX_BINARY_POINT_VALUE 0 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 256 -#define portPRIORITY_SHIFT 0 -#define portMAX_BINARY_POINT_VALUE 0 -#else -#error Invalid configUNIQUE_INTERRUPT_PRIORITIES setting. configUNIQUE_INTERRUPT_PRIORITIES must be set to the number of unique priorities implemented by the target hardware -#endif - -/* Interrupt controller access addresses. */ -#define portICCPMR_PRIORITY_MASK_OFFSET (0x04) -#define portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET (0x0C) -#define portICCEOIR_END_OF_INTERRUPT_OFFSET (0x10) -#define portICCBPR_BINARY_POINT_OFFSET (0x08) -#define portICCRPR_RUNNING_PRIORITY_OFFSET (0x14) - -// #define portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS (configINTERRUPT_CONTROLLER_BASE_ADDRESS + configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET) -// #define portICCPMR_PRIORITY_MASK_REGISTER (*((volatile uint32_t *)(portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET))) -// #define portICCIAR_INTERRUPT_ACKNOWLEDGE_REGISTER_ADDRESS (portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET) -// #define portICCEOIR_END_OF_INTERRUPT_REGISTER_ADDRESS (portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCEOIR_END_OF_INTERRUPT_OFFSET) -// #define portICCPMR_PRIORITY_MASK_REGISTER_ADDRESS (portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET) -// #define portICCBPR_BINARY_POINT_REGISTER (*((const volatile uint32_t *)(portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCBPR_BINARY_POINT_OFFSET))) -// #define portICCRPR_RUNNING_PRIORITY_REGISTER (*((const volatile uint32_t *)(portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCRPR_RUNNING_PRIORITY_OFFSET))) - -#define portMEMORY_BARRIER() __asm volatile("" :: \ - : "memory") - -#endif /* PORTMACRO_H */ diff --git a/third-party/freertos/portable/GCC/ft2004_aarch64/debug_print_freertos.c b/third-party/freertos/portable/GCC/ft2004_aarch64/debug_print_freertos.c deleted file mode 100644 index 71fda224f44d6e872ee2a25612d798d078b73f13..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/ft2004_aarch64/debug_print_freertos.c +++ /dev/null @@ -1,128 +0,0 @@ - -// #include "printf-stdarg.h" -#include "ft_types.h" -#include "exception.h" -#include -#include "aarch64.h" - -u64 raw_read_elr_el1(void) -{ - u64 elr_el1; - - __asm__ __volatile__("mrs %0, ELR_EL1\n\t" - : "=r"(elr_el1) - : - : "memory"); - - return elr_el1; -} - -u64 raw_read_sp_el1(void) -{ - // u64 sp_el1; - - // __asm__ __volatile__("mrs %0, sp\n\t" - // : "=r"(sp_el1) - // : - // : "memory"); - - return 0; -} - -void _origin_print(void) -{ - printf("check is here \r\n"); -} - -void test_freertos_print(u64 x0, u64 x1, u64 x2) -{ - printf("x0 %x \r\n", x0); - printf("x1 %x \r\n", x1); - printf("x2 %x \r\n", x2); - printf("esr_el1 %x \r\n", get_esr_el1()); - // printf("elr_el1 %x \r\n", raw_read_elr_el1()); - // printf("spsr_el1 %x \r\n", raw_read_spsr_el1()); - // printf("sp_el1 %x \r\n", raw_read_sp_el1()); - while (1) - { - /* code */ - } -} - -void handle_exception(exception_frame *exc) -{ - printf("elr_el1 %x \r\n", raw_read_elr_el1()); - printf("An exception occur:\r\n"); - printf("exc_type: "); - printf("%x", exc->exc_type); - printf("\r\nESR: "); - printf("%x", exc->exc_esr); - printf(" SP: "); - printf("%x", exc->exc_sp); - printf(" ELR: "); - printf("%x", exc->exc_elr); - printf(" SPSR: "); - printf("%x", exc->exc_spsr); - printf("\r\n x0: "); - printf("%x", exc->x0); - printf(" x1: "); - printf("%x", exc->x1); - printf(" x2: "); - printf("%x", exc->x2); - printf(" x3: "); - printf("%x", exc->x3); - printf("\r\n x4: "); - printf("%x", exc->x4); - printf(" x5: "); - printf("%x", exc->x5); - printf(" x6: "); - printf("%x", exc->x6); - printf(" x7: "); - printf("%x", exc->x7); - printf("\r\n x8: "); - printf("%x", exc->x8); - printf(" x9: "); - printf("%x", exc->x9); - printf(" x10: "); - printf("%x", exc->x10); - printf(" x11: "); - printf("%x", exc->x11); - printf("\r\nx12: "); - printf("%x", exc->x12); - printf(" x13: "); - printf("%x", exc->x13); - printf(" x14: "); - printf("%x", exc->x14); - printf(" x15: "); - printf("%x", exc->x15); - printf("\r\nx16: "); - printf("%x", exc->x16); - printf(" x17: "); - printf("%x", exc->x17); - printf(" x18: "); - printf("%x", exc->x18); - printf(" x19: "); - printf("%x", exc->x19); - printf("\r\nx20: "); - printf("%x", exc->x20); - printf(" x21: "); - printf("%x", exc->x21); - printf(" x22: "); - printf("%x", exc->x22); - printf(" x23: "); - printf("%x", exc->x23); - printf("\r\nx24: "); - printf("%x", exc->x24); - printf(" x25: "); - printf("%x", exc->x25); - printf(" x26: "); - printf("%x", exc->x26); - printf(" x27: "); - printf("%x", exc->x27); - printf("\r\nx28: "); - printf("%x", exc->x28); - printf(" x29: "); - printf("%x", exc->x29); - printf(" x30: "); - printf("%x", exc->x30); -} \ No newline at end of file diff --git a/third-party/freertos/portable/GCC/ft2004_aarch64/port.c b/third-party/freertos/portable/GCC/ft2004_aarch64/port.c deleted file mode 100644 index 3af303c9a6db0135ac2c1d5465b8b91dd2506ef6..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/ft2004_aarch64/port.c +++ /dev/null @@ -1,508 +0,0 @@ -/* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -/* Standard includes. */ -#include -#include -/* Scheduler includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "ft_types.h" -#include "gicv3_cpuif.h" - -#ifndef configUNIQUE_INTERRUPT_PRIORITIES -#error configUNIQUE_INTERRUPT_PRIORITIES must be defined. See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif - -#ifndef configSETUP_TICK_INTERRUPT -#error configSETUP_TICK_INTERRUPT() must be defined. See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif /* configSETUP_TICK_INTERRUPT */ - -#ifndef configMAX_API_CALL_INTERRUPT_PRIORITY -#error configMAX_API_CALL_INTERRUPT_PRIORITY must be defined. See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif - -#if configMAX_API_CALL_INTERRUPT_PRIORITY == 0 -#error configMAX_API_CALL_INTERRUPT_PRIORITY must not be set to 0 -#endif - -#if configMAX_API_CALL_INTERRUPT_PRIORITY > configUNIQUE_INTERRUPT_PRIORITIES -#error configMAX_API_CALL_INTERRUPT_PRIORITY must be less than or equal to configUNIQUE_INTERRUPT_PRIORITIES as the lower the numeric priority value the higher the logical interrupt priority -#endif - -#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 -/* Check the configuration. */ -#if (configMAX_PRIORITIES > 32) -#error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice. -#endif -#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ - -/* In case security extensions are implemented. */ -#if configMAX_API_CALL_INTERRUPT_PRIORITY <= (configUNIQUE_INTERRUPT_PRIORITIES / 2) -#error configMAX_API_CALL_INTERRUPT_PRIORITY must be greater than ( configUNIQUE_INTERRUPT_PRIORITIES / 2 ) -#endif - -/* Some vendor specific files default configCLEAR_TICK_INTERRUPT() in -portmacro.h. */ -#ifndef configCLEAR_TICK_INTERRUPT -#define configCLEAR_TICK_INTERRUPT() -#endif - -/* A critical section is exited when the critical section nesting count reaches -this value. */ -#define portNO_CRITICAL_NESTING ((size_t)0) - -/* In all GICs 255 can be written to the priority mask register to unmask all -(but the lowest) interrupt priority. */ -#define portUNMASK_VALUE (0xF0UL) - -/* Tasks are not created with a floating point context, but can be given a -floating point context after they have been created. A variable is stored as -part of the tasks context that holds portNO_FLOATING_POINT_CONTEXT if the task -does not have an FPU context, or any other value if the task does have an FPU -context. */ -#define portNO_FLOATING_POINT_CONTEXT ((StackType_t)0) - -/* Constants required to setup the initial task context. */ -#define portSP_ELx ((StackType_t)0x01) -#define portSP_EL0 ((StackType_t)0x00) - -#if defined(GUEST) -#define portEL1 ((StackType_t)0x04) -#define portINITIAL_PSTATE (portEL1 | portSP_EL0) -#else -#define portEL3 ((StackType_t)0x0c) -/* At the time of writing, the BSP only supports EL3. */ -#define portINITIAL_PSTATE (portEL3 | portSP_EL0) -#endif - -/* Used by portASSERT_IF_INTERRUPT_PRIORITY_INVALID() when ensuring the binary -point is zero. */ -#define portBINARY_POINT_BITS ((uint8_t)0x03) - -/* Masks all bits in the APSR other than the mode bits. */ -#define portAPSR_MODE_BITS_MASK (0x0C) - -/* The I bit in the DAIF bits. */ -#define portDAIF_I (0x80) - -/* Macro to unmask all interrupt priorities. */ -#define portCLEAR_INTERRUPT_MASK() \ - { \ - portDISABLE_INTERRUPTS(); \ - setPriorityMask(portUNMASK_VALUE); \ - __asm volatile("DSB SY \n" \ - "ISB SY \n"); \ - portENABLE_INTERRUPTS(); \ - } - -/* Hardware specifics used when sanity checking the configuration. */ -#define portINTERRUPT_PRIORITY_REGISTER_OFFSET (0x400UL + 32UL) // -#define portMAX_8_BIT_VALUE ((uint8_t)0xff) -#define portBIT_0_SET ((uint8_t)0x01) - -/*-----------------------------------------------------------*/ - -/* - * Starts the first task executing. This function is necessarily written in - * assembly code so is implemented in portASM.s. - */ -extern void vPortRestoreTaskContext(void); - -/*-----------------------------------------------------------*/ - -/* A variable is used to keep track of the critical section nesting. This -variable has to be stored as part of the task context and must be initialised to -a non zero value to ensure interrupts don't inadvertently become unmasked before -the scheduler starts. As it is stored as part of the task context it will -automatically be set to 0 when the first task is started. */ -volatile uint64_t ullCriticalNesting = 9999ULL; - -/* Saved as part of the task context. If ullPortTaskHasFPUContext is non-zero -then floating point context must be saved and restored for the task. */ -uint64_t ullPortTaskHasFPUContext = pdFALSE; - -/* Set to 1 to pend a context switch from an ISR. */ -uint64_t ullPortYieldRequired = pdFALSE; - -/* Counts the interrupt nesting depth. A context switch is only performed if -if the nesting depth is 0. */ -uint64_t ullPortInterruptNesting = pdFALSE; - -/* Used in the ASM code. */ -__attribute__((used)) const uint64_t ullMaxAPIPriorityMask = (configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT); - -/*-----------------------------------------------------------*/ - -/* - * See header file for description. - */ -StackType_t *pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters) -{ - /* Setup the initial stack of the task. The stack is set exactly as - expected by the portRESTORE_CONTEXT() macro. */ - - /* First all the general purpose registers. */ - pxTopOfStack--; - *pxTopOfStack = 0x0101010101010101ULL; /* R1 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)pvParameters; /* R0 */ - pxTopOfStack--; - *pxTopOfStack = 0x0303030303030303ULL; /* R3 */ - pxTopOfStack--; - *pxTopOfStack = 0x0202020202020202ULL; /* R2 */ - pxTopOfStack--; - *pxTopOfStack = 0x0505050505050505ULL; /* R5 */ - pxTopOfStack--; - *pxTopOfStack = 0x0404040404040404ULL; /* R4 */ - pxTopOfStack--; - *pxTopOfStack = 0x0707070707070707ULL; /* R7 */ - pxTopOfStack--; - *pxTopOfStack = 0x0606060606060606ULL; /* R6 */ - pxTopOfStack--; - *pxTopOfStack = 0x0909090909090909ULL; /* R9 */ - pxTopOfStack--; - *pxTopOfStack = 0x0808080808080808ULL; /* R8 */ - pxTopOfStack--; - *pxTopOfStack = 0x1111111111111111ULL; /* R11 */ - pxTopOfStack--; - *pxTopOfStack = 0x1010101010101010ULL; /* R10 */ - pxTopOfStack--; - *pxTopOfStack = 0x1313131313131313ULL; /* R13 */ - pxTopOfStack--; - *pxTopOfStack = 0x1212121212121212ULL; /* R12 */ - pxTopOfStack--; - *pxTopOfStack = 0x1515151515151515ULL; /* R15 */ - pxTopOfStack--; - *pxTopOfStack = 0x1414141414141414ULL; /* R14 */ - pxTopOfStack--; - *pxTopOfStack = 0x1717171717171717ULL; /* R17 */ - pxTopOfStack--; - *pxTopOfStack = 0x1616161616161616ULL; /* R16 */ - pxTopOfStack--; - *pxTopOfStack = 0x1919191919191919ULL; /* R19 */ - pxTopOfStack--; - *pxTopOfStack = 0x1818181818181818ULL; /* R18 */ - pxTopOfStack--; - *pxTopOfStack = 0x2121212121212121ULL; /* R21 */ - pxTopOfStack--; - *pxTopOfStack = 0x2020202020202020ULL; /* R20 */ - pxTopOfStack--; - *pxTopOfStack = 0x2323232323232323ULL; /* R23 */ - pxTopOfStack--; - *pxTopOfStack = 0x2222222222222222ULL; /* R22 */ - pxTopOfStack--; - *pxTopOfStack = 0x2525252525252525ULL; /* R25 */ - pxTopOfStack--; - *pxTopOfStack = 0x2424242424242424ULL; /* R24 */ - pxTopOfStack--; - *pxTopOfStack = 0x2727272727272727ULL; /* R27 */ - pxTopOfStack--; - *pxTopOfStack = 0x2626262626262626ULL; /* R26 */ - pxTopOfStack--; - *pxTopOfStack = 0x2929292929292929ULL; /* R29 */ - pxTopOfStack--; - *pxTopOfStack = 0x2828282828282828ULL; /* R28 */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x00; /* XZR - has no effect, used so there are an even number of registers. */ - pxTopOfStack--; - *pxTopOfStack = (StackType_t)0x00; /* R30 - procedure call link register. */ - pxTopOfStack--; - - *pxTopOfStack = portINITIAL_PSTATE; - pxTopOfStack--; - - *pxTopOfStack = (StackType_t)pxCode; /* Exception return address. */ - pxTopOfStack--; - - /* The task will start with a critical nesting count of 0 as interrupts are - enabled. */ - *pxTopOfStack = portNO_CRITICAL_NESTING; - pxTopOfStack--; - - /* The task will start without a floating point context. A task that uses - the floating point hardware must call vPortTaskUsesFPU() before executing - any floating point instructions. */ - *pxTopOfStack = portNO_FLOATING_POINT_CONTEXT; - - return pxTopOfStack; -} -/*-----------------------------------------------------------*/ - -BaseType_t xPortStartScheduler(void) -{ - uint32_t ulAPSR; - -#if (configASSERT_DEFINED == 1) - { - volatile uint32_t ulOriginalPriority; - volatile uint8_t *const pucFirstUserPriorityRegister = (volatile uint8_t *const)(configINTERRUPT_CONTROLLER_BASE_ADDRESS + portINTERRUPT_PRIORITY_REGISTER_OFFSET); - volatile uint8_t ucMaxPriorityValue; - - /* Determine how many priority bits are implemented in the GIC. - Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = *pucFirstUserPriorityRegister; - /* Determine the number of priority bits available. First write to - all possible bits. */ - *pucFirstUserPriorityRegister = portMAX_8_BIT_VALUE; - - /* Read the value back to see how many bits stuck. */ - ucMaxPriorityValue = *pucFirstUserPriorityRegister; - /* Shift to the least significant bits. */ - while ((ucMaxPriorityValue & portBIT_0_SET) != portBIT_0_SET) - { - ucMaxPriorityValue >>= (uint8_t)0x01; - } - /* Sanity check configUNIQUE_INTERRUPT_PRIORITIES matches the read - value. */ - configASSERT(ucMaxPriorityValue >= portLOWEST_INTERRUPT_PRIORITY); - - /* Restore the clobbered interrupt priority register to its original - value. */ - *pucFirstUserPriorityRegister = ulOriginalPriority; - } -#endif /* conifgASSERT_DEFINED */ - - /* At the time of writing, the BSP only supports EL1. */ - __asm volatile("MRS %0, CurrentEL" - : "=r"(ulAPSR)); - ulAPSR &= portAPSR_MODE_BITS_MASK; -#if defined(GUEST) - - configASSERT(ulAPSR == portEL1); - if (ulAPSR == portEL1) -#else - configASSERT(ulAPSR == portEL3); - if (ulAPSR == portEL3) -#endif - { - /* Only continue if the binary point value is set to its lowest possible - setting. See the comments in vPortValidateInterruptPriority() below for - more information. */ - // configASSERT((portICCBPR_BINARY_POINT_REGISTER & portBINARY_POINT_BITS) <= portMAX_BINARY_POINT_VALUE); - configASSERT((getBPR1() & portBINARY_POINT_BITS) <= portMAX_BINARY_POINT_VALUE); - - // if ((portICCBPR_BINARY_POINT_REGISTER & portBINARY_POINT_BITS) <= portMAX_BINARY_POINT_VALUE) - if ((getBPR1() & portBINARY_POINT_BITS) <= portMAX_BINARY_POINT_VALUE) - { - /* Interrupts are turned off in the CPU itself to ensure a tick does - not execute while the scheduler is being started. Interrupts are - automatically turned back on in the CPU when the first task starts - executing. */ - portDISABLE_INTERRUPTS(); - - /* Start the timer that generates the tick ISR. */ - configSETUP_TICK_INTERRUPT(); - - /* Start the first task executing. */ - vPortRestoreTaskContext(); - } - } - - return 0; -} -/*-----------------------------------------------------------*/ - -void vPortEndScheduler(void) -{ - /* Not implemented in ports where there is nothing to return to. - Artificially force an assert. */ - configASSERT(ullCriticalNesting == 1000ULL); -} -/*-----------------------------------------------------------*/ - -void vPortEnterCritical(void) -{ - /* Mask interrupts up to the max syscall interrupt priority. */ - uxPortSetInterruptMask(); - - /* Now interrupts are disabled ullCriticalNesting can be accessed - directly. Increment ullCriticalNesting to keep a count of how many times - portENTER_CRITICAL() has been called. */ - ullCriticalNesting++; - - /* This is not the interrupt safe version of the enter critical function so - assert() if it is being called from an interrupt context. Only API - functions that end in "FromISR" can be used in an interrupt. Only assert if - the critical nesting count is 1 to protect against recursive calls if the - assert function also uses a critical section. */ - if (ullCriticalNesting == 1ULL) - { - configASSERT(ullPortInterruptNesting == 0); - } -} -/*-----------------------------------------------------------*/ - -void vPortExitCritical(void) -{ - if (ullCriticalNesting > portNO_CRITICAL_NESTING) - { - /* Decrement the nesting count as the critical section is being - exited. */ - ullCriticalNesting--; - - /* If the nesting level has reached zero then all interrupt - priorities must be re-enabled. */ - if (ullCriticalNesting == portNO_CRITICAL_NESTING) - { - /* Critical nesting has reached zero so all interrupt priorities - should be unmasked. */ - portCLEAR_INTERRUPT_MASK(); - } - } -} -/*-----------------------------------------------------------*/ - -void FreeRTOS_Tick_Handler(void) -{ -/* Interrupts should not be enabled before this point. */ -#if (configASSERT_DEFINED == 1) - { - uint32_t ulMaskBits; - - __asm volatile("mrs %0, daif" - : "=r"(ulMaskBits)::"memory"); - configASSERT((ulMaskBits & portDAIF_I) != 0); - } -#endif /* configASSERT_DEFINED */ - - /* Set interrupt mask before altering scheduler structures. The tick - handler runs at the lowest priority, so interrupts cannot already be masked, - so there is no need to save and restore the current mask value. It is - necessary to turn off interrupts in the CPU itself while the ICCPMR is being - updated. */ - - setPriorityMask(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT); - __asm volatile("dsb sy \n" - "isb sy \n" :: - : "memory"); - - /* Ok to enable interrupts after the interrupt source has been cleared. */ - configCLEAR_TICK_INTERRUPT(); - portENABLE_INTERRUPTS(); - - /* Increment the RTOS tick. */ - if (xTaskIncrementTick() != pdFALSE) - { - ullPortYieldRequired = pdTRUE; - } - - /* Ensure all interrupt priorities are active again. */ - portCLEAR_INTERRUPT_MASK(); -} -/*-----------------------------------------------------------*/ - -void vPortTaskUsesFPU(void) -{ - /* A task is registering the fact that it needs an FPU context. Set the - FPU flag (which is saved as part of the task context). */ - ullPortTaskHasFPUContext = pdTRUE; - printf("ullPortTaskHasFPUContext %x \r\n", ullPortTaskHasFPUContext); - /* Consider initialising the FPSR here - but probably not necessary in - AArch64. */ -} -/*-----------------------------------------------------------*/ - -void vPortClearInterruptMask(UBaseType_t uxNewMaskValue) -{ - if (uxNewMaskValue == pdFALSE) - { - portCLEAR_INTERRUPT_MASK(); - } -} -/*-----------------------------------------------------------*/ - -UBaseType_t uxPortSetInterruptMask(void) -{ - uint32_t ulReturn; - - /* Interrupt in the CPU must be turned off while the ICCPMR is being - updated. */ - portDISABLE_INTERRUPTS(); - if (getPriorityMask() == (uint32_t)(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT)) - { - /* Interrupts were already masked. */ - ulReturn = pdTRUE; - } - else - { - ulReturn = pdFALSE; - setPriorityMask(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT); - // portICCPMR_PRIORITY_MASK_REGISTER = (uint32_t)(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT); - __asm volatile("dsb sy \n" - "isb sy \n" :: - : "memory"); - } - portENABLE_INTERRUPTS(); - - return ulReturn; -} -/*-----------------------------------------------------------*/ - -#if (configASSERT_DEFINED == 1) - -void vPortValidateInterruptPriority(void) -{ - /* The following assertion will fail if a service routine (ISR) for - an interrupt that has been assigned a priority above - configMAX_SYSCALL_INTERRUPT_PRIORITY calls an ISR safe FreeRTOS API - function. ISR safe FreeRTOS API functions must *only* be called - from interrupts that have been assigned a priority at or below - configMAX_SYSCALL_INTERRUPT_PRIORITY. - - Numerically low interrupt priority numbers represent logically high - interrupt priorities, therefore the priority of the interrupt must - be set to a value equal to or numerically *higher* than - configMAX_SYSCALL_INTERRUPT_PRIORITY. - - FreeRTOS maintains separate thread and ISR API functions to ensure - interrupt entry is as fast and simple as possible. */ - configASSERT(getRunningPriority() >= (uint32_t)(configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT)); - - /* Priority grouping: The interrupt controller (GIC) allows the bits - that define each interrupt's priority to be split between bits that - define the interrupt's pre-emption priority bits and bits that define - the interrupt's sub-priority. For simplicity all bits must be defined - to be pre-emption priority bits. The following assertion will fail if - this is not the case (if some bits represent a sub-priority). - - The priority grouping is configured by the GIC's binary point register - (ICCBPR). Writting 0 to ICCBPR will ensure it is set to its lowest - possible value (which may be above 0). */ - configASSERT((getBPR1() & portBINARY_POINT_BITS) <= portMAX_BINARY_POINT_VALUE); -} - -#endif /* configASSERT_DEFINED */ -/*-----------------------------------------------------------*/ - -_WEAK void vApplicationTickHook(void) -{ -} - -_WEAK void vApplicationIdleHook(void) -{ -} diff --git a/third-party/freertos/portable/GCC/ft2004_aarch64/portASM.S b/third-party/freertos/portable/GCC/ft2004_aarch64/portASM.S deleted file mode 100644 index baeb0c9c07667611d4bd55790b3e3f91f8785820..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/ft2004_aarch64/portASM.S +++ /dev/null @@ -1,439 +0,0 @@ -/* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ -#include "gicv3_aliases.h" - - .text - - /* Variables and functions. */ - .extern ullMaxAPIPriorityMask - .extern pxCurrentTCB - .extern vTaskSwitchContext - .extern vApplicationIRQHandler - .extern ullPortInterruptNesting - .extern ullPortTaskHasFPUContext - .extern ullCriticalNesting - .extern ullPortYieldRequired - .extern ullICCEOIR - .extern ullICCIAR - .extern _freertos_vector_table - - .global FreeRTOS_IRQ_Handler - .global FreeRTOS_SWI_Handler - .global vPortRestoreTaskContext - - - - -.macro portSAVE_CONTEXT - /* Switch to use the EL0 stack pointer. */ - MSR SPSEL, #0 - - /* Save the entire context. */ - STP X0, X1, [SP, #-0x10]! - STP X2, X3, [SP, #-0x10]! - STP X4, X5, [SP, #-0x10]! - STP X6, X7, [SP, #-0x10]! - STP X8, X9, [SP, #-0x10]! - STP X10, X11, [SP, #-0x10]! - STP X12, X13, [SP, #-0x10]! - STP X14, X15, [SP, #-0x10]! - STP X16, X17, [SP, #-0x10]! - STP X18, X19, [SP, #-0x10]! - STP X20, X21, [SP, #-0x10]! - STP X22, X23, [SP, #-0x10]! - STP X24, X25, [SP, #-0x10]! - STP X26, X27, [SP, #-0x10]! - STP X28, X29, [SP, #-0x10]! - STP X30, XZR, [SP, #-0x10]! - - /* Save the SPSR. */ -#if defined( GUEST ) - MRS X3, SPSR_EL1 - MRS X2, ELR_EL1 -#else - MRS X3, SPSR_EL3 - /* Save the ELR. */ - MRS X2, ELR_EL3 -#endif - - STP X2, X3, [SP, #-0x10]! - - /* Save the critical section nesting depth. */ - LDR X0, ullCriticalNestingConst - LDR X3, [X0] - - /* Save the FPU context indicator. */ - LDR X0, ullPortTaskHasFPUContextConst - LDR X2, [X0] - - /* Save the FPU context, if any (32 128-bit registers). */ - CMP X2, #0 - B.EQ 1f - STP Q0, Q1, [SP,#-0x20]! - STP Q2, Q3, [SP,#-0x20]! - STP Q4, Q5, [SP,#-0x20]! - STP Q6, Q7, [SP,#-0x20]! - STP Q8, Q9, [SP,#-0x20]! - STP Q10, Q11, [SP,#-0x20]! - STP Q12, Q13, [SP,#-0x20]! - STP Q14, Q15, [SP,#-0x20]! - STP Q16, Q17, [SP,#-0x20]! - STP Q18, Q19, [SP,#-0x20]! - STP Q20, Q21, [SP,#-0x20]! - STP Q22, Q23, [SP,#-0x20]! - STP Q24, Q25, [SP,#-0x20]! - STP Q26, Q27, [SP,#-0x20]! - STP Q28, Q29, [SP,#-0x20]! - STP Q30, Q31, [SP,#-0x20]! - -1: - /* Store the critical nesting count and FPU context indicator. */ - STP X2, X3, [SP, #-0x10]! - - LDR X0, pxCurrentTCBConst - LDR X1, [X0] - MOV X0, SP /* Move SP into X0 for saving. */ - STR X0, [X1] - - /* Switch to use the ELx stack pointer. */ - MSR SPSEL, #1 - - .endm - -; /**********************************************************************/ - - - - -.macro portRESTORE_CONTEXT - - /* Switch to use the EL0 stack pointer. */ - MSR SPSEL, #0 - - /* Set the SP to point to the stack of the task being restored. */ - LDR X0, pxCurrentTCBConst - LDR X1, [X0] - LDR X0, [X1] - MOV SP, X0 - - LDP X2, X3, [SP], #0x10 /* Critical nesting and FPU context. */ - - /* Set the PMR register to be correct for the current critical nesting - depth. */ - LDR X0, ullCriticalNestingConst /* X0 holds the address of ullCriticalNesting. */ - MOV X1, #255 /* X1 holds the unmask value. */ - CMP X3, #0 - B.EQ 1f - LDR X6, ullMaxAPIPriorityMaskConst - LDR X1, [X6] /* X1 holds the mask value. */ -1: - //STR W1, [X5] /* Write the mask value to ICCPMR. */ - MSR S3_0_C4_C6_0, X1 - DSB SY /* _RB_Barriers probably not required here. */ - ISB SY - STR X3, [X0] /* Restore the task's critical nesting count. */ - - /* Restore the FPU context indicator. */ - LDR X0, ullPortTaskHasFPUContextConst - STR X2, [X0] - - /* Restore the FPU context, if any. */ - CMP X2, #0 - B.EQ 1f - - LDP Q30, Q31, [SP], #0x20 - LDP Q28, Q29, [SP], #0x20 - LDP Q26, Q27, [SP], #0x20 - LDP Q24, Q25, [SP], #0x20 - LDP Q22, Q23, [SP], #0x20 - LDP Q20, Q21, [SP], #0x20 - LDP Q18, Q19, [SP], #0x20 - LDP Q16, Q17, [SP], #0x20 - LDP Q14, Q15, [SP], #0x20 - LDP Q12, Q13, [SP], #0x20 - LDP Q10, Q11, [SP], #0x20 - LDP Q8, Q9, [SP], #0x20 - LDP Q6, Q7, [SP], #0x20 - LDP Q4, Q5, [SP], #0x20 - LDP Q2, Q3, [SP], #0x20 - LDP Q0, Q1, [SP], #0x20 -1: - LDP X2, X3, [SP], #0x10 /* SPSR and ELR. */ - -#if defined( GUEST ) - /* Restore the SPSR. */ - MSR SPSR_EL1, X3 - /* Restore the ELR. */ - MSR ELR_EL1, X2 -#else - /* Restore the SPSR. */ - MSR SPSR_EL3, X3 /*_RB_ Assumes started in EL3. */ - /* Restore the ELR. */ - MSR ELR_EL3, X2 -#endif - - LDP X30, XZR, [SP], #0x10 - LDP X28, X29, [SP], #0x10 - LDP X26, X27, [SP], #0x10 - LDP X24, X25, [SP], #0x10 - LDP X22, X23, [SP], #0x10 - LDP X20, X21, [SP], #0x10 - LDP X18, X19, [SP], #0x10 - LDP X16, X17, [SP], #0x10 - LDP X14, X15, [SP], #0x10 - LDP X12, X13, [SP], #0x10 - LDP X10, X11, [SP], #0x10 - LDP X8, X9, [SP], #0x10 - LDP X6, X7, [SP], #0x10 - LDP X4, X5, [SP], #0x10 - LDP X2, X3, [SP], #0x10 - LDP X0, X1, [SP], #0x10 - - /* Switch to use the ELx stack pointer. _RB_ Might not be required. */ - MSR SPSEL, #1 - - ERET - - .endm - - -/****************************************************************************** - * FreeRTOS_SWI_Handler handler is used to perform a context switch. - *****************************************************************************/ -.align 8 -.type FreeRTOS_SWI_Handler, %function -FreeRTOS_SWI_Handler: - /* Save the context of the current task and select a new task to run. */ - portSAVE_CONTEXT -#if defined( GUEST ) - MRS X0, ESR_EL1 -#else - MRS X0, ESR_EL3 -#endif - - LSR X1, X0, #26 - -#if defined( GUEST ) - CMP X1, #0x15 /* 0x15 = SVC instruction. */ -#else - CMP X1, #0x17 /* 0x17 = SMC instruction. */ -#endif - B.NE FreeRTOS_Abort - BL vTaskSwitchContext - - portRESTORE_CONTEXT - -FreeRTOS_Abort: - /* Full ESR is in X0, exception class code is in X1. */ - B . - -/****************************************************************************** - * vPortRestoreTaskContext is used to start the scheduler. - *****************************************************************************/ -.align 8 -.type vPortRestoreTaskContext, %function -vPortRestoreTaskContext: -.set freertos_vector_base, _freertos_vector_table - - /* Install the FreeRTOS interrupt handlers. */ - LDR X1, =freertos_vector_base -#if defined( GUEST ) - MSR VBAR_EL1, X1 -#else - MSR VBAR_EL3, X1 -#endif - DSB SY - ISB SY - - /* Start the first task. */ - portRESTORE_CONTEXT - - -/****************************************************************************** - * FreeRTOS_IRQ_Handler handles IRQ entry and exit. - *****************************************************************************/ -.align 8 -.type FreeRTOS_IRQ_Handler, %function -FreeRTOS_IRQ_Handler: - /* Save volatile registers. */ - STP X0, X1, [SP, #-0x10]! - STP X2, X3, [SP, #-0x10]! - STP X4, X5, [SP, #-0x10]! - STP X6, X7, [SP, #-0x10]! - STP X8, X9, [SP, #-0x10]! - STP X10, X11, [SP, #-0x10]! - STP X12, X13, [SP, #-0x10]! - STP X14, X15, [SP, #-0x10]! - STP X16, X17, [SP, #-0x10]! - STP X18, X19, [SP, #-0x10]! - STP X29, X30, [SP, #-0x10]! - - /* Save the SPSR and ELR. */ -#if defined( GUEST ) - MRS X3, SPSR_EL1 - MRS X2, ELR_EL1 -#else - MRS X3, SPSR_EL3 - MRS X2, ELR_EL3 -#endif - STP X2, X3, [SP, #-0x10]! - - /* Increment the interrupt nesting counter. */ - LDR X5, ullPortInterruptNestingConst - LDR X1, [X5] /* Old nesting count in X1. */ - ADD X6, X1, #1 - STR X6, [X5] /* Address of nesting count variable in X5. */ - - /* Maintain the interrupt nesting information across the function call. */ - STP X1, X5, [SP, #-0x10]! - - - /* Read value from the interrupt acknowledge register, which is stored in W0 - for future parameter and interrupt clearing use. */ - - MRS X0, ICC_IAR1_EL1 - - // LDR X2, ullICCIARConst - // LDR X3, [X2] - // LDR W0, [X3] /* ICCIAR in W0 as parameter. */ - - /* Maintain the ICCIAR value across the function call. */ - STP X0, X1, [SP, #-0x10]! - - /* Call the C handler. */ - BL vApplicationIRQHandler - - /* Disable interrupts. */ - MSR DAIFSET, #2 - DSB SY - ISB SY - - /* Restore the ICCIAR value. */ - LDP X0, X1, [SP], #0x10 - - /* End IRQ processing by writing ICCIAR to the EOI register. */ - // LDR X4, ullICCEOIRConst - // LDR X4, [X4] - // STR W0, [X4] - MSR ICC_EOIR1_EL1, x0 - - - /* Restore the critical nesting count. */ - LDP X1, X5, [SP], #0x10 - STR X1, [X5] - - /* Has interrupt nesting unwound? */ - CMP X1, #0 - B.NE Exit_IRQ_No_Context_Switch - - /* Is a context switch required? */ - LDR X0, ullPortYieldRequiredConst - LDR X1, [X0] - CMP X1, #0 - B.EQ Exit_IRQ_No_Context_Switch - - /* Reset ullPortYieldRequired to 0. */ - MOV X2, #0 - STR X2, [X0] - - /* Restore volatile registers. */ - LDP X4, X5, [SP], #0x10 /* SPSR and ELR. */ -#if defined( GUEST ) - MSR SPSR_EL1, X5 - MSR ELR_EL1, X4 -#else - MSR SPSR_EL3, X5 /*_RB_ Assumes started in EL3. */ - MSR ELR_EL3, X4 -#endif - DSB SY - ISB SY - - LDP X29, X30, [SP], #0x10 - LDP X18, X19, [SP], #0x10 - LDP X16, X17, [SP], #0x10 - LDP X14, X15, [SP], #0x10 - LDP X12, X13, [SP], #0x10 - LDP X10, X11, [SP], #0x10 - LDP X8, X9, [SP], #0x10 - LDP X6, X7, [SP], #0x10 - LDP X4, X5, [SP], #0x10 - LDP X2, X3, [SP], #0x10 - LDP X0, X1, [SP], #0x10 - - /* Save the context of the current task and select a new task to run. */ - portSAVE_CONTEXT - BL vTaskSwitchContext - portRESTORE_CONTEXT - -Exit_IRQ_No_Context_Switch: - /* Restore volatile registers. */ - LDP X4, X5, [SP], #0x10 /* SPSR and ELR. */ -#if defined( GUEST ) - MSR SPSR_EL1, X5 - MSR ELR_EL1, X4 -#else - MSR SPSR_EL3, X5 /*_RB_ Assumes started in EL3. */ - MSR ELR_EL3, X4 -#endif - DSB SY - ISB SY - - LDP X29, X30, [SP], #0x10 - LDP X18, X19, [SP], #0x10 - LDP X16, X17, [SP], #0x10 - LDP X14, X15, [SP], #0x10 - LDP X12, X13, [SP], #0x10 - LDP X10, X11, [SP], #0x10 - LDP X8, X9, [SP], #0x10 - LDP X6, X7, [SP], #0x10 - LDP X4, X5, [SP], #0x10 - LDP X2, X3, [SP], #0x10 - LDP X0, X1, [SP], #0x10 - - ERET - - - - -.align 8 -pxCurrentTCBConst: .dword pxCurrentTCB -ullCriticalNestingConst: .dword ullCriticalNesting -ullPortTaskHasFPUContextConst: .dword ullPortTaskHasFPUContext -ullMaxAPIPriorityMaskConst: .dword ullMaxAPIPriorityMask -vApplicationIRQHandlerConst: .dword vApplicationIRQHandler -ullPortInterruptNestingConst: .dword ullPortInterruptNesting -ullPortYieldRequiredConst: .dword ullPortYieldRequired - - - - -.end - - - - - diff --git a/third-party/freertos/portable/GCC/ft2004_aarch64/portmacro.h b/third-party/freertos/portable/GCC/ft2004_aarch64/portmacro.h deleted file mode 100644 index ad1b13647688783f28d95f26411cbcde5aecd275..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/ft2004_aarch64/portmacro.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * FreeRTOS Kernel V10.0.1 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ - -#ifndef PORTMACRO_H -#define PORTMACRO_H - -#ifdef __cplusplus -extern "C" -{ -#endif -#include "ft_types.h" -/*----------------------------------------------------------- - * Port specific definitions. - * - * The settings in this file configure FreeRTOS correctly for the given hardware - * and compiler. - * - * These settings should not be altered. - *----------------------------------------------------------- - */ - -/* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE double -#define portLONG long -#define portSHORT short -#define portSTACK_TYPE size_t -#define portBASE_TYPE long - - typedef portSTACK_TYPE StackType_t; - typedef portBASE_TYPE BaseType_t; - typedef uint64_t UBaseType_t; - - typedef uint64_t TickType_t; -#define portMAX_DELAY ((TickType_t)0xffffffffffffffff) - -/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do -not need to be guarded with a critical section. */ -#define portTICK_TYPE_IS_ATOMIC 1 - -/*-----------------------------------------------------------*/ - -/* Hardware specifics. */ -#define portSTACK_GROWTH (-1) -#define portTICK_PERIOD_MS ((TickType_t)1000 / configTICK_RATE_HZ) -#define portBYTE_ALIGNMENT 16 -#define portPOINTER_SIZE_TYPE uint64_t - -/*-----------------------------------------------------------*/ - -/* Task utilities. */ - -/* Called at the end of an ISR that can cause a context switch. */ -#define portEND_SWITCHING_ISR(xSwitchRequired) \ - { \ - extern uint64_t ullPortYieldRequired; \ - \ - if (xSwitchRequired != pdFALSE) \ - { \ - ullPortYieldRequired = pdTRUE; \ - } \ - } - -#define portYIELD_FROM_ISR(x) portEND_SWITCHING_ISR(x) -#if defined(GUEST) -#define portYIELD() __asm volatile("SVC 0" :: \ - : "memory") -#else -#define portYIELD() __asm volatile("SMC 0" :: \ - : "memory") -#endif - /*----------------------------------------------------------- - * Critical section control - *----------------------------------------------------------*/ - - extern void vPortEnterCritical(void); - extern void vPortExitCritical(void); - extern UBaseType_t uxPortSetInterruptMask(void); - extern void vPortClearInterruptMask(UBaseType_t uxNewMaskValue); - extern void vPortInstallFreeRTOSVectorTable(void); - -#define portDISABLE_INTERRUPTS() \ - __asm volatile("MSR DAIFSET, #2" :: \ - : "memory"); \ - __asm volatile("DSB SY"); \ - __asm volatile("ISB SY"); - -#define portENABLE_INTERRUPTS() \ - __asm volatile("MSR DAIFCLR, #2" :: \ - : "memory"); \ - __asm volatile("DSB SY"); \ - __asm volatile("ISB SY"); - -/* These macros do not globally disable/enable interrupts. They do mask off -interrupts that have a priority below configMAX_API_CALL_INTERRUPT_PRIORITY. */ -#define portENTER_CRITICAL() vPortEnterCritical(); -#define portEXIT_CRITICAL() vPortExitCritical(); -#define portSET_INTERRUPT_MASK_FROM_ISR() uxPortSetInterruptMask() -#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x) - -/*-----------------------------------------------------------*/ - -/* Task function macros as described on the FreeRTOS.org WEB site. These are -not required for this port but included in case common demo code that uses these -macros is used. */ -#define portTASK_FUNCTION_PROTO(vFunction, pvParameters) void vFunction(void *pvParameters) -#define portTASK_FUNCTION(vFunction, pvParameters) void vFunction(void *pvParameters) - - /* Prototype of the FreeRTOS tick handler. This must be installed as the -handler for whichever peripheral is used to generate the RTOS tick. */ - void FreeRTOS_Tick_Handler(void); - - /* Any task that uses the floating point unit MUST call vPortTaskUsesFPU() -before any floating point instructions are executed. */ - void vPortTaskUsesFPU(void); -#define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU() - -#define portLOWEST_INTERRUPT_PRIORITY (((uint32_t)configUNIQUE_INTERRUPT_PRIORITIES) - 1UL) -#define portLOWEST_USABLE_INTERRUPT_PRIORITY (portLOWEST_INTERRUPT_PRIORITY - 1UL) - -/* Architecture specific optimisations. */ -#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION -#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 -#endif - -#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 - -/* Store/clear the ready priorities in a bit map. */ -#define portRECORD_READY_PRIORITY(uxPriority, uxReadyPriorities) (uxReadyPriorities) |= (1UL << (uxPriority)) -#define portRESET_READY_PRIORITY(uxPriority, uxReadyPriorities) (uxReadyPriorities) &= ~(1UL << (uxPriority)) - - /*-----------------------------------------------------------*/ - -#define portGET_HIGHEST_PRIORITY(uxTopPriority, uxReadyPriorities) uxTopPriority = (31 - __builtin_clz(uxReadyPriorities)) - -#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ - -#ifdef configASSERT - void vPortValidateInterruptPriority(void); -#define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority() -#endif /* configASSERT */ - -#define portNOP() __asm volatile("NOP") -#define portINLINE __inline - -#ifdef __cplusplus -} /* extern C */ -#endif - -/* The number of bits to shift for an interrupt priority is dependent on the -number of bits implemented by the interrupt controller. */ -#if configUNIQUE_INTERRUPT_PRIORITIES == 16 -#define portPRIORITY_SHIFT 4 -#define portMAX_BINARY_POINT_VALUE 3 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 32 -#define portPRIORITY_SHIFT 3 -#define portMAX_BINARY_POINT_VALUE 2 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 64 -#define portPRIORITY_SHIFT 2 -#define portMAX_BINARY_POINT_VALUE 1 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 128 -#define portPRIORITY_SHIFT 1 -#define portMAX_BINARY_POINT_VALUE 0 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 256 -#define portPRIORITY_SHIFT 0 -#define portMAX_BINARY_POINT_VALUE 0 -#else -#error Invalid configUNIQUE_INTERRUPT_PRIORITIES setting. configUNIQUE_INTERRUPT_PRIORITIES must be set to the number of unique priorities implemented by the target hardware -#endif - -/* Interrupt controller access addresses. */ -#define portICCPMR_PRIORITY_MASK_OFFSET (0x04) -#define portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET (0x0C) -#define portICCEOIR_END_OF_INTERRUPT_OFFSET (0x10) -#define portICCBPR_BINARY_POINT_OFFSET (0x08) -#define portICCRPR_RUNNING_PRIORITY_OFFSET (0x14) - -// #define portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS (GIC_GICC_BASE) -// #define portICCPMR_PRIORITY_MASK_REGISTER (*((volatile uint32_t *)(portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET))) -// #define portICCIAR_INTERRUPT_ACKNOWLEDGE_REGISTER_ADDRESS (portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET) -// #define portICCEOIR_END_OF_INTERRUPT_REGISTER_ADDRESS (portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCEOIR_END_OF_INTERRUPT_OFFSET) -// #define portICCPMR_PRIORITY_MASK_REGISTER_ADDRESS (portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET) -// #define portICCBPR_BINARY_POINT_REGISTER (*((const volatile uint32_t *)(portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCBPR_BINARY_POINT_OFFSET))) -// #define portICCRPR_RUNNING_PRIORITY_REGISTER (*((const volatile uint32_t *)(portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCRPR_RUNNING_PRIORITY_OFFSET))) - -#endif /* PORTMACRO_H */ diff --git a/third-party/freertos/portable/GCC/ft2004_aarch32/FreeRTOSConfig.h b/third-party/freertos/portable/GCC/ft_platform/aarch32/FreeRTOSConfig.h similarity index 82% rename from third-party/freertos/portable/GCC/ft2004_aarch32/FreeRTOSConfig.h rename to third-party/freertos/portable/GCC/ft_platform/aarch32/FreeRTOSConfig.h index f37dc282452a91dfb9f318c5ce07734baf74747b..7d0134245dedd138fa8e429521627a874172fa5d 100644 --- a/third-party/freertos/portable/GCC/ft2004_aarch32/FreeRTOSConfig.h +++ b/third-party/freertos/portable/GCC/ft_platform/aarch32/FreeRTOSConfig.h @@ -28,9 +28,6 @@ #ifndef FREERTOS_CONFIG_H #define FREERTOS_CONFIG_H -// #include "ft_types.h" -// #include "parameters.h" - /*----------------------------------------------------------- * Application specific definitions. * @@ -64,11 +61,13 @@ * interrupt entry to be shorter, faster, simpler and smaller. * */ -#define configMAX_API_CALL_INTERRUPT_PRIORITY 0xb // 在不安全group1 中 ,0x8 ~0xb 不可以使用安全api(优先级越低越高) -#define configKERNEL_INTERRUPT_PRIORITY ((0x8 << 4) + 3 * 16) // 在不安全group1 中,16 is steps ,3 是其中等级 + +/* 在不安全group1 中 ,0x8 ~0xb 不可以使用安全api(优先级越低越高)*/ +#define configMAX_API_CALL_INTERRUPT_PRIORITY 0xb +/* 在不安全group1 中,16 is steps ,3 是其中等级*/ +#define configKERNEL_INTERRUPT_PRIORITY ((0x8 << 4) + 3 * 16) -#define configCPU_CLOCK_HZ 100000000UL // 100MHz #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 //Method to select the next task #define configUSE_TICKLESS_IDLE 0 //disable tickless mode #define configTICK_RATE_HZ ((TickType_t)1000) //system timer rate 10ms @@ -95,7 +94,7 @@ #define configUSE_APPLICATION_TASK_TAG 0 #define configUSE_COUNTING_SEMAPHORES 1 #define configUSE_QUEUE_SETS 1 -#define configSUPPORT_STATIC_ALLOCATION 0 //use dynamic memory allocation +#define configSUPPORT_STATIC_ALLOCATION 1 //use dynamic memory allocation #define configSUPPORT_DYNAMIC_ALLOCATION 1 /* Include the query-heap CLI command to query the free heap space. */ @@ -132,7 +131,10 @@ to exclude the API function. */ #define INCLUDE_xTaskAbortDelay 1 #define INCLUDE_xTaskGetTaskHandle 1 #define INCLUDE_xTaskGetHandle 1 + #define INCLUDE_xSemaphoreGetMutexHolder 1 +#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 +#define INCLUDE_xTaskGetIdleTaskHandle 1 /* This demo makes use of one or more example stats formatting functions. These format the raw data provided by the uxTaskGetSystemState() function in to human @@ -159,16 +161,7 @@ command interpreter running. */ /* Normal assert() semantics without relying on the provision of an assert.h header file. */ -// void vAssertCalled(const char *pcFile, unsigned long ulLine); -// #define configASSERT(x) -// if ((x) == 0) -// vAssertCalled(__FILE__, __LINE__); -// void vMainAssertCalled(const char *pcFileName, uint32_t ulLineNumber); -// #define configASSERT(x) \ -// if ((x) == 0) \ -// { \ -// vMainAssertCalled(__FILE__, __LINE__); \ -// } + #define configASSERT(x) \ do \ { \ @@ -196,20 +189,7 @@ nothing to return to. To avoid this define configTASK_RETURN_ADDRESS to 0. */ * be installed as the peripheral's interrupt handler. */ -// #define configSETUP_TICK_INTERRUPT() \ -// do \ -// { \ -// void SystemSetupSystick(u32 tickRateHz, void *tickHandler, u32 intPriority); \ -// /* Setup systick with lowest priority */ \ -// SystemSetupSystick(configTICK_RATE_HZ, (void *)FreeRTOS_Tick_Handler, (configUNIQUE_INTERRUPT_PRIORITIES - 2) << portPRIORITY_SHIFT); \ -// } while (0) - -// #define configCLEAR_TICK_INTERRUPT() \ -// do \ -// { \ -// } while (0) -// void vConfigureTickInterrupt(void); -// #define configSETUP_TICK_INTERRUPT() vConfigureTickInterrupt() + #define configSETUP_TICK_INTERRUPT() \ do \ { \ @@ -218,8 +198,6 @@ nothing to return to. To avoid this define configTASK_RETURN_ADDRESS to 0. */ } while (0) -// void vClearTickInterrupt(void); -// #define configCLEAR_TICK_INTERRUPT() vClearTickInterrupt() #define configCLEAR_TICK_INTERRUPT() \ do \ { \ diff --git a/third-party/freertos/portable/GCC/ft2004_aarch32/port.c b/third-party/freertos/portable/GCC/ft_platform/aarch32/port.c similarity index 99% rename from third-party/freertos/portable/GCC/ft2004_aarch32/port.c rename to third-party/freertos/portable/GCC/ft_platform/aarch32/port.c index 4da6f187238bb07938b0a4d6bf40379b4380cd41..74582106d9471751beff0b04d9dab04ef8739662 100644 --- a/third-party/freertos/portable/GCC/ft2004_aarch32/port.c +++ b/third-party/freertos/portable/GCC/ft_platform/aarch32/port.c @@ -544,3 +544,11 @@ void vApplicationFPUSafeIRQHandler(uint32_t ulICCIAR) (void)ulICCIAR; configASSERT((volatile void *)NULL); } + +_WEAK void vApplicationTickHook(void) +{ +} + +_WEAK void vApplicationIdleHook(void) +{ +} \ No newline at end of file diff --git a/third-party/freertos/portable/GCC/d2000_aarch32/portASM.S b/third-party/freertos/portable/GCC/ft_platform/aarch32/portASM.S similarity index 94% rename from third-party/freertos/portable/GCC/d2000_aarch32/portASM.S rename to third-party/freertos/portable/GCC/ft_platform/aarch32/portASM.S index 55b184e29ac9aa386024fa9649dab25f720832cd..4cdbf8e8ef079af292b3120d5210480a6d602048 100644 --- a/third-party/freertos/portable/GCC/d2000_aarch32/portASM.S +++ b/third-party/freertos/portable/GCC/ft_platform/aarch32/portASM.S @@ -35,10 +35,7 @@ .set IRQ_MODE, 0x12 /* Hardware registers. */ - /*.extern ulICCIAR*/ - /*.extern ulICCEOIR*/ - /*.extern ulICCPMR*/ - + /* Variables and functions. */ .extern ulMaxAPIPriorityMask .extern _freertos_vector_table @@ -120,13 +117,6 @@ /* Ensure the priority mask is correct for the critical nesting depth. */ - /*LDR R2, ulICCPMRConst - LDR R2, [R2] - CMP R1, #0 - MOVEQ R4, #255 - LDRNE R4, ulMaxAPIPriorityMaskConst - LDRNE R4, [R4] - STR R4, [R2] */ CMP R1, #0 MOVEQ R4, #255 @@ -196,12 +186,7 @@ FreeRTOS_IRQ_Handler: STR r4, [r3] /* Read value from the interrupt acknowledge register, which is stored in r0 - for future parameter and interrupt clearing use. - LDR r2, ulICCIARConst - LDR r2, [r2] - LDR r0, [r2,#0xC] - - */ + for future parameter and interrupt clearing use. */ mrc p15, 0, r0, c12, c12, 0 isb @@ -224,11 +209,7 @@ FreeRTOS_IRQ_Handler: DSB ISB - /* Write the value read from ICCIAR to ICCEOIR. - LDR r4, ulICCEOIRConst - LDR r4, [r4] - STR r0, [r4] - */ + /* Write the value read from ICCIAR to ICCEOIR.*/ mcr p15, 0, r0, c12, c12, 1 isb @@ -341,9 +322,6 @@ vApplicationIRQHandler: *****************************************************************************/ -/* ulICCIARConst: .word ulICCIAR */ -/* ulICCEOIRConst: .word ulICCEOIR */ -/* ulICCPMRConst: .word ulICCPMR */ pxCurrentTCBConst: .word pxCurrentTCB ulCriticalNestingConst: .word ulCriticalNesting ulPortTaskHasFPUContextConst: .word ulPortTaskHasFPUContext diff --git a/third-party/freertos/portable/GCC/d2000_aarch32/portmacro.h b/third-party/freertos/portable/GCC/ft_platform/aarch32/portmacro.h similarity index 87% rename from third-party/freertos/portable/GCC/d2000_aarch32/portmacro.h rename to third-party/freertos/portable/GCC/ft_platform/aarch32/portmacro.h index 24b9acc2e868006764318dddcff55afb0d5331a2..bbf98f732ab697c268fffaeed2236738fd761783 100644 --- a/third-party/freertos/portable/GCC/d2000_aarch32/portmacro.h +++ b/third-party/freertos/portable/GCC/ft_platform/aarch32/portmacro.h @@ -194,13 +194,6 @@ number of bits implemented by the interrupt controller. */ #define portICCBPR_BINARY_POINT_OFFSET (0x08) #define portICCRPR_RUNNING_PRIORITY_OFFSET (0x14) -// #define portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS (configINTERRUPT_CONTROLLER_BASE_ADDRESS + configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET) -// #define portICCPMR_PRIORITY_MASK_REGISTER (*((volatile uint32_t *)(portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET))) -// #define portICCIAR_INTERRUPT_ACKNOWLEDGE_REGISTER_ADDRESS (portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET) -// #define portICCEOIR_END_OF_INTERRUPT_REGISTER_ADDRESS (portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCEOIR_END_OF_INTERRUPT_OFFSET) -// #define portICCPMR_PRIORITY_MASK_REGISTER_ADDRESS (portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET) -// #define portICCBPR_BINARY_POINT_REGISTER (*((const volatile uint32_t *)(portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCBPR_BINARY_POINT_OFFSET))) -// #define portICCRPR_RUNNING_PRIORITY_REGISTER (*((const volatile uint32_t *)(portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCRPR_RUNNING_PRIORITY_OFFSET))) #define portMEMORY_BARRIER() __asm volatile("" :: \ : "memory") diff --git a/third-party/freertos/portable/GCC/ft2004_aarch64/FreeRTOSConfig.h b/third-party/freertos/portable/GCC/ft_platform/aarch64/FreeRTOSConfig.h similarity index 94% rename from third-party/freertos/portable/GCC/ft2004_aarch64/FreeRTOSConfig.h rename to third-party/freertos/portable/GCC/ft_platform/aarch64/FreeRTOSConfig.h index 96e1b4ab122600d00e0a356052acc969e3638724..07566640706f6d7e908e64b61aeee837c29e3804 100644 --- a/third-party/freertos/portable/GCC/ft2004_aarch64/FreeRTOSConfig.h +++ b/third-party/freertos/portable/GCC/ft_platform/aarch64/FreeRTOSConfig.h @@ -65,10 +65,11 @@ * For the purpose of setting configMAX_API_CALL_INTERRUPT_PRIORITY 255 * represents the lowest priority. */ -#define configMAX_API_CALL_INTERRUPT_PRIORITY 0xb // 在不安全group1 中 ,0x8 ~0xb 不可以使用安全api(优先级越低越高) -#define configKERNEL_INTERRUPT_PRIORITY ((0x8 << 4) + 3 * 16) // 在不安全group1 中,16 is steps ,3 是其中等级 +/* 在不安全group1 中 ,0x8 ~0xb 不可以使用安全api(优先级越低越高)*/ +#define configMAX_API_CALL_INTERRUPT_PRIORITY 0xb +/* 在不安全group1 中,16 is steps ,3 是其中等级*/ +#define configKERNEL_INTERRUPT_PRIORITY ((0x8 << 4) + 3 * 16) -#define configCPU_CLOCK_HZ 100000000UL #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 #define configUSE_TICKLESS_IDLE 0 #define configTICK_RATE_HZ ((TickType_t)1000) @@ -90,7 +91,7 @@ #define configUSE_QUEUE_SETS 1 /* This demo creates RTOS objects using both static and dynamic allocation. */ -#define configSUPPORT_STATIC_ALLOCATION 0 +#define configSUPPORT_STATIC_ALLOCATION 1 #define configSUPPORT_DYNAMIC_ALLOCATION 1 /* Defaults to 1 anyway. */ /* Co-routine definitions. */ @@ -117,6 +118,10 @@ to exclude the API function. */ #define INCLUDE_xTaskAbortDelay 1 #define INCLUDE_xTaskGetHandle 1 +#define INCLUDE_xSemaphoreGetMutexHolder 1 +#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 +#define INCLUDE_xTaskGetIdleTaskHandle 1 + /* This demo makes use of one or more example stats formatting functions. These format the raw data provided by the uxTaskGetSystemState() function in to human readable ASCII form. See the notes in the implementation of vTaskList() within diff --git a/third-party/freertos/portable/GCC/d2000_aarch64/port.c b/third-party/freertos/portable/GCC/ft_platform/aarch64/port.c similarity index 94% rename from third-party/freertos/portable/GCC/d2000_aarch64/port.c rename to third-party/freertos/portable/GCC/ft_platform/aarch64/port.c index 3af303c9a6db0135ac2c1d5465b8b91dd2506ef6..0798bcaf433e9696042195f8f5d7313a6f6e27f9 100644 --- a/third-party/freertos/portable/GCC/d2000_aarch64/port.c +++ b/third-party/freertos/portable/GCC/ft_platform/aarch64/port.c @@ -262,28 +262,35 @@ BaseType_t xPortStartScheduler(void) volatile uint32_t ulOriginalPriority; volatile uint8_t *const pucFirstUserPriorityRegister = (volatile uint8_t *const)(configINTERRUPT_CONTROLLER_BASE_ADDRESS + portINTERRUPT_PRIORITY_REGISTER_OFFSET); volatile uint8_t ucMaxPriorityValue; - - /* Determine how many priority bits are implemented in the GIC. - Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = *pucFirstUserPriorityRegister; - /* Determine the number of priority bits available. First write to - all possible bits. */ - *pucFirstUserPriorityRegister = portMAX_8_BIT_VALUE; - - /* Read the value back to see how many bits stuck. */ - ucMaxPriorityValue = *pucFirstUserPriorityRegister; - /* Shift to the least significant bits. */ - while ((ucMaxPriorityValue & portBIT_0_SET) != portBIT_0_SET) + if(pucFirstUserPriorityRegister != 0) { - ucMaxPriorityValue >>= (uint8_t)0x01; + /* Determine how many priority bits are implemented in the GIC. + Save the interrupt priority value that is about to be clobbered. */ + ulOriginalPriority = *pucFirstUserPriorityRegister; + /* Determine the number of priority bits available. First write to + all possible bits. */ + *pucFirstUserPriorityRegister = portMAX_8_BIT_VALUE; + + /* Read the value back to see how many bits stuck. */ + ucMaxPriorityValue = *pucFirstUserPriorityRegister; + + if(ucMaxPriorityValue != 0) + { + /* Shift to the least significant bits. */ + while ((ucMaxPriorityValue & portBIT_0_SET) != portBIT_0_SET) + { + ucMaxPriorityValue >>= (uint8_t)0x01; + } + /* Sanity check configUNIQUE_INTERRUPT_PRIORITIES matches the read + value. */ + configASSERT(ucMaxPriorityValue >= portLOWEST_INTERRUPT_PRIORITY); + } + + /* Restore the clobbered interrupt priority register to its original + value. */ + *pucFirstUserPriorityRegister = ulOriginalPriority; } - /* Sanity check configUNIQUE_INTERRUPT_PRIORITIES matches the read - value. */ - configASSERT(ucMaxPriorityValue >= portLOWEST_INTERRUPT_PRIORITY); - /* Restore the clobbered interrupt priority register to its original - value. */ - *pucFirstUserPriorityRegister = ulOriginalPriority; } #endif /* conifgASSERT_DEFINED */ @@ -292,7 +299,6 @@ BaseType_t xPortStartScheduler(void) : "=r"(ulAPSR)); ulAPSR &= portAPSR_MODE_BITS_MASK; #if defined(GUEST) - configASSERT(ulAPSR == portEL1); if (ulAPSR == portEL1) #else diff --git a/third-party/freertos/portable/GCC/e2000_aarch64/portASM.S b/third-party/freertos/portable/GCC/ft_platform/aarch64/portASM.S similarity index 98% rename from third-party/freertos/portable/GCC/e2000_aarch64/portASM.S rename to third-party/freertos/portable/GCC/ft_platform/aarch64/portASM.S index c47a5bea0fc17933d3d6ec31b97c339ce9094378..5530452f0ddb7964384390f136d6461cc3059f0f 100644 --- a/third-party/freertos/portable/GCC/e2000_aarch64/portASM.S +++ b/third-party/freertos/portable/GCC/ft_platform/aarch64/portASM.S @@ -130,6 +130,7 @@ .macro portRESTORE_CONTEXT + /* Switch to use the EL0 stack pointer. */ MSR SPSEL, #0 @@ -188,7 +189,6 @@ MSR SPSR_EL1, X3 /* Restore the ELR. */ MSR ELR_EL1, X2 - #else /* Restore the SPSR. */ MSR SPSR_EL3, X3 /*_RB_ Assumes started in EL3. */ @@ -315,11 +315,7 @@ FreeRTOS_IRQ_Handler: /* Read value from the interrupt acknowledge register, which is stored in W0 for future parameter and interrupt clearing use. */ - MRS X0, ICC_IAR1_EL1 - - // LDR X2, ullICCIARConst - // LDR X3, [X2] - // LDR W0, [X3] /* ICCIAR in W0 as parameter. */ + MRS X0, ICC_IAR1_EL1 /* ICCIAR in x0 as parameter. */ /* Maintain the ICCIAR value across the function call. */ STP X0, X1, [SP, #-0x10]! @@ -336,9 +332,7 @@ FreeRTOS_IRQ_Handler: LDP X0, X1, [SP], #0x10 /* End IRQ processing by writing ICCIAR to the EOI register. */ - // LDR X4, ullICCEOIRConst - // LDR X4, [X4] - // STR W0, [X4] + MSR ICC_EOIR1_EL1, x0 diff --git a/third-party/freertos/portable/GCC/d2000_aarch64/portmacro.h b/third-party/freertos/portable/GCC/ft_platform/aarch64/portmacro.h similarity index 100% rename from third-party/freertos/portable/GCC/d2000_aarch64/portmacro.h rename to third-party/freertos/portable/GCC/ft_platform/aarch64/portmacro.h diff --git a/third-party/freertos/portable/GCC/qemu_aarch32/FreeRTOSConfig.h b/third-party/freertos/portable/GCC/qemu_aarch32/FreeRTOSConfig.h deleted file mode 100644 index 58b5bb03900c08ede5281c1f21191473ef439a28..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/qemu_aarch32/FreeRTOSConfig.h +++ /dev/null @@ -1,206 +0,0 @@ -/* - FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef FREERTOS_CONFIG_H -#define FREERTOS_CONFIG_H - -/*----------------------------------------------------------- - * Application specific definitions. - * - * These definitions should be adjusted for your particular hardware and - * application requirements. - * - * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE - * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. - * - * See http://www.freertos.org/a00110.html. - *----------------------------------------------------------*/ - -#define configUSE_PREEMPTION 1 -#define configUSE_TICKLESS_IDLE 0 -#define configCPU_CLOCK_HZ (SystemCoreClock) -#define configTICK_RATE_HZ ((TickType_t)200) -#define configMAX_PRIORITIES 5 -#define configMINIMAL_STACK_SIZE ((unsigned short)90) -#define configMAX_TASK_NAME_LEN 20 -#define configUSE_16_BIT_TICKS 0 -#define configIDLE_SHOULD_YIELD 1 -#define configUSE_TASK_NOTIFICATIONS 1 -#define configUSE_MUTEXES 1 -#define configUSE_RECURSIVE_MUTEXES 1 -#define configUSE_COUNTING_SEMAPHORES 1 -#define configUSE_ALTERNATIVE_API 0 /* Deprecated! */ -#define configQUEUE_REGISTRY_SIZE 8 -#define configUSE_QUEUE_SETS 0 -#define configUSE_TIME_SLICING 1 -#define configUSE_NEWLIB_REENTRANT 0 -#define configENABLE_BACKWARD_COMPATIBILITY 0 -#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 - -/* Used memory allocation (heap_x.c) */ -#define configFRTOS_MEMORY_SCHEME 4 -/* Tasks.c additions (e.g. Thread Aware Debug capability) */ -#define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 0 - -/* Memory allocation related definitions. */ -#define configSUPPORT_STATIC_ALLOCATION 0 -#define configSUPPORT_DYNAMIC_ALLOCATION 1 -#define configTOTAL_HEAP_SIZE ((size_t)(20 * 1024)) -#define configAPPLICATION_ALLOCATED_HEAP 0 - -/* Hook function related definitions. */ -#define configUSE_IDLE_HOOK 0 -#define configUSE_TICK_HOOK 0 -#define configCHECK_FOR_STACK_OVERFLOW 0 -#define configUSE_MALLOC_FAILED_HOOK 0 -#define configUSE_DAEMON_TASK_STARTUP_HOOK 0 - -/* Run time and task stats gathering related definitions. */ -#define configGENERATE_RUN_TIME_STATS 1 -#define configUSE_TRACE_FACILITY 1 -#define configUSE_STATS_FORMATTING_FUNCTIONS 1 - -/* Task aware debugging. */ -#define configRECORD_STACK_HIGH_ADDRESS 1 - -/* Co-routine related definitions. */ -#define configUSE_CO_ROUTINES 0 -#define configMAX_CO_ROUTINE_PRIORITIES 2 - -/* Software timer related definitions. */ -#define configUSE_TIMERS 1 -#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) -#define configTIMER_QUEUE_LENGTH 10 -#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2) - -/* Define to trap errors during development. */ -#define configASSERT(x) if(( x) == 0) {taskDISABLE_INTERRUPTS(); for (;;);} - -/* Optional functions - most linkers will remove unused functions anyway. */ -#define INCLUDE_vTaskPrioritySet 1 -#define INCLUDE_uxTaskPriorityGet 1 -#define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskSuspend 1 -#define INCLUDE_vTaskDelayUntil 1 -#define INCLUDE_vTaskDelay 1 -#define INCLUDE_xTaskGetSchedulerState 1 -#define INCLUDE_xTaskGetCurrentTaskHandle 1 -#define INCLUDE_uxTaskGetStackHighWaterMark 0 -#define INCLUDE_xTaskGetIdleTaskHandle 0 -#define INCLUDE_eTaskGetState 0 -#define INCLUDE_xTimerPendFunctionCall 1 -#define INCLUDE_xTaskAbortDelay 0 -#define INCLUDE_xTaskGetHandle 0 -#define INCLUDE_xTaskResumeFromISR 1 - - -/* Cortex-A specific definitions. */ -#define configMAX_API_CALL_INTERRUPT_PRIORITY 20 - -/* Systick definitions */ -#define configSETUP_TICK_INTERRUPT() \ - do \ - { \ - void SystemSetupSystick(uint32_t tickRateHz, void *tickHandler, uint32_t intPriority); \ - /* Setup systick with lowest priority */ \ - SystemSetupSystick(configTICK_RATE_HZ, (void *)FreeRTOS_Tick_Handler, configUNIQUE_INTERRUPT_PRIORITIES - 2); \ - } while (0) -#define configCLEAR_TICK_INTERRUPT() \ - do \ - { \ - void SystemClearSystickFlag(void); \ - SystemClearSystickFlag(); \ - } while (0) - -/* Definitions that map the FreeRTOS port exception handlers to startup handler names. */ -#define FreeRTOS_IRQ_Handler IRQ_Handler -#define FreeRTOS_SWI_Handler SVC_Handler - -/* - * If define configUSE_TASK_FPU_SUPPORT to 1, the task will start without a floating - * point context. A task that uses the floating point hardware must call vPortTaskUsesFPU() - * before executing any floating point instructions. - */ -#ifndef configUSE_TASK_FPU_SUPPORT -#define configUSE_TASK_FPU_SUPPORT 1 -#endif - -/* GIC information defintions. */ -#define configINTERRUPT_CONTROLLER_BASE_ADDRESS 0x00a01000UL -#define configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET 0x1000UL -#define configUNIQUE_INTERRUPT_PRIORITIES 32 - -//#define sprintf tfp_sprintf - -extern volatile unsigned int g_cpu_runtime; - -#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() (g_cpu_runtime = 0ul) -#define portGET_RUN_TIME_COUNTER_VALUE() g_cpu_runtime - -#endif /* FREERTOS_CONFIG_H */ diff --git a/third-party/freertos/portable/GCC/qemu_aarch32/port.c b/third-party/freertos/portable/GCC/qemu_aarch32/port.c deleted file mode 100644 index 9f39e183931540d06c0e4277523ac2ba147862e2..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/qemu_aarch32/port.c +++ /dev/null @@ -1,610 +0,0 @@ -/* - FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -/* Standard includes. */ -#include - -/* Scheduler includes. */ -#include "FreeRTOS.h" -#include "task.h" - -#ifndef configINTERRUPT_CONTROLLER_BASE_ADDRESS - #error configINTERRUPT_CONTROLLER_BASE_ADDRESS must be defined. See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif - -#ifndef configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET - #error configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET must be defined. See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif - -#ifndef configUNIQUE_INTERRUPT_PRIORITIES - #error configUNIQUE_INTERRUPT_PRIORITIES must be defined. See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif - -#ifndef configSETUP_TICK_INTERRUPT - #error configSETUP_TICK_INTERRUPT() must be defined. See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif /* configSETUP_TICK_INTERRUPT */ - -#ifndef configMAX_API_CALL_INTERRUPT_PRIORITY - #error configMAX_API_CALL_INTERRUPT_PRIORITY must be defined. See http://www.freertos.org/Using-FreeRTOS-on-Cortex-A-Embedded-Processors.html -#endif - -#if configMAX_API_CALL_INTERRUPT_PRIORITY == 0 - #error configMAX_API_CALL_INTERRUPT_PRIORITY must not be set to 0 -#endif - -#if configMAX_API_CALL_INTERRUPT_PRIORITY > configUNIQUE_INTERRUPT_PRIORITIES - #error configMAX_API_CALL_INTERRUPT_PRIORITY must be less than or equal to configUNIQUE_INTERRUPT_PRIORITIES as the lower the numeric priority value the higher the logical interrupt priority -#endif - -#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 - /* Check the configuration. */ - #if( configMAX_PRIORITIES > 32 ) - #error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice. - #endif -#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ - -/* In case security extensions are implemented. */ -#if configMAX_API_CALL_INTERRUPT_PRIORITY <= ( configUNIQUE_INTERRUPT_PRIORITIES / 2 ) - #error configMAX_API_CALL_INTERRUPT_PRIORITY must be greater than ( configUNIQUE_INTERRUPT_PRIORITIES / 2 ) -#endif - -/* Some vendor specific files default configCLEAR_TICK_INTERRUPT() in -portmacro.h. */ -#ifndef configCLEAR_TICK_INTERRUPT - #define configCLEAR_TICK_INTERRUPT() -#endif - -/* A critical section is exited when the critical section nesting count reaches -this value. */ -#define portNO_CRITICAL_NESTING ( ( uint32_t ) 0 ) - -/* In all GICs 255 can be written to the priority mask register to unmask all -(but the lowest) interrupt priority. */ -#define portUNMASK_VALUE ( 0xFFUL ) - -/* Tasks are not created with a floating point context, but can be given a -floating point context after they have been created. A variable is stored as -part of the tasks context that holds portNO_FLOATING_POINT_CONTEXT if the task -does not have an FPU context, or any other value if the task does have an FPU -context. */ -#define portNO_FLOATING_POINT_CONTEXT ( ( StackType_t ) 0 ) - -/* Constants required to setup the initial task context. */ -#define portINITIAL_SPSR ( ( StackType_t ) 0x1f ) /* System mode, ARM mode, IRQ enabled FIQ enabled. */ -#define portTHUMB_MODE_BIT ( ( StackType_t ) 0x20 ) -#define portINTERRUPT_ENABLE_BIT ( 0x80UL ) -#define portTHUMB_MODE_ADDRESS ( 0x01UL ) - -/* Used by portASSERT_IF_INTERRUPT_PRIORITY_INVALID() when ensuring the binary -point is zero. */ -#define portBINARY_POINT_BITS ( ( uint8_t ) 0x03 ) - -/* Masks all bits in the APSR other than the mode bits. */ -#define portAPSR_MODE_BITS_MASK ( 0x1F ) - -/* The value of the mode bits in the APSR when the CPU is executing in user -mode. */ -#define portAPSR_USER_MODE ( 0x10 ) - -/* The critical section macros only mask interrupts up to an application -determined priority level. Sometimes it is necessary to turn interrupt off in -the CPU itself before modifying certain hardware registers. */ -#define portCPU_IRQ_DISABLE() \ - __asm volatile ( "CPSID i" ); \ - __asm volatile ( "DSB" ); \ - __asm volatile ( "ISB" ); - -#define portCPU_IRQ_ENABLE() \ - __asm volatile ( "CPSIE i" ); \ - __asm volatile ( "DSB" ); \ - __asm volatile ( "ISB" ); - - -/* Macro to unmask all interrupt priorities. */ -#define portCLEAR_INTERRUPT_MASK() \ -{ \ - portCPU_IRQ_DISABLE(); \ - portICCPMR_PRIORITY_MASK_REGISTER = portUNMASK_VALUE; \ - __asm volatile ( "DSB \n" \ - "ISB \n" ); \ - portCPU_IRQ_ENABLE(); \ -} - -#define portINTERRUPT_PRIORITY_REGISTER_OFFSET 0x400UL -#define portMAX_8_BIT_VALUE ( ( uint8_t ) 0xff ) -#define portBIT_0_SET ( ( uint8_t ) 0x01 ) - -/* Let the user override the pre-loading of the initial LR with the address of -prvTaskExitError() in case it messes up unwinding of the stack in the -debugger. */ -#ifdef configTASK_RETURN_ADDRESS - #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS -#else - #define portTASK_RETURN_ADDRESS prvTaskExitError -#endif - -/* The space on the stack required to hold the FPU registers. This is 32 64-bit -registers, plus a 32-bit status register. */ -#define portFPU_REGISTER_WORDS ( ( 32 * 2 ) + 1 ) - -/*-----------------------------------------------------------*/ - -/* - * Starts the first task executing. This function is necessarily written in - * assembly code so is implemented in portASM.s. - */ -extern void vPortRestoreTaskContext( void ); - -/* - * Used to catch tasks that attempt to return from their implementing function. - */ -static void prvTaskExitError( void ); - -/* - * If the application provides an implementation of vApplicationIRQHandler(), - * then it will get called directly without saving the FPU registers on - * interrupt entry, and this weak implementation of - * vApplicationFPUSafeIRQHandler() is just provided to remove linkage errors - - * it should never actually get called so its implementation contains a - * call to configASSERT() that will always fail. - * - * If the application provides its own implementation of - * vApplicationFPUSafeIRQHandler() then the implementation of - * vApplicationIRQHandler() provided in portASM.S will save the FPU registers - * before calling it. - * - * Therefore, if the application writer wants FPU registers to be saved on - * interrupt entry their IRQ handler must be called - * vApplicationFPUSafeIRQHandler(), and if the application writer does not want - * FPU registers to be saved on interrupt entry their IRQ handler must be - * called vApplicationIRQHandler(). - */ -void vApplicationFPUSafeIRQHandler( uint32_t ulICCIAR ) __attribute__((weak) ); - -/*-----------------------------------------------------------*/ - -/* A variable is used to keep track of the critical section nesting. This -variable has to be stored as part of the task context and must be initialised to -a non zero value to ensure interrupts don't inadvertently become unmasked before -the scheduler starts. As it is stored as part of the task context it will -automatically be set to 0 when the first task is started. */ -volatile uint32_t ulCriticalNesting = 9999UL; - -/* Saved as part of the task context. If ulPortTaskHasFPUContext is non-zero then -a floating point context must be saved and restored for the task. */ -volatile uint32_t ulPortTaskHasFPUContext = pdFALSE; - -/* Set to 1 to pend a context switch from an ISR. */ -volatile uint32_t ulPortYieldRequired = pdFALSE; - -/* Counts the interrupt nesting depth. A context switch is only performed if -if the nesting depth is 0. */ -volatile uint32_t ulPortInterruptNesting = 0UL; - -/* Used in the asm file. */ -__attribute__(( used )) const uint32_t ulICCIAR = portICCIAR_INTERRUPT_ACKNOWLEDGE_REGISTER_ADDRESS; -__attribute__(( used )) const uint32_t ulICCEOIR = portICCEOIR_END_OF_INTERRUPT_REGISTER_ADDRESS; -__attribute__(( used )) const uint32_t ulICCPMR = portICCPMR_PRIORITY_MASK_REGISTER_ADDRESS; -__attribute__(( used )) const uint32_t ulMaxAPIPriorityMask = ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT ); - -/*-----------------------------------------------------------*/ - -/* - * See header file for description. - */ -StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) -{ - /* Setup the initial stack of the task. The stack is set exactly as - expected by the portRESTORE_CONTEXT() macro. - - The fist real value on the stack is the status register, which is set for - system mode, with interrupts enabled. A few NULLs are added first to ensure - GDB does not try decoding a non-existent return address. */ - *pxTopOfStack = ( StackType_t ) NULL; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) NULL; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) NULL; - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) portINITIAL_SPSR; - - if( ( ( uint32_t ) pxCode & portTHUMB_MODE_ADDRESS ) != 0x00UL ) - { - /* The task will start in THUMB mode. */ - *pxTopOfStack |= portTHUMB_MODE_BIT; - } - - pxTopOfStack--; - - /* Next the return address, which in this case is the start of the task. */ - *pxTopOfStack = ( StackType_t ) pxCode; - pxTopOfStack--; - - /* Next all the registers other than the stack pointer. */ - *pxTopOfStack = ( StackType_t ) portTASK_RETURN_ADDRESS; /* R14 */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 0x12121212; /* R12 */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 0x11111111; /* R11 */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 0x10101010; /* R10 */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 0x09090909; /* R9 */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 0x08080808; /* R8 */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 0x07070707; /* R7 */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 0x06060606; /* R6 */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 0x05050505; /* R5 */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 0x04040404; /* R4 */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 0x03030303; /* R3 */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 0x02020202; /* R2 */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 0x01010101; /* R1 */ - pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) pvParameters; /* R0 */ - pxTopOfStack--; - - /* The task will start with a critical nesting count of 0 as interrupts are - enabled. */ - *pxTopOfStack = portNO_CRITICAL_NESTING; - - #if( configUSE_TASK_FPU_SUPPORT == 1 ) - { - /* The task will start without a floating point context. A task that - uses the floating point hardware must call vPortTaskUsesFPU() before - executing any floating point instructions. */ - pxTopOfStack--; - *pxTopOfStack = portNO_FLOATING_POINT_CONTEXT; - } - #elif( configUSE_TASK_FPU_SUPPORT == 2 ) - { - /* The task will start with a floating point context. Leave enough - space for the registers - and ensure they are initialised to 0. */ - pxTopOfStack -= portFPU_REGISTER_WORDS; - memset( pxTopOfStack, 0x00, portFPU_REGISTER_WORDS * sizeof( StackType_t ) ); - - pxTopOfStack--; - *pxTopOfStack = pdTRUE; - ulPortTaskHasFPUContext = pdTRUE; - } - #else - { - #error Invalid configUSE_TASK_FPU_SUPPORT setting - configUSE_TASK_FPU_SUPPORT must be set to 1, 2, or left undefined. - } - #endif - - return pxTopOfStack; -} -/*-----------------------------------------------------------*/ - -static void prvTaskExitError( void ) -{ - /* A function that implements a task must not exit or attempt to return to - its caller as there is nothing to return to. If a task wants to exit it - should instead call vTaskDelete( NULL ). - - Artificially force an assert() to be triggered if configASSERT() is - defined, then stop here so application writers can catch the error. */ - configASSERT( ulPortInterruptNesting == ~0UL ); - portDISABLE_INTERRUPTS(); - for( ;; ); -} -/*-----------------------------------------------------------*/ - -BaseType_t xPortStartScheduler( void ) -{ -uint32_t ulAPSR; - - #if( configASSERT_DEFINED == 1 ) - { - volatile uint32_t ulOriginalPriority; - volatile uint8_t * const pucFirstUserPriorityRegister = ( volatile uint8_t * const ) ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + portINTERRUPT_PRIORITY_REGISTER_OFFSET ); - volatile uint8_t ucMaxPriorityValue; - - /* Determine how many priority bits are implemented in the GIC. - - Save the interrupt priority value that is about to be clobbered. */ - ulOriginalPriority = *pucFirstUserPriorityRegister; - - /* Determine the number of priority bits available. First write to - all possible bits. */ - *pucFirstUserPriorityRegister = portMAX_8_BIT_VALUE; - - /* Read the value back to see how many bits stuck. */ - ucMaxPriorityValue = *pucFirstUserPriorityRegister; - - /* Shift to the least significant bits. */ - while( ( ucMaxPriorityValue & portBIT_0_SET ) != portBIT_0_SET ) - { - ucMaxPriorityValue >>= ( uint8_t ) 0x01; - } - - /* Sanity check configUNIQUE_INTERRUPT_PRIORITIES matches the read - value. */ - //configASSERT( ucMaxPriorityValue == portLOWEST_INTERRUPT_PRIORITY ); - - /* Restore the clobbered interrupt priority register to its original - value. */ - *pucFirstUserPriorityRegister = ulOriginalPriority; - } - #endif /* conifgASSERT_DEFINED */ - - - /* Only continue if the CPU is not in User mode. The CPU must be in a - Privileged mode for the scheduler to start. */ - __asm volatile ( "MRS %0, APSR" : "=r" ( ulAPSR ) ); - ulAPSR &= portAPSR_MODE_BITS_MASK; - configASSERT( ulAPSR != portAPSR_USER_MODE ); - - if( ulAPSR != portAPSR_USER_MODE ) - { - /* Only continue if the binary point value is set to its lowest possible - setting. See the comments in vPortValidateInterruptPriority() below for - more information. */ - configASSERT( ( portICCBPR_BINARY_POINT_REGISTER & portBINARY_POINT_BITS ) <= portMAX_BINARY_POINT_VALUE ); - - if( ( portICCBPR_BINARY_POINT_REGISTER & portBINARY_POINT_BITS ) <= portMAX_BINARY_POINT_VALUE ) - { - /* Interrupts are turned off in the CPU itself to ensure tick does - not execute while the scheduler is being started. Interrupts are - automatically turned back on in the CPU when the first task starts - executing. */ - portCPU_IRQ_DISABLE(); - - /* Start the timer that generates the tick ISR. */ - configSETUP_TICK_INTERRUPT(); - - /* Start the first task executing. */ - vPortRestoreTaskContext(); - } - } - - /* Will only get here if vTaskStartScheduler() was called with the CPU in - a non-privileged mode or the binary point register was not set to its lowest - possible value. prvTaskExitError() is referenced to prevent a compiler - warning about it being defined but not referenced in the case that the user - defines their own exit address. */ - ( void ) prvTaskExitError; - return 0; -} -/*-----------------------------------------------------------*/ - -void vPortEndScheduler( void ) -{ - /* Not implemented in ports where there is nothing to return to. - Artificially force an assert. */ - configASSERT( ulCriticalNesting == 1000UL ); -} -/*-----------------------------------------------------------*/ - -void vPortEnterCritical( void ) -{ - /* Mask interrupts up to the max syscall interrupt priority. */ - ulPortSetInterruptMask(); - - /* Now interrupts are disabled ulCriticalNesting can be accessed - directly. Increment ulCriticalNesting to keep a count of how many times - portENTER_CRITICAL() has been called. */ - ulCriticalNesting++; - - /* This is not the interrupt safe version of the enter critical function so - assert() if it is being called from an interrupt context. Only API - functions that end in "FromISR" can be used in an interrupt. Only assert if - the critical nesting count is 1 to protect against recursive calls if the - assert function also uses a critical section. */ - if( ulCriticalNesting == 1 ) - { - configASSERT( ulPortInterruptNesting == 0 ); - } -} -/*-----------------------------------------------------------*/ - -void vPortExitCritical( void ) -{ - if( ulCriticalNesting > portNO_CRITICAL_NESTING ) - { - /* Decrement the nesting count as the critical section is being - exited. */ - ulCriticalNesting--; - - /* If the nesting level has reached zero then all interrupt - priorities must be re-enabled. */ - if( ulCriticalNesting == portNO_CRITICAL_NESTING ) - { - /* Critical nesting has reached zero so all interrupt priorities - should be unmasked. */ - portCLEAR_INTERRUPT_MASK(); - } - } -} -/*-----------------------------------------------------------*/ - -void FreeRTOS_Tick_Handler( void ) -{ - /* Set interrupt mask before altering scheduler structures. The tick - handler runs at the lowest priority, so interrupts cannot already be masked, - so there is no need to save and restore the current mask value. It is - necessary to turn off interrupts in the CPU itself while the ICCPMR is being - updated. */ - portCPU_IRQ_DISABLE(); - portICCPMR_PRIORITY_MASK_REGISTER = ( uint32_t ) ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT ); - __asm volatile ( "dsb \n" - "isb \n" ); - portCPU_IRQ_ENABLE(); - - /* Increment the RTOS tick. */ - if( xTaskIncrementTick() != pdFALSE ) - { - ulPortYieldRequired = pdTRUE; - } - - /* Ensure all interrupt priorities are active again. */ - portCLEAR_INTERRUPT_MASK(); - configCLEAR_TICK_INTERRUPT(); -} -/*-----------------------------------------------------------*/ - -#if( configUSE_TASK_FPU_SUPPORT != 2 ) - - void vPortTaskUsesFPU( void ) - { - uint32_t ulInitialFPSCR = 0; - - /* A task is registering the fact that it needs an FPU context. Set the - FPU flag (which is saved as part of the task context). */ - ulPortTaskHasFPUContext = pdTRUE; - - /* Initialise the floating point status register. */ - __asm volatile ( "FMXR FPSCR, %0" :: "r" (ulInitialFPSCR) ); - } - -#endif /* configUSE_TASK_FPU_SUPPORT */ -/*-----------------------------------------------------------*/ - -void vPortClearInterruptMask( uint32_t ulNewMaskValue ) -{ - if( ulNewMaskValue == pdFALSE ) - { - portCLEAR_INTERRUPT_MASK(); - } -} -/*-----------------------------------------------------------*/ - -uint32_t ulPortSetInterruptMask( void ) -{ -uint32_t ulReturn; - - /* Interrupt in the CPU must be turned off while the ICCPMR is being - updated. */ - portCPU_IRQ_DISABLE(); - if( portICCPMR_PRIORITY_MASK_REGISTER == ( uint32_t ) ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT ) ) - { - /* Interrupts were already masked. */ - ulReturn = pdTRUE; - } - else - { - ulReturn = pdFALSE; - portICCPMR_PRIORITY_MASK_REGISTER = ( uint32_t ) ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT ); - __asm volatile ( "dsb \n" - "isb \n" ); - } - portCPU_IRQ_ENABLE(); - - return ulReturn; -} -/*-----------------------------------------------------------*/ - -#if( configASSERT_DEFINED == 1 ) - - void vPortValidateInterruptPriority( void ) - { - /* The following assertion will fail if a service routine (ISR) for - an interrupt that has been assigned a priority above - configMAX_SYSCALL_INTERRUPT_PRIORITY calls an ISR safe FreeRTOS API - function. ISR safe FreeRTOS API functions must *only* be called - from interrupts that have been assigned a priority at or below - configMAX_SYSCALL_INTERRUPT_PRIORITY. - - Numerically low interrupt priority numbers represent logically high - interrupt priorities, therefore the priority of the interrupt must - be set to a value equal to or numerically *higher* than - configMAX_SYSCALL_INTERRUPT_PRIORITY. - - FreeRTOS maintains separate thread and ISR API functions to ensure - interrupt entry is as fast and simple as possible. */ - configASSERT( portICCRPR_RUNNING_PRIORITY_REGISTER >= ( uint32_t ) ( configMAX_API_CALL_INTERRUPT_PRIORITY << portPRIORITY_SHIFT ) ); - - /* Priority grouping: The interrupt controller (GIC) allows the bits - that define each interrupt's priority to be split between bits that - define the interrupt's pre-emption priority bits and bits that define - the interrupt's sub-priority. For simplicity all bits must be defined - to be pre-emption priority bits. The following assertion will fail if - this is not the case (if some bits represent a sub-priority). - - The priority grouping is configured by the GIC's binary point register - (ICCBPR). Writting 0 to ICCBPR will ensure it is set to its lowest - possible value (which may be above 0). */ - configASSERT( ( portICCBPR_BINARY_POINT_REGISTER & portBINARY_POINT_BITS ) <= portMAX_BINARY_POINT_VALUE ); - } - -#endif /* configASSERT_DEFINED */ -/*-----------------------------------------------------------*/ - -void vApplicationFPUSafeIRQHandler( uint32_t ulICCIAR ) -{ - ( void ) ulICCIAR; - configASSERT( ( volatile void * ) NULL ); -} diff --git a/third-party/freertos/portable/GCC/qemu_aarch32/portASM.S b/third-party/freertos/portable/GCC/qemu_aarch32/portASM.S deleted file mode 100644 index 46ff2cfcd03988030fa4b8fd55c86720bed99217..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/qemu_aarch32/portASM.S +++ /dev/null @@ -1,349 +0,0 @@ -/* - FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. - All rights reserved - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** - - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation AND MODIFIED BY the FreeRTOS exception. - >>>NOTE<<< The modification to the GPL is included to allow you to - distribute a combined work that includes FreeRTOS without being obliged to - provide the source code for proprietary components outside of the FreeRTOS - kernel. FreeRTOS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. - - 1 tab == 4 spaces! - - http://www.FreeRTOS.org - Documentation, latest information, license and - contact details. - - http://www.SafeRTOS.com - A version that is certified for use in safety - critical systems. - - http://www.OpenRTOS.com - Commercial support, development, porting, - licensing and training services. -*/ - - .text - .arm - - .set SYS_MODE, 0x1f - .set SVC_MODE, 0x13 - .set IRQ_MODE, 0x12 - - /* Hardware registers. */ - .extern ulICCIAR - .extern ulICCEOIR - .extern ulICCPMR - - /* Variables and functions. */ - .extern ulMaxAPIPriorityMask - .extern _freertos_vector_table - .extern pxCurrentTCB - .extern vTaskSwitchContext - .extern vApplicationIRQHandler - .extern ulPortInterruptNesting - .extern ulPortTaskHasFPUContext - - .global FreeRTOS_IRQ_Handler - .global FreeRTOS_SWI_Handler - .global vPortRestoreTaskContext - - - - -.macro portSAVE_CONTEXT - - /* Save the LR and SPSR onto the system mode stack before switching to - system mode to save the remaining system mode registers. */ - SRSDB sp!, #SYS_MODE - CPS #SYS_MODE - PUSH {R0-R12, R14} - - /* Push the critical nesting count. */ - LDR R2, ulCriticalNestingConst - LDR R1, [R2] - PUSH {R1} - - /* Does the task have a floating point context that needs saving? If - ulPortTaskHasFPUContext is 0 then no. */ - LDR R2, ulPortTaskHasFPUContextConst - LDR R3, [R2] - CMP R3, #0 - - /* Save the floating point context, if any. */ - FMRXNE R1, FPSCR - VPUSHNE {D0-D15} - VPUSHNE {D16-D31} - PUSHNE {R1} - - /* Save ulPortTaskHasFPUContext itself. */ - PUSH {R3} - - /* Save the stack pointer in the TCB. */ - LDR R0, pxCurrentTCBConst - LDR R1, [R0] - STR SP, [R1] - - .endm - -; /**********************************************************************/ - -.macro portRESTORE_CONTEXT - - /* Set the SP to point to the stack of the task being restored. */ - LDR R0, pxCurrentTCBConst - LDR R1, [R0] - LDR SP, [R1] - - /* Is there a floating point context to restore? If the restored - ulPortTaskHasFPUContext is zero then no. */ - LDR R0, ulPortTaskHasFPUContextConst - POP {R1} - STR R1, [R0] - CMP R1, #0 - - /* Restore the floating point context, if any. */ - POPNE {R0} - VPOPNE {D16-D31} - VPOPNE {D0-D15} - VMSRNE FPSCR, R0 - - /* Restore the critical section nesting depth. */ - LDR R0, ulCriticalNestingConst - POP {R1} - STR R1, [R0] - - /* Ensure the priority mask is correct for the critical nesting depth. */ - LDR R2, ulICCPMRConst - LDR R2, [R2] - CMP R1, #0 - MOVEQ R4, #255 - LDRNE R4, ulMaxAPIPriorityMaskConst - LDRNE R4, [R4] - STR R4, [R2] - - /* Restore all system mode registers other than the SP (which is already - being used). */ - POP {R0-R12, R14} - - /* Return to the task code, loading CPSR on the way. */ - RFEIA sp! - - .endm - - - - -/****************************************************************************** - * SVC handler is used to start the scheduler. - *****************************************************************************/ -.align 4 -.type FreeRTOS_SWI_Handler, %function -FreeRTOS_SWI_Handler: - /* Save the context of the current task and select a new task to run. */ - portSAVE_CONTEXT - LDR R0, vTaskSwitchContextConst - BLX R0 - portRESTORE_CONTEXT - - -/****************************************************************************** - * vPortRestoreTaskContext is used to start the scheduler. - *****************************************************************************/ -.type vPortRestoreTaskContext, %function -vPortRestoreTaskContext: - /* Switch to system mode. */ - CPS #SYS_MODE - portRESTORE_CONTEXT - -.align 4 -.type FreeRTOS_IRQ_Handler, %function -FreeRTOS_IRQ_Handler: - /* Return to the interrupted instruction. */ - SUB lr, lr, #4 - - /* Push the return address and SPSR. */ - PUSH {lr} - MRS lr, SPSR - PUSH {lr} - - /* Change to supervisor mode to allow reentry. */ - CPS #SVC_MODE - - /* Push used registers. */ - PUSH {r0-r4, r12} - - /* Increment nesting count. r3 holds the address of ulPortInterruptNesting - for future use. r1 holds the original ulPortInterruptNesting value for - future use. */ - LDR r3, ulPortInterruptNestingConst - LDR r1, [r3] - ADD r4, r1, #1 - STR r4, [r3] - - /* Read value from the interrupt acknowledge register, which is stored in r0 - for future parameter and interrupt clearing use. */ - LDR r2, ulICCIARConst - LDR r2, [r2] - LDR r0, [r2] - - /* Ensure bit 2 of the stack pointer is clear. r2 holds the bit 2 value for - future use. */ - MOV r2, sp - AND r2, r2, #4 - SUB sp, sp, r2 - - /* Call the interrupt handler. */ - PUSH {r0-r3, lr} - LDR r1, vApplicationIRQHandlerConst - BLX r1 - POP {r0-r3, lr} - ADD sp, sp, r2 - - CPSID i - DSB - ISB - - /* Write the value read from ICCIAR to ICCEOIR. */ - LDR r4, ulICCEOIRConst - LDR r4, [r4] - STR r0, [r4] - - /* Restore the old nesting count. */ - STR r1, [r3] - - /* A context switch is never performed if the nesting count is not 0. */ - CMP r1, #0 - BNE exit_without_switch - - /* Did the interrupt request a context switch? r1 holds the address of - ulPortYieldRequired and r0 the value of ulPortYieldRequired for future - use. */ - LDR r1, =ulPortYieldRequired - LDR r0, [r1] - CMP r0, #0 - BNE switch_before_exit - -exit_without_switch: - /* No context switch. Restore used registers, LR_irq and SPSR before - returning. */ - POP {r0-r4, r12} - CPS #IRQ_MODE - POP {LR} - MSR SPSR_cxsf, LR - POP {LR} - MOVS PC, LR - -switch_before_exit: - /* A context swtich is to be performed. Clear the context switch pending - flag. */ - MOV r0, #0 - STR r0, [r1] - - /* Restore used registers, LR-irq and SPSR before saving the context - to the task stack. */ - POP {r0-r4, r12} - CPS #IRQ_MODE - POP {LR} - MSR SPSR_cxsf, LR - POP {LR} - portSAVE_CONTEXT - - /* Call the function that selects the new task to execute. - vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD - instructions, or 8 byte aligned stack allocated data. LR does not need - saving as a new LR will be loaded by portRESTORE_CONTEXT anyway. */ - LDR R0, vTaskSwitchContextConst - BLX R0 - - /* Restore the context of, and branch to, the task selected to execute - next. */ - portRESTORE_CONTEXT - - -/****************************************************************************** - * If the application provides an implementation of vApplicationIRQHandler(), - * then it will get called directly without saving the FPU registers on - * interrupt entry, and this weak implementation of - * vApplicationIRQHandler() will not get called. - * - * If the application provides its own implementation of - * vApplicationFPUSafeIRQHandler() then this implementation of - * vApplicationIRQHandler() will be called, save the FPU registers, and then - * call vApplicationFPUSafeIRQHandler(). - * - * Therefore, if the application writer wants FPU registers to be saved on - * interrupt entry their IRQ handler must be called - * vApplicationFPUSafeIRQHandler(), and if the application writer does not want - * FPU registers to be saved on interrupt entry their IRQ handler must be - * called vApplicationIRQHandler(). - *****************************************************************************/ - -.align 4 -.weak vApplicationIRQHandler -.type vApplicationIRQHandler, %function -vApplicationIRQHandler: - PUSH {LR} - FMRX R1, FPSCR - VPUSH {D0-D15} - VPUSH {D16-D31} - PUSH {R1} - - LDR r1, vApplicationFPUSafeIRQHandlerConst - BLX r1 - - POP {R0} - VPOP {D16-D31} - VPOP {D0-D15} - VMSR FPSCR, R0 - - POP {PC} - - -ulICCIARConst: .word ulICCIAR -ulICCEOIRConst: .word ulICCEOIR -ulICCPMRConst: .word ulICCPMR -pxCurrentTCBConst: .word pxCurrentTCB -ulCriticalNestingConst: .word ulCriticalNesting -ulPortTaskHasFPUContextConst: .word ulPortTaskHasFPUContext -ulMaxAPIPriorityMaskConst: .word ulMaxAPIPriorityMask -vTaskSwitchContextConst: .word vTaskSwitchContext -vApplicationIRQHandlerConst: .word vApplicationIRQHandler -ulPortInterruptNestingConst: .word ulPortInterruptNesting -vApplicationFPUSafeIRQHandlerConst: .word vApplicationFPUSafeIRQHandler - -.end - - - - - diff --git a/third-party/freertos/portable/GCC/qemu_aarch32/portmacro.h b/third-party/freertos/portable/GCC/qemu_aarch32/portmacro.h deleted file mode 100644 index a6b4a7466a031cd3a2f105e3f7fc13beec93349f..0000000000000000000000000000000000000000 --- a/third-party/freertos/portable/GCC/qemu_aarch32/portmacro.h +++ /dev/null @@ -1,256 +0,0 @@ -/* - FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. - All rights reserved - - VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - This file is part of the FreeRTOS distribution. - - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the - Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. - - *************************************************************************** - >>! NOTE: The modification to the GPL is included to allow you to !<< - >>! distribute a combined work that includes FreeRTOS without being !<< - >>! obliged to provide the source code for proprietary components !<< - >>! outside of the FreeRTOS kernel. !<< - *************************************************************************** - - FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available on the following - link: http://www.freertos.org/a00114.html - - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that is more than just the market leader, it * - * is the industry's de facto standard. * - * * - * Help yourself get started quickly while simultaneously helping * - * to support the FreeRTOS project by purchasing a FreeRTOS * - * tutorial book, reference manual, or both: * - * http://www.FreeRTOS.org/Documentation * - * * - *************************************************************************** - - http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading - the FAQ page "My application does not run, what could be wrong?". Have you - defined configASSERT()? - - http://www.FreeRTOS.org/support - In return for receiving this top quality - embedded software for free we request you assist our global community by - participating in the support forum. - - http://www.FreeRTOS.org/training - Investing in training allows your team to - be as productive as possible as early as possible. Now you can receive - FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers - Ltd, and the world's leading authority on the world's leading RTOS. - - http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, - including FreeRTOS+Trace - an indispensable productivity tool, a DOS - compatible FAT file system, and our tiny thread aware UDP/IP stack. - - http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. - Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. - - http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High - Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and commercial middleware. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and - mission critical applications that require provable dependability. - - 1 tab == 4 spaces! -*/ - -#ifndef PORTMACRO_H -#define PORTMACRO_H - -#ifdef __cplusplus - extern "C" { -#endif - -/*----------------------------------------------------------- - * Port specific definitions. - * - * The settings in this file configure FreeRTOS correctly for the given hardware - * and compiler. - * - * These settings should not be altered. - *----------------------------------------------------------- - */ - -/* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE double -#define portLONG long -#define portSHORT short -#define portSTACK_TYPE uint32_t -#define portBASE_TYPE long - -typedef portSTACK_TYPE StackType_t; -typedef long BaseType_t; -typedef unsigned long UBaseType_t; - -typedef uint32_t TickType_t; -#define portMAX_DELAY ( TickType_t ) 0xffffffffUL - -/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do -not need to be guarded with a critical section. */ -#define portTICK_TYPE_IS_ATOMIC 1 - -/*-----------------------------------------------------------*/ - -/* Hardware specifics. */ -#define portSTACK_GROWTH ( -1 ) -#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) -#define portBYTE_ALIGNMENT 8 - -/*-----------------------------------------------------------*/ - -/* Task utilities. */ - -/* Called at the end of an ISR that can cause a context switch. */ -#define portEND_SWITCHING_ISR( xSwitchRequired )\ -{ \ -extern uint32_t ulPortYieldRequired; \ - \ - if( xSwitchRequired != pdFALSE ) \ - { \ - ulPortYieldRequired = pdTRUE; \ - } \ -} - -#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) -#define portYIELD() __asm volatile ( "SWI 0" ); - - -/*----------------------------------------------------------- - * Critical section control - *----------------------------------------------------------*/ - -extern void vPortEnterCritical( void ); -extern void vPortExitCritical( void ); -extern uint32_t ulPortSetInterruptMask( void ); -extern void vPortClearInterruptMask( uint32_t ulNewMaskValue ); -extern void vPortInstallFreeRTOSVectorTable( void ); - -/* These macros do not globally disable/enable interrupts. They do mask off -interrupts that have a priority below configMAX_API_CALL_INTERRUPT_PRIORITY. */ -#define portENTER_CRITICAL() vPortEnterCritical(); -#define portEXIT_CRITICAL() vPortExitCritical(); -#define portDISABLE_INTERRUPTS() ulPortSetInterruptMask() -#define portENABLE_INTERRUPTS() vPortClearInterruptMask( 0 ) -#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortSetInterruptMask() -#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask(x) - -/*-----------------------------------------------------------*/ - -/* Task function macros as described on the FreeRTOS.org WEB site. These are -not required for this port but included in case common demo code that uses these -macros is used. */ -#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) -#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) -/*-----------------------------------------------------------*/ - -/* Tickless idle/low power functionality. */ -#ifndef portSUPPRESS_TICKS_AND_SLEEP - extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ); - #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime ) -#endif -/*-----------------------------------------------------------*/ - -/* Prototype of the FreeRTOS tick handler. This must be installed as the -handler for whichever peripheral is used to generate the RTOS tick. */ -void FreeRTOS_Tick_Handler( void ); - -/* If configUSE_TASK_FPU_SUPPORT is set to 1 (or left undefined) then tasks are -created without an FPU context and must call vPortTaskUsesFPU() to give -themselves an FPU context before using any FPU instructions. If -configUSE_TASK_FPU_SUPPORT is set to 2 then all tasks will have an FPU context -by default. */ -#if( configUSE_TASK_FPU_SUPPORT != 2 ) - void vPortTaskUsesFPU( void ); -#else - /* Each task has an FPU context already, so define this function away to - nothing to prevent it being called accidentally. */ - #define vPortTaskUsesFPU() -#endif -#define portTASK_USES_FLOATING_POINT() vPortTaskUsesFPU() - -#define portLOWEST_INTERRUPT_PRIORITY ( ( ( uint32_t ) configUNIQUE_INTERRUPT_PRIORITIES ) - 1UL ) -#define portLOWEST_USABLE_INTERRUPT_PRIORITY ( portLOWEST_INTERRUPT_PRIORITY - 1UL ) - -/* Architecture specific optimisations. */ -#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION - #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 -#endif - -#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1 - - /* Store/clear the ready priorities in a bit map. */ - #define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) ) - #define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) ) - - /*-----------------------------------------------------------*/ - - #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - ( uint32_t ) __builtin_clz( uxReadyPriorities ) ) - -#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */ - -#ifdef configASSERT - void vPortValidateInterruptPriority( void ); - #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority() -#endif /* configASSERT */ - -#define portNOP() __asm volatile( "NOP" ) -#define portINLINE __inline - -#ifdef __cplusplus - } /* extern C */ -#endif - - -/* The number of bits to shift for an interrupt priority is dependent on the -number of bits implemented by the interrupt controller. */ -#if configUNIQUE_INTERRUPT_PRIORITIES == 16 - #define portPRIORITY_SHIFT 4 - #define portMAX_BINARY_POINT_VALUE 3 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 32 - #define portPRIORITY_SHIFT 3 - #define portMAX_BINARY_POINT_VALUE 2 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 64 - #define portPRIORITY_SHIFT 2 - #define portMAX_BINARY_POINT_VALUE 1 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 128 - #define portPRIORITY_SHIFT 1 - #define portMAX_BINARY_POINT_VALUE 0 -#elif configUNIQUE_INTERRUPT_PRIORITIES == 256 - #define portPRIORITY_SHIFT 0 - #define portMAX_BINARY_POINT_VALUE 0 -#else - #error Invalid configUNIQUE_INTERRUPT_PRIORITIES setting. configUNIQUE_INTERRUPT_PRIORITIES must be set to the number of unique priorities implemented by the target hardware -#endif - -/* Interrupt controller access addresses. */ -#define portICCPMR_PRIORITY_MASK_OFFSET ( 0x04 ) -#define portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET ( 0x0C ) -#define portICCEOIR_END_OF_INTERRUPT_OFFSET ( 0x10 ) -#define portICCBPR_BINARY_POINT_OFFSET ( 0x08 ) -#define portICCRPR_RUNNING_PRIORITY_OFFSET ( 0x14 ) - -#define portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS ( configINTERRUPT_CONTROLLER_BASE_ADDRESS + configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET ) -#define portICCPMR_PRIORITY_MASK_REGISTER ( *( ( volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET ) ) ) -#define portICCIAR_INTERRUPT_ACKNOWLEDGE_REGISTER_ADDRESS ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCIAR_INTERRUPT_ACKNOWLEDGE_OFFSET ) -#define portICCEOIR_END_OF_INTERRUPT_REGISTER_ADDRESS ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCEOIR_END_OF_INTERRUPT_OFFSET ) -#define portICCPMR_PRIORITY_MASK_REGISTER_ADDRESS ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCPMR_PRIORITY_MASK_OFFSET ) -#define portICCBPR_BINARY_POINT_REGISTER ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCBPR_BINARY_POINT_OFFSET ) ) ) -#define portICCRPR_RUNNING_PRIORITY_REGISTER ( *( ( const volatile uint32_t * ) ( portINTERRUPT_CONTROLLER_CPU_INTERFACE_ADDRESS + portICCRPR_RUNNING_PRIORITY_OFFSET ) ) ) - -#endif /* PORTMACRO_H */ - diff --git a/third-party/freertos/portable/freertos_configs.c b/third-party/freertos/portable/freertos_configs.c index bcb047f5430e765eaecdb3d0a7d0381782278413..6430e7d47cb99300be8668547f76ba824ebd4f43 100644 --- a/third-party/freertos/portable/freertos_configs.c +++ b/third-party/freertos/portable/freertos_configs.c @@ -20,6 +20,7 @@ #include "interrupt.h" #include "trap.h" #include +#include "ft_assert.h" void vMainAssertCalled(const char *pcFileName, uint32_t ulLineNumber) { @@ -131,4 +132,63 @@ void InitIrq() /* interrupt init */ ArmGicRedistAddressSet(0, GICV3_RD_BASEADDRESS + 0, 0); InterruptInit(GICV3_BASEADDRESS, 0); -} \ No newline at end of file +} + + +void vApplicationStackOverflowHook(xTaskHandle pxTask, signed char *pcTaskName) +{ + (void) pxTask; + (void) pcTaskName; + + taskDISABLE_INTERRUPTS(); + FT_ASSERTNONERETURN(FALSE); + +} + +/* configSUPPORT_STATIC_ALLOCATION is set to 1, so the application must provide an + * implementation of vApplicationGetIdleTaskMemory() to provide the memory that is + * used by the Idle task. */ +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) +{ + /* If the buffers to be provided to the Idle task are declared inside this + * function then they must be declared static - otherwise they will be allocated on + * the stack and so not exists after this function exits. */ + static StaticTask_t xIdleTaskTCB; + static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; + + /* Pass out a pointer to the StaticTask_t structure in which the Idle task's + state will be stored. */ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + + /* Pass out the array that will be used as the Idle task's stack. */ + *ppxIdleTaskStackBuffer = uxIdleTaskStack; + + /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; +} + +/* configSUPPORT_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the + * application must provide an implementation of vApplicationGetTimerTaskMemory() + * to provide the memory that is used by the Timer service task. */ +void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ) +{ + /* If the buffers to be provided to the Timer task are declared inside this + * function then they must be declared static - otherwise they will be allocated on + * the stack and so not exists after this function exits. */ + static StaticTask_t xTimerTaskTCB; + static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; + + /* Pass out a pointer to the StaticTask_t structure in which the Timer + task's state will be stored. */ + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + + /* Pass out the array that will be used as the Timer task's stack. */ + *ppxTimerTaskStackBuffer = uxTimerTaskStack; + + /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */ + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; +} diff --git a/third-party/freertos/tasks.c b/third-party/freertos/tasks.c index 7b3d3380981891e039c88f41cecb3a6ff4725e4b..c56fe949e3ae37eb4dfc1516390acc27ef37a15e 100644 --- a/third-party/freertos/tasks.c +++ b/third-party/freertos/tasks.c @@ -303,7 +303,7 @@ typedef struct tskTaskControlBlock #endif #if (configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0) - void *pvThreadLocalStoragePointers[configNUM_THREAD_LOCAL_STORAGE_POINTERS]; + void *pvThreadLocalStoragePointers[configNUM_THREAD_LOCAL_STORAGE_POINTERS]; #endif #if (configGENERATE_RUN_TIME_STATS == 1) @@ -336,6 +336,10 @@ typedef struct tskTaskControlBlock uint8_t ucDelayAborted; #endif +#if( configUSE_POSIX_ERRNO == 1 ) + int iTaskErrno; + #endif + } tskTCB; /* The old tskTCB name is maintained above then typedefed to the new TCB_t name @@ -3381,7 +3385,6 @@ eSleepModeStatus eTaskConfirmSleepModeStatus(void) /*-----------------------------------------------------------*/ #if (configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0) - void vTaskSetThreadLocalStoragePointer(TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue) { TCB_t *pxTCB; @@ -3898,7 +3901,9 @@ BaseType_t xTaskPriorityDisinherit(TaskHandle_t const pxMutexHolder) If the mutex is held by a task then it cannot be given from an interrupt, and if a mutex is given by the holding task then it must be the running state task. */ + /* current task is used xSemaphoreTake to get mux? */ configASSERT(pxTCB == pxCurrentTCB); + /* this queue is mux type */ configASSERT(pxTCB->uxMutexesHeld); (pxTCB->uxMutexesHeld)--; diff --git a/third-party/third-party.mk b/third-party/third-party.mk index 89b80d5ef67313a3ce1b7037bbadd6cdc6f7858d..0f6ea5e27c12d6b1b732098c2dd59b979937fa17 100644 --- a/third-party/third-party.mk +++ b/third-party/third-party.mk @@ -11,33 +11,13 @@ SRC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable SRC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos ifdef CONFIG_TARGET_ARMV8_AARCH64 - ifdef CONFIG_TARGET_F2000_4 - SRC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/ft2004_aarch64 - INC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/ft2004_aarch64 - endif #CONFIG_TARGET_F2000_4 - - ifdef CONFIG_TARGET_D2000 - SRC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/d2000_aarch64 - INC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/d2000_aarch64 - endif #CONFIG_TARGET_D2000 - - ifdef CONFIG_TARGET_E2000 - SRC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/e2000_aarch64 - INC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/e2000_aarch64 - endif #CONFIG_TARGET_E2000 + SRC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/ft_platform/aarch64 + INC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/ft_platform/aarch64 endif #CONFIG_TARGET_ARMV8_AARCH64 ifdef CONFIG_TARGET_ARMV8_AARCH32 - ifdef CONFIG_TARGET_F2000_4 - SRC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/ft2004_aarch32 - INC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/ft2004_aarch32 - endif - - ifdef CONFIG_TARGET_D2000 - SRC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/d2000_aarch32 - INC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/d2000_aarch32 - endif - + SRC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/ft_platform/aarch32 + INC_DIR += $(THIRD_PARTY_CUR_DIR)/freertos/portable/GCC/ft_platform/aarch32 endif #CONFIG_TARGET_ARMV8_AARCH32