mirror of
https://github.com/RT-Thread/rtthread-nano.git
synced 2025-12-08 03:51:06 +08:00
[synchronous] rt-thread 3.1.3 (date:11.5)
This commit is contained in:
@@ -18,9 +18,6 @@ before_script:
|
||||
- export RTT_ROOT=`pwd`
|
||||
- "[ x$RTT_CC == x ] && export RTT_CC='gcc' || true"
|
||||
|
||||
script:
|
||||
- scons -C bsp/$RTT_BSP
|
||||
|
||||
env:
|
||||
# - RTT_BSP='simulator' RTT_CC='clang-analyze' RTT_EXEC_PATH=/usr/share/clang/scan-build
|
||||
- RTT_BSP='CME_M7' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
@@ -28,35 +25,39 @@ env:
|
||||
- RTT_BSP='asm9260t' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='at91sam9260' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='allwinner_tina' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='imxrt1052-evk' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
# - RTT_BSP='avr32uc3b0' RTT_TOOL_CHAIN='atmel-avr32'
|
||||
# - RTT_BSP='bf533' # no scons
|
||||
- RTT_BSP='efm32' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
# - RTT_BSP='gd32450z-eval' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='efm32' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
# - RTT_BSP='es32f0334' RTT_TOOL_CHAIN='sourcery-arm' # not support gcc
|
||||
# - RTT_BSP='es32f0654' RTT_TOOL_CHAIN='sourcery-arm' # not support gcc
|
||||
- RTT_BSP='gd32303e-eval' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='gd32450z-eval' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='gkipc' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lm3s8962' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lm3s9b9x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lm4f232' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='imxrt/imxrt1050-evk' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lm3s8962' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lm3s9b9x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lm4f232' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='tm4c129x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lpc176x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lpc178x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lpc2148' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lpc2478' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='xplorer4330/M4' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lpc43xx/M4' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lpc176x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lpc178x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lpc408x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
# - RTT_BSP='lpc824' RTT_TOOL_CHAIN='sourcery-arm' # not support gcc
|
||||
- RTT_BSP='lpc2148' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lpc2478' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lpc5410x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='lpc54114-lite' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
# - RTT_BSP='lpc54608-LPCXpresso' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='ls1bdev' RTT_TOOL_CHAIN='sourcery-mips'
|
||||
- RTT_BSP='ls1cdev' RTT_TOOL_CHAIN='sourcery-mips'
|
||||
- RTT_BSP='imx6sx/cortex-a9' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='imx6sx/cortex-a9' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
# - RTT_BSP='m16c62p' # m32c
|
||||
- RTT_BSP='mb9bf500r' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='mb9bf506r' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='mb9bf500r' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='mb9bf506r' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='mb9bf618s' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='mb9bf568r' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
# - RTT_BSP='microblaze' # no scons
|
||||
- RTT_BSP='mini2440' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='mini2440' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
# - RTT_BSP='mini4020' # no scons
|
||||
# - RTT_BSP='nios_ii' # no scons
|
||||
- RTT_BSP='nuvoton_nuc472' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
@@ -66,21 +67,46 @@ env:
|
||||
- RTT_BSP='qemu-vexpress-gemini' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='sam7x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
# - RTT_BSP='simulator' # x86
|
||||
- RTT_BSP='stm32f0x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32l072' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f107' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f10x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f10x-HAL' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f20x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f40x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f4xx-HAL' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f411-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f429-apollo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
# - RTT_BSP='stm32f429-armfly' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f429-disco' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32l475-iot-disco' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32l476-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32h743-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f091-st-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f103-atk-nano' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f103-atk-warshipv3' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f103-dofly-lyc8' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f103-dofly-M3S' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f103-fire-arbitrary' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f103-hw100k-ibox' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f103-mini-system' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f107-uc-eval' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f401-st-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f405-smdz-breadfruit' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f407-atk-explorer' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f407-st-discovery' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f411-st-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f429-armfly-v6' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f429-atk-apollo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f429-fire-challenger' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f446-st-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f469-st-disco' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f746-st-disco' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f767-atk-apollo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f767-fire-challenger' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32f767-st-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32g071-st-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32h743-atk-apollo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32l4r9-st-eval' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32l053-st-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32l432-st-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32l475-atk-pandora' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32l475-st-discovery' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32l476-st-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32/stm32l496-ali-developer' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f4xx-HAL' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f10x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f10x-HAL' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f20x' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f429-apollo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32f429-disco' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='stm32h743-nucleo' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='swm320-lq100' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
# - RTT_BSP='taihu' RTT_TOOL_CHAIN='sourcery-ppc'
|
||||
# - RTT_BSP='upd70f3454' # iar
|
||||
# - RTT_BSP='x86' # x86
|
||||
@@ -89,3 +115,8 @@ env:
|
||||
- RTT_BSP='frdm-k64f' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='fh8620' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
- RTT_BSP='x1000' RTT_TOOL_CHAIN='sourcery-mips'
|
||||
- RTT_BSP='xplorer4330/M4' RTT_TOOL_CHAIN='sourcery-arm'
|
||||
|
||||
stage: compile
|
||||
script:
|
||||
- scons -C bsp/$RTT_BSP
|
||||
|
||||
@@ -1,3 +1,194 @@
|
||||
# RT-Thread v3.1.3 Change Log
|
||||
|
||||
## Kernel
|
||||
|
||||
* Fix the `rt_tick_from_millisecond()` compilation warning issue;
|
||||
* Fix the issue that the system object is not detached when handling defunct threads.
|
||||
* Add the value checking of semaphore (the maximum value of semaphore is up to 65535)
|
||||
* Add the checking and assertion of re-initialization of object.
|
||||
* In the rt_enter_critical/rt_exit_critical function, add the checking of whether scheduler is startup or not.
|
||||
* Fix the definition issue of `ENOTSUP` in libc_errno.h.
|
||||
* Simplify the rtdbg.h file and use ulog to make log/debug system easier to use.
|
||||
* Add the configuration of RT_USING_ARCH_DATA_TYPE, `rt_int8_t/.../rt_uint32_t` and other basic data types can be defined by BSP itself. (It is recommended to put them into the rtconfig_project.h file, so that this file can be automatically included in rtconfig.h when menuconfig generates it.)
|
||||
* Add `RT_Device_Class_Sensor` type devices;
|
||||
* In the case of single core, the definition of `rt_hw_spin_lock/rt_hw_spin_unlock` is redefined as the disable/enable interrupt.
|
||||
* Add the `rt_strnlen()` function in kservice.c.
|
||||
* Support the long long type in rt_kprintf (HubertXie);
|
||||
|
||||
## Components
|
||||
|
||||
* Remove CMSIS and move to software package as CMSIS package.
|
||||
* Remove logtrace component. The system log system switches to ulog;
|
||||
* Add more code to support AC6 tool chain in some BSP and components;
|
||||
* In DFS file system component, clean up the log and fix the mkfs issue when index may be out of range.
|
||||
* Split the running mode from sleep mode in power management, and the frequency change should be clearer. Power management is not use idle hook but execute the sleep action in idle thread directly. (How to use power management, please visit programming document for details)
|
||||
* Cleanup the log of MMC/SD driver framework;
|
||||
* Rewrite Sensor Framework, replace the original C++ implementation with C version, and add some corresponding sensor software packages; To use the sensor packages, please use this release;
|
||||
* Add the DMA transmission operation in the serial driver framework;
|
||||
* Add the consistency protection to tc_flush routine of serial driver (loogg).
|
||||
* Add rt_sfud_flash_find_by_dev_name API in SFUD.
|
||||
* When the Pipe device closed, if it is an unnamed Pipe device and the open count is 0, this Pipe device will be deleted.
|
||||
* The delayed work implementation is added to workqueue, and the workqueue of the system is added as an option.
|
||||
* Fix the data loss issue when using DMA transmission in USB CDC.
|
||||
* Change the return type of finsh_getchar to int;
|
||||
* Fix the errno issue in newlib/GCC tool chain.
|
||||
* Change the management of pthreads to POSIX thread array instead of mapping pthread_t directly to rt_thread_t; Change the fields definition more similar with newlib/glibc in pthreads.
|
||||
* Fix the thread name output in ulog.
|
||||
* Add loop parameter in utest, then executes test cases repeatedly; Add thread parameter in utest to execute testcase in a new thread.
|
||||
* Add delay in handshake phase to protect incomplete data reception in YModem component.
|
||||
* Add netdev component, abstract netdev concept, used to management and control network interface device, and provide netdev operation commands, including ping/ifconfig/dns/netstat etc;
|
||||
* Modify SAL for netdev, that is, adds the judgment of netdev status and information when the socket creating and data transmitting;
|
||||
* Add options and types for UDP multicast traffic handling and IPPROTO_IP in SAL;
|
||||
* Fix `itctrol()` function not support to control socketfd issues in SAL;
|
||||
* Improve error log processing in AT socket;
|
||||
* Fix serial receive data failed issues when AT client initialization is not completed;
|
||||
|
||||
## BSP
|
||||
|
||||
* Add IMXRT1021-EVK BSP (NXP provides maintenance and support);
|
||||
* Add the ETH hardware checksum option in IMXRT1052 ETH driver;
|
||||
* Cleanup the LPC 4088 BSP to use main function entry and support menuconfig;
|
||||
* The double Frame Buffer mechanism and touch screen driver are added in Godson 1C BSP, then it can better to support Persimmon UI (sundm75).
|
||||
* Add watchdog driver in Godson 1C BSP(sundm75);
|
||||
* Fix the SysTick interrupt handling issue in nRF52832 and add menuconfig configuration file.
|
||||
* Add QSPI and SPI flash driver to Nuvoton M487 BSP (bluebear 233)
|
||||
* Change the CPU porting to libcpu/arm/cortex-a folder in QEMU-VExpress A9/IMX6UL BSP;
|
||||
* In QEMU-VExpress A9 BSP, the MAC address associated with the local MAC address is used for a unified MAC address in the network.
|
||||
* remove stm32f0x, stm32f7-disco, stm32f107, stm32f40x, stm32l072, stm32l475-iot-disco, stm32l476-nucleo BSP (when the new STM32 BSP can completely replace these old BSP, these BSP will be removed);
|
||||
* For the new STM32 BSP:
|
||||
* Add CAN driver (ylz0923)
|
||||
* Add CAN driver to stm32f103-fire-arbitrary (ylz0923)
|
||||
* stm32f746-st-disco with LCD, watchdog, SDCard, ethernet, Flash and other drivers (Jinsheng)
|
||||
* More board support is added to the new STM32 BSP:
|
||||
* stm32f103-atk-warship V3 ATK Warship V3 (daizhiwang)
|
||||
* STm32f103-dofly-M3S Dofly STM32F103 Development Board
|
||||
* stm32f103-mini-system, the minimum system board for STM32F103 (daizhiwang)
|
||||
* stm32f401-st-nucleo
|
||||
* stm32f405-smdz-breadfruit sanmu electronic stm32405 development board (sunlichao)
|
||||
* stm32f469-st-disco
|
||||
* stm32h743-atk-apollo (whj4674672)
|
||||
* stm32l4r9-st-eval
|
||||
* stm32l053-st-nucleo (sun_shine)
|
||||
* stm32l475-st-discovery
|
||||
* stm32l476-st-nucleo (Vincent-VG)
|
||||
* stm32l496-ali-developer
|
||||
* The SCI driver is added to the TMS320F28379D BSP (xuzuoyi).
|
||||
* Add W60X Wi-Fi SoC chip BSP from Winner Microelectronics Co.,Ltd. (Winner Micro and RealThread provide maintenance and support);
|
||||
* Fix the UART2 IO configuration issue in X1000 UART driver (Zhou Yanjie);
|
||||
* Cleanup the libcpu/arm/cortex-a code;
|
||||
* The _rt_hw_context_switch_interrupt/_rt_hw_context_switch is separated in TI DSP TMS320F28379D BSP (xuzuoyi);
|
||||
|
||||
## Tool
|
||||
|
||||
* Add Makefile generation feature in scons with command `scons –target=makefile -s`. Then developer can use make to build RT-Thread under Linux or Windows.
|
||||
* Add Eclipse project generation feature in scons with command `scons –target=eclipse -s`, which will put the necessary information in `.cproject` and `.project` files in current BSP folder. The developer can use Eclipse to build RT-Thread.
|
||||
* Fix the multi-group same name issue when generating Keil MDK project file and add a library file into the SConscript (Eric Qiang);
|
||||
* Fix the GCC Version Comparing issue
|
||||
* ENV version updated to v1.1.2
|
||||
* Update scons version to 3.0.5
|
||||
* Fix VC++ warning issue
|
||||
* Fix Unicode error issue
|
||||
|
||||
# RT-Thread v3.1.2 Change Log
|
||||
|
||||
## Kernel
|
||||
|
||||
* nothing
|
||||
|
||||
## Components
|
||||
|
||||
* When formatting the file system, adds FM_SFD option to create a volume in SFD format for FatFs; (HubretXie)
|
||||
* Add file system handle pointer in `struct dfs_fd' structure;
|
||||
* Fix stdio fd issue when POSIX api is used; (gbcwbz)
|
||||
* Fix the `fd_is_open()` issue: when the sub-path is the same in different mounted filesystem.
|
||||
* Change the critical lock/unlock to dfs_lock/unlock in `getcwd()` function of DFS (the critical lock/unlock is different in SMP environment);
|
||||
* Fix the `aio_result` issue, which is returned by `aio_read_work` in AIO; (fullhan)
|
||||
* Fix the mmap issue when the addr parameter is NULL; (fullhan)
|
||||
* Modify the `_sys_istty` function in armlibc to correctly handle STDIN/STDOUT/STDERR; (gbcwbz)
|
||||
* Modify the `_write_r` function in newlib to correctly handle stdout.
|
||||
* Fix the at_socket issue when socket is a null pointer; (thomas onegd)
|
||||
* Fix the select event issue in `at_recvfrom()` function in at_socket;
|
||||
* Divide SAL into `sal_socket_ops/sal_proto_ops` and sal_proto_ops is implemented with gethostbyname/getaddrinfo ops etc.
|
||||
* Add socket TLS layer in SAL, that is, upper application can be supported by encrypted transmission without considering lowlevel TLS at all.
|
||||
* Fix the length issue of `ulog_strcpy`, which should be not exceed `ULOG_LINE_BUF_SIZE`;
|
||||
* Add the macro definition of hexadecimal log output to ulog; (HubretXie)
|
||||
* Add uTest component. The uTest is a unit test framework on RT-Thread, and can also be used for automatic testing on board with external Python scripts.
|
||||
* Fix some compilation warnings and enumeration mismatches in drivers/audio;
|
||||
* Fix the `can_rx/can_tx` issue, which is not cleared to NULL when CAN device is closed in drivers/can; (xeonxu)
|
||||
* Fix drivers/hwtimer, time acquisition issue with counting down mode;
|
||||
* Add drivers/adc driver framework;
|
||||
* Fix the tick compensation issue when enable interrupt too early; (geniusgogo)
|
||||
* Add `RT_SERIAL_USING_DMA` option in drivers/serial;
|
||||
* Add QSPI support in drivers/spi framework;
|
||||
* Add QSPI support in SFUD (based on the QSPI peripheral of stm32); SFUD is upgraded to version 1.1.0;
|
||||
* Optimize SPI take/release function call in spi_msd;
|
||||
* Fix the `blk_size` issue in `rt_rbb_blk_alloc()`;
|
||||
* Fix the FS USB issue in `_get_descriptor` function;
|
||||
* Fix the empty password issue in AP mode of drivers/wlan;
|
||||
* Fix the return type issue in drivers/wlan;
|
||||
* Remove the duplicate opening file check when open a file;
|
||||
|
||||
# BSP
|
||||
|
||||
* Change the name parameter to `cosnt char *` in `rt_hw_interrupt_install` function; (liruncong)
|
||||
* Fix `$` warning issue in Kconfig files of each BSP;
|
||||
* Add the LPC54114-lite BSP, including GPIO, I2C, SDCard, SPI, SPI Flash, UART driver;
|
||||
* Add Nuvoton-M487 BSP, including UART, EMAC driver; (Bluebear 233)
|
||||
* Fix the CAN driver issue in STM32F4XX-HAL BSP; (xeonxu)
|
||||
* Fix UART DMA settings issue in STM32F10x/STM32F40x BSP; (zhouchuanfu)
|
||||
* Fix the HEAP_BEGIN definition issue in STM32H743-Nucleo BSP; (nongxiaoming)
|
||||
* Fix GPIO configuration issue in stm32f10x-HAL; (Wu Han)
|
||||
* Change stm32f107 BSP as main function entry; (whj4674672)
|
||||
* Fix the serial interrupt handling issue in stm32f10x BSP;
|
||||
* Add PWM, RTC and watchdog drivers to stm32f10x-HAL BSP; (XXXXzzzz000)
|
||||
* Fix the watchdog driver issue in stm32f4xx-HAL BSP; (XXXXzzzz000)
|
||||
* Use lwIP version 2.x in stm32f40x/stm32f107 BSP.
|
||||
* Fix the link issue when enable CmBacktrace package in stm32f4xx-HAL BSP; (xeonxu)
|
||||
* Support Audio and microphones features in stm32f429-apollo BSP;
|
||||
* Enable dlmodule support in x86 BSP; (SASANO Takayoshi)
|
||||
* Addd uTest section in the link script of qemu-vexpress-a9/stm32f429-atk-apollo BSP for automatic testing;
|
||||
* Change the license to Apache License v2.0 in Godson 1C BSP; (sundm75)
|
||||
* Add the new BSP framework for STM32 serial chip, such as STM32 G0/F0/L0/F1/F4/F7/H7. In new BSP framework, the SoC drivers is reused. And in same time, lots of STM32 boards are supportted with new BSP framework:
|
||||
* STM32F091-Nucleo Development Board BSP
|
||||
* STM32F411-Nucleo Development Board BSP
|
||||
* STM32L432-Nucleo Development Board BSP; (sun_shine)
|
||||
* STM32F407-Discovery Development Board BSP
|
||||
* STM32F446-Nucleo Development Board BSP; (andeyqi)
|
||||
* STM32F746-Discovery Development Board BSP; (jinsheng)
|
||||
* STM32F767-Nucleo Development Board BSP; (e31207077)
|
||||
* STM32G071-Nucleo Development Board BSP;
|
||||
* ATK STM32F103 NANO Development Board BSP
|
||||
* ATK STM32F407 Explorer Development Board BSP
|
||||
* ATK STM32F429 Apollo Development Board BSP
|
||||
* ATK STM32F767 Apollo Development Board BSP
|
||||
* ATK STM32L475 Pandora IoT Development Board BSP
|
||||
* Fire STM32F103 Arbitrary Development Board BSP
|
||||
* Fire STM32F429 Challenger Development Board BSP
|
||||
* Fire STM32F767 Challenger Development Board BSP; (Hao Zhu)
|
||||
* ArmFly STM32F429-v6 Development Board BSP
|
||||
* STM32F103 iBox development board BSP; (dingo1688)
|
||||
* Dofly STM32F103 Development Board; (FindYGL)
|
||||
* STM32F107 uC/Eval Development Board BSP; (whj4674672)
|
||||
* and more, there are more developers involved for stm32 BSP framework, they are HubretXie, Hao Zhu, e190, etc. to improve the STM32 public driver.
|
||||
* Add SWM320 BSP of Synwit.cn, including GPIO, HW Timer, I2C, Watchdog, PWM, RTC, SPI, UART, etc.; (provided and maintained by Synwit)
|
||||
* Add TI TMS320F28379D BSP, the first DSP chip supported on RT-Thread; (xuzhuoyi)
|
||||
* Fix USB driver issue in X1000; (Zhou YanJie)
|
||||
|
||||
# Tool
|
||||
|
||||
* Provide more inforamtion when the tool chain does not exist;
|
||||
* Add a draft Segger Embedded Studio project file generation command. Note that the tool chain in SES is a special version not the newlib.
|
||||
* Fix the IAR library link command issue when use scons command line under;
|
||||
* Fix the BSP path issue in scons `str(Dir('#'))`;
|
||||
* Add `scons --pyconfig-silent` command to add some Kconfig configurations and to generate `.config` and `rtconfig.h` files;
|
||||
* Update the `scons --dist` command to adapt to the new BSP framework;
|
||||
* Modify the mkromfs.py script. Fix the corresponding C code generation When the romfs contains empty files or empty folders;
|
||||
* Fix the issue of version string comparison issue for GNU GCC version in utils.py;
|
||||
* ENV updated to V1.1.0
|
||||
* Provide better prompt information to improve user experience;
|
||||
* Add `system32` path to environment variables to avoid the `cmd` command cannot be found;
|
||||
* Add `PYTHONHOME` variable to environment variables to avoid PYTHON environment issue;
|
||||
|
||||
# RT-Thread v3.1.1 Change Log
|
||||
|
||||
## Kernel
|
||||
@@ -462,7 +653,7 @@ RT-Thread v2.0.1是2.0这个系列的bug修正版,而v2.1.0 alpha则是当前
|
||||
* 修正USB host代码的编译错误;
|
||||
* 修正sensor框架回调函数的问题;
|
||||
* 修正pin设备注册时的设备名称问题;
|
||||
|
||||
|
||||
而v2.1.0 alpha这个技术预览版则沿着最初设定的roadmap技术路线进行,这其中主要包括:
|
||||
|
||||
* lwip更深度的集成:把它集成到RT-Thread的文件系统接口中,这样Linux/Unix下的一些socket网络应用能够更顺利的移植到RT-Thread上,也为以后可以应用到更多地方的select接口铺路。
|
||||
@@ -475,7 +666,7 @@ RT-Thread v2.0.1是2.0这个系列的bug修正版,而v2.1.0 alpha则是当前
|
||||
以下是自v2.0.0 RC版本以来的详细更改记录。后续我还会给出v2.0.0版本自v1.2.x版本的主要不同、看点,以及给出下一个版本的roadmap规划。
|
||||
|
||||
## 内核
|
||||
|
||||
|
||||
* console以RT_DEVICE_FLAG_STREAM参数打开字符设备;
|
||||
* 在rt_memheap_free中加入更多的断言检查;
|
||||
|
||||
@@ -495,7 +686,7 @@ RT-Thread v2.0.1是2.0这个系列的bug修正版,而v2.1.0 alpha则是当前
|
||||
* 添加VBUS组件用于Linux与RT-Thread系统之间,RT-Thread与RT-Thread系统之间通信(睿赛德服务公司捐赠);
|
||||
* 增加lwIP/NAT组件,可以做多个网口间的地址转换(Hicard);
|
||||
* 增加lwIP/DHCP服务端,用于向客户端分配IP地址(睿赛德服务公司提供);
|
||||
|
||||
|
||||
## BSP
|
||||
|
||||
* 修正LPC4357串口驱动初始化时过早打开中断的问题(nongxiaoming);
|
||||
@@ -606,7 +797,7 @@ v2.0.0版本的开发相对活跃些,开源社区提供了强有力的支持
|
||||
* 启动timer前,对timer进行强制移除;
|
||||
* 在执行soft timer超时函数时,打开调度器锁;
|
||||
* 新增块设备的自动刷新参数,RT_DEVICE_CTRL_BLK_AUTOREFRESH;
|
||||
|
||||
|
||||
## 工具
|
||||
|
||||
* 修正scons命令编译时,选择keil mdk (armcc)编译器时,命令行太长编译失败的问题;
|
||||
@@ -659,7 +850,7 @@ v2.0.0版本的开发相对活跃些,开源社区提供了强有力的支持
|
||||
# RT-Thread 2.0.0 Alpha更改说明
|
||||
|
||||
发布时间:2014/4/8
|
||||
|
||||
|
||||
RT-Thread 2.0.0分支的第一个技术预览版本,仅用于展示2.0.0发展分支的演化动向(按照roadmap,2.0.0这个分支会有一部分RT-Thread和Linux互补性的技术,为Linux增加更好的实时性,为RT-Thread增加更多的功能性,这份技术预览版正是朝着这个目标而努力),欢迎反馈建议和问题。
|
||||
|
||||
## 组件
|
||||
@@ -695,7 +886,7 @@ insmod rtvmm.ko
|
||||
# RT-Thread 1.2.1更改说明
|
||||
|
||||
发布时间: 2014/4/8
|
||||
|
||||
|
||||
在原有的1.2.0版本的bug修正版本,也是1.2.0系列的第一个修正版本,原则上不添加任何的新功能,我们尽量会按照每个季度一个修订版本的方式推进。大家在使用的过程中有什么问题还请反馈给我们,这些问题很可能会在下个版本中修正!
|
||||
|
||||
以下是更改记录:
|
||||
@@ -741,7 +932,7 @@ insmod rtvmm.ko
|
||||
发布时间: 2014/1/6
|
||||
|
||||
实现roadmap中提到的大部分内容
|
||||
|
||||
|
||||
1,文档方面已完成《RT-Thread编程手册》,同时还有论坛上jiezhi童鞋的《一起来学RT-Thread系列连载教程》
|
||||
2,BSP分支方面新增cortext-A8(beaglebone),cortext-R4(rm48x50),UNITY-2(SEP6200),lpc408x的移植
|
||||
3,组件方面:
|
||||
@@ -828,7 +1019,7 @@ insmod rtvmm.ko
|
||||
# RT-Thread 1.2.0RC更改说明
|
||||
|
||||
发布时间: 2013/10/10/ 10:19
|
||||
|
||||
|
||||
主要说明: 该版本新增ARM Cortex-A8的支持(BeagleBone),新增UNITY-2内核的支持(SEP6200),新增Ymodem协议。
|
||||
|
||||
变更履历
|
||||
@@ -923,7 +1114,7 @@ insmod rtvmm.ko
|
||||
版本: RT-Thread 1.2.0 Beta 版本
|
||||
|
||||
发布时间: 2013/6/30
|
||||
|
||||
|
||||
进过开发人员三个月的努力,RT-Thread 1.2.0 Beta 版本如期发布。
|
||||
该版本默认采用lwIP 1.4.1协议栈,USB device stack也进一步完善。加入 log_trace 子系统,加入组件初始化升级版本,加入 ARM Cortex-R 的移植。
|
||||
|
||||
@@ -970,7 +1161,7 @@ insmod rtvmm.ko
|
||||
版本: RT-Thread 1.2.0 Alpha版本
|
||||
|
||||
发布时间: 2013/4/10
|
||||
|
||||
|
||||
遵循2013年RT-Thread roadmap,RT-Thread 1.2.0 Alpha版本发布,Alpha意味着此版本为技术预览版,仅用于展示RT-Thread 1.2.0未来的发展方向,并不适合于开发正式产品。RT-Thread 1.2.0版本是1.1.x系列的下一个分支,这个分支主要体现的是RT-Thread 1.x系列的文档情况。当然也有一些功能、代码方面的增强。
|
||||
|
||||
伴随着新版本的到来,RT-Thread有几个重大的转变:
|
||||
|
||||
@@ -17,13 +17,13 @@ RT-Thread RTOS like a traditional real-time operating system. The kernel has rea
|
||||
|
||||
* Device Driver;
|
||||
* Component;
|
||||
* Dyanmic Module
|
||||
* Dynamic Module
|
||||
|
||||
The device driver is more like a driver framework, UART, IIC, SPI, SDIO, USB device/host, EMAC, MTD NAND etc. The developer can easily add low level driver and board configuration, then combined with the upper framework, he/she can use lots of features.
|
||||
|
||||
The Component is a software concept upon RT-Thread kernel, for example a shell (finsh/msh shell), virtual file system (FAT, YAFFS, UFFS, ROM/RAM file system etc), TCP/IP protocol stack (lwIP), POSIX (thread) interface etc. One component must be a directory under RT-Thread/Components and one component can be descripted by a SConscript file (then be compiled and linked into the system).
|
||||
|
||||
The Dyanmic Module, formerly named as User Applicaion (UA) is a dyanmic loaded module or library, it can be compiled standalone without Kernel. Each Dyanmic Module has its own object list to manage thread/semaphore/kernel object which was created or initialized inside this UA. More information about UA, please visit another [git repo](https://github.com/RT-Thread/rtthread-apps).
|
||||
The Dynamic Module, formerly named as User Applicaion (UA) is a dynamic loaded module or library, it can be compiled standalone without Kernel. Each Dynamic Module has its own object list to manage thread/semaphore/kernel object which was created or initialized inside this UA. More information about UA, please visit another [git repo](https://github.com/RT-Thread/rtthread-apps).
|
||||
|
||||
## Board Support Package ##
|
||||
|
||||
@@ -53,10 +53,6 @@ RT-Thread is Open Source software under the Apache License 2.0 since RT-Thread v
|
||||
|
||||
Since 9th of September 2018, PRs submitted by the community may be merged into the main line only after signing the Contributor License Agreement(CLA).
|
||||
|
||||
NOTE:
|
||||
|
||||
RT-Thread using the Apache license v2.0 is only launched after the release of v3.1.1, and is still in preparation right now.
|
||||
|
||||
## Usage ##
|
||||
|
||||
RT-Thread RTOS uses [scons](http://www.scons.org) as building system. Therefore, please install scons and Python 2.7 firstly.
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* File : libc_errno.h
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
@@ -18,144 +14,193 @@
|
||||
#include <rtconfig.h>
|
||||
|
||||
#if defined(RT_USING_NEWLIB) || defined(_WIN32)
|
||||
/* use errno.h file in newlib */
|
||||
/* use errno.h file in toolchains */
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#if defined(__CC_ARM)
|
||||
/*
|
||||
defined in armcc/errno.h
|
||||
|
||||
#define EDOM 1
|
||||
#define ERANGE 2
|
||||
#define EILSEQ 4
|
||||
#define ESIGNUM 3
|
||||
#define EINVAL 5
|
||||
#define ENOMEM 6
|
||||
*/
|
||||
#define ERROR_BASE_NO 7
|
||||
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
/* defined in iar/errno.h
|
||||
#define EDOM 33
|
||||
#define ERANGE 34
|
||||
#define EFPOS 35
|
||||
#define EILSEQ 36
|
||||
*/
|
||||
#define ERROR_BASE_NO 36
|
||||
|
||||
#else
|
||||
/* define errno self. */
|
||||
#define EPERM 1
|
||||
#define ENOENT 2
|
||||
#define ESRCH 3
|
||||
#define EINTR 4
|
||||
#define EIO 5
|
||||
#define ENXIO 6
|
||||
#define E2BIG 7
|
||||
#define ENOEXEC 8
|
||||
#define EBADF 9
|
||||
#define ECHILD 10
|
||||
#define EAGAIN 11
|
||||
#define ENOMEM 12
|
||||
#define EACCES 13
|
||||
#define EFAULT 14
|
||||
#define ENOTBLK 15
|
||||
#define EBUSY 16
|
||||
#define EEXIST 17
|
||||
#define EXDEV 18
|
||||
#define ENODEV 19
|
||||
#define ENOTDIR 20
|
||||
#define EISDIR 21
|
||||
#define EINVAL 22
|
||||
#define ENFILE 23
|
||||
#define EMFILE 24
|
||||
#define ENOTTY 25
|
||||
#define ETXTBSY 26
|
||||
#define EFBIG 27
|
||||
#define ENOSPC 28
|
||||
#define ESPIPE 29
|
||||
#define EROFS 30
|
||||
#define EMLINK 31
|
||||
#define EPIPE 32
|
||||
#define EDOM 33
|
||||
#define ERANGE 34
|
||||
#define EDEADLK 35
|
||||
#define ENAMETOOLONG 36
|
||||
#define ENOLCK 37
|
||||
#define ENOSYS 38
|
||||
#define ENOTEMPTY 39
|
||||
#define ELOOP 40
|
||||
|
||||
#define ERROR_BASE_NO 0
|
||||
#endif
|
||||
|
||||
#if !defined(RT_USING_NEWLIB) && !defined(_WIN32)
|
||||
|
||||
#define EPERM (ERROR_BASE_NO + 1)
|
||||
#define ENOENT (ERROR_BASE_NO + 2)
|
||||
#define ESRCH (ERROR_BASE_NO + 3)
|
||||
#define EINTR (ERROR_BASE_NO + 4)
|
||||
#define EIO (ERROR_BASE_NO + 5)
|
||||
#define ENXIO (ERROR_BASE_NO + 6)
|
||||
#define E2BIG (ERROR_BASE_NO + 7)
|
||||
#define ENOEXEC (ERROR_BASE_NO + 8)
|
||||
#define EBADF (ERROR_BASE_NO + 9)
|
||||
#define ECHILD (ERROR_BASE_NO + 10)
|
||||
#define EAGAIN (ERROR_BASE_NO + 11)
|
||||
|
||||
#ifndef ENOMEM
|
||||
#define ENOMEM (ERROR_BASE_NO + 12)
|
||||
#endif
|
||||
|
||||
#define EACCES (ERROR_BASE_NO + 13)
|
||||
#define EFAULT (ERROR_BASE_NO + 14)
|
||||
#define ENOTBLK (ERROR_BASE_NO + 15)
|
||||
#define EBUSY (ERROR_BASE_NO + 16)
|
||||
#define EEXIST (ERROR_BASE_NO + 17)
|
||||
#define EXDEV (ERROR_BASE_NO + 18)
|
||||
#define ENODEV (ERROR_BASE_NO + 19)
|
||||
#define ENOTDIR (ERROR_BASE_NO + 20)
|
||||
#define EISDIR (ERROR_BASE_NO + 21)
|
||||
|
||||
#ifndef EINVAL
|
||||
#define EINVAL (ERROR_BASE_NO + 22)
|
||||
#endif
|
||||
|
||||
#define ENFILE (ERROR_BASE_NO + 23)
|
||||
#define EMFILE (ERROR_BASE_NO + 24)
|
||||
#define ENOTTY (ERROR_BASE_NO + 25)
|
||||
#define ETXTBSY (ERROR_BASE_NO + 26)
|
||||
#define EFBIG (ERROR_BASE_NO + 27)
|
||||
#define ENOSPC (ERROR_BASE_NO + 28)
|
||||
#define ESPIPE (ERROR_BASE_NO + 29)
|
||||
#define EROFS (ERROR_BASE_NO + 30)
|
||||
#define EMLINK (ERROR_BASE_NO + 31)
|
||||
#define EPIPE (ERROR_BASE_NO + 32)
|
||||
|
||||
#ifndef EDOM
|
||||
#define EDOM (ERROR_BASE_NO + 33)
|
||||
#endif
|
||||
|
||||
#ifndef ERANGE
|
||||
#define ERANGE (ERROR_BASE_NO + 34)
|
||||
#endif
|
||||
|
||||
#define EDEADLK (ERROR_BASE_NO + 35)
|
||||
#define ENAMETOOLONG (ERROR_BASE_NO + 36)
|
||||
#define ENOLCK (ERROR_BASE_NO + 37)
|
||||
#define ENOSYS (ERROR_BASE_NO + 38)
|
||||
#define ENOTEMPTY (ERROR_BASE_NO + 39)
|
||||
#define ELOOP (ERROR_BASE_NO + 40)
|
||||
#define EWOULDBLOCK EAGAIN
|
||||
#define ENOMSG 42
|
||||
#define EIDRM 43
|
||||
#define ECHRNG 44
|
||||
#define EL2NSYNC 45
|
||||
#define EL3HLT 46
|
||||
#define EL3RST 47
|
||||
#define ELNRNG 48
|
||||
#define EUNATCH 49
|
||||
#define ENOCSI 50
|
||||
#define EL2HLT 51
|
||||
#define EBADE 52
|
||||
#define EBADR 53
|
||||
#define EXFULL 54
|
||||
#define ENOANO 55
|
||||
#define EBADRQC 56
|
||||
#define EBADSLT 57
|
||||
#define ENOMSG (ERROR_BASE_NO + 42)
|
||||
#define EIDRM (ERROR_BASE_NO + 43)
|
||||
#define ECHRNG (ERROR_BASE_NO + 44)
|
||||
#define EL2NSYNC (ERROR_BASE_NO + 45)
|
||||
#define EL3HLT (ERROR_BASE_NO + 46)
|
||||
#define EL3RST (ERROR_BASE_NO + 47)
|
||||
#define ELNRNG (ERROR_BASE_NO + 48)
|
||||
#define EUNATCH (ERROR_BASE_NO + 49)
|
||||
#define ENOCSI (ERROR_BASE_NO + 50)
|
||||
#define EL2HLT (ERROR_BASE_NO + 51)
|
||||
#define EBADE (ERROR_BASE_NO + 52)
|
||||
#define EBADR (ERROR_BASE_NO + 53)
|
||||
#define EXFULL (ERROR_BASE_NO + 54)
|
||||
#define ENOANO (ERROR_BASE_NO + 55)
|
||||
#define EBADRQC (ERROR_BASE_NO + 56)
|
||||
#define EBADSLT (ERROR_BASE_NO + 57)
|
||||
#define EDEADLOCK EDEADLK
|
||||
#define EBFONT 59
|
||||
#define ENOSTR 60
|
||||
#define ENODATA 61
|
||||
#define ETIME 62
|
||||
#define ENOSR 63
|
||||
#define ENONET 64
|
||||
#define ENOPKG 65
|
||||
#define EREMOTE 66
|
||||
#define ENOLINK 67
|
||||
#define EADV 68
|
||||
#define ESRMNT 69
|
||||
#define ECOMM 70
|
||||
#define EPROTO 71
|
||||
#define EMULTIHOP 72
|
||||
#define EDOTDOT 73
|
||||
#define EBADMSG 74
|
||||
#define EOVERFLOW 75
|
||||
#define ENOTUNIQ 76
|
||||
#define EBADFD 77
|
||||
#define EREMCHG 78
|
||||
#define ELIBACC 79
|
||||
#define ELIBBAD 80
|
||||
#define ELIBSCN 81
|
||||
#define ELIBMAX 82
|
||||
#define ELIBEXEC 83
|
||||
#define EILSEQ 84
|
||||
#define ERESTART 85
|
||||
#define ESTRPIPE 86
|
||||
#define EUSERS 87
|
||||
#define ENOTSOCK 88
|
||||
#define EDESTADDRREQ 89
|
||||
#define EMSGSIZE 90
|
||||
#define EPROTOTYPE 91
|
||||
#define ENOPROTOOPT 92
|
||||
#define EPROTONOSUPPORT 93
|
||||
#define ESOCKTNOSUPPORT 94
|
||||
#define EOPNOTSUPP 95
|
||||
#define ENOTSUP EOPNOTSUPP
|
||||
#define EPFNOSUPPORT 96
|
||||
#define EAFNOSUPPORT 97
|
||||
#define EADDRINUSE 98
|
||||
#define EADDRNOTAVAIL 99
|
||||
#define ENETDOWN 100
|
||||
#define ENETUNREACH 101
|
||||
#define ENETRESET 102
|
||||
#define ECONNABORTED 103
|
||||
#define ECONNRESET 104
|
||||
#define ENOBUFS 105
|
||||
#define EISCONN 106
|
||||
#define ENOTCONN 107
|
||||
#define ESHUTDOWN 108
|
||||
#define ETOOMANYREFS 109
|
||||
#define ETIMEDOUT 110
|
||||
#define ECONNREFUSED 111
|
||||
#define EHOSTDOWN 112
|
||||
#define EHOSTUNREACH 113
|
||||
#define EALREADY 114
|
||||
#define EINPROGRESS 115
|
||||
#define ESTALE 116
|
||||
#define EUCLEAN 117
|
||||
#define ENOTNAM 118
|
||||
#define ENAVAIL 119
|
||||
#define EISNAM 120
|
||||
#define EREMOTEIO 121
|
||||
#define EDQUOT 122
|
||||
#define ENOMEDIUM 123
|
||||
#define EMEDIUMTYPE 124
|
||||
#define ECANCELED 125
|
||||
#define ENOKEY 126
|
||||
#define EKEYEXPIRED 127
|
||||
#define EKEYREVOKED 128
|
||||
#define EKEYREJECTED 129
|
||||
#define EOWNERDEAD 130
|
||||
#define ENOTRECOVERABLE 131
|
||||
#define ERFKILL 132
|
||||
#define EHWPOISON 133
|
||||
#define EBFONT (ERROR_BASE_NO + 59)
|
||||
#define ENOSTR (ERROR_BASE_NO + 60)
|
||||
#define ENODATA (ERROR_BASE_NO + 61)
|
||||
#define ETIME (ERROR_BASE_NO + 62)
|
||||
#define ENOSR (ERROR_BASE_NO + 63)
|
||||
#define ENONET (ERROR_BASE_NO + 64)
|
||||
#define ENOPKG (ERROR_BASE_NO + 65)
|
||||
#define EREMOTE (ERROR_BASE_NO + 66)
|
||||
#define ENOLINK (ERROR_BASE_NO + 67)
|
||||
#define EADV (ERROR_BASE_NO + 68)
|
||||
#define ESRMNT (ERROR_BASE_NO + 69)
|
||||
#define ECOMM (ERROR_BASE_NO + 70)
|
||||
#define EPROTO (ERROR_BASE_NO + 71)
|
||||
#define EMULTIHOP (ERROR_BASE_NO + 72)
|
||||
#define EDOTDOT (ERROR_BASE_NO + 73)
|
||||
#define EBADMSG (ERROR_BASE_NO + 74)
|
||||
#define EOVERFLOW (ERROR_BASE_NO + 75)
|
||||
#define ENOTUNIQ (ERROR_BASE_NO + 76)
|
||||
#define EBADFD (ERROR_BASE_NO + 77)
|
||||
#define EREMCHG (ERROR_BASE_NO + 78)
|
||||
#define ELIBACC (ERROR_BASE_NO + 79)
|
||||
#define ELIBBAD (ERROR_BASE_NO + 80)
|
||||
#define ELIBSCN (ERROR_BASE_NO + 81)
|
||||
#define ELIBMAX (ERROR_BASE_NO + 82)
|
||||
#define ELIBEXEC (ERROR_BASE_NO + 83)
|
||||
|
||||
#ifndef EILSEQ
|
||||
#define EILSEQ (ERROR_BASE_NO + 84)
|
||||
#endif
|
||||
|
||||
#define ERESTART (ERROR_BASE_NO + 85)
|
||||
#define ESTRPIPE (ERROR_BASE_NO + 86)
|
||||
#define EUSERS (ERROR_BASE_NO + 87)
|
||||
#define ENOTSOCK (ERROR_BASE_NO + 88)
|
||||
#define EDESTADDRREQ (ERROR_BASE_NO + 89)
|
||||
#define EMSGSIZE (ERROR_BASE_NO + 90)
|
||||
#define EPROTOTYPE (ERROR_BASE_NO + 91)
|
||||
#define ENOPROTOOPT (ERROR_BASE_NO + 92)
|
||||
#define EPROTONOSUPPORT (ERROR_BASE_NO + 93)
|
||||
#define ESOCKTNOSUPPORT (ERROR_BASE_NO + 94)
|
||||
#define EOPNOTSUPP (ERROR_BASE_NO + 95)
|
||||
#define ENOTSUP EOPNOTSUPP
|
||||
#define EPFNOSUPPORT (ERROR_BASE_NO + 96)
|
||||
#define EAFNOSUPPORT (ERROR_BASE_NO + 97)
|
||||
#define EADDRINUSE (ERROR_BASE_NO + 98)
|
||||
#define EADDRNOTAVAIL (ERROR_BASE_NO + 99)
|
||||
#define ENETDOWN (ERROR_BASE_NO + 100)
|
||||
#define ENETUNREACH (ERROR_BASE_NO + 101)
|
||||
#define ENETRESET (ERROR_BASE_NO + 102)
|
||||
#define ECONNABORTED (ERROR_BASE_NO + 103)
|
||||
#define ECONNRESET (ERROR_BASE_NO + 104)
|
||||
#define ENOBUFS (ERROR_BASE_NO + 105)
|
||||
#define EISCONN (ERROR_BASE_NO + 106)
|
||||
#define ENOTCONN (ERROR_BASE_NO + 107)
|
||||
#define ESHUTDOWN (ERROR_BASE_NO + 108)
|
||||
#define ETOOMANYREFS (ERROR_BASE_NO + 109)
|
||||
#define ETIMEDOUT (ERROR_BASE_NO + 110)
|
||||
#define ECONNREFUSED (ERROR_BASE_NO + 111)
|
||||
#define EHOSTDOWN (ERROR_BASE_NO + 112)
|
||||
#define EHOSTUNREACH (ERROR_BASE_NO + 113)
|
||||
#define EALREADY (ERROR_BASE_NO + 114)
|
||||
#define EINPROGRESS (ERROR_BASE_NO + 115)
|
||||
#define ESTALE (ERROR_BASE_NO + 116)
|
||||
#define EUCLEAN (ERROR_BASE_NO + 117)
|
||||
#define ENOTNAM (ERROR_BASE_NO + 118)
|
||||
#define ENAVAIL (ERROR_BASE_NO + 119)
|
||||
#define EISNAM (ERROR_BASE_NO + 120)
|
||||
#define EREMOTEIO (ERROR_BASE_NO + 121)
|
||||
#define EDQUOT (ERROR_BASE_NO + 122)
|
||||
#define ENOMEDIUM (ERROR_BASE_NO + 123)
|
||||
#define EMEDIUMTYPE (ERROR_BASE_NO + 124)
|
||||
#define ECANCELED (ERROR_BASE_NO + 125)
|
||||
#define ENOKEY (ERROR_BASE_NO + 126)
|
||||
#define EKEYEXPIRED (ERROR_BASE_NO + 127)
|
||||
#define EKEYREVOKED (ERROR_BASE_NO + 128)
|
||||
#define EKEYREJECTED (ERROR_BASE_NO + 129)
|
||||
#define EOWNERDEAD (ERROR_BASE_NO + 130)
|
||||
#define ENOTRECOVERABLE (ERROR_BASE_NO + 131)
|
||||
#define ERFKILL (ERROR_BASE_NO + 132)
|
||||
#define EHWPOISON (ERROR_BASE_NO + 133)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,17 +18,13 @@
|
||||
* In your C/C++ file, enable/disable DEBUG_ENABLE macro, and then include this
|
||||
* header file.
|
||||
*
|
||||
* #define DBG_SECTION_NAME "MOD"
|
||||
* #define DBG_ENABLE // enable debug macro
|
||||
* #define DBG_LEVEL DBG_INFO
|
||||
* #include <rtdbg.h> // must after of DEBUG_ENABLE or some other options
|
||||
* #define DBG_TAG "MOD_TAG"
|
||||
* #define DBG_LVL DBG_INFO
|
||||
* #include <rtdbg.h> // must after of DBG_LVL, DBG_TAG or other options
|
||||
*
|
||||
* Then in your C/C++ file, you can use LOG_X macro to print out logs:
|
||||
* LOG_D("this is a debug log!");
|
||||
* LOG_E("this is a error log!");
|
||||
*
|
||||
* If you want to use different color for different kinds log, you can
|
||||
* #define DBG_COLOR
|
||||
*/
|
||||
|
||||
#ifndef RT_DBG_H__
|
||||
@@ -36,7 +32,17 @@
|
||||
|
||||
#include <rtconfig.h>
|
||||
|
||||
#if defined(RT_USING_ULOG) && defined(DBG_ENABLE)
|
||||
/* the debug log will force enable when RT_DEBUG macro is defined */
|
||||
#if defined(RT_DEBUG) && !defined(DBG_ENABLE)
|
||||
#define DBG_ENABLE
|
||||
#endif
|
||||
|
||||
/* it will force output color log when RT_DEBUG_COLOR macro is defined */
|
||||
#if defined(RT_DEBUG_COLOR) && !defined(DBG_COLOR)
|
||||
#define DBG_COLOR
|
||||
#endif
|
||||
|
||||
#if defined(RT_USING_ULOG)
|
||||
/* using ulog compatible with rtdbg */
|
||||
#include <ulog.h>
|
||||
#else
|
||||
@@ -47,15 +53,29 @@
|
||||
#define DBG_INFO 2
|
||||
#define DBG_LOG 3
|
||||
|
||||
#ifdef DBG_TAG
|
||||
#ifndef DBG_SECTION_NAME
|
||||
#define DBG_SECTION_NAME DBG_TAG
|
||||
#endif
|
||||
#else
|
||||
/* compatible with old version */
|
||||
#ifndef DBG_SECTION_NAME
|
||||
#define DBG_SECTION_NAME "DBG"
|
||||
#endif
|
||||
#endif /* DBG_TAG */
|
||||
|
||||
#ifdef DBG_ENABLE
|
||||
|
||||
#ifdef DBG_LVL
|
||||
#ifndef DBG_LEVEL
|
||||
#define DBG_LEVEL DBG_LVL
|
||||
#endif
|
||||
#else
|
||||
/* compatible with old version */
|
||||
#ifndef DBG_LEVEL
|
||||
#define DBG_LEVEL DBG_WARNING
|
||||
#endif
|
||||
#endif /* DBG_LVL */
|
||||
|
||||
/*
|
||||
* The color for terminal (foreground)
|
||||
@@ -108,23 +128,6 @@
|
||||
__FUNCTION__, __LINE__); \
|
||||
}
|
||||
|
||||
#define dbg_enter \
|
||||
if ((DBG_LEVEL) <= DBG_LOG){ \
|
||||
_DBG_COLOR(32); \
|
||||
rt_kprintf(DBG_SECTION_NAME " Enter %s\n", \
|
||||
__FUNCTION__); \
|
||||
_DBG_COLOR(0); \
|
||||
}
|
||||
|
||||
#define dbg_exit \
|
||||
if ((DBG_LEVEL) <= DBG_LOG){ \
|
||||
_DBG_COLOR(32); \
|
||||
rt_kprintf(DBG_SECTION_NAME " Exit %s:%d\n", \
|
||||
__FUNCTION__); \
|
||||
_DBG_COLOR(0); \
|
||||
}
|
||||
|
||||
|
||||
#define dbg_log_line(lvl, color_n, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
* 2018-05-31 Bernard change version number to v3.1.0
|
||||
* 2018-09-04 Bernard change version number to v3.1.1
|
||||
* 2018-09-14 Bernard apply Apache License v2.0 to RT-Thread Kernel
|
||||
* 2019-09-14 Bernard change version number to v3.1.3
|
||||
* 2018-12-28 armink change version number to v3.1.2
|
||||
* 2019-03-14 armink change version number to v3.1.3
|
||||
*/
|
||||
|
||||
#ifndef __RT_DEF_H__
|
||||
@@ -53,12 +54,16 @@ extern "C" {
|
||||
(RT_SUBVERSION * 100) + RT_REVISION)
|
||||
|
||||
/* RT-Thread basic data type definitions */
|
||||
#ifndef RT_USING_ARCH_DATA_TYPE
|
||||
typedef signed char rt_int8_t; /**< 8bit integer type */
|
||||
typedef signed short rt_int16_t; /**< 16bit integer type */
|
||||
typedef signed long rt_int32_t; /**< 32bit integer type */
|
||||
typedef signed long long rt_int64_t; /**< 64bit integer type */
|
||||
typedef unsigned char rt_uint8_t; /**< 8bit unsigned integer type */
|
||||
typedef unsigned short rt_uint16_t; /**< 16bit unsigned integer type */
|
||||
typedef unsigned long rt_uint32_t; /**< 32bit unsigned integer type */
|
||||
typedef unsigned long long rt_uint64_t; /**< 64bit unsigned integer type */
|
||||
#endif
|
||||
typedef int rt_bool_t; /**< boolean type */
|
||||
|
||||
/* 32bit CPU */
|
||||
@@ -77,7 +82,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
|
||||
#define RT_TRUE 1 /**< boolean true */
|
||||
#define RT_FALSE 0 /**< boolean fails */
|
||||
|
||||
/*@}*/
|
||||
/**@}*/
|
||||
|
||||
/* maximum value of base type */
|
||||
#define RT_UINT8_MAX 0xff /**< Maxium number of UINT8 */
|
||||
@@ -122,11 +127,11 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
/* the version of GNU GCC must be greater than 4.x */
|
||||
typedef __builtin_va_list __gnuc_va_list;
|
||||
typedef __gnuc_va_list va_list;
|
||||
#define va_start(v,l) __builtin_va_start(v,l)
|
||||
#define va_end(v) __builtin_va_end(v)
|
||||
#define va_arg(v,l) __builtin_va_arg(v,l)
|
||||
typedef __builtin_va_list __gnuc_va_list;
|
||||
typedef __gnuc_va_list va_list;
|
||||
#define va_start(v,l) __builtin_va_start(v,l)
|
||||
#define va_end(v) __builtin_va_end(v)
|
||||
#define va_arg(v,l) __builtin_va_arg(v,l)
|
||||
#endif
|
||||
|
||||
#define SECTION(x) __attribute__((section(x)))
|
||||
@@ -248,7 +253,7 @@ typedef int (*init_fn_t)(void);
|
||||
* @addtogroup Error
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
/**@{*/
|
||||
|
||||
/* RT-Thread error code definitions */
|
||||
#define RT_EOK 0 /**< There is no error */
|
||||
@@ -263,7 +268,7 @@ typedef int (*init_fn_t)(void);
|
||||
#define RT_EINTR 9 /**< Interrupted system call */
|
||||
#define RT_EINVAL 10 /**< Invalid argument */
|
||||
|
||||
/*@}*/
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @ingroup BasicDef
|
||||
@@ -314,7 +319,7 @@ typedef struct rt_slist_node rt_slist_t; /**< Type for single lis
|
||||
* @addtogroup KernelObject
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
/**@{*/
|
||||
|
||||
/*
|
||||
* kernel object macros
|
||||
@@ -356,7 +361,8 @@ typedef struct rt_object *rt_object_t; /**< Type for kernel obj
|
||||
*/
|
||||
enum rt_object_class_type
|
||||
{
|
||||
RT_Object_Class_Thread = 0, /**< The object is a thread. */
|
||||
RT_Object_Class_Null = 0, /**< The object is not used. */
|
||||
RT_Object_Class_Thread, /**< The object is a thread. */
|
||||
RT_Object_Class_Semaphore, /**< The object is a semaphore. */
|
||||
RT_Object_Class_Mutex, /**< The object is a mutex. */
|
||||
RT_Object_Class_Event, /**< The object is a event. */
|
||||
@@ -391,13 +397,13 @@ struct rt_object_information
|
||||
#define RT_OBJECT_HOOK_CALL(func, argv)
|
||||
#endif
|
||||
|
||||
/*@}*/
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @addtogroup Clock
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* clock & timer macros
|
||||
@@ -441,7 +447,7 @@ struct rt_timer
|
||||
};
|
||||
typedef struct rt_timer *rt_timer_t;
|
||||
|
||||
/*@}*/
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @addtogroup Signal
|
||||
@@ -454,13 +460,13 @@ typedef siginfo_t rt_siginfo_t;
|
||||
|
||||
#define RT_SIG_MAX 32
|
||||
#endif
|
||||
/*@}*/
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @addtogroup Thread
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
/**@{*/
|
||||
|
||||
/*
|
||||
* Thread
|
||||
@@ -477,9 +483,10 @@ typedef siginfo_t rt_siginfo_t;
|
||||
#define RT_THREAD_CLOSE 0x04 /**< Closed status */
|
||||
#define RT_THREAD_STAT_MASK 0x0f
|
||||
|
||||
#define RT_THREAD_STAT_SIGNAL 0x10
|
||||
#define RT_THREAD_STAT_SIGNAL 0x10 /**< task hold signals */
|
||||
#define RT_THREAD_STAT_SIGNAL_READY (RT_THREAD_STAT_SIGNAL | RT_THREAD_READY)
|
||||
#define RT_THREAD_STAT_SIGNAL_WAIT 0x20
|
||||
#define RT_THREAD_STAT_SIGNAL_WAIT 0x20 /**< task is waiting for signals */
|
||||
#define RT_THREAD_STAT_SIGNAL_PENDING 0x40 /**< signals is held and it has not been procressed */
|
||||
#define RT_THREAD_STAT_SIGNAL_MASK 0xf0
|
||||
|
||||
/**
|
||||
@@ -559,13 +566,13 @@ struct rt_thread
|
||||
};
|
||||
typedef struct rt_thread *rt_thread_t;
|
||||
|
||||
/*@}*/
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @addtogroup IPC
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* IPC flags and control command definitions
|
||||
@@ -598,6 +605,7 @@ struct rt_semaphore
|
||||
struct rt_ipc_object parent; /**< inherit from ipc_object */
|
||||
|
||||
rt_uint16_t value; /**< value of semaphore. */
|
||||
rt_uint16_t reserved; /**< reserved field */
|
||||
};
|
||||
typedef struct rt_semaphore *rt_sem_t;
|
||||
#endif
|
||||
@@ -683,13 +691,13 @@ struct rt_messagequeue
|
||||
typedef struct rt_messagequeue *rt_mq_t;
|
||||
#endif
|
||||
|
||||
/*@}*/
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @addtogroup MM
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
/**@{*/
|
||||
|
||||
/*
|
||||
* memory management
|
||||
@@ -757,14 +765,14 @@ struct rt_mempool
|
||||
typedef struct rt_mempool *rt_mp_t;
|
||||
#endif
|
||||
|
||||
/*@}*/
|
||||
/**@}*/
|
||||
|
||||
#ifdef RT_USING_DEVICE
|
||||
/**
|
||||
* @addtogroup Device
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* device (I/O) class type
|
||||
@@ -790,6 +798,7 @@ enum rt_device_class_type
|
||||
RT_Device_Class_Portal, /**< Portal device */
|
||||
RT_Device_Class_Timer, /**< Timer device */
|
||||
RT_Device_Class_Miscellaneous, /**< Miscellaneous device */
|
||||
RT_Device_Class_Sensor, /**< Sensor device */
|
||||
RT_Device_Class_Unknown /**< unknown device */
|
||||
};
|
||||
|
||||
@@ -961,6 +970,7 @@ enum
|
||||
RTGRAPHIC_PIXEL_FORMAT_ABGR888,
|
||||
RTGRAPHIC_PIXEL_FORMAT_ARGB565,
|
||||
RTGRAPHIC_PIXEL_FORMAT_ALPHA,
|
||||
RTGRAPHIC_PIXEL_FORMAT_COLOR,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1009,7 +1019,7 @@ struct rt_device_graphic_ops
|
||||
};
|
||||
#define rt_graphix_ops(device) ((struct rt_device_graphic_ops *)(device->user_data))
|
||||
|
||||
/*@}*/
|
||||
/**@}*/
|
||||
#endif
|
||||
|
||||
/* definitions for libc */
|
||||
|
||||
@@ -90,7 +90,7 @@ void rt_hw_interrupt_umask(int vector);
|
||||
rt_isr_handler_t rt_hw_interrupt_install(int vector,
|
||||
rt_isr_handler_t handler,
|
||||
void *param,
|
||||
char *name);
|
||||
const char *name);
|
||||
|
||||
rt_base_t rt_hw_interrupt_disable(void);
|
||||
void rt_hw_interrupt_enable(rt_base_t level);
|
||||
@@ -117,6 +117,12 @@ void rt_hw_exception_install(rt_err_t (*exception_handle)(void *context));
|
||||
*/
|
||||
void rt_hw_us_delay(rt_uint32_t us);
|
||||
|
||||
#define RT_DEFINE_SPINLOCK(x)
|
||||
#define RT_DECLARE_SPINLOCK(x) rt_ubase_t x
|
||||
|
||||
#define rt_hw_spin_lock(lock) *(lock) = rt_hw_interrupt_disable()
|
||||
#define rt_hw_spin_unlock(lock) rt_hw_interrupt_enable(*(lock))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@ extern "C" {
|
||||
* @addtogroup KernelService
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
/**@{*/
|
||||
|
||||
/**
|
||||
* rt_container_of - return the member address of ptr, if the type of ptr is the
|
||||
@@ -306,7 +306,7 @@ rt_inline int rt_slist_isempty(rt_slist_t *l)
|
||||
#define rt_slist_tail_entry(ptr, type, member) \
|
||||
rt_slist_entry(rt_slist_tail(ptr), type, member)
|
||||
|
||||
/*@}*/
|
||||
/**@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ void rt_system_tick_init(void);
|
||||
rt_tick_t rt_tick_get(void);
|
||||
void rt_tick_set(rt_tick_t tick);
|
||||
void rt_tick_increase(void);
|
||||
int rt_tick_from_millisecond(rt_int32_t ms);
|
||||
rt_tick_t rt_tick_from_millisecond(rt_int32_t ms);
|
||||
|
||||
void rt_system_timer_init(void);
|
||||
void rt_system_timer_thread_init(void);
|
||||
@@ -257,7 +257,7 @@ void rt_page_free(void *addr, rt_size_t npages);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_HOOK
|
||||
void rt_malloc_sethook(void (*hook)(void *ptr, rt_uint32_t size));
|
||||
void rt_malloc_sethook(void (*hook)(void *ptr, rt_size_t size));
|
||||
void rt_free_sethook(void (*hook)(void *ptr));
|
||||
#endif
|
||||
|
||||
@@ -270,9 +270,9 @@ void rt_free_sethook(void (*hook)(void *ptr));
|
||||
rt_err_t rt_memheap_init(struct rt_memheap *memheap,
|
||||
const char *name,
|
||||
void *start_addr,
|
||||
rt_uint32_t size);
|
||||
rt_size_t size);
|
||||
rt_err_t rt_memheap_detach(struct rt_memheap *heap);
|
||||
void *rt_memheap_alloc(struct rt_memheap *heap, rt_uint32_t size);
|
||||
void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size);
|
||||
void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize);
|
||||
void rt_memheap_free(void *ptr);
|
||||
#endif
|
||||
@@ -497,6 +497,7 @@ void *rt_memcpy(void *dest, const void *src, rt_ubase_t n);
|
||||
rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_ubase_t count);
|
||||
rt_int32_t rt_strcmp(const char *cs, const char *ct);
|
||||
rt_size_t rt_strlen(const char *src);
|
||||
rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen);
|
||||
char *rt_strdup(const char *s);
|
||||
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
||||
/* leak strdup interface */
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
;/*
|
||||
; * File : context_iar.S
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||
; * Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
; *
|
||||
; * This program is free software; you can redistribute it and/or modify
|
||||
; * it under the terms of the GNU General Public License as published by
|
||||
; * the Free Software Foundation; either version 2 of the License, or
|
||||
; * (at your option) any later version.
|
||||
; *
|
||||
; * This program 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 along
|
||||
; * with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
; * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Change Logs:
|
||||
; * Date Author Notes
|
||||
|
||||
@@ -1,27 +1,13 @@
|
||||
;/*
|
||||
; * File : context_iar.S
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||
; *
|
||||
; * This program is free software; you can redistribute it and/or modify
|
||||
; * it under the terms of the GNU General Public License as published by
|
||||
; * the Free Software Foundation; either version 2 of the License, or
|
||||
; * (at your option) any later version.
|
||||
; *
|
||||
; * This program 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 along
|
||||
; * with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
; * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
; *
|
||||
; * Change Logs:
|
||||
; * Date Author Notes
|
||||
; * 2011-08-14 weety copy from mini2440
|
||||
; * 2015-04-15 ArdaFu convert from context_gcc.s
|
||||
; */
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2011-08-14 weety copy from mini2440
|
||||
* 2015-04-15 ArdaFu convert from context_gcc.s
|
||||
*/
|
||||
|
||||
#define NOINT 0xc0
|
||||
|
||||
|
||||
@@ -1,24 +1,10 @@
|
||||
;/*
|
||||
; * file : context_rvds.s
|
||||
; * this file is part of rt-thread rtos
|
||||
; * copyright (c) 2006, rt-thread development team
|
||||
; * Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
; *
|
||||
; * this program is free software; you can redistribute it and/or modify
|
||||
; * it under the terms of the gnu general public license as published by
|
||||
; * the free software foundation; either version 2 of the license, or
|
||||
; * (at your option) any later version.
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * this program 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 along
|
||||
; * with this program; if not, write to the free software foundation, inc.,
|
||||
; * 51 franklin street, fifth floor, boston, ma 02110-1301 usa.
|
||||
; *
|
||||
; * change logs:
|
||||
; * date author notes
|
||||
; * Change Logs:
|
||||
; * Date Author Notes
|
||||
; * 2011-08-14 weety copy from mini2440
|
||||
; */
|
||||
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
;/*
|
||||
; * File : start.S
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||
; * Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
; *
|
||||
; * This program is free software; you can redistribute it and/or modify
|
||||
; * it under the terms of the GNU General Public License as published by
|
||||
; * the Free Software Foundation; either version 2 of the License, or
|
||||
; * (at your option) any later version.
|
||||
; *
|
||||
; * This program 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 along
|
||||
; * with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
; * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Change Logs:
|
||||
; * Date Author Notes
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
;/*
|
||||
; * File : start_rvds.S
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||
; * Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
; *
|
||||
; * This program is free software; you can redistribute it and/or modify
|
||||
; * it under the terms of the GNU General Public License as published by
|
||||
; * the Free Software Foundation; either version 2 of the License, or
|
||||
; * (at your option) any later version.
|
||||
; *
|
||||
; * This program 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 along
|
||||
; * with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
; * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Change Logs:
|
||||
; * Date Author Notes
|
||||
@@ -25,28 +11,16 @@
|
||||
; * 2015-06-04 aozima Align stack address to 8 byte.
|
||||
; */
|
||||
|
||||
#include "rt_low_level_init.h"
|
||||
UND_STK_SIZE EQU 512
|
||||
SVC_STK_SIZE EQU 4096
|
||||
ABT_STK_SIZE EQU 512
|
||||
IRQ_STK_SIZE EQU 1024
|
||||
FIQ_STK_SIZE EQU 1024
|
||||
SYS_STK_SIZE EQU 512
|
||||
Heap_Size EQU 512
|
||||
|
||||
S_FRAME_SIZE EQU (18*4) ;72
|
||||
;S_SPSR EQU (17*4) ;SPSR
|
||||
;S_CPSR EQU (16*4) ;CPSR
|
||||
S_PC EQU (15*4) ;R15
|
||||
;S_LR EQU (14*4) ;R14
|
||||
;S_SP EQU (13*4) ;R13
|
||||
|
||||
;S_IP EQU (12*4) ;R12
|
||||
;S_FP EQU (11*4) ;R11
|
||||
;S_R10 EQU (10*4)
|
||||
;S_R9 EQU (9*4)
|
||||
;S_R8 EQU (8*4)
|
||||
;S_R7 EQU (7*4)
|
||||
;S_R6 EQU (6*4)
|
||||
;S_R5 EQU (5*4)
|
||||
;S_R4 EQU (4*4)
|
||||
;S_R3 EQU (3*4)
|
||||
;S_R2 EQU (2*4)
|
||||
;S_R1 EQU (1*4)
|
||||
;S_R0 EQU (0*4)
|
||||
|
||||
MODE_USR EQU 0X10
|
||||
MODE_FIQ EQU 0X11
|
||||
|
||||
@@ -13,51 +13,51 @@
|
||||
#ifdef __GNUC__
|
||||
/*
|
||||
-->High Address,Stack Top
|
||||
PC<-----|
|
||||
LR |
|
||||
IP |
|
||||
FP |
|
||||
...... |
|
||||
PC<-| |
|
||||
LR | |
|
||||
IP | |
|
||||
PC<------|
|
||||
LR |
|
||||
IP |
|
||||
FP |
|
||||
...... |
|
||||
PC <-| |
|
||||
LR | |
|
||||
IP | |
|
||||
FP---|-- |
|
||||
...... |
|
||||
PC |
|
||||
LR |
|
||||
IP |
|
||||
...... |
|
||||
PC |
|
||||
LR |
|
||||
IP |
|
||||
FP---
|
||||
-->Low Address,Stack Bottom
|
||||
*/
|
||||
void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry)
|
||||
{
|
||||
rt_uint32_t i, pc, func_entry;
|
||||
rt_uint32_t i, pc, func_entry;
|
||||
|
||||
pc = *fp;
|
||||
rt_kprintf("[0x%x]\n", pc-0xC);
|
||||
pc = *fp;
|
||||
rt_kprintf("[0x%x]\n", pc-0xC);
|
||||
|
||||
for(i=0; i<10; i++)
|
||||
{
|
||||
fp = (rt_uint32_t *)*(fp - 3);
|
||||
pc = *fp ;
|
||||
for(i=0; i<10; i++)
|
||||
{
|
||||
fp = (rt_uint32_t *)*(fp - 3);
|
||||
pc = *fp ;
|
||||
|
||||
func_entry = pc - 0xC;
|
||||
func_entry = pc - 0xC;
|
||||
|
||||
if(func_entry <= 0x30000000) break;
|
||||
if(func_entry <= 0x30000000) break;
|
||||
|
||||
if(func_entry == thread_entry)
|
||||
{
|
||||
rt_kprintf("EntryPoint:0x%x\n", func_entry);
|
||||
if(func_entry == thread_entry)
|
||||
{
|
||||
rt_kprintf("EntryPoint:0x%x\n", func_entry);
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
rt_kprintf("[0x%x]\n", func_entry);
|
||||
}
|
||||
rt_kprintf("[0x%x]\n", func_entry);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry)
|
||||
{
|
||||
/* old compiler implementation */
|
||||
/* old compiler implementation */
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,7 +8,14 @@
|
||||
* 2013-07-05 Bernard the first version
|
||||
*/
|
||||
|
||||
#include "rtconfig.h"
|
||||
.section .text, "ax"
|
||||
|
||||
#ifdef RT_USING_SMP
|
||||
#define rt_hw_interrupt_disable rt_hw_local_irq_disable
|
||||
#define rt_hw_interrupt_enable rt_hw_local_irq_enable
|
||||
#endif
|
||||
|
||||
/*
|
||||
* rt_base_t rt_hw_interrupt_disable();
|
||||
*/
|
||||
@@ -27,17 +34,19 @@ rt_hw_interrupt_enable:
|
||||
bx lr
|
||||
|
||||
/*
|
||||
* void rt_hw_context_switch_to(rt_uint32 to);
|
||||
* r0 --> to
|
||||
* void rt_hw_context_switch_to(rt_uint32 to, struct rt_thread *to_thread);
|
||||
* r0 --> to (thread stack)
|
||||
* r1 --> to_thread
|
||||
*/
|
||||
.globl rt_hw_context_switch_to
|
||||
rt_hw_context_switch_to:
|
||||
ldr sp, [r0] @ get new task stack pointer
|
||||
|
||||
ldmfd sp!, {r4} @ pop new task spsr
|
||||
msr spsr_cxsf, r4
|
||||
|
||||
ldmfd sp!, {r0-r12, lr, pc}^ @ pop new task r0-r12, lr & pc
|
||||
#ifdef RT_USING_SMP
|
||||
mov r0, r1
|
||||
bl rt_cpus_lock_status_restore
|
||||
#endif /*RT_USING_SMP*/
|
||||
b rt_hw_context_switch_exit
|
||||
|
||||
.section .bss.share.isr
|
||||
_guest_switch_lvl:
|
||||
@@ -47,9 +56,10 @@ _guest_switch_lvl:
|
||||
|
||||
.section .text.isr, "ax"
|
||||
/*
|
||||
* void rt_hw_context_switch(rt_uint32 from, rt_uint32 to);
|
||||
* r0 --> from
|
||||
* r1 --> to
|
||||
* void rt_hw_context_switch(rt_uint32 from, rt_uint32 to, struct rt_thread *to_thread);
|
||||
* r0 --> from (from_thread stack)
|
||||
* r1 --> to (to_thread stack)
|
||||
* r2 --> to_thread
|
||||
*/
|
||||
.globl rt_hw_context_switch
|
||||
rt_hw_context_switch:
|
||||
@@ -62,21 +72,55 @@ rt_hw_context_switch:
|
||||
|
||||
stmfd sp!, {r4} @ push cpsr
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
stmfd sp, {r13, r14}^ @ push usr_sp usr_lr
|
||||
sub sp, #8
|
||||
#endif
|
||||
|
||||
str sp, [r0] @ store sp in preempted tasks TCB
|
||||
ldr sp, [r1] @ get new task stack pointer
|
||||
|
||||
ldmfd sp!, {r4} @ pop new task cpsr to spsr
|
||||
msr spsr_cxsf, r4
|
||||
ldmfd sp!, {r0-r12, lr, pc}^ @ pop new task r0-r12, lr & pc, copy spsr to cpsr
|
||||
#ifdef RT_USING_SMP
|
||||
mov r0, r2
|
||||
bl rt_cpus_lock_status_restore
|
||||
#endif /*RT_USING_SMP*/
|
||||
b rt_hw_context_switch_exit
|
||||
|
||||
/*
|
||||
* void rt_hw_context_switch_interrupt(rt_uint32 from, rt_uint32 to);
|
||||
*/
|
||||
.equ Mode_USR, 0x10
|
||||
.equ Mode_FIQ, 0x11
|
||||
.equ Mode_IRQ, 0x12
|
||||
.equ Mode_SVC, 0x13
|
||||
.equ Mode_ABT, 0x17
|
||||
.equ Mode_UND, 0x1B
|
||||
.equ Mode_SYS, 0x1F
|
||||
|
||||
.equ I_Bit, 0x80 @ when I bit is set, IRQ is disabled
|
||||
.equ F_Bit, 0x40 @ when F bit is set, FIQ is disabled
|
||||
|
||||
.globl rt_thread_switch_interrupt_flag
|
||||
.globl rt_interrupt_from_thread
|
||||
.globl rt_interrupt_to_thread
|
||||
.globl rt_hw_context_switch_interrupt
|
||||
rt_hw_context_switch_interrupt:
|
||||
#ifdef RT_USING_SMP
|
||||
/* r0 :svc_mod context
|
||||
* r1 :addr of from_thread's sp
|
||||
* r2 :addr of to_thread's sp
|
||||
* r3 :to_thread's tcb
|
||||
*/
|
||||
|
||||
str r0, [r1]
|
||||
|
||||
ldr sp, [r2]
|
||||
mov r0, r3
|
||||
bl rt_cpus_lock_status_restore
|
||||
|
||||
b rt_hw_context_switch_exit
|
||||
|
||||
#else /*RT_USING_SMP*/
|
||||
ldr r2, =rt_thread_switch_interrupt_flag
|
||||
ldr r3, [r2]
|
||||
cmp r3, #1
|
||||
@@ -89,3 +133,26 @@ _reswitch:
|
||||
ldr r2, =rt_interrupt_to_thread @ set rt_interrupt_to_thread
|
||||
str r1, [r2]
|
||||
bx lr
|
||||
#endif /*RT_USING_SMP*/
|
||||
|
||||
.global rt_hw_context_switch_exit
|
||||
rt_hw_context_switch_exit:
|
||||
|
||||
#ifdef RT_USING_SMP
|
||||
#ifdef RT_USING_SIGNALS
|
||||
mov r0, sp
|
||||
cps #Mode_IRQ
|
||||
bl rt_signal_check
|
||||
cps #Mode_SVC
|
||||
mov sp, r0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
ldmfd sp, {r13, r14}^ /* usr_sp, usr_lr */
|
||||
add sp, #8
|
||||
#endif
|
||||
ldmfd sp!, {r1}
|
||||
msr spsr_cxsf, r1 /* original mode */
|
||||
ldmfd sp!, {r0-r12,lr,pc}^ /* irq return */
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-03-25 quanzhao the first version
|
||||
*/
|
||||
#ifndef __CP15_H__
|
||||
#define __CP15_H__
|
||||
@@ -15,6 +16,9 @@ void rt_cpu_mmu_disable(void);
|
||||
void rt_cpu_mmu_enable(void);
|
||||
void rt_cpu_tlb_set(volatile unsigned long*);
|
||||
|
||||
void rt_cpu_dcache_clean_flush(void);
|
||||
void rt_cpu_icache_flush(void);
|
||||
|
||||
void rt_cpu_vector_set_base(unsigned int addr);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,11 @@ rt_cpu_get_smp_id:
|
||||
|
||||
.globl rt_cpu_vector_set_base
|
||||
rt_cpu_vector_set_base:
|
||||
/* clear SCTRL.V to customize the vector address */
|
||||
mrc p15, #0, r1, c1, c0, #0
|
||||
bic r1, #(1 << 13)
|
||||
mcr p15, #0, r1, c1, c0, #0
|
||||
/* set up the vector address */
|
||||
mcr p15, #0, r0, c12, c0, #0
|
||||
dsb
|
||||
bx lr
|
||||
@@ -36,7 +41,7 @@ rt_hw_cpu_icache_enable:
|
||||
_FLD_MAX_WAY:
|
||||
.word 0x3ff
|
||||
_FLD_MAX_IDX:
|
||||
.word 0x7ff
|
||||
.word 0x7fff
|
||||
|
||||
.globl rt_cpu_dcache_clean_flush
|
||||
rt_cpu_dcache_clean_flush:
|
||||
@@ -84,6 +89,14 @@ finished:
|
||||
pop {r4-r11}
|
||||
bx lr
|
||||
|
||||
.globl rt_cpu_icache_flush
|
||||
rt_cpu_icache_flush:
|
||||
mov r0, #0
|
||||
mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate
|
||||
dsb
|
||||
isb
|
||||
bx lr
|
||||
|
||||
.globl rt_hw_cpu_dcache_disable
|
||||
rt_hw_cpu_dcache_disable:
|
||||
push {r4-r11, lr}
|
||||
|
||||
@@ -6,28 +6,78 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2011-09-15 Bernard first version
|
||||
* 2018-11-22 Jesven add rt_hw_cpu_id()
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include <board.h>
|
||||
|
||||
#ifdef RT_USING_SMP
|
||||
int rt_hw_cpu_id(void)
|
||||
{
|
||||
int cpu_id;
|
||||
__asm__ volatile (
|
||||
"mrc p15, 0, %0, c0, c0, 5"
|
||||
:"=r"(cpu_id)
|
||||
);
|
||||
cpu_id &= 0xf;
|
||||
return cpu_id;
|
||||
};
|
||||
|
||||
void rt_hw_spin_lock(rt_hw_spinlock_t *lock)
|
||||
{
|
||||
unsigned long tmp;
|
||||
unsigned long newval;
|
||||
rt_hw_spinlock_t lockval;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"pld [%0]"
|
||||
::"r"(&lock->slock)
|
||||
);
|
||||
|
||||
__asm__ __volatile__(
|
||||
"1: ldrex %0, [%3]\n"
|
||||
" add %1, %0, %4\n"
|
||||
" strex %2, %1, [%3]\n"
|
||||
" teq %2, #0\n"
|
||||
" bne 1b"
|
||||
: "=&r" (lockval), "=&r" (newval), "=&r" (tmp)
|
||||
: "r" (&lock->slock), "I" (1 << 16)
|
||||
: "cc");
|
||||
|
||||
while (lockval.tickets.next != lockval.tickets.owner) {
|
||||
__asm__ __volatile__("wfe":::"memory");
|
||||
lockval.tickets.owner = *(volatile unsigned short *)(&lock->tickets.owner);
|
||||
}
|
||||
|
||||
__asm__ volatile ("dmb":::"memory");
|
||||
}
|
||||
|
||||
void rt_hw_spin_unlock(rt_hw_spinlock_t *lock)
|
||||
{
|
||||
__asm__ volatile ("dmb":::"memory");
|
||||
lock->tickets.owner++;
|
||||
__asm__ volatile ("dsb ishst\nsev":::"memory");
|
||||
}
|
||||
#endif /*RT_USING_SMP*/
|
||||
|
||||
/**
|
||||
* @addtogroup AM33xx
|
||||
* @addtogroup ARM CPU
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/** shutdown CPU */
|
||||
void rt_hw_cpu_shutdown()
|
||||
{
|
||||
rt_uint32_t level;
|
||||
rt_kprintf("shutdown...\n");
|
||||
rt_uint32_t level;
|
||||
rt_kprintf("shutdown...\n");
|
||||
|
||||
level = rt_hw_interrupt_disable();
|
||||
while (level)
|
||||
{
|
||||
RT_ASSERT(0);
|
||||
}
|
||||
level = rt_hw_interrupt_disable();
|
||||
while (level)
|
||||
{
|
||||
RT_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
@@ -6,68 +6,32 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2013-07-06 Bernard first version
|
||||
* 2014-04-03 Grissiom port to VMM
|
||||
* 2018-11-22 Jesven add smp support
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include "interrupt.h"
|
||||
#include "gic.h"
|
||||
|
||||
#include <irq_numbers.h>
|
||||
#include <interrupt.h>
|
||||
|
||||
#include <gic.h>
|
||||
#include "cp15.h"
|
||||
|
||||
#define MAX_HANDLERS IMX_INTERRUPT_COUNT
|
||||
|
||||
extern volatile rt_uint8_t rt_interrupt_nest;
|
||||
|
||||
/* exception and interrupt handler table */
|
||||
struct rt_irq_desc isr_table[MAX_HANDLERS];
|
||||
|
||||
rt_uint32_t rt_interrupt_from_thread;
|
||||
rt_uint32_t rt_interrupt_to_thread;
|
||||
rt_uint32_t rt_thread_switch_interrupt_flag;
|
||||
#ifndef RT_USING_SMP
|
||||
/* Those varibles will be accessed in ISR, so we need to share them. */
|
||||
rt_uint32_t rt_interrupt_from_thread = 0;
|
||||
rt_uint32_t rt_interrupt_to_thread = 0;
|
||||
rt_uint32_t rt_thread_switch_interrupt_flag = 0;
|
||||
#endif
|
||||
|
||||
const unsigned int VECTOR_BASE = 0x00;
|
||||
extern void rt_cpu_vector_set_base(unsigned int addr);
|
||||
extern int system_vectors;
|
||||
|
||||
/* keep compatible with platform SDK */
|
||||
void register_interrupt_routine(uint32_t irq_id, irq_hdlr_t isr)
|
||||
void rt_hw_vector_init(void)
|
||||
{
|
||||
rt_hw_interrupt_install(irq_id, (rt_isr_handler_t)isr, NULL, "unknown");
|
||||
}
|
||||
|
||||
void enable_interrupt(uint32_t irq_id, uint32_t cpu_id, uint32_t priority)
|
||||
{
|
||||
gic_set_irq_priority(irq_id, priority);
|
||||
gic_set_irq_security(irq_id, false); // set IRQ as non-secure
|
||||
gic_set_cpu_target(irq_id, cpu_id, true);
|
||||
gic_enable_irq(irq_id, true);
|
||||
}
|
||||
|
||||
void disable_interrupt(uint32_t irq_id, uint32_t cpu_id)
|
||||
{
|
||||
gic_enable_irq(irq_id, false);
|
||||
gic_set_cpu_target(irq_id, cpu_id, false);
|
||||
}
|
||||
|
||||
static void rt_hw_vector_init(void)
|
||||
{
|
||||
int sctrl;
|
||||
unsigned int *src = (unsigned int *)&system_vectors;
|
||||
|
||||
/* C12-C0 is only active when SCTLR.V = 0 */
|
||||
asm volatile ("mrc p15, #0, %0, c1, c0, #0"
|
||||
:"=r" (sctrl));
|
||||
sctrl &= ~(1 << 13);
|
||||
asm volatile ("mcr p15, #0, %0, c1, c0, #0"
|
||||
:
|
||||
:"r" (sctrl));
|
||||
|
||||
asm volatile ("mcr p15, #0, %0, c12, c0, #0"
|
||||
:
|
||||
:"r" (src));
|
||||
rt_cpu_vector_set_base((unsigned int)&system_vectors);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,14 +39,24 @@ static void rt_hw_vector_init(void)
|
||||
*/
|
||||
void rt_hw_interrupt_init(void)
|
||||
{
|
||||
rt_hw_vector_init();
|
||||
gic_init();
|
||||
rt_uint32_t gic_cpu_base;
|
||||
rt_uint32_t gic_dist_base;
|
||||
rt_uint32_t gic_irq_start;
|
||||
|
||||
/* init interrupt nest, and context in thread sp */
|
||||
rt_interrupt_nest = 0;
|
||||
rt_interrupt_from_thread = 0;
|
||||
rt_interrupt_to_thread = 0;
|
||||
rt_thread_switch_interrupt_flag = 0;
|
||||
/* initialize vector table */
|
||||
rt_hw_vector_init();
|
||||
|
||||
/* initialize exceptions table */
|
||||
rt_memset(isr_table, 0x00, sizeof(isr_table));
|
||||
|
||||
/* initialize ARM GIC */
|
||||
gic_dist_base = platform_get_gic_dist_base();
|
||||
gic_cpu_base = platform_get_gic_cpu_base();
|
||||
|
||||
gic_irq_start = GIC_IRQ_START;
|
||||
|
||||
arm_gic_dist_init(0, gic_dist_base, gic_irq_start);
|
||||
arm_gic_cpu_init(0, gic_cpu_base);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +65,7 @@ void rt_hw_interrupt_init(void)
|
||||
*/
|
||||
void rt_hw_interrupt_mask(int vector)
|
||||
{
|
||||
disable_interrupt(vector, 0);
|
||||
arm_gic_mask(0, vector);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,9 +74,26 @@ void rt_hw_interrupt_mask(int vector)
|
||||
*/
|
||||
void rt_hw_interrupt_umask(int vector)
|
||||
{
|
||||
enable_interrupt(vector, 0, 0);
|
||||
arm_gic_umask(0, vector);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the active interrupt number.
|
||||
* @param none
|
||||
*/
|
||||
int rt_hw_interrupt_get_irq(void)
|
||||
{
|
||||
return arm_gic_get_active_irq(0) & GIC_ACK_INTID_MASK;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function acknowledges the interrupt.
|
||||
* @param vector the interrupt number
|
||||
*/
|
||||
void rt_hw_interrupt_ack(int vector)
|
||||
{
|
||||
arm_gic_ack(0, vector);
|
||||
}
|
||||
/**
|
||||
* This function will install a interrupt service routine to a interrupt.
|
||||
* @param vector the interrupt number
|
||||
@@ -110,7 +101,7 @@ void rt_hw_interrupt_umask(int vector)
|
||||
* @param old_handler the old interrupt service routine
|
||||
*/
|
||||
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
|
||||
void *param, char *name)
|
||||
void *param, const char *name)
|
||||
{
|
||||
rt_isr_handler_t old_handler = RT_NULL;
|
||||
|
||||
@@ -126,23 +117,7 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
|
||||
isr_table[vector].handler = handler;
|
||||
isr_table[vector].param = param;
|
||||
}
|
||||
// arm_gic_set_cpu(0, vector, 1 << rt_cpu_get_smp_id());
|
||||
}
|
||||
|
||||
return old_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger a software IRQ
|
||||
*
|
||||
* Since we are running in single core, the target CPU are always CPU0.
|
||||
*/
|
||||
void rt_hw_interrupt_trigger(int vector)
|
||||
{
|
||||
// arm_gic_trigger(0, 1, vector);
|
||||
}
|
||||
|
||||
void rt_hw_interrupt_clear(int vector)
|
||||
{
|
||||
gic_write_end_of_irq(vector);
|
||||
}
|
||||
|
||||
@@ -13,35 +13,7 @@
|
||||
#include <board.h>
|
||||
|
||||
#include "cp15.h"
|
||||
|
||||
#define DESC_SEC (0x2)
|
||||
#define CB (3<<2) //cache_on, write_back
|
||||
#define CNB (2<<2) //cache_on, write_through
|
||||
#define NCB (1<<2) //cache_off,WR_BUF on
|
||||
#define NCNB (0<<2) //cache_off,WR_BUF off
|
||||
#define AP_RW (3<<10) //supervisor=RW, user=RW
|
||||
#define AP_RO (2<<10) //supervisor=RW, user=RO
|
||||
#define XN (1<<4) // eXecute Never
|
||||
|
||||
#define DOMAIN_FAULT (0x0)
|
||||
#define DOMAIN_CHK (0x1)
|
||||
#define DOMAIN_NOTCHK (0x3)
|
||||
#define DOMAIN0 (0x0<<5)
|
||||
#define DOMAIN1 (0x1<<5)
|
||||
|
||||
#define DOMAIN0_ATTR (DOMAIN_CHK<<0)
|
||||
#define DOMAIN1_ATTR (DOMAIN_FAULT<<2)
|
||||
|
||||
/* Read/Write, cache, write back */
|
||||
#define RW_CB (AP_RW|DOMAIN0|CB|DESC_SEC)
|
||||
/* Read/Write, cache, write through */
|
||||
#define RW_CNB (AP_RW|DOMAIN0|CNB|DESC_SEC)
|
||||
/* Read/Write without cache and write buffer */
|
||||
#define RW_NCNB (AP_RW|DOMAIN0|NCNB|DESC_SEC)
|
||||
/* Read/Write without cache and write buffer, no execute */
|
||||
#define RW_NCNBXN (AP_RW|DOMAIN0|NCNB|DESC_SEC|XN)
|
||||
/* Read/Write without cache and write buffer */
|
||||
#define RW_FAULT (AP_RW|DOMAIN1|NCNB|DESC_SEC)
|
||||
#include "mmu.h"
|
||||
|
||||
/* dump 2nd level page table */
|
||||
void rt_hw_cpu_dump_page_table_2nd(rt_uint32_t *ptb)
|
||||
@@ -178,18 +150,25 @@ unsigned long rt_hw_set_domain_register(unsigned long domain_val)
|
||||
return old_domain;
|
||||
}
|
||||
|
||||
void rt_hw_init_mmu_table(struct mem_desc *mdesc, rt_uint32_t size)
|
||||
{
|
||||
/* set page table */
|
||||
for(; size > 0; size--)
|
||||
{
|
||||
rt_hw_mmu_setmtt(mdesc->vaddr_start, mdesc->vaddr_end,
|
||||
mdesc->paddr_start, mdesc->attr);
|
||||
mdesc++;
|
||||
}
|
||||
}
|
||||
|
||||
void rt_hw_mmu_init(void)
|
||||
{
|
||||
rt_cpu_dcache_clean_flush();
|
||||
rt_cpu_icache_flush();
|
||||
rt_hw_cpu_dcache_disable();
|
||||
rt_hw_cpu_icache_disable();
|
||||
rt_cpu_mmu_disable();
|
||||
|
||||
/* set page table */
|
||||
/* 4G 1:1 memory */
|
||||
rt_hw_mmu_setmtt(0, 0xffffffff-1, 0, RW_CB);
|
||||
/* IO memory region */
|
||||
rt_hw_mmu_setmtt(0x44000000, 0x80000000-1, 0x44000000, RW_NCNBXN);
|
||||
|
||||
/*rt_hw_cpu_dump_page_table(MMUTable);*/
|
||||
rt_hw_set_domain_register(0x55555555);
|
||||
|
||||
|
||||
@@ -50,13 +50,17 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
|
||||
*(--stk) = 0xdeadbeef; /* r2 */
|
||||
*(--stk) = 0xdeadbeef; /* r1 */
|
||||
*(--stk) = (rt_uint32_t)parameter; /* r0 : argument */
|
||||
|
||||
/* cpsr */
|
||||
if ((rt_uint32_t)tentry & 0x01)
|
||||
*(--stk) = SVCMODE | 0x20; /* thumb mode */
|
||||
else
|
||||
*(--stk) = SVCMODE; /* arm mode */
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
*(--stk) = 0; /* user lr */
|
||||
*(--stk) = 0; /* user sp*/
|
||||
#endif
|
||||
|
||||
/* return task's current stack address */
|
||||
return (rt_uint8_t *)stk;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,11 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2013-07-05 Bernard the first version
|
||||
* 2018-11-22 Jesven in the interrupt context, use rt_scheduler_do_irq_switch checks
|
||||
* and switches to a new thread
|
||||
*/
|
||||
|
||||
#include "rtconfig.h"
|
||||
.equ Mode_USR, 0x10
|
||||
.equ Mode_FIQ, 0x11
|
||||
.equ Mode_IRQ, 0x12
|
||||
@@ -20,11 +23,11 @@
|
||||
.equ F_Bit, 0x40 @ when F bit is set, FIQ is disabled
|
||||
|
||||
.equ UND_Stack_Size, 0x00000000
|
||||
.equ SVC_Stack_Size, 0x00000100
|
||||
.equ SVC_Stack_Size, 0x00000400
|
||||
.equ ABT_Stack_Size, 0x00000000
|
||||
.equ RT_FIQ_STACK_PGSZ, 0x00000000
|
||||
.equ RT_IRQ_STACK_PGSZ, 0x00000100
|
||||
.equ USR_Stack_Size, 0x00000100
|
||||
.equ RT_IRQ_STACK_PGSZ, 0x00000800
|
||||
.equ USR_Stack_Size, 0x00000400
|
||||
|
||||
#define ISR_Stack_Size (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \
|
||||
RT_FIQ_STACK_PGSZ + RT_IRQ_STACK_PGSZ)
|
||||
@@ -44,12 +47,13 @@ stack_top:
|
||||
/* reset entry */
|
||||
.globl _reset
|
||||
_reset:
|
||||
bl rt_cpu_mmu_disable
|
||||
/* set the cpu to SVC32 mode and disable interrupt */
|
||||
mrs r0, cpsr
|
||||
bic r0, r0, #0x1f
|
||||
orr r0, r0, #0x13
|
||||
msr cpsr_c, r0
|
||||
cps #Mode_SVC
|
||||
|
||||
/* disable the data alignment check */
|
||||
mrc p15, 0, r1, c1, c0, 0
|
||||
bic r1, #(1<<1)
|
||||
mcr p15, 0, r1, c1, c0, 0
|
||||
|
||||
/* setup stack */
|
||||
bl stack_setup
|
||||
@@ -64,6 +68,20 @@ bss_loop:
|
||||
strlo r0,[r1],#4 /* clear 4 bytes */
|
||||
blo bss_loop /* loop until done */
|
||||
|
||||
#ifdef RT_USING_SMP
|
||||
mrc p15, 0, r1, c1, c0, 1
|
||||
mov r0, #(1<<6)
|
||||
orr r1, r0
|
||||
mcr p15, 0, r1, c1, c0, 1 //enable smp
|
||||
#endif
|
||||
|
||||
/* initialize the mmu table and enable mmu */
|
||||
ldr r0, =platform_mem_desc
|
||||
ldr r1, =platform_mem_desc_size
|
||||
ldr r1, [r1]
|
||||
bl rt_hw_init_mmu_table
|
||||
bl rt_hw_mmu_init
|
||||
|
||||
/* call C++ constructors of global objects */
|
||||
ldr r0, =__ctors_start__
|
||||
ldr r1, =__ctors_end__
|
||||
@@ -137,6 +155,44 @@ vector_fiq:
|
||||
.align 5
|
||||
.globl vector_irq
|
||||
vector_irq:
|
||||
#ifdef RT_USING_SMP
|
||||
clrex
|
||||
|
||||
stmfd sp!, {r0, r1}
|
||||
cps #Mode_SVC
|
||||
mov r0, sp /* svc_sp */
|
||||
mov r1, lr /* svc_lr */
|
||||
|
||||
cps #Mode_IRQ
|
||||
sub lr, #4
|
||||
stmfd r0!, {r1, lr} /* svc_lr, svc_pc */
|
||||
stmfd r0!, {r2 - r12}
|
||||
ldmfd sp!, {r1, r2} /* original r0, r1 */
|
||||
stmfd r0!, {r1 - r2}
|
||||
mrs r1, spsr /* original mode */
|
||||
stmfd r0!, {r1}
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
stmfd r0, {r13, r14}^ /* usr_sp, usr_lr */
|
||||
sub r0, #8
|
||||
#endif
|
||||
/* now irq stack is clean */
|
||||
/* r0 is task svc_sp */
|
||||
/* backup r0 -> r8 */
|
||||
mov r8, r0
|
||||
|
||||
bl rt_interrupt_enter
|
||||
bl rt_hw_trap_irq
|
||||
bl rt_interrupt_leave
|
||||
|
||||
cps #Mode_SVC
|
||||
mov sp, r8
|
||||
mov r0, r8
|
||||
bl rt_scheduler_do_irq_switch
|
||||
|
||||
b rt_hw_context_switch_exit
|
||||
|
||||
#else
|
||||
stmfd sp!, {r0-r12,lr}
|
||||
|
||||
bl rt_interrupt_enter
|
||||
@@ -174,6 +230,11 @@ rt_hw_context_switch_interrupt_do:
|
||||
stmfd sp!, {r1-r4} @ push old task's r0-r3
|
||||
stmfd sp!, {r0} @ push old task's cpsr
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
stmfd sp, {r13, r14}^ @push usr_sp, usr_lr
|
||||
sub sp, #8
|
||||
#endif
|
||||
|
||||
ldr r4, =rt_interrupt_from_thread
|
||||
ldr r5, [r4]
|
||||
str sp, [r5] @ store sp in preempted tasks's TCB
|
||||
@@ -182,11 +243,18 @@ rt_hw_context_switch_interrupt_do:
|
||||
ldr r6, [r6]
|
||||
ldr sp, [r6] @ get new task's stack pointer
|
||||
|
||||
#ifdef RT_USING_LWP
|
||||
ldmfd sp, {r13, r14}^ @pop usr_sp, usr_lr
|
||||
add sp, #8
|
||||
#endif
|
||||
|
||||
ldmfd sp!, {r4} @ pop new task's cpsr to spsr
|
||||
msr spsr_cxsf, r4
|
||||
|
||||
ldmfd sp!, {r0-r12,lr,pc}^ @ pop new task's r0-r12,lr & pc, copy spsr to cpsr
|
||||
|
||||
#endif
|
||||
|
||||
.macro push_svc_reg
|
||||
sub sp, sp, #17 * 4 @/* Sizeof(struct rt_hw_exp_stack) */
|
||||
stmia sp, {r0 - r12} @/* Calling r0-r12 */
|
||||
@@ -200,36 +268,84 @@ rt_hw_context_switch_interrupt_do:
|
||||
.endm
|
||||
|
||||
.align 5
|
||||
.globl vector_swi
|
||||
.weak vector_swi
|
||||
vector_swi:
|
||||
push_svc_reg
|
||||
bl rt_hw_trap_swi
|
||||
b .
|
||||
|
||||
.align 5
|
||||
.globl vector_undef
|
||||
.globl vector_undef
|
||||
vector_undef:
|
||||
push_svc_reg
|
||||
bl rt_hw_trap_undef
|
||||
b .
|
||||
|
||||
.align 5
|
||||
.globl vector_pabt
|
||||
.globl vector_pabt
|
||||
vector_pabt:
|
||||
push_svc_reg
|
||||
bl rt_hw_trap_pabt
|
||||
b .
|
||||
|
||||
.align 5
|
||||
.globl vector_dabt
|
||||
.globl vector_dabt
|
||||
vector_dabt:
|
||||
push_svc_reg
|
||||
bl rt_hw_trap_dabt
|
||||
b .
|
||||
|
||||
.align 5
|
||||
.globl vector_resv
|
||||
.globl vector_resv
|
||||
vector_resv:
|
||||
push_svc_reg
|
||||
bl rt_hw_trap_resv
|
||||
b .
|
||||
|
||||
#ifdef RT_USING_SMP
|
||||
.global set_secondary_cpu_boot_address
|
||||
set_secondary_cpu_boot_address:
|
||||
ldr r0, =secondary_cpu_start
|
||||
|
||||
mvn r1, #0 //0xffffffff
|
||||
ldr r2, =0x10000034
|
||||
str r1, [r2]
|
||||
str r0, [r2, #-4]
|
||||
mov pc, lr
|
||||
|
||||
.global secondary_cpu_start
|
||||
secondary_cpu_start:
|
||||
mrc p15, 0, r1, c1, c0, 1
|
||||
mov r0, #(1<<6)
|
||||
orr r1, r0
|
||||
mcr p15, 0, r1, c1, c0, 1 //enable smp
|
||||
|
||||
mrc p15, 0, r0, c1, c0, 0
|
||||
bic r0, #(1<<13)
|
||||
mcr p15, 0, r0, c1, c0, 0
|
||||
|
||||
cps #Mode_IRQ
|
||||
ldr sp, =irq_stack_2_limit
|
||||
|
||||
cps #Mode_FIQ
|
||||
ldr sp, =irq_stack_2_limit
|
||||
|
||||
cps #Mode_SVC
|
||||
ldr sp, =svc_stack_2_limit
|
||||
|
||||
/* initialize the mmu table and enable mmu */
|
||||
bl rt_hw_mmu_init
|
||||
|
||||
b secondary_cpu_c_start
|
||||
#endif
|
||||
|
||||
.bss
|
||||
.align 2 //align to 2~2=4
|
||||
svc_stack_2:
|
||||
.space (1 << 10)
|
||||
svc_stack_2_limit:
|
||||
|
||||
irq_stack_2:
|
||||
.space (1 << 10)
|
||||
irq_stack_2_limit:
|
||||
|
||||
|
||||
@@ -13,10 +13,8 @@
|
||||
#include <board.h>
|
||||
|
||||
#include "armv7.h"
|
||||
#include "interrupt.h"
|
||||
|
||||
#include "gic.h"
|
||||
|
||||
extern struct rt_thread *rt_current_thread;
|
||||
#ifdef RT_USING_FINSH
|
||||
extern long list_thread(void);
|
||||
#endif
|
||||
@@ -130,48 +128,52 @@ void rt_hw_trap_resv(struct rt_hw_exp_stack *regs)
|
||||
void rt_hw_trap_irq(void)
|
||||
{
|
||||
void *param;
|
||||
int ir;
|
||||
rt_isr_handler_t isr_func;
|
||||
extern struct rt_irq_desc isr_table[];
|
||||
|
||||
// vectNum = RESERVED[31:13] | CPUID[12:10] | INTERRUPT_ID[9:0]
|
||||
// send ack and get ID source
|
||||
uint32_t vectNum = gic_read_irq_ack();
|
||||
ir = rt_hw_interrupt_get_irq();
|
||||
|
||||
// Check that INT_ID isn't 1023 or 1022 (spurious interrupt)
|
||||
if (vectNum & 0x0200)
|
||||
if (ir == 1023)
|
||||
{
|
||||
gic_write_end_of_irq(vectNum); // send end of irq
|
||||
/* Spurious interrupt */
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// copy the local value to the global image of CPUID
|
||||
unsigned cpu = (vectNum >> 10) & 0x7;
|
||||
unsigned irq = vectNum & 0x1FF;
|
||||
|
||||
/* skip warning */
|
||||
cpu = cpu;
|
||||
|
||||
// Call the service routine stored in the handlers array. If there isn't
|
||||
// one for this IRQ, then call the default handler.
|
||||
/* get interrupt service routine */
|
||||
isr_func = isr_table[irq].handler;
|
||||
/* get interrupt service routine */
|
||||
isr_func = isr_table[ir].handler;
|
||||
#ifdef RT_USING_INTERRUPT_INFO
|
||||
isr_table[irq].counter++;
|
||||
isr_table[ir].counter++;
|
||||
#endif
|
||||
if (isr_func)
|
||||
{
|
||||
/* Interrupt for myself. */
|
||||
param = isr_table[irq].param;
|
||||
/* turn to interrupt service routine */
|
||||
isr_func(irq, param);
|
||||
}
|
||||
|
||||
// Signal the end of the irq.
|
||||
gic_write_end_of_irq(vectNum);
|
||||
if (isr_func)
|
||||
{
|
||||
/* Interrupt for myself. */
|
||||
param = isr_table[ir].param;
|
||||
/* turn to interrupt service routine */
|
||||
isr_func(ir, param);
|
||||
}
|
||||
|
||||
/* end of interrupt */
|
||||
rt_hw_interrupt_ack(ir);
|
||||
}
|
||||
|
||||
void rt_hw_trap_fiq(void)
|
||||
{
|
||||
/* TODO */
|
||||
void *param;
|
||||
int ir;
|
||||
rt_isr_handler_t isr_func;
|
||||
extern struct rt_irq_desc isr_table[];
|
||||
|
||||
ir = rt_hw_interrupt_get_irq();
|
||||
|
||||
/* get interrupt service routine */
|
||||
isr_func = isr_table[ir].handler;
|
||||
param = isr_table[ir].param;
|
||||
|
||||
/* turn to interrupt service routine */
|
||||
isr_func(ir, param);
|
||||
|
||||
/* end of interrupt */
|
||||
rt_hw_interrupt_ack(ir);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
;/*
|
||||
; * File : context_iar.S
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2009, RT-Thread Development Team
|
||||
; * Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
; *
|
||||
; * The license and distribution terms for this file may be
|
||||
; * found in the file LICENSE in this distribution or at
|
||||
; * http://www.rt-thread.org/license/LICENSE
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Change Logs:
|
||||
; * Date Author Notes
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
;/*
|
||||
; * File : context_rvds.S
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2009, RT-Thread Development Team
|
||||
; * Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
; *
|
||||
; * The license and distribution terms for this file may be
|
||||
; * found in the file LICENSE in this distribution or at
|
||||
; * http://www.rt-thread.org/license/LICENSE
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Change Logs:
|
||||
; * Date Author Notes
|
||||
|
||||
@@ -114,3 +114,22 @@ void rt_hw_hard_fault_exception(struct exception_stack_frame *contex)
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
#define SCB_CFSR (*(volatile const unsigned *)0xE000ED28) /* Configurable Fault Status Register */
|
||||
#define SCB_HFSR (*(volatile const unsigned *)0xE000ED2C) /* HardFault Status Register */
|
||||
#define SCB_MMAR (*(volatile const unsigned *)0xE000ED34) /* MemManage Fault Address register */
|
||||
#define SCB_BFAR (*(volatile const unsigned *)0xE000ED38) /* Bus Fault Address Register */
|
||||
#define SCB_AIRCR (*(volatile unsigned long *)0xE000ED00) /* Reset control Address Register */
|
||||
#define SCB_RESET_VALUE 0x05FA0004 /* Reset value, write to SCB_AIRCR can reset cpu */
|
||||
|
||||
#define SCB_CFSR_MFSR (*(volatile const unsigned char*)0xE000ED28) /* Memory-management Fault Status Register */
|
||||
#define SCB_CFSR_BFSR (*(volatile const unsigned char*)0xE000ED29) /* Bus Fault Status Register */
|
||||
#define SCB_CFSR_UFSR (*(volatile const unsigned short*)0xE000ED2A) /* Usage Fault Status Register */
|
||||
|
||||
/**
|
||||
* reset CPU
|
||||
*/
|
||||
RT_WEAK void rt_hw_cpu_reset(void)
|
||||
{
|
||||
SCB_AIRCR = SCB_RESET_VALUE;//((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |SCB_AIRCR_SYSRESETREQ_Msk);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
;/*
|
||||
; * File : context_iar.S
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
|
||||
; * Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
; *
|
||||
; * The license and distribution terms for this file may be
|
||||
; * found in the file LICENSE in this distribution or at
|
||||
; * http://www.rt-thread.org/license/LICENSE
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Change Logs:
|
||||
; * Date Author Notes
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
;/*
|
||||
; * File : context_rvds.S
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
|
||||
; * Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
; *
|
||||
; * The license and distribution terms for this file may be
|
||||
; * found in the file LICENSE in this distribution or at
|
||||
; * http://www.rt-thread.org/license/LICENSE
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Change Logs:
|
||||
; * Date Author Notes
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
;/*
|
||||
; * File : context_iar.S
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
|
||||
; * Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
; *
|
||||
; * The license and distribution terms for this file may be
|
||||
; * found in the file LICENSE in this distribution or at
|
||||
; * http://www.rt-thread.org/license/LICENSE
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Change Logs:
|
||||
; * Date Author Notes
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
;/*
|
||||
; * File : context_iar.S
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
|
||||
; * Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
; *
|
||||
; * The license and distribution terms for this file may be
|
||||
; * found in the file LICENSE in this distribution or at
|
||||
; * http://www.rt-thread.org/license/LICENSE
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Change Logs:
|
||||
; * Date Author Notes
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
;/*
|
||||
; * File : context_rvds.S
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
|
||||
; * Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
; *
|
||||
; * The license and distribution terms for this file may be
|
||||
; * found in the file LICENSE in this distribution or at
|
||||
; * http://www.rt-thread.org/license/LICENSE
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Change Logs:
|
||||
; * Date Author Notes
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
;/*
|
||||
; * File : context_ccs.asm
|
||||
; * This file is part of RT-Thread RTOS
|
||||
; * COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||
; * Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
; *
|
||||
; * The license and distribution terms for this file may be
|
||||
; * found in the file LICENSE in this distribution or at
|
||||
; * http://www.rt-thread.org/license/LICENSE
|
||||
; * SPDX-License-Identifier: Apache-2.0
|
||||
; *
|
||||
; * Change Logs:
|
||||
; * Date Author Notes
|
||||
; * Date Author Notes
|
||||
; * 2009-01-20 Bernard first version
|
||||
; * 2011-07-22 Bernard added thumb mode porting
|
||||
; * 2013-05-24 Grissiom port to CCS
|
||||
|
||||
@@ -86,7 +86,7 @@ void rt_hw_interrupt_umask(int vector)
|
||||
* @return the old handler
|
||||
*/
|
||||
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
|
||||
void *param, char *name)
|
||||
void *param, const char *name)
|
||||
{
|
||||
rt_isr_handler_t old_handler = RT_NULL;
|
||||
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018/10/02 Bernard The first version
|
||||
*/
|
||||
|
||||
#include "cpuport.h"
|
||||
|
||||
.section .text.entry
|
||||
.align 2
|
||||
.global trap_entry
|
||||
trap_entry:
|
||||
|
||||
/* save all from thread context */
|
||||
addi sp, sp, -32 * REGBYTES
|
||||
|
||||
STORE x1, 1 * REGBYTES(sp)
|
||||
li t0, 0x80
|
||||
STORE t0, 2 * REGBYTES(sp)
|
||||
|
||||
STORE x4, 4 * REGBYTES(sp)
|
||||
STORE x5, 5 * REGBYTES(sp)
|
||||
STORE x6, 6 * REGBYTES(sp)
|
||||
STORE x7, 7 * REGBYTES(sp)
|
||||
STORE x8, 8 * REGBYTES(sp)
|
||||
STORE x9, 9 * REGBYTES(sp)
|
||||
STORE x10, 10 * REGBYTES(sp)
|
||||
STORE x11, 11 * REGBYTES(sp)
|
||||
STORE x12, 12 * REGBYTES(sp)
|
||||
STORE x13, 13 * REGBYTES(sp)
|
||||
STORE x14, 14 * REGBYTES(sp)
|
||||
STORE x15, 15 * REGBYTES(sp)
|
||||
STORE x16, 16 * REGBYTES(sp)
|
||||
STORE x17, 17 * REGBYTES(sp)
|
||||
STORE x18, 18 * REGBYTES(sp)
|
||||
STORE x19, 19 * REGBYTES(sp)
|
||||
STORE x20, 20 * REGBYTES(sp)
|
||||
STORE x21, 21 * REGBYTES(sp)
|
||||
STORE x22, 22 * REGBYTES(sp)
|
||||
STORE x23, 23 * REGBYTES(sp)
|
||||
STORE x24, 24 * REGBYTES(sp)
|
||||
STORE x25, 25 * REGBYTES(sp)
|
||||
STORE x26, 26 * REGBYTES(sp)
|
||||
STORE x27, 27 * REGBYTES(sp)
|
||||
STORE x28, 28 * REGBYTES(sp)
|
||||
STORE x29, 29 * REGBYTES(sp)
|
||||
STORE x30, 30 * REGBYTES(sp)
|
||||
STORE x31, 31 * REGBYTES(sp)
|
||||
|
||||
/* save break thread stack to s0 */
|
||||
move s0, sp
|
||||
/* switch to interrupt stack */
|
||||
la sp, _sp
|
||||
|
||||
/* interrupt handle */
|
||||
call rt_interrupt_enter
|
||||
csrr a0, mcause
|
||||
csrr a1, mepc
|
||||
mv a2, sp
|
||||
call handle_trap
|
||||
call rt_interrupt_leave
|
||||
|
||||
/* switch to from_thread stack */
|
||||
move sp, s0
|
||||
|
||||
/* need to switch new thread */
|
||||
la s0, rt_thread_switch_interrupt_flag
|
||||
lw s2, 0(s0)
|
||||
beqz s2, spurious_interrupt
|
||||
sw zero, 0(s0)
|
||||
|
||||
csrr a0, mepc
|
||||
STORE a0, 0 * REGBYTES(sp)
|
||||
|
||||
la s0, rt_interrupt_from_thread
|
||||
LOAD s1, 0(s0)
|
||||
STORE sp, 0(s1)
|
||||
|
||||
la s0, rt_interrupt_to_thread
|
||||
LOAD s1, 0(s0)
|
||||
LOAD sp, 0(s1)
|
||||
|
||||
LOAD a0, 0 * REGBYTES(sp)
|
||||
csrw mepc, a0
|
||||
|
||||
spurious_interrupt:
|
||||
LOAD x1, 1 * REGBYTES(sp)
|
||||
|
||||
/* Remain in M-mode after mret */
|
||||
li t0, 0x00001800
|
||||
csrs mstatus, t0
|
||||
LOAD t0, 2 * REGBYTES(sp)
|
||||
csrs mstatus, t0
|
||||
|
||||
LOAD x4, 4 * REGBYTES(sp)
|
||||
LOAD x5, 5 * REGBYTES(sp)
|
||||
LOAD x6, 6 * REGBYTES(sp)
|
||||
LOAD x7, 7 * REGBYTES(sp)
|
||||
LOAD x8, 8 * REGBYTES(sp)
|
||||
LOAD x9, 9 * REGBYTES(sp)
|
||||
LOAD x10, 10 * REGBYTES(sp)
|
||||
LOAD x11, 11 * REGBYTES(sp)
|
||||
LOAD x12, 12 * REGBYTES(sp)
|
||||
LOAD x13, 13 * REGBYTES(sp)
|
||||
LOAD x14, 14 * REGBYTES(sp)
|
||||
LOAD x15, 15 * REGBYTES(sp)
|
||||
LOAD x16, 16 * REGBYTES(sp)
|
||||
LOAD x17, 17 * REGBYTES(sp)
|
||||
LOAD x18, 18 * REGBYTES(sp)
|
||||
LOAD x19, 19 * REGBYTES(sp)
|
||||
LOAD x20, 20 * REGBYTES(sp)
|
||||
LOAD x21, 21 * REGBYTES(sp)
|
||||
LOAD x22, 22 * REGBYTES(sp)
|
||||
LOAD x23, 23 * REGBYTES(sp)
|
||||
LOAD x24, 24 * REGBYTES(sp)
|
||||
LOAD x25, 25 * REGBYTES(sp)
|
||||
LOAD x26, 26 * REGBYTES(sp)
|
||||
LOAD x27, 27 * REGBYTES(sp)
|
||||
LOAD x28, 28 * REGBYTES(sp)
|
||||
LOAD x29, 29 * REGBYTES(sp)
|
||||
LOAD x30, 30 * REGBYTES(sp)
|
||||
LOAD x31, 31 * REGBYTES(sp)
|
||||
|
||||
addi sp, sp, 32 * REGBYTES
|
||||
mret
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
static rt_tick_t rt_tick = 0;
|
||||
|
||||
extern void rt_timer_check(void);
|
||||
|
||||
/**
|
||||
* This function will init system tick and set it to zero.
|
||||
* @ingroup SystemInit
|
||||
@@ -100,15 +98,20 @@ void rt_tick_increase(void)
|
||||
*
|
||||
* @return the calculated tick
|
||||
*/
|
||||
int rt_tick_from_millisecond(rt_int32_t ms)
|
||||
rt_tick_t rt_tick_from_millisecond(rt_int32_t ms)
|
||||
{
|
||||
int tick;
|
||||
rt_tick_t tick;
|
||||
|
||||
if (ms < 0)
|
||||
tick = RT_WAITING_FOREVER;
|
||||
{
|
||||
tick = (rt_tick_t)RT_WAITING_FOREVER;
|
||||
}
|
||||
else
|
||||
tick = (RT_TICK_PER_SECOND * ms + 999) / 1000;
|
||||
|
||||
{
|
||||
tick = RT_TICK_PER_SECOND * (ms / 1000);
|
||||
tick += (RT_TICK_PER_SECOND * (ms % 1000) + 999) / 1000;
|
||||
}
|
||||
|
||||
/* return the calculated tick */
|
||||
return tick;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,6 @@ extern int $Super$$main(void);
|
||||
/* re-define main function */
|
||||
int $Sub$$main(void)
|
||||
{
|
||||
rt_hw_interrupt_disable();
|
||||
rtthread_startup();
|
||||
return 0;
|
||||
}
|
||||
@@ -149,7 +148,6 @@ int __low_level_init(void)
|
||||
{
|
||||
// call IAR table copy function.
|
||||
__iar_data_init3();
|
||||
rt_hw_interrupt_disable();
|
||||
rtthread_startup();
|
||||
return 0;
|
||||
}
|
||||
@@ -158,7 +156,6 @@ extern int main(void);
|
||||
/* Add -eentry to arm-none-eabi-gcc argument */
|
||||
int entry(void)
|
||||
{
|
||||
rt_hw_interrupt_disable();
|
||||
rtthread_startup();
|
||||
return 0;
|
||||
}
|
||||
|
||||
14
rt-thread/src/cpu.c
Normal file
14
rt-thread/src/cpu.c
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-10-30 Bernard The first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
|
||||
/* nothing on non-smp version */
|
||||
@@ -186,6 +186,8 @@ void rt_thread_idle_excute(void)
|
||||
/* if it's a system object, not delete it */
|
||||
if (rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE)
|
||||
{
|
||||
/* detach this object */
|
||||
rt_object_detach((rt_object_t)thread);
|
||||
/* unlock scheduler */
|
||||
rt_exit_critical();
|
||||
|
||||
@@ -219,16 +221,15 @@ void rt_thread_idle_excute(void)
|
||||
}
|
||||
}
|
||||
|
||||
extern void rt_system_power_manager(void);
|
||||
static void rt_thread_idle_entry(void *parameter)
|
||||
{
|
||||
#ifdef RT_USING_IDLE_HOOK
|
||||
rt_size_t i;
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
#ifdef RT_USING_IDLE_HOOK
|
||||
rt_size_t i;
|
||||
|
||||
for (i = 0; i < RT_IDEL_HOOK_LIST_SIZE; i++)
|
||||
{
|
||||
if (idle_hook_list[i] != RT_NULL)
|
||||
@@ -239,6 +240,9 @@ static void rt_thread_idle_entry(void *parameter)
|
||||
#endif
|
||||
|
||||
rt_thread_idle_excute();
|
||||
#ifdef RT_USING_PM
|
||||
rt_system_power_manager();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -200,6 +200,7 @@ rt_err_t rt_sem_init(rt_sem_t sem,
|
||||
rt_uint8_t flag)
|
||||
{
|
||||
RT_ASSERT(sem != RT_NULL);
|
||||
RT_ASSERT(value < 0x10000U);
|
||||
|
||||
/* init object */
|
||||
rt_object_init(&(sem->parent.parent), RT_Object_Class_Semaphore, name);
|
||||
@@ -208,7 +209,7 @@ rt_err_t rt_sem_init(rt_sem_t sem,
|
||||
rt_ipc_object_init(&(sem->parent));
|
||||
|
||||
/* set init value */
|
||||
sem->value = value;
|
||||
sem->value = (rt_uint16_t)value;
|
||||
|
||||
/* set parent */
|
||||
sem->parent.parent.flag = flag;
|
||||
@@ -260,6 +261,7 @@ rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag)
|
||||
rt_sem_t sem;
|
||||
|
||||
RT_DEBUG_NOT_IN_INTERRUPT;
|
||||
RT_ASSERT(value < 0x10000U);
|
||||
|
||||
/* allocate object */
|
||||
sem = (rt_sem_t)rt_object_allocate(RT_Object_Class_Semaphore, name);
|
||||
@@ -750,8 +752,8 @@ __again:
|
||||
|
||||
if (thread->error != RT_EOK)
|
||||
{
|
||||
/* interrupt by signal, try it again */
|
||||
if (thread->error == -RT_EINTR) goto __again;
|
||||
/* interrupt by signal, try it again */
|
||||
if (thread->error == -RT_EINTR) goto __again;
|
||||
|
||||
/* return error */
|
||||
return thread->error;
|
||||
|
||||
@@ -133,20 +133,21 @@ void *rt_memset(void *s, int c, rt_ubase_t count)
|
||||
|
||||
return s;
|
||||
#else
|
||||
#define LBLOCKSIZE (sizeof(rt_int32_t))
|
||||
#define UNALIGNED(X) ((rt_int32_t)X & (LBLOCKSIZE - 1))
|
||||
#define LBLOCKSIZE (sizeof(long))
|
||||
#define UNALIGNED(X) ((long)X & (LBLOCKSIZE - 1))
|
||||
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE)
|
||||
|
||||
int i;
|
||||
unsigned int i;
|
||||
char *m = (char *)s;
|
||||
rt_uint32_t buffer;
|
||||
rt_uint32_t *aligned_addr;
|
||||
rt_uint32_t d = c & 0xff;
|
||||
unsigned long buffer;
|
||||
unsigned long *aligned_addr;
|
||||
unsigned int d = c & 0xff; /* To avoid sign extension, copy C to an
|
||||
unsigned variable. */
|
||||
|
||||
if (!TOO_SMALL(count) && !UNALIGNED(s))
|
||||
{
|
||||
/* If we get this far, we know that n is large and m is word-aligned. */
|
||||
aligned_addr = (rt_uint32_t *)s;
|
||||
aligned_addr = (unsigned long *)s;
|
||||
|
||||
/* Store D into each char sized location in BUFFER so that
|
||||
* we can set large blocks quickly.
|
||||
@@ -226,25 +227,24 @@ void *rt_memcpy(void *dst, const void *src, rt_ubase_t count)
|
||||
return dst;
|
||||
#else
|
||||
|
||||
#define UNALIGNED(X, Y) \
|
||||
(((rt_int32_t)X & (sizeof(rt_int32_t) - 1)) | \
|
||||
((rt_int32_t)Y & (sizeof(rt_int32_t) - 1)))
|
||||
#define BIGBLOCKSIZE (sizeof(rt_int32_t) << 2)
|
||||
#define LITTLEBLOCKSIZE (sizeof(rt_int32_t))
|
||||
#define UNALIGNED(X, Y) \
|
||||
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
|
||||
#define BIGBLOCKSIZE (sizeof (long) << 2)
|
||||
#define LITTLEBLOCKSIZE (sizeof (long))
|
||||
#define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE)
|
||||
|
||||
char *dst_ptr = (char *)dst;
|
||||
char *src_ptr = (char *)src;
|
||||
rt_int32_t *aligned_dst;
|
||||
rt_int32_t *aligned_src;
|
||||
long *aligned_dst;
|
||||
long *aligned_src;
|
||||
int len = count;
|
||||
|
||||
/* If the size is small, or either SRC or DST is unaligned,
|
||||
then punt into the byte copy loop. This should be rare. */
|
||||
if (!TOO_SMALL(len) && !UNALIGNED(src_ptr, dst_ptr))
|
||||
{
|
||||
aligned_dst = (rt_int32_t *)dst_ptr;
|
||||
aligned_src = (rt_int32_t *)src_ptr;
|
||||
aligned_dst = (long *)dst_ptr;
|
||||
aligned_src = (long *)src_ptr;
|
||||
|
||||
/* Copy 4X long words at a time if possible. */
|
||||
while (len >= BIGBLOCKSIZE)
|
||||
@@ -461,6 +461,7 @@ rt_int32_t rt_strcmp(const char *cs, const char *ct)
|
||||
return (*cs - *ct);
|
||||
}
|
||||
RTM_EXPORT(rt_strcmp);
|
||||
|
||||
/**
|
||||
* The strnlen() function returns the number of characters in the
|
||||
* string pointed to by s, excluding the terminating null byte ('\0'),
|
||||
@@ -476,11 +477,13 @@ rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen)
|
||||
{
|
||||
const char *sc;
|
||||
|
||||
for (sc = s; *sc != '\0' && sc - s < maxlen; ++sc) /* nothing */
|
||||
for (sc = s; *sc != '\0' && (rt_ubase_t)(sc - s) < maxlen; ++sc) /* nothing */
|
||||
;
|
||||
|
||||
return sc - s;
|
||||
}
|
||||
RTM_EXPORT(rt_strnlen);
|
||||
|
||||
/**
|
||||
* This function will return the length of a string, which terminate will
|
||||
* null character.
|
||||
@@ -535,31 +538,52 @@ void rt_show_version(void)
|
||||
rt_kprintf("- RT - Thread Operating System\n");
|
||||
rt_kprintf(" / | \\ %d.%d.%d build %s\n",
|
||||
RT_VERSION, RT_SUBVERSION, RT_REVISION, __DATE__);
|
||||
rt_kprintf(" 2006 - 2018 Copyright by rt-thread team\n");
|
||||
rt_kprintf(" 2006 - 2019 Copyright by rt-thread team\n");
|
||||
}
|
||||
RTM_EXPORT(rt_show_version);
|
||||
|
||||
/* private function */
|
||||
#define isdigit(c) ((unsigned)((c) - '0') < 10)
|
||||
|
||||
rt_inline rt_int32_t divide(rt_int32_t *n, rt_int32_t base)
|
||||
#ifdef RT_PRINTF_LONGLONG
|
||||
rt_inline int divide(long long *n, int base)
|
||||
{
|
||||
rt_int32_t res;
|
||||
int res;
|
||||
|
||||
/* optimized for processor which does not support divide instructions. */
|
||||
if (base == 10)
|
||||
{
|
||||
res = ((rt_uint32_t) * n) % 10U;
|
||||
*n = ((rt_uint32_t) * n) / 10U;
|
||||
res = (int)(((unsigned long long)*n) % 10U);
|
||||
*n = (long long)(((unsigned long long)*n) / 10U);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = ((rt_uint32_t) * n) % 16U;
|
||||
*n = ((rt_uint32_t) * n) / 16U;
|
||||
res = (int)(((unsigned long long)*n) % 16U);
|
||||
*n = (long long)(((unsigned long long)*n) / 16U);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
rt_inline int divide(long *n, int base)
|
||||
{
|
||||
int res;
|
||||
|
||||
/* optimized for processor which does not support divide instructions. */
|
||||
if (base == 10)
|
||||
{
|
||||
res = (int)(((unsigned long)*n) % 10U);
|
||||
*n = (long)(((unsigned long)*n) / 10U);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = (int)(((unsigned long)*n) % 16U);
|
||||
*n = (long)(((unsigned long)*n) / 16U);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
rt_inline int skip_atoi(const char **s)
|
||||
{
|
||||
@@ -581,7 +605,11 @@ rt_inline int skip_atoi(const char **s)
|
||||
#ifdef RT_PRINTF_PRECISION
|
||||
static char *print_number(char *buf,
|
||||
char *end,
|
||||
#ifdef RT_PRINTF_LONGLONG
|
||||
long long num,
|
||||
#else
|
||||
long num,
|
||||
#endif
|
||||
int base,
|
||||
int s,
|
||||
int precision,
|
||||
@@ -589,7 +617,11 @@ static char *print_number(char *buf,
|
||||
#else
|
||||
static char *print_number(char *buf,
|
||||
char *end,
|
||||
#ifdef RT_PRINTF_LONGLONG
|
||||
long long num,
|
||||
#else
|
||||
long num,
|
||||
#endif
|
||||
int base,
|
||||
int s,
|
||||
int type)
|
||||
@@ -601,6 +633,7 @@ static char *print_number(char *buf,
|
||||
#else
|
||||
char tmp[16];
|
||||
#endif
|
||||
int precision_bak = precision;
|
||||
const char *digits;
|
||||
static const char small_digits[] = "0123456789abcdef";
|
||||
static const char large_digits[] = "0123456789ABCDEF";
|
||||
@@ -664,7 +697,7 @@ static char *print_number(char *buf,
|
||||
|
||||
while (size-- > 0)
|
||||
{
|
||||
if (buf <= end)
|
||||
if (buf < end)
|
||||
*buf = ' ';
|
||||
++ buf;
|
||||
}
|
||||
@@ -672,11 +705,11 @@ static char *print_number(char *buf,
|
||||
|
||||
if (sign)
|
||||
{
|
||||
if (buf <= end)
|
||||
if (buf < end)
|
||||
{
|
||||
*buf = sign;
|
||||
-- size;
|
||||
}
|
||||
-- size;
|
||||
++ buf;
|
||||
}
|
||||
|
||||
@@ -685,16 +718,16 @@ static char *print_number(char *buf,
|
||||
{
|
||||
if (base == 8)
|
||||
{
|
||||
if (buf <= end)
|
||||
if (buf < end)
|
||||
*buf = '0';
|
||||
++ buf;
|
||||
}
|
||||
else if (base == 16)
|
||||
{
|
||||
if (buf <= end)
|
||||
if (buf < end)
|
||||
*buf = '0';
|
||||
++ buf;
|
||||
if (buf <= end)
|
||||
if (buf < end)
|
||||
{
|
||||
*buf = type & LARGE ? 'X' : 'x';
|
||||
}
|
||||
@@ -708,7 +741,7 @@ static char *print_number(char *buf,
|
||||
{
|
||||
while (size-- > 0)
|
||||
{
|
||||
if (buf <= end)
|
||||
if (buf < end)
|
||||
*buf = c;
|
||||
++ buf;
|
||||
}
|
||||
@@ -717,23 +750,23 @@ static char *print_number(char *buf,
|
||||
#ifdef RT_PRINTF_PRECISION
|
||||
while (i < precision--)
|
||||
{
|
||||
if (buf <= end)
|
||||
if (buf < end)
|
||||
*buf = '0';
|
||||
++ buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* put number in the temporary buffer */
|
||||
while (i-- > 0)
|
||||
while (i-- > 0 && (precision_bak != 0))
|
||||
{
|
||||
if (buf <= end)
|
||||
if (buf < end)
|
||||
*buf = tmp[i];
|
||||
++ buf;
|
||||
}
|
||||
|
||||
while (size-- > 0)
|
||||
{
|
||||
if (buf <= end)
|
||||
if (buf < end)
|
||||
*buf = ' ';
|
||||
++ buf;
|
||||
}
|
||||
@@ -765,7 +798,7 @@ rt_int32_t rt_vsnprintf(char *buf,
|
||||
#endif
|
||||
|
||||
str = buf;
|
||||
end = buf + size - 1;
|
||||
end = buf + size;
|
||||
|
||||
/* Make sure end is always >= buf */
|
||||
if (end < buf)
|
||||
@@ -778,7 +811,7 @@ rt_int32_t rt_vsnprintf(char *buf,
|
||||
{
|
||||
if (*fmt != '%')
|
||||
{
|
||||
if (str <= end)
|
||||
if (str < end)
|
||||
*str = *fmt;
|
||||
++ str;
|
||||
continue;
|
||||
@@ -859,20 +892,20 @@ rt_int32_t rt_vsnprintf(char *buf,
|
||||
{
|
||||
while (--field_width > 0)
|
||||
{
|
||||
if (str <= end) *str = ' ';
|
||||
if (str < end) *str = ' ';
|
||||
++ str;
|
||||
}
|
||||
}
|
||||
|
||||
/* get character */
|
||||
c = (rt_uint8_t)va_arg(args, int);
|
||||
if (str <= end) *str = c;
|
||||
if (str < end) *str = c;
|
||||
++ str;
|
||||
|
||||
/* put width */
|
||||
while (--field_width > 0)
|
||||
{
|
||||
if (str <= end) *str = ' ';
|
||||
if (str < end) *str = ' ';
|
||||
++ str;
|
||||
}
|
||||
continue;
|
||||
@@ -890,21 +923,21 @@ rt_int32_t rt_vsnprintf(char *buf,
|
||||
{
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (str <= end) *str = ' ';
|
||||
if (str < end) *str = ' ';
|
||||
++ str;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
if (str <= end) *str = *s;
|
||||
if (str < end) *str = *s;
|
||||
++ str;
|
||||
++ s;
|
||||
}
|
||||
|
||||
while (len < field_width--)
|
||||
{
|
||||
if (str <= end) *str = ' ';
|
||||
if (str < end) *str = ' ';
|
||||
++ str;
|
||||
}
|
||||
continue;
|
||||
@@ -927,7 +960,7 @@ rt_int32_t rt_vsnprintf(char *buf,
|
||||
continue;
|
||||
|
||||
case '%':
|
||||
if (str <= end) *str = '%';
|
||||
if (str < end) *str = '%';
|
||||
++ str;
|
||||
continue;
|
||||
|
||||
@@ -949,12 +982,12 @@ rt_int32_t rt_vsnprintf(char *buf,
|
||||
break;
|
||||
|
||||
default:
|
||||
if (str <= end) *str = '%';
|
||||
if (str < end) *str = '%';
|
||||
++ str;
|
||||
|
||||
if (*fmt)
|
||||
{
|
||||
if (str <= end) *str = *fmt;
|
||||
if (str < end) *str = *fmt;
|
||||
++ str;
|
||||
}
|
||||
else
|
||||
@@ -991,8 +1024,14 @@ rt_int32_t rt_vsnprintf(char *buf,
|
||||
#endif
|
||||
}
|
||||
|
||||
if (str <= end) *str = '\0';
|
||||
else *end = '\0';
|
||||
if (size > 0)
|
||||
{
|
||||
if (str < end) *str = '\0';
|
||||
else
|
||||
{
|
||||
end[-1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/* the trailing null byte doesn't count towards the total
|
||||
* ++str;
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
rt_err_t rt_memheap_init(struct rt_memheap *memheap,
|
||||
const char *name,
|
||||
void *start_addr,
|
||||
rt_uint32_t size)
|
||||
rt_size_t size)
|
||||
{
|
||||
struct rt_memheap_item *item;
|
||||
|
||||
@@ -135,7 +135,7 @@ rt_err_t rt_memheap_detach(struct rt_memheap *heap)
|
||||
}
|
||||
RTM_EXPORT(rt_memheap_detach);
|
||||
|
||||
void *rt_memheap_alloc(struct rt_memheap *heap, rt_uint32_t size)
|
||||
void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size)
|
||||
{
|
||||
rt_err_t result;
|
||||
rt_uint32_t free_size;
|
||||
|
||||
@@ -240,6 +240,7 @@ void rt_object_init(struct rt_object *object,
|
||||
const char *name)
|
||||
{
|
||||
register rt_base_t temp;
|
||||
struct rt_list_node *node = RT_NULL;
|
||||
struct rt_object_information *information;
|
||||
#ifdef RT_USING_MODULE
|
||||
struct rt_dlmodule *module = dlmodule_self();
|
||||
@@ -249,11 +250,26 @@ void rt_object_init(struct rt_object *object,
|
||||
information = rt_object_get_information(type);
|
||||
RT_ASSERT(information != RT_NULL);
|
||||
|
||||
/* initialize object's parameters */
|
||||
/* check object type to avoid re-initialization */
|
||||
|
||||
/* enter critical */
|
||||
rt_enter_critical();
|
||||
/* try to find object */
|
||||
for (node = information->object_list.next;
|
||||
node != &(information->object_list);
|
||||
node = node->next)
|
||||
{
|
||||
struct rt_object *obj;
|
||||
|
||||
obj = rt_list_entry(node, struct rt_object, list);
|
||||
RT_ASSERT(obj != object);
|
||||
}
|
||||
/* leave critical */
|
||||
rt_exit_critical();
|
||||
|
||||
/* initialize object's parameters */
|
||||
/* set object type to static */
|
||||
object->type = type | RT_Object_Class_Static;
|
||||
|
||||
/* copy name */
|
||||
rt_strncpy(object->name, name, RT_NAME_MAX);
|
||||
|
||||
|
||||
@@ -74,7 +74,11 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread)
|
||||
{
|
||||
RT_ASSERT(thread != RT_NULL);
|
||||
|
||||
#if defined(ARCH_CPU_STACK_GROWS_UPWARD)
|
||||
if (*((rt_uint8_t *)((rt_ubase_t)thread->stack_addr + thread->stack_size - 1)) != '#' ||
|
||||
#else
|
||||
if (*((rt_uint8_t *)thread->stack_addr) != '#' ||
|
||||
#endif
|
||||
(rt_uint32_t)thread->sp <= (rt_uint32_t)thread->stack_addr ||
|
||||
(rt_uint32_t)thread->sp >
|
||||
(rt_uint32_t)thread->stack_addr + (rt_uint32_t)thread->stack_size)
|
||||
@@ -234,18 +238,29 @@ void rt_schedule(void)
|
||||
|
||||
if (rt_interrupt_nest == 0)
|
||||
{
|
||||
extern void rt_thread_handle_sig(rt_bool_t clean_state);
|
||||
|
||||
rt_hw_context_switch((rt_uint32_t)&from_thread->sp,
|
||||
(rt_uint32_t)&to_thread->sp);
|
||||
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(level);
|
||||
|
||||
#ifdef RT_USING_SIGNALS
|
||||
/* check signal status */
|
||||
rt_thread_handle_sig(RT_TRUE);
|
||||
if (rt_current_thread->stat & RT_THREAD_STAT_SIGNAL_PENDING)
|
||||
{
|
||||
extern void rt_thread_handle_sig(rt_bool_t clean_state);
|
||||
|
||||
rt_current_thread->stat &= ~RT_THREAD_STAT_SIGNAL_PENDING;
|
||||
|
||||
rt_hw_interrupt_enable(level);
|
||||
|
||||
/* check signal status */
|
||||
rt_thread_handle_sig(RT_TRUE);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -253,21 +268,12 @@ void rt_schedule(void)
|
||||
|
||||
rt_hw_context_switch_interrupt((rt_uint32_t)&from_thread->sp,
|
||||
(rt_uint32_t)&to_thread->sp);
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -397,14 +403,17 @@ void rt_exit_critical(void)
|
||||
level = rt_hw_interrupt_disable();
|
||||
|
||||
rt_scheduler_lock_nest --;
|
||||
|
||||
if (rt_scheduler_lock_nest <= 0)
|
||||
{
|
||||
rt_scheduler_lock_nest = 0;
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(level);
|
||||
|
||||
rt_schedule();
|
||||
if (rt_current_thread)
|
||||
{
|
||||
/* if scheduler is started, do a schedule */
|
||||
rt_schedule();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -398,10 +398,10 @@ void rt_system_heap_init(void *begin_addr, void *end_addr)
|
||||
* Calculate the zone index for the allocation request size and set the
|
||||
* allocation request size to that particular zone's chunk size.
|
||||
*/
|
||||
rt_inline int zoneindex(rt_uint32_t *bytes)
|
||||
rt_inline int zoneindex(rt_size_t *bytes)
|
||||
{
|
||||
/* unsigned for shift opt */
|
||||
rt_uint32_t n = (rt_uint32_t) * bytes;
|
||||
rt_uint32_t n = (rt_uint32_t)(*bytes);
|
||||
|
||||
if (n < 128)
|
||||
{
|
||||
|
||||
@@ -326,17 +326,17 @@ rt_err_t rt_thread_detach(rt_thread_t thread)
|
||||
/* change stat */
|
||||
thread->stat = RT_THREAD_CLOSE;
|
||||
|
||||
/* detach object */
|
||||
rt_object_detach((rt_object_t)thread);
|
||||
|
||||
if (thread->cleanup != RT_NULL)
|
||||
if ((rt_object_is_systemobject((rt_object_t)thread) == RT_TRUE) &&
|
||||
thread->cleanup == RT_NULL)
|
||||
{
|
||||
rt_object_detach((rt_object_t)thread);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* disable interrupt */
|
||||
lock = rt_hw_interrupt_disable();
|
||||
|
||||
/* insert to defunct thread list */
|
||||
rt_list_insert_after(&rt_thread_defunct, &(thread->tlist));
|
||||
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(lock);
|
||||
}
|
||||
@@ -345,7 +345,6 @@ rt_err_t rt_thread_detach(rt_thread_t thread)
|
||||
}
|
||||
RTM_EXPORT(rt_thread_detach);
|
||||
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
/**
|
||||
* This function will create a thread object and allocate thread object memory
|
||||
|
||||
Reference in New Issue
Block a user