diff --git a/Ubiquitous/XiUOS/arch/arm/cortex-m3/Makefile b/Ubiquitous/XiUOS/arch/arm/cortex-m3/Makefile index 652c93de1..1bf35853d 100644 --- a/Ubiquitous/XiUOS/arch/arm/cortex-m3/Makefile +++ b/Ubiquitous/XiUOS/arch/arm/cortex-m3/Makefile @@ -1,11 +1,11 @@ ifeq ($(CONFIG_BOARD_CORTEX_M3_EVB),y) -SRC_FILES := boot.c +SRC_FILES := boot.c interrupt_vector_evb.S endif ifeq ($(CONFIG_BOARD_STM32F103_NANO),y) -SRC_FILES := boot.S +SRC_FILES := boot.S interrupt_vector_nano.S endif -SRC_FILES += interrupt.c interrupt_vector.S +SRC_FILES += interrupt.c include $(KERNEL_ROOT)/compiler.mk diff --git a/Ubiquitous/XiUOS/arch/arm/cortex-m3/arch_interrupt.h b/Ubiquitous/XiUOS/arch/arm/cortex-m3/arch_interrupt.h index 8ec49ae75..068ec7ff7 100644 --- a/Ubiquitous/XiUOS/arch/arm/cortex-m3/arch_interrupt.h +++ b/Ubiquitous/XiUOS/arch/arm/cortex-m3/arch_interrupt.h @@ -15,12 +15,20 @@ #include +#ifdef BOARD_CORTEX_M3_EVB #define ARCH_MAX_IRQ_NUM (256) +#endif + +#ifdef BOARD_STM32F103_NANO +#define ARCH_MAX_IRQ_NUM (64) +#endif #define ARCH_IRQ_NUM_OFFSET 0 +#ifdef BOARD_CORTEX_M3_EVB #define SYSTICK_IRQN 15 #define UART1_IRQn 21 +#endif int32 ArchEnableHwIrq(uint32 irq_num); int32 ArchDisableHwIrq(uint32 irq_num); diff --git a/Ubiquitous/XiUOS/arch/arm/cortex-m3/interrupt_vector.S b/Ubiquitous/XiUOS/arch/arm/cortex-m3/interrupt_vector_evb.S similarity index 98% rename from Ubiquitous/XiUOS/arch/arm/cortex-m3/interrupt_vector.S rename to Ubiquitous/XiUOS/arch/arm/cortex-m3/interrupt_vector_evb.S index c4a304ba1..b21fd6e3d 100644 --- a/Ubiquitous/XiUOS/arch/arm/cortex-m3/interrupt_vector.S +++ b/Ubiquitous/XiUOS/arch/arm/cortex-m3/interrupt_vector_evb.S @@ -38,7 +38,7 @@ //***************************************************************************** /** -* @file interrupt_vector.S +* @file interrupt_vector_evb.S * @brief derived from Stellaris Firmware Development Package * @version 1.0 * @author AIIT XUOS Lab @@ -46,7 +46,7 @@ */ /************************************************* -File name: interrupt_vector.S +File name: interrupt_vector_evb.S Description: vector table for a Cortex M3 Others: History: @@ -87,7 +87,7 @@ InterruptVectors: .word IsrEntry //DebugMon_Handler .word IsrEntry .word PendSV_Handler - .word IsrEntry //systick + .word SysTick_Handler //systick .word IsrEntry // GPIO Port A .word IsrEntry // GPIO Port B .word IsrEntry // GPIO Port C diff --git a/Ubiquitous/XiUOS/arch/arm/cortex-m3/interrupt_vector_nano.S b/Ubiquitous/XiUOS/arch/arm/cortex-m3/interrupt_vector_nano.S new file mode 100644 index 000000000..b8ea59f18 --- /dev/null +++ b/Ubiquitous/XiUOS/arch/arm/cortex-m3/interrupt_vector_nano.S @@ -0,0 +1,130 @@ +/** + *************** (C) COPYRIGHT 2017 STMicroelectronics ************************ + * @file startup_stm32f103xb.s + * @author MCD Application Team + * @brief STM32F103xB Devices vector table for Atollic toolchain. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Configure the clock system + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M3 processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/** +* @file interrupt_vector_nano.S +* @brief derived from Stellaris Firmware Development Package +* @version 1.1 +* @author AIIT XUOS Lab +* @date 2021-12-02 +*/ + +/************************************************* +File name: interrupt_vector_nano.S +Description: vector table for a stm32f103xb +Others: +History: +1. Date: 2021-12-02 +Author: AIIT XUOS Lab +Modification: +1. take startup_stm32f103xb.s for XiUOS reference +*************************************************/ + + +//***************************************************************************** +// +// The vector table. Note that the proper constructs must be placed on this to +// ensure that it ends up at physical address 0x0000.0000. +// +//***************************************************************************** +.globl InterruptVectors + +/****************************************************************************** +*******************************************************************************/ + .section .isr_vector,"a",%progbits + .type InterruptVectors, %object + .size InterruptVectors, .-InterruptVectors + +InterruptVectors: + .word _sp + .word Reset_Handler + .word NMI_Handler + .word HardFaultHandler + .word MemFaultHandler + .word BusFault_Handler + .word UsageFault_Handler + .word 0 + .word 0 + .word 0 + .word 0 + .word IsrEntry + .word IsrEntry + .word 0 + .word PendSV_Handler + .word SysTick_Handler + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word UartIsr1 + .word IsrEntry //UartIsr2 + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word IsrEntry + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 diff --git a/Ubiquitous/XiUOS/arch/arm/shared/prepare_ahwstack.c b/Ubiquitous/XiUOS/arch/arm/shared/prepare_ahwstack.c index 6b597821d..57935a830 100644 --- a/Ubiquitous/XiUOS/arch/arm/shared/prepare_ahwstack.c +++ b/Ubiquitous/XiUOS/arch/arm/shared/prepare_ahwstack.c @@ -15,7 +15,9 @@ #include #include "svc_handle.h" #include +#ifdef TOOL_SHELL #include +#endif #if (defined ( __GNUC__ ) && defined ( __VFP_FP__ ) && !defined(__SOFTFP__)) #define USE_FPU 1 diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/.defconfig b/Ubiquitous/XiUOS/board/stm32f103-nano/.defconfig index d61e0b1ee..cfc19af53 100644 --- a/Ubiquitous/XiUOS/board/stm32f103-nano/.defconfig +++ b/Ubiquitous/XiUOS/board/stm32f103-nano/.defconfig @@ -129,20 +129,20 @@ CONFIG_SHELL_HELP_SHOW_PERMISSION=y # CONFIG_SHELL_HELP_LIST_USER is not set # CONFIG_SHELL_HELP_LIST_VAR is not set # CONFIG_SHELL_HELP_LIST_KEY is not set -CONFIG_KERNEL_QUEUEMANAGE=y -CONFIG_KERNEL_WORKQUEUE=y -CONFIG_WORKQUEUE_KTASK_STACKSIZE=512 -CONFIG_WORKQUEUE_KTASK_PRIORITY=23 -CONFIG_KERNEL_WAITQUEUE=y -CONFIG_KERNEL_DATAQUEUE=y +# CONFIG_KERNEL_QUEUEMANAGE is not set +# CONFIG_KERNEL_WORKQUEUE is not set +# CONFIG_WORKQUEUE_KTASK_STACKSIZE is not set +# CONFIG_WORKQUEUE_KTASK_PRIORITY is not set +# CONFIG_KERNEL_WAITQUEUE is not set +# CONFIG_KERNEL_DATAQUEUE is not set # CONFIG_KERNEL_CIRCULAR_AREA is not set # CONFIG_KERNEL_AVL_TREE is not set CONFIG_NAME_MAX=8 CONFIG_ALIGN_SIZE=4 CONFIG_KERNEL_COMPONENTS_INIT=y CONFIG_KERNEL_USER_MAIN=y -CONFIG_MAIN_KTASK_STACK_SIZE=2048 -CONFIG_ENV_INIT_KTASK_STACK_SIZE=8192 +CONFIG_MAIN_KTASK_STACK_SIZE=256 +CONFIG_ENV_INIT_KTASK_STACK_SIZE=1024 CONFIG_MAIN_KTASK_PRIORITY=10 # CONFIG_USER_TEST is not set # CONFIG_TOOL_TEST_SEM is not set diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/README.md b/Ubiquitous/XiUOS/board/stm32f103-nano/README.md index 4fad6c7d2..c85749cc3 100644 --- a/Ubiquitous/XiUOS/board/stm32f103-nano/README.md +++ b/Ubiquitous/XiUOS/board/stm32f103-nano/README.md @@ -122,29 +122,63 @@ XiUOS板级驱动当前支持使用GPIO、UART。 ### 编译工具链:`arm-none-eabi-gcc` 使用`VScode`打开工程的方法有多种,本文介绍一种快捷键,在项目目录下将`code .`输入linux系统命令终端即可打开目标项目 -修改`applications`文件夹下`main.c` -在输出函数中写入 `Hello, world!!! \n Running on stm32f103-nano`完成代码编辑。 +修改`APP_Framework/Applications`文件夹下`main.c` +在输出函数中写入 `Hello, world!`完成代码编辑。 ![main](img/main.png) 编译步骤: -1.在VScode命令终端中执行以下命令,生成配置文件 +1.在VScode命令终端中执行以下命令,生成配置文件。 ```c make BOARD=stm32f103-nano distclean make BOARD=stm32f103-nano menuconfig ``` -2.在menuconfig界面配置需要关闭和开启的功能,按回车键进入下级菜单,按Y键选中需要开启的功能,按N键选中需要关闭的功能,配置结束后保存并退出(本例旨在演示简单的输出例程,所以没有需要配置的选项,双击快捷键ESC退出配置) +2.在menuconfig界面配置需要关闭和开启的功能,按回车键进入下级菜单,按Y键选中需要开启的功能,按N键选中需要关闭的功能,配置结束后保存并退出(本例旨在演示简单的输出例程,所以没有需要配置的选项,双击快捷键ESC退出配置)。 ![menuconfig1](img/menuconfig1.png) 退出时选择`yes`保存上面所配置的内容,如下图所示: -![menuconfig2](img/menuconfig2.jpg) +![menuconfig2](img/menuconfig2.png) -3.继续执行以下命令,进行编译 +3.需要注意的是,stm32f103-nano开发板中CPU RAM大小为20KB,需要调整XiUOS中堆栈相关配置的默认值,避免出现超出堆栈大小而无法正常启动。 + +(1)ID hash table配置,ID num配置为16,减少.bss段大小; + +![ID_HASH_TABLE](img/ID_HASH_TABLE.png) + +(2)IPC feature配置,保留信号量、互斥锁等必需的进程间通信,关闭队列等未用到的方式; + +![IPC_FEATURE](img/IPC_FEATURE.png) + +(3)ENV task配置,该线程栈大小配置为1024; + +![KTASK_SIZE](img/KTASK_SIZE.png) + +(4)MAIN task配置,该线程栈大小配置为256; + +![MAIN_STACK_SIZE](img/MAIN_STACK_SIZE.png) + +(5)大内存分配页对齐配置,页对齐配置为1KB,减少页对齐后优化的ram空间,增加可分配的堆大小; + +![MEMORY_PAGE_SIZE](img/MEMORY_PAGE_SIZE.png) + +(6)SHELL task配置,该线程栈大小配置为4096,建议无优化空间时再选择减少SHELL线程栈大小,避免出现SHELL工作异常的情况; + +![SHELL_STACK_SIZE](img/SHELL_STACK_SIZE.png) + +(7)WORKQUEUE配置,若未用到工作队列,可关闭该功能,减少堆栈空间申请; + +![WORKQUEUE](img/WORKQUEUE.png) + +(7)ZOMBIE RECYCLE task配置 ,僵尸线程回收线程栈大小同样在无优化空间时可选择减少。 + +![ZOMBIE_STACK_SIZE](img/ZOMBIE_STACK_SIZE.png) + +4.继续执行以下命令,进行编译 ```c make BOARD=stm32f103-nano @@ -160,9 +194,7 @@ stm32f103-nano开发板内置板载st-link SWD下载接口,连接USB后便可 ### 烧写工具 -ARM:ST-LINK(ST-LINK V2实物如图,可在购物网站搜索关键字购买) - -![st-link](img/st-link.png) +ARM:ST-LINK, stm32f103-nano 板卡内置st-link SWD, 因此无需额外外接工具,只需安装st-flash相关依赖驱动即可。 下载并以下执行命令以下命令安装st-link工具(本文使用v1.5.1版本)。 @@ -180,29 +212,7 @@ cd build/Release && make install DESTDIR=_install 代码根目录下执行st-flash工具烧录 ``` -sudo st-flash write build/XiUOS_stm32f103-nano.bin 0x8000000 -``` - -此外,推荐用户使用putty作为终端工具,安装命令如下: - -```c -sudo apt install putty -``` - -打开putty配置串口信息 - -```c -sudo puty -``` - -选择ttyUSB0(这个端口号根据具体情况而定),配置波特率为115200。 - -![putty](img/putty.png) - -注意:选择正确的终端端口号,最后可以执行以下命令,清除配置文件和编译生成的文件 - -```c -make BOARD=stm32f103-nano distclean +sudo st-flash write build/XiUOS_stm32f103-nano.bin 0x8000000 ``` ### 3.1 运行结果 diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/board.c b/Ubiquitous/XiUOS/board/stm32f103-nano/board.c index 7b9263bbd..45883e49f 100644 --- a/Ubiquitous/XiUOS/board/stm32f103-nano/board.c +++ b/Ubiquitous/XiUOS/board/stm32f103-nano/board.c @@ -75,7 +75,7 @@ void SysTick_Handler(int irqn, void *arg) { TickAndTaskTimesliceUpdate(); } -DECLARE_HW_IRQ(SYSTICK_IRQN, SysTick_Handler, NONE); + void InitBoardHardware() { diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/img/ID_HASH_TABLE.png b/Ubiquitous/XiUOS/board/stm32f103-nano/img/ID_HASH_TABLE.png new file mode 100644 index 000000000..4a4bb5bc7 Binary files /dev/null and b/Ubiquitous/XiUOS/board/stm32f103-nano/img/ID_HASH_TABLE.png differ diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/img/IPC_FEATURE.png b/Ubiquitous/XiUOS/board/stm32f103-nano/img/IPC_FEATURE.png new file mode 100644 index 000000000..723afb794 Binary files /dev/null and b/Ubiquitous/XiUOS/board/stm32f103-nano/img/IPC_FEATURE.png differ diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/img/KTASK_SIZE.png b/Ubiquitous/XiUOS/board/stm32f103-nano/img/KTASK_SIZE.png new file mode 100644 index 000000000..2a245e071 Binary files /dev/null and b/Ubiquitous/XiUOS/board/stm32f103-nano/img/KTASK_SIZE.png differ diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/img/MAIN_STACK_SIZE.png b/Ubiquitous/XiUOS/board/stm32f103-nano/img/MAIN_STACK_SIZE.png new file mode 100644 index 000000000..d9a35ba8a Binary files /dev/null and b/Ubiquitous/XiUOS/board/stm32f103-nano/img/MAIN_STACK_SIZE.png differ diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/img/MEMORY_PAGE_SIZE.png b/Ubiquitous/XiUOS/board/stm32f103-nano/img/MEMORY_PAGE_SIZE.png new file mode 100644 index 000000000..e0000ed84 Binary files /dev/null and b/Ubiquitous/XiUOS/board/stm32f103-nano/img/MEMORY_PAGE_SIZE.png differ diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/img/SHELL_STACK_SIZE.png b/Ubiquitous/XiUOS/board/stm32f103-nano/img/SHELL_STACK_SIZE.png new file mode 100644 index 000000000..fe235ef63 Binary files /dev/null and b/Ubiquitous/XiUOS/board/stm32f103-nano/img/SHELL_STACK_SIZE.png differ diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/img/WORKQUEUE.png b/Ubiquitous/XiUOS/board/stm32f103-nano/img/WORKQUEUE.png new file mode 100644 index 000000000..6ed8e3d79 Binary files /dev/null and b/Ubiquitous/XiUOS/board/stm32f103-nano/img/WORKQUEUE.png differ diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/img/ZOMBIE_STACK_SIZE.png b/Ubiquitous/XiUOS/board/stm32f103-nano/img/ZOMBIE_STACK_SIZE.png new file mode 100644 index 000000000..46c9b92b8 Binary files /dev/null and b/Ubiquitous/XiUOS/board/stm32f103-nano/img/ZOMBIE_STACK_SIZE.png differ diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/img/main.png b/Ubiquitous/XiUOS/board/stm32f103-nano/img/main.png new file mode 100644 index 000000000..e2153cdf7 Binary files /dev/null and b/Ubiquitous/XiUOS/board/stm32f103-nano/img/main.png differ diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/img/menuconfig1.png b/Ubiquitous/XiUOS/board/stm32f103-nano/img/menuconfig1.png new file mode 100644 index 000000000..879cfc7da Binary files /dev/null and b/Ubiquitous/XiUOS/board/stm32f103-nano/img/menuconfig1.png differ diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/img/menuconfig2.png b/Ubiquitous/XiUOS/board/stm32f103-nano/img/menuconfig2.png new file mode 100644 index 000000000..42c197993 Binary files /dev/null and b/Ubiquitous/XiUOS/board/stm32f103-nano/img/menuconfig2.png differ diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/img/stm32f103-nano.png b/Ubiquitous/XiUOS/board/stm32f103-nano/img/stm32f103-nano.png new file mode 100644 index 000000000..be280fdf5 Binary files /dev/null and b/Ubiquitous/XiUOS/board/stm32f103-nano/img/stm32f103-nano.png differ diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/img/terminal.png b/Ubiquitous/XiUOS/board/stm32f103-nano/img/terminal.png new file mode 100644 index 000000000..ceda82bfd Binary files /dev/null and b/Ubiquitous/XiUOS/board/stm32f103-nano/img/terminal.png differ diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/link.lds b/Ubiquitous/XiUOS/board/stm32f103-nano/link.lds index cd58ce37b..183b3037f 100644 --- a/Ubiquitous/XiUOS/board/stm32f103-nano/link.lds +++ b/Ubiquitous/XiUOS/board/stm32f103-nano/link.lds @@ -11,7 +11,7 @@ MEMORY OUTPUT_ARCH(arm) ENTRY(Reset_Handler) -_system_stack_size = 0x1000; +_system_stack_size = 0x200; SECTIONS { diff --git a/Ubiquitous/XiUOS/board/stm32f103-nano/third_party_driver/uart/connect_uart.c b/Ubiquitous/XiUOS/board/stm32f103-nano/third_party_driver/uart/connect_uart.c index f9404586a..456a065fd 100644 --- a/Ubiquitous/XiUOS/board/stm32f103-nano/third_party_driver/uart/connect_uart.c +++ b/Ubiquitous/XiUOS/board/stm32f103-nano/third_party_driver/uart/connect_uart.c @@ -105,7 +105,6 @@ void UartIsr1(int vector, void *param) /* get serial bus 1 */ UartHandler(&serial_bus_1, &serial_driver_1); } -DECLARE_HW_IRQ(USART1_IRQn, UartIsr1, NONE); #endif #ifdef BSP_USING_UART2 @@ -114,7 +113,6 @@ void UartIsr2(int vector, void *param) /* get serial bus 2 */ UartHandler(&serial_bus_2, &serial_driver_2); } -DECLARE_HW_IRQ(USART2_IRQn, UartIsr2, NONE); #endif static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInfo *configure_info) diff --git a/Ubiquitous/XiUOS/kernel/thread/softtimer.c b/Ubiquitous/XiUOS/kernel/thread/softtimer.c index 786cb6ba1..f317b16ae 100644 --- a/Ubiquitous/XiUOS/kernel/thread/softtimer.c +++ b/Ubiquitous/XiUOS/kernel/thread/softtimer.c @@ -103,7 +103,7 @@ x_err_t _StartRun(TimerType timer) return EOK; } -// Just stop working, don't free memory +// Just stop working, don't x_free memory x_err_t _QuitRun(TimerType timer) { x_base lock = 0; @@ -246,7 +246,7 @@ static void TimerCBEnter(void *param) struct Timer *t = (struct Timer *)param; t->func_callback(t->param); - free(t->t_work); + x_free(t->t_work); } void timer_work_func(struct Work *work, void *work_data) diff --git a/Ubiquitous/XiUOS/resources/Kconfig b/Ubiquitous/XiUOS/resources/Kconfig index 99e9409af..cb3eccf29 100644 --- a/Ubiquitous/XiUOS/resources/Kconfig +++ b/Ubiquitous/XiUOS/resources/Kconfig @@ -1,7 +1,6 @@ menuconfig RESOURCES_SERIAL bool "Using SERIAL bus drivers" - select KERNEL_WORKQUEUE default y if RESOURCES_SERIAL diff --git a/Ubiquitous/XiUOS/resources/serial/dev_serial.c b/Ubiquitous/XiUOS/resources/serial/dev_serial.c index 46a042dfb..6db0a55b4 100644 --- a/Ubiquitous/XiUOS/resources/serial/dev_serial.c +++ b/Ubiquitous/XiUOS/resources/serial/dev_serial.c @@ -382,18 +382,18 @@ static uint32 SerialDevOpen(void *dev) if (NONE == serial_dev->serial_fifo.serial_rx) { if (SIGN_OPER_INT_RX & serial_dev_param->serial_set_mode) { - serial_dev->serial_fifo.serial_rx = (struct SerialRx *)malloc(sizeof(struct SerialRx)); + serial_dev->serial_fifo.serial_rx = (struct SerialRx *)x_malloc(sizeof(struct SerialRx)); if (NONE == serial_dev->serial_fifo.serial_rx) { - KPrintf("SerialDevOpen malloc serial_rx error\n"); - free(serial_dev->serial_fifo.serial_rx); + KPrintf("SerialDevOpen x_malloc serial_rx error\n"); + x_free(serial_dev->serial_fifo.serial_rx); return ERROR; } - serial_dev->serial_fifo.serial_rx->serial_rx_buffer = (uint8 *)malloc(serial_cfg->data_cfg.serial_buffer_size); + serial_dev->serial_fifo.serial_rx->serial_rx_buffer = (uint8 *)x_malloc(serial_cfg->data_cfg.serial_buffer_size); if (NONE == serial_dev->serial_fifo.serial_rx->serial_rx_buffer) { - KPrintf("SerialDevOpen malloc serial_rx_buffer error\n"); - free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer); - free(serial_dev->serial_fifo.serial_rx); + KPrintf("SerialDevOpen x_malloc serial_rx_buffer error\n"); + x_free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer); + x_free(serial_dev->serial_fifo.serial_rx); return ERROR; } @@ -409,27 +409,27 @@ static uint32 SerialDevOpen(void *dev) #ifdef SERIAL_USING_DMA else if (SIGN_OPER_DMA_RX & serial_dev_param->serial_set_mode) { if (0 == serial_cfg->data_cfg.serial_buffer_size) { - serial_dev->serial_fifo.serial_rx = (struct SerialRx *)malloc(sizeof(struct SerialRx)); + serial_dev->serial_fifo.serial_rx = (struct SerialRx *)x_malloc(sizeof(struct SerialRx)); if (NONE == serial_dev->serial_fifo.serial_rx) { - KPrintf("SerialDevOpen DMA buffer 0 malloc serial_rx error\n"); - free(serial_dev->serial_fifo.serial_rx); + KPrintf("SerialDevOpen DMA buffer 0 x_malloc serial_rx error\n"); + x_free(serial_dev->serial_fifo.serial_rx); return ERROR; } serial_dev->serial_fifo.serial_rx->serial_dma_enable = RET_FALSE; serial_dev_param->serial_work_mode |= SIGN_OPER_DMA_RX; } else { - serial_dev->serial_fifo.serial_rx = (struct SerialRx *)malloc(sizeof(struct SerialRx)); + serial_dev->serial_fifo.serial_rx = (struct SerialRx *)x_malloc(sizeof(struct SerialRx)); if (NONE == serial_dev->serial_fifo.serial_rx) { - KPrintf("SerialDevOpen DMA malloc serial_rx error\n"); - free(serial_dev->serial_fifo.serial_rx); + KPrintf("SerialDevOpen DMA x_malloc serial_rx error\n"); + x_free(serial_dev->serial_fifo.serial_rx); return ERROR; } - serial_dev->serial_fifo.serial_rx->serial_rx_buffer = (uint8 *)malloc(serial_cfg->data_cfg.serial_buffer_size); + serial_dev->serial_fifo.serial_rx->serial_rx_buffer = (uint8 *)x_malloc(serial_cfg->data_cfg.serial_buffer_size); if (NONE == serial_dev->serial_fifo.serial_rx->serial_rx_buffer) { - KPrintf("SerialDevOpen DMA malloc serial_rx_buffer error\n"); - free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer); - free(serial_dev->serial_fifo.serial_rx); + KPrintf("SerialDevOpen DMA x_malloc serial_rx_buffer error\n"); + x_free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer); + x_free(serial_dev->serial_fifo.serial_rx); return ERROR; } @@ -460,10 +460,10 @@ static uint32 SerialDevOpen(void *dev) if (NONE == serial_dev->serial_fifo.serial_tx) { if (SIGN_OPER_INT_TX & serial_dev_param->serial_set_mode) { - serial_dev->serial_fifo.serial_tx = (struct SerialTx *)malloc(sizeof(struct SerialTx)); + serial_dev->serial_fifo.serial_tx = (struct SerialTx *)x_malloc(sizeof(struct SerialTx)); if (NONE == serial_dev->serial_fifo.serial_tx) { - KPrintf("SerialDevOpen malloc serial_tx error\n"); - free(serial_dev->serial_fifo.serial_tx); + KPrintf("SerialDevOpen x_malloc serial_tx error\n"); + x_free(serial_dev->serial_fifo.serial_tx); return ERROR; } @@ -475,10 +475,10 @@ static uint32 SerialDevOpen(void *dev) } #ifdef SERIAL_USING_DMA else if (SIGN_OPER_DMA_TX & serial_dev_param->serial_set_mode) { - serial_dev->serial_fifo.serial_tx = (struct SerialTx *)malloc(sizeof(struct SerialTx)); + serial_dev->serial_fifo.serial_tx = (struct SerialTx *)x_malloc(sizeof(struct SerialTx)); if (NONE == serial_dev->serial_fifo.serial_tx) { - KPrintf("SerialDevOpen DMA malloc serial_tx error\n"); - free(serial_dev->serial_fifo.serial_tx); + KPrintf("SerialDevOpen DMA x_malloc serial_tx error\n"); + x_free(serial_dev->serial_fifo.serial_tx); return ERROR; } @@ -511,13 +511,13 @@ static uint32 SerialDevOpen(void *dev) KPrintf("SerialDevOpen create sem failed .\n"); if (serial_dev->serial_fifo.serial_rx->serial_rx_buffer) { - free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer); + x_free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer); } if (serial_dev->serial_fifo.serial_rx) { - free(serial_dev->serial_fifo.serial_rx); + x_free(serial_dev->serial_fifo.serial_rx); } if (serial_dev->serial_fifo.serial_tx) { - free(serial_dev->serial_fifo.serial_tx); + x_free(serial_dev->serial_fifo.serial_tx); } return ERROR; @@ -540,8 +540,8 @@ static uint32 SerialDevClose(void *dev) if (SIGN_OPER_INT_RX & serial_dev_param->serial_work_mode) { NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_rx->serial_rx_buffer); NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_rx); - free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer); - free(serial_dev->serial_fifo.serial_rx); + x_free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer); + x_free(serial_dev->serial_fifo.serial_rx); serial_drv->drv_done->configure(serial_drv, serial_operation_cmd); } @@ -550,12 +550,12 @@ static uint32 SerialDevClose(void *dev) if(0 == serial_cfg->data_cfg.serial_buffer_size) { NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_rx); - free(serial_dev->serial_fifo.serial_rx); + x_free(serial_dev->serial_fifo.serial_rx); } else { NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_rx->serial_rx_buffer); NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_rx); - free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer); - free(serial_dev->serial_fifo.serial_rx); + x_free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer); + x_free(serial_dev->serial_fifo.serial_rx); } serial_drv->drv_done->configure(serial_drv, serial_operation_cmd); @@ -564,14 +564,14 @@ static uint32 SerialDevClose(void *dev) if (SIGN_OPER_INT_TX & serial_dev_param->serial_work_mode) { NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_tx); - free(serial_dev->serial_fifo.serial_tx); + x_free(serial_dev->serial_fifo.serial_tx); serial_drv->drv_done->configure(serial_drv, serial_operation_cmd); } #ifdef SERIAL_USING_DMA else if (SIGN_OPER_DMA_TX & serial_dev_param->serial_work_mode) { NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_tx); - free(serial_dev->serial_fifo.serial_tx); + x_free(serial_dev->serial_fifo.serial_tx); serial_drv->drv_done->configure(serial_drv, serial_operation_cmd); }