From 40f55ec57b5dfed47fb39b904a7e998d33da82a7 Mon Sep 17 00:00:00 2001 From: daishengdong Date: Fri, 28 Feb 2020 00:11:28 +0800 Subject: [PATCH] support posix 1. posix pthread.h: pthread, pthread_barrier, pthread_cond, pthread_mutex, , pthread_rwlock, pthread_spin, etc 2. posix semaphore.h: sem_* 3. posix mqueue.h: mq_* 4. posix time.h: timer_* 5. to support posix, add tos_barrier, tos_bitmap, tos_rwlock, tos_stopwatch, change name of k_task_t from a char * pointer to a char array. 6. sample, see examples\posix 7. project, see board\TencentOS_tiny_EVB_MX_Plus\KEIL\posix --- .../TencentOS_tiny_STM32L431RCTx.dbgconf | 97 + .../KEIL/posix/EventRecorderStub.scvd | 9 + .../RTE/_TencentOS_tiny/RTE_Components.h | 20 + .../KEIL/posix/TencentOS_tiny.uvoptx | 1331 ++++++++ .../KEIL/posix/TencentOS_tiny.uvprojx | 867 +++++ .../posix/obj/TencentOS_tiny.build_log.htm | 140 + .../KEIL/posix/obj/TencentOS_tiny.htm | 3008 +++++++++++++++++ .../KEIL/posix/obj/TencentOS_tiny.sct | 16 + .../KEIL/posix/startup_stm32l431xx.s | 404 +++ examples/posix/posix_sample.c | 136 + kernel/core/include/tos_barrier.h | 89 + kernel/core/include/tos_binary_heap.h | 4 + kernel/core/include/tos_bitmap.h | 155 + kernel/core/include/tos_char_fifo.h | 6 +- kernel/core/include/tos_compiler.h | 19 +- kernel/core/include/tos_completion.h | 6 +- kernel/core/include/tos_config_default.h | 26 - kernel/core/include/tos_countdownlatch.h | 6 +- kernel/core/include/tos_err.h | 21 +- kernel/core/include/tos_event.h | 4 + kernel/core/include/tos_k.h | 6 +- kernel/core/include/tos_klib.h | 66 +- kernel/core/include/tos_ktypes.h | 1 + kernel/core/include/tos_list.h | 4 + kernel/core/include/tos_mail_queue.h | 4 + kernel/core/include/tos_message_queue.h | 4 + kernel/core/include/tos_mmblk.h | 4 + kernel/core/include/tos_mmheap.h | 4 + kernel/core/include/tos_mutex.h | 4 + kernel/core/include/tos_pend.h | 4 + kernel/core/include/tos_priority_mail_queue.h | 4 + .../core/include/tos_priority_message_queue.h | 4 + kernel/core/include/tos_priority_queue.h | 4 + kernel/core/include/tos_robin.h | 4 + kernel/core/include/tos_rwlock.h | 192 ++ kernel/core/include/tos_sched.h | 4 + kernel/core/include/tos_sem.h | 4 + kernel/core/include/tos_slist.h | 4 + kernel/core/include/tos_stopwatch.h | 141 + kernel/core/include/tos_sys.h | 45 +- kernel/core/include/tos_task.h | 59 +- kernel/core/include/tos_tick.h | 4 + kernel/core/include/tos_time.h | 4 + kernel/core/include/tos_timer.h | 4 + kernel/core/tos_barrier.c | 111 + kernel/core/tos_bitmap.c | 143 + kernel/core/tos_completion.c | 10 +- kernel/core/tos_countdownlatch.c | 10 +- kernel/core/tos_event.c | 6 +- kernel/core/tos_mail_queue.c | 1 + kernel/core/tos_message_queue.c | 1 + kernel/core/tos_priority_mail_queue.c | 1 + kernel/core/tos_priority_message_queue.c | 1 + kernel/core/tos_rwlock.c | 326 ++ kernel/core/tos_sem.c | 6 +- kernel/core/tos_stopwatch.c | 123 + kernel/core/tos_task.c | 21 +- osal/posix/include/errno.h | 267 ++ osal/posix/include/mqueue.h | 53 + osal/posix/include/private/mqueue.h | 47 + osal/posix/include/private/posix_config.h | 48 + .../include/private/posix_config_check.h | 61 + .../include/private/posix_config_default.h | 74 + osal/posix/include/private/pthread.h | 119 + osal/posix/include/private/time.h | 36 + osal/posix/include/private/timer.h | 50 + osal/posix/include/pthread.h | 189 ++ osal/posix/include/sched.h | 47 + osal/posix/include/semaphore.h | 45 + osal/posix/include/signal.h | 37 + osal/posix/include/sys/time.h | 62 + osal/posix/include/sys/types.h | 131 + osal/posix/include/time.h | 87 + osal/posix/include/tos_posix.h | 30 + osal/posix/mqueue.c | 173 + osal/posix/mqueue_prv.c | 98 + osal/posix/pthread.c | 1605 +++++++++ osal/posix/pthread_prv.c | 302 ++ osal/posix/sched.c | 105 + osal/posix/semaphore.c | 137 + osal/posix/time.c | 180 + osal/posix/time_prv.c | 54 + osal/posix/timer_prv.c | 97 + osal/posix/tos_posix.c | 26 + 84 files changed, 11704 insertions(+), 158 deletions(-) create mode 100644 board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/DebugConfig/TencentOS_tiny_STM32L431RCTx.dbgconf create mode 100644 board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/EventRecorderStub.scvd create mode 100644 board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/RTE/_TencentOS_tiny/RTE_Components.h create mode 100644 board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/TencentOS_tiny.uvoptx create mode 100644 board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/TencentOS_tiny.uvprojx create mode 100644 board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/obj/TencentOS_tiny.build_log.htm create mode 100644 board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/obj/TencentOS_tiny.htm create mode 100644 board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/obj/TencentOS_tiny.sct create mode 100644 board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/startup_stm32l431xx.s create mode 100644 examples/posix/posix_sample.c create mode 100644 kernel/core/include/tos_barrier.h create mode 100644 kernel/core/include/tos_bitmap.h create mode 100644 kernel/core/include/tos_rwlock.h create mode 100644 kernel/core/include/tos_stopwatch.h create mode 100644 kernel/core/tos_barrier.c create mode 100644 kernel/core/tos_bitmap.c create mode 100644 kernel/core/tos_rwlock.c create mode 100644 kernel/core/tos_stopwatch.c create mode 100644 osal/posix/include/errno.h create mode 100644 osal/posix/include/mqueue.h create mode 100644 osal/posix/include/private/mqueue.h create mode 100644 osal/posix/include/private/posix_config.h create mode 100644 osal/posix/include/private/posix_config_check.h create mode 100644 osal/posix/include/private/posix_config_default.h create mode 100644 osal/posix/include/private/pthread.h create mode 100644 osal/posix/include/private/time.h create mode 100644 osal/posix/include/private/timer.h create mode 100644 osal/posix/include/pthread.h create mode 100644 osal/posix/include/sched.h create mode 100644 osal/posix/include/semaphore.h create mode 100644 osal/posix/include/signal.h create mode 100644 osal/posix/include/sys/time.h create mode 100644 osal/posix/include/sys/types.h create mode 100644 osal/posix/include/time.h create mode 100644 osal/posix/include/tos_posix.h create mode 100644 osal/posix/mqueue.c create mode 100644 osal/posix/mqueue_prv.c create mode 100644 osal/posix/pthread.c create mode 100644 osal/posix/pthread_prv.c create mode 100644 osal/posix/sched.c create mode 100644 osal/posix/semaphore.c create mode 100644 osal/posix/time.c create mode 100644 osal/posix/time_prv.c create mode 100644 osal/posix/timer_prv.c create mode 100644 osal/posix/tos_posix.c diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/DebugConfig/TencentOS_tiny_STM32L431RCTx.dbgconf b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/DebugConfig/TencentOS_tiny_STM32L431RCTx.dbgconf new file mode 100644 index 00000000..c9811753 --- /dev/null +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/DebugConfig/TencentOS_tiny_STM32L431RCTx.dbgconf @@ -0,0 +1,97 @@ +// File: STM32L43x_44x_45x_46x.dbgconf +// Version: 1.0.0 +// Note: refer to STM32L43xxx STM32L44xxx STM32L45xxx STM32L46xxx Reference manual (RM0394) +// refer to STM32L431xx, STM32L432xx, STM32L433xx, STM32L442xx, STM32L443xx, STM32L451xx, STM32L452xx, STM32L462xx datasheets + +// <<< Use Configuration Wizard in Context Menu >>> + +// Debug MCU configuration register (DBGMCU_CR) +// DBG_STANDBY +// Debug Standby mode +// 0: (FCLK=Off, HCLK=Off) The whole digital part is unpowered. +// 1: (FCLK=On, HCLK=On) The digital part is not unpowered and FCLK and HCLK are provided by the internal RC oscillator which remains active +// DBG_STOP +// Debug Stop mode +// 0: (FCLK=Off, HCLK=Off) In STOP mode, the clock controller disables all clocks (including HCLK and FCLK). +// 1: (FCLK=On, HCLK=On) When entering STOP mode, FCLK and HCLK are provided by the internal RC oscillator which remains active in STOP mode. +// DBG_SLEEP +// Debug Sleep mode +// 0: (FCLK=On, HCLK=Off) In Sleep mode, FCLK is clocked by the system clock as previously configured by the software while HCLK is disabled. +// 1: (FCLK=On, HCLK=On) When entering Sleep mode, HCLK is fed by the same clock that is provided to FCLK (system clock as previously configured by the software). +// +DbgMCU_CR = 0x00000007; + +// Debug MCU APB1 freeze register1 (DBGMCU_APB1FZR1) +// DBG_LPTIM1_STOP +// LPTIM1 counter stopped when core is halted +// 0: The counter clock of LPTIM1 is fed even if the core is halted +// 1: The counter clock of LPTIM1 is stopped when the core is halted +// DBG_CAN_STOP +// bxCAN1 stopped when core is halted +// 0: Same behavior as in normal mode +// 1: The bxCAN1 receive registers are frozen +// DBG_I2C3_STOP +// I2C3 SMBUS timeout counter stopped when core is halted +// 0: Same behavior as in normal mode +// 1: The I2C3 SMBus timeout is frozen +// DBG_I2C2_STOP +// I2C2 SMBUS timeout counter stopped when core is halted +// 0: Same behavior as in normal mode +// 1: The I2C2 SMBus timeout is frozen +// DBG_I2C1_STOP +// I2C1 SMBUS timeout counter stopped when core is halted +// 0: Same behavior as in normal mode +// 1: The I2C1 SMBus timeout is frozen +// DBG_IWDG_STOP +// Independent watchdog counter stopped when core is halted +// 0: The independent watchdog counter clock continues even if the core is halted +// 1: The independent watchdog counter clock is stopped when the core is halted +// DBG_WWDG_STOP +// Window watchdog counter stopped when core is halted +// 0: The window watchdog counter clock continues even if the core is halted +// 1: The window watchdog counter clock is stopped when the core is halted +// DBG_RTC_STOP +// RTC counter stopped when core is halted +// 0: The clock of the RTC counter is fed even if the core is halted +// 1: The clock of the RTC counter is stopped when the core is halted +// DBG_TIM7_STOP +// TIM7 counter stopped when core is halted +// 0: The counter clock of TIM7 is fed even if the core is halted +// 1: The counter clock of TIM7 is stopped when the core is halted +// DBG_TIM6_STOP +// TIM6 counter stopped when core is halted +// 0: The counter clock of TIM6 is fed even if the core is halted +// 1: The counter clock of TIM6 is stopped when the core is halted +// DBG_TIM2_STOP +// TIM2 counter stopped when core is halted +// 0: The counter clock of TIM2 is fed even if the core is halted +// 1: The counter clock of TIM2 is stopped when the core is halted +// +DbgMCU_APB1_Fz1 = 0x00000000; + +// Debug MCU APB1 freeze register 2 (DBGMCU_APB1FZR2) +// DBG_LPTIM2_STOP +// LPTIM2 counter stopped when core is halted +// 0: The counter clock of LPTIM2 is fed even if the core is halted +// 1: The counter clock of LPTIM2 is stopped when the core is halted +// +DbgMCU_APB1_Fz2 = 0x00000000; + +// Debug MCU APB2 freeze register (DBGMCU_APB2FZR) +// DBG_TIM16_STOP +// TIM16 counter stopped when core is halted +// 0: The clock of the TIM16 counter is fed even if the core is halted +// 1: The clock of the TIM16 counter is stopped when the core is halted +// DBG_TIM15_STOP +// TIM15 counter stopped when core is halted +// 0: The clock of the TIM15 counter is fed even if the core is halted +// 1: The clock of the TIM15 counter is stopped when the core is halted +// DBG_TIM1_STOP +// TIM1 counter stopped when core is halted +// 0: The clock of the TIM1 counter is fed even if the core is halted +// 1: The clock of the TIM1 counter is stopped when the core is halted +// +DbgMCU_APB2_Fz = 0x00000000; +// + +// <<< end of configuration section >>> \ No newline at end of file diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/EventRecorderStub.scvd b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/EventRecorderStub.scvd new file mode 100644 index 00000000..2956b296 --- /dev/null +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/EventRecorderStub.scvd @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/RTE/_TencentOS_tiny/RTE_Components.h b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/RTE/_TencentOS_tiny/RTE_Components.h new file mode 100644 index 00000000..45b7722b --- /dev/null +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/RTE/_TencentOS_tiny/RTE_Components.h @@ -0,0 +1,20 @@ + +/* + * Auto generated Run-Time-Environment Component Configuration File + * *** Do not modify ! *** + * + * Project: 'TencentOS_tiny' + * Target: 'TencentOS_tiny' + */ + +#ifndef RTE_COMPONENTS_H +#define RTE_COMPONENTS_H + + +/* + * Define the Device Header File: + */ +#define CMSIS_device_header "stm32l4xx.h" + + +#endif /* RTE_COMPONENTS_H */ diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/TencentOS_tiny.uvoptx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/TencentOS_tiny.uvoptx new file mode 100644 index 00000000..31f63da6 --- /dev/null +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/TencentOS_tiny.uvoptx @@ -0,0 +1,1331 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + TencentOS_tiny + 0x4 + ARM-ADS + + 80000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\list\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 18 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 6 + + + + + + + + + + + STLink\ST-LINKIII-KEIL_SWO.dll + + + + 0 + ARMRTXEVENTFLAGS + -L70 -Z18 -C0 -M0 -T1 + + + 0 + DLGTARM + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0) + + + 0 + ARMDBGFLAGS + + + + 0 + DLGUARM + (105=-1,-1,-1,-1,0) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32L4xx_256 -FS08000000 -FL040000 -FP0($$Device:STM32L431RCTx$CMSIS\Flash\STM32L4xx_256.FLM)) + + + 0 + ST-LINKIII-KEIL_SWO + -U303030303030303030303031 -O10446 -SF4000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32L4xx_256.FLM -FS08000000 -FL040000 -FP0($$Device:STM32L431RCTx$CMSIS\Flash\STM32L4xx_256.FLM) + + + + + 0 + 0 + 35 + 1 +
134231724
+ 0 + 0 + 0 + 0 + 0 + 1 + ..\..\..\..\examples\posix\posix_sample.c + + \\TencentOS_tiny\../../../../examples/posix/posix_sample.c\35 +
+
+ + + 0 + 1 + self_task + + + 1 + 1 + pthread_mutex.owner + + + 2 + 1 + pthread_mutex + + + 3 + 1 + task + + + + + 1 + 0 + 0x200016F4 + 0 + + + + 0 + + + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + 1 + 1 + 0 + 2 + 10000000 + +
+
+ + + Application/MDK-ARM + 0 + 0 + 0 + 0 + + 1 + 1 + 2 + 0 + 0 + 0 + startup_stm32l431xx.s + startup_stm32l431xx.s + 0 + 0 + + + + + Application/User + 0 + 0 + 0 + 0 + + 2 + 2 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\gpio.c + gpio.c + 0 + 0 + + + 2 + 3 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\main.c + main.c + 0 + 0 + + + 2 + 4 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\mcu_init.c + mcu_init.c + 0 + 0 + + + 2 + 5 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\stm32l4xx_hal_msp.c + stm32l4xx_hal_msp.c + 0 + 0 + + + 2 + 6 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\stm32l4xx_it.c + stm32l4xx_it.c + 0 + 0 + + + 2 + 7 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\usart.c + usart.c + 0 + 0 + + + 2 + 8 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\adc.c + adc.c + 0 + 0 + + + 2 + 9 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\dac.c + dac.c + 0 + 0 + + + 2 + 10 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\i2c.c + i2c.c + 0 + 0 + + + 2 + 11 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\spi.c + spi.c + 0 + 0 + + + + + examples + 0 + 0 + 0 + 0 + + 3 + 12 + 1 + 0 + 0 + 0 + ..\..\..\..\examples\posix\posix_sample.c + posix_sample.c + 0 + 0 + + + + + Drivers/STM32L4xx_HAL_Driver + 0 + 0 + 0 + 0 + + 4 + 13 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim.c + stm32l4xx_hal_tim.c + 0 + 0 + + + 4 + 14 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim_ex.c + stm32l4xx_hal_tim_ex.c + 0 + 0 + + + 4 + 15 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_uart.c + stm32l4xx_hal_uart.c + 0 + 0 + + + 4 + 16 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_uart_ex.c + stm32l4xx_hal_uart_ex.c + 0 + 0 + + + 4 + 17 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal.c + stm32l4xx_hal.c + 0 + 0 + + + 4 + 18 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c.c + stm32l4xx_hal_i2c.c + 0 + 0 + + + 4 + 19 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c_ex.c + stm32l4xx_hal_i2c_ex.c + 0 + 0 + + + 4 + 20 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc.c + stm32l4xx_hal_rcc.c + 0 + 0 + + + 4 + 21 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc_ex.c + stm32l4xx_hal_rcc_ex.c + 0 + 0 + + + 4 + 22 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash.c + stm32l4xx_hal_flash.c + 0 + 0 + + + 4 + 23 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ex.c + stm32l4xx_hal_flash_ex.c + 0 + 0 + + + 4 + 24 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ramfunc.c + stm32l4xx_hal_flash_ramfunc.c + 0 + 0 + + + 4 + 25 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_gpio.c + stm32l4xx_hal_gpio.c + 0 + 0 + + + 4 + 26 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma.c + stm32l4xx_hal_dma.c + 0 + 0 + + + 4 + 27 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma_ex.c + stm32l4xx_hal_dma_ex.c + 0 + 0 + + + 4 + 28 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr.c + stm32l4xx_hal_pwr.c + 0 + 0 + + + 4 + 29 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr_ex.c + stm32l4xx_hal_pwr_ex.c + 0 + 0 + + + 4 + 30 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cortex.c + stm32l4xx_hal_cortex.c + 0 + 0 + + + 4 + 31 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc_ex.c + stm32l4xx_hal_adc_ex.c + 0 + 0 + + + 4 + 32 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc.c + stm32l4xx_hal_adc.c + 0 + 0 + + + 4 + 33 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac.c + stm32l4xx_hal_dac.c + 0 + 0 + + + 4 + 34 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac_ex.c + stm32l4xx_hal_dac_ex.c + 0 + 0 + + + 4 + 35 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi.c + stm32l4xx_hal_spi.c + 0 + 0 + + + 4 + 36 + 1 + 0 + 0 + 0 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi_ex.c + stm32l4xx_hal_spi_ex.c + 0 + 0 + + + + + Drivers/CMSIS + 0 + 0 + 0 + 0 + + 5 + 37 + 1 + 0 + 0 + 0 + ..\..\BSP\Src\system_stm32l4xx.c + system_stm32l4xx.c + 0 + 0 + + + + + Hardware + 0 + 0 + 0 + 0 + + 6 + 38 + 1 + 0 + 0 + 0 + ..\..\BSP\Hardware\DHT11\DHT11_BUS.c + DHT11_BUS.c + 0 + 0 + + + 6 + 39 + 1 + 0 + 0 + 0 + ..\..\BSP\Hardware\OLED\oled.c + oled.c + 0 + 0 + + + + + kernel + 0 + 0 + 0 + 0 + + 7 + 40 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_binary_heap.c + tos_binary_heap.c + 0 + 0 + + + 7 + 41 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_char_fifo.c + tos_char_fifo.c + 0 + 0 + + + 7 + 42 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_completion.c + tos_completion.c + 0 + 0 + + + 7 + 43 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_countdownlatch.c + tos_countdownlatch.c + 0 + 0 + + + 7 + 44 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_event.c + tos_event.c + 0 + 0 + + + 7 + 45 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_global.c + tos_global.c + 0 + 0 + + + 7 + 46 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_mail_queue.c + tos_mail_queue.c + 0 + 0 + + + 7 + 47 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_message_queue.c + tos_message_queue.c + 0 + 0 + + + 7 + 48 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_mmblk.c + tos_mmblk.c + 0 + 0 + + + 7 + 49 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_mmheap.c + tos_mmheap.c + 0 + 0 + + + 7 + 50 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_mutex.c + tos_mutex.c + 0 + 0 + + + 7 + 51 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_pend.c + tos_pend.c + 0 + 0 + + + 7 + 52 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_priority_mail_queue.c + tos_priority_mail_queue.c + 0 + 0 + + + 7 + 53 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_priority_message_queue.c + tos_priority_message_queue.c + 0 + 0 + + + 7 + 54 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_priority_queue.c + tos_priority_queue.c + 0 + 0 + + + 7 + 55 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_ring_queue.c + tos_ring_queue.c + 0 + 0 + + + 7 + 56 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_robin.c + tos_robin.c + 0 + 0 + + + 7 + 57 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_sched.c + tos_sched.c + 0 + 0 + + + 7 + 58 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_sem.c + tos_sem.c + 0 + 0 + + + 7 + 59 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_sys.c + tos_sys.c + 0 + 0 + + + 7 + 60 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_task.c + tos_task.c + 0 + 0 + + + 7 + 61 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_tick.c + tos_tick.c + 0 + 0 + + + 7 + 62 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_time.c + tos_time.c + 0 + 0 + + + 7 + 63 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_timer.c + tos_timer.c + 0 + 0 + + + 7 + 64 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_barrier.c + tos_barrier.c + 0 + 0 + + + 7 + 65 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_bitmap.c + tos_bitmap.c + 0 + 0 + + + 7 + 66 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_rwlock.c + tos_rwlock.c + 0 + 0 + + + 7 + 67 + 1 + 0 + 0 + 0 + ..\..\..\..\kernel\core\tos_stopwatch.c + tos_stopwatch.c + 0 + 0 + + + + + cpu + 0 + 0 + 0 + 0 + + 8 + 68 + 2 + 0 + 0 + 0 + ..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_s.S + port_s.S + 0 + 0 + + + 8 + 69 + 1 + 0 + 0 + 0 + ..\..\..\..\arch\arm\arm-v7m\common\tos_cpu.c + tos_cpu.c + 0 + 0 + + + 8 + 70 + 1 + 0 + 0 + 0 + ..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_c.c + port_c.c + 0 + 0 + + + + + cmsis + 0 + 0 + 0 + 0 + + 9 + 71 + 1 + 0 + 0 + 0 + ..\..\..\..\osal\cmsis_os\cmsis_os.c + cmsis_os.c + 0 + 0 + + + + + config + 0 + 0 + 0 + 0 + + 10 + 72 + 5 + 0 + 0 + 0 + ..\..\TOS-CONFIG\tos_config.h + tos_config.h + 0 + 0 + + + + + posix + 0 + 0 + 0 + 0 + + 11 + 73 + 1 + 0 + 0 + 0 + ..\..\..\..\osal\posix\pthread.c + pthread.c + 0 + 0 + + + 11 + 74 + 1 + 0 + 0 + 0 + ..\..\..\..\osal\posix\pthread_prv.c + pthread_prv.c + 0 + 0 + + + 11 + 75 + 1 + 0 + 0 + 0 + ..\..\..\..\osal\posix\time.c + time.c + 0 + 0 + + + 11 + 76 + 1 + 0 + 0 + 0 + ..\..\..\..\osal\posix\time_prv.c + time_prv.c + 0 + 0 + + + 11 + 77 + 1 + 0 + 0 + 0 + ..\..\..\..\osal\posix\semaphore.c + semaphore.c + 0 + 0 + + + 11 + 78 + 1 + 0 + 0 + 0 + ..\..\..\..\osal\posix\mqueue.c + mqueue.c + 0 + 0 + + + 11 + 79 + 1 + 0 + 0 + 0 + ..\..\..\..\osal\posix\timer_prv.c + timer_prv.c + 0 + 0 + + + 11 + 80 + 1 + 0 + 0 + 0 + ..\..\..\..\osal\posix\mqueue_prv.c + mqueue_prv.c + 0 + 0 + + + 11 + 81 + 1 + 0 + 0 + 0 + ..\..\..\..\osal\posix\sched.c + sched.c + 0 + 0 + + + 11 + 82 + 1 + 0 + 0 + 0 + ..\..\..\..\osal\posix\tos_posix.c + tos_posix.c + 0 + 0 + + + + + ::CMSIS + 0 + 0 + 0 + 1 + + +
diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/TencentOS_tiny.uvprojx b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/TencentOS_tiny.uvprojx new file mode 100644 index 00000000..3020a921 --- /dev/null +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/TencentOS_tiny.uvprojx @@ -0,0 +1,867 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + TencentOS_tiny + 0x4 + ARM-ADS + 5060750::V5.06 update 6 (build 750)::ARMCC + 0 + + + STM32L431RCTx + STMicroelectronics + Keil.STM32L4xx_DFP.2.2.0 + http://www.keil.com/pack + IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x803FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") + + + + + + + + + + + + + + + $$Device:STM32L431RCTx$CMSIS\SVD\STM32L4x1.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\obj\ + TencentOS_tiny + 1 + 0 + 1 + 1 + 0 + .\list\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 0 + + + SARMCM3.DLL + -REMAP -MPU + DCM.DLL + -pCM4 + SARMCM3.DLL + -MPU + TCM.DLL + -pCM4 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4107 + + 1 + STLink\ST-LINKIII-KEIL_SWO.dll + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M4" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 2 + 0 + 0 + 0 + 8 + 1 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x10000 + + + 1 + 0x8000000 + 0x40000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x8000000 + 0x40000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x10000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + + USE_HAL_DRIVER,STM32L431xx,WITH_TOS_NET_ADAPTER,USE_ESP8266 + + ..\..\BSP\Inc;..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Inc;..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Legacy;..\..\..\..\platform\vendor_bsp\st\CMSIS\Device\ST\STM32L4xx\Include;..\..\..\..\platform\vendor_bsp\st\CMSIS\Include;..\..\..\..\kernel\core\include;..\..\TOS-CONFIG;..\..\..\..\platform\arch\arm\cortex-m4\keil;..\..\..\..\kernel\pm\include;..\..\..\..\osal\cmsis_os;..\..\..\..\arch\arm\arm-v7m\common\include;..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc;..\..\BSP\Hardware\DHT11;..\..\BSP\Hardware\OLED;..\..\BSP\Hardware\BH1750;..\..\..\..\examples\helloworld;..\..\..\..\osal\posix\include + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x08000000 + 0x20000000 + + + + + + + + + + + + + Application/MDK-ARM + + + startup_stm32l431xx.s + 2 + startup_stm32l431xx.s + + + + + Application/User + + + gpio.c + 1 + ..\..\BSP\Src\gpio.c + + + main.c + 1 + ..\..\BSP\Src\main.c + + + mcu_init.c + 1 + ..\..\BSP\Src\mcu_init.c + + + stm32l4xx_hal_msp.c + 1 + ..\..\BSP\Src\stm32l4xx_hal_msp.c + + + stm32l4xx_it.c + 1 + ..\..\BSP\Src\stm32l4xx_it.c + + + usart.c + 1 + ..\..\BSP\Src\usart.c + + + adc.c + 1 + ..\..\BSP\Src\adc.c + + + dac.c + 1 + ..\..\BSP\Src\dac.c + + + i2c.c + 1 + ..\..\BSP\Src\i2c.c + + + spi.c + 1 + ..\..\BSP\Src\spi.c + + + + + examples + + + posix_sample.c + 1 + ..\..\..\..\examples\posix\posix_sample.c + + + + + Drivers/STM32L4xx_HAL_Driver + + + stm32l4xx_hal_tim.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim.c + + + stm32l4xx_hal_tim_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim_ex.c + + + stm32l4xx_hal_uart.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_uart.c + + + stm32l4xx_hal_uart_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_uart_ex.c + + + stm32l4xx_hal.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal.c + + + stm32l4xx_hal_i2c.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c.c + + + stm32l4xx_hal_i2c_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c_ex.c + + + stm32l4xx_hal_rcc.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc.c + + + stm32l4xx_hal_rcc_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc_ex.c + + + stm32l4xx_hal_flash.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash.c + + + stm32l4xx_hal_flash_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ex.c + + + stm32l4xx_hal_flash_ramfunc.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ramfunc.c + + + stm32l4xx_hal_gpio.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_gpio.c + + + stm32l4xx_hal_dma.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma.c + + + stm32l4xx_hal_dma_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma_ex.c + + + stm32l4xx_hal_pwr.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr.c + + + stm32l4xx_hal_pwr_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr_ex.c + + + stm32l4xx_hal_cortex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cortex.c + + + stm32l4xx_hal_adc_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc_ex.c + + + stm32l4xx_hal_adc.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc.c + + + stm32l4xx_hal_dac.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac.c + + + stm32l4xx_hal_dac_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac_ex.c + + + stm32l4xx_hal_spi.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi.c + + + stm32l4xx_hal_spi_ex.c + 1 + ..\..\..\..\platform\vendor_bsp\st\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi_ex.c + + + + + Drivers/CMSIS + + + system_stm32l4xx.c + 1 + ..\..\BSP\Src\system_stm32l4xx.c + + + + + Hardware + + + DHT11_BUS.c + 1 + ..\..\BSP\Hardware\DHT11\DHT11_BUS.c + + + oled.c + 1 + ..\..\BSP\Hardware\OLED\oled.c + + + + + kernel + + + tos_binary_heap.c + 1 + ..\..\..\..\kernel\core\tos_binary_heap.c + + + tos_char_fifo.c + 1 + ..\..\..\..\kernel\core\tos_char_fifo.c + + + tos_completion.c + 1 + ..\..\..\..\kernel\core\tos_completion.c + + + tos_countdownlatch.c + 1 + ..\..\..\..\kernel\core\tos_countdownlatch.c + + + tos_event.c + 1 + ..\..\..\..\kernel\core\tos_event.c + + + tos_global.c + 1 + ..\..\..\..\kernel\core\tos_global.c + + + tos_mail_queue.c + 1 + ..\..\..\..\kernel\core\tos_mail_queue.c + + + tos_message_queue.c + 1 + ..\..\..\..\kernel\core\tos_message_queue.c + + + tos_mmblk.c + 1 + ..\..\..\..\kernel\core\tos_mmblk.c + + + tos_mmheap.c + 1 + ..\..\..\..\kernel\core\tos_mmheap.c + + + tos_mutex.c + 1 + ..\..\..\..\kernel\core\tos_mutex.c + + + tos_pend.c + 1 + ..\..\..\..\kernel\core\tos_pend.c + + + tos_priority_mail_queue.c + 1 + ..\..\..\..\kernel\core\tos_priority_mail_queue.c + + + tos_priority_message_queue.c + 1 + ..\..\..\..\kernel\core\tos_priority_message_queue.c + + + tos_priority_queue.c + 1 + ..\..\..\..\kernel\core\tos_priority_queue.c + + + tos_ring_queue.c + 1 + ..\..\..\..\kernel\core\tos_ring_queue.c + + + tos_robin.c + 1 + ..\..\..\..\kernel\core\tos_robin.c + + + tos_sched.c + 1 + ..\..\..\..\kernel\core\tos_sched.c + + + tos_sem.c + 1 + ..\..\..\..\kernel\core\tos_sem.c + + + tos_sys.c + 1 + ..\..\..\..\kernel\core\tos_sys.c + + + tos_task.c + 1 + ..\..\..\..\kernel\core\tos_task.c + + + tos_tick.c + 1 + ..\..\..\..\kernel\core\tos_tick.c + + + tos_time.c + 1 + ..\..\..\..\kernel\core\tos_time.c + + + tos_timer.c + 1 + ..\..\..\..\kernel\core\tos_timer.c + + + tos_barrier.c + 1 + ..\..\..\..\kernel\core\tos_barrier.c + + + tos_bitmap.c + 1 + ..\..\..\..\kernel\core\tos_bitmap.c + + + tos_rwlock.c + 1 + ..\..\..\..\kernel\core\tos_rwlock.c + + + tos_stopwatch.c + 1 + ..\..\..\..\kernel\core\tos_stopwatch.c + + + + + cpu + + + port_s.S + 2 + ..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_s.S + + + tos_cpu.c + 1 + ..\..\..\..\arch\arm\arm-v7m\common\tos_cpu.c + + + port_c.c + 1 + ..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_c.c + + + + + cmsis + + + cmsis_os.c + 1 + ..\..\..\..\osal\cmsis_os\cmsis_os.c + + + + + config + + + tos_config.h + 5 + ..\..\TOS-CONFIG\tos_config.h + + + + + posix + + + pthread.c + 1 + ..\..\..\..\osal\posix\pthread.c + + + pthread_prv.c + 1 + ..\..\..\..\osal\posix\pthread_prv.c + + + time.c + 1 + ..\..\..\..\osal\posix\time.c + + + time_prv.c + 1 + ..\..\..\..\osal\posix\time_prv.c + + + semaphore.c + 1 + ..\..\..\..\osal\posix\semaphore.c + + + mqueue.c + 1 + ..\..\..\..\osal\posix\mqueue.c + + + timer_prv.c + 1 + ..\..\..\..\osal\posix\timer_prv.c + + + mqueue_prv.c + 1 + ..\..\..\..\osal\posix\mqueue_prv.c + + + sched.c + 1 + ..\..\..\..\osal\posix\sched.c + + + tos_posix.c + 1 + ..\..\..\..\osal\posix\tos_posix.c + + + + + ::CMSIS + + + + + + + + + + + + + + + + + + +
diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/obj/TencentOS_tiny.build_log.htm b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/obj/TencentOS_tiny.build_log.htm new file mode 100644 index 00000000..02d4bd83 --- /dev/null +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/obj/TencentOS_tiny.build_log.htm @@ -0,0 +1,140 @@ + + +
+

µVision Build Log

+

Tool Versions:

+IDE-Version: µVision V5.26.2.0 +Copyright (C) 2018 ARM Ltd and ARM Germany GmbH. All rights reserved. +License Information: arthur Microsoft, Microsoft, LIC=2TTQ1-CJN11-8Y7VV-PZWYN-PU1X8-9S4FH + +Tool Versions: +Toolchain: MDK-ARM Professional Version: 5.26.2.0 +Toolchain Path: d:\Keil_v5\ARM\ARMCC\Bin +C Compiler: Armcc.exe V5.06 update 6 (build 750) +Assembler: Armasm.exe V5.06 update 6 (build 750) +Linker/Locator: ArmLink.exe V5.06 update 6 (build 750) +Library Manager: ArmAr.exe V5.06 update 6 (build 750) +Hex Converter: FromElf.exe V5.06 update 6 (build 750) +CPU DLL: SARMCM3.DLL V5.26.2.0 +Dialog DLL: DCM.DLL V1.17.2.0 +Target DLL: STLink\ST-LINKIII-KEIL_SWO.dll V3.0.5.0 +Dialog DLL: TCM.DLL V1.36.1.0 + +

Project:

+D:\TOS\TencentOS-tiny\board\TencentOS_tiny_EVB_MX_Plus\KEIL\posix\TencentOS_tiny.uvprojx +Project File Date: 02/27/2020 + +

Output:

+*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'd:\Keil_v5\ARM\ARMCC\Bin' +Rebuild target 'TencentOS_tiny' +assembling startup_stm32l431xx.s... +compiling gpio.c... +compiling stm32l4xx_it.c... +compiling stm32l4xx_hal_msp.c... +compiling main.c... +compiling mcu_init.c... +compiling usart.c... +compiling adc.c... +compiling dac.c... +compiling stm32l4xx_hal_tim_ex.c... +compiling i2c.c... +compiling posix_sample.c... +compiling spi.c... +compiling stm32l4xx_hal_tim.c... +compiling stm32l4xx_hal_uart.c... +compiling stm32l4xx_hal_uart_ex.c... +compiling stm32l4xx_hal_i2c_ex.c... +compiling stm32l4xx_hal_i2c.c... +compiling stm32l4xx_hal_rcc.c... +compiling stm32l4xx_hal.c... +compiling stm32l4xx_hal_flash.c... +compiling stm32l4xx_hal_rcc_ex.c... +compiling stm32l4xx_hal_flash_ex.c... +compiling stm32l4xx_hal_flash_ramfunc.c... +compiling stm32l4xx_hal_dma.c... +compiling stm32l4xx_hal_gpio.c... +compiling stm32l4xx_hal_dma_ex.c... +compiling stm32l4xx_hal_pwr_ex.c... +compiling stm32l4xx_hal_pwr.c... +compiling stm32l4xx_hal_cortex.c... +compiling stm32l4xx_hal_dac_ex.c... +compiling stm32l4xx_hal_adc_ex.c... +compiling stm32l4xx_hal_dac.c... +compiling stm32l4xx_hal_adc.c... +compiling stm32l4xx_hal_spi_ex.c... +compiling stm32l4xx_hal_spi.c... +compiling system_stm32l4xx.c... +compiling tos_binary_heap.c... +compiling oled.c... +compiling DHT11_BUS.c... +compiling tos_char_fifo.c... +compiling tos_completion.c... +compiling tos_countdownlatch.c... +compiling tos_event.c... +compiling tos_mail_queue.c... +compiling tos_global.c... +compiling tos_message_queue.c... +compiling tos_mmblk.c... +compiling tos_mutex.c... +compiling tos_mmheap.c... +compiling tos_pend.c... +compiling tos_priority_message_queue.c... +compiling tos_ring_queue.c... +compiling tos_priority_queue.c... +compiling tos_priority_mail_queue.c... +compiling tos_sched.c... +compiling tos_robin.c... +compiling tos_sem.c... +compiling tos_tick.c... +compiling tos_sys.c... +compiling tos_task.c... +compiling tos_time.c... +compiling tos_timer.c... +compiling tos_barrier.c... +assembling port_s.S... +compiling tos_bitmap.c... +compiling tos_cpu.c... +compiling tos_stopwatch.c... +compiling tos_rwlock.c... +compiling cmsis_os.c... +compiling pthread.c... +compiling port_c.c... +compiling pthread_prv.c... +compiling time_prv.c... +compiling semaphore.c... +compiling time.c... +compiling timer_prv.c... +compiling mqueue_prv.c... +compiling mqueue.c... +compiling sched.c... +compiling tos_posix.c... +linking... +Program Size: Code=23380 RO-data=2664 RW-data=312 ZI-data=42888 +FromELF: creating hex file... +".\obj\TencentOS_tiny.axf" - 0 Error(s), 0 Warning(s). + +

Software Packages used:

+ +Package Vendor: ARM + http://www.keil.com/pack/ARM.CMSIS.5.4.0.pack + ARM.CMSIS.5.4.0 + CMSIS (Cortex Microcontroller Software Interface Standard) + * Component: CORE Version: 5.1.2 + +Package Vendor: Keil + http://www.keil.com/pack/Keil.STM32L4xx_DFP.2.2.0.pack + Keil.STM32L4xx_DFP.2.2.0 + STMicroelectronics STM32L4 Series Device Support, Drivers and Examples + +

Collection of Component include folders:

+ .\RTE\_TencentOS_tiny + d:\Keil_v5\ARM\PACK\ARM\CMSIS\5.4.0\CMSIS\Core\Include + d:\Keil_v5\ARM\PACK\Keil\STM32L4xx_DFP\2.2.0\Drivers\CMSIS\Device\ST\STM32L4xx\Include + +

Collection of Component Files used:

+ + * Component: ARM::CMSIS:CORE:5.1.2 +Build Time Elapsed: 00:00:22 +
+ + diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/obj/TencentOS_tiny.htm b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/obj/TencentOS_tiny.htm new file mode 100644 index 00000000..8059c031 --- /dev/null +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/obj/TencentOS_tiny.htm @@ -0,0 +1,3008 @@ + + +Static Call Graph - [.\obj\TencentOS_tiny.axf] +
+

Static Call Graph for image .\obj\TencentOS_tiny.axf


+

#<CALLGRAPH># ARM Linker, 5060750: Last Updated: Fri Feb 28 00:10:35 2020 +

+

Maximum Stack Usage = 296 bytes + Unknown(Functions without stacksize, Cycles, Untraceable Function Pointers)

+Call chain for Maximum Stack Depth:

+main ⇒ osThreadCreate ⇒ tos_task_create_dyn ⇒ tos_mmheap_aligned_alloc ⇒ blk_prepare_used ⇒ blk_trim_free ⇒ blk_split ⇒ blk_mark_as_free ⇒ blk_link_next ⇒ blk_next +

+

+Functions with no stack information +

+ +

+

+Mutually Recursive functions +

  • ADC1_IRQHandler   ⇒   ADC1_IRQHandler
    + +

    +

    +Function Pointers +

      +
    • ADC1_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • BusFault_Handler from stm32l4xx_it.o(i.BusFault_Handler) referenced from startup_stm32l431xx.o(RESET) +
    • CAN1_RX0_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • CAN1_RX1_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • CAN1_SCE_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • CAN1_TX_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • COMP_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • CRS_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA1_Channel1_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA1_Channel2_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA1_Channel3_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA1_Channel4_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA1_Channel5_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA1_Channel6_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA1_Channel7_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA2_Channel1_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA2_Channel2_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA2_Channel3_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA2_Channel4_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA2_Channel5_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA2_Channel6_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DMA2_Channel7_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • DebugMon_Handler from stm32l4xx_it.o(i.DebugMon_Handler) referenced from startup_stm32l431xx.o(RESET) +
    • EXTI0_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • EXTI15_10_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • EXTI1_IRQHandler from stm32l4xx_it.o(i.EXTI1_IRQHandler) referenced from startup_stm32l431xx.o(RESET) +
    • EXTI2_IRQHandler from stm32l4xx_it.o(i.EXTI2_IRQHandler) referenced from startup_stm32l431xx.o(RESET) +
    • EXTI3_IRQHandler from stm32l4xx_it.o(i.EXTI3_IRQHandler) referenced from startup_stm32l431xx.o(RESET) +
    • EXTI4_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • EXTI9_5_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • FLASH_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • FPU_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • HardFault_Handler from stm32l4xx_it.o(i.HardFault_Handler) referenced from startup_stm32l431xx.o(RESET) +
    • I2C1_ER_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • I2C1_EV_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • I2C2_ER_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • I2C2_EV_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • I2C3_ER_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • I2C3_EV_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • LPTIM1_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • LPTIM2_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • LPUART1_IRQHandler from stm32l4xx_it.o(i.LPUART1_IRQHandler) referenced from startup_stm32l431xx.o(RESET) +
    • MemManage_Handler from stm32l4xx_it.o(i.MemManage_Handler) referenced from startup_stm32l431xx.o(RESET) +
    • NMI_Handler from stm32l4xx_it.o(i.NMI_Handler) referenced from startup_stm32l431xx.o(RESET) +
    • PVD_PVM_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • PendSV_Handler from port_s.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • QUADSPI_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • RCC_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • RNG_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • RTC_Alarm_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • RTC_WKUP_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • Reset_Handler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • SAI1_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • SDMMC1_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • SPI1_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • SPI2_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • SPI3_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • SVC_Handler from stm32l4xx_it.o(i.SVC_Handler) referenced from startup_stm32l431xx.o(RESET) +
    • SWPMI1_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • SysTick_Handler from stm32l4xx_it.o(i.SysTick_Handler) referenced from startup_stm32l431xx.o(RESET) +
    • SystemInit from system_stm32l4xx.o(i.SystemInit) referenced from startup_stm32l431xx.o(.text) +
    • TAMP_STAMP_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • TIM1_BRK_TIM15_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • TIM1_CC_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • TIM1_TRG_COM_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • TIM1_UP_TIM16_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • TIM2_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • TIM6_DAC_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • TIM7_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • TSC_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • UART_DMAAbortOnError from stm32l4xx_hal_uart.o(i.UART_DMAAbortOnError) referenced from stm32l4xx_hal_uart.o(i.HAL_UART_IRQHandler) +
    • UART_RxISR_16BIT from stm32l4xx_hal_uart.o(i.UART_RxISR_16BIT) referenced from stm32l4xx_hal_uart.o(i.HAL_UART_Receive_IT) +
    • UART_RxISR_8BIT from stm32l4xx_hal_uart.o(i.UART_RxISR_8BIT) referenced from stm32l4xx_hal_uart.o(i.HAL_UART_Receive_IT) +
    • USART1_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • USART2_IRQHandler from stm32l4xx_it.o(i.USART2_IRQHandler) referenced from startup_stm32l431xx.o(RESET) +
    • USART3_IRQHandler from stm32l4xx_it.o(i.USART3_IRQHandler) referenced from startup_stm32l431xx.o(RESET) +
    • UsageFault_Handler from stm32l4xx_it.o(i.UsageFault_Handler) referenced from startup_stm32l431xx.o(RESET) +
    • WWDG_IRQHandler from startup_stm32l431xx.o(.text) referenced from startup_stm32l431xx.o(RESET) +
    • __main from entry.o(.ARM.Collect$$$$00000000) referenced from startup_stm32l431xx.o(.text) +
    • _snputc from printf5.o(i._snputc) referenced from printf5.o(i.__0snprintf$5) +
    • application_entry from posix_sample.o(i.application_entry) referenced from main.o(.constdata) +
    • firstborn_routine from posix_sample.o(i.firstborn_routine) referenced from posix_sample.o(i.application_entry) +
    • fourthborn_routine from posix_sample.o(i.fourthborn_routine) referenced from posix_sample.o(i.firstborn_routine) +
    • fputc from mcu_init.o(i.fputc) referenced from printf5.o(i.__0printf$5) +
    • knl_idle_entry from tos_sys.o(i.knl_idle_entry) referenced from tos_sys.o(i.knl_idle_init) +
    • main from main.o(i.main) referenced from entry9a.o(.ARM.Collect$$$$0000000B) +
    • pthread_entry from pthread.o(i.pthread_entry) referenced from pthread.o(i.pthread_create) +
    • secondborn_routine from posix_sample.o(i.secondborn_routine) referenced from posix_sample.o(i.firstborn_routine) +
    • task_exit from tos_task.o(i.task_exit) referenced from tos_task.o(i.tos_task_create) +
    • thirdborn_routine from posix_sample.o(i.thirdborn_routine) referenced from posix_sample.o(i.firstborn_routine) +
    +

    +

    +Global Symbols +

    +

    __main (Thumb, 0 bytes, Stack size unknown bytes, entry.o(.ARM.Collect$$$$00000000)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(.text) +
    +

    _main_stk (Thumb, 0 bytes, Stack size unknown bytes, entry2.o(.ARM.Collect$$$$00000001)) + +

    _main_scatterload (Thumb, 0 bytes, Stack size unknown bytes, entry5.o(.ARM.Collect$$$$00000004)) +

    [Calls]

    • >>   __scatterload +
    + +

    __main_after_scatterload (Thumb, 0 bytes, Stack size unknown bytes, entry5.o(.ARM.Collect$$$$00000004)) +

    [Called By]

    • >>   __scatterload +
    + +

    _main_clock (Thumb, 0 bytes, Stack size unknown bytes, entry7b.o(.ARM.Collect$$$$00000008)) + +

    _main_cpp_init (Thumb, 0 bytes, Stack size unknown bytes, entry8b.o(.ARM.Collect$$$$0000000A)) + +

    _main_init (Thumb, 0 bytes, Stack size unknown bytes, entry9a.o(.ARM.Collect$$$$0000000B)) + +

    __rt_final_cpp (Thumb, 0 bytes, Stack size unknown bytes, entry10a.o(.ARM.Collect$$$$0000000D)) + +

    __rt_final_exit (Thumb, 0 bytes, Stack size unknown bytes, entry11a.o(.ARM.Collect$$$$0000000F)) + +

    Reset_Handler (Thumb, 8 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    ADC1_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +

    [Calls]

    • >>   ADC1_IRQHandler +
    +
    [Called By]
    • >>   ADC1_IRQHandler +
    +
    [Address Reference Count : 1]
    • startup_stm32l431xx.o(RESET) +
    +

    CAN1_RX0_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    CAN1_RX1_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    CAN1_SCE_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    CAN1_TX_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    COMP_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    CRS_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA1_Channel1_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA1_Channel2_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA1_Channel3_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA1_Channel4_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA1_Channel5_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA1_Channel6_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA1_Channel7_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA2_Channel1_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA2_Channel2_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA2_Channel3_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA2_Channel4_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA2_Channel5_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA2_Channel6_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DMA2_Channel7_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    EXTI0_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    EXTI15_10_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    EXTI4_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    EXTI9_5_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    FLASH_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    FPU_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    I2C1_ER_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    I2C1_EV_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    I2C2_ER_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    I2C2_EV_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    I2C3_ER_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    I2C3_EV_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    LPTIM1_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    LPTIM2_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    PVD_PVM_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    QUADSPI_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    RCC_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    RNG_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    RTC_Alarm_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    RTC_WKUP_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    SAI1_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    SDMMC1_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    SPI1_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    SPI2_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    SPI3_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    SWPMI1_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    TAMP_STAMP_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    TIM1_BRK_TIM15_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    TIM1_CC_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    TIM1_TRG_COM_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    TIM1_UP_TIM16_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    TIM2_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    TIM6_DAC_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    TIM7_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    TSC_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    USART1_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    WWDG_IRQHandler (Thumb, 0 bytes, Stack size 0 bytes, startup_stm32l431xx.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    port_int_disable (Thumb, 0 bytes, Stack size unknown bytes, port_s.o(.text), UNUSED) + +

    port_int_enable (Thumb, 0 bytes, Stack size unknown bytes, port_s.o(.text), UNUSED) + +

    port_cpsr_save (Thumb, 0 bytes, Stack size unknown bytes, port_s.o(.text)) +

    [Called By]

    • >>   tos_cpu_cpsr_save +
    + +

    port_cpsr_restore (Thumb, 0 bytes, Stack size unknown bytes, port_s.o(.text)) +

    [Called By]

    • >>   tos_cpu_cpsr_restore +
    + +

    port_clz (Thumb, 0 bytes, Stack size unknown bytes, port_s.o(.text)) +

    [Called By]

    • >>   tos_cpu_clz +
    + +

    port_sched_start (Thumb, 0 bytes, Stack size unknown bytes, port_s.o(.text)) +

    [Called By]

    • >>   cpu_sched_start +
    + +

    port_context_switch (Thumb, 0 bytes, Stack size unknown bytes, port_s.o(.text)) +

    [Called By]

    • >>   cpu_context_switch +
    + +

    port_irq_context_switch (Thumb, 0 bytes, Stack size unknown bytes, port_s.o(.text)) +

    [Called By]

    • >>   cpu_irq_context_switch +
    + +

    PendSV_Handler (Thumb, 0 bytes, Stack size unknown bytes, port_s.o(.text)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    __aeabi_uldivmod (Thumb, 98 bytes, Stack size 40 bytes, uldiv.o(.text)) +

    [Stack]

    • Max Depth = 40
    • Call Chain = __aeabi_uldivmod +
    +
    [Calls]
    • >>   __aeabi_llsr +
    • >>   __aeabi_llsl +
    +
    [Called By]
    • >>   _printf_core +
    • >>   UART_SetConfig +
    + +

    __aeabi_memset (Thumb, 14 bytes, Stack size 0 bytes, memseta.o(.text), UNUSED) +

    [Called By]

    • >>   _memset$wrapper +
    • >>   __aeabi_memclr +
    + +

    __aeabi_memset4 (Thumb, 0 bytes, Stack size 0 bytes, memseta.o(.text), UNUSED) + +

    __aeabi_memset8 (Thumb, 0 bytes, Stack size 0 bytes, memseta.o(.text), UNUSED) + +

    __aeabi_memclr (Thumb, 4 bytes, Stack size 0 bytes, memseta.o(.text), UNUSED) +

    [Calls]

    • >>   __aeabi_memset +
    + +

    __aeabi_memclr4 (Thumb, 0 bytes, Stack size 0 bytes, memseta.o(.text)) +

    [Called By]

    • >>   HAL_UART_MspInit +
    • >>   SystemClock_Config +
    • >>   MX_GPIO_Init +
    + +

    __aeabi_memclr8 (Thumb, 0 bytes, Stack size 0 bytes, memseta.o(.text), UNUSED) + +

    _memset$wrapper (Thumb, 18 bytes, Stack size 8 bytes, memseta.o(.text), UNUSED) +

    [Calls]

    • >>   __aeabi_memset +
    + +

    strncpy (Thumb, 24 bytes, Stack size 8 bytes, strncpy.o(.text)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = strncpy +
    +
    [Called By]
    • >>   tos_task_create +
    + +

    __aeabi_llsl (Thumb, 30 bytes, Stack size 0 bytes, llshl.o(.text)) +

    [Called By]

    • >>   __aeabi_uldivmod +
    + +

    _ll_shift_l (Thumb, 0 bytes, Stack size 0 bytes, llshl.o(.text), UNUSED) + +

    __aeabi_llsr (Thumb, 32 bytes, Stack size 0 bytes, llushr.o(.text)) +

    [Called By]

    • >>   __aeabi_uldivmod +
    + +

    _ll_ushift_r (Thumb, 0 bytes, Stack size 0 bytes, llushr.o(.text), UNUSED) + +

    __scatterload (Thumb, 28 bytes, Stack size 0 bytes, init.o(.text)) +

    [Calls]

    • >>   __main_after_scatterload +
    +
    [Called By]
    • >>   _main_scatterload +
    + +

    __scatterload_rt2 (Thumb, 0 bytes, Stack size 0 bytes, init.o(.text), UNUSED) + +

    __decompress (Thumb, 0 bytes, Stack size unknown bytes, __dczerorl2.o(.text), UNUSED) + +

    __decompress1 (Thumb, 86 bytes, Stack size unknown bytes, __dczerorl2.o(.text), UNUSED) + +

    BusFault_Handler (Thumb, 4 bytes, Stack size 0 bytes, stm32l4xx_it.o(i.BusFault_Handler)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    DHT11_Init (Thumb, 48 bytes, Stack size 8 bytes, dht11_bus.o(i.DHT11_Init)) +

    [Stack]

    • Max Depth = 52
    • Call Chain = DHT11_Init ⇒ DHT11_Mode_Out_PP ⇒ HAL_GPIO_Init +
    +
    [Calls]
    • >>   HAL_GPIO_WritePin +
    • >>   DHT11_Mode_Out_PP +
    +
    [Called By]
    • >>   board_init +
    + +

    DebugMon_Handler (Thumb, 2 bytes, Stack size 0 bytes, stm32l4xx_it.o(i.DebugMon_Handler)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    EXTI1_IRQHandler (Thumb, 10 bytes, Stack size 8 bytes, stm32l4xx_it.o(i.EXTI1_IRQHandler)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = EXTI1_IRQHandler ⇒ HAL_GPIO_EXTI_IRQHandler +
    +
    [Calls]
    • >>   HAL_GPIO_EXTI_IRQHandler +
    +
    [Address Reference Count : 1]
    • startup_stm32l431xx.o(RESET) +
    +

    EXTI2_IRQHandler (Thumb, 10 bytes, Stack size 8 bytes, stm32l4xx_it.o(i.EXTI2_IRQHandler)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = EXTI2_IRQHandler ⇒ HAL_GPIO_EXTI_IRQHandler +
    +
    [Calls]
    • >>   HAL_GPIO_EXTI_IRQHandler +
    +
    [Address Reference Count : 1]
    • startup_stm32l431xx.o(RESET) +
    +

    EXTI3_IRQHandler (Thumb, 10 bytes, Stack size 8 bytes, stm32l4xx_it.o(i.EXTI3_IRQHandler)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = EXTI3_IRQHandler ⇒ HAL_GPIO_EXTI_IRQHandler +
    +
    [Calls]
    • >>   HAL_GPIO_EXTI_IRQHandler +
    +
    [Address Reference Count : 1]
    • startup_stm32l431xx.o(RESET) +
    +

    Error_Handler (Thumb, 2 bytes, Stack size 0 bytes, mcu_init.o(i.Error_Handler)) +

    [Called By]

    • >>   MX_USART3_UART_Init +
    • >>   MX_USART2_UART_Init +
    • >>   SystemClock_Config +
    + +

    HAL_DMA_Abort_IT (Thumb, 92 bytes, Stack size 16 bytes, stm32l4xx_hal_dma.o(i.HAL_DMA_Abort_IT)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = HAL_DMA_Abort_IT +
    +
    [Called By]
    • >>   HAL_UART_IRQHandler +
    + +

    HAL_Delay (Thumb, 32 bytes, Stack size 16 bytes, stm32l4xx_hal.o(i.HAL_Delay)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = HAL_Delay +
    +
    [Calls]
    • >>   HAL_GetTick +
    +
    [Called By]
    • >>   OLED_Init +
    + +

    HAL_GPIO_EXTI_Callback (Thumb, 2 bytes, Stack size 0 bytes, stm32l4xx_hal_gpio.o(i.HAL_GPIO_EXTI_Callback)) +

    [Called By]

    • >>   HAL_GPIO_EXTI_IRQHandler +
    + +

    HAL_GPIO_EXTI_IRQHandler (Thumb, 24 bytes, Stack size 8 bytes, stm32l4xx_hal_gpio.o(i.HAL_GPIO_EXTI_IRQHandler)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = HAL_GPIO_EXTI_IRQHandler +
    +
    [Calls]
    • >>   HAL_GPIO_EXTI_Callback +
    +
    [Called By]
    • >>   EXTI3_IRQHandler +
    • >>   EXTI2_IRQHandler +
    • >>   EXTI1_IRQHandler +
    + +

    HAL_GPIO_Init (Thumb, 428 bytes, Stack size 20 bytes, stm32l4xx_hal_gpio.o(i.HAL_GPIO_Init)) +

    [Stack]

    • Max Depth = 20
    • Call Chain = HAL_GPIO_Init +
    +
    [Called By]
    • >>   HAL_UART_MspInit +
    • >>   MX_GPIO_Init +
    • >>   DHT11_Mode_Out_PP +
    + +

    HAL_GPIO_WritePin (Thumb, 10 bytes, Stack size 0 bytes, stm32l4xx_hal_gpio.o(i.HAL_GPIO_WritePin)) +

    [Called By]

    • >>   DHT11_Init +
    • >>   MX_GPIO_Init +
    • >>   Write_IIC_Byte +
    • >>   IIC_Wait_Ack +
    • >>   IIC_Stop +
    • >>   IIC_Start +
    + +

    HAL_GetTick (Thumb, 6 bytes, Stack size 0 bytes, stm32l4xx_hal.o(i.HAL_GetTick)) +

    [Called By]

    • >>   HAL_RCC_OscConfig +
    • >>   HAL_RCC_ClockConfig +
    • >>   HAL_RCCEx_PeriphCLKConfig +
    • >>   HAL_Delay +
    • >>   RCCEx_PLLSAI1_Config +
    • >>   UART_WaitOnFlagUntilTimeout +
    • >>   UART_CheckIdleState +
    + +

    HAL_IncTick (Thumb, 12 bytes, Stack size 0 bytes, stm32l4xx_hal.o(i.HAL_IncTick)) +

    [Called By]

    • >>   SysTick_Handler +
    + +

    HAL_Init (Thumb, 30 bytes, Stack size 8 bytes, stm32l4xx_hal.o(i.HAL_Init)) +

    [Stack]

    • Max Depth = 72
    • Call Chain = HAL_Init ⇒ HAL_InitTick ⇒ HAL_NVIC_SetPriority ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   HAL_MspInit +
    • >>   HAL_InitTick +
    • >>   HAL_NVIC_SetPriorityGrouping +
    +
    [Called By]
    • >>   board_init +
    + +

    HAL_InitTick (Thumb, 44 bytes, Stack size 16 bytes, stm32l4xx_hal.o(i.HAL_InitTick)) +

    [Stack]

    • Max Depth = 64
    • Call Chain = HAL_InitTick ⇒ HAL_NVIC_SetPriority ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   HAL_NVIC_SetPriority +
    • >>   HAL_SYSTICK_Config +
    +
    [Called By]
    • >>   HAL_RCC_OscConfig +
    • >>   HAL_RCC_ClockConfig +
    • >>   HAL_Init +
    + +

    HAL_MspInit (Thumb, 58 bytes, Stack size 8 bytes, stm32l4xx_hal_msp.o(i.HAL_MspInit)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = HAL_MspInit +
    +
    [Called By]
    • >>   HAL_Init +
    + +

    HAL_NVIC_EnableIRQ (Thumb, 32 bytes, Stack size 0 bytes, stm32l4xx_hal_cortex.o(i.HAL_NVIC_EnableIRQ)) +

    [Called By]

    • >>   HAL_UART_MspInit +
    • >>   MX_GPIO_Init +
    + +

    HAL_NVIC_SetPriority (Thumb, 124 bytes, Stack size 40 bytes, stm32l4xx_hal_cortex.o(i.HAL_NVIC_SetPriority)) +

    [Stack]

    • Max Depth = 48
    • Call Chain = HAL_NVIC_SetPriority ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   __NVIC_SetPriority +
    • >>   __NVIC_GetPriorityGrouping +
    +
    [Called By]
    • >>   HAL_UART_MspInit +
    • >>   MX_GPIO_Init +
    • >>   HAL_InitTick +
    + +

    HAL_NVIC_SetPriorityGrouping (Thumb, 32 bytes, Stack size 0 bytes, stm32l4xx_hal_cortex.o(i.HAL_NVIC_SetPriorityGrouping)) +

    [Called By]

    • >>   HAL_Init +
    + +

    HAL_PWREx_ControlVoltageScaling (Thumb, 128 bytes, Stack size 0 bytes, stm32l4xx_hal_pwr_ex.o(i.HAL_PWREx_ControlVoltageScaling)) +

    [Called By]

    • >>   SystemClock_Config +
    + +

    HAL_PWREx_GetVoltageRange (Thumb, 10 bytes, Stack size 0 bytes, stm32l4xx_hal_pwr_ex.o(i.HAL_PWREx_GetVoltageRange)) +

    [Called By]

    • >>   RCC_SetFlashLatencyFromMSIRange +
    + +

    HAL_PWR_EnableBkUpAccess (Thumb, 14 bytes, Stack size 0 bytes, stm32l4xx_hal_pwr.o(i.HAL_PWR_EnableBkUpAccess)) +

    [Called By]

    • >>   SystemClock_Config +
    + +

    HAL_RCCEx_EnableMSIPLLMode (Thumb, 14 bytes, Stack size 0 bytes, stm32l4xx_hal_rcc_ex.o(i.HAL_RCCEx_EnableMSIPLLMode)) +

    [Called By]

    • >>   SystemClock_Config +
    + +

    HAL_RCCEx_PeriphCLKConfig (Thumb, 894 bytes, Stack size 32 bytes, stm32l4xx_hal_rcc_ex.o(i.HAL_RCCEx_PeriphCLKConfig)) +

    [Stack]

    • Max Depth = 56
    • Call Chain = HAL_RCCEx_PeriphCLKConfig ⇒ RCCEx_PLLSAI1_Config +
    +
    [Calls]
    • >>   RCCEx_PLLSAI1_Config +
    • >>   HAL_GetTick +
    +
    [Called By]
    • >>   SystemClock_Config +
    + +

    HAL_RCC_ClockConfig (Thumb, 358 bytes, Stack size 24 bytes, stm32l4xx_hal_rcc.o(i.HAL_RCC_ClockConfig)) +

    [Stack]

    • Max Depth = 88
    • Call Chain = HAL_RCC_ClockConfig ⇒ HAL_InitTick ⇒ HAL_NVIC_SetPriority ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   HAL_InitTick +
    • >>   HAL_RCC_GetSysClockFreq +
    • >>   HAL_GetTick +
    +
    [Called By]
    • >>   SystemClock_Config +
    + +

    HAL_RCC_GetHCLKFreq (Thumb, 6 bytes, Stack size 0 bytes, stm32l4xx_hal_rcc.o(i.HAL_RCC_GetHCLKFreq)) +

    [Called By]

    • >>   HAL_RCC_GetPCLK2Freq +
    • >>   HAL_RCC_GetPCLK1Freq +
    + +

    HAL_RCC_GetPCLK1Freq (Thumb, 26 bytes, Stack size 4 bytes, stm32l4xx_hal_rcc.o(i.HAL_RCC_GetPCLK1Freq)) +

    [Stack]

    • Max Depth = 4
    • Call Chain = HAL_RCC_GetPCLK1Freq +
    +
    [Calls]
    • >>   HAL_RCC_GetHCLKFreq +
    +
    [Called By]
    • >>   UART_SetConfig +
    + +

    HAL_RCC_GetPCLK2Freq (Thumb, 26 bytes, Stack size 4 bytes, stm32l4xx_hal_rcc.o(i.HAL_RCC_GetPCLK2Freq)) +

    [Stack]

    • Max Depth = 4
    • Call Chain = HAL_RCC_GetPCLK2Freq +
    +
    [Calls]
    • >>   HAL_RCC_GetHCLKFreq +
    +
    [Called By]
    • >>   UART_SetConfig +
    + +

    HAL_RCC_GetSysClockFreq (Thumb, 266 bytes, Stack size 24 bytes, stm32l4xx_hal_rcc.o(i.HAL_RCC_GetSysClockFreq)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = HAL_RCC_GetSysClockFreq +
    +
    [Called By]
    • >>   HAL_RCC_OscConfig +
    • >>   HAL_RCC_ClockConfig +
    • >>   UART_SetConfig +
    + +

    HAL_RCC_OscConfig (Thumb, 1660 bytes, Stack size 32 bytes, stm32l4xx_hal_rcc.o(i.HAL_RCC_OscConfig)) +

    [Stack]

    • Max Depth = 96
    • Call Chain = HAL_RCC_OscConfig ⇒ HAL_InitTick ⇒ HAL_NVIC_SetPriority ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   RCC_SetFlashLatencyFromMSIRange +
    • >>   HAL_InitTick +
    • >>   HAL_RCC_GetSysClockFreq +
    • >>   HAL_GetTick +
    +
    [Called By]
    • >>   SystemClock_Config +
    + +

    HAL_SYSTICK_Config (Thumb, 52 bytes, Stack size 16 bytes, stm32l4xx_hal_cortex.o(i.HAL_SYSTICK_Config)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = HAL_SYSTICK_Config ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   __NVIC_SetPriority +
    +
    [Called By]
    • >>   HAL_InitTick +
    + +

    HAL_UARTEx_WakeupCallback (Thumb, 2 bytes, Stack size 0 bytes, stm32l4xx_hal_uart_ex.o(i.HAL_UARTEx_WakeupCallback)) +

    [Called By]

    • >>   HAL_UART_IRQHandler +
    + +

    HAL_UART_ErrorCallback (Thumb, 2 bytes, Stack size 0 bytes, stm32l4xx_hal_uart.o(i.HAL_UART_ErrorCallback)) +

    [Called By]

    • >>   HAL_UART_IRQHandler +
    • >>   UART_DMAAbortOnError +
    + +

    HAL_UART_IRQHandler (Thumb, 392 bytes, Stack size 24 bytes, stm32l4xx_hal_uart.o(i.HAL_UART_IRQHandler)) +

    [Stack]

    • Max Depth = 40
    • Call Chain = HAL_UART_IRQHandler ⇒ HAL_DMA_Abort_IT +
    +
    [Calls]
    • >>   HAL_UART_ErrorCallback +
    • >>   HAL_UARTEx_WakeupCallback +
    • >>   HAL_DMA_Abort_IT +
    • >>   UART_EndTransmit_IT +
    • >>   UART_EndRxTransfer +
    +
    [Called By]
    • >>   USART3_IRQHandler +
    • >>   USART2_IRQHandler +
    • >>   LPUART1_IRQHandler +
    + +

    HAL_UART_Init (Thumb, 120 bytes, Stack size 8 bytes, stm32l4xx_hal_uart.o(i.HAL_UART_Init)) +

    [Stack]

    • Max Depth = 88
    • Call Chain = HAL_UART_Init ⇒ HAL_UART_MspInit ⇒ HAL_NVIC_SetPriority ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   HAL_UART_MspInit +
    • >>   UART_SetConfig +
    • >>   UART_CheckIdleState +
    • >>   UART_AdvFeatureConfig +
    +
    [Called By]
    • >>   MX_USART3_UART_Init +
    • >>   MX_USART2_UART_Init +
    + +

    HAL_UART_MspInit (Thumb, 342 bytes, Stack size 32 bytes, usart.o(i.HAL_UART_MspInit)) +

    [Stack]

    • Max Depth = 80
    • Call Chain = HAL_UART_MspInit ⇒ HAL_NVIC_SetPriority ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   HAL_NVIC_SetPriority +
    • >>   HAL_NVIC_EnableIRQ +
    • >>   HAL_GPIO_Init +
    • >>   __aeabi_memclr4 +
    +
    [Called By]
    • >>   HAL_UART_Init +
    + +

    HAL_UART_Receive_IT (Thumb, 214 bytes, Stack size 8 bytes, stm32l4xx_hal_uart.o(i.HAL_UART_Receive_IT)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = HAL_UART_Receive_IT +
    +
    [Called By]
    • >>   MX_USART2_UART_Init +
    + +

    HAL_UART_RxCpltCallback (Thumb, 2 bytes, Stack size 0 bytes, stm32l4xx_hal_uart.o(i.HAL_UART_RxCpltCallback)) +

    [Called By]

    • >>   UART_RxISR_8BIT +
    • >>   UART_RxISR_16BIT +
    + +

    HAL_UART_TxCpltCallback (Thumb, 2 bytes, Stack size 0 bytes, stm32l4xx_hal_uart.o(i.HAL_UART_TxCpltCallback)) +

    [Called By]

    • >>   UART_EndTransmit_IT +
    + +

    HardFault_Handler (Thumb, 4 bytes, Stack size 0 bytes, stm32l4xx_it.o(i.HardFault_Handler)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    IIC_Start (Thumb, 48 bytes, Stack size 8 bytes, oled.o(i.IIC_Start)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = IIC_Start +
    +
    [Calls]
    • >>   HAL_GPIO_WritePin +
    +
    [Called By]
    • >>   Write_IIC_Data +
    • >>   Write_IIC_Command +
    + +

    IIC_Stop (Thumb, 36 bytes, Stack size 8 bytes, oled.o(i.IIC_Stop)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = IIC_Stop +
    +
    [Calls]
    • >>   HAL_GPIO_WritePin +
    +
    [Called By]
    • >>   Write_IIC_Data +
    • >>   Write_IIC_Command +
    + +

    IIC_Wait_Ack (Thumb, 28 bytes, Stack size 8 bytes, oled.o(i.IIC_Wait_Ack)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = IIC_Wait_Ack +
    +
    [Calls]
    • >>   HAL_GPIO_WritePin +
    +
    [Called By]
    • >>   Write_IIC_Data +
    • >>   Write_IIC_Command +
    + +

    LPUART1_IRQHandler (Thumb, 10 bytes, Stack size 8 bytes, stm32l4xx_it.o(i.LPUART1_IRQHandler)) +

    [Stack]

    • Max Depth = 48
    • Call Chain = LPUART1_IRQHandler ⇒ HAL_UART_IRQHandler ⇒ HAL_DMA_Abort_IT +
    +
    [Calls]
    • >>   HAL_UART_IRQHandler +
    +
    [Address Reference Count : 1]
    • startup_stm32l431xx.o(RESET) +
    +

    MX_GPIO_Init (Thumb, 316 bytes, Stack size 32 bytes, gpio.o(i.MX_GPIO_Init)) +

    [Stack]

    • Max Depth = 80
    • Call Chain = MX_GPIO_Init ⇒ HAL_NVIC_SetPriority ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   HAL_NVIC_SetPriority +
    • >>   HAL_NVIC_EnableIRQ +
    • >>   HAL_GPIO_WritePin +
    • >>   HAL_GPIO_Init +
    • >>   __aeabi_memclr4 +
    +
    [Called By]
    • >>   board_init +
    + +

    MX_USART2_UART_Init (Thumb, 66 bytes, Stack size 8 bytes, usart.o(i.MX_USART2_UART_Init)) +

    [Stack]

    • Max Depth = 96
    • Call Chain = MX_USART2_UART_Init ⇒ HAL_UART_Init ⇒ HAL_UART_MspInit ⇒ HAL_NVIC_SetPriority ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   HAL_UART_Receive_IT +
    • >>   HAL_UART_Init +
    • >>   Error_Handler +
    +
    [Called By]
    • >>   board_init +
    + +

    MX_USART3_UART_Init (Thumb, 56 bytes, Stack size 8 bytes, usart.o(i.MX_USART3_UART_Init)) +

    [Stack]

    • Max Depth = 96
    • Call Chain = MX_USART3_UART_Init ⇒ HAL_UART_Init ⇒ HAL_UART_MspInit ⇒ HAL_NVIC_SetPriority ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   HAL_UART_Init +
    • >>   Error_Handler +
    +
    [Called By]
    • >>   board_init +
    + +

    MemManage_Handler (Thumb, 4 bytes, Stack size 0 bytes, stm32l4xx_it.o(i.MemManage_Handler)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    NMI_Handler (Thumb, 2 bytes, Stack size 0 bytes, stm32l4xx_it.o(i.NMI_Handler)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    OLED_Clear (Thumb, 62 bytes, Stack size 16 bytes, oled.o(i.OLED_Clear)) +

    [Stack]

    • Max Depth = 64
    • Call Chain = OLED_Clear ⇒ OLED_WR_Byte ⇒ Write_IIC_Data ⇒ Write_IIC_Byte +
    +
    [Calls]
    • >>   OLED_WR_Byte +
    +
    [Called By]
    • >>   OLED_Init +
    • >>   board_init +
    + +

    OLED_Init (Thumb, 198 bytes, Stack size 8 bytes, oled.o(i.OLED_Init)) +

    [Stack]

    • Max Depth = 72
    • Call Chain = OLED_Init ⇒ OLED_Clear ⇒ OLED_WR_Byte ⇒ Write_IIC_Data ⇒ Write_IIC_Byte +
    +
    [Calls]
    • >>   OLED_Clear +
    • >>   HAL_Delay +
    • >>   OLED_WR_Byte +
    +
    [Called By]
    • >>   board_init +
    + +

    OLED_Set_Pos (Thumb, 40 bytes, Stack size 16 bytes, oled.o(i.OLED_Set_Pos)) +

    [Stack]

    • Max Depth = 64
    • Call Chain = OLED_Set_Pos ⇒ OLED_WR_Byte ⇒ Write_IIC_Data ⇒ Write_IIC_Byte +
    +
    [Calls]
    • >>   OLED_WR_Byte +
    +
    [Called By]
    • >>   OLED_ShowChinese +
    • >>   OLED_ShowChar +
    + +

    OLED_ShowChar (Thumb, 154 bytes, Stack size 32 bytes, oled.o(i.OLED_ShowChar)) +

    [Stack]

    • Max Depth = 96
    • Call Chain = OLED_ShowChar ⇒ OLED_Set_Pos ⇒ OLED_WR_Byte ⇒ Write_IIC_Data ⇒ Write_IIC_Byte +
    +
    [Calls]
    • >>   OLED_WR_Byte +
    • >>   OLED_Set_Pos +
    +
    [Called By]
    • >>   OLED_ShowString +
    + +

    OLED_ShowChinese (Thumb, 98 bytes, Stack size 24 bytes, oled.o(i.OLED_ShowChinese)) +

    [Stack]

    • Max Depth = 88
    • Call Chain = OLED_ShowChinese ⇒ OLED_Set_Pos ⇒ OLED_WR_Byte ⇒ Write_IIC_Data ⇒ Write_IIC_Byte +
    +
    [Calls]
    • >>   OLED_WR_Byte +
    • >>   OLED_Set_Pos +
    +
    [Called By]
    • >>   board_init +
    + +

    OLED_ShowString (Thumb, 58 bytes, Stack size 24 bytes, oled.o(i.OLED_ShowString)) +

    [Stack]

    • Max Depth = 120
    • Call Chain = OLED_ShowString ⇒ OLED_ShowChar ⇒ OLED_Set_Pos ⇒ OLED_WR_Byte ⇒ Write_IIC_Data ⇒ Write_IIC_Byte +
    +
    [Calls]
    • >>   OLED_ShowChar +
    +
    [Called By]
    • >>   board_init +
    + +

    OLED_WR_Byte (Thumb, 24 bytes, Stack size 16 bytes, oled.o(i.OLED_WR_Byte)) +

    [Stack]

    • Max Depth = 48
    • Call Chain = OLED_WR_Byte ⇒ Write_IIC_Data ⇒ Write_IIC_Byte +
    +
    [Calls]
    • >>   Write_IIC_Data +
    • >>   Write_IIC_Command +
    +
    [Called By]
    • >>   OLED_ShowChinese +
    • >>   OLED_Init +
    • >>   OLED_Clear +
    • >>   OLED_ShowChar +
    • >>   OLED_Set_Pos +
    + +

    SVC_Handler (Thumb, 2 bytes, Stack size 0 bytes, stm32l4xx_it.o(i.SVC_Handler)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    SysTick_Handler (Thumb, 26 bytes, Stack size 8 bytes, stm32l4xx_it.o(i.SysTick_Handler)) +

    [Stack]

    • Max Depth = 96 + Unknown Stack Size +
    • Call Chain = SysTick_Handler ⇒ tos_tick_handler ⇒ tick_update ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   tos_tick_handler +
    • >>   tos_knl_is_running +
    • >>   tos_knl_irq_leave +
    • >>   tos_knl_irq_enter +
    • >>   HAL_IncTick +
    +
    [Address Reference Count : 1]
    • startup_stm32l431xx.o(RESET) +
    +

    SystemClock_Config (Thumb, 214 bytes, Stack size 184 bytes, mcu_init.o(i.SystemClock_Config)) +

    [Stack]

    • Max Depth = 280
    • Call Chain = SystemClock_Config ⇒ HAL_RCC_OscConfig ⇒ HAL_InitTick ⇒ HAL_NVIC_SetPriority ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   HAL_RCC_OscConfig +
    • >>   HAL_RCC_ClockConfig +
    • >>   HAL_RCCEx_PeriphCLKConfig +
    • >>   HAL_RCCEx_EnableMSIPLLMode +
    • >>   HAL_PWR_EnableBkUpAccess +
    • >>   HAL_PWREx_ControlVoltageScaling +
    • >>   Error_Handler +
    • >>   __aeabi_memclr4 +
    +
    [Called By]
    • >>   board_init +
    + +

    SystemInit (Thumb, 68 bytes, Stack size 0 bytes, system_stm32l4xx.o(i.SystemInit)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(.text) +
    +

    UART_AdvFeatureConfig (Thumb, 248 bytes, Stack size 0 bytes, stm32l4xx_hal_uart.o(i.UART_AdvFeatureConfig)) +

    [Called By]

    • >>   HAL_UART_Init +
    + +

    UART_CheckIdleState (Thumb, 116 bytes, Stack size 16 bytes, stm32l4xx_hal_uart.o(i.UART_CheckIdleState)) +

    [Stack]

    • Max Depth = 40
    • Call Chain = UART_CheckIdleState ⇒ UART_WaitOnFlagUntilTimeout +
    +
    [Calls]
    • >>   HAL_GetTick +
    • >>   UART_WaitOnFlagUntilTimeout +
    +
    [Called By]
    • >>   HAL_UART_Init +
    + +

    UART_SetConfig (Thumb, 1000 bytes, Stack size 40 bytes, stm32l4xx_hal_uart.o(i.UART_SetConfig)) +

    [Stack]

    • Max Depth = 80
    • Call Chain = UART_SetConfig ⇒ __aeabi_uldivmod +
    +
    [Calls]
    • >>   __aeabi_uldivmod +
    • >>   HAL_RCC_GetSysClockFreq +
    • >>   HAL_RCC_GetPCLK2Freq +
    • >>   HAL_RCC_GetPCLK1Freq +
    +
    [Called By]
    • >>   HAL_UART_Init +
    + +

    UART_WaitOnFlagUntilTimeout (Thumb, 108 bytes, Stack size 24 bytes, stm32l4xx_hal_uart.o(i.UART_WaitOnFlagUntilTimeout)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = UART_WaitOnFlagUntilTimeout +
    +
    [Calls]
    • >>   HAL_GetTick +
    +
    [Called By]
    • >>   UART_CheckIdleState +
    + +

    USART2_IRQHandler (Thumb, 10 bytes, Stack size 8 bytes, stm32l4xx_it.o(i.USART2_IRQHandler)) +

    [Stack]

    • Max Depth = 48
    • Call Chain = USART2_IRQHandler ⇒ HAL_UART_IRQHandler ⇒ HAL_DMA_Abort_IT +
    +
    [Calls]
    • >>   HAL_UART_IRQHandler +
    +
    [Address Reference Count : 1]
    • startup_stm32l431xx.o(RESET) +
    +

    USART3_IRQHandler (Thumb, 10 bytes, Stack size 8 bytes, stm32l4xx_it.o(i.USART3_IRQHandler)) +

    [Stack]

    • Max Depth = 48
    • Call Chain = USART3_IRQHandler ⇒ HAL_UART_IRQHandler ⇒ HAL_DMA_Abort_IT +
    +
    [Calls]
    • >>   HAL_UART_IRQHandler +
    +
    [Address Reference Count : 1]
    • startup_stm32l431xx.o(RESET) +
    +

    UsageFault_Handler (Thumb, 4 bytes, Stack size 0 bytes, stm32l4xx_it.o(i.UsageFault_Handler)) +
    [Address Reference Count : 1]

    • startup_stm32l431xx.o(RESET) +
    +

    Write_IIC_Byte (Thumb, 96 bytes, Stack size 24 bytes, oled.o(i.Write_IIC_Byte)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = Write_IIC_Byte +
    +
    [Calls]
    • >>   HAL_GPIO_WritePin +
    +
    [Called By]
    • >>   Write_IIC_Data +
    • >>   Write_IIC_Command +
    + +

    Write_IIC_Command (Thumb, 44 bytes, Stack size 8 bytes, oled.o(i.Write_IIC_Command)) +

    [Stack]

    • Max Depth = 32
    • Call Chain = Write_IIC_Command ⇒ Write_IIC_Byte +
    +
    [Calls]
    • >>   Write_IIC_Byte +
    • >>   IIC_Wait_Ack +
    • >>   IIC_Stop +
    • >>   IIC_Start +
    +
    [Called By]
    • >>   OLED_WR_Byte +
    + +

    Write_IIC_Data (Thumb, 44 bytes, Stack size 8 bytes, oled.o(i.Write_IIC_Data)) +

    [Stack]

    • Max Depth = 32
    • Call Chain = Write_IIC_Data ⇒ Write_IIC_Byte +
    +
    [Calls]
    • >>   Write_IIC_Byte +
    • >>   IIC_Wait_Ack +
    • >>   IIC_Stop +
    • >>   IIC_Start +
    +
    [Called By]
    • >>   OLED_WR_Byte +
    + +

    __0printf$5 (Thumb, 22 bytes, Stack size 24 bytes, printf5.o(i.__0printf$5), UNUSED) +

    [Calls]

    • >>   _printf_core +
    + +

    __1printf$5 (Thumb, 0 bytes, Stack size 24 bytes, printf5.o(i.__0printf$5), UNUSED) + +

    __2printf (Thumb, 0 bytes, Stack size 24 bytes, printf5.o(i.__0printf$5)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = __2printf +
    +
    [Called By]
    • >>   main +
    • >>   thirdborn_routine +
    • >>   secondborn_routine +
    • >>   fourthborn_routine +
    • >>   firstborn_routine +
    + +

    __0snprintf$5 (Thumb, 44 bytes, Stack size 32 bytes, printf5.o(i.__0snprintf$5), UNUSED) +

    [Calls]

    • >>   _printf_core +
    + +

    __1snprintf$5 (Thumb, 0 bytes, Stack size 32 bytes, printf5.o(i.__0snprintf$5), UNUSED) + +

    __2snprintf (Thumb, 0 bytes, Stack size 32 bytes, printf5.o(i.__0snprintf$5)) +

    [Stack]

    • Max Depth = 32
    • Call Chain = __2snprintf +
    +
    [Called By]
    • >>   pthread_create +
    + +

    __scatterload_copy (Thumb, 14 bytes, Stack size unknown bytes, handlers.o(i.__scatterload_copy), UNUSED) + +

    __scatterload_null (Thumb, 2 bytes, Stack size unknown bytes, handlers.o(i.__scatterload_null), UNUSED) + +

    __scatterload_zeroinit (Thumb, 14 bytes, Stack size unknown bytes, handlers.o(i.__scatterload_zeroinit), UNUSED) + +

    application_entry (Thumb, 90 bytes, Stack size 32 bytes, posix_sample.o(i.application_entry)) +

    [Stack]

    • Max Depth = 280 + Unknown Stack Size +
    • Call Chain = application_entry ⇒ pthread_create ⇒ pthread_dead_reap ⇒ pthread_ctl_reap ⇒ tos_mmheap_free ⇒ blk_merge_prev ⇒ blk_remove ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   tos_posix_init +
    • >>   pthread_create +
    • >>   pthread_attr_setstack +
    • >>   pthread_attr_setschedparam +
    • >>   pthread_attr_setinheritsched +
    • >>   pthread_attr_init +
    +
    [Address Reference Count : 1]
    • main.o(.constdata) +
    +

    board_init (Thumb, 110 bytes, Stack size 8 bytes, mcu_init.o(i.board_init)) +

    [Stack]

    • Max Depth = 288
    • Call Chain = board_init ⇒ SystemClock_Config ⇒ HAL_RCC_OscConfig ⇒ HAL_InitTick ⇒ HAL_NVIC_SetPriority ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   OLED_ShowString +
    • >>   OLED_ShowChinese +
    • >>   OLED_Init +
    • >>   OLED_Clear +
    • >>   MX_USART3_UART_Init +
    • >>   MX_USART2_UART_Init +
    • >>   HAL_Init +
    • >>   DHT11_Init +
    • >>   SystemClock_Config +
    • >>   MX_GPIO_Init +
    +
    [Called By]
    • >>   main +
    + +

    cpu_context_switch (Thumb, 8 bytes, Stack size 8 bytes, tos_cpu.o(i.cpu_context_switch)) +

    [Stack]

    • Max Depth = 8 + Unknown Stack Size +
    • Call Chain = cpu_context_switch +
    +
    [Calls]
    • >>   port_context_switch +
    +
    [Called By]
    • >>   knl_sched +
    + +

    cpu_init (Thumb, 28 bytes, Stack size 8 bytes, tos_cpu.o(i.cpu_init)) +

    [Stack]

    • Max Depth = 40
    • Call Chain = cpu_init ⇒ cpu_systick_init ⇒ port_systick_config ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   cpu_systick_init +
    +
    [Called By]
    • >>   tos_knl_init +
    + +

    cpu_irq_context_switch (Thumb, 8 bytes, Stack size 8 bytes, tos_cpu.o(i.cpu_irq_context_switch)) +

    [Stack]

    • Max Depth = 8 + Unknown Stack Size +
    • Call Chain = cpu_irq_context_switch +
    +
    [Calls]
    • >>   port_irq_context_switch +
    +
    [Called By]
    • >>   tos_knl_irq_leave +
    + +

    cpu_sched_start (Thumb, 4 bytes, Stack size 0 bytes, tos_cpu.o(i.cpu_sched_start)) +

    [Calls]

    • >>   port_sched_start +
    +
    [Called By]
    • >>   tos_knl_start +
    + +

    cpu_systick_init (Thumb, 18 bytes, Stack size 8 bytes, tos_cpu.o(i.cpu_systick_init)) +

    [Stack]

    • Max Depth = 32
    • Call Chain = cpu_systick_init ⇒ port_systick_config ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   port_systick_priority_set +
    • >>   port_systick_config +
    +
    [Called By]
    • >>   cpu_init +
    + +

    cpu_task_stk_init (Thumb, 216 bytes, Stack size 20 bytes, tos_cpu.o(i.cpu_task_stk_init)) +

    [Stack]

    • Max Depth = 20
    • Call Chain = cpu_task_stk_init +
    +
    [Called By]
    • >>   tos_task_create +
    + +

    firstborn_routine (Thumb, 220 bytes, Stack size 24 bytes, posix_sample.o(i.firstborn_routine)) +

    [Stack]

    • Max Depth = 272 + Unknown Stack Size +
    • Call Chain = firstborn_routine ⇒ pthread_create ⇒ pthread_dead_reap ⇒ pthread_ctl_reap ⇒ tos_mmheap_free ⇒ blk_merge_prev ⇒ blk_remove ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   tos_task_delay +
    • >>   pthread_join +
    • >>   pthread_create +
    • >>   pthread_cancel +
    • >>   pthread_attr_setdetachstate +
    • >>   pthread_attr_init +
    • >>   __2printf +
    +
    [Address Reference Count : 1]
    • posix_sample.o(i.application_entry) +
    +

    fourthborn_routine (Thumb, 42 bytes, Stack size 0 bytes, posix_sample.o(i.fourthborn_routine)) +

    [Stack]

    • Max Depth = 184 + Unknown Stack Size +
    • Call Chain = fourthborn_routine ⇒ pthread_exit ⇒ tos_task_destroy ⇒ task_destroy_dyn ⇒ task_do_destroy ⇒ task_mutex_release ⇒ mutex_release ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   tos_task_delay +
    • >>   pthread_exit +
    • >>   __2printf +
    +
    [Address Reference Count : 1]
    • posix_sample.o(i.firstborn_routine) +
    +

    fputc (Thumb, 24 bytes, Stack size 0 bytes, mcu_init.o(i.fputc)) +
    [Address Reference Count : 1]

    • printf5.o(i.__0printf$5) +
    +

    knl_idle_init (Thumb, 38 bytes, Stack size 24 bytes, tos_sys.o(i.knl_idle_init)) +

    [Stack]

    • Max Depth = 96 + Unknown Stack Size +
    • Call Chain = knl_idle_init ⇒ tos_task_create ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   tos_task_create +
    +
    [Called By]
    • >>   tos_knl_init +
    + +

    knl_is_idle (Thumb, 16 bytes, Stack size 0 bytes, tos_sys.o(i.knl_is_idle)) +

    [Called By]

    • >>   task_do_destroy +
    • >>   tos_task_create +
    + +

    knl_is_inirq (Thumb, 14 bytes, Stack size 0 bytes, tos_sys.o(i.knl_is_inirq)) +

    [Called By]

    • >>   tos_knl_irq_leave +
    • >>   tos_task_delay +
    • >>   pthread_create +
    • >>   knl_sched +
    • >>   tos_knl_sched_lock +
    • >>   tos_task_prio_change +
    • >>   tos_mutex_post +
    • >>   tos_mutex_pend_timed +
    • >>   tos_mutex_create +
    • >>   tos_task_yield +
    • >>   tos_task_destroy +
    • >>   tos_task_create_dyn +
    • >>   tos_task_create +
    • >>   tos_knl_sched_unlock +
    • >>   tos_sem_pend +
    + +

    knl_is_sched_locked (Thumb, 14 bytes, Stack size 0 bytes, tos_sys.o(i.knl_is_sched_locked)) +

    [Called By]

    • >>   tos_knl_irq_leave +
    • >>   tos_task_delay +
    • >>   knl_sched +
    • >>   tos_mutex_pend_timed +
    • >>   tos_task_destroy +
    • >>   tos_knl_sched_unlock +
    • >>   tos_sem_pend +
    + +

    knl_is_self (Thumb, 18 bytes, Stack size 0 bytes, tos_sys.o(i.knl_is_self)) +

    [Called By]

    • >>   tos_knl_irq_leave +
    • >>   knl_sched +
    • >>   tos_task_prio_change +
    • >>   tos_mutex_post +
    • >>   tos_mutex_pend_timed +
    • >>   tos_task_destroy +
    • >>   task_destroy_dyn +
    + +

    knl_sched (Thumb, 94 bytes, Stack size 8 bytes, tos_sys.o(i.knl_sched)) +

    [Stack]

    • Max Depth = 16 + Unknown Stack Size +
    • Call Chain = knl_sched ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_knl_is_running +
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   knl_is_sched_locked +
    • >>   knl_is_inirq +
    • >>   knl_is_self +
    • >>   cpu_context_switch +
    • >>   readyqueue_highest_ready_task_get +
    +
    [Called By]
    • >>   tos_task_delay +
    • >>   tos_task_prio_change +
    • >>   tos_mutex_post +
    • >>   tos_mutex_pend_timed +
    • >>   tos_task_yield +
    • >>   task_do_destroy +
    • >>   tos_task_create +
    • >>   tos_knl_sched_unlock +
    • >>   tos_sem_pend +
    • >>   tos_sem_destroy +
    • >>   sem_do_post +
    + +

    main (Thumb, 32 bytes, Stack size 8 bytes, main.o(i.main)) +

    [Stack]

    • Max Depth = 296 + Unknown Stack Size +
    • Call Chain = main ⇒ osThreadCreate ⇒ tos_task_create_dyn ⇒ tos_mmheap_aligned_alloc ⇒ blk_prepare_used ⇒ blk_trim_free ⇒ blk_split ⇒ blk_mark_as_free ⇒ blk_link_next ⇒ blk_next +
    +
    [Calls]
    • >>   osThreadCreate +
    • >>   osKernelStart +
    • >>   osKernelInitialize +
    • >>   board_init +
    • >>   __2printf +
    +
    [Address Reference Count : 1]
    • entry9a.o(.ARM.Collect$$$$0000000B) +
    +

    mmheap_init_with_pool (Thumb, 20 bytes, Stack size 16 bytes, tos_mmheap.o(i.mmheap_init_with_pool)) +

    [Stack]

    • Max Depth = 112 + Unknown Stack Size +
    • Call Chain = mmheap_init_with_pool ⇒ tos_mmheap_pool_add ⇒ blk_insert ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   mmheap_ctl_init +
    • >>   tos_mmheap_pool_add +
    +
    [Called By]
    • >>   tos_knl_init +
    + +

    mutex_release (Thumb, 20 bytes, Stack size 8 bytes, tos_mutex.o(i.mutex_release)) +

    [Stack]

    • Max Depth = 88 + Unknown Stack Size +
    • Call Chain = mutex_release ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   pend_wakeup_all +
    • >>   mutex_old_owner_release +
    +
    [Called By]
    • >>   task_mutex_release +
    + +

    osKernelInitialize (Thumb, 14 bytes, Stack size 8 bytes, cmsis_os.o(i.osKernelInitialize)) +

    [Stack]

    • Max Depth = 128 + Unknown Stack Size +
    • Call Chain = osKernelInitialize ⇒ tos_knl_init ⇒ mmheap_init_with_pool ⇒ tos_mmheap_pool_add ⇒ blk_insert ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   tos_knl_init +
    • >>   errno_knl2cmsis +
    +
    [Called By]
    • >>   main +
    + +

    osKernelStart (Thumb, 14 bytes, Stack size 8 bytes, cmsis_os.o(i.osKernelStart)) +

    [Stack]

    • Max Depth = 16 + Unknown Stack Size +
    • Call Chain = osKernelStart ⇒ tos_knl_start +
    +
    [Calls]
    • >>   tos_knl_start +
    • >>   errno_knl2cmsis +
    +
    [Called By]
    • >>   main +
    + +

    osThreadCreate (Thumb, 118 bytes, Stack size 40 bytes, cmsis_os.o(i.osThreadCreate)) +

    [Stack]

    • Max Depth = 288 + Unknown Stack Size +
    • Call Chain = osThreadCreate ⇒ tos_task_create_dyn ⇒ tos_mmheap_aligned_alloc ⇒ blk_prepare_used ⇒ blk_trim_free ⇒ blk_split ⇒ blk_mark_as_free ⇒ blk_link_next ⇒ blk_next +
    +
    [Calls]
    • >>   tos_task_create_dyn +
    • >>   tos_task_create +
    • >>   priority_cmsis2knl +
    +
    [Called By]
    • >>   main +
    + +

    pend_highest_pending_prio_get (Thumb, 34 bytes, Stack size 16 bytes, tos_pend.o(i.pend_highest_pending_prio_get)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = pend_highest_pending_prio_get +
    +
    [Calls]
    • >>   tos_list_empty +
    +
    [Called By]
    • >>   tos_mutex_post +
    • >>   task_highest_pending_prio_get +
    + +

    pend_highest_pending_task_get (Thumb, 8 bytes, Stack size 0 bytes, tos_pend.o(i.pend_highest_pending_task_get)) +

    [Called By]

    • >>   tos_mutex_post +
    + +

    pend_is_nopending (Thumb, 12 bytes, Stack size 8 bytes, tos_pend.o(i.pend_is_nopending)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = pend_is_nopending +
    +
    [Calls]
    • >>   tos_list_empty +
    +
    [Called By]
    • >>   tos_mutex_post +
    • >>   tos_sem_destroy +
    • >>   sem_do_post +
    + +

    pend_list_adjust (Thumb, 22 bytes, Stack size 8 bytes, tos_pend.o(i.pend_list_adjust)) +

    [Stack]

    • Max Depth = 20
    • Call Chain = pend_list_adjust ⇒ pend_list_add +
    +
    [Calls]
    • >>   tos_list_del +
    • >>   pend_list_add +
    +
    [Called By]
    • >>   tos_task_prio_change +
    + +

    pend_list_remove (Thumb, 34 bytes, Stack size 8 bytes, tos_pend.o(i.pend_list_remove)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = pend_list_remove +
    +
    [Calls]
    • >>   tos_list_del +
    +
    [Called By]
    • >>   pend_task_wakeup +
    • >>   task_do_destroy +
    + +

    pend_object_deinit (Thumb, 12 bytes, Stack size 8 bytes, tos_pend.o(i.pend_object_deinit)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = pend_object_deinit +
    +
    [Calls]
    • >>   tos_list_init +
    +
    [Called By]
    • >>   tos_sem_destroy +
    + +

    pend_object_init (Thumb, 12 bytes, Stack size 8 bytes, tos_pend.o(i.pend_object_init)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = pend_object_init +
    +
    [Calls]
    • >>   tos_list_init +
    +
    [Called By]
    • >>   tos_mutex_create +
    • >>   tos_sem_create_max +
    + +

    pend_state2errno (Thumb, 46 bytes, Stack size 0 bytes, tos_pend.o(i.pend_state2errno)) +

    [Called By]

    • >>   tos_mutex_pend_timed +
    • >>   tos_sem_pend +
    + +

    pend_task_block (Thumb, 42 bytes, Stack size 16 bytes, tos_pend.o(i.pend_task_block)) +

    [Stack]

    • Max Depth = 72 + Unknown Stack Size +
    • Call Chain = pend_task_block ⇒ tick_list_add ⇒ tick_task_place ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tick_list_add +
    • >>   readyqueue_remove +
    • >>   pend_list_add +
    +
    [Called By]
    • >>   tos_mutex_pend_timed +
    • >>   tos_sem_pend +
    + +

    pend_task_wakeup (Thumb, 70 bytes, Stack size 16 bytes, tos_pend.o(i.pend_task_wakeup)) +

    [Stack]

    • Max Depth = 56 + Unknown Stack Size +
    • Call Chain = pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   tick_list_remove +
    • >>   readyqueue_add +
    • >>   pend_list_remove +
    +
    [Called By]
    • >>   pend_wakeup_one +
    • >>   pend_wakeup_all +
    • >>   tick_update +
    + +

    pend_wakeup (Thumb, 30 bytes, Stack size 16 bytes, tos_pend.o(i.pend_wakeup)) +

    [Stack]

    • Max Depth = 96 + Unknown Stack Size +
    • Call Chain = pend_wakeup ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   pend_wakeup_one +
    • >>   pend_wakeup_all +
    +
    [Called By]
    • >>   sem_do_post +
    + +

    pend_wakeup_all (Thumb, 50 bytes, Stack size 24 bytes, tos_pend.o(i.pend_wakeup_all)) +

    [Stack]

    • Max Depth = 80 + Unknown Stack Size +
    • Call Chain = pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   pend_task_wakeup +
    +
    [Called By]
    • >>   pend_wakeup +
    • >>   mutex_release +
    • >>   tos_sem_destroy +
    + +

    pend_wakeup_one (Thumb, 20 bytes, Stack size 16 bytes, tos_pend.o(i.pend_wakeup_one)) +

    [Stack]

    • Max Depth = 72 + Unknown Stack Size +
    • Call Chain = pend_wakeup_one ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   pend_task_wakeup +
    +
    [Called By]
    • >>   pend_wakeup +
    • >>   tos_mutex_post +
    + +

    port_systick_config (Thumb, 50 bytes, Stack size 16 bytes, port_c.o(i.port_systick_config)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = port_systick_config ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   __NVIC_SetPriority +
    +
    [Called By]
    • >>   cpu_systick_init +
    + +

    port_systick_priority_set (Thumb, 16 bytes, Stack size 8 bytes, port_c.o(i.port_systick_priority_set)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = port_systick_priority_set ⇒ __NVIC_SetPriority +
    +
    [Calls]
    • >>   __NVIC_SetPriority +
    +
    [Called By]
    • >>   cpu_systick_init +
    + +

    pthread_attr_init (Thumb, 80 bytes, Stack size 0 bytes, pthread.o(i.pthread_attr_init)) +

    [Called By]

    • >>   pthread_create +
    • >>   firstborn_routine +
    • >>   application_entry +
    + +

    pthread_attr_setdetachstate (Thumb, 44 bytes, Stack size 0 bytes, pthread.o(i.pthread_attr_setdetachstate)) +

    [Called By]

    • >>   firstborn_routine +
    + +

    pthread_attr_setinheritsched (Thumb, 62 bytes, Stack size 0 bytes, pthread.o(i.pthread_attr_setinheritsched)) +

    [Called By]

    • >>   application_entry +
    + +

    pthread_attr_setschedparam (Thumb, 46 bytes, Stack size 0 bytes, pthread.o(i.pthread_attr_setschedparam)) +

    [Called By]

    • >>   application_entry +
    + +

    pthread_attr_setstack (Thumb, 76 bytes, Stack size 0 bytes, pthread.o(i.pthread_attr_setstack)) +

    [Called By]

    • >>   application_entry +
    + +

    pthread_cancel (Thumb, 78 bytes, Stack size 16 bytes, pthread.o(i.pthread_cancel)) +

    [Stack]

    • Max Depth = 160 + Unknown Stack Size +
    • Call Chain = pthread_cancel ⇒ tos_task_destroy ⇒ task_destroy_dyn ⇒ task_do_destroy ⇒ task_mutex_release ⇒ mutex_release ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   pthread_unlock +
    • >>   pthread_lock +
    • >>   pthread_ctl_by_id +
    • >>   tos_task_destroy +
    +
    [Called By]
    • >>   firstborn_routine +
    + +

    pthread_create (Thumb, 508 bytes, Stack size 112 bytes, pthread.o(i.pthread_create)) +

    [Stack]

    • Max Depth = 248 + Unknown Stack Size +
    • Call Chain = pthread_create ⇒ pthread_dead_reap ⇒ pthread_ctl_reap ⇒ tos_mmheap_free ⇒ blk_merge_prev ⇒ blk_remove ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   pthread_attr_init +
    • >>   __2snprintf +
    • >>   pthread_id_alloc +
    • >>   pthread_id_add +
    • >>   pthread_ctl_self +
    • >>   tos_mmheap_free +
    • >>   tos_mmheap_alloc +
    • >>   knl_is_inirq +
    • >>   tos_knl_sched_lock +
    • >>   tos_task_create +
    • >>   tos_knl_sched_unlock +
    • >>   tos_sem_destroy +
    • >>   tos_sem_create +
    • >>   pthread_dead_reap +
    +
    [Called By]
    • >>   firstborn_routine +
    • >>   application_entry +
    + +

    pthread_ctl_by_id (Thumb, 42 bytes, Stack size 0 bytes, pthread_prv.o(i.pthread_ctl_by_id)) +

    [Called By]

    • >>   pthread_join +
    • >>   pthread_cancel +
    + +

    pthread_ctl_reap (Thumb, 88 bytes, Stack size 24 bytes, pthread_prv.o(i.pthread_ctl_reap)) +

    [Stack]

    • Max Depth = 128 + Unknown Stack Size +
    • Call Chain = pthread_ctl_reap ⇒ tos_mmheap_free ⇒ blk_merge_prev ⇒ blk_remove ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   pthread_id_free +
    • >>   tos_mmheap_free +
    • >>   tos_sem_destroy +
    +
    [Called By]
    • >>   pthread_dead_reap +
    + +

    pthread_ctl_self (Thumb, 80 bytes, Stack size 24 bytes, pthread_prv.o(i.pthread_ctl_self)) +

    [Stack]

    • Max Depth = 48 + Unknown Stack Size +
    • Call Chain = pthread_ctl_self ⇒ tos_task_curr_task_get ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   tos_task_curr_task_get +
    +
    [Called By]
    • >>   pthread_setcanceltype +
    • >>   pthread_join +
    • >>   pthread_exit +
    • >>   pthread_create +
    • >>   pthread_setcancelstate +
    • >>   pthread_is_cancel_pending +
    + +

    pthread_exit (Thumb, 290 bytes, Stack size 40 bytes, pthread.o(i.pthread_exit)) +

    [Stack]

    • Max Depth = 184 + Unknown Stack Size +
    • Call Chain = pthread_exit ⇒ tos_task_destroy ⇒ task_destroy_dyn ⇒ task_do_destroy ⇒ task_mutex_release ⇒ mutex_release ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   pthread_unlock +
    • >>   pthread_lock +
    • >>   pthread_key_is_alloc +
    • >>   pthread_key_destructor_get +
    • >>   pthread_ctl_self +
    • >>   pthread_setcancelstate +
    • >>   tos_mmheap_free +
    • >>   tos_task_destroy +
    • >>   tos_sem_post_all +
    +
    [Called By]
    • >>   fourthborn_routine +
    • >>   pthread_testcancel +
    • >>   pthread_entry +
    + +

    pthread_id_add (Thumb, 60 bytes, Stack size 16 bytes, pthread_prv.o(i.pthread_id_add)) +

    [Stack]

    • Max Depth = 24 + Unknown Stack Size +
    • Call Chain = pthread_id_add ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    +
    [Called By]
    • >>   pthread_create +
    + +

    pthread_id_alloc (Thumb, 64 bytes, Stack size 16 bytes, pthread_prv.o(i.pthread_id_alloc)) +

    [Stack]

    • Max Depth = 24 + Unknown Stack Size +
    • Call Chain = pthread_id_alloc ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    +
    [Called By]
    • >>   pthread_create +
    + +

    pthread_id_free (Thumb, 60 bytes, Stack size 16 bytes, pthread_prv.o(i.pthread_id_free)) +

    [Stack]

    • Max Depth = 24 + Unknown Stack Size +
    • Call Chain = pthread_id_free ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    +
    [Called By]
    • >>   pthread_ctl_reap +
    + +

    pthread_init (Thumb, 30 bytes, Stack size 8 bytes, pthread_prv.o(i.pthread_init)) +

    [Stack]

    • Max Depth = 40
    • Call Chain = pthread_init ⇒ pthread_key_ctl_init ⇒ tos_bitmap_create_full +
    +
    [Calls]
    • >>   pthread_lock_init +
    • >>   pthread_key_ctl_init +
    +
    [Called By]
    • >>   tos_posix_init +
    + +

    pthread_join (Thumb, 228 bytes, Stack size 32 bytes, pthread.o(i.pthread_join)) +

    [Stack]

    • Max Depth = 224 + Unknown Stack Size +
    • Call Chain = pthread_join ⇒ pthread_testcancel ⇒ pthread_exit ⇒ tos_task_destroy ⇒ task_destroy_dyn ⇒ task_do_destroy ⇒ task_mutex_release ⇒ mutex_release ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   pthread_unlock +
    • >>   pthread_lock +
    • >>   pthread_ctl_self +
    • >>   pthread_ctl_by_id +
    • >>   pthread_testcancel +
    • >>   tos_sem_pend +
    • >>   pthread_is_cancel_pending +
    • >>   pthread_dead_reap +
    +
    [Called By]
    • >>   firstborn_routine +
    + +

    pthread_key_ctl_init (Thumb, 44 bytes, Stack size 8 bytes, pthread_prv.o(i.pthread_key_ctl_init)) +

    [Stack]

    • Max Depth = 32
    • Call Chain = pthread_key_ctl_init ⇒ tos_bitmap_create_full +
    +
    [Calls]
    • >>   tos_bitmap_create_full +
    +
    [Called By]
    • >>   pthread_init +
    + +

    pthread_key_destructor_get (Thumb, 24 bytes, Stack size 8 bytes, pthread_prv.o(i.pthread_key_destructor_get)) +

    [Stack]

    • Max Depth = 32
    • Call Chain = pthread_key_destructor_get ⇒ pthread_key_destructor_is_register ⇒ tos_bitmap_is_set +
    +
    [Calls]
    • >>   pthread_key_destructor_is_register +
    +
    [Called By]
    • >>   pthread_exit +
    + +

    pthread_key_is_alloc (Thumb, 26 bytes, Stack size 8 bytes, pthread_prv.o(i.pthread_key_is_alloc)) +

    [Stack]

    • Max Depth = 40
    • Call Chain = pthread_key_is_alloc ⇒ tos_bitmap_is_reset ⇒ tos_bitmap_is_set +
    +
    [Calls]
    • >>   tos_bitmap_is_reset +
    +
    [Called By]
    • >>   pthread_exit +
    + +

    pthread_lock (Thumb, 10 bytes, Stack size 8 bytes, pthread_prv.o(i.pthread_lock)) +

    [Stack]

    • Max Depth = 104 + Unknown Stack Size +
    • Call Chain = pthread_lock ⇒ tos_mutex_pend ⇒ tos_mutex_pend_timed ⇒ pend_task_block ⇒ tick_list_add ⇒ tick_task_place ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_mutex_pend +
    +
    [Called By]
    • >>   pthread_join +
    • >>   pthread_exit +
    • >>   pthread_cancel +
    + +

    pthread_lock_init (Thumb, 20 bytes, Stack size 8 bytes, pthread_prv.o(i.pthread_lock_init)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = pthread_lock_init ⇒ tos_mutex_create ⇒ pend_object_init +
    +
    [Calls]
    • >>   tos_mutex_create +
    +
    [Called By]
    • >>   pthread_init +
    + +

    pthread_setcancelstate (Thumb, 52 bytes, Stack size 16 bytes, pthread.o(i.pthread_setcancelstate)) +

    [Stack]

    • Max Depth = 64 + Unknown Stack Size +
    • Call Chain = pthread_setcancelstate ⇒ pthread_ctl_self ⇒ tos_task_curr_task_get ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   pthread_ctl_self +
    +
    [Called By]
    • >>   pthread_exit +
    + +

    pthread_setcanceltype (Thumb, 52 bytes, Stack size 16 bytes, pthread.o(i.pthread_setcanceltype)) +

    [Stack]

    • Max Depth = 64 + Unknown Stack Size +
    • Call Chain = pthread_setcanceltype ⇒ pthread_ctl_self ⇒ tos_task_curr_task_get ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   pthread_ctl_self +
    +
    [Called By]
    • >>   thirdborn_routine +
    + +

    pthread_testcancel (Thumb, 16 bytes, Stack size 8 bytes, pthread.o(i.pthread_testcancel)) +

    [Stack]

    • Max Depth = 192 + Unknown Stack Size +
    • Call Chain = pthread_testcancel ⇒ pthread_exit ⇒ tos_task_destroy ⇒ task_destroy_dyn ⇒ task_do_destroy ⇒ task_mutex_release ⇒ mutex_release ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   pthread_exit +
    • >>   pthread_is_cancel_pending +
    +
    [Called By]
    • >>   pthread_join +
    + +

    pthread_unlock (Thumb, 10 bytes, Stack size 8 bytes, pthread_prv.o(i.pthread_unlock)) +

    [Stack]

    • Max Depth = 120 + Unknown Stack Size +
    • Call Chain = pthread_unlock ⇒ tos_mutex_post ⇒ mutex_old_owner_release ⇒ tos_task_prio_change ⇒ readyqueue_remove ⇒ readyqueue_prio_highest_get ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   tos_mutex_post +
    +
    [Called By]
    • >>   pthread_join +
    • >>   pthread_exit +
    • >>   pthread_cancel +
    + +

    readyqueue_add (Thumb, 36 bytes, Stack size 8 bytes, tos_sched.o(i.readyqueue_add)) +

    [Stack]

    • Max Depth = 40
    • Call Chain = readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   readyqueue_add_tail +
    • >>   readyqueue_add_head +
    +
    [Called By]
    • >>   pend_task_wakeup +
    + +

    readyqueue_add_head (Thumb, 50 bytes, Stack size 24 bytes, tos_sched.o(i.readyqueue_add_head)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = readyqueue_add_head +
    +
    [Calls]
    • >>   tos_list_empty +
    • >>   readyqueue_prio_mark +
    • >>   _list_add +
    +
    [Called By]
    • >>   readyqueue_add +
    • >>   tos_task_prio_change +
    + +

    readyqueue_add_tail (Thumb, 40 bytes, Stack size 16 bytes, tos_sched.o(i.readyqueue_add_tail)) +

    [Stack]

    • Max Depth = 32
    • Call Chain = readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   tos_list_empty +
    • >>   tos_list_add_tail +
    • >>   readyqueue_prio_mark +
    +
    [Called By]
    • >>   readyqueue_add +
    • >>   tos_task_prio_change +
    • >>   tos_task_yield +
    • >>   tos_task_create +
    + +

    readyqueue_highest_ready_task_get (Thumb, 18 bytes, Stack size 0 bytes, tos_sched.o(i.readyqueue_highest_ready_task_get)) +

    [Called By]

    • >>   tos_knl_irq_leave +
    • >>   knl_sched +
    • >>   tos_knl_start +
    + +

    readyqueue_init (Thumb, 60 bytes, Stack size 0 bytes, tos_sched.o(i.readyqueue_init)) +

    [Called By]

    • >>   tos_knl_init +
    + +

    readyqueue_remove (Thumb, 96 bytes, Stack size 16 bytes, tos_sched.o(i.readyqueue_remove)) +

    [Stack]

    • Max Depth = 40 + Unknown Stack Size +
    • Call Chain = readyqueue_remove ⇒ readyqueue_prio_highest_get ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   tos_list_empty +
    • >>   readyqueue_prio_highest_get +
    • >>   _list_del +
    +
    [Called By]
    • >>   tos_task_delay +
    • >>   pend_task_block +
    • >>   tos_task_prio_change +
    • >>   tos_task_yield +
    • >>   task_do_destroy +
    + +

    secondborn_routine (Thumb, 30 bytes, Stack size 8 bytes, posix_sample.o(i.secondborn_routine)) +

    [Stack]

    • Max Depth = 80 + Unknown Stack Size +
    • Call Chain = secondborn_routine ⇒ tos_task_delay ⇒ tick_list_add ⇒ tick_task_place ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_task_delay +
    • >>   __2printf +
    +
    [Address Reference Count : 1]
    • posix_sample.o(i.firstborn_routine) +
    +

    task_free_all (Thumb, 74 bytes, Stack size 16 bytes, tos_task.o(i.task_free_all)) +

    [Stack]

    • Max Depth = 128 + Unknown Stack Size +
    • Call Chain = task_free_all ⇒ task_free ⇒ tos_mmheap_free ⇒ blk_merge_prev ⇒ blk_remove ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   tos_list_del +
    • >>   task_free +
    +
    [Called By]
    • >>   knl_idle_entry +
    + +

    thirdborn_routine (Thumb, 26 bytes, Stack size 0 bytes, posix_sample.o(i.thirdborn_routine)) +

    [Stack]

    • Max Depth = 72 + Unknown Stack Size +
    • Call Chain = thirdborn_routine ⇒ tos_task_delay ⇒ tick_list_add ⇒ tick_task_place ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_task_delay +
    • >>   pthread_setcanceltype +
    • >>   __2printf +
    +
    [Address Reference Count : 1]
    • posix_sample.o(i.firstborn_routine) +
    +

    tick_list_add (Thumb, 32 bytes, Stack size 16 bytes, tos_tick.o(i.tick_list_add)) +

    [Stack]

    • Max Depth = 56 + Unknown Stack Size +
    • Call Chain = tick_list_add ⇒ tick_task_place ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tick_task_place +
    +
    [Called By]
    • >>   tos_task_delay +
    • >>   pend_task_block +
    + +

    tick_list_remove (Thumb, 28 bytes, Stack size 8 bytes, tos_tick.o(i.tick_list_remove)) +

    [Stack]

    • Max Depth = 32 + Unknown Stack Size +
    • Call Chain = tick_list_remove ⇒ tick_task_takeoff ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tick_task_takeoff +
    +
    [Called By]
    • >>   pend_task_wakeup +
    • >>   task_do_destroy +
    + +

    tick_update (Thumb, 154 bytes, Stack size 24 bytes, tos_tick.o(i.tick_update)) +

    [Stack]

    • Max Depth = 80 + Unknown Stack Size +
    • Call Chain = tick_update ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   pend_task_wakeup +
    • >>   tos_list_empty +
    +
    [Called By]
    • >>   tos_tick_handler +
    + +

    timer_init (Thumb, 4 bytes, Stack size 0 bytes, tos_timer.o(i.timer_init)) +

    [Called By]

    • >>   tos_knl_init +
    + +

    timer_update (Thumb, 114 bytes, Stack size 16 bytes, tos_timer.o(i.timer_update)) +

    [Stack]

    • Max Depth = 48 + Unknown Stack Size +
    • Call Chain = timer_update ⇒ timer_takeoff ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_knl_sched_lock +
    • >>   timer_takeoff +
    • >>   timer_place +
    • >>   tos_knl_sched_unlock +
    +
    [Called By]
    • >>   tos_tick_handler +
    + +

    tos_bitmap_create_full (Thumb, 80 bytes, Stack size 24 bytes, tos_bitmap.o(i.tos_bitmap_create_full)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = tos_bitmap_create_full +
    +
    [Calls]
    • >>   knl_object_init +
    +
    [Called By]
    • >>   pthread_key_ctl_init +
    + +

    tos_bitmap_is_reset (Thumb, 72 bytes, Stack size 16 bytes, tos_bitmap.o(i.tos_bitmap_is_reset)) +

    [Stack]

    • Max Depth = 32
    • Call Chain = tos_bitmap_is_reset ⇒ tos_bitmap_is_set +
    +
    [Calls]
    • >>   tos_bitmap_is_set +
    • >>   knl_object_verify +
    +
    [Called By]
    • >>   pthread_key_is_alloc +
    + +

    tos_bitmap_is_set (Thumb, 86 bytes, Stack size 16 bytes, tos_bitmap.o(i.tos_bitmap_is_set)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = tos_bitmap_is_set +
    +
    [Calls]
    • >>   knl_object_verify +
    +
    [Called By]
    • >>   pthread_key_destructor_is_register +
    • >>   tos_bitmap_is_reset +
    + +

    tos_cpu_clz (Thumb, 12 bytes, Stack size 8 bytes, tos_cpu.o(i.tos_cpu_clz)) +

    [Stack]

    • Max Depth = 8 + Unknown Stack Size +
    • Call Chain = tos_cpu_clz +
    +
    [Calls]
    • >>   port_clz +
    +
    [Called By]
    • >>   generic_fls +
    • >>   readyqueue_prio_highest_get +
    + +

    tos_cpu_cpsr_restore (Thumb, 12 bytes, Stack size 8 bytes, tos_cpu.o(i.tos_cpu_cpsr_restore)) +

    [Stack]

    • Max Depth = 8 + Unknown Stack Size +
    • Call Chain = tos_cpu_cpsr_restore +
    +
    [Calls]
    • >>   port_cpsr_restore +
    +
    [Called By]
    • >>   tos_knl_irq_leave +
    • >>   tos_task_delay +
    • >>   pthread_id_free +
    • >>   pthread_id_alloc +
    • >>   pthread_id_add +
    • >>   pthread_ctl_self +
    • >>   knl_sched +
    • >>   tos_knl_sched_lock +
    • >>   tos_task_prio_change +
    • >>   tos_mutex_post +
    • >>   tos_mutex_pend_timed +
    • >>   timer_takeoff +
    • >>   timer_place +
    • >>   tick_update +
    • >>   tick_task_takeoff +
    • >>   tick_task_place +
    • >>   tos_task_yield +
    • >>   tos_task_curr_task_get +
    • >>   task_do_destroy +
    • >>   tos_task_create +
    • >>   task_free_all +
    • >>   tos_knl_sched_unlock +
    • >>   tos_sem_pend +
    • >>   tos_sem_destroy +
    • >>   sem_do_post +
    + +

    tos_cpu_cpsr_save (Thumb, 8 bytes, Stack size 8 bytes, tos_cpu.o(i.tos_cpu_cpsr_save)) +

    [Stack]

    • Max Depth = 8 + Unknown Stack Size +
    • Call Chain = tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   port_cpsr_save +
    +
    [Called By]
    • >>   tos_knl_irq_leave +
    • >>   tos_task_delay +
    • >>   pthread_id_free +
    • >>   pthread_id_alloc +
    • >>   pthread_id_add +
    • >>   pthread_ctl_self +
    • >>   knl_sched +
    • >>   tos_knl_sched_lock +
    • >>   tos_task_prio_change +
    • >>   tos_mutex_post +
    • >>   tos_mutex_pend_timed +
    • >>   timer_takeoff +
    • >>   timer_place +
    • >>   tick_update +
    • >>   tick_task_takeoff +
    • >>   tick_task_place +
    • >>   tos_task_yield +
    • >>   tos_task_curr_task_get +
    • >>   task_do_destroy +
    • >>   tos_task_create +
    • >>   task_free_all +
    • >>   tos_knl_sched_unlock +
    • >>   tos_sem_pend +
    • >>   tos_sem_destroy +
    • >>   sem_do_post +
    + +

    tos_knl_init (Thumb, 56 bytes, Stack size 8 bytes, tos_sys.o(i.tos_knl_init)) +

    [Stack]

    • Max Depth = 120 + Unknown Stack Size +
    • Call Chain = tos_knl_init ⇒ mmheap_init_with_pool ⇒ tos_mmheap_pool_add ⇒ blk_insert ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   mmheap_init_with_pool +
    • >>   timer_init +
    • >>   cpu_init +
    • >>   knl_idle_init +
    • >>   readyqueue_init +
    +
    [Called By]
    • >>   osKernelInitialize +
    + +

    tos_knl_irq_enter (Thumb, 42 bytes, Stack size 4 bytes, tos_sys.o(i.tos_knl_irq_enter)) +

    [Stack]

    • Max Depth = 4
    • Call Chain = tos_knl_irq_enter +
    +
    [Calls]
    • >>   tos_knl_is_running +
    +
    [Called By]
    • >>   SysTick_Handler +
    + +

    tos_knl_irq_leave (Thumb, 134 bytes, Stack size 8 bytes, tos_sys.o(i.tos_knl_irq_leave)) +

    [Stack]

    • Max Depth = 16 + Unknown Stack Size +
    • Call Chain = tos_knl_irq_leave ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_knl_is_running +
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   knl_is_sched_locked +
    • >>   knl_is_inirq +
    • >>   knl_is_self +
    • >>   cpu_irq_context_switch +
    • >>   readyqueue_highest_ready_task_get +
    +
    [Called By]
    • >>   SysTick_Handler +
    + +

    tos_knl_is_running (Thumb, 14 bytes, Stack size 0 bytes, tos_sys.o(i.tos_knl_is_running)) +

    [Called By]

    • >>   tos_tick_handler +
    • >>   tos_knl_irq_leave +
    • >>   tos_knl_irq_enter +
    • >>   SysTick_Handler +
    • >>   knl_sched +
    • >>   tos_knl_sched_lock +
    • >>   tos_task_curr_task_get +
    • >>   tos_task_create +
    • >>   tos_knl_start +
    • >>   tos_knl_sched_unlock +
    + +

    tos_knl_sched_lock (Thumb, 88 bytes, Stack size 8 bytes, tos_sys.o(i.tos_knl_sched_lock)) +

    [Stack]

    • Max Depth = 16 + Unknown Stack Size +
    • Call Chain = tos_knl_sched_lock ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_knl_is_running +
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   knl_is_inirq +
    +
    [Called By]
    • >>   pthread_create +
    • >>   timer_update +
    • >>   task_destroy_dyn +
    + +

    tos_knl_sched_unlock (Thumb, 90 bytes, Stack size 8 bytes, tos_sys.o(i.tos_knl_sched_unlock)) +

    [Stack]

    • Max Depth = 24 + Unknown Stack Size +
    • Call Chain = tos_knl_sched_unlock ⇒ knl_sched ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_knl_is_running +
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   knl_sched +
    • >>   knl_is_sched_locked +
    • >>   knl_is_inirq +
    +
    [Called By]
    • >>   pthread_create +
    • >>   timer_update +
    • >>   task_destroy_dyn +
    + +

    tos_knl_start (Thumb, 52 bytes, Stack size 8 bytes, tos_sys.o(i.tos_knl_start)) +

    [Stack]

    • Max Depth = 8 + Unknown Stack Size +
    • Call Chain = tos_knl_start +
    +
    [Calls]
    • >>   tos_knl_is_running +
    • >>   cpu_sched_start +
    • >>   readyqueue_highest_ready_task_get +
    +
    [Called By]
    • >>   osKernelStart +
    + +

    tos_mmheap_aligned_alloc (Thumb, 164 bytes, Stack size 64 bytes, tos_mmheap.o(i.tos_mmheap_aligned_alloc)) +

    [Stack]

    • Max Depth = 176 + Unknown Stack Size +
    • Call Chain = tos_mmheap_aligned_alloc ⇒ blk_prepare_used ⇒ blk_trim_free ⇒ blk_split ⇒ blk_mark_as_free ⇒ blk_link_next ⇒ blk_next +
    +
    [Calls]
    • >>   blk_trim_free_leading +
    • >>   blk_to_ptr +
    • >>   blk_prepare_used +
    • >>   blk_locate_free +
    • >>   align_ptr +
    • >>   adjust_request_size +
    +
    [Called By]
    • >>   tos_task_create_dyn +
    + +

    tos_mmheap_alloc (Thumb, 38 bytes, Stack size 16 bytes, tos_mmheap.o(i.tos_mmheap_alloc)) +

    [Stack]

    • Max Depth = 128 + Unknown Stack Size +
    • Call Chain = tos_mmheap_alloc ⇒ blk_prepare_used ⇒ blk_trim_free ⇒ blk_split ⇒ blk_mark_as_free ⇒ blk_link_next ⇒ blk_next +
    +
    [Calls]
    • >>   blk_prepare_used +
    • >>   blk_locate_free +
    • >>   adjust_request_size +
    +
    [Called By]
    • >>   pthread_create +
    • >>   tos_task_create_dyn +
    + +

    tos_mmheap_free (Thumb, 48 bytes, Stack size 16 bytes, tos_mmheap.o(i.tos_mmheap_free)) +

    [Stack]

    • Max Depth = 104 + Unknown Stack Size +
    • Call Chain = tos_mmheap_free ⇒ blk_merge_prev ⇒ blk_remove ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   blk_merge_prev +
    • >>   blk_merge_next +
    • >>   blk_mark_as_free +
    • >>   blk_insert +
    +
    [Called By]
    • >>   pthread_exit +
    • >>   pthread_create +
    • >>   pthread_ctl_reap +
    • >>   tos_task_create_dyn +
    • >>   task_free +
    + +

    tos_mmheap_pool_add (Thumb, 182 bytes, Stack size 24 bytes, tos_mmheap.o(i.tos_mmheap_pool_add)) +

    [Stack]

    • Max Depth = 96 + Unknown Stack Size +
    • Call Chain = tos_mmheap_pool_add ⇒ blk_insert ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   offset_to_blk +
    • >>   mmheap_pool_is_exist +
    • >>   blk_set_used +
    • >>   blk_set_size +
    • >>   blk_set_prev_used +
    • >>   blk_set_prev_free +
    • >>   blk_set_free +
    • >>   blk_link_next +
    • >>   blk_insert +
    +
    [Called By]
    • >>   mmheap_init_with_pool +
    + +

    tos_mutex_create (Thumb, 86 bytes, Stack size 8 bytes, tos_mutex.o(i.tos_mutex_create)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = tos_mutex_create ⇒ pend_object_init +
    +
    [Calls]
    • >>   pend_object_init +
    • >>   knl_is_inirq +
    +
    [Called By]
    • >>   pthread_lock_init +
    + +

    tos_mutex_pend (Thumb, 16 bytes, Stack size 8 bytes, tos_mutex.o(i.tos_mutex_pend)) +

    [Stack]

    • Max Depth = 96 + Unknown Stack Size +
    • Call Chain = tos_mutex_pend ⇒ tos_mutex_pend_timed ⇒ pend_task_block ⇒ tick_list_add ⇒ tick_task_place ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_mutex_pend_timed +
    +
    [Called By]
    • >>   pthread_lock +
    + +

    tos_mutex_pend_timed (Thumb, 276 bytes, Stack size 16 bytes, tos_mutex.o(i.tos_mutex_pend_timed)) +

    [Stack]

    • Max Depth = 88 + Unknown Stack Size +
    • Call Chain = tos_mutex_pend_timed ⇒ pend_task_block ⇒ tick_list_add ⇒ tick_task_place ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   pend_task_block +
    • >>   pend_state2errno +
    • >>   knl_sched +
    • >>   knl_is_sched_locked +
    • >>   knl_is_inirq +
    • >>   tos_task_prio_change +
    • >>   knl_is_self +
    • >>   mutex_fresh_owner_mark +
    • >>   knl_object_verify +
    +
    [Called By]
    • >>   tos_mutex_pend +
    + +

    tos_mutex_post (Thumb, 240 bytes, Stack size 32 bytes, tos_mutex.o(i.tos_mutex_post)) +

    [Stack]

    • Max Depth = 112 + Unknown Stack Size +
    • Call Chain = tos_mutex_post ⇒ mutex_old_owner_release ⇒ tos_task_prio_change ⇒ readyqueue_remove ⇒ readyqueue_prio_highest_get ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   pend_wakeup_one +
    • >>   pend_is_nopending +
    • >>   knl_sched +
    • >>   knl_is_inirq +
    • >>   tos_task_prio_change +
    • >>   pend_highest_pending_task_get +
    • >>   pend_highest_pending_prio_get +
    • >>   knl_is_self +
    • >>   mutex_old_owner_release +
    • >>   mutex_fresh_owner_mark +
    • >>   knl_object_verify +
    +
    [Called By]
    • >>   pthread_unlock +
    + +

    tos_posix_init (Thumb, 8 bytes, Stack size 8 bytes, tos_posix.o(i.tos_posix_init)) +

    [Stack]

    • Max Depth = 48
    • Call Chain = tos_posix_init ⇒ pthread_init ⇒ pthread_key_ctl_init ⇒ tos_bitmap_create_full +
    +
    [Calls]
    • >>   pthread_init +
    +
    [Called By]
    • >>   application_entry +
    + +

    tos_sem_create (Thumb, 20 bytes, Stack size 16 bytes, tos_sem.o(i.tos_sem_create)) +

    [Stack]

    • Max Depth = 40
    • Call Chain = tos_sem_create ⇒ tos_sem_create_max ⇒ pend_object_init +
    +
    [Calls]
    • >>   tos_sem_create_max +
    +
    [Called By]
    • >>   pthread_create +
    + +

    tos_sem_create_max (Thumb, 50 bytes, Stack size 16 bytes, tos_sem.o(i.tos_sem_create_max)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = tos_sem_create_max ⇒ pend_object_init +
    +
    [Calls]
    • >>   pend_object_init +
    +
    [Called By]
    • >>   tos_sem_create +
    + +

    tos_sem_destroy (Thumb, 106 bytes, Stack size 16 bytes, tos_sem.o(i.tos_sem_destroy)) +

    [Stack]

    • Max Depth = 96 + Unknown Stack Size +
    • Call Chain = tos_sem_destroy ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   pend_wakeup_all +
    • >>   pend_object_deinit +
    • >>   pend_is_nopending +
    • >>   knl_sched +
    • >>   knl_object_verify +
    +
    [Called By]
    • >>   pthread_create +
    • >>   pthread_ctl_reap +
    + +

    tos_sem_pend (Thumb, 190 bytes, Stack size 16 bytes, tos_sem.o(i.tos_sem_pend)) +

    [Stack]

    • Max Depth = 88 + Unknown Stack Size +
    • Call Chain = tos_sem_pend ⇒ pend_task_block ⇒ tick_list_add ⇒ tick_task_place ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   pend_task_block +
    • >>   pend_state2errno +
    • >>   knl_sched +
    • >>   knl_is_sched_locked +
    • >>   knl_is_inirq +
    • >>   knl_object_verify +
    +
    [Called By]
    • >>   pthread_join +
    + +

    tos_sem_post_all (Thumb, 14 bytes, Stack size 8 bytes, tos_sem.o(i.tos_sem_post_all)) +

    [Stack]

    • Max Depth = 120 + Unknown Stack Size +
    • Call Chain = tos_sem_post_all ⇒ sem_do_post ⇒ pend_wakeup ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   sem_do_post +
    +
    [Called By]
    • >>   pthread_exit +
    + +

    tos_task_create (Thumb, 322 bytes, Stack size 40 bytes, tos_task.o(i.tos_task_create)) +

    [Stack]

    • Max Depth = 72 + Unknown Stack Size +
    • Call Chain = tos_task_create ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   tos_knl_is_running +
    • >>   strncpy +
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   knl_sched +
    • >>   knl_is_inirq +
    • >>   cpu_task_stk_init +
    • >>   tos_list_add +
    • >>   task_reset +
    • >>   knl_is_idle +
    • >>   readyqueue_add_tail +
    +
    [Called By]
    • >>   osThreadCreate +
    • >>   pthread_create +
    • >>   tos_task_create_dyn +
    • >>   knl_idle_init +
    + +

    tos_task_create_dyn (Thumb, 240 bytes, Stack size 72 bytes, tos_task.o(i.tos_task_create_dyn)) +

    [Stack]

    • Max Depth = 248 + Unknown Stack Size +
    • Call Chain = tos_task_create_dyn ⇒ tos_mmheap_aligned_alloc ⇒ blk_prepare_used ⇒ blk_trim_free ⇒ blk_split ⇒ blk_mark_as_free ⇒ blk_link_next ⇒ blk_next +
    +
    [Calls]
    • >>   tos_mmheap_free +
    • >>   tos_mmheap_alloc +
    • >>   knl_is_inirq +
    • >>   tos_mmheap_aligned_alloc +
    • >>   task_free +
    • >>   tos_task_create +
    +
    [Called By]
    • >>   osThreadCreate +
    + +

    tos_task_curr_task_get (Thumb, 48 bytes, Stack size 16 bytes, tos_task.o(i.tos_task_curr_task_get)) +

    [Stack]

    • Max Depth = 24 + Unknown Stack Size +
    • Call Chain = tos_task_curr_task_get ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_knl_is_running +
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    +
    [Called By]
    • >>   pthread_ctl_self +
    + +

    tos_task_delay (Thumb, 122 bytes, Stack size 16 bytes, tos_task.o(i.tos_task_delay)) +

    [Stack]

    • Max Depth = 72 + Unknown Stack Size +
    • Call Chain = tos_task_delay ⇒ tick_list_add ⇒ tick_task_place ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   knl_sched +
    • >>   knl_is_sched_locked +
    • >>   knl_is_inirq +
    • >>   tick_list_add +
    • >>   readyqueue_remove +
    • >>   tos_task_yield +
    +
    [Called By]
    • >>   thirdborn_routine +
    • >>   secondborn_routine +
    • >>   fourthborn_routine +
    • >>   firstborn_routine +
    + +

    tos_task_destroy (Thumb, 116 bytes, Stack size 8 bytes, tos_task.o(i.tos_task_destroy)) +

    [Stack]

    • Max Depth = 144 + Unknown Stack Size +
    • Call Chain = tos_task_destroy ⇒ task_destroy_dyn ⇒ task_do_destroy ⇒ task_mutex_release ⇒ mutex_release ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   knl_is_sched_locked +
    • >>   knl_is_inirq +
    • >>   knl_is_self +
    • >>   task_destroy_static +
    • >>   task_destroy_dyn +
    • >>   knl_object_verify +
    +
    [Called By]
    • >>   pthread_exit +
    • >>   pthread_cancel +
    • >>   task_exit +
    + +

    tos_task_prio_change (Thumb, 260 bytes, Stack size 24 bytes, tos_task.o(i.tos_task_prio_change)) +

    [Stack]

    • Max Depth = 64 + Unknown Stack Size +
    • Call Chain = tos_task_prio_change ⇒ readyqueue_remove ⇒ readyqueue_prio_highest_get ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   knl_sched +
    • >>   knl_is_inirq +
    • >>   readyqueue_remove +
    • >>   pend_list_adjust +
    • >>   knl_is_self +
    • >>   tos_list_empty +
    • >>   task_state_is_ready +
    • >>   task_highest_pending_prio_get +
    • >>   knl_object_verify +
    • >>   readyqueue_add_tail +
    • >>   readyqueue_add_head +
    +
    [Called By]
    • >>   tos_mutex_post +
    • >>   tos_mutex_pend_timed +
    • >>   mutex_old_owner_release +
    + +

    tos_task_yield (Thumb, 56 bytes, Stack size 8 bytes, tos_task.o(i.tos_task_yield)) +

    [Stack]

    • Max Depth = 48 + Unknown Stack Size +
    • Call Chain = tos_task_yield ⇒ readyqueue_remove ⇒ readyqueue_prio_highest_get ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   knl_sched +
    • >>   knl_is_inirq +
    • >>   readyqueue_remove +
    • >>   readyqueue_add_tail +
    +
    [Called By]
    • >>   tos_task_delay +
    + +

    tos_tick_handler (Thumb, 32 bytes, Stack size 8 bytes, tos_tick.o(i.tos_tick_handler)) +

    [Stack]

    • Max Depth = 88 + Unknown Stack Size +
    • Call Chain = tos_tick_handler ⇒ tick_update ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   tos_knl_is_running +
    • >>   timer_update +
    • >>   tick_update +
    +
    [Called By]
    • >>   SysTick_Handler +
    +

    +

    +Local Symbols +

    +

    UART_DMAAbortOnError (Thumb, 24 bytes, Stack size 16 bytes, stm32l4xx_hal_uart.o(i.UART_DMAAbortOnError)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = UART_DMAAbortOnError +
    +
    [Calls]
    • >>   HAL_UART_ErrorCallback +
    +
    [Address Reference Count : 1]
    • stm32l4xx_hal_uart.o(i.HAL_UART_IRQHandler) +
    +

    UART_EndRxTransfer (Thumb, 36 bytes, Stack size 0 bytes, stm32l4xx_hal_uart.o(i.UART_EndRxTransfer)) +

    [Called By]

    • >>   HAL_UART_IRQHandler +
    + +

    UART_EndTransmit_IT (Thumb, 34 bytes, Stack size 8 bytes, stm32l4xx_hal_uart.o(i.UART_EndTransmit_IT)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = UART_EndTransmit_IT +
    +
    [Calls]
    • >>   HAL_UART_TxCpltCallback +
    +
    [Called By]
    • >>   HAL_UART_IRQHandler +
    + +

    UART_RxISR_16BIT (Thumb, 108 bytes, Stack size 24 bytes, stm32l4xx_hal_uart.o(i.UART_RxISR_16BIT)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = UART_RxISR_16BIT +
    +
    [Calls]
    • >>   HAL_UART_RxCpltCallback +
    +
    [Address Reference Count : 1]
    • stm32l4xx_hal_uart.o(i.HAL_UART_Receive_IT) +
    +

    UART_RxISR_8BIT (Thumb, 102 bytes, Stack size 16 bytes, stm32l4xx_hal_uart.o(i.UART_RxISR_8BIT)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = UART_RxISR_8BIT +
    +
    [Calls]
    • >>   HAL_UART_RxCpltCallback +
    +
    [Address Reference Count : 1]
    • stm32l4xx_hal_uart.o(i.HAL_UART_Receive_IT) +
    +

    RCC_SetFlashLatencyFromMSIRange (Thumb, 148 bytes, Stack size 24 bytes, stm32l4xx_hal_rcc.o(i.RCC_SetFlashLatencyFromMSIRange)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = RCC_SetFlashLatencyFromMSIRange +
    +
    [Calls]
    • >>   HAL_PWREx_GetVoltageRange +
    +
    [Called By]
    • >>   HAL_RCC_OscConfig +
    + +

    RCCEx_PLLSAI1_Config (Thumb, 376 bytes, Stack size 24 bytes, stm32l4xx_hal_rcc_ex.o(i.RCCEx_PLLSAI1_Config)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = RCCEx_PLLSAI1_Config +
    +
    [Calls]
    • >>   HAL_GetTick +
    +
    [Called By]
    • >>   HAL_RCCEx_PeriphCLKConfig +
    + +

    __NVIC_GetPriorityGrouping (Thumb, 10 bytes, Stack size 0 bytes, stm32l4xx_hal_cortex.o(i.__NVIC_GetPriorityGrouping)) +

    [Called By]

    • >>   HAL_NVIC_SetPriority +
    + +

    __NVIC_SetPriority (Thumb, 32 bytes, Stack size 8 bytes, stm32l4xx_hal_cortex.o(i.__NVIC_SetPriority)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = __NVIC_SetPriority +
    +
    [Called By]
    • >>   HAL_NVIC_SetPriority +
    • >>   HAL_SYSTICK_Config +
    + +

    DHT11_Mode_Out_PP (Thumb, 30 bytes, Stack size 24 bytes, dht11_bus.o(i.DHT11_Mode_Out_PP)) +

    [Stack]

    • Max Depth = 44
    • Call Chain = DHT11_Mode_Out_PP ⇒ HAL_GPIO_Init +
    +
    [Calls]
    • >>   HAL_GPIO_Init +
    +
    [Called By]
    • >>   DHT11_Init +
    + +

    __ffs (Thumb, 20 bytes, Stack size 8 bytes, tos_mmheap.o(i.__ffs)) +

    [Stack]

    • Max Depth = 24 + Unknown Stack Size +
    • Call Chain = __ffs ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   generic_fls +
    +
    [Called By]
    • >>   blk_search_suitable +
    + +

    __fls (Thumb, 14 bytes, Stack size 8 bytes, tos_mmheap.o(i.__fls)) +

    [Stack]

    • Max Depth = 24 + Unknown Stack Size +
    • Call Chain = __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   generic_fls +
    +
    [Called By]
    • >>   mapping_search +
    • >>   mapping_insert +
    + +

    adjust_request_size (Thumb, 46 bytes, Stack size 8 bytes, tos_mmheap.o(i.adjust_request_size)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = adjust_request_size +
    +
    [Called By]
    • >>   tos_mmheap_alloc +
    • >>   tos_mmheap_aligned_alloc +
    + +

    align_ptr (Thumb, 12 bytes, Stack size 0 bytes, tos_mmheap.o(i.align_ptr)) +

    [Called By]

    • >>   tos_mmheap_aligned_alloc +
    + +

    blk_absorb (Thumb, 30 bytes, Stack size 16 bytes, tos_mmheap.o(i.blk_absorb)) +

    [Stack]

    • Max Depth = 56
    • Call Chain = blk_absorb ⇒ blk_link_next ⇒ blk_next +
    +
    [Calls]
    • >>   blk_size +
    • >>   blk_link_next +
    +
    [Called By]
    • >>   blk_merge_prev +
    • >>   blk_merge_next +
    + +

    blk_can_split (Thumb, 28 bytes, Stack size 16 bytes, tos_mmheap.o(i.blk_can_split)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = blk_can_split +
    +
    [Calls]
    • >>   blk_size +
    +
    [Called By]
    • >>   blk_trim_free_leading +
    • >>   blk_trim_free +
    + +

    blk_insert (Thumb, 32 bytes, Stack size 24 bytes, tos_mmheap.o(i.blk_insert)) +

    [Stack]

    • Max Depth = 72 + Unknown Stack Size +
    • Call Chain = blk_insert ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   mapping_insert +
    • >>   insert_free_block +
    • >>   blk_size +
    +
    [Called By]
    • >>   tos_mmheap_free +
    • >>   blk_trim_free_leading +
    • >>   blk_trim_free +
    • >>   tos_mmheap_pool_add +
    + +

    blk_link_next (Thumb, 18 bytes, Stack size 16 bytes, tos_mmheap.o(i.blk_link_next)) +

    [Stack]

    • Max Depth = 40
    • Call Chain = blk_link_next ⇒ blk_next +
    +
    [Calls]
    • >>   blk_next +
    +
    [Called By]
    • >>   blk_trim_free_leading +
    • >>   blk_trim_free +
    • >>   blk_mark_as_free +
    • >>   blk_absorb +
    • >>   tos_mmheap_pool_add +
    + +

    blk_locate_free (Thumb, 58 bytes, Stack size 24 bytes, tos_mmheap.o(i.blk_locate_free)) +

    [Stack]

    • Max Depth = 96 + Unknown Stack Size +
    • Call Chain = blk_locate_free ⇒ mapping_search ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   remove_free_block +
    • >>   mapping_search +
    • >>   blk_search_suitable +
    +
    [Called By]
    • >>   tos_mmheap_alloc +
    • >>   tos_mmheap_aligned_alloc +
    + +

    blk_mark_as_free (Thumb, 26 bytes, Stack size 16 bytes, tos_mmheap.o(i.blk_mark_as_free)) +

    [Stack]

    • Max Depth = 56
    • Call Chain = blk_mark_as_free ⇒ blk_link_next ⇒ blk_next +
    +
    [Calls]
    • >>   blk_set_prev_free +
    • >>   blk_set_free +
    • >>   blk_link_next +
    +
    [Called By]
    • >>   tos_mmheap_free +
    • >>   blk_split +
    + +

    blk_mark_as_used (Thumb, 26 bytes, Stack size 16 bytes, tos_mmheap.o(i.blk_mark_as_used)) +

    [Stack]

    • Max Depth = 40
    • Call Chain = blk_mark_as_used ⇒ blk_next +
    +
    [Calls]
    • >>   blk_set_used +
    • >>   blk_set_prev_used +
    • >>   blk_next +
    +
    [Called By]
    • >>   blk_prepare_used +
    + +

    blk_merge_next (Thumb, 42 bytes, Stack size 16 bytes, tos_mmheap.o(i.blk_merge_next)) +

    [Stack]

    • Max Depth = 88 + Unknown Stack Size +
    • Call Chain = blk_merge_next ⇒ blk_remove ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   blk_remove +
    • >>   blk_next +
    • >>   blk_absorb +
    +
    [Called By]
    • >>   tos_mmheap_free +
    + +

    blk_merge_prev (Thumb, 40 bytes, Stack size 16 bytes, tos_mmheap.o(i.blk_merge_prev)) +

    [Stack]

    • Max Depth = 88 + Unknown Stack Size +
    • Call Chain = blk_merge_prev ⇒ blk_remove ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   blk_remove +
    • >>   blk_absorb +
    +
    [Called By]
    • >>   tos_mmheap_free +
    + +

    blk_next (Thumb, 36 bytes, Stack size 24 bytes, tos_mmheap.o(i.blk_next)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = blk_next +
    +
    [Calls]
    • >>   offset_to_blk +
    • >>   blk_to_ptr +
    • >>   blk_size +
    +
    [Called By]
    • >>   blk_merge_next +
    • >>   blk_mark_as_used +
    • >>   blk_link_next +
    + +

    blk_prepare_used (Thumb, 34 bytes, Stack size 16 bytes, tos_mmheap.o(i.blk_prepare_used)) +

    [Stack]

    • Max Depth = 112 + Unknown Stack Size +
    • Call Chain = blk_prepare_used ⇒ blk_trim_free ⇒ blk_split ⇒ blk_mark_as_free ⇒ blk_link_next ⇒ blk_next +
    +
    [Calls]
    • >>   blk_trim_free +
    • >>   blk_to_ptr +
    • >>   blk_mark_as_used +
    +
    [Called By]
    • >>   tos_mmheap_alloc +
    • >>   tos_mmheap_aligned_alloc +
    + +

    blk_remove (Thumb, 32 bytes, Stack size 24 bytes, tos_mmheap.o(i.blk_remove)) +

    [Stack]

    • Max Depth = 72 + Unknown Stack Size +
    • Call Chain = blk_remove ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   remove_free_block +
    • >>   mapping_insert +
    • >>   blk_size +
    +
    [Called By]
    • >>   blk_merge_prev +
    • >>   blk_merge_next +
    + +

    blk_search_suitable (Thumb, 104 bytes, Stack size 32 bytes, tos_mmheap.o(i.blk_search_suitable)) +

    [Stack]

    • Max Depth = 56 + Unknown Stack Size +
    • Call Chain = blk_search_suitable ⇒ __ffs ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   __ffs +
    +
    [Called By]
    • >>   blk_locate_free +
    + +

    blk_set_free (Thumb, 10 bytes, Stack size 0 bytes, tos_mmheap.o(i.blk_set_free)) +

    [Called By]

    • >>   blk_mark_as_free +
    • >>   tos_mmheap_pool_add +
    + +

    blk_set_prev_free (Thumb, 10 bytes, Stack size 0 bytes, tos_mmheap.o(i.blk_set_prev_free)) +

    [Called By]

    • >>   blk_trim_free_leading +
    • >>   blk_trim_free +
    • >>   blk_mark_as_free +
    • >>   tos_mmheap_pool_add +
    + +

    blk_set_prev_used (Thumb, 10 bytes, Stack size 0 bytes, tos_mmheap.o(i.blk_set_prev_used)) +

    [Called By]

    • >>   blk_mark_as_used +
    • >>   tos_mmheap_pool_add +
    + +

    blk_set_size (Thumb, 12 bytes, Stack size 0 bytes, tos_mmheap.o(i.blk_set_size)) +

    [Called By]

    • >>   blk_split +
    • >>   tos_mmheap_pool_add +
    + +

    blk_set_used (Thumb, 10 bytes, Stack size 0 bytes, tos_mmheap.o(i.blk_set_used)) +

    [Called By]

    • >>   blk_mark_as_used +
    • >>   tos_mmheap_pool_add +
    + +

    blk_size (Thumb, 10 bytes, Stack size 0 bytes, tos_mmheap.o(i.blk_size)) +

    [Called By]

    • >>   blk_split +
    • >>   blk_remove +
    • >>   blk_next +
    • >>   blk_insert +
    • >>   blk_can_split +
    • >>   blk_absorb +
    + +

    blk_split (Thumb, 62 bytes, Stack size 24 bytes, tos_mmheap.o(i.blk_split)) +

    [Stack]

    • Max Depth = 80
    • Call Chain = blk_split ⇒ blk_mark_as_free ⇒ blk_link_next ⇒ blk_next +
    +
    [Calls]
    • >>   offset_to_blk +
    • >>   blk_to_ptr +
    • >>   blk_size +
    • >>   blk_set_size +
    • >>   blk_mark_as_free +
    +
    [Called By]
    • >>   blk_trim_free_leading +
    • >>   blk_trim_free +
    + +

    blk_to_ptr (Thumb, 8 bytes, Stack size 0 bytes, tos_mmheap.o(i.blk_to_ptr)) +

    [Called By]

    • >>   blk_split +
    • >>   blk_prepare_used +
    • >>   blk_next +
    • >>   tos_mmheap_aligned_alloc +
    + +

    blk_trim_free (Thumb, 46 bytes, Stack size 16 bytes, tos_mmheap.o(i.blk_trim_free)) +

    [Stack]

    • Max Depth = 96 + Unknown Stack Size +
    • Call Chain = blk_trim_free ⇒ blk_split ⇒ blk_mark_as_free ⇒ blk_link_next ⇒ blk_next +
    +
    [Calls]
    • >>   blk_split +
    • >>   blk_set_prev_free +
    • >>   blk_link_next +
    • >>   blk_insert +
    • >>   blk_can_split +
    +
    [Called By]
    • >>   blk_prepare_used +
    + +

    blk_trim_free_leading (Thumb, 50 bytes, Stack size 16 bytes, tos_mmheap.o(i.blk_trim_free_leading)) +

    [Stack]

    • Max Depth = 96 + Unknown Stack Size +
    • Call Chain = blk_trim_free_leading ⇒ blk_split ⇒ blk_mark_as_free ⇒ blk_link_next ⇒ blk_next +
    +
    [Calls]
    • >>   blk_split +
    • >>   blk_set_prev_free +
    • >>   blk_link_next +
    • >>   blk_insert +
    • >>   blk_can_split +
    +
    [Called By]
    • >>   tos_mmheap_aligned_alloc +
    + +

    generic_fls (Thumb, 16 bytes, Stack size 8 bytes, tos_mmheap.o(i.generic_fls)) +

    [Stack]

    • Max Depth = 16 + Unknown Stack Size +
    • Call Chain = generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   tos_cpu_clz +
    +
    [Called By]
    • >>   __fls +
    • >>   __ffs +
    + +

    insert_free_block (Thumb, 74 bytes, Stack size 12 bytes, tos_mmheap.o(i.insert_free_block)) +

    [Stack]

    • Max Depth = 12
    • Call Chain = insert_free_block +
    +
    [Called By]
    • >>   blk_insert +
    + +

    mapping_insert (Thumb, 58 bytes, Stack size 24 bytes, tos_mmheap.o(i.mapping_insert)) +

    [Stack]

    • Max Depth = 48 + Unknown Stack Size +
    • Call Chain = mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   __fls +
    +
    [Called By]
    • >>   mapping_search +
    • >>   blk_remove +
    • >>   blk_insert +
    + +

    mapping_search (Thumb, 46 bytes, Stack size 24 bytes, tos_mmheap.o(i.mapping_search)) +

    [Stack]

    • Max Depth = 72 + Unknown Stack Size +
    • Call Chain = mapping_search ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   mapping_insert +
    • >>   __fls +
    +
    [Called By]
    • >>   blk_locate_free +
    + +

    mmheap_ctl_init (Thumb, 88 bytes, Stack size 0 bytes, tos_mmheap.o(i.mmheap_ctl_init)) +

    [Called By]

    • >>   mmheap_init_with_pool +
    + +

    mmheap_pool_is_exist (Thumb, 38 bytes, Stack size 0 bytes, tos_mmheap.o(i.mmheap_pool_is_exist)) +

    [Called By]

    • >>   tos_mmheap_pool_add +
    + +

    offset_to_blk (Thumb, 6 bytes, Stack size 0 bytes, tos_mmheap.o(i.offset_to_blk)) +

    [Called By]

    • >>   blk_split +
    • >>   blk_next +
    • >>   tos_mmheap_pool_add +
    + +

    remove_free_block (Thumb, 92 bytes, Stack size 16 bytes, tos_mmheap.o(i.remove_free_block)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = remove_free_block +
    +
    [Called By]
    • >>   blk_remove +
    • >>   blk_locate_free +
    + +

    knl_object_verify (Thumb, 16 bytes, Stack size 0 bytes, tos_mutex.o(i.knl_object_verify)) +

    [Called By]

    • >>   tos_mutex_post +
    • >>   tos_mutex_pend_timed +
    + +

    mutex_fresh_owner_mark (Thumb, 42 bytes, Stack size 8 bytes, tos_mutex.o(i.mutex_fresh_owner_mark)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = mutex_fresh_owner_mark +
    +
    [Called By]
    • >>   tos_mutex_post +
    • >>   tos_mutex_pend_timed +
    + +

    mutex_old_owner_release (Thumb, 76 bytes, Stack size 16 bytes, tos_mutex.o(i.mutex_old_owner_release)) +

    [Stack]

    • Max Depth = 80 + Unknown Stack Size +
    • Call Chain = mutex_old_owner_release ⇒ tos_task_prio_change ⇒ readyqueue_remove ⇒ readyqueue_prio_highest_get ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   tos_task_prio_change +
    +
    [Called By]
    • >>   tos_mutex_post +
    • >>   mutex_release +
    + +

    pend_list_add (Thumb, 84 bytes, Stack size 12 bytes, tos_pend.o(i.pend_list_add)) +

    [Stack]

    • Max Depth = 12
    • Call Chain = pend_list_add +
    +
    [Called By]
    • >>   pend_task_block +
    • >>   pend_list_adjust +
    + +

    tos_list_del (Thumb, 12 bytes, Stack size 0 bytes, tos_pend.o(i.tos_list_del)) +

    [Called By]

    • >>   pend_list_remove +
    • >>   pend_list_adjust +
    + +

    tos_list_empty (Thumb, 16 bytes, Stack size 0 bytes, tos_pend.o(i.tos_list_empty)) +

    [Called By]

    • >>   pend_is_nopending +
    • >>   pend_highest_pending_prio_get +
    + +

    tos_list_init (Thumb, 6 bytes, Stack size 0 bytes, tos_pend.o(i.tos_list_init)) +

    [Called By]

    • >>   pend_object_init +
    • >>   pend_object_deinit +
    + +

    _list_add (Thumb, 10 bytes, Stack size 0 bytes, tos_sched.o(i._list_add)) +

    [Called By]

    • >>   tos_list_add_tail +
    • >>   readyqueue_add_head +
    + +

    _list_del (Thumb, 6 bytes, Stack size 0 bytes, tos_sched.o(i._list_del)) +

    [Called By]

    • >>   readyqueue_remove +
    + +

    readyqueue_prio_highest_get (Thumb, 36 bytes, Stack size 16 bytes, tos_sched.o(i.readyqueue_prio_highest_get)) +

    [Stack]

    • Max Depth = 24 + Unknown Stack Size +
    • Call Chain = readyqueue_prio_highest_get ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   tos_cpu_clz +
    +
    [Called By]
    • >>   readyqueue_remove +
    + +

    readyqueue_prio_mark (Thumb, 56 bytes, Stack size 0 bytes, tos_sched.o(i.readyqueue_prio_mark)) +

    [Called By]

    • >>   readyqueue_add_tail +
    • >>   readyqueue_add_head +
    + +

    tos_list_add_tail (Thumb, 18 bytes, Stack size 16 bytes, tos_sched.o(i.tos_list_add_tail)) +

    [Stack]

    • Max Depth = 16
    • Call Chain = tos_list_add_tail +
    +
    [Calls]
    • >>   _list_add +
    +
    [Called By]
    • >>   readyqueue_add_tail +
    + +

    tos_list_empty (Thumb, 16 bytes, Stack size 0 bytes, tos_sched.o(i.tos_list_empty)) +

    [Called By]

    • >>   readyqueue_remove +
    • >>   readyqueue_add_tail +
    • >>   readyqueue_add_head +
    + +

    knl_object_verify (Thumb, 16 bytes, Stack size 0 bytes, tos_sem.o(i.knl_object_verify)) +

    [Called By]

    • >>   tos_sem_pend +
    • >>   tos_sem_destroy +
    • >>   sem_do_post +
    + +

    sem_do_post (Thumb, 140 bytes, Stack size 16 bytes, tos_sem.o(i.sem_do_post)) +

    [Stack]

    • Max Depth = 112 + Unknown Stack Size +
    • Call Chain = sem_do_post ⇒ pend_wakeup ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   pend_wakeup +
    • >>   pend_is_nopending +
    • >>   knl_sched +
    • >>   knl_object_verify +
    +
    [Called By]
    • >>   tos_sem_post_all +
    + +

    knl_idle_entry (Thumb, 10 bytes, Stack size 0 bytes, tos_sys.o(i.knl_idle_entry)) +

    [Stack]

    • Max Depth = 128 + Unknown Stack Size +
    • Call Chain = knl_idle_entry ⇒ task_free_all ⇒ task_free ⇒ tos_mmheap_free ⇒ blk_merge_prev ⇒ blk_remove ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   task_free_all +
    +
    [Address Reference Count : 1]
    • tos_sys.o(i.knl_idle_init) +
    +

    knl_object_verify (Thumb, 16 bytes, Stack size 0 bytes, tos_task.o(i.knl_object_verify)) +

    [Called By]

    • >>   tos_task_prio_change +
    • >>   tos_task_destroy +
    + +

    task_destroy_dyn (Thumb, 60 bytes, Stack size 16 bytes, tos_task.o(i.task_destroy_dyn)) +

    [Stack]

    • Max Depth = 136 + Unknown Stack Size +
    • Call Chain = task_destroy_dyn ⇒ task_do_destroy ⇒ task_mutex_release ⇒ mutex_release ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   tos_knl_sched_lock +
    • >>   knl_is_self +
    • >>   tos_list_add +
    • >>   task_free +
    • >>   task_do_destroy +
    • >>   tos_knl_sched_unlock +
    +
    [Called By]
    • >>   tos_task_destroy +
    + +

    task_destroy_static (Thumb, 32 bytes, Stack size 8 bytes, tos_task.o(i.task_destroy_static)) +

    [Stack]

    • Max Depth = 128 + Unknown Stack Size +
    • Call Chain = task_destroy_static ⇒ task_do_destroy ⇒ task_mutex_release ⇒ mutex_release ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   task_do_destroy +
    +
    [Called By]
    • >>   tos_task_destroy +
    + +

    task_do_destroy (Thumb, 138 bytes, Stack size 16 bytes, tos_task.o(i.task_do_destroy)) +

    [Stack]

    • Max Depth = 120 + Unknown Stack Size +
    • Call Chain = task_do_destroy ⇒ task_mutex_release ⇒ mutex_release ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   knl_sched +
    • >>   tick_list_remove +
    • >>   readyqueue_remove +
    • >>   pend_list_remove +
    • >>   tos_list_empty +
    • >>   tos_list_del +
    • >>   task_state_is_ready +
    • >>   task_reset +
    • >>   task_mutex_release +
    • >>   knl_is_idle +
    +
    [Called By]
    • >>   task_destroy_static +
    • >>   task_destroy_dyn +
    + +

    task_exit (Thumb, 10 bytes, Stack size 8 bytes, tos_task.o(i.task_exit)) +

    [Stack]

    • Max Depth = 152 + Unknown Stack Size +
    • Call Chain = task_exit ⇒ tos_task_destroy ⇒ task_destroy_dyn ⇒ task_do_destroy ⇒ task_mutex_release ⇒ mutex_release ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   tos_task_destroy +
    +
    [Address Reference Count : 1]
    • tos_task.o(i.tos_task_create) +
    +

    task_free (Thumb, 18 bytes, Stack size 8 bytes, tos_task.o(i.task_free)) +

    [Stack]

    • Max Depth = 112 + Unknown Stack Size +
    • Call Chain = task_free ⇒ tos_mmheap_free ⇒ blk_merge_prev ⇒ blk_remove ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   tos_mmheap_free +
    +
    [Called By]
    • >>   tos_task_create_dyn +
    • >>   task_destroy_dyn +
    • >>   task_free_all +
    + +

    task_highest_pending_prio_get (Thumb, 54 bytes, Stack size 24 bytes, tos_task.o(i.task_highest_pending_prio_get)) +

    [Stack]

    • Max Depth = 40
    • Call Chain = task_highest_pending_prio_get ⇒ pend_highest_pending_prio_get +
    +
    [Calls]
    • >>   pend_highest_pending_prio_get +
    +
    [Called By]
    • >>   tos_task_prio_change +
    + +

    task_mutex_release (Thumb, 46 bytes, Stack size 16 bytes, tos_task.o(i.task_mutex_release)) +

    [Stack]

    • Max Depth = 104 + Unknown Stack Size +
    • Call Chain = task_mutex_release ⇒ mutex_release ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   mutex_release +
    +
    [Called By]
    • >>   task_do_destroy +
    + +

    task_reset (Thumb, 80 bytes, Stack size 8 bytes, tos_task.o(i.task_reset)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = task_reset +
    +
    [Calls]
    • >>   tos_list_init +
    +
    [Called By]
    • >>   task_do_destroy +
    • >>   tos_task_create +
    + +

    task_state_is_ready (Thumb, 16 bytes, Stack size 0 bytes, tos_task.o(i.task_state_is_ready)) +

    [Called By]

    • >>   tos_task_prio_change +
    • >>   task_do_destroy +
    + +

    tos_list_add (Thumb, 14 bytes, Stack size 0 bytes, tos_task.o(i.tos_list_add)) +

    [Called By]

    • >>   task_destroy_dyn +
    • >>   tos_task_create +
    + +

    tos_list_del (Thumb, 12 bytes, Stack size 0 bytes, tos_task.o(i.tos_list_del)) +

    [Called By]

    • >>   task_do_destroy +
    • >>   task_free_all +
    + +

    tos_list_empty (Thumb, 16 bytes, Stack size 0 bytes, tos_task.o(i.tos_list_empty)) +

    [Called By]

    • >>   tos_task_prio_change +
    • >>   task_do_destroy +
    + +

    tos_list_init (Thumb, 6 bytes, Stack size 0 bytes, tos_task.o(i.tos_list_init)) +

    [Called By]

    • >>   task_reset +
    + +

    tick_task_place (Thumb, 154 bytes, Stack size 32 bytes, tos_tick.o(i.tick_task_place)) +

    [Stack]

    • Max Depth = 40 + Unknown Stack Size +
    • Call Chain = tick_task_place ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    +
    [Called By]
    • >>   tick_list_add +
    + +

    tick_task_takeoff (Thumb, 102 bytes, Stack size 16 bytes, tos_tick.o(i.tick_task_takeoff)) +

    [Stack]

    • Max Depth = 24 + Unknown Stack Size +
    • Call Chain = tick_task_takeoff ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    • >>   tos_list_empty +
    +
    [Called By]
    • >>   tick_list_remove +
    + +

    tos_list_empty (Thumb, 16 bytes, Stack size 0 bytes, tos_tick.o(i.tos_list_empty)) +

    [Called By]

    • >>   tick_update +
    • >>   tick_task_takeoff +
    + +

    timer_place (Thumb, 120 bytes, Stack size 16 bytes, tos_timer.o(i.timer_place)) +

    [Stack]

    • Max Depth = 24 + Unknown Stack Size +
    • Call Chain = timer_place ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    +
    [Called By]
    • >>   timer_update +
    + +

    timer_takeoff (Thumb, 104 bytes, Stack size 24 bytes, tos_timer.o(i.timer_takeoff)) +

    [Stack]

    • Max Depth = 32 + Unknown Stack Size +
    • Call Chain = timer_takeoff ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   tos_cpu_cpsr_save +
    • >>   tos_cpu_cpsr_restore +
    +
    [Called By]
    • >>   timer_update +
    + +

    knl_object_init (Thumb, 4 bytes, Stack size 0 bytes, tos_bitmap.o(i.knl_object_init)) +

    [Called By]

    • >>   tos_bitmap_create_full +
    + +

    knl_object_verify (Thumb, 16 bytes, Stack size 0 bytes, tos_bitmap.o(i.knl_object_verify)) +

    [Called By]

    • >>   tos_bitmap_is_set +
    • >>   tos_bitmap_is_reset +
    + +

    __NVIC_SetPriority (Thumb, 32 bytes, Stack size 8 bytes, port_c.o(i.__NVIC_SetPriority)) +

    [Stack]

    • Max Depth = 8
    • Call Chain = __NVIC_SetPriority +
    +
    [Called By]
    • >>   port_systick_priority_set +
    • >>   port_systick_config +
    + +

    errno_knl2cmsis (Thumb, 12 bytes, Stack size 0 bytes, cmsis_os.o(i.errno_knl2cmsis)) +

    [Called By]

    • >>   osKernelStart +
    • >>   osKernelInitialize +
    + +

    priority_cmsis2knl (Thumb, 18 bytes, Stack size 0 bytes, cmsis_os.o(i.priority_cmsis2knl)) +

    [Called By]

    • >>   osThreadCreate +
    + +

    pthread_dead_reap (Thumb, 22 bytes, Stack size 8 bytes, pthread.o(i.pthread_dead_reap)) +

    [Stack]

    • Max Depth = 136 + Unknown Stack Size +
    • Call Chain = pthread_dead_reap ⇒ pthread_ctl_reap ⇒ tos_mmheap_free ⇒ blk_merge_prev ⇒ blk_remove ⇒ mapping_insert ⇒ __fls ⇒ generic_fls ⇒ tos_cpu_clz +
    +
    [Calls]
    • >>   pthread_ctl_reap +
    +
    [Called By]
    • >>   pthread_join +
    • >>   pthread_create +
    + +

    pthread_entry (Thumb, 22 bytes, Stack size 16 bytes, pthread.o(i.pthread_entry)) +

    [Stack]

    • Max Depth = 200 + Unknown Stack Size +
    • Call Chain = pthread_entry ⇒ pthread_exit ⇒ tos_task_destroy ⇒ task_destroy_dyn ⇒ task_do_destroy ⇒ task_mutex_release ⇒ mutex_release ⇒ pend_wakeup_all ⇒ pend_task_wakeup ⇒ readyqueue_add ⇒ readyqueue_add_tail ⇒ tos_list_add_tail +
    +
    [Calls]
    • >>   pthread_exit +
    +
    [Address Reference Count : 1]
    • pthread.o(i.pthread_create) +
    +

    pthread_is_cancel_pending (Thumb, 34 bytes, Stack size 8 bytes, pthread.o(i.pthread_is_cancel_pending)) +

    [Stack]

    • Max Depth = 56 + Unknown Stack Size +
    • Call Chain = pthread_is_cancel_pending ⇒ pthread_ctl_self ⇒ tos_task_curr_task_get ⇒ tos_cpu_cpsr_save +
    +
    [Calls]
    • >>   pthread_ctl_self +
    +
    [Called By]
    • >>   pthread_join +
    • >>   pthread_testcancel +
    + +

    pthread_key_destructor_is_register (Thumb, 48 bytes, Stack size 8 bytes, pthread_prv.o(i.pthread_key_destructor_is_register)) +

    [Stack]

    • Max Depth = 24
    • Call Chain = pthread_key_destructor_is_register ⇒ tos_bitmap_is_set +
    +
    [Calls]
    • >>   tos_bitmap_is_set +
    +
    [Called By]
    • >>   pthread_key_destructor_get +
    + +

    _printf_core (Thumb, 658 bytes, Stack size 104 bytes, printf5.o(i._printf_core), UNUSED) +

    [Calls]

    • >>   __aeabi_uldivmod +
    +
    [Called By]
    • >>   __0snprintf$5 +
    • >>   __0printf$5 +
    + +

    _snputc (Thumb, 22 bytes, Stack size 0 bytes, printf5.o(i._snputc)) +
    [Address Reference Count : 1]

    • printf5.o(i.__0snprintf$5) +

    +

    +Undefined Global Symbols +


    diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/obj/TencentOS_tiny.sct b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/obj/TencentOS_tiny.sct new file mode 100644 index 00000000..66acf7f8 --- /dev/null +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/obj/TencentOS_tiny.sct @@ -0,0 +1,16 @@ +; ************************************************************* +; *** Scatter-Loading Description File generated by uVision *** +; ************************************************************* + +LR_IROM1 0x08000000 0x00040000 { ; load region size_region + ER_IROM1 0x08000000 0x00040000 { ; load address = execution address + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + .ANY (+XO) + } + RW_IRAM1 0x20000000 0x00010000 { ; RW data + .ANY (+RW +ZI) + } +} + diff --git a/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/startup_stm32l431xx.s b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/startup_stm32l431xx.s new file mode 100644 index 00000000..6a5c15a5 --- /dev/null +++ b/board/TencentOS_tiny_EVB_MX_Plus/KEIL/posix/startup_stm32l431xx.s @@ -0,0 +1,404 @@ +;********************** COPYRIGHT(c) 2017 STMicroelectronics ****************** +;* File Name : startup_stm32l431xx.s +;* Author : MCD Application Team +;* Description : STM32L431xx Ultra Low Power devices vector table for MDK-ARM toolchain. +;* This module performs: +;* - Set the initial SP +;* - Set the initial PC == Reset_Handler +;* - Set the vector table entries with the exceptions ISR address +;* - Branches to __main in the C library (which eventually +;* calls main()). +;* After Reset the Cortex-M4 processor is in Thread mode, +;* priority is Privileged, and the Stack is set to Main. +;* <<< Use Configuration Wizard in Context Menu >>> +;******************************************************************************* +;* +;* Redistribution and use in source and binary forms, with or without modification, +;* are permitted provided that the following conditions are met: +;* 1. Redistributions of source code must retain the above copyright notice, +;* this list of conditions and the following disclaimer. +;* 2. Redistributions in binary form must reproduce the above copyright notice, +;* this list of conditions and the following disclaimer in the documentation +;* and/or other materials provided with the distribution. +;* 3. Neither the name of STMicroelectronics nor the names of its contributors +;* may be used to endorse or promote products derived from this software +;* without specific prior written permission. +;* +;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;* +;******************************************************************************* +; +; Amount of memory (in bytes) allocated for Stack +; Tailor this value to your application needs +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Stack_Size EQU 0x100 + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + +Heap_Size EQU 0x100 + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; MPU Fault Handler + DCD BusFault_Handler ; Bus Fault Handler + DCD UsageFault_Handler ; Usage Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD DebugMon_Handler ; Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + DCD WWDG_IRQHandler ; Window WatchDog + DCD PVD_PVM_IRQHandler ; PVD/PVM1/PVM2/PVM3/PVM4 through EXTI Line detection + DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line + DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line + DCD FLASH_IRQHandler ; FLASH + DCD RCC_IRQHandler ; RCC + DCD EXTI0_IRQHandler ; EXTI Line0 + DCD EXTI1_IRQHandler ; EXTI Line1 + DCD EXTI2_IRQHandler ; EXTI Line2 + DCD EXTI3_IRQHandler ; EXTI Line3 + DCD EXTI4_IRQHandler ; EXTI Line4 + DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 + DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 + DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 + DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 + DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 + DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 + DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 + DCD ADC1_IRQHandler ; ADC1 + DCD CAN1_TX_IRQHandler ; CAN1 TX + DCD CAN1_RX0_IRQHandler ; CAN1 RX0 + DCD CAN1_RX1_IRQHandler ; CAN1 RX1 + DCD CAN1_SCE_IRQHandler ; CAN1 SCE + DCD EXTI9_5_IRQHandler ; External Line[9:5]s + DCD TIM1_BRK_TIM15_IRQHandler ; TIM1 Break and TIM15 + DCD TIM1_UP_TIM16_IRQHandler ; TIM1 Update and TIM16 + DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation + DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare + DCD TIM2_IRQHandler ; TIM2 + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD I2C1_EV_IRQHandler ; I2C1 Event + DCD I2C1_ER_IRQHandler ; I2C1 Error + DCD I2C2_EV_IRQHandler ; I2C2 Event + DCD I2C2_ER_IRQHandler ; I2C2 Error + DCD SPI1_IRQHandler ; SPI1 + DCD SPI2_IRQHandler ; SPI2 + DCD USART1_IRQHandler ; USART1 + DCD USART2_IRQHandler ; USART2 + DCD USART3_IRQHandler ; USART3 + DCD EXTI15_10_IRQHandler ; External Line[15:10] + DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SDMMC1_IRQHandler ; SDMMC1 + DCD 0 ; Reserved + DCD SPI3_IRQHandler ; SPI3 + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors + DCD TIM7_IRQHandler ; TIM7 + DCD DMA2_Channel1_IRQHandler ; DMA2 Channel 1 + DCD DMA2_Channel2_IRQHandler ; DMA2 Channel 2 + DCD DMA2_Channel3_IRQHandler ; DMA2 Channel 3 + DCD DMA2_Channel4_IRQHandler ; DMA2 Channel 4 + DCD DMA2_Channel5_IRQHandler ; DMA2 Channel 5 + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD COMP_IRQHandler ; COMP Interrupt + DCD LPTIM1_IRQHandler ; LP TIM1 interrupt + DCD LPTIM2_IRQHandler ; LP TIM2 interrupt + DCD 0 ; Reserved + DCD DMA2_Channel6_IRQHandler ; DMA2 Channel 6 + DCD DMA2_Channel7_IRQHandler ; DMA2 Channel 7 + DCD LPUART1_IRQHandler ; LP UART1 interrupt + DCD QUADSPI_IRQHandler ; Quad SPI global interrupt + DCD I2C3_EV_IRQHandler ; I2C3 event + DCD I2C3_ER_IRQHandler ; I2C3 error + DCD SAI1_IRQHandler ; Serial Audio Interface 1 global interrupt + DCD 0 ; Reserved + DCD SWPMI1_IRQHandler ; Serial Wire Interface 1 global interrupt + DCD TSC_IRQHandler ; Touch Sense Controller global interrupt + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD RNG_IRQHandler ; RNG global interrupt + DCD FPU_IRQHandler ; FPU + DCD CRS_IRQHandler ; CRS interrupt + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + +; Reset handler +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT WWDG_IRQHandler [WEAK] + EXPORT PVD_PVM_IRQHandler [WEAK] + EXPORT TAMP_STAMP_IRQHandler [WEAK] + EXPORT RTC_WKUP_IRQHandler [WEAK] + EXPORT FLASH_IRQHandler [WEAK] + EXPORT RCC_IRQHandler [WEAK] + EXPORT EXTI0_IRQHandler [WEAK] + EXPORT EXTI1_IRQHandler [WEAK] + EXPORT EXTI2_IRQHandler [WEAK] + EXPORT EXTI3_IRQHandler [WEAK] + EXPORT EXTI4_IRQHandler [WEAK] + EXPORT DMA1_Channel1_IRQHandler [WEAK] + EXPORT DMA1_Channel2_IRQHandler [WEAK] + EXPORT DMA1_Channel3_IRQHandler [WEAK] + EXPORT DMA1_Channel4_IRQHandler [WEAK] + EXPORT DMA1_Channel5_IRQHandler [WEAK] + EXPORT DMA1_Channel6_IRQHandler [WEAK] + EXPORT DMA1_Channel7_IRQHandler [WEAK] + EXPORT ADC1_IRQHandler [WEAK] + EXPORT CAN1_TX_IRQHandler [WEAK] + EXPORT CAN1_RX0_IRQHandler [WEAK] + EXPORT CAN1_RX1_IRQHandler [WEAK] + EXPORT CAN1_SCE_IRQHandler [WEAK] + EXPORT EXTI9_5_IRQHandler [WEAK] + EXPORT TIM1_BRK_TIM15_IRQHandler [WEAK] + EXPORT TIM1_UP_TIM16_IRQHandler [WEAK] + EXPORT TIM1_TRG_COM_IRQHandler [WEAK] + EXPORT TIM1_CC_IRQHandler [WEAK] + EXPORT TIM2_IRQHandler [WEAK] + EXPORT I2C1_EV_IRQHandler [WEAK] + EXPORT I2C1_ER_IRQHandler [WEAK] + EXPORT I2C2_EV_IRQHandler [WEAK] + EXPORT I2C2_ER_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT SPI2_IRQHandler [WEAK] + EXPORT USART1_IRQHandler [WEAK] + EXPORT USART2_IRQHandler [WEAK] + EXPORT USART3_IRQHandler [WEAK] + EXPORT EXTI15_10_IRQHandler [WEAK] + EXPORT RTC_Alarm_IRQHandler [WEAK] + EXPORT SDMMC1_IRQHandler [WEAK] + EXPORT SPI3_IRQHandler [WEAK] + EXPORT TIM6_DAC_IRQHandler [WEAK] + EXPORT TIM7_IRQHandler [WEAK] + EXPORT DMA2_Channel1_IRQHandler [WEAK] + EXPORT DMA2_Channel2_IRQHandler [WEAK] + EXPORT DMA2_Channel3_IRQHandler [WEAK] + EXPORT DMA2_Channel4_IRQHandler [WEAK] + EXPORT DMA2_Channel5_IRQHandler [WEAK] + EXPORT COMP_IRQHandler [WEAK] + EXPORT LPTIM1_IRQHandler [WEAK] + EXPORT LPTIM2_IRQHandler [WEAK] + EXPORT DMA2_Channel6_IRQHandler [WEAK] + EXPORT DMA2_Channel7_IRQHandler [WEAK] + EXPORT LPUART1_IRQHandler [WEAK] + EXPORT QUADSPI_IRQHandler [WEAK] + EXPORT I2C3_EV_IRQHandler [WEAK] + EXPORT I2C3_ER_IRQHandler [WEAK] + EXPORT SAI1_IRQHandler [WEAK] + EXPORT SWPMI1_IRQHandler [WEAK] + EXPORT TSC_IRQHandler [WEAK] + EXPORT RNG_IRQHandler [WEAK] + EXPORT FPU_IRQHandler [WEAK] + EXPORT CRS_IRQHandler [WEAK] + +WWDG_IRQHandler +PVD_PVM_IRQHandler +TAMP_STAMP_IRQHandler +RTC_WKUP_IRQHandler +FLASH_IRQHandler +RCC_IRQHandler +EXTI0_IRQHandler +EXTI1_IRQHandler +EXTI2_IRQHandler +EXTI3_IRQHandler +EXTI4_IRQHandler +DMA1_Channel1_IRQHandler +DMA1_Channel2_IRQHandler +DMA1_Channel3_IRQHandler +DMA1_Channel4_IRQHandler +DMA1_Channel5_IRQHandler +DMA1_Channel6_IRQHandler +DMA1_Channel7_IRQHandler +ADC1_IRQHandler +CAN1_TX_IRQHandler +CAN1_RX0_IRQHandler +CAN1_RX1_IRQHandler +CAN1_SCE_IRQHandler +EXTI9_5_IRQHandler +TIM1_BRK_TIM15_IRQHandler +TIM1_UP_TIM16_IRQHandler +TIM1_TRG_COM_IRQHandler +TIM1_CC_IRQHandler +TIM2_IRQHandler +I2C1_EV_IRQHandler +I2C1_ER_IRQHandler +I2C2_EV_IRQHandler +I2C2_ER_IRQHandler +SPI1_IRQHandler +SPI2_IRQHandler +USART1_IRQHandler +USART2_IRQHandler +USART3_IRQHandler +EXTI15_10_IRQHandler +RTC_Alarm_IRQHandler +SDMMC1_IRQHandler +SPI3_IRQHandler +TIM6_DAC_IRQHandler +TIM7_IRQHandler +DMA2_Channel1_IRQHandler +DMA2_Channel2_IRQHandler +DMA2_Channel3_IRQHandler +DMA2_Channel4_IRQHandler +DMA2_Channel5_IRQHandler +COMP_IRQHandler +LPTIM1_IRQHandler +LPTIM2_IRQHandler +DMA2_Channel6_IRQHandler +DMA2_Channel7_IRQHandler +LPUART1_IRQHandler +QUADSPI_IRQHandler +I2C3_EV_IRQHandler +I2C3_ER_IRQHandler +SAI1_IRQHandler +SWPMI1_IRQHandler +TSC_IRQHandler +RNG_IRQHandler +FPU_IRQHandler +CRS_IRQHandler + + B . + + ENDP + + ALIGN + +;******************************************************************************* +; User Stack and Heap initialization +;******************************************************************************* + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap + + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + + ALIGN + + ENDIF + + END + +;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE***** diff --git a/examples/posix/posix_sample.c b/examples/posix/posix_sample.c new file mode 100644 index 00000000..746ff0db --- /dev/null +++ b/examples/posix/posix_sample.c @@ -0,0 +1,136 @@ +#include "tos_posix.h" +#include "pthread.h" +#include "mqueue.h" +#include "semaphore.h" +#include "time.h" + +typedef struct pthread_arg_st { + char *msg; + uint32_t payload; +} pthread_arg_t; + +#define FIRSTBORN_PTHREAD_STACK_SIZE 1024 +uint8_t firstborn_pthread_stack[FIRSTBORN_PTHREAD_STACK_SIZE]; + +pthread_t firstborn_pthread; +pthread_arg_t the_arg; + +pthread_t secondborn_pthread; +char *secondborn_last_words = "2nd, dead now"; + +pthread_t thirdborn_pthread; + +pthread_t fourthborn_pthread; +char *fourthborn_last_words = "4th, dead now"; + +void *fourthborn_routine(void *arg) +{ + int i = 0; + + while (1) { + printf("I am the 4th-born\n"); + tos_task_delay(2000); + if (++i == 4) { + printf("4th-born: I kill myself!\n"); + pthread_exit(fourthborn_last_words); + } + } +} + +void *thirdborn_routine(void *arg) +{ + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + while (1) { + printf("I am the 3rd-born\n"); + tos_task_delay(2000); + } +} + +void *secondborn_routine(void *arg) +{ + printf("I am the 2nd-born, hello!\n"); + tos_task_delay(2000); + printf("I am the 2nd-born, goodbye!\n"); + return (void *)secondborn_last_words; +} + +void *firstborn_routine(void *arg) +{ + int i = 0; + int rc = 0; + pthread_arg_t *the_arg; + pthread_attr_t attr; + void *value; + + the_arg = (pthread_arg_t *)arg; + printf("msg: %s\n", the_arg->msg); + printf("payload:0x%x\n", the_arg->payload); + + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + rc = pthread_create(&secondborn_pthread, &attr, secondborn_routine, NULL); + if (rc != 0) { + printf("2nd-born create failed!\n"); + } + + pthread_join(secondborn_pthread, &value); + printf("2nd-born is dead now\n"); + printf("his last words: %s\n", (char *)value); + + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + rc = pthread_create(&thirdborn_pthread, &attr, thirdborn_routine, NULL); + if (rc != 0) { + printf("3rd-born pthread create failed!\n"); + } + + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + rc = pthread_create(&fourthborn_pthread, &attr, fourthborn_routine, NULL); + if (rc != 0) { + printf("4th-born create failed!\n"); + } + + while (1) { + ++i; + printf("I am the 1st-born\n"); + + if (i == 3) { + printf("do the canceling to 3rd-born!\n"); + pthread_cancel(thirdborn_pthread); + } else if (i == 4) { + /* the fourththread must be dead already, check his last words */ + pthread_join(fourthborn_pthread, &value); + printf("4th-born's last words: %s\n", (char *)value); + } + tos_task_delay(3000); + } +} + +void application_entry(void *arg) +{ + int rc = 0; + pthread_attr_t attr; + struct sched_param param; + + /* if use posix, must have this function invoked first */ + rc = tos_posix_init(); + if (rc != 0) { + return; + } + + the_arg.msg = "hello, 1st-born posix thread!"; + the_arg.payload = 0xDEADBEEF; + + pthread_attr_init(&attr); + pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); + param.sched_priority = 4; + pthread_attr_setschedparam(&attr, ¶m); + pthread_attr_setstack(&attr, firstborn_pthread_stack, sizeof(firstborn_pthread_stack)); + + rc = pthread_create(&firstborn_pthread, &attr, firstborn_routine, &the_arg); + if (rc != 0) { + return; + } +} + diff --git a/kernel/core/include/tos_barrier.h b/kernel/core/include/tos_barrier.h new file mode 100644 index 00000000..14dbba96 --- /dev/null +++ b/kernel/core/include/tos_barrier.h @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _TOS_BARRIER_H_ +#define _TOS_BARRIER_H_ + +__CDECLS_BEGIN + +typedef struct k_barrier_st { +#if TOS_CFG_OBJECT_VERIFY_EN > 0u + knl_obj_t knl_obj; +#endif + + pend_obj_t pend_obj; + k_barrier_cnt_t count; +} k_barrier_t; + +/** + * @brief Create a thread barrier. + * + * @attention the count must be greater then zero. + * + * @param[in] barrier the barrier. + * @param[in] count the number of threads(task) must call tos_barrier_pend before any of them successfully return from the call. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_BARRIER_COUNT_INVALID the count is equals to zero. + */ +__API__ k_err_t tos_barrier_create(k_barrier_t *barrier, k_barrier_cnt_t count); + +/** + * @brief Create a thread barrier. + * + * @attention the count must be greater then zero. + * + * @param[in] barrier the barrier. + * @param[in] count the number of threads(task) must call tos_barrier_pend before any of them successfully return from the call. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_BARRIER_COUNT_INVALID the count is equals to zero. + */ +__API__ k_err_t tos_barrier_destroy(k_barrier_t *barrier); + +/** + * @brief Pend on a barrier. + * + * @attention until (countdownlatch->count) of tasks have called the pend, the pender would wake up. + * + * @param[in] barrier the barrier. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_BARRIER_OVERFLOW the barrier is pended too many times. + */ +__API__ k_err_t tos_barrier_pend(k_barrier_t *barrier); + +/** + * @brief Reset a barrier. + * + * @attention + * + * @param[in] barrier the barrier. + * @param[in] count the count of the barrier to be reset. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + */ +__API__ k_err_t tos_barrier_reset(k_barrier_t *barrier, k_barrier_cnt_t count); + +__CDECLS_END + +#endif /* _TOS_BARRIER_H_ */ + diff --git a/kernel/core/include/tos_binary_heap.h b/kernel/core/include/tos_binary_heap.h index e93e7a2f..fd9b425b 100644 --- a/kernel/core/include/tos_binary_heap.h +++ b/kernel/core/include/tos_binary_heap.h @@ -18,6 +18,8 @@ #ifndef _TOS_BINARY_HEAP_H_ #define _TOS_BINARY_HEAP_H_ +__CDECLS_BEGIN + typedef int (*k_bin_heap_cmp)(void *first, void *second); typedef struct k_binary_heap_st { @@ -176,5 +178,7 @@ __API__ int tos_bin_heap_is_empty(k_bin_heap_t *bin_heap); */ __API__ int tos_bin_heap_is_full(k_bin_heap_t *bin_heap); +__CDECLS_END + #endif /* _TOS_BINARY_HEAP_H_ */ diff --git a/kernel/core/include/tos_bitmap.h b/kernel/core/include/tos_bitmap.h new file mode 100644 index 00000000..73d5fcf2 --- /dev/null +++ b/kernel/core/include/tos_bitmap.h @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _TOS_BITMAP_H_ +#define _TOS_BITMAP_H_ + +typedef uint32_t k_bmtbl_t; + +typedef struct k_bitmap_st { +#if TOS_CFG_OBJECT_VERIFY_EN > 0u + knl_obj_t knl_obj; +#endif + + uint32_t bit_ndx_max; + uint32_t bit_max; + k_bmtbl_t *bitmap_tbl; +} k_bitmap_t; + +#define K_BITMAP_SLOT_SIZE (sizeof(k_bmtbl_t) * 8) /* in bits */ + +#define K_BITMAP_TBL_SIZE(bit_max) ((bit_max + K_BITMAP_SLOT_SIZE - 1) / K_BITMAP_SLOT_SIZE) + +#define K_BITMAP_NDX(bit) ((bit) >> 5u) /* bit / K_BITMAP_SLOT_SIZE */ + +#define K_BITMAP_BIT(bit) ((uint32_t)1u << (K_BITMAP_SLOT_SIZE - 1u - ((bit) & (K_BITMAP_SLOT_SIZE - 1u)))) + +#define TOS_BITMAP_SIZE(bit_max) (K_BITMAP_TBL_SIZE(bit_max)) + +/** + * @brief Create a bitmap with all bit are set to 0. + * + * @attention the size of bitmap_tabl can be caculated by the macro TOS_BITMAP_SIZE + * + * @param[in] bitmap pointer to the handler of the bitmap. + * @param[in] bitmap_tbl bitmap table buffer. + * @param[in] bit_max maximal bit. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_OBJ_PTR_NULL bitmap is NULL. + */ +__API__ k_err_t tos_bitmap_create_empty(k_bitmap_t *bitmap, k_bmtbl_t *bitmap_tbl, uint32_t bit_max); + +/** + * @brief Create a bitmap with all bit are set to 1. + * + * @attention the size of bitmap_tabl can be caculated by the macro TOS_BITMAP_SIZE + * + * @param[in] bitmap pointer to the handler of the bitmap. + * @param[in] bitmap_tbl bitmap table buffer. + * @param[in] bit_max maximal bit. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_OBJ_PTR_NULL bitmap is NULL. + */ +__API__ k_err_t tos_bitmap_create_full(k_bitmap_t *bitmap, k_bmtbl_t *bitmap_tbl, uint32_t bit_max); + +/** + * @brief Destroy the bitmap. + * + * @attention + * + * @param[in] bitmap pointer to the handler of the bitmap. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_OBJ_PTR_NULL bitmap is NULL. + */ +__API__ k_err_t tos_bitmap_destroy(k_bitmap_t *bitmap); + +/** + * @brief Set a certain bit of the bitmap to 1. + * + * @attention + * + * @param[in] bitmap pointer to the handler of the bitmap. + * @param[in] bit the bit to set. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_BITMAP_EXCEED bit is larger than the bit_max passed to tos_bitmap_create_*. + */ +__API__ k_err_t tos_bitmap_set(k_bitmap_t *bitmap, uint32_t bit); + +/** + * @brief Set a certain bit of the bitmap to 0. + * + * @attention + * + * @param[in] bitmap pointer to the handler of the bitmap. + * @param[in] bit the bit to set. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_BITMAP_EXCEED bit is larger than the bit_max passed to tos_bitmap_create_*. + */ +__API__ k_err_t tos_bitmap_reset(k_bitmap_t *bitmap, uint32_t bit); + +/** + * @brief Test whether a certain bit of the bitmap is 1. + * + * @attention + * + * @param[in] bitmap pointer to the handler of the bitmap. + * @param[in] bit the bit to set. + * + * @return whether the bit is 1 + * @retval #K_TRUE the certain bit is 1. + * @retval #K_FALSE the certain bit is not 1(that means is 0). + */ +__API__ int tos_bitmap_is_set(k_bitmap_t *bitmap, uint32_t bit); + +/** + * @brief Test whether a certain bit of the bitmap is 0. + * + * @attention + * + * @param[in] bitmap pointer to the handler of the bitmap. + * @param[in] bit the bit to set. + * + * @return whether the bit is 0 + * @retval #K_TRUE the certain bit is 0. + * @retval #K_FALSE the certain bit is not 0(that means is 1). + */ +__API__ int tos_bitmap_is_reset(k_bitmap_t *bitmap, uint32_t bit); + +/** + * @brief Get the lowest significant bit of the bitmap. + * + * @attention The very first bit which is set to 1. + * + * @param[in] bitmap pointer to the handler of the bitmap. + * @param[in] bit the bit to set. + * + * @return the lowest significant bit of the bitmap. + */ +__API__ int tos_bitmap_lsb(k_bitmap_t *bitmap); + +#endif /* _TOS_BITMAP_H_ */ + diff --git a/kernel/core/include/tos_char_fifo.h b/kernel/core/include/tos_char_fifo.h index 21084c82..1580b0b0 100644 --- a/kernel/core/include/tos_char_fifo.h +++ b/kernel/core/include/tos_char_fifo.h @@ -18,6 +18,8 @@ #ifndef _TOS_CHAR_FIFO_H_ #define _TOS_CHAR_FIFO_H_ +__CDECLS_BEGIN + typedef struct k_char_fifo_st { knl_obj_t knl_obj; @@ -187,5 +189,7 @@ __API__ int tos_chr_fifo_is_empty(k_chr_fifo_t *chr_fifo); */ __API__ int tos_chr_fifo_is_full(k_chr_fifo_t *chr_fifo); -#endif // _TOS_CHAR_FIFO_H_ +__CDECLS_END + +#endif /* _TOS_CHAR_FIFO_H_ */ diff --git a/kernel/core/include/tos_compiler.h b/kernel/core/include/tos_compiler.h index cdc651a4..ffa86998 100644 --- a/kernel/core/include/tos_compiler.h +++ b/kernel/core/include/tos_compiler.h @@ -18,21 +18,30 @@ #ifndef _TOS_COMPILER_H_ #define _TOS_COMPILER_H_ -// function with __API__ prefix, api for user +/* function with __API__ prefix, api for user */ #define __API__ -// function with __KNL__ prefix, only for kernel +/* function with __KNL__ prefix, only for kernel */ #define __KNL__ -// function with __HOOK__ prefix, should be implemented by user +/* function with __HOOK__ prefix, should be implemented by user */ #define __HOOK__ -// function with __DEBUG__ prefix, only for debug +/* function with __DEBUG__ prefix, only for debug */ #define __DEBUG__ -// function with __PORT__ is architecture depended +/* function with __PORT__ is architecture depended */ #define __PORT__ +/* CPP header guards */ +#ifdef __cplusplus +#define __CDECLS_BEGIN extern "C" { +#define __CDECLS_END } +#else +#define __CDECLS_BEGIN +#define __CDECLS_END +#endif + /*------------------ RealView Compiler -----------------*/ #if defined(__CC_ARM) diff --git a/kernel/core/include/tos_completion.h b/kernel/core/include/tos_completion.h index 41f07a41..bbaae49a 100644 --- a/kernel/core/include/tos_completion.h +++ b/kernel/core/include/tos_completion.h @@ -18,7 +18,7 @@ #ifndef _TOS_COMPLETION_H_ #define _TOS_COMPLETION_H_ -#if TOS_CFG_COMPLETION_EN > 0u +__CDECLS_BEGIN typedef uint16_t completion_done_t; @@ -147,7 +147,7 @@ __API__ k_err_t tos_completion_reset(k_completion_t *completion); */ __API__ int tos_completion_is_done(k_completion_t *completion); -#endif +__CDECLS_END -#endif +#endif /* _TOS_COMPLETION_H_ */ diff --git a/kernel/core/include/tos_config_default.h b/kernel/core/include/tos_config_default.h index e189ff64..5e5a2185 100644 --- a/kernel/core/include/tos_config_default.h +++ b/kernel/core/include/tos_config_default.h @@ -69,24 +69,6 @@ ///////////////////////////////////////// -///////////////////////////////////////// -// disable countdownlatch -#ifdef TOS_CFG_COUNTDOWNLATCH_EN -#undef TOS_CFG_COUNTDOWNLATCH_EN -#endif -#define TOS_CFG_COUNTDOWNLATCH_EN 0u -///////////////////////////////////////// - - -///////////////////////////////////////// -// disable completion -#ifdef TOS_CFG_COMPLETION_EN -#undef TOS_CFG_COMPLETION_EN -#endif -#define TOS_CFG_COMPLETION_EN 0u -///////////////////////////////////////// - - ///////////////////////////////////////// // disable the "traditional" timer #ifdef TOS_CFG_TIMER_EN @@ -206,14 +188,6 @@ #define TOS_CFG_SEM_EN 0u #endif -#ifndef TOS_CFG_COUNTDOWNLATCH_EN -#define TOS_CFG_COUNTDOWNLATCH_EN 0u -#endif - -#ifndef TOS_CFG_COMPLETION_EN -#define TOS_CFG_COMPLETION_EN 0u -#endif - #ifndef TOS_CFG_TIMER_EN #define TOS_CFG_TIMER_EN 0u #endif diff --git a/kernel/core/include/tos_countdownlatch.h b/kernel/core/include/tos_countdownlatch.h index 0470dc8c..9cc0f339 100644 --- a/kernel/core/include/tos_countdownlatch.h +++ b/kernel/core/include/tos_countdownlatch.h @@ -18,7 +18,7 @@ #ifndef _TOS_COUNTDOWNLATCH_H_ #define _TOS_COUNTDOWNLATCH_H_ -#if TOS_CFG_COUNTDOWNLATCH_EN > 0u +__CDECLS_BEGIN typedef struct k_countdownlatch_st { #if TOS_CFG_OBJECT_VERIFY_EN > 0u @@ -114,7 +114,7 @@ __API__ k_err_t tos_countdownlatch_post(k_countdownlatch_t *countdownlatch); */ __API__ k_err_t tos_countdownlatch_reset(k_countdownlatch_t *countdownlatch, k_countdownlatch_cnt_t count); -#endif +__CDECLS_END -#endif +#endif /* _TOS_COUNTDOWNLATCH_H_ */ diff --git a/kernel/core/include/tos_err.h b/kernel/core/include/tos_err.h index 135ef377..b0a2954b 100644 --- a/kernel/core/include/tos_err.h +++ b/kernel/core/include/tos_err.h @@ -21,7 +21,12 @@ typedef enum k_err_en { K_ERR_NONE = 0u, - K_ERR_BIN_HEAP_FULL = 10u, + K_ERR_BARRIER_COUNT_INVALID = 5u, + K_ERR_BARRIER_OVERFLOW, + + K_ERR_BITMAP_EXCEED = 10u, + + K_ERR_BIN_HEAP_FULL = 15u, K_ERR_BIN_HEAP_EMPTY, K_ERR_BIN_HEAP_ITEM_SIZE_NOT_MATCH, @@ -64,7 +69,6 @@ typedef enum k_err_en { K_ERR_PEND_NOWAIT = 1200u, K_ERR_PEND_SCHED_LOCKED, - K_ERR_PEND_IN_IRQ, K_ERR_PEND_ABNORMAL, K_ERR_PEND_TIMEOUT, K_ERR_PEND_DESTROY, @@ -79,16 +83,25 @@ typedef enum k_err_en { K_ERR_PRIO_Q_SLOT_NOT_TAKEN, K_ERR_PRIO_Q_ITEM_SIZE_NOT_MATCH, - K_ERR_RING_Q_FULL = 1600u, + K_ERR_RING_Q_FULL = 1500u, K_ERR_RING_Q_EMPTY, K_ERR_RING_Q_ITEM_SIZE_NOT_MATCH, + K_ERR_RWLOCK_READERS_TO_MANY = 1600u, + K_ERR_RWLOCK_IS_READING, + K_ERR_RWLOCK_IS_WRITTING, + K_ERR_RWLOCK_NOT_READING, + K_ERR_RWLOCK_NOT_WRITTING, + K_ERR_RWLOCK_NOT_TAKEN, + K_ERR_RWLOCK_WAITING_WRITERS_TO_MANY, + K_ERR_SCHED_LOCKED = 1700u, K_ERR_SCHED_NOT_LOCKED, K_ERR_SEM_OVERFLOW = 1800u, - K_ERR_TASK_DESTROY_IDLE = 1900u, + K_ERR_TASK_ALREADY_CREATED = 1900u, + K_ERR_TASK_DESTROY_IDLE, K_ERR_TASK_NOT_DELAY, K_ERR_TASK_PRIO_INVALID, K_ERR_TASK_RESUME_SELF, diff --git a/kernel/core/include/tos_event.h b/kernel/core/include/tos_event.h index 23a8a1a4..5da2f55a 100644 --- a/kernel/core/include/tos_event.h +++ b/kernel/core/include/tos_event.h @@ -18,6 +18,8 @@ #ifndef _TOS_EVENT_H_ #define _TOS_EVENT_H_ +__CDECLS_BEGIN + #if TOS_CFG_EVENT_EN > 0 // if we are pending an event, for any flag we expect is set is ok, this flag should be passed to tos_event_pend @@ -133,5 +135,7 @@ __API__ k_err_t tos_event_post_keep(k_event_t *event, k_event_flag_t flag); #endif +__CDECLS_END + #endif /* _TOS_EVENT_H_ */ diff --git a/kernel/core/include/tos_k.h b/kernel/core/include/tos_k.h index 56b522e1..91f44552 100644 --- a/kernel/core/include/tos_k.h +++ b/kernel/core/include/tos_k.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -48,10 +49,13 @@ #include #include #include -#include +#include #include +#include +#include #include #include +#include #include #include #include diff --git a/kernel/core/include/tos_klib.h b/kernel/core/include/tos_klib.h index 55b88352..156a4a19 100644 --- a/kernel/core/include/tos_klib.h +++ b/kernel/core/include/tos_klib.h @@ -23,51 +23,57 @@ #include #include +#define TOS_MACRO_BEGIN do { +#define TOS_MACRO_END } while (0) + #define TOS_OFFSET_OF_FIELD(type, field) \ ((uint32_t)&(((type *)0)->field)) #define TOS_CONTAINER_OF_FIELD(ptr, type, field) \ ((type *)((uint8_t *)(ptr) - TOS_OFFSET_OF_FIELD(type, field))) -#define TOS_PTR_SANITY_CHECK(ptr) \ - do { \ - if (unlikely(!(ptr))) { \ - return K_ERR_OBJ_PTR_NULL; \ - } \ - } while(0) +#define TOS_COUNT_OF(array) (sizeof(array) / sizeof(array[0])) -#define TOS_PTR_SANITY_CHECK_RC(ptr, return_code) \ - do { \ - if (unlikely(!(ptr))) { \ - return return_code; \ - } \ - } while(0) +#define TOS_PTR_SANITY_CHECK(ptr) \ +TOS_MACRO_BEGIN \ + if (unlikely(!(ptr))) { \ + return K_ERR_OBJ_PTR_NULL; \ + } \ +TOS_MACRO_END -#define TOS_IN_IRQ_CHECK() \ - do { \ - if (unlikely(knl_is_inirq())) { \ - return K_ERR_IN_IRQ; \ - } \ - } while(0) +#define TOS_PTR_SANITY_CHECK_RC(ptr, return_code) \ +TOS_MACRO_BEGIN \ + if (unlikely(!(ptr))) { \ + return return_code; \ + } \ +TOS_MACRO_END + +#define TOS_IN_IRQ_CHECK() \ +TOS_MACRO_BEGIN \ + if (unlikely(knl_is_inirq())) { \ + return K_ERR_IN_IRQ; \ + } \ +TOS_MACRO_END #if TOS_CFG_OBJECT_VERIFY_EN > 0u #define TOS_OBJ_INIT(obj, obj_type) knl_object_init(&obj->knl_obj, obj_type) #define TOS_OBJ_DEINIT(obj) knl_object_deinit(&obj->knl_obj) -#define TOS_OBJ_VERIFY(obj, obj_type) \ - do { \ - if (!knl_object_verify(&obj->knl_obj, obj_type)) { \ - return K_ERR_OBJ_INVALID; \ - } \ - } while (0) +#define TOS_OBJ_VERIFY(obj, obj_type) \ +TOS_MACRO_BEGIN \ + if (!knl_object_verify(&obj->knl_obj, obj_type)) { \ + return K_ERR_OBJ_INVALID; \ + } \ +TOS_MACRO_END -#define TOS_OBJ_VERIFY_RC(obj, obj_type, return_code) \ - do { \ - if (!knl_object_verify(&obj->knl_obj, obj_type)) { \ - return return_code; \ - } \ - } while (0) + +#define TOS_OBJ_VERIFY_RC(obj, obj_type, return_code) \ +TOS_MACRO_BEGIN \ + if (!knl_object_verify(&obj->knl_obj, obj_type)) { \ + return return_code; \ + } \ +TOS_MACRO_END #else diff --git a/kernel/core/include/tos_ktypes.h b/kernel/core/include/tos_ktypes.h index 1d8940ef..dead3aec 100644 --- a/kernel/core/include/tos_ktypes.h +++ b/kernel/core/include/tos_ktypes.h @@ -30,6 +30,7 @@ typedef uint8_t k_nesting_t; typedef uint16_t k_opt_t; typedef uint16_t k_sem_cnt_t; typedef uint32_t k_event_flag_t; +typedef uint16_t k_barrier_cnt_t; typedef uint16_t k_countdownlatch_cnt_t; typedef uint32_t k_time_t; diff --git a/kernel/core/include/tos_list.h b/kernel/core/include/tos_list.h index c77934bd..7a135fa5 100644 --- a/kernel/core/include/tos_list.h +++ b/kernel/core/include/tos_list.h @@ -18,6 +18,8 @@ #ifndef _TOS_LIST_H_ #define _TOS_LIST_H_ +__CDECLS_BEGIN + typedef struct k_list_node_st { struct k_list_node_st *next; struct k_list_node_st *prev; @@ -138,5 +140,7 @@ __API__ __STATIC_INLINE__ int tos_list_empty(const k_list_t *list) return list->next == list; } +__CDECLS_END + #endif /* _TOS_LIST_H_ */ diff --git a/kernel/core/include/tos_mail_queue.h b/kernel/core/include/tos_mail_queue.h index 43bc5f6a..61391f01 100644 --- a/kernel/core/include/tos_mail_queue.h +++ b/kernel/core/include/tos_mail_queue.h @@ -18,6 +18,8 @@ #ifndef _TOS_MAIL_QUEUE_H_ #define _TOS_MAIL_QUEUE_H_ +__CDECLS_BEGIN + #if TOS_CFG_MAIL_QUEUE_EN > 0u typedef struct k_mail_queue_st { @@ -155,5 +157,7 @@ __API__ k_err_t tos_mail_q_post_all(k_mail_q_t *mail_q, void *mail_buf, size_t m #endif +__CDECLS_END + #endif /* _TOS_MAIL_QUEUE_H_ */ diff --git a/kernel/core/include/tos_message_queue.h b/kernel/core/include/tos_message_queue.h index d914f976..be2d4d20 100644 --- a/kernel/core/include/tos_message_queue.h +++ b/kernel/core/include/tos_message_queue.h @@ -18,6 +18,8 @@ #ifndef _TOS_MESSAGE_QUEUE_H_ #define _TOS_MESSAGE_QUEUE_H_ +__CDECLS_BEGIN + #if TOS_CFG_MESSAGE_QUEUE_EN > 0u typedef struct k_message_queue_st { @@ -150,5 +152,7 @@ __API__ k_err_t tos_msg_q_post_all(k_msg_q_t *msg_q, void *msg_ptr); #endif +__CDECLS_END + #endif /* _TOS_MESSAGE_QUEUE_H_ */ diff --git a/kernel/core/include/tos_mmblk.h b/kernel/core/include/tos_mmblk.h index d690ee59..cc072cd6 100644 --- a/kernel/core/include/tos_mmblk.h +++ b/kernel/core/include/tos_mmblk.h @@ -18,6 +18,8 @@ #ifndef _TOS_MMBLK_H_ #define _TOS_MMBLK_H_ +__CDECLS_BEGIN + #if TOS_CFG_MMBLK_EN > 0u #define K_MMBLK_NEXT_BLK(blk_curr, blk_size) ((void *)((cpu_addr_t)blk_curr + blk_size)) @@ -103,5 +105,7 @@ __API__ k_err_t tos_mmblk_free(k_mmblk_pool_t *mbp, void *blk); #endif +__CDECLS_END + #endif /* _TOS_MMBLK_H_ */ diff --git a/kernel/core/include/tos_mmheap.h b/kernel/core/include/tos_mmheap.h index 0e08f393..2faa605a 100644 --- a/kernel/core/include/tos_mmheap.h +++ b/kernel/core/include/tos_mmheap.h @@ -55,6 +55,8 @@ #ifndef _TOS_MMHEAP_H_ #define _TOS_MMHEAP_H_ +__CDECLS_BEGIN + #if TOS_CFG_MMHEAP_EN > 0u /** @@ -262,5 +264,7 @@ __KNL__ k_err_t mmheap_init_with_pool(void *pool_start, size_t pool_size); #endif +__CDECLS_END + #endif /* _TOS_MMHEAP_H_ */ diff --git a/kernel/core/include/tos_mutex.h b/kernel/core/include/tos_mutex.h index 76880e18..60a8c65a 100644 --- a/kernel/core/include/tos_mutex.h +++ b/kernel/core/include/tos_mutex.h @@ -18,6 +18,8 @@ #ifndef _TOS_MUTEX_H_ #define _TOS_MUTEX_H_ +__CDECLS_BEGIN + #if TOS_CFG_MUTEX_EN > 0u typedef struct k_mutex_st { @@ -114,5 +116,7 @@ __KNL__ void mutex_release(k_mutex_t *mutex); #endif +__CDECLS_END + #endif /* _TOS_MUTEX_H_ */ diff --git a/kernel/core/include/tos_pend.h b/kernel/core/include/tos_pend.h index 63c41ff2..5f03e811 100644 --- a/kernel/core/include/tos_pend.h +++ b/kernel/core/include/tos_pend.h @@ -18,6 +18,8 @@ #ifndef _TOS_PEND_H_ #define _TOS_PEND_H_ +__CDECLS_BEGIN + typedef struct k_task_st k_task_t; /** @@ -67,5 +69,7 @@ __KNL__ void pend_wakeup_all(pend_obj_t *object, pend_state_t state); __KNL__ void pend_wakeup(pend_obj_t *object, pend_state_t state, opt_post_t opt); +__CDECLS_END + #endif /* _TOS_PEND_H_ */ diff --git a/kernel/core/include/tos_priority_mail_queue.h b/kernel/core/include/tos_priority_mail_queue.h index 075c4417..7ca52fce 100644 --- a/kernel/core/include/tos_priority_mail_queue.h +++ b/kernel/core/include/tos_priority_mail_queue.h @@ -18,6 +18,8 @@ #ifndef _TOS_PRIORITY_MAIL_QUEUE_H_ #define _TOS_PRIORITY_MAIL_QUEUE_H_ +__CDECLS_BEGIN + #if TOS_CFG_PRIORITY_MAIL_QUEUE_EN > 0u typedef struct k_priority_mail_queue_st { @@ -160,5 +162,7 @@ __API__ k_err_t tos_prio_mail_q_post_all(k_prio_mail_q_t *prio_mail_q, void *mai #endif +__CDECLS_END + #endif /* TOS_CFG_PRIORITY_MAIL_QUEUE_EN */ diff --git a/kernel/core/include/tos_priority_message_queue.h b/kernel/core/include/tos_priority_message_queue.h index 9798ca9d..22e868a6 100644 --- a/kernel/core/include/tos_priority_message_queue.h +++ b/kernel/core/include/tos_priority_message_queue.h @@ -18,6 +18,8 @@ #ifndef _TOS_PRIORITY_MESSAGE_QUEUE_H_ #define _TOS_PRIORITY_MESSAGE_QUEUE_H_ +__CDECLS_BEGIN + #if TOS_CFG_PRIORITY_MESSAGE_QUEUE_EN > 0u typedef struct k_priority_message_queue_st { @@ -155,5 +157,7 @@ __API__ k_err_t tos_prio_msg_q_post_all(k_prio_msg_q_t *prio_msg_q, void *msg_pt #endif +__CDECLS_END + #endif /* _TOS_PRIORITY_MESSAGE_QUEUE_H_ */ diff --git a/kernel/core/include/tos_priority_queue.h b/kernel/core/include/tos_priority_queue.h index 13c4e09b..580b58ce 100644 --- a/kernel/core/include/tos_priority_queue.h +++ b/kernel/core/include/tos_priority_queue.h @@ -18,6 +18,8 @@ #ifndef _TOS_PRIORITY_QUEUE_H_ #define _TOS_PRIORITY_QUEUE_H_ +__CDECLS_BEGIN + typedef uint16_t prio_q_slot_t; typedef struct prio_q_pool_manager_entry_st { @@ -207,5 +209,7 @@ __API__ int tos_prio_q_is_empty(k_prio_q_t *prio_q); */ __API__ int tos_prio_q_is_full(k_prio_q_t *prio_q); +__CDECLS_END + #endif /* _TOS_PRIORITY_QUEUE_H_ */ diff --git a/kernel/core/include/tos_robin.h b/kernel/core/include/tos_robin.h index 4580f50a..ae594710 100644 --- a/kernel/core/include/tos_robin.h +++ b/kernel/core/include/tos_robin.h @@ -18,6 +18,8 @@ #ifndef _TOS_ROBIN_H_ #define _TOS_ROBIN_H_ +__CDECLS_BEGIN + #if TOS_CFG_ROUND_ROBIN_EN > 0u /** @@ -50,5 +52,7 @@ __KNL__ void robin_sched(k_prio_t prio); #endif +__CDECLS_END + #endif /* _TOS_ROBIN_H_ */ diff --git a/kernel/core/include/tos_rwlock.h b/kernel/core/include/tos_rwlock.h new file mode 100644 index 00000000..6225e8d9 --- /dev/null +++ b/kernel/core/include/tos_rwlock.h @@ -0,0 +1,192 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _TOS_RWLOCK_H_ +#define _TOS_RWLOCK_H_ + +__CDECLS_BEGIN + +#if (TOS_CFG_SEM_EN > 0u) && (TOS_CFG_MUTEX_EN > 0u) + +typedef uint16_t rw_cnt_t; + +typedef struct k_rwlock_st { +#if TOS_CFG_OBJECT_VERIFY_EN > 0u + knl_obj_t knl_obj; +#endif + + k_mutex_t lock; + k_sem_t signal; + + rw_cnt_t n_readers; /* how many readers are reading? */ + rw_cnt_t n_writers; /* how many writers are waiting to obtain the wlock? */ + int is_writting; +} k_rwlock_t; + +/** + * @brief Create a read-write lock. + * + * @attention a read-write lock can be hold by multi-readers, that means simultaneously reading is allowed; + * but a read-write lock can only be hold by one writes, that means simultaneously writting or read while writting is not allowed. + * + * @param[in] rwlock the read-write lock. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + */ +__API__ k_err_t tos_rwlock_create(k_rwlock_t *rwlock); + +/** + * @brief Destroy a read-write lock. + * + * @attention + * + * @param[in] rwlock the read-write lock. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + */ +__API__ k_err_t tos_rwlock_destroy(k_rwlock_t *rwlock); + +/** + * @brief Pend on the read-lock of a read-write lock. + * + * @attention if one reader already hold the read-lock, other reader can hold the read-lock simultaneously. + * and no writers can hold the write-lock. + * + * @param[in] rwlock the read-write lock. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_RWLOCK_READERS_TO_MANY too many reader are holding the read-lock + */ +__API__ k_err_t tos_rwlock_rpend_timed(k_rwlock_t *rwlock, k_tick_t timeout); + +/** + * @brief Pend on the read-lock of a read-write lock. + * + * @attention if one reader already hold the read-lock, other reader can hold the read-lock simultaneously. + * and no writers can hold the write-lock. + * + * @param[in] rwlock the read-write lock. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_RWLOCK_READERS_TO_MANY too many reader are holding the read-lock + */ +__API__ k_err_t tos_rwlock_rpend(k_rwlock_t *rwlock); + +/** + * @brief Try pend on the read-lock of a read-write lock. + * + * @attention Try means just take a look, if can obtain the read-lock, then we obtain it; otherwise, just return with no-waiting. + * + * @param[in] rwlock the read-write lock. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_RWLOCK_IS_WRITTING the read-write lock is hold by a writter(is writting). + */ +__API__ k_err_t tos_rwlock_rpend_try(k_rwlock_t *rwlock); + +/** + * @brief Pend on the write-lock of a read-write lock. + * + * @attention if one writer already hold the write-lock, other writer CANNOT hold the write-lock any more. + * and no readers can hold the read-lock. + * + * @param[in] rwlock the read-write lock. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_RWLOCK_WAITING_WRITERS_TO_MANY too many writers are waiting for the write-lock + */ +__API__ k_err_t tos_rwlock_wpend_timed(k_rwlock_t *rwlock, k_tick_t timeout); + +/** + * @brief Pend on the write-lock of a read-write lock. + * + * @attention if one writer already hold the write-lock, other writer CANNOT hold the write-lock any more. + * and no readers can hold the read-lock. + * + * @param[in] rwlock the read-write lock. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_RWLOCK_WAITING_WRITERS_TO_MANY too many writers are waiting for the write-lock + */ +__API__ k_err_t tos_rwlock_wpend(k_rwlock_t *rwlock); + +/** + * @brief Pend on the write-lock of a read-write lock. + * + * @attention Try means just take a look, if can obtain the write-lock, then we obtain it; otherwise, just return with no-waiting. + * + * @param[in] rwlock the read-write lock. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_RWLOCK_IS_READING the read-write lock is hold by other reader[s](is reading). + * @retval #K_ERR_RWLOCK_IS_WRITTING the read-write lock is hold by another writter(is writting). + */ +__API__ k_err_t tos_rwlock_wpend_try(k_rwlock_t *rwlock); + +/** + * @brief Post the read-lock of a read-write lock. + * + * @attention + * + * @param[in] rwlock the read-write lock. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_RWLOCK_NOT_READING the read-lock is not held by reader[s]. + */ +__API__ k_err_t tos_rwlock_rpost(k_rwlock_t *rwlock); + +/** + * @brief Post the write-lock of a read-write lock. + * + * @attention + * + * @param[in] rwlock the read-write lock. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_RWLOCK_NOT_WRITTING the write-lock is not held by a writter. + */ +__API__ k_err_t tos_rwlock_wpost(k_rwlock_t *rwlock); + +/** + * @brief Post the read&write-lock of a read-write lock. + * + * @attention + * + * @param[in] rwlock the read-write lock. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + * @retval #K_ERR_RWLOCK_NOT_TAKEN the read-write lock is neither held by reader[s] nor held by a writter. + */ +__API__ k_err_t tos_rwlock_post(k_rwlock_t *rwlock); + +#endif + +__CDECLS_END + +#endif /* _TOS_RWLOCK_H_ */ + diff --git a/kernel/core/include/tos_sched.h b/kernel/core/include/tos_sched.h index 2aaa3969..427b45f1 100644 --- a/kernel/core/include/tos_sched.h +++ b/kernel/core/include/tos_sched.h @@ -18,6 +18,8 @@ #ifndef _TOS_SCHED_H_ #define _TOS_SCHED_H_ +__CDECLS_BEGIN + #define K_PRIO_TBL_SIZE ((TOS_CFG_TASK_PRIO_MAX + 31) / 32) #define K_PRIO_TBL_SLOT_SIZE (32u) @@ -48,5 +50,7 @@ __KNL__ void readyqueue_remove(k_task_t *task); __KNL__ void readyqueue_move_head_to_tail(k_prio_t prio); +__CDECLS_END + #endif /* _TOS_SCHED_H_ */ diff --git a/kernel/core/include/tos_sem.h b/kernel/core/include/tos_sem.h index 6dfe1b28..4a94675b 100644 --- a/kernel/core/include/tos_sem.h +++ b/kernel/core/include/tos_sem.h @@ -18,6 +18,8 @@ #ifndef _TOS_SEM_H_ #define _TOS_SEM_H_ +__CDECLS_BEGIN + #if TOS_CFG_SEM_EN > 0u typedef struct k_sem_st { @@ -120,5 +122,7 @@ __API__ k_err_t tos_sem_post_all(k_sem_t *sem); #endif +__CDECLS_END + #endif /* _TOS_SEM_H_ */ diff --git a/kernel/core/include/tos_slist.h b/kernel/core/include/tos_slist.h index 1a92dc51..b47f6db6 100644 --- a/kernel/core/include/tos_slist.h +++ b/kernel/core/include/tos_slist.h @@ -18,6 +18,8 @@ #ifndef _TOS_SLIST_H_ #define _TOS_SLIST_H_ +__CDECLS_BEGIN + typedef struct k_slist_node_st { struct k_slist_node_st *next; } k_slist_t; @@ -181,5 +183,7 @@ __API__ __STATIC_INLINE__ int tos_slist_empty(k_slist_t *slist) return !slist->next; } +__CDECLS_END + #endif /* _TOS_SLIST_H_ */ diff --git a/kernel/core/include/tos_stopwatch.h b/kernel/core/include/tos_stopwatch.h new file mode 100644 index 00000000..340b8542 --- /dev/null +++ b/kernel/core/include/tos_stopwatch.h @@ -0,0 +1,141 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _TOS_STOPWATCH_H_ +#define _TOS_STOPWATCH_H_ + +__CDECLS_BEGIN + +typedef struct k_stopwatch_st { +#if TOS_CFG_OBJECT_VERIFY_EN > 0u + knl_obj_t knl_obj; +#endif + + k_tick_t until; +} k_stopwatch_t; + +/** + * @brief Create a stopwatch. + * + * @attention + * + * @param[in] stopwatch the stopwatch. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + */ +__API__ k_err_t tos_stopwatch_create(k_stopwatch_t *stopwatch); + +/** + * @brief Destroy a stopwatch. + * + * @attention + * + * @param[in] stopwatch the stopwatch. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + */ +__API__ k_err_t tos_stopwatch_destroy(k_stopwatch_t *stopwatch); + +/** + * @brief Count down for a certain tick. + * + * @attention + * + * @param[in] stopwatch the stopwatch. + * @param[in] tick tick to count down. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + */ +__API__ k_err_t tos_stopwatch_countdown(k_stopwatch_t *stopwatch, k_tick_t tick); + +/** + * @brief Count down for a certain time(in millisecond). + * + * @attention + * + * @param[in] stopwatch the stopwatch. + * @param[in] millisec time(in millisecond) to count down. + * + * @return errcode + * @retval #K_ERR_NONE return successfully. + */ +__API__ k_err_t tos_stopwatch_countdown_ms(k_stopwatch_t *stopwatch, k_time_t millisec); + +/** + * @brief Delay for a certain tick. + * + * @attention the stopwatch delay is a "busy" delay without give up of CPU(compared to tos_task_delay) + * + * @param[in] tick tick to delay. + * + * @return None + */ +__API__ void tos_stopwatch_delay(k_tick_t tick); + +/** + * @brief Delay for a certain time(in millisecond). + * + * @attention the stopwatch delay is a "busy" delay without give up of CPU(compared to tos_task_delay) + * + * @param[in] millisec time(in millisecond) to delay. + * + * @return None + */ +__API__ void tos_stopwatch_delay_ms(k_time_t millisec); + +/** + * @brief How much time remain of the stopwatch(in tick). + * + * @attention + * + * @param[in] stopwatch ticks remain. + * + * @return ticks remain + */ +__API__ k_tick_t tos_stopwatch_remain(k_stopwatch_t *stopwatch); + +/** + * @brief How much time remain of the stopwatch(in millisecond). + * + * @attention + * + * @param[in] stopwatch milliseconds remain. + * + * @return milliseconds remain + */ +__API__ k_time_t tos_stopwatch_remain_ms(k_stopwatch_t *stopwatch); + +/** + * @brief Whether the stopwatch is expired. + * + * @attention + * + * @param[in] stopwatch milliseconds remain. + * + * @return whether the stopwatch is expired + * @retval #K_TRUE the stopwatch is expired. + * @retval #K_FALSE the stopwatch is no expired. + */ +__API__ int tos_stopwatch_is_expired(k_stopwatch_t *stopwatch); + +__CDECLS_END + +#endif /* _TOS_STOPWATCH_H_ */ + diff --git a/kernel/core/include/tos_sys.h b/kernel/core/include/tos_sys.h index 58120b6b..b54b4653 100644 --- a/kernel/core/include/tos_sys.h +++ b/kernel/core/include/tos_sys.h @@ -18,6 +18,8 @@ #ifndef _TOS_SYS_H_ #define _TOS_SYS_H_ +__CDECLS_BEGIN + #define K_NESTING_LIMIT_IRQ (k_nesting_t)250u #define K_NESTING_LIMIT_SCHED_LOCK (k_nesting_t)250u @@ -28,26 +30,31 @@ typedef enum knl_state_en { // some kind of magic number, mainly for identifing whether the object is initialized, or whether user pass the correct parameter. typedef enum knl_obj_type_en { - KNL_OBJ_TYPE_NONE = 0x0000, - KNL_OBJ_TYPE_TASK = 0xDAD1, - KNL_OBJ_TYPE_TIMER = 0xDAD2, - KNL_OBJ_TYPE_MSG_QUEUE = 0xDAD3, - KNL_OBJ_TYPE_MMBLK_POOL = 0xDAD4, - KNL_OBJ_TYPE_RING_QUEUE = 0xDAD5, - KNL_OBJ_TYPE_BINARY_HEAP = 0xDAD6, - KNL_OBJ_TYPE_PRIORITY_QUEUE = 0xDAD7, - KNL_OBJ_TYPE_CHAR_FIFO = 0xDAD8, + KNL_OBJ_TYPE_NONE = 0x0000, + + KNL_OBJ_TYPE_BINARY_HEAP = 0xDAD0, + KNL_OBJ_TYPE_BITMAP = 0xDAD1, + KNL_OBJ_TYPE_CHAR_FIFO = 0xDAD2, + KNL_OBJ_TYPE_MMBLK_POOL = 0xDAD3, + KNL_OBJ_TYPE_MSG_QUEUE = 0xDAD4, + KNL_OBJ_TYPE_PRIORITY_QUEUE = 0xDAD5, + KNL_OBJ_TYPE_RING_QUEUE = 0xDAD6, + KNL_OBJ_TYPE_STOPWATCH = 0xDAD7, + KNL_OBJ_TYPE_TASK = 0xDAD8, + KNL_OBJ_TYPE_TIMER = 0xDAD9, // ipc object - KNL_OBJ_TYPE_SEMAPHORE = 0x1BEE, - KNL_OBJ_TYPE_MUTEX = 0x2BEE, - KNL_OBJ_TYPE_EVENT = 0x3BEE, - KNL_OBJ_TYPE_MAIL_QUEUE = 0x4BEE, - KNL_OBJ_TYPE_MESSAGE_QUEUE = 0x5BEE, - KNL_OBJ_TYPE_PRIORITY_MAIL_QUEUE = 0x6BEE, - KNL_OBJ_TYPE_PRIORITY_MESSAGE_QUEUE = 0x7BEE, - KNL_OBJ_TYPE_COUNTDOWNLATCH = 0x8BEE, - KNL_OBJ_TYPE_COMPLETION = 0x9BEE, + KNL_OBJ_TYPE_BARRIER = 0x0BEE, + KNL_OBJ_TYPE_COMPLETION = 0x1BEE, + KNL_OBJ_TYPE_COUNTDOWNLATCH = 0x2BEE, + KNL_OBJ_TYPE_EVENT = 0x3BEE, + KNL_OBJ_TYPE_MAIL_QUEUE = 0x4BEE, + KNL_OBJ_TYPE_MESSAGE_QUEUE = 0x5BEE, + KNL_OBJ_TYPE_MUTEX = 0x6BEE, + KNL_OBJ_TYPE_PRIORITY_MAIL_QUEUE = 0x7BEE, + KNL_OBJ_TYPE_PRIORITY_MESSAGE_QUEUE = 0x8BEE, + KNL_OBJ_TYPE_RWLOCK = 0x9BEE, + KNL_OBJ_TYPE_SEMAPHORE = 0xABEE, } knl_obj_type_t; typedef enum knl_obj_alloc_type_en { @@ -218,5 +225,7 @@ __KNL__ __STATIC_INLINE__ int knl_object_alloc_is_static(knl_obj_t *knl_obj) #endif +__CDECLS_END + #endif /* _TOS_SYS_H_ */ diff --git a/kernel/core/include/tos_task.h b/kernel/core/include/tos_task.h index 74888f4b..a83099a9 100644 --- a/kernel/core/include/tos_task.h +++ b/kernel/core/include/tos_task.h @@ -18,6 +18,11 @@ #ifndef _TOS_TASK_H_ #define _TOS_TASK_H_ +__CDECLS_BEGIN + +#define K_TASK_NAME_MAX (16u) +#define K_TASK_STK_SIZE_MIN (sizeof(cpu_context_t)) + // task state is just a flag, indicating which manager list we are in. // ready to schedule @@ -67,43 +72,43 @@ typedef void (*k_task_walker_t)(k_task_t *task); * task control block */ typedef struct k_task_st { - k_stack_t *sp; /**< task stack pointer. This lady always comes first, we count on her in port_s.S for context switch. */ + k_stack_t *sp; /**< task stack pointer. This lady always comes first, we count on her in port_s.S for context switch. */ - knl_obj_t knl_obj; /**< just for verification, test whether current object is really a task. */ + knl_obj_t knl_obj; /**< just for verification, test whether current object is really a task. */ - char *name; /**< task name */ - k_task_entry_t entry; /**< task entry */ - void *arg; /**< argument for task entry */ - k_task_state_t state; /**< just state */ - k_prio_t prio; /**< just priority */ + char name[K_TASK_NAME_MAX]; /**< task name */ + k_task_entry_t entry; /**< task entry */ + void *arg; /**< argument for task entry */ + k_task_state_t state; /**< just state */ + k_prio_t prio; /**< just priority */ - k_stack_t *stk_base; /**< task stack base address */ - size_t stk_size; /**< stack size of the task */ + k_stack_t *stk_base; /**< task stack base address */ + size_t stk_size; /**< stack size of the task */ #if TOS_CFG_TASK_DYNAMIC_CREATE_EN > 0u - k_list_t dead_list; /**< when a dynamic allocated task destroyed, we hook the task's dead_list to the k_dead_task_list */ + k_list_t dead_list; /**< when a dynamic allocated task destroyed, we hook the task's dead_list to the k_dead_task_list */ #endif - k_list_t stat_list; /**< list for hooking us to the k_stat_list */ + k_list_t stat_list; /**< list for hooking us to the k_stat_list */ - k_tick_t tick_expires; /**< if we are in k_tick_list, how much time will we wait for? */ + k_tick_t tick_expires; /**< if we are in k_tick_list, how much time will we wait for? */ - k_list_t tick_list; /**< list for hooking us to the k_tick_list */ - k_list_t pend_list; /**< when we are ready, our pend_list is in readyqueue; when pend, in a certain pend object's list. */ + k_list_t tick_list; /**< list for hooking us to the k_tick_list */ + k_list_t pend_list; /**< when we are ready, our pend_list is in readyqueue; when pend, in a certain pend object's list. */ #if TOS_CFG_MUTEX_EN > 0u - k_list_t mutex_own_list; /**< the list hold all the mutex we own. - When we die(tos_task_destroy), we have an obligation to wakeup all the task pending for those mutexs we own; - if not, those pending tasks may never get a chance to wakeup. */ - k_prio_t prio_pending; /*< when tos_task_prio_change called, we may be just the owner of a mutex. - to avoid PRIORITY INVERSION, must make sure our priority is higher than any one who is pending for - the mutex we hold. So, if the prio_new of tos_task_prio_change is not appropriate - (may against the principle of PRIORITY INVERSION), we just mark the prio_new here, do the real priority - change in the right time(mutex_old_owner_release) later. */ + k_list_t mutex_own_list; /**< the list hold all the mutex we own. + When we die(tos_task_destroy), we have an obligation to wakeup all the task pending for those mutexs we own; + if not, those pending tasks may never get a chance to wakeup. */ + k_prio_t prio_pending; /*< when tos_task_prio_change called, we may be just the owner of a mutex. + to avoid PRIORITY INVERSION, must make sure our priority is higher than any one who is pending for + the mutex we hold. So, if the prio_new of tos_task_prio_change is not appropriate + (may against the principle of PRIORITY INVERSION), we just mark the prio_new here, do the real priority + change in the right time(mutex_old_owner_release) later. */ #endif - pend_obj_t *pending_obj; /**< if we are pending, which pend object's list we are in? */ - pend_state_t pend_state; /**< why we wakeup from a pend */ + pend_obj_t *pending_obj; /**< if we are pending, which pend object's list we are in? */ + pend_state_t pend_state; /**< why we wakeup from a pend */ #if TOS_CFG_ROUND_ROBIN_EN > 0u k_timeslice_t timeslice_reload; /**< if current time slice is used up, use time_slice_reload to reload our time slice */ @@ -406,7 +411,9 @@ __DEBUG__ __STATIC_INLINE__ void task_default_walker(k_task_t *task) state_str = state_str; tos_kprintln("tsk name: %s", task->name); - if (task->state == K_TASK_STATE_PENDTIMEOUT_SUSPENDED) { + if (tos_task_curr_task_get() == task) { + state_str = "RUNNING"; + } else if (task->state == K_TASK_STATE_PENDTIMEOUT_SUSPENDED) { state_str = "PENDTIMEOUT_SUSPENDED"; } else if (task->state == K_TASK_STATE_PEND_SUSPENDED) { state_str = "PEND_SUSPENDED"; @@ -431,5 +438,7 @@ __DEBUG__ __STATIC_INLINE__ void task_default_walker(k_task_t *task) tos_kprintf("\n"); } +__CDECLS_END + #endif /* _TOS_TASK_H_ */ diff --git a/kernel/core/include/tos_tick.h b/kernel/core/include/tos_tick.h index 607f5374..a1e3becb 100644 --- a/kernel/core/include/tos_tick.h +++ b/kernel/core/include/tos_tick.h @@ -18,6 +18,8 @@ #ifndef _TOS_TICK_H_ #define _TOS_TICK_H_ +__CDECLS_BEGIN + /** * @brief Systick interrupt handler. * systick interrupt handler. @@ -40,5 +42,7 @@ __KNL__ void tick_list_remove(k_task_t *task); __KNL__ k_tick_t tick_next_expires_get(void); #endif +__CDECLS_END + #endif /* _TOS_TICK_H_ */ diff --git a/kernel/core/include/tos_time.h b/kernel/core/include/tos_time.h index 1aa966e9..da23ff67 100644 --- a/kernel/core/include/tos_time.h +++ b/kernel/core/include/tos_time.h @@ -18,6 +18,8 @@ #ifndef _TOS_TIME_H_ #define _TOS_TIME_H_ +__CDECLS_BEGIN + // if you wanna pend for something forever, use TOS_TIME_FOREVER #define TOS_TIME_FOREVER (k_tick_t)(-1) // if you don't wanna wait when you pend nothing, use TOS_TIME_NOWAIT @@ -106,5 +108,7 @@ __API__ k_err_t tos_sleep_ms(k_time_t millisec); */ __API__ k_err_t tos_sleep_hmsm(k_time_t hour, k_time_t minute, k_time_t second, k_time_t millisec); +__CDECLS_END + #endif /* _TOS_TIME_H_ */ diff --git a/kernel/core/include/tos_timer.h b/kernel/core/include/tos_timer.h index d3a6e9bf..5ad3b3ae 100644 --- a/kernel/core/include/tos_timer.h +++ b/kernel/core/include/tos_timer.h @@ -18,6 +18,8 @@ #ifndef _TOS_TIMER_H_ #define _TOS_TIMER_H_ +__CDECLS_BEGIN + #if TOS_CFG_TIMER_EN > 0u // if we just want the timer to run only once, this option should be passed to tos_timer_create. @@ -185,5 +187,7 @@ __KNL__ k_tick_t timer_next_expires_get(void); #endif +__CDECLS_END + #endif /* _TOS_TIMER_H_ */ diff --git a/kernel/core/tos_barrier.c b/kernel/core/tos_barrier.c new file mode 100644 index 00000000..96edfa5a --- /dev/null +++ b/kernel/core/tos_barrier.c @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "tos_k.h" + +__API__ k_err_t tos_barrier_create(k_barrier_t *barrier, k_barrier_cnt_t count) +{ + TOS_PTR_SANITY_CHECK(barrier); + + if (count == 0u) { + return K_ERR_BARRIER_COUNT_INVALID; + } + + barrier->count = count; + pend_object_init(&barrier->pend_obj); + TOS_OBJ_INIT(barrier, KNL_OBJ_TYPE_BARRIER); + + return K_ERR_NONE; +} + +__API__ k_err_t tos_barrier_destroy(k_barrier_t *barrier) +{ + TOS_CPU_CPSR_ALLOC(); + + TOS_PTR_SANITY_CHECK(barrier); + TOS_OBJ_VERIFY(barrier, KNL_OBJ_TYPE_BARRIER); + + TOS_CPU_INT_DISABLE(); + + if (!pend_is_nopending(&barrier->pend_obj)) { + pend_wakeup_all(&barrier->pend_obj, PEND_STATE_DESTROY); + } + + pend_object_deinit(&barrier->pend_obj); + + TOS_OBJ_DEINIT(barrier); + + TOS_CPU_INT_ENABLE(); + knl_sched(); + + return K_ERR_NONE; +} + +__API__ k_err_t tos_barrier_pend(k_barrier_t *barrier) +{ + TOS_CPU_CPSR_ALLOC(); + + TOS_IN_IRQ_CHECK(); + TOS_PTR_SANITY_CHECK(barrier); + TOS_OBJ_VERIFY(barrier, KNL_OBJ_TYPE_BARRIER); + + TOS_CPU_INT_DISABLE(); + + if (barrier->count == 0u) { + TOS_CPU_INT_ENABLE(); + return K_ERR_BARRIER_OVERFLOW; + } + + if (barrier->count == (k_barrier_cnt_t)1u) { + barrier->count = (k_barrier_cnt_t)0u; + + if (!pend_is_nopending(&barrier->pend_obj)) { + pend_wakeup_all(&barrier->pend_obj, PEND_STATE_POST); + } + + TOS_CPU_INT_ENABLE(); + return K_ERR_NONE; + } + + if (knl_is_sched_locked()) { + TOS_CPU_INT_ENABLE(); + return K_ERR_PEND_SCHED_LOCKED; + } + + --barrier->count; + pend_task_block(k_curr_task, &barrier->pend_obj, TOS_TIME_FOREVER); + + TOS_CPU_INT_ENABLE(); + knl_sched(); + + return pend_state2errno(k_curr_task->pend_state); +} + +__API__ k_err_t tos_barrier_reset(k_barrier_t *barrier, k_barrier_cnt_t count) +{ + TOS_CPU_CPSR_ALLOC(); + + TOS_PTR_SANITY_CHECK(barrier); + TOS_OBJ_VERIFY(barrier, KNL_OBJ_TYPE_BARRIER); + + TOS_CPU_INT_DISABLE(); + barrier->count = count; + TOS_CPU_INT_ENABLE(); + + return K_ERR_NONE; +} + diff --git a/kernel/core/tos_bitmap.c b/kernel/core/tos_bitmap.c new file mode 100644 index 00000000..c9f59573 --- /dev/null +++ b/kernel/core/tos_bitmap.c @@ -0,0 +1,143 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "tos_k.h" + +__API__ k_err_t tos_bitmap_create_empty(k_bitmap_t *bitmap, k_bmtbl_t *bitmap_tbl, uint32_t bit_max) +{ + int i = 0; + + TOS_PTR_SANITY_CHECK(bitmap); + + bitmap->bitmap_tbl = bitmap_tbl; + bitmap->bit_max = bit_max; + bitmap->bit_ndx_max = K_BITMAP_TBL_SIZE(bit_max); + + for (i = 0; i < bitmap->bit_ndx_max; ++i) { + /* all bits are 0 */ + bitmap_tbl[i] = 0; + } + TOS_OBJ_INIT(bitmap, KNL_OBJ_TYPE_BITMAP); + + return K_ERR_NONE; +} + +__API__ k_err_t tos_bitmap_create_full(k_bitmap_t *bitmap, k_bmtbl_t *bitmap_tbl, uint32_t bit_max) +{ + int i = 0; + + TOS_PTR_SANITY_CHECK(bitmap); + + bitmap->bitmap_tbl = bitmap_tbl; + bitmap->bit_max = bit_max; + bitmap->bit_ndx_max = K_BITMAP_TBL_SIZE(bit_max); + + for (i = 0; i < bitmap->bit_ndx_max; ++i) { + /* all bits are 1 */ + bitmap_tbl[i] = ~0; + } + TOS_OBJ_INIT(bitmap, KNL_OBJ_TYPE_BITMAP); + + return K_ERR_NONE; +} + +__API__ k_err_t tos_bitmap_destroy(k_bitmap_t *bitmap) +{ + TOS_PTR_SANITY_CHECK(bitmap); + TOS_OBJ_VERIFY(bitmap, KNL_OBJ_TYPE_BITMAP); + + TOS_OBJ_DEINIT(bitmap); + return K_ERR_NONE; +} + +__API__ k_err_t tos_bitmap_set(k_bitmap_t *bitmap, uint32_t bit) +{ + TOS_PTR_SANITY_CHECK(bitmap); + TOS_OBJ_VERIFY(bitmap, KNL_OBJ_TYPE_BITMAP); + + if (bit > bitmap->bit_max) { + return K_ERR_BITMAP_EXCEED; + } + + bitmap->bitmap_tbl[K_BITMAP_NDX(bit)] |= K_BITMAP_BIT(bit); + + return K_ERR_NONE; +} + +__API__ k_err_t tos_bitmap_reset(k_bitmap_t *bitmap, uint32_t bit) +{ + TOS_PTR_SANITY_CHECK(bitmap); + TOS_OBJ_VERIFY(bitmap, KNL_OBJ_TYPE_BITMAP); + + if (bit > bitmap->bit_max) { + return K_ERR_BITMAP_EXCEED; + } + + bitmap->bitmap_tbl[K_BITMAP_NDX(bit)] &= ~K_BITMAP_BIT(bit); + + return K_ERR_NONE; +} + +__API__ int tos_bitmap_is_set(k_bitmap_t *bitmap, uint32_t bit) +{ + TOS_PTR_SANITY_CHECK_RC(bitmap, K_FALSE); + TOS_OBJ_VERIFY_RC(bitmap, KNL_OBJ_TYPE_BITMAP, K_FALSE); + + if (bit > bitmap->bit_max) { + return K_FALSE; + } + + return (bitmap->bitmap_tbl[K_BITMAP_NDX(bit)] & K_BITMAP_BIT(bit)) ? K_TRUE : K_FALSE; +} + +__API__ int tos_bitmap_is_reset(k_bitmap_t *bitmap, uint32_t bit) +{ + TOS_PTR_SANITY_CHECK_RC(bitmap, K_FALSE); + TOS_OBJ_VERIFY_RC(bitmap, KNL_OBJ_TYPE_BITMAP, K_FALSE); + + if (bit > bitmap->bit_max) { + return K_FALSE; + } + + return tos_bitmap_is_set(bitmap, bit) ? K_FALSE : K_TRUE; +} + +__API__ int tos_bitmap_lsb(k_bitmap_t *bitmap) +{ + int lsb = 0, i = 0; + k_bmtbl_t *bitmap_tbl; + + TOS_PTR_SANITY_CHECK_RC(bitmap, -1); + TOS_OBJ_VERIFY_RC(bitmap, KNL_OBJ_TYPE_BITMAP, -1); + + bitmap_tbl = bitmap->bitmap_tbl; + + for (i = 0; i < bitmap->bit_ndx_max - 1; ++i) { + if (*bitmap_tbl == 0) { + lsb += K_BITMAP_SLOT_SIZE; + ++bitmap_tbl; + } + } + + lsb += tos_cpu_clz(*bitmap_tbl); + if (lsb > bitmap->bit_max) { + return bitmap->bit_max + 1; + } + + return lsb; +} + diff --git a/kernel/core/tos_completion.c b/kernel/core/tos_completion.c index 76cc1fc6..c9eb4eff 100644 --- a/kernel/core/tos_completion.c +++ b/kernel/core/tos_completion.c @@ -17,8 +17,6 @@ #include "tos_k.h" -#if TOS_CFG_COMPLETION_EN > 0u - __API__ k_err_t tos_completion_create(k_completion_t *completion) { TOS_PTR_SANITY_CHECK(completion); @@ -57,6 +55,7 @@ __API__ k_err_t tos_completion_pend_timed(k_completion_t *completion, k_tick_t t { TOS_CPU_CPSR_ALLOC(); + TOS_IN_IRQ_CHECK(); TOS_PTR_SANITY_CHECK(completion); TOS_OBJ_VERIFY(completion, KNL_OBJ_TYPE_COMPLETION); @@ -72,11 +71,6 @@ __API__ k_err_t tos_completion_pend_timed(k_completion_t *completion, k_tick_t t return K_ERR_PEND_NOWAIT; } - if (knl_is_inirq()) { - TOS_CPU_INT_ENABLE(); - return K_ERR_PEND_IN_IRQ; - } - if (knl_is_sched_locked()) { TOS_CPU_INT_ENABLE(); return K_ERR_PEND_SCHED_LOCKED; @@ -163,5 +157,3 @@ __API__ int tos_completion_is_done(k_completion_t *completion) return is_done; } -#endif - diff --git a/kernel/core/tos_countdownlatch.c b/kernel/core/tos_countdownlatch.c index 99dba491..25a484e6 100644 --- a/kernel/core/tos_countdownlatch.c +++ b/kernel/core/tos_countdownlatch.c @@ -17,8 +17,6 @@ #include "tos_k.h" -#if TOS_CFG_COUNTDOWNLATCH_EN > 0u - __API__ k_err_t tos_countdownlatch_create(k_countdownlatch_t *countdownlatch, k_countdownlatch_cnt_t count) { TOS_PTR_SANITY_CHECK(countdownlatch); @@ -57,6 +55,7 @@ __API__ k_err_t tos_countdownlatch_pend_timed(k_countdownlatch_t *countdownlatch { TOS_CPU_CPSR_ALLOC(); + TOS_IN_IRQ_CHECK(); TOS_PTR_SANITY_CHECK(countdownlatch); TOS_OBJ_VERIFY(countdownlatch, KNL_OBJ_TYPE_COUNTDOWNLATCH); @@ -72,11 +71,6 @@ __API__ k_err_t tos_countdownlatch_pend_timed(k_countdownlatch_t *countdownlatch return K_ERR_PEND_NOWAIT; } - if (knl_is_inirq()) { - TOS_CPU_INT_ENABLE(); - return K_ERR_PEND_IN_IRQ; - } - if (knl_is_sched_locked()) { TOS_CPU_INT_ENABLE(); return K_ERR_PEND_SCHED_LOCKED; @@ -138,5 +132,3 @@ __API__ k_err_t tos_countdownlatch_reset(k_countdownlatch_t *countdownlatch, k_c return K_ERR_NONE; } -#endif - diff --git a/kernel/core/tos_event.c b/kernel/core/tos_event.c index de000175..92f9bc70 100644 --- a/kernel/core/tos_event.c +++ b/kernel/core/tos_event.c @@ -75,6 +75,7 @@ __API__ k_err_t tos_event_pend(k_event_t *event, k_event_flag_t flag_expect, k_e { TOS_CPU_CPSR_ALLOC(); + TOS_IN_IRQ_CHECK(); TOS_PTR_SANITY_CHECK(event); TOS_PTR_SANITY_CHECK(flag_match); TOS_OBJ_VERIFY(event, KNL_OBJ_TYPE_EVENT); @@ -102,11 +103,6 @@ __API__ k_err_t tos_event_pend(k_event_t *event, k_event_flag_t flag_expect, k_e return K_ERR_PEND_NOWAIT; } - if (knl_is_inirq()) { - TOS_CPU_INT_ENABLE(); - return K_ERR_PEND_IN_IRQ; - } - if (knl_is_sched_locked()) { TOS_CPU_INT_ENABLE(); return K_ERR_PEND_SCHED_LOCKED; diff --git a/kernel/core/tos_mail_queue.c b/kernel/core/tos_mail_queue.c index 52745b1f..b601f1e9 100644 --- a/kernel/core/tos_mail_queue.c +++ b/kernel/core/tos_mail_queue.c @@ -150,6 +150,7 @@ __API__ k_err_t tos_mail_q_pend(k_mail_q_t *mail_q, void *mail_buf, size_t *mail TOS_CPU_CPSR_ALLOC(); k_err_t err; + TOS_IN_IRQ_CHECK(); TOS_PTR_SANITY_CHECK(mail_q); TOS_PTR_SANITY_CHECK(mail_buf); TOS_OBJ_VERIFY(mail_q, KNL_OBJ_TYPE_MAIL_QUEUE); diff --git a/kernel/core/tos_message_queue.c b/kernel/core/tos_message_queue.c index ecf10ce5..22ff9050 100644 --- a/kernel/core/tos_message_queue.c +++ b/kernel/core/tos_message_queue.c @@ -151,6 +151,7 @@ __API__ k_err_t tos_msg_q_pend(k_msg_q_t *msg_q, void **msg_ptr, k_tick_t timeou TOS_CPU_CPSR_ALLOC(); k_err_t err; + TOS_IN_IRQ_CHECK(); TOS_PTR_SANITY_CHECK(msg_q); TOS_PTR_SANITY_CHECK(msg_ptr); TOS_OBJ_VERIFY(msg_q, KNL_OBJ_TYPE_MESSAGE_QUEUE); diff --git a/kernel/core/tos_priority_mail_queue.c b/kernel/core/tos_priority_mail_queue.c index 315cf018..6ec43760 100644 --- a/kernel/core/tos_priority_mail_queue.c +++ b/kernel/core/tos_priority_mail_queue.c @@ -151,6 +151,7 @@ __API__ k_err_t tos_prio_mail_q_pend(k_prio_mail_q_t *prio_mail_q, void *mail_bu TOS_CPU_CPSR_ALLOC(); k_err_t err; + TOS_IN_IRQ_CHECK(); TOS_PTR_SANITY_CHECK(prio_mail_q); TOS_PTR_SANITY_CHECK(mail_buf); TOS_OBJ_VERIFY(prio_mail_q, KNL_OBJ_TYPE_PRIORITY_MAIL_QUEUE); diff --git a/kernel/core/tos_priority_message_queue.c b/kernel/core/tos_priority_message_queue.c index 7a0b1078..0af3fafe 100644 --- a/kernel/core/tos_priority_message_queue.c +++ b/kernel/core/tos_priority_message_queue.c @@ -154,6 +154,7 @@ __API__ k_err_t tos_prio_msg_q_pend(k_prio_msg_q_t *prio_msg_q, void **msg_ptr, TOS_CPU_CPSR_ALLOC(); k_err_t err; + TOS_IN_IRQ_CHECK(); TOS_PTR_SANITY_CHECK(prio_msg_q); TOS_PTR_SANITY_CHECK(msg_ptr); TOS_OBJ_VERIFY(prio_msg_q, KNL_OBJ_TYPE_PRIORITY_MESSAGE_QUEUE); diff --git a/kernel/core/tos_rwlock.c b/kernel/core/tos_rwlock.c new file mode 100644 index 00000000..d071f211 --- /dev/null +++ b/kernel/core/tos_rwlock.c @@ -0,0 +1,326 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "tos_k.h" + +#if (TOS_CFG_SEM_EN > 0u) && (TOS_CFG_MUTEX_EN > 0u) + +__API__ k_err_t tos_rwlock_create(k_rwlock_t *rwlock) +{ + k_err_t err; + TOS_PTR_SANITY_CHECK(rwlock); + + err = tos_sem_create(&rwlock->signal, 0u); + if (err != K_ERR_NONE) { + return err; + } + + err = tos_mutex_create(&rwlock->lock); + if (err != K_ERR_NONE) { + tos_sem_destroy(&rwlock->signal); + return err; + } + + rwlock->n_readers = (rw_cnt_t)0u; + rwlock->n_writers = (rw_cnt_t)0u; + rwlock->is_writting = K_FALSE; + TOS_OBJ_INIT(rwlock, KNL_OBJ_TYPE_RWLOCK); + + return K_ERR_NONE; +} + +__API__ k_err_t tos_rwlock_destroy(k_rwlock_t *rwlock) +{ + k_err_t err0, err1; + + TOS_PTR_SANITY_CHECK(rwlock); + TOS_OBJ_VERIFY(rwlock, KNL_OBJ_TYPE_RWLOCK); + + err0 = tos_sem_destroy(&rwlock->signal); + err1 = tos_mutex_destroy(&rwlock->lock); + + rwlock->n_readers = (rw_cnt_t)0u; + rwlock->n_writers = (rw_cnt_t)0u; + rwlock->is_writting = K_FALSE; + TOS_OBJ_DEINIT(rwlock); + + if (err0 != K_ERR_NONE) { + return err0; + } + + return err1; +} + +__API__ k_err_t tos_rwlock_rpend_timed(k_rwlock_t *rwlock, k_tick_t timeout) +{ + k_err_t err; + k_stopwatch_t stopwatch; + + TOS_PTR_SANITY_CHECK(rwlock); + TOS_OBJ_VERIFY(rwlock, KNL_OBJ_TYPE_RWLOCK); + + if (timeout != TOS_TIME_FOREVER) { + tos_stopwatch_create(&stopwatch); + tos_stopwatch_countdown(&stopwatch, timeout); + } + + err = tos_mutex_pend_timed(&rwlock->lock, timeout); + if (err != K_ERR_NONE) { + return err; + } + + if (rwlock->n_readers == (rw_cnt_t)-1) { + /* number of reader reachs limit */ + return K_ERR_RWLOCK_READERS_TO_MANY; + } + + if (rwlock->n_writers == 0u && !rwlock->is_writting) { + /* no writer is now holding or waiting to hold the lock */ + ++rwlock->n_readers; + tos_mutex_post(&rwlock->lock); + return K_ERR_NONE; + } + + if (timeout != TOS_TIME_FOREVER) { + timeout = tos_stopwatch_remain(&stopwatch); + if (timeout == 0u) { + timeout = 1u; + } + } + + while (rwlock->n_writers > 0u || rwlock->is_writting) { + /* util no one is writting or waiting to hold the lock */ + err = tos_sem_pend(&rwlock->signal, timeout); + if (err != K_ERR_NONE) { + break; + } + + if (timeout != TOS_TIME_FOREVER) { + timeout = tos_stopwatch_remain(&stopwatch); + if (timeout == 0u) { + err = K_ERR_PEND_TIMEOUT; + break; + } + } + } + + tos_mutex_post(&rwlock->lock); + return err; +} + +__API__ k_err_t tos_rwlock_rpend(k_rwlock_t *rwlock) +{ + return tos_rwlock_rpend_timed(rwlock, TOS_TIME_FOREVER); +} + +__API__ k_err_t tos_rwlock_rpend_try(k_rwlock_t *rwlock) +{ + k_err_t err; + + TOS_PTR_SANITY_CHECK(rwlock); + TOS_OBJ_VERIFY(rwlock, KNL_OBJ_TYPE_RWLOCK); + + err = tos_mutex_pend(&rwlock->lock); + if (err != K_ERR_NONE) { + return err; + } + + if (rwlock->n_readers == (rw_cnt_t)-1) { + /* number of reader reachs limit */ + return K_ERR_RWLOCK_READERS_TO_MANY; + } + + if (rwlock->n_writers == 0u && !rwlock->is_writting) { + /* no writer is holding or waiting to hold the lock */ + ++rwlock->n_readers; + tos_mutex_post(&rwlock->lock); + return K_ERR_NONE; + } + + /* the rwlock is held by other writters */ + tos_mutex_post(&rwlock->lock); + return K_ERR_RWLOCK_IS_WRITTING; +} + +__API__ k_err_t tos_rwlock_wpend_timed(k_rwlock_t *rwlock, k_tick_t timeout) +{ + k_err_t err; + k_stopwatch_t stopwatch; + + TOS_PTR_SANITY_CHECK(rwlock); + TOS_OBJ_VERIFY(rwlock, KNL_OBJ_TYPE_RWLOCK); + + if (timeout != TOS_TIME_FOREVER) { + tos_stopwatch_create(&stopwatch); + tos_stopwatch_countdown(&stopwatch, timeout); + } + + err = tos_mutex_pend_timed(&rwlock->lock, timeout); + if (err != K_ERR_NONE) { + return err; + } + + if (rwlock->n_writers == (rw_cnt_t)-1) { + /* number of waitting writer reachs limit */ + return K_ERR_RWLOCK_WAITING_WRITERS_TO_MANY; + } + + ++rwlock->n_writers; + + if (timeout != TOS_TIME_FOREVER) { + timeout = tos_stopwatch_remain(&stopwatch); + if (timeout == 0u) { + timeout = 1u; + } + } + + while (rwlock->n_readers > 0u || rwlock->is_writting) { + /* util no one is writting or reading */ + err = tos_sem_pend(&rwlock->signal, timeout); + if (err != K_ERR_NONE) { + break; + } + + if (timeout != TOS_TIME_FOREVER) { + timeout = tos_stopwatch_remain(&stopwatch); + if (timeout == 0u) { + err = K_ERR_PEND_TIMEOUT; + break; + } + } + } + + if (err == K_ERR_NONE) { + /* we hold the wlock now */ + rwlock->is_writting = K_TRUE; + } else { + tos_sem_post_all(&rwlock->signal); + } + + --rwlock->n_writers; + + tos_mutex_post(&rwlock->lock); + return err; +} + +__API__ k_err_t tos_rwlock_wpend(k_rwlock_t *rwlock) +{ + return tos_rwlock_wpend_timed(rwlock, TOS_TIME_FOREVER); +} + +__API__ k_err_t tos_rwlock_wpend_try(k_rwlock_t *rwlock) +{ + k_err_t err; + + TOS_PTR_SANITY_CHECK(rwlock); + TOS_OBJ_VERIFY(rwlock, KNL_OBJ_TYPE_RWLOCK); + + err = tos_mutex_pend(&rwlock->lock); + if (err != K_ERR_NONE) { + return err; + } + + if (rwlock->n_readers > 0u) { + err = K_ERR_RWLOCK_IS_READING; + } else if (rwlock->is_writting) { + err = K_ERR_RWLOCK_IS_WRITTING; + } else { + rwlock->is_writting = K_TRUE; + } + + tos_mutex_post(&rwlock->lock); + return err; +} + +__API__ k_err_t tos_rwlock_rpost(k_rwlock_t *rwlock) +{ + k_err_t err; + + TOS_PTR_SANITY_CHECK(rwlock); + TOS_OBJ_VERIFY(rwlock, KNL_OBJ_TYPE_RWLOCK); + + err = tos_mutex_pend(&rwlock->lock); + if (err != K_ERR_NONE) { + return err; + } + + if (rwlock->n_readers == 0u) { + err = K_ERR_RWLOCK_NOT_READING; + } else { + --rwlock->n_readers; + if (rwlock->n_readers == 0u) { + err = tos_sem_post_all(&rwlock->signal); + } + } + + tos_mutex_post(&rwlock->lock); + return err; +} + +__API__ k_err_t tos_rwlock_wpost(k_rwlock_t *rwlock) +{ + k_err_t err; + + TOS_PTR_SANITY_CHECK(rwlock); + TOS_OBJ_VERIFY(rwlock, KNL_OBJ_TYPE_RWLOCK); + + err = tos_mutex_pend(&rwlock->lock); + if (err != K_ERR_NONE) { + return err; + } + + if (!rwlock->is_writting) { + err = K_ERR_RWLOCK_NOT_WRITTING; + } else { + rwlock->is_writting = K_FALSE; + err = tos_sem_post_all(&rwlock->signal); + } + + tos_mutex_post(&rwlock->lock); + return err; +} + +__API__ k_err_t tos_rwlock_post(k_rwlock_t *rwlock) +{ + k_err_t err; + + TOS_PTR_SANITY_CHECK(rwlock); + TOS_OBJ_VERIFY(rwlock, KNL_OBJ_TYPE_RWLOCK); + + err = tos_mutex_pend(&rwlock->lock); + if (err != K_ERR_NONE) { + return err; + } + + if (rwlock->n_readers > 0u) { + --rwlock->n_readers; + if (rwlock->n_readers == 0u) { + err = tos_sem_post_all(&rwlock->signal); + } + } else if (rwlock->is_writting) { + rwlock->is_writting = K_FALSE; + err = tos_sem_post_all(&rwlock->signal); + } else { + err = K_ERR_RWLOCK_NOT_TAKEN; + } + + tos_mutex_post(&rwlock->lock); + return err; +} + +#endif + diff --git a/kernel/core/tos_sem.c b/kernel/core/tos_sem.c index 19814be2..8a8297d9 100644 --- a/kernel/core/tos_sem.c +++ b/kernel/core/tos_sem.c @@ -101,6 +101,7 @@ __API__ k_err_t tos_sem_pend(k_sem_t *sem, k_tick_t timeout) { TOS_CPU_CPSR_ALLOC(); + TOS_IN_IRQ_CHECK(); TOS_PTR_SANITY_CHECK(sem); TOS_OBJ_VERIFY(sem, KNL_OBJ_TYPE_SEMAPHORE); @@ -117,11 +118,6 @@ __API__ k_err_t tos_sem_pend(k_sem_t *sem, k_tick_t timeout) return K_ERR_PEND_NOWAIT; } - if (knl_is_inirq()) { - TOS_CPU_INT_ENABLE(); - return K_ERR_PEND_IN_IRQ; - } - if (knl_is_sched_locked()) { TOS_CPU_INT_ENABLE(); return K_ERR_PEND_SCHED_LOCKED; diff --git a/kernel/core/tos_stopwatch.c b/kernel/core/tos_stopwatch.c new file mode 100644 index 00000000..24a09bc0 --- /dev/null +++ b/kernel/core/tos_stopwatch.c @@ -0,0 +1,123 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "tos_k.h" + +__API__ k_err_t tos_stopwatch_create(k_stopwatch_t *stopwatch) +{ + TOS_PTR_SANITY_CHECK(stopwatch); + + stopwatch->until = 0u; + TOS_OBJ_INIT(stopwatch, KNL_OBJ_TYPE_STOPWATCH); + + return K_ERR_NONE; +} + +__API__ k_err_t tos_stopwatch_destroy(k_stopwatch_t *stopwatch) +{ + TOS_PTR_SANITY_CHECK(stopwatch); + TOS_OBJ_VERIFY(stopwatch, KNL_OBJ_TYPE_STOPWATCH); + + stopwatch->until = 0u; + TOS_OBJ_DEINIT(stopwatch); + + return K_ERR_NONE; +} + +__API__ k_err_t tos_stopwatch_countdown(k_stopwatch_t *stopwatch, k_tick_t tick) +{ + k_tick_t now; + + TOS_PTR_SANITY_CHECK(stopwatch); + TOS_OBJ_VERIFY(stopwatch, KNL_OBJ_TYPE_STOPWATCH); + + now = tos_systick_get(); + stopwatch->until = now + tick; + + return K_ERR_NONE; +} + +__API__ k_err_t tos_stopwatch_countdown_ms(k_stopwatch_t *stopwatch, k_time_t millisec) +{ + k_tick_t tick; + + TOS_PTR_SANITY_CHECK(stopwatch); + TOS_OBJ_VERIFY(stopwatch, KNL_OBJ_TYPE_STOPWATCH); + + tick = tos_millisec2tick(millisec); + return tos_stopwatch_countdown(stopwatch, tick); +} + +__API__ void tos_stopwatch_delay(k_tick_t tick) +{ + k_tick_t now; + + now = tos_systick_get(); + while ((tos_systick_get() - now) < tick) { + ; + } +} + +__API__ void tos_stopwatch_delay_ms(k_time_t millisec) +{ + k_tick_t tick; + + tick = tos_millisec2tick(millisec); + tos_stopwatch_delay(tick); +} + +__API__ k_tick_t tos_stopwatch_remain(k_stopwatch_t *stopwatch) +{ + k_tick_t now; + + TOS_PTR_SANITY_CHECK_RC(stopwatch, (k_tick_t)-1); + TOS_OBJ_VERIFY_RC(stopwatch, KNL_OBJ_TYPE_STOPWATCH, (k_tick_t)-1); + + if (tos_stopwatch_is_expired(stopwatch)) { + return (k_tick_t)0u; + } + + now = tos_systick_get(); + return stopwatch->until - now; +} + +__API__ k_time_t tos_stopwatch_remain_ms(k_stopwatch_t *stopwatch) +{ + k_tick_t now; + + TOS_PTR_SANITY_CHECK_RC(stopwatch, (k_time_t)-1); + TOS_OBJ_VERIFY_RC(stopwatch, KNL_OBJ_TYPE_STOPWATCH, (k_time_t)-1); + + if (tos_stopwatch_is_expired(stopwatch)) { + return (k_tick_t)0u; + } + + now = tos_systick_get(); + return (k_time_t)(((stopwatch->until) - now + TOS_CFG_CPU_TICK_PER_SECOND - 1) / TOS_CFG_CPU_TICK_PER_SECOND); +} + +__API__ int tos_stopwatch_is_expired(k_stopwatch_t *stopwatch) +{ + k_tick_t now; + + TOS_PTR_SANITY_CHECK_RC(stopwatch, K_FALSE); + TOS_OBJ_VERIFY_RC(stopwatch, KNL_OBJ_TYPE_STOPWATCH, K_FALSE); + + now = tos_systick_get(); + return now >= stopwatch->until ? K_TRUE : K_FALSE; +} + diff --git a/kernel/core/tos_task.c b/kernel/core/tos_task.c index df54cd8f..510e176c 100644 --- a/kernel/core/tos_task.c +++ b/kernel/core/tos_task.c @@ -96,7 +96,12 @@ __API__ k_err_t tos_task_create(k_task_t *task, TOS_PTR_SANITY_CHECK(entry); TOS_PTR_SANITY_CHECK(stk_base); - if (unlikely(stk_size < sizeof(cpu_context_t))) { + if (task->knl_obj.type == KNL_OBJ_TYPE_TASK) { + /* try to re-create a task, kind of dangerous action */ + return K_ERR_TASK_ALREADY_CREATED; + } + + if (unlikely(stk_size < K_TASK_STK_SIZE_MIN)) { return K_ERR_TASK_STK_SIZE_INVALID; } @@ -119,10 +124,10 @@ __API__ k_err_t tos_task_create(k_task_t *task, task->sp = cpu_task_stk_init((void *)entry, arg, (void *)task_exit, stk_base, stk_size); task->entry = entry; task->arg = arg; - task->name = name; task->prio = prio; task->stk_base = stk_base; task->stk_size = stk_size; + strncpy(task->name, name, K_TASK_NAME_MAX); #if TOS_CFG_ROUND_ROBIN_EN > 0u task->timeslice_reload = timeslice; @@ -186,18 +191,6 @@ __STATIC__ k_err_t task_do_destroy(k_task_t *task) __STATIC__ k_err_t task_destroy_static(k_task_t *task) { - TOS_IN_IRQ_CHECK(); - - if (unlikely(!task)) { - task = k_curr_task; - } - - TOS_OBJ_VERIFY(task, KNL_OBJ_TYPE_TASK); - - if (knl_is_self(task) && knl_is_sched_locked()) { - return K_ERR_SCHED_LOCKED; - } - #if TOS_CFG_TASK_DYNAMIC_CREATE_EN > 0u if (!knl_object_alloc_is_static(&task->knl_obj)) { return K_ERR_OBJ_INVALID_ALLOC_TYPE; diff --git a/osal/posix/include/errno.h b/osal/posix/include/errno.h new file mode 100644 index 00000000..d7b27c15 --- /dev/null +++ b/osal/posix/include/errno.h @@ -0,0 +1,267 @@ +/*---------------------------------------------------------------------------- * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_ERRNO_H_ +#define _POSIX_ERRNO_H_ + +#define ENOERR 0 +#define ENOERR_STR "No error." + +#define E2BIG 1 +#define E2BIG_STR "Argument list too long." + +#define EACCES 2 +#define EACCES_STR "Permission denied." + +#define EADDRINUSE 3 +#define EADDRINUSE_STR "Address in use." + +#define EADDRNOTAVAIL 4 +#define EADDRNOTAVAIL_STR "Address not available." + +#define EAFNOSUPPORT 5 +#define EAFNOSUPPORT_STR "Address family not supported." + +#define EAGAIN 6 +#define EAGAIN_STR "Resource unavailable, try again (may be the same value as [EWOULDBLOCK])." + +#define EALREADY 7 +#define EALREADY_STR "Connection already in progress." + +#define EBADF 8 +#define EBADF_STR "Bad file descriptor." + +#define EBADMSG 9 +#define EBADMSG_STR "Bad message." + +#define EBUSY 10 +#define EBUSY_STR "Device or resource busy." + +#define ECANCELED 11 +#define ECANCELED_STR "Operation canceled." + +#define ECHILD 12 +#define ECHILD_STR "No child processes." + +#define ECONNABORTED 13 +#define ECONNABORTED_STR "Connection aborted." + +#define ECONNREFUSED 14 +#define ECONNREFUSED_STR "Connection refused." + +#define ECONNRESET 15 +#define ECONNRESET_STR "Connection reset." + +#define EDEADLK 16 +#define EDEADLK_STR "Resource deadlock would occur." + +#define EDESTADDRREQ 17 +#define EDESTADDRREQ_STR "Destination address required." + +#define EDOM 18 +#define EDOM_STR "Mathematics argument out of domain of function." + +#define EDQUOT 19 +#define EDQUOT_STR "Reserved." + +#define EEXIST 20 +#define EEXIST_STR "File exists." + +#define EFAULT 21 +#define EFAULT_STR "Bad address." + +#define EFBIG 22 +#define EFBIG_STR "File too large." + +#define EHOSTUNREACH 23 +#define EHOSTUNREACH_STR "Host is unreachable." + +#define EIDRM 24 +#define EIDRM_STR "Identifier removed." + +#define EILSEQ 25 +#define EILSEQ_STR "Illegal byte sequence." + +#define EINPROGRESS 26 +#define EINPROGRESS_STR "Operation in progress." + +#define EINTR 27 +#define EINTR_STR "Interrupted function." + +#define EINVAL 28 +#define EINVAL_STR "Invalid argument." + +#define EIO 29 +#define EIO_STR "I/O error." + +#define EISCONN 30 +#define EISCONN_STR "Socket is connected." + +#define EISDIR 31 +#define EISDIR_STR "Is a directory." + +#define ELOOP 32 +#define ELOOP_STR "Too many levels of symbolic links." + +#define EMFILE 33 +#define EMFILE_STR "File descriptor value too large." + +#define EMLINK 34 +#define EMLINK_STR "Too many links." + +#define EMSGSIZE 35 +#define EMSGSIZE_STR "Message too large." + +#define EMULTIHOP 36 +#define EMULTIHOP_STR "Reserved." + +#define ENAMETOOLONG 37 +#define ENAMETOOLONG_STR "Filename too long." + +#define ENETDOWN 38 +#define ENETDOWN_STR "Network is down." + +#define ENETRESET 39 +#define ENETRESET_STR "Connection aborted by network." + +#define ENETUNREACH 40 +#define ENETUNREACH_STR "Network unreachable." + +#define ENFILE 41 +#define ENFILE_STR "Too many files open in system." + +#define ENOBUFS 42 +#define ENOBUFS_STR "No buffer space available." + +#define ENODATA 43 +#define ENODATA_STR "No message is available on the STREAM head read queue. " + +#define ENODEV 44 +#define ENODEV_STR "No such device." + +#define ENOENT 45 +#define ENOENT_STR "No such file or directory." + +#define ENOEXEC 46 +#define ENOEXEC_STR "Executable file format error." + +#define ENOLCK 47 +#define ENOLCK_STR "No locks available." + +#define ENOLINK 48 +#define ENOLINK_STR "Reserved." + +#define ENOMEM 49 +#define ENOMEM_STR "Not enough space." + +#define ENOMSG 50 +#define ENOMSG_STR "No message of the desired type." + +#define ENOPROTOOPT 51 +#define ENOPROTOOPT_STR "Protocol not available." + +#define ENOSPC 52 +#define ENOSPC_STR "No space left on device." + +#define ENOSR 53 +#define ENOSR_STR "No STREAM resources." + +#define ENOSTR 54 +#define ENOSTR_STR "Not a STREAM." + +#define ENOSYS 55 +#define ENOSYS_STR "Functionality not supported." + +#define ENOTCONN 56 +#define ENOTCONN_STR "The socket is not connected." + +#define ENOTDIR 57 +#define ENOTDIR_STR "Not a directory or a symbolic link to a directory." + +#define ENOTEMPTY 58 +#define ENOTEMPTY_STR "Directory not empty." + +#define ENOTRECOVERABLE 59 +#define ENOTRECOVERABLE_STR "State not recoverable." + +#define ENOTSOCK 60 +#define ENOTSOCK_STR "Not a socket." + +#define ENOTSUP 61 +#define ENOTSUP_STR "Not supported (may be the same value as [EOPNOTSUPP]). " + +#define ENOTTY 62 +#define ENOTTY_STR "Inappropriate I/O control operation." + +#define ENXIO 63 +#define ENXIO_STR "No such device or address." + +#define EOPNOTSUPP 64 +#define EOPNOTSUPP_STR "Operation not supported on socket (may be the same value as [ENOTSUP])." + +#define EOVERFLOW 65 +#define EOVERFLOW_STR "Value too large to be stored in data type." + +#define EOWNERDEAD 66 +#define EOWNERDEAD_STR "Previous owner died." + +#define EPERM 67 +#define EPERM_STR "Operation not permitted." + +#define EPIPE 68 +#define EPIPE_STR "Broken pipe." + +#define EPROTO 69 +#define EPROTO_STR "Protocol error." + +#define EPROTONOSUPPORT 70 +#define EPROTONOSUPPORT_STR "Protocol not supported." + +#define EPROTOTYPE 71 +#define EPROTOTYPE_STR "Protocol wrong type for socket." + +#define ERANGE 72 +#define ERANGE_STR "Result too large." + +#define EROFS 73 +#define EROFS_STR "Read-only file system." + +#define ESPIPE 74 +#define ESPIPE_STR "Invalid seek." + +#define ESRCH 75 +#define ESRCH_STR "No such process." + +#define ESTALE 76 +#define ESTALE_STR "Reserved." + +#define ETIME 77 +#define ETIME_STR "Stream ioctl() timeout." + +#define ETIMEDOUT 78 +#define ETIMEDOUT_STR "Connection timed out." + +#define ETXTBSY 79 +#define ETXTBSY_STR "Text file busy." + +#define EWOULDBLOCK 80 +#define EWOULDBLOCK_STR "Operation would block (may be the same value as [EAGAIN])." + +#define EXDEV 81 +#define EXDEV_STR "Cross-device link." + +#endif /* _POSIX_ERRNO_H_ */ + diff --git a/osal/posix/include/mqueue.h b/osal/posix/include/mqueue.h new file mode 100644 index 00000000..148ff05d --- /dev/null +++ b/osal/posix/include/mqueue.h @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_MQUEUE_H_ +#define _POSIX_MQUEUE_H_ + +#include "tos_k.h" + +#include "signal.h" +#include "time.h" + +__CDECLS_BEGIN + +typedef int mqd_t; + +struct mq_attr { + long mq_flags; /* message queue flags */ + long mq_maxmsg; /* maximum number of messages */ + long mq_msgsize; /* maximum message size */ + long mq_curmsgs; /* number of messages currently queued */ +}; + +#define __NOTSUPP__ + +__API__ int mq_close(mqd_t mqdes); +__NOTSUPP__ int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat); +__NOTSUPP__ int mq_notify(mqd_t mqdes, const struct sigevent *notification); +__API__ mqd_t mq_open(const char *name, int oflag, ...); +__API__ ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio); +__API__ int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio); +__NOTSUPP__ int mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat, struct mq_attr *omqstat); +__API__ ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio, const struct timespec *abstime); +__NOTSUPP__ int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec *abstime); +__NOTSUPP__ int mq_unlink(const char *name); + +__CDECLS_END + +#endif /* _POSIX_MQUEUE_H_ */ + diff --git a/osal/posix/include/private/mqueue.h b/osal/posix/include/private/mqueue.h new file mode 100644 index 00000000..1be1cc48 --- /dev/null +++ b/osal/posix/include/private/mqueue.h @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_PRIVATE_MQUEUE_H_ +#define _POSIX_PRIVATE_MQUEUE_H_ + +#include "tos_k.h" + +#include "private/posix_config.h" + +__CDECLS_BEGIN + +#define MQUEUE_MAX (POSIX_CFG_MQUEUE_MAX) + +#define MQUEUE_MSG_MAX 20 +#define MQUEUE_MSG_SIZE_MAX 50 + +typedef struct mqueue_control_st { + mqd_t id; + k_prio_mail_q_t kprio_mail_q; +} mqueue_ctl_t; + +__KNL__ int mqueue_id_add(mqd_t id, mqueue_ctl_t *mqueue_ctl); + +__KNL__ mqd_t mqueue_id_alloc(void); + +__KNL__ int mqueue_id_free(mqd_t id); + +__KNL__ mqueue_ctl_t *mqueue_by_id(mqd_t id); + +__CDECLS_END + +#endif /* _POSIX_PRIVATE_TIMER_H_*/ diff --git a/osal/posix/include/private/posix_config.h b/osal/posix/include/private/posix_config.h new file mode 100644 index 00000000..ae216853 --- /dev/null +++ b/osal/posix/include/private/posix_config.h @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_CONFIG_H_ +#define _POSIX_CONFIG_H_ + +#define POSIX_CFG_PTHREAD_THREADS_MAX 32 +#define POSIX_CFG_PTHREAD_DESTRUCTOR_ITERATIONS 4 +#define POSIX_CFG_PTHREAD_KEYS_MAX 8 + +#define POSIX_CFG_TIMERS_MAX 8 + +#define POSIX_CFG_MQUEUE_MAX 8 + +#define POSIX_CFG_PTHREAD_BARRIER_EN 1u + +#define POSIX_CFG_PTHREAD_COND_EN 1u + +#define POSIX_CFG_PTHREAD_MUTEX_EN 1u + +#define POSIX_CFG_PTHREAD_RWLOCK_EN 1u + +#define POSIX_CFG_PTHREAD_SPIN_EN 1u + +#define POSIX_CFG_SEM_EN 1u + +#define POSIX_CFG_MQUEUE_EN 1u + +#define POSIX_CFG_TIMER_EN 1u + +#include "private/posix_config_check.h" + +#endif /* _POSIX_CONFIG_H_ */ + diff --git a/osal/posix/include/private/posix_config_check.h b/osal/posix/include/private/posix_config_check.h new file mode 100644 index 00000000..c80387a3 --- /dev/null +++ b/osal/posix/include/private/posix_config_check.h @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_CONFIG_CHECK_H_ +#define _POSIX_CONFIG_CHECK_H_ + +#include "tos_config.h" +#include "private/posix_config_default.h" + +#if (TOS_CFG_MMHEAP_EN == 0u) +#error "INVALID config, Must enable TOS_CFG_MMHEAP_EN to use posix stuff" +#endif + +#if (POSIX_CFG_PTHREAD_COND_EN > 0u) && (TOS_CFG_SEM_EN == 0u) +#error "INVALID config, Must enable TOS_CFG_SEM_EN to use pthread_cond" +#endif + +#if (POSIX_CFG_PTHREAD_COND_EN > 0u) && (TOS_CFG_MUTEX_EN == 0u) +#error "INVALID config, Must enable TOS_CFG_MUTEX_EN to use pthread_cond" +#endif + +#if (POSIX_CFG_PTHREAD_MUTEX_EN > 0u) && (TOS_CFG_MUTEX_EN == 0u) +#error "INVALID config, Must enable TOS_CFG_MUTEX_EN to use pthread_mutex" +#endif + +#if (POSIX_CFG_PTHREAD_RWLOCK_EN > 0u) && (TOS_CFG_SEM_EN == 0u) +#error "INVALID config, Must enable TOS_CFG_SEM_EN to use pthread_rwlock" +#endif + +#if (POSIX_CFG_PTHREAD_RWLOCK_EN > 0u) && (TOS_CFG_MUTEX_EN == 0u) +#error "INVALID config, Must enable TOS_CFG_MUTEX_EN to use pthread_rwlock" +#endif + +#if (POSIX_CFG_SEM_EN > 0u) && (TOS_CFG_SEM_EN == 0u) +#error "INVALID config, Must enable TOS_CFG_SEM_EN to use posix sem" +#endif + +#if (POSIX_CFG_MQUEUE_EN > 0u) && (TOS_CFG_PRIORITY_MAIL_QUEUE_EN == 0u) +#error "INVALID config, Must enable TOS_CFG_PRIORITY_MAIL_QUEUE_EN to use posix mqueue" +#endif + +#if (POSIX_CFG_TIMER_EN > 0u) && (TOS_CFG_TIMER_EN == 0u) +#error "INVALID config, Must enable TOS_CFG_TIMER_EN to use posix timer" +#endif + +#endif /* _POSIX_CONFIG_CHECK_H_ */ + diff --git a/osal/posix/include/private/posix_config_default.h b/osal/posix/include/private/posix_config_default.h new file mode 100644 index 00000000..4ad87aa2 --- /dev/null +++ b/osal/posix/include/private/posix_config_default.h @@ -0,0 +1,74 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_CONFIG_DEFAULT_H_ +#define _POSIX_CONFIG_DEFAULT_H_ + +#ifndef POSIX_CFG_PTHREAD_THREADS_MAX +#define POSIX_CFG_PTHREAD_THREADS_MAX 32 +#endif + +#ifndef POSIX_CFG_PTHREAD_DESTRUCTOR_ITERATIONS +#define POSIX_CFG_PTHREAD_DESTRUCTOR_ITERATIONS 4 +#endif + +#ifndef POSIX_CFG_PTHREAD_KEYS_MAX +#define POSIX_CFG_PTHREAD_KEYS_MAX 8 +#endif + +#ifndef POSIX_CFG_TIMERS_MAX +#define POSIX_CFG_TIMERS_MAX 8 +#endif + +#ifndef POSIX_CFG_MQUEUE_MAX +#define POSIX_CFG_MQUEUE_MAX 8 +#endif + +#ifndef POSIX_CFG_PTHREAD_BARRIER_EN +#define POSIX_CFG_PTHREAD_BARRIER_EN 1u +#endif + +#ifndef POSIX_CFG_PTHREAD_COND_EN +#define POSIX_CFG_PTHREAD_COND_EN 1u +#endif + +#ifndef POSIX_CFG_PTHREAD_MUTEX_EN +#define POSIX_CFG_PTHREAD_MUTEX_EN 1u +#endif + +#ifndef POSIX_CFG_PTHREAD_RWLOCK_EN +#define POSIX_CFG_PTHREAD_RWLOCK_EN 1u +#endif + +#ifndef POSIX_CFG_PTHREAD_SPIN_EN +#define POSIX_CFG_PTHREAD_SPIN_EN 1u +#endif + +#ifndef POSIX_CFG_SEM_EN +#define POSIX_CFG_SEM_EN 1u +#endif + +#ifndef POSIX_CFG_MQUEUE_EN +#define POSIX_CFG_MQUEUE_EN 1u +#endif + +#ifndef POSIX_CFG_TIMER_EN +#define POSIX_CFG_TIMER_EN 1u +#endif + +#endif /* _POSIX_CONFIG_DEFAULT_H_ */ + diff --git a/osal/posix/include/private/pthread.h b/osal/posix/include/private/pthread.h new file mode 100644 index 00000000..b0c8c9fd --- /dev/null +++ b/osal/posix/include/private/pthread.h @@ -0,0 +1,119 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_PRIVATE_PTHREAD_H_ +#define _POSIX_PRIVATE_PTHREAD_H_ + +#include "tos_k.h" + +#include "private/posix_config.h" + +#include "sys/types.h" + +__CDECLS_BEGIN + +typedef struct pthread_control_st { + uint16_t threadstate : 4; + uint16_t cancelstate : 2; + uint16_t canceltype : 2; + uint16_t cancelpending : 1; + + pthread_t id; + pthread_attr_t attr; + k_task_t ktask; + k_task_t *the_ktask; + + k_sem_t joinner_sem; + + void *(*start_routine)(void *); /* start routine of the pthread */ + void *arg; /* argument to start routine */ + void *retval; /* return value of start routine */ + void *stackaddr; /* memory of address */ + + k_slist_t cleanup_ctl_list; + + void **thread_data; +} pthread_ctl_t; + +typedef struct pthread_cleanup_control_st { + void (*routine)(void *); /* function to be called */ + void *arg; /* argument for the routine */ + k_slist_t list; +} pthread_cleanup_ctl_t; + +#define PTHREAD_KEYS_MAX (POSIX_CFG_PTHREAD_KEYS_MAX) + +typedef void (*key_destructor_t)(void*); + +typedef struct pthread_key_control_st { + k_bmtbl_t key_bitmap_tbl[TOS_BITMAP_SIZE(PTHREAD_KEYS_MAX)]; + k_bitmap_t key_bitmap; + key_destructor_t destructors[PTHREAD_KEYS_MAX]; +} pthread_key_ctl_t; + +#define PTHREAD_INFO_SIZE (sizeof(pthread_ctl_t)) +#define PTHREAD_STK_SIZE_MIN (K_TASK_STK_SIZE_MIN + PTHREAD_INFO_SIZE) + +#define PTHREAD_DEFAULT_TIMESLICE 20 +#define PTHREAD_DEFAULT_STACKSIZE (2048 + PTHREAD_INFO_SIZE) +#define PTHREAD_DEFAULT_INHERIT_SCHED PTHREAD_INHERIT_SCHED +#define PTHREAD_DEFAULT_SCHEDPOLICY SCHED_OTHER +#define PTHREAD_DEFAULT_PRIORITY (TOS_CFG_TASK_PRIO_MAX / 2) +#define PTHREAD_DEFAULT_DETACH_STATE PTHREAD_CREATE_JOINABLE + +#define PTHREAD_DESTRUCTOR_ITERATIONS (POSIX_CFG_PTHREAD_DESTRUCTOR_ITERATIONS) + +#define PTHREAD_THREADS_MAX (POSIX_CFG_PTHREAD_THREADS_MAX) + +__KNL__ pthread_ctl_t *pthread_ctl_self(void); + +__KNL__ pthread_ctl_t *pthread_ctl_by_id(pthread_t id); + +__KNL__ int pthread_id_add(pthread_t id, pthread_ctl_t *info); + +__KNL__ pthread_t pthread_id_alloc(void); + +__KNL__ int pthread_id_free(pthread_t id); + +__KNL__ void pthread_data_clear(pthread_key_t key); + +__KNL__ int pthread_key_ctl_init(void); + +__KNL__ pthread_key_t pthread_key_alloc(void); + +__KNL__ int pthread_key_is_alloc(pthread_key_t key); + +__KNL__ int pthread_key_free(pthread_key_t key); + +__KNL__ int pthread_key_destructor_register(pthread_key_t key, key_destructor_t destructor); + +__KNL__ key_destructor_t pthread_key_destructor_get(pthread_key_t key); + +__KNL__ int pthread_ctl_reap(int pthreads_ready2reap); + +__KNL__ void pthread_lock(void); + +__KNL__ void pthread_unlock(void); + +__KNL__ int pthread_lock_init(void); + +__KNL__ int pthread_init(void); + +__CDECLS_END + +#endif /* _POSIX_PRIVATE_PTHREAD_PRV_H_ */ + diff --git a/osal/posix/include/private/time.h b/osal/posix/include/private/time.h new file mode 100644 index 00000000..99b5dc19 --- /dev/null +++ b/osal/posix/include/private/time.h @@ -0,0 +1,36 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_PRIVATE_TIME_H_ +#define _POSIX_PRIVATE_TIME_H_ + +#include "tos_k.h" + +__CDECLS_BEGIN + +#define MILLISECOND_PER_SECOND 1000UL +#define MICROSECOND_PER_SECOND 1000000UL +#define NANOSECOND_PER_SECOND 1000000000UL + +__KNL__ k_tick_t timespec_to_ktick(const struct timespec *tp); + +__KNL__ void ktick_to_timespec(k_tick_t ktick, struct timespec *tp); + +__CDECLS_END + +#endif /* _POSIX_PRIVATE_TIME_H_ */ + diff --git a/osal/posix/include/private/timer.h b/osal/posix/include/private/timer.h new file mode 100644 index 00000000..e513332a --- /dev/null +++ b/osal/posix/include/private/timer.h @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_PRIVATE_TIMER_H_ +#define _POSIX_PRIVATE_TIMER_H_ + +#include "tos_k.h" + +#include "private/posix_config.h" + +#include "signal.h" + +__CDECLS_BEGIN + +#define TIMERS_MAX (POSIX_CFG_TIMERS_MAX) + +typedef struct ptimer_control_st { + timer_t id; + k_timer_t ktimer; + + void (*sigev_notify_function)(union sigval); + union sigval sigev_value; +} ptimer_ctl_t; + +__KNL__ int timer_id_add(timer_t id, ptimer_ctl_t *ptimer_ctl); + +__KNL__ timer_t timer_id_alloc(void); + +__KNL__ int timer_id_free(timer_t id); + +__KNL__ ptimer_ctl_t *timer_by_id(timer_t id); + +__CDECLS_END + +#endif /* _POSIX_PRIVATE_TIMER_H_*/ + diff --git a/osal/posix/include/pthread.h b/osal/posix/include/pthread.h new file mode 100644 index 00000000..3d9370f5 --- /dev/null +++ b/osal/posix/include/pthread.h @@ -0,0 +1,189 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_PTHREAD_H_ +#define _POSIX_PTHREAD_H_ + +#include "tos_k.h" + +#include "stddef.h" +#include "limits.h" +#include "sys/types.h" +#include "sched.h" +#include "time.h" + +__CDECLS_BEGIN + +extern int __pthread_canceled; + +#define PTHREAD_CANCELD ((void *)(&__pthread_canceled)) + +/* type of mutex */ +#define PTHREAD_MUTEX_NORMAL 0 +#define PTHREAD_MUTEX_ERRORCHECK 1 +#define PTHREAD_MUTEX_RECURSIVE 2 +#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL + +/* state of the thread */ +#define PTHREAD_STATE_DETACHED 1 /* The thread is running but detached */ +#define PTHREAD_STATE_RUNNING 2 /* The thread is running and will wait to join when it exits */ +#define PTHREAD_STATE_JOIN 3 /* The thread has exited and is waiting to be joined */ +#define PTHREAD_STATE_EXITED 4 /* The thread has exited and is ready to be reaped */ + +/* cancelability state */ +#define PTHREAD_CANCEL_ENABLE 1 +#define PTHREAD_CANCEL_DISABLE 2 + +/* cancelability type */ +#define PTHREAD_CANCEL_ASYNCHRONOUS 1 +#define PTHREAD_CANCEL_DEFERRED 2 + +/* values for detachstate*/ +#define PTHREAD_CREATE_JOINABLE 1 +#define PTHREAD_CREATE_DETACHED 2 + +/* values for inheritsched */ +#define PTHREAD_INHERIT_SCHED 1 +#define PTHREAD_EXPLICIT_SCHED 2 + +#define PTHREAD_ONCE_INIT 0 + +#define PTHREAD_COND_INITIALIZER + +#define PTHREAD_MUTEX_INITIALIZER + +#define PTHREAD_RWLOCK_INITIALIZER + +#define __NOTSUPP__ + +__NOTSUPP__ int pthread_atfork(void (*prepare)(void), void (*parent)(void), void(*child)(void)); +__API__ int pthread_attr_destroy(pthread_attr_t *attr); +__API__ int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate); +__NOTSUPP__ int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize); +__API__ int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inheritsched); +__API__ int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param); +__API__ int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy); +__NOTSUPP__ int pthread_attr_getscope(const pthread_attr_t *attr, int *contentionscope); +__API__ int pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, size_t *stacksize); +__API__ int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize); +__API__ int pthread_attr_init(pthread_attr_t *attr); +__API__ int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); +__NOTSUPP__ int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize); +__API__ int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched); +__API__ int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param); +__API__ int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy); +__NOTSUPP__ int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope); +__API__ int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize); +__API__ int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize); + +__API__ int pthread_barrier_destroy(pthread_barrier_t *barrier); +__API__ int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned count); +__API__ int pthread_barrier_wait(pthread_barrier_t *barrier); +__NOTSUPP__ int pthread_barrierattr_destroy(pthread_barrierattr_t *attr); +__NOTSUPP__ int pthread_barrierattr_getpshared(const pthread_barrierattr_t *attr, int *pshared); +__NOTSUPP__ int pthread_barrierattr_init(pthread_barrierattr_t *attr); +__NOTSUPP__ int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int pshared); + +__API__ int pthread_cancel(pthread_t thread); + +__API__ int pthread_cond_broadcast(pthread_cond_t *cond); +__API__ int pthread_cond_destroy(pthread_cond_t *cond); +__API__ int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr); +__API__ int pthread_cond_signal(pthread_cond_t *cond); +__API__ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime); +__API__ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); +__NOTSUPP__ int pthread_condattr_destroy(pthread_condattr_t *attr); +__NOTSUPP__ int pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clock_id); +__NOTSUPP__ int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared); +__NOTSUPP__ int pthread_condattr_init(pthread_condattr_t *attr); +__NOTSUPP__ int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id); +__NOTSUPP__ int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared); + +__API__ int pthread_create(pthread_t *pthread, const pthread_attr_t *attr, void *(*entry)(void*), void *arg); +__API__ int pthread_detach(pthread_t thread); +__API__ int pthread_equal(pthread_t t1, pthread_t t2); +__API__ void pthread_exit(void *value_ptr); + +__NOTSUPP__ int pthread_getconcurrency(void); +__NOTSUPP__ int pthread_getcpuclockid(pthread_t thread_id, clockid_t *clock_id); +__API__ int pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param); +__API__ void *pthread_getspecific(pthread_key_t key); +__API__ int pthread_join(pthread_t thread, void **value_ptr); + +__API__ int pthread_key_create(pthread_key_t *, void (*)(void*)); +__API__ int pthread_key_delete(pthread_key_t); + +__NOTSUPP__ int pthread_mutex_consistent(pthread_mutex_t *mutex); +__API__ int pthread_mutex_destroy(pthread_mutex_t *mutex); +__NOTSUPP__ int pthread_mutex_getprioceiling(const pthread_mutex_t *mutex, int *prioceiling); +__API__ int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr); +__API__ int pthread_mutex_lock(pthread_mutex_t *mutex); +__NOTSUPP__ int pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int prioceiling, int *old_ceiling); +__API__ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *abstime); +__API__ int pthread_mutex_trylock(pthread_mutex_t *mutex); +__API__ int pthread_mutex_unlock(pthread_mutex_t *mutex); +__API__ int pthread_mutexattr_destroy(pthread_mutexattr_t *); +__NOTSUPP__ int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *mutex, int *prioceiling); +__NOTSUPP__ int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *mutex, int *protocol); +__NOTSUPP__ int pthread_mutexattr_getpshared(const pthread_mutexattr_t *mutex, int *pshared); +__NOTSUPP__ int pthread_mutexattr_getrobust(const pthread_mutexattr_t *mutex, int *robust); +__API__ int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type); +__API__ int pthread_mutexattr_init(pthread_mutexattr_t *attr); +__NOTSUPP__ int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *mutex, int prioceiling); +__NOTSUPP__ int pthread_mutexattr_setprotocol(pthread_mutexattr_t *mutex, int protocol); +__NOTSUPP__ int pthread_mutexattr_setpshared(pthread_mutexattr_t *mutex, int pshared); +__NOTSUPP__ int pthread_mutexattr_setrobust(pthread_mutexattr_t *mutex, int robust); +__API__ int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type); + +__API__ int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)); + +__API__ int pthread_rwlock_destroy(pthread_rwlock_t *rwlock); +__API__ int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr); +__API__ int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock); +__API__ int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *abstime); +__API__ int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abstime); +__API__ int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock); +__API__ int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock); +__API__ int pthread_rwlock_unlock(pthread_rwlock_t *rwlock); +__API__ int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock); +__NOTSUPP__ int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr); +__NOTSUPP__ int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr, int *pshared); +__NOTSUPP__ int pthread_rwlockattr_init(pthread_rwlockattr_t *attr); +__NOTSUPP__ int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared); + +__API__ pthread_t pthread_self(void); +__API__ int pthread_setcancelstate(int state, int *oldstate); +__API__ int pthread_setcanceltype(int type, int *oldtype); +__NOTSUPP__ int pthread_setconcurrency(int new_level); +__API__ int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param); +__API__ int pthread_setschedprio(pthread_t, int); +__API__ int pthread_setspecific(pthread_key_t key, const void *value); + +__API__ int pthread_spin_destroy(pthread_spinlock_t *lock); +__API__ int pthread_spin_init(pthread_spinlock_t *lock, int pshared); +__API__ int pthread_spin_lock(pthread_spinlock_t *lock); +__API__ int pthread_spin_trylock(pthread_spinlock_t *lock); +__API__ int pthread_spin_unlock(pthread_spinlock_t *lock); + +__API__ void pthread_testcancel(void); +__API__ void pthread_cleanup_pop(int execute); +__API__ void pthread_cleanup_push(void (*routine)(void*), void *arg); + +__CDECLS_END + +#endif /* _POSIX_PTHREAD_H_ */ + diff --git a/osal/posix/include/sched.h b/osal/posix/include/sched.h new file mode 100644 index 00000000..4e5afb90 --- /dev/null +++ b/osal/posix/include/sched.h @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_SCHED_H_ +#define _POSIX_SCHED_H_ + +#include "tos_k.h" + +#include "sys/types.h" +#include "time.h" + +__CDECLS_BEGIN + +/* Scheduling Psolicies, values for schedpolicy */ +#define SCHED_FIFO 0 /* First in-first out (FIFO) scheduling policy. */ +#define SCHED_RR 1 /* Round robin scheduling policy. */ +#define SCHED_OTHER 2 /* Another scheduling policy. */ + +#define __NOTSUPP__ + +__API__ int sched_get_priority_max(int policy); +__API__ int sched_get_priority_min(int policy); +__API__ int sched_getparam(pid_t pid, struct sched_param *param); +__NOTSUPP__ int sched_getscheduler(pid_t pid); +__API__ int sched_rr_get_interval(pid_t pid, struct timespec *interval); +__API__ int sched_setparam(pid_t pid, const struct sched_param *param); +__NOTSUPP__ int sched_setscheduler(pid_t pid, int policy, const struct sched_param *param); +__API__ int sched_yield(void); + +__CDECLS_END + +#endif /* _POSIX_SCHED_H_ */ + diff --git a/osal/posix/include/semaphore.h b/osal/posix/include/semaphore.h new file mode 100644 index 00000000..08f22048 --- /dev/null +++ b/osal/posix/include/semaphore.h @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_SEMAPHORE_H_ +#define _POSIX_SEMAPHORE_H_ + +#include "tos_k.h" + +#include "time.h" + +__CDECLS_BEGIN + +typedef k_sem_t sem_t; + +#define __NOTSUPP__ + +__NOTSUPP__ int sem_close(sem_t *sem); +__API__ int sem_destroy(sem_t *sem); +__API__ int sem_getvalue(sem_t *sem, int *sval); +__API__ int sem_init(sem_t *sem, int pshared, unsigned value); +__NOTSUPP__ sem_t *sem_open(const char *name, int oflag, ...); +__API__ int sem_post(sem_t *sem); +__API__ int sem_timedwait(sem_t *sem, const struct timespec *abstime); +__API__ int sem_trywait(sem_t *sem); +__NOTSUPP__ int sem_unlink(const char *name); +__API__ int sem_wait(sem_t *sem); + +__CDECLS_END + +#endif /* _POSIX_SEMAPHORE_H_ */ + diff --git a/osal/posix/include/signal.h b/osal/posix/include/signal.h new file mode 100644 index 00000000..90518979 --- /dev/null +++ b/osal/posix/include/signal.h @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_SIGNAL_H_ +#define _POSIX_SIGNAL_H_ + +#include "sys/types.h" + +union sigval { + int sival_int; /* integer signal value */ + void *sival_ptr; /* pointer signal value */ +}; + +struct sigevent { + int sigev_notify; /* notification type */ + int sigev_signo; /* signal number */ + union sigval sigev_value; /* signal value */ + void (*sigev_notify_function)(union sigval); /* notification function */ + pthread_attr_t *sigev_notify_attributes; /* notification attributes */ +}; + +#endif /* _POSIX_SIGNAL_H_ */ + diff --git a/osal/posix/include/sys/time.h b/osal/posix/include/sys/time.h new file mode 100644 index 00000000..13b16449 --- /dev/null +++ b/osal/posix/include/sys/time.h @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_SYS_TIME_H_ +#define _POSIX_SYS_TIME_H_ + +#include "sys/types.h" +#include "time.h" + +__CDECLS_BEGIN + +struct timeval { + long tv_sec; + long tv_usec; +}; + +struct itimerval { + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; + +#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ + (ts)->tv_sec = (tv)->tv_sec; \ + (ts)->tv_nsec = (tv)->tv_usec * 1000; \ +} + +#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (ts)->tv_nsec / 1000; \ +} + +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +__API__ int getitimer(int which, struct itimerval *value); +__API__ int gettimeofday(struct timeval *tp, void *tzp); +__API__ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue); +#if 0 +int select(int, fd_set *restrict, fd_set *restrict, fd_set *restrict, struct timeval *restrict); +#endif +__API__ int utimes(const char *path, const struct timeval [2]); + +__CDECLS_END + +#endif /* _POSIX_SYS_TIME_H_ */ + diff --git a/osal/posix/include/sys/types.h b/osal/posix/include/sys/types.h new file mode 100644 index 00000000..3de0ce15 --- /dev/null +++ b/osal/posix/include/sys/types.h @@ -0,0 +1,131 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_SYS_TYPES_H_ +#define _POSIX_SYS_TYPES_H_ + +#include "stddef.h" +#include "stdint.h" + +typedef uint32_t blkcnt_t; /* Used for file block counts. */ +typedef size_t blksize_t; /* Used for block sizes. */ + +typedef uint64_t clock_t; /* Used for system times in clock ticks or CLOCKS_PER_SEC; see . */ +typedef uint32_t clockid_t; /* Used for clock ID type in the clock and timer functions. */ + +typedef uint32_t dev_t; /* Used for device IDs. */ +typedef uint32_t fsblkcnt_t; /* Used for file system block counts. */ +typedef uint32_t fsfilcnt_t; /* Used for file system file counts. */ +typedef uint32_t gid_t; /* Used for group IDs. */ +typedef uint32_t id_t; /* Used as a general identifier; can be used to contain at least a pid_t, uid_t, or gid_t. */ +typedef uint32_t ino_t; /* Used for file serial numbers. */ +typedef uint32_t key_t; /* Used for XSI interprocess communication. */ +typedef uint32_t mode_t; /* Used for some file attributes. */ +typedef uint32_t nlink_t; /* Used for link counts. */ +typedef uint32_t off_t; /* Used for file sizes. */ +typedef int pid_t; /* Used for process IDs and process group IDs. */ +typedef uint32_t uid_t; /* Used for user IDs. */ + +#if 0 /* we donnot typedef a size_t or ssize_t here, use what is supplied by stddef.h */ +size_t /* Used for sizes of objects. */ +ssize_t /* Used for a count of bytes or an error indication. */ +#endif + +typedef int ssize_t; + +typedef uint32_t suseconds_t; /* Used for time in microseconds. */ + +typedef uint32_t time_t; /* Used for time in seconds. */ + +struct sched_param { + int sched_priority; /* Process or thread execution scheduling priority. */ +}; + +/* Used to identify a thread attribute object. */ +typedef struct pthread_attr_st { + uint32_t detachstate : 2; + uint32_t inheritsched : 2; /* inherit parent priority/policy? */ + uint32_t schedpolicy : 2; /* pthread scheduler policy */ + uint32_t stackaddr_valid : 1; + uint32_t stacksize_valid : 1; + struct sched_param schedparam; + void *stackaddr; /* address of memory to be used as stack */ + size_t stacksize; /* size of the stack allocated for the pthread */ +} pthread_attr_t; + +/* Used to identify a barrier. */ +typedef k_barrier_t pthread_barrier_t; + +/* Used to define a barrier attributes object. */ +typedef uint32_t pthread_barrierattr_t; + +/* Used for condition variables. */ +typedef k_sem_t pthread_cond_t; + +/* Used to identify a condition attribute object. */ +typedef int pthread_condattr_t; + +/* Used for thread-specific data keys. */ +typedef int pthread_key_t; + +/* Used to identify a mutex attribute object. */ +typedef struct pthread_mutexattr_st { + uint8_t type : 4; + uint8_t reserved : 4; +} pthread_mutexattr_t; + +/* Used for mutexes. */ +typedef struct pthread_mutex_st { + k_mutex_t kmutex; + pthread_mutexattr_t attr; +} pthread_mutex_t; + +/* Used for dynamic package initialization. */ +typedef int pthread_once_t; + +/* Used for read-write locks. */ +typedef k_rwlock_t pthread_rwlock_t; + +/* Used for read-write lock attributes. */ +typedef int pthread_rwlockattr_t; + +/* Used to identify a spin lock. */ +typedef struct pthread_spinlock_st { + uint8_t is_destroyed : 1; + uint8_t is_locked : 1; +} pthread_spinlock_t; + +/* Used to identify a thread. */ +typedef pid_t pthread_t; + +/* Used for timer ID returned by timer_create(). */ +typedef int timer_t; + +/* Used to identify a trace stream attributes object */ +typedef int trace_attr_t; + +/* Used to identify a trace event type. */ +typedef int trace_event_id_t; + +/* Used to identify a trace event type set. */ +typedef int trace_event_set_t; + +/* Used to identify a trace stream. */ +typedef int trace_id_t; + +#endif /* _POSIX_SYS_TYPES_H_ */ + diff --git a/osal/posix/include/time.h b/osal/posix/include/time.h new file mode 100644 index 00000000..eca9d3e2 --- /dev/null +++ b/osal/posix/include/time.h @@ -0,0 +1,87 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _POSIX_TIME_H_ +#define _POSIX_TIME_H_ + +#include "tos_k.h" + +#include "sys/types.h" +#include "signal.h" + +__CDECLS_BEGIN + +struct tm { + int tm_sec; /* Seconds [0,60] */ + int tm_min; /* Minutes [0,59] */ + int tm_hour; /* Hour [0,23] */ + int tm_mday; /* Day of month [1,31] */ + int tm_mon; /* Month of year [0,11] */ + int tm_year; /* Years since 1900 */ + int tm_wday; /* Day of week [0,6] (Sunday =0) */ + int tm_yday; /* Day of year [0,365] */ +}; + +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + +struct itimerspec { + struct timespec it_interval; /* timer period */ + struct timespec it_value; /* timer expiration */ +}; + +#define CLOCK_REALTIME 0 + +#define __NOTSUPP__ + +__API__ char *asctime(const struct tm *timeptr); +__API__ char *asctime_r(const struct tm *asctime_r, char *buf); +__API__ clock_t clock(void); +__API__ int clock_getcpuclockid(pid_t pid, clockid_t *clock_id); +__API__ int clock_getres(clockid_t clock_id, struct timespec *res); +__API__ int clock_gettime(clockid_t clock_id, struct timespec *tp); +__API__ int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp); +__API__ int clock_settime(clockid_t clock_id, const struct timespec *tp); +__API__ char *ctime(const time_t *clock); +__API__ char *ctime_r(const time_t *clock, char *buf); +__API__ double difftime(time_t time1, time_t time0); +__API__ struct tm *getdate(const char *string); +__API__ struct tm *gmtime(const time_t *timer); +__API__ struct tm *gmtime_r(const time_t *timer, struct tm *result); +__API__ struct tm *localtime(const time_t *timer); +__API__ struct tm *localtime_r(const time_t *timer, struct tm *result); +__API__ time_t mktime(struct tm *timeptr); +__API__ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); +__API__ size_t strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr); +#if 0 +__API__ size_t strftime_l(char *s, size_t maxsize, const char *format, const struct tm *timeptr, locale_t locale); +#endif +__API__ char *strptime(const char *buf, const char *format, struct tm *tm); +__API__ time_t time(time_t *tloc); +__API__ int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid); +__API__ int timer_delete(timer_t timerid); +__NOTSUPP__ int timer_getoverrun(timer_t timerid); +__API__ int timer_gettime(timer_t timerid, struct itimerspec *value); +__API__ int timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue); +__API__ void tzset(void); + +__CDECLS_END + +#endif /* _POSIX_TIME_H_ */ + diff --git a/osal/posix/include/tos_posix.h b/osal/posix/include/tos_posix.h new file mode 100644 index 00000000..2dd8058a --- /dev/null +++ b/osal/posix/include/tos_posix.h @@ -0,0 +1,30 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#ifndef _TOS_POSIX_H_ +#define _TOS_POSIX_H_ + +#include "tos_k.h" + +__CDECLS_BEGIN + +__API__ int tos_posix_init(void); + +__CDECLS_END + +#endif /* _TOS_POSIX_H_ */ + diff --git a/osal/posix/mqueue.c b/osal/posix/mqueue.c new file mode 100644 index 00000000..b69689ff --- /dev/null +++ b/osal/posix/mqueue.c @@ -0,0 +1,173 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "private/posix_config.h" + +#include "errno.h" +#include "mqueue.h" +#include "private/time.h" +#include "private/mqueue.h" + +#if POSIX_CFG_MQUEUE_EN > 0u + +__API__ int mq_close(mqd_t mqdes) +{ + k_err_t kerr; + mqueue_ctl_t *the_ctl; + + the_ctl = mqueue_by_id(mqdes); + if (!the_ctl) { + return EINVAL; + } + + kerr = tos_prio_mail_q_destroy_dyn((k_prio_mail_q_t *)&the_ctl->kprio_mail_q); + mqueue_id_free(mqdes); + tos_mmheap_free(the_ctl); + + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__NOTSUPP__ int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int mq_notify(mqd_t mqdes, const struct sigevent *notification) +{ + return EOPNOTSUPP; +} + +__API__ mqd_t mq_open(const char *name, int oflag, ...) +{ + mqd_t id; + k_err_t kerr; + mode_t mode; + va_list arg; + mqueue_ctl_t *the_ctl; + struct mq_attr *attr; + + id = mqueue_id_alloc(); + if (id == -1) { + return -1; + } + + va_start(arg, oflag); + mode = va_arg(arg, mode_t); + mode = mode; /* make compiler happy */ + attr = va_arg(arg, struct mq_attr *); + va_end(arg); + + if (attr->mq_maxmsg > MQUEUE_MSG_MAX || + attr->mq_msgsize > MQUEUE_MSG_SIZE_MAX) { + return EINVAL; + } + + the_ctl = (mqueue_ctl_t *)tos_mmheap_alloc(sizeof(mqueue_ctl_t)); + if (!the_ctl) { + return -1; + } + + kerr = tos_prio_mail_q_create_dyn((k_prio_mail_q_t *)&the_ctl->kprio_mail_q, + attr->mq_maxmsg, attr->mq_msgsize); + if (kerr != K_ERR_NONE) { + tos_mmheap_free(the_ctl); + return -1; + } + + the_ctl->id = id; + mqueue_id_add(id, the_ctl); + + return id; +} + +__API__ ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio) +{ + k_err_t kerr; + mqueue_ctl_t *the_ctl; + + the_ctl = mqueue_by_id(mqdes); + if (!the_ctl) { + return EINVAL; + } + + kerr = tos_prio_mail_q_pend((k_prio_mail_q_t *)&the_ctl->kprio_mail_q, msg_ptr, &msg_len, TOS_TIME_FOREVER); + if (kerr == K_ERR_NONE) { + return 0; + } + + return msg_len; +} + +__API__ int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio) +{ + k_err_t kerr; + mqueue_ctl_t *the_ctl; + + the_ctl = mqueue_by_id(mqdes); + if (!the_ctl) { + return EINVAL; + } + + kerr = tos_prio_mail_q_post((k_prio_mail_q_t *)&the_ctl->kprio_mail_q, (void *)msg_ptr, msg_len, msg_prio); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__NOTSUPP__ int mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat, struct mq_attr *omqstat) +{ + return EOPNOTSUPP; +} + +__API__ ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio, const struct timespec *abstime) +{ + k_err_t kerr; + k_tick_t ktick; + mqueue_ctl_t *the_ctl; + + the_ctl = mqueue_by_id(mqdes); + if (!the_ctl) { + return EINVAL; + } + + ktick = timespec_to_ktick(abstime); + kerr = tos_prio_mail_q_pend((k_prio_mail_q_t *)&the_ctl->kprio_mail_q, (void *)msg_ptr, &msg_len, ktick); + if (kerr == K_ERR_NONE) { + return 0; + } + + return msg_len; +} + +__NOTSUPP__ int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec *abstime) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int mq_unlink(const char *name) +{ + return EOPNOTSUPP; +} + +#endif /* POSIX_CFG_MQUEUE_EN */ + diff --git a/osal/posix/mqueue_prv.c b/osal/posix/mqueue_prv.c new file mode 100644 index 00000000..165e1aee --- /dev/null +++ b/osal/posix/mqueue_prv.c @@ -0,0 +1,98 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "tos_k.h" + +#include "mqueue.h" +#include "private/mqueue.h" + +__STATIC__ mqueue_ctl_t *mqueue_ctl_table[MQUEUE_MAX] = { 0 }; + +__KNL__ int mqueue_id_add(mqd_t id, mqueue_ctl_t *mqueue_ctl) +{ + TOS_CPU_CPSR_ALLOC(); + + if (id < 0 || + id >= TOS_COUNT_OF(mqueue_ctl_table) || + mqueue_ctl_table[id]) { + return -1; + } + + TOS_CPU_INT_DISABLE(); + + mqueue_ctl_table[id] = mqueue_ctl; + + TOS_CPU_INT_ENABLE(); + + return 0; +} + +__KNL__ mqd_t mqueue_id_alloc(void) +{ + TOS_CPU_CPSR_ALLOC(); + int i = 0; + + TOS_CPU_INT_DISABLE(); + + for (i = 0; i < TOS_COUNT_OF(mqueue_ctl_table); ++i) { + if (!mqueue_ctl_table[i]) { + TOS_CPU_INT_ENABLE(); + return (mqd_t)i; + } + } + + TOS_CPU_INT_ENABLE(); + return -1; +} + +__KNL__ int mqueue_id_free(mqd_t id) +{ + TOS_CPU_CPSR_ALLOC(); + + if (id < 0 || + id >= TOS_COUNT_OF(mqueue_ctl_table) || + !mqueue_ctl_table[id]) { + return -1; + } + + TOS_CPU_INT_DISABLE(); + + mqueue_ctl_table[id] = K_NULL; + + TOS_CPU_INT_ENABLE(); + + return 0; +} + +__KNL__ mqueue_ctl_t *mqueue_by_id(mqd_t id) +{ + mqueue_ctl_t *the_ctl; + + the_ctl = mqueue_ctl_table[id]; + + if (!the_ctl) { + return K_NULL; + } + + if (the_ctl->id != id) { + return K_NULL; + } + + return the_ctl; +} + + diff --git a/osal/posix/pthread.c b/osal/posix/pthread.c new file mode 100644 index 00000000..66a9a946 --- /dev/null +++ b/osal/posix/pthread.c @@ -0,0 +1,1605 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "private/posix_config.h" + +#include "errno.h" +#include "pthread.h" +#include "private/pthread.h" +#include "private/time.h" + +int __pthread_canceled; + +__STATIC__ int pthreads_ready2reap = 0; + +__STATIC__ void pthread_dead_reap(void) +{ + pthreads_ready2reap -= pthread_ctl_reap(pthreads_ready2reap); +} + +__STATIC__ void pthread_entry(void *data) +{ + void *retval; + pthread_ctl_t *the_ctl; + + the_ctl = (pthread_ctl_t *)data; + + retval = the_ctl->start_routine(the_ctl->arg); + + pthread_exit(retval); +} + +__STATIC__ int pthread_is_cancel_pending(void) +{ + pthread_ctl_t *self_ctl; + + self_ctl = pthread_ctl_self(); + if (self_ctl && + self_ctl->cancelpending && + self_ctl->cancelstate == PTHREAD_CANCEL_ENABLE) { + return K_TRUE; + } + + return K_FALSE; +} + +__NOTSUPP__ int pthread_atfork(void (*prepare)(void), void (*parent)(void), void(*child)(void)) +{ + return EOPNOTSUPP; +} + +__API__ int pthread_attr_destroy(pthread_attr_t *attr) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + + memset(attr, 0, sizeof(pthread_attr_t)); + + return 0; +} + +__API__ int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + TOS_PTR_SANITY_CHECK_RC(detachstate, EINVAL); + + *detachstate = attr->detachstate; + + return 0; +} + +__NOTSUPP__ int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize) +{ + return EOPNOTSUPP; +} + +__API__ int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inheritsched) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + TOS_PTR_SANITY_CHECK_RC(inheritsched, EINVAL); + + *inheritsched = attr->inheritsched; + + return 0; +} + +__API__ int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + TOS_PTR_SANITY_CHECK_RC(param, EINVAL); + + *param = attr->schedparam; + + return 0; +} + +__API__ int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + TOS_PTR_SANITY_CHECK_RC(policy, EINVAL); + + *policy = attr->schedpolicy; + + return 0; +} + +__NOTSUPP__ int pthread_attr_getscope(const pthread_attr_t *attr, int *contentionscope) +{ + return EOPNOTSUPP; +} + +__API__ int pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, size_t *stacksize) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + TOS_PTR_SANITY_CHECK_RC(stackaddr, EINVAL); + TOS_PTR_SANITY_CHECK_RC(stacksize, EINVAL); + + if (!attr->stackaddr_valid || !attr->stacksize_valid) { + return EINVAL; + } + + *stackaddr = attr->stackaddr; + *stacksize = attr->stacksize; + + return 0; +} + +__API__ int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + TOS_PTR_SANITY_CHECK_RC(stacksize, EINVAL); + + if (!attr->stacksize_valid) { + return EINVAL; + } + + *stacksize = attr->stacksize; + + return 0; +} + +__API__ int pthread_attr_init(pthread_attr_t *attr) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + + attr->detachstate = PTHREAD_DEFAULT_DETACH_STATE; + attr->inheritsched = PTHREAD_DEFAULT_INHERIT_SCHED; + attr->schedpolicy = PTHREAD_DEFAULT_SCHEDPOLICY; + attr->schedparam.sched_priority = PTHREAD_DEFAULT_PRIORITY; + + attr->stackaddr_valid = K_FALSE; + attr->stacksize_valid = K_FALSE; + attr->stackaddr = K_NULL; + attr->stacksize = 0; + + return 0; +} + +__API__ int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + + if (detachstate != PTHREAD_CREATE_JOINABLE && + detachstate != PTHREAD_CREATE_DETACHED) { + return EINVAL; + } + + attr->detachstate = detachstate; + + return 0; +} + +__NOTSUPP__ int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize) +{ + return EOPNOTSUPP; +} + +__API__ int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + TOS_PTR_SANITY_CHECK_RC(inheritsched, EINVAL); + + if (inheritsched != PTHREAD_INHERIT_SCHED && + inheritsched != PTHREAD_EXPLICIT_SCHED) { + return EINVAL; + } + + attr->inheritsched = inheritsched; + + return 0; +} + +__API__ int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + TOS_PTR_SANITY_CHECK_RC(param, EINVAL); + + attr->schedparam = *param; + + return 0; +} + +__API__ int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + TOS_PTR_SANITY_CHECK_RC(policy, EINVAL); + + if (policy != SCHED_OTHER && + policy != SCHED_FIFO && + policy != SCHED_RR) { + return EINVAL; + } + + attr->schedpolicy = policy; + + return 0; +} + +__NOTSUPP__ int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope) +{ + return EOPNOTSUPP; +} + +__API__ int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + TOS_PTR_SANITY_CHECK_RC(stackaddr, EINVAL); + + if (stacksize < PTHREAD_STK_SIZE_MIN) { + return EINVAL; + } + + attr->stackaddr = stackaddr; + attr->stackaddr_valid = K_TRUE; + + attr->stacksize = stacksize; + attr->stacksize_valid = K_TRUE; + + return 0; +} + +__API__ int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + + if (stacksize < PTHREAD_STK_SIZE_MIN) { + return EINVAL; + } + + attr->stacksize = stacksize; + attr->stacksize_valid = K_TRUE; + + return 0; +} + +#if POSIX_CFG_PTHREAD_BARRIER_EN > 0u + +__API__ int pthread_barrier_destroy(pthread_barrier_t *barrier) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(barrier, EINVAL); + + kerr = tos_barrier_destroy((k_barrier_t *)barrier); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned count) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(barrier, EINVAL); + + kerr = tos_barrier_create((k_barrier_t *)barrier, (k_barrier_cnt_t)count); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_barrier_wait(pthread_barrier_t *barrier) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(barrier, EINVAL); + + kerr = tos_barrier_pend((k_barrier_t *)barrier); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__NOTSUPP__ int pthread_barrierattr_destroy(pthread_barrierattr_t *attr) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_barrierattr_getpshared(const pthread_barrierattr_t *attr, int *pshared) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_barrierattr_init(pthread_barrierattr_t *attr) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_barrierattr_setpshared(pthread_barrierattr_t *attr, int pshared) +{ + return EOPNOTSUPP; +} + +#endif /* POSIX_CFG_PTHREAD_BARRIER_EN */ + +__API__ int pthread_cancel(pthread_t thread) +{ + pthread_ctl_t *the_ctl; + + pthread_lock(); + + the_ctl = pthread_ctl_by_id(thread); + if (!the_ctl) { + pthread_unlock(); + return ESRCH; + } + + the_ctl->cancelpending = K_TRUE; + + if (the_ctl->cancelstate == PTHREAD_CANCEL_DISABLE) { + return EPERM; + } + + if (the_ctl->canceltype == PTHREAD_CANCEL_ASYNCHRONOUS) { + tos_task_destroy(the_ctl->the_ktask); + } + + pthread_unlock(); + + return 0; +} + +#if POSIX_CFG_PTHREAD_COND_EN > 0u + +__API__ int pthread_cond_broadcast(pthread_cond_t *cond) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(cond, EINVAL); + + kerr = tos_sem_post_all((k_sem_t *)cond); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_cond_destroy(pthread_cond_t *cond) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(cond, EINVAL); + + kerr = tos_sem_destroy((k_sem_t *)cond); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(cond, EINVAL); + + kerr = tos_sem_create((k_sem_t *)cond, 0); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_cond_signal(pthread_cond_t *cond) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(cond, EINVAL); + + kerr = tos_sem_post((k_sem_t *)cond); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__STATIC__ int pthread_cond_do_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, k_tick_t timeout) +{ + k_err_t kerr; + int errcode; + + if (mutex->kmutex.owner != tos_task_curr_task_get()) { + return EPERM; + } + + errcode = pthread_mutex_unlock(mutex); + if (errcode != 0) { + return EINVAL; + } + + kerr = tos_sem_pend((k_sem_t *)cond, timeout); + pthread_mutex_lock(mutex); + + if (kerr == K_ERR_NONE) { + return 0; + } + + if (kerr == K_ERR_PEND_TIMEOUT) { + return ETIMEDOUT; + } + + return EINVAL; +} + +__API__ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) +{ + k_tick_t timeout; + + TOS_PTR_SANITY_CHECK_RC(cond, EINVAL); + TOS_PTR_SANITY_CHECK_RC(mutex, EINVAL); + TOS_PTR_SANITY_CHECK_RC(abstime, EINVAL); + + timeout = timespec_to_ktick(abstime); + return pthread_cond_do_timedwait(cond, mutex, timeout); +} + +__API__ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) +{ + TOS_PTR_SANITY_CHECK_RC(cond, EINVAL); + TOS_PTR_SANITY_CHECK_RC(mutex, EINVAL); + + return pthread_cond_do_timedwait(cond, mutex, TOS_TIME_FOREVER); +} + +__NOTSUPP__ int pthread_condattr_destroy(pthread_condattr_t *attr) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clock_id) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_condattr_init(pthread_condattr_t *attr) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared) +{ + return EOPNOTSUPP; +} + +#endif /* POSIX_CFG_PTHREAD_COND_EN */ + +__API__ int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) +{ + k_err_t kerr; + pthread_t id; + int errcode; + int is_stk_need_free = K_FALSE; + void *stackaddr = K_NULL; + size_t stacksize; + char name[K_TASK_NAME_MAX]; + static uint16_t pthrd_id = 0; + pthread_attr_t the_attr; + pthread_ctl_t *self_ctl = K_NULL, *the_ctl = K_NULL; + + TOS_IN_IRQ_CHECK(); + + TOS_PTR_SANITY_CHECK_RC(thread, EINVAL); + TOS_PTR_SANITY_CHECK_RC(start_routine, EINVAL); + + id = pthread_id_alloc(); + if (id == -1) { + return ENOMEM; + } + + if (!attr) { + pthread_attr_init(&the_attr); + } else { + the_attr = *attr; + } + + self_ctl = pthread_ctl_self(); + + if (the_attr.inheritsched == PTHREAD_INHERIT_SCHED) { + if (!self_ctl) { + /* cannot inherit sched policy from non-POSIX thread */ + errcode = EPERM; + goto errout0; + } + + the_attr.schedpolicy = self_ctl->attr.schedpolicy; + the_attr.schedparam = self_ctl->attr.schedparam; + } + + if (the_attr.stackaddr_valid) { + /* means we called pthread_attr_setstack and returned OK once before*/ + stackaddr = the_attr.stackaddr; + stacksize = the_attr.stacksize; + } else if (the_attr.stacksize_valid) { + /* we called pthread_attr_setstacksize and returned OK once before */ + stacksize = the_attr.stacksize + PTHREAD_INFO_SIZE; + } else { + /* neither the pthread_attr_setstack nor pthread_attr_setstacksize has beed called */ + stacksize = PTHREAD_DEFAULT_STACKSIZE; + } + + if (!the_attr.stackaddr_valid) { + stackaddr = tos_mmheap_alloc(stacksize); + if (!stackaddr) { + errcode = ENOMEM; + goto errout0; + } + + is_stk_need_free = K_TRUE; + } + + /* we keep our little secret onto the bottom of stack, avoiding of multi-times malloc */ + the_ctl = (pthread_ctl_t *)stackaddr; + the_ctl->stackaddr = (is_stk_need_free ? stackaddr : K_NULL); + the_ctl->start_routine = start_routine; + the_ctl->arg = arg; + + stackaddr = (void *)((cpu_addr_t)stackaddr + PTHREAD_INFO_SIZE); + stacksize -= PTHREAD_INFO_SIZE; + snprintf(name, sizeof(name), "pthrd%d", pthrd_id++); + + if (the_attr.detachstate == PTHREAD_CREATE_JOINABLE) { + kerr = tos_sem_create(&the_ctl->joinner_sem, 0); + if (kerr != K_ERR_NONE) { + errcode = EBUSY; + goto errout0; + } + } + + tos_knl_sched_lock(); + + pthread_dead_reap(); + + kerr = tos_task_create(&the_ctl->ktask, name, + pthread_entry, (void *)the_ctl, + the_attr.schedparam.sched_priority, + stackaddr, stacksize, + PTHREAD_DEFAULT_TIMESLICE); + if (kerr != K_ERR_NONE) { + errcode = EBUSY; + tos_knl_sched_unlock(); + goto errout1; + } + + the_ctl->threadstate = the_attr.detachstate == PTHREAD_CREATE_JOINABLE ? + PTHREAD_STATE_RUNNING : PTHREAD_STATE_DETACHED; + + the_ctl->id = id; + the_ctl->attr = the_attr; + the_ctl->retval = K_NULL; + the_ctl->the_ktask = &the_ctl->ktask; + + the_ctl->cancelstate = PTHREAD_CANCEL_ENABLE; + the_ctl->canceltype = PTHREAD_CANCEL_DEFERRED; + the_ctl->cancelpending = K_FALSE; + + the_ctl->thread_data = K_NULL; + tos_slist_init(&the_ctl->cleanup_ctl_list); + + pthread_id_add(id, the_ctl); + + *thread = id; + + tos_knl_sched_unlock(); + + return ENOERR; + +errout1: + tos_sem_destroy(&the_ctl->joinner_sem); + +errout0: + if (is_stk_need_free) { + /* stack is allocated by us */ + tos_mmheap_free(stackaddr); + } + + return errcode; +} + +__API__ int pthread_detach(pthread_t thread) +{ + int errcode = 0; + pthread_ctl_t *the_ctl; + + pthread_lock(); + + the_ctl = pthread_ctl_by_id(thread); + if (!the_ctl) { + errcode = ESRCH; + } else if (the_ctl->threadstate == PTHREAD_STATE_DETACHED) { + /* already detached */ + errcode = EINVAL; + } else { + the_ctl->threadstate = PTHREAD_STATE_DETACHED; + /* make any who is joining for us wakeup and return(I am detached now!) */ + tos_sem_post_all(&the_ctl->joinner_sem); + } + + pthread_dead_reap(); + + pthread_unlock(); + + return errcode; +} + +__API__ int pthread_equal(pthread_t t1, pthread_t t2) +{ + return t1 == t2; +} + +__API__ void pthread_exit(void *value_ptr) +{ + void *value; + int key = 0; + int destructor_called = K_FALSE, destructor_iterations = 0; + key_destructor_t key_destructor = K_NULL; + pthread_ctl_t *self_ctl; + pthread_cleanup_ctl_t *cleanup_ctl, *tmp; + + self_ctl = pthread_ctl_self(); + if (!self_ctl) { + /* this is a non-POSIX thread */ + return; + } + + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, K_NULL); + + /* call all the cleanup routine */ + TOS_SLIST_FOR_EACH_ENTRY_SAFE(cleanup_ctl, tmp, pthread_cleanup_ctl_t, list, &self_ctl->cleanup_ctl_list) { + cleanup_ctl->routine(cleanup_ctl->arg); + tos_slist_del(&cleanup_ctl->list, &self_ctl->cleanup_ctl_list); + tos_mmheap_free(cleanup_ctl); + } + + /* call destructor for each key */ + do { + for (key = 0; key < PTHREAD_KEYS_MAX; ++key) { + /* key is not created */ + if (!pthread_key_is_alloc(key)) { + continue; + } + + /* destrutor is not register-ed */ + key_destructor = pthread_key_destructor_get(key); + if (!key_destructor) { + continue; + } + + if (self_ctl->thread_data) { + continue; + } + + value = self_ctl->thread_data[key]; + self_ctl->thread_data[key] = K_NULL; + key_destructor(value); + + destructor_called = K_TRUE; + } + + ++destructor_iterations; + } while (destructor_called && (destructor_iterations <= PTHREAD_DESTRUCTOR_ITERATIONS)); + + /* donot forget this */ + if (self_ctl->thread_data) { + tos_mmheap_free(self_ctl->thread_data); + } + + pthread_lock(); + + self_ctl->retval = value_ptr; + + if (self_ctl->threadstate == PTHREAD_STATE_DETACHED) { + /* ready to die totally */ + self_ctl->threadstate = PTHREAD_STATE_EXITED; + ++pthreads_ready2reap; + } else { + /* we are dying, but we still waiting for someone to join us(reap for us)*/ + self_ctl->threadstate = PTHREAD_STATE_JOIN; + } + + /* wakeup all the joniners */ + tos_sem_post_all(&self_ctl->joinner_sem); + + pthread_unlock(); + + /* will invoke a knl_sched at last */ + tos_task_destroy(self_ctl->the_ktask); +} + +__NOTSUPP__ int pthread_getconcurrency(void) +{ + return EOPNOTSUPP; +} + +__API__ int pthread_getcpuclockid(pthread_t thread_id, clockid_t *clock_id) +{ + return EOPNOTSUPP; +} + +__API__ int pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param) +{ + pthread_ctl_t *the_ctl; + + pthread_lock(); + + the_ctl = pthread_ctl_by_id(thread); + + if (!the_ctl) { + pthread_unlock(); + return ESRCH; + } + + if (policy) { + *policy = the_ctl->attr.schedpolicy; + } + + if (param) { + *param = the_ctl->attr.schedparam; + } + + pthread_unlock(); + + return 0; +} + +__API__ void *pthread_getspecific(pthread_key_t key) +{ + pthread_ctl_t *self_ctl; + + if (key >= PTHREAD_KEYS_MAX || key < 0) { + return K_NULL; + } + + self_ctl = pthread_ctl_self(); + if (!self_ctl || !self_ctl->thread_data) { + /* this is a non-POSIX thread, or thread_data is empty */ + return K_NULL; + } + + return self_ctl->thread_data[key]; +} + +__API__ int pthread_join(pthread_t thread, void **value_ptr) +{ + k_err_t kerr; + int errcode = 0; + pthread_ctl_t *self_ctl, *the_ctl; + + pthread_testcancel(); + + pthread_lock(); + + pthread_dead_reap(); + + pthread_unlock(); + + self_ctl = pthread_ctl_self(); + if (!self_ctl) { + /* a non-POSIX thread */ + errcode = EPERM; + goto errout; + } + + the_ctl = pthread_ctl_by_id(thread); + if (!the_ctl) { + errcode = ESRCH; + goto errout; + } + + if (the_ctl == self_ctl) { + errcode = EDEADLK; + goto errout; + } + + if (the_ctl->attr.detachstate == PTHREAD_CREATE_DETACHED) { + /* the target thread is not joinable */ + errcode = EPERM; + goto errout; + } + + if (the_ctl->threadstate == PTHREAD_STATE_DETACHED && + the_ctl->threadstate == PTHREAD_STATE_EXITED) { + errcode = EINVAL; + goto errout; + } + + if (the_ctl->threadstate == PTHREAD_STATE_JOIN) { + /* the thread is exit, and waiting to be joined */ + ; + } else if (the_ctl->threadstate == PTHREAD_STATE_RUNNING) { + while (the_ctl->threadstate == PTHREAD_STATE_RUNNING) { + kerr = tos_sem_pend(&the_ctl->joinner_sem, TOS_TIME_FOREVER); + if (kerr != K_ERR_NONE) { + errcode = ESRCH; + goto errout; + } + + if (pthread_is_cancel_pending()) { + /* someone cancel us, goto errout and suicide in testcancel */ + errcode = EAGAIN; + goto errout; + } + } + } + + if (value_ptr) { + *value_ptr = the_ctl->retval; + } + + /* the guy now happy to die */ + the_ctl->threadstate = PTHREAD_STATE_EXITED; + + ++pthreads_ready2reap; + + pthread_lock(); + + pthread_dead_reap(); + + pthread_unlock(); + +errout: + pthread_testcancel(); + return errcode; +} + +__API__ int pthread_key_create(pthread_key_t *key, void (*destructor)(void*)) +{ + pthread_key_t the_key; + + TOS_PTR_SANITY_CHECK_RC(key, -1); + + the_key = pthread_key_alloc(); + if (the_key == -1) { + *key = -1; + return EAGAIN; + } + + pthread_lock(); + + pthread_key_destructor_register(the_key, destructor); + + pthread_data_clear(the_key); + + pthread_unlock(); + + *key = the_key; + + return 0; +} + +__API__ int pthread_key_delete(pthread_key_t key) +{ + int rc; + + pthread_lock(); + + rc = pthread_key_free(key); + + pthread_unlock(); + + return rc; +} + +#if POSIX_CFG_PTHREAD_MUTEX_EN > 0u + +__NOTSUPP__ int pthread_mutex_consistent(pthread_mutex_t *mutex) +{ + return EOPNOTSUPP; +} + +__API__ int pthread_mutex_destroy(pthread_mutex_t *mutex) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(mutex, EINVAL); + + kerr = tos_mutex_destroy(&mutex->kmutex); + if (kerr != K_ERR_NONE) { + return EINVAL; + } + + pthread_mutexattr_init(&mutex->attr); + + return 0; +} + +__API__ int pthread_mutex_getprioceiling(const pthread_mutex_t *mutex, int *prioceiling) +{ + return EOPNOTSUPP; +} + +__API__ int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(mutex, EINVAL); + + if (!attr) { + pthread_mutexattr_init(&mutex->attr); + attr = &mutex->attr; + } else { + mutex->attr = *attr; + } + + kerr = tos_mutex_create(&mutex->kmutex); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_mutex_lock(pthread_mutex_t *mutex) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(mutex, EINVAL); + + if (mutex->attr.type != PTHREAD_MUTEX_RECURSIVE && + mutex->kmutex.owner == tos_task_curr_task_get()) { + /* RECURSIVE is not permitted, and we are the owner */ + return EPERM; + } + + /* the k_mutex_t is born to support RECURSIVE */ + kerr = tos_mutex_pend(&mutex->kmutex); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int prioceiling, int *old_ceiling) +{ + return EOPNOTSUPP; +} + +__API__ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *abstime) +{ + k_err_t kerr; + k_tick_t ktick; + + TOS_PTR_SANITY_CHECK_RC(mutex, EINVAL); + TOS_PTR_SANITY_CHECK_RC(abstime, EINVAL); + + if (mutex->attr.type != PTHREAD_MUTEX_RECURSIVE && + mutex->kmutex.owner == tos_task_curr_task_get()) { + /* RECURSIVE is not permitted, and we are the owner */ + return EPERM; + } + + ktick = timespec_to_ktick(abstime); + kerr = tos_mutex_pend_timed(&mutex->kmutex, ktick); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_mutex_trylock(pthread_mutex_t *mutex) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(mutex, EINVAL); + + if (mutex->attr.type != PTHREAD_MUTEX_RECURSIVE && + mutex->kmutex.owner == tos_task_curr_task_get()) { + /* RECURSIVE is not permitted, and we are the owner */ + return EPERM; + } + + kerr = tos_mutex_pend_timed(&mutex->kmutex, TOS_TIME_NOWAIT); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_mutex_unlock(pthread_mutex_t *mutex) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(mutex, EINVAL); + + if ((!mutex->kmutex.owner || + mutex->kmutex.owner != tos_task_curr_task_get()) && + mutex->attr.type == PTHREAD_MUTEX_ERRORCHECK) { + /* the mutex is not locked or not locked by us, and type is PTHREAD_MUTEX_ERRORCHECK */ + return EPERM; + } + + kerr = tos_mutex_post(&mutex->kmutex); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + + attr->type = 0xF; + + return 0; +} + +__NOTSUPP__ int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *mutex, int *prioceiling) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *mutex, int *protocol) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_mutexattr_getpshared(const pthread_mutexattr_t *mutex, int *pshared) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_mutexattr_getrobust(const pthread_mutexattr_t *mutex, int *robust) +{ + return EOPNOTSUPP; +} + +__API__ int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + TOS_PTR_SANITY_CHECK_RC(type, EINVAL); + + *type = attr->type; + + return 0; +} +__API__ int pthread_mutexattr_init(pthread_mutexattr_t *attr) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + + attr->type = PTHREAD_MUTEX_DEFAULT; + + return 0; +} +__NOTSUPP__ int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_mutexattr_setprotocol(pthread_mutexattr_t *mutex, int protocol) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_mutexattr_setpshared(pthread_mutexattr_t *mutex, int pshared) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_mutexattr_setrobust(pthread_mutexattr_t *mutex, int robust) +{ + return EOPNOTSUPP; +} + +__API__ int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) +{ + TOS_PTR_SANITY_CHECK_RC(attr, EINVAL); + + if (type < PTHREAD_MUTEX_NORMAL || + type > PTHREAD_MUTEX_DEFAULT) { + return EINVAL; + } + + attr->type = type; + + return 0; +} + +#endif /* POSIX_CFG_PTHREAD_MUTEX_EN */ + +#if POSIX_CFG_PTHREAD_RWLOCK_EN > 0u + +__API__ int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) +{ + pthread_once_t old; + + TOS_PTR_SANITY_CHECK_RC(once_control, EINVAL); + TOS_PTR_SANITY_CHECK_RC(init_routine, EINVAL); + + pthread_lock(); + + old = *once_control; + *once_control = 1; + + pthread_unlock(); + + if (!old) { + init_routine(); + } + + return 0; +} + +__API__ int pthread_rwlock_destroy(pthread_rwlock_t *rwlock) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(rwlock, EINVAL); + + kerr = tos_rwlock_destroy((k_rwlock_t *)rwlock); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(rwlock, EINVAL); + + kerr = tos_rwlock_create((k_rwlock_t *)rwlock); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(rwlock, EINVAL); + + kerr = tos_rwlock_rpend((k_rwlock_t *)rwlock); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *abstime) +{ + k_err_t kerr; + k_tick_t ktick; + + TOS_PTR_SANITY_CHECK_RC(rwlock, EINVAL); + TOS_PTR_SANITY_CHECK_RC(abstime, EINVAL); + + ktick = timespec_to_ktick(abstime); + kerr = tos_rwlock_rpend_timed((k_rwlock_t *)rwlock, ktick); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abstime) +{ + k_err_t kerr; + k_tick_t ktick; + + TOS_PTR_SANITY_CHECK_RC(rwlock, EINVAL); + TOS_PTR_SANITY_CHECK_RC(abstime, EINVAL); + + ktick = timespec_to_ktick(abstime); + kerr = tos_rwlock_wpend_timed((k_rwlock_t *)rwlock, ktick); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + + +__API__ int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(rwlock, EINVAL); + + kerr = tos_rwlock_rpend_try((k_rwlock_t *)rwlock); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(rwlock, EINVAL); + + kerr = tos_rwlock_wpend_try((k_rwlock_t *)rwlock); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_rwlock_unlock(pthread_rwlock_t *rwlock) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(rwlock, EINVAL); + + kerr = tos_rwlock_post((k_rwlock_t *)rwlock); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(rwlock, EINVAL); + + kerr = tos_rwlock_wpend((k_rwlock_t *)rwlock); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__NOTSUPP__ int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr, int *pshared) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_rwlockattr_init(pthread_rwlockattr_t *attr) +{ + return EOPNOTSUPP; +} + +__NOTSUPP__ int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared) +{ + return EOPNOTSUPP; +} + +#endif /* POSIX_CFG_PTHREAD_RWLOCK_EN */ + +__API__ pthread_t pthread_self(void) +{ + pthread_ctl_t *self_ctl; + + self_ctl = pthread_ctl_self(); + if (!self_ctl) { + /* a non-POSIX thread */ + return -1; + } + + return self_ctl->id; +} + +__API__ int pthread_setcancelstate(int state, int *oldstate) +{ + pthread_ctl_t *self_ctl; + + if (state != PTHREAD_CANCEL_ENABLE && + state != PTHREAD_CANCEL_DISABLE) { + return EINVAL; + } + + self_ctl = pthread_ctl_self(); + if (!self_ctl) { + /* this is a non-POSIX thread */ + return EPERM; + } + + if (oldstate) { + *oldstate = self_ctl->cancelstate; + } + + self_ctl->cancelstate = state; + + return 0; +} + +__API__ int pthread_setcanceltype(int type, int *oldtype) +{ + pthread_ctl_t *self_ctl; + + if (type != PTHREAD_CANCEL_ASYNCHRONOUS && + type != PTHREAD_CANCEL_DEFERRED) { + return EINVAL; + } + + self_ctl = pthread_ctl_self(); + if (!self_ctl) { + /* this is a non-POSIX thread */ + return EPERM; + } + + if (oldtype) { + *oldtype = self_ctl->canceltype; + } + + self_ctl->canceltype = type; + + return 0; +} + +__NOTSUPP__ int pthread_setconcurrency(int new_level) +{ + return EOPNOTSUPP; +} + +__API__ int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param) +{ + pthread_ctl_t *the_ctl; + + TOS_PTR_SANITY_CHECK_RC(param, EINVAL); + + if (policy != SCHED_OTHER && + policy != SCHED_FIFO && + policy != SCHED_RR) { + return EINVAL; + } + + pthread_lock(); + + the_ctl = pthread_ctl_by_id(thread); + + if (!the_ctl) { + pthread_unlock(); + return ESRCH; + } + + the_ctl->attr.schedpolicy = policy; + the_ctl->attr.schedparam = *param; + + if (the_ctl->the_ktask) { + tos_task_prio_change(the_ctl->the_ktask, param->sched_priority); + } + + pthread_unlock(); + + return 0; +} + +__API__ int pthread_setschedprio(pthread_t thread, int prio) +{ + pthread_ctl_t *the_ctl; + + pthread_lock(); + + the_ctl = pthread_ctl_by_id(thread); + + if (!the_ctl) { + pthread_unlock(); + return ESRCH; + } + + the_ctl->attr.schedparam.sched_priority = prio; + + if (the_ctl->the_ktask) { + tos_task_prio_change(the_ctl->the_ktask, prio); + } + + pthread_unlock(); + + return 0; +} + +__API__ int pthread_setspecific(pthread_key_t key, const void *value) +{ + int i = 0; + pthread_ctl_t *self_ctl; + + if (key >= PTHREAD_KEYS_MAX || key < 0) { + return EINVAL; + } + + self_ctl = pthread_ctl_self(); + if (!self_ctl) { + /* this is a non-POSIX thread */ + return EPERM; + } + + if (!self_ctl->thread_data) { + self_ctl->thread_data = (void **)tos_mmheap_alloc(sizeof(void *) * PTHREAD_KEYS_MAX); + if (!self_ctl->thread_data) { + return ENOMEM; + } + + for (i = 0; i < PTHREAD_KEYS_MAX; ++i) { + self_ctl->thread_data[i] = K_NULL; + } + } + + self_ctl->thread_data[key] = (void *)value; + + return 0; +} + +#if POSIX_CFG_PTHREAD_SPIN_EN > 0u + +__API__ int pthread_spin_destroy(pthread_spinlock_t *lock) +{ + TOS_PTR_SANITY_CHECK_RC(lock, EINVAL); + + if (lock->is_destroyed) { + return 0; + } + + lock->is_destroyed = K_TRUE; + lock->is_locked = K_FALSE; + + return 0; +} + +__API__ int pthread_spin_init(pthread_spinlock_t *lock, int pshared) +{ + TOS_PTR_SANITY_CHECK_RC(lock, EINVAL); + + lock->is_destroyed = K_FALSE; + lock->is_locked = K_FALSE; + + return 0; +} + +__API__ int pthread_spin_lock(pthread_spinlock_t *lock) +{ + TOS_PTR_SANITY_CHECK_RC(lock, EINVAL); + + if (lock->is_destroyed) { + return EPERM; + } + + while (!lock->is_locked) { + lock->is_locked = K_TRUE; + } + + return 0; +} + +__API__ int pthread_spin_trylock(pthread_spinlock_t *lock) +{ + TOS_PTR_SANITY_CHECK_RC(lock, EINVAL); + + if (lock->is_destroyed) { + return EPERM; + } + + if (lock->is_locked) { + return EBUSY; + } + + lock->is_locked = K_TRUE; + return 0; +} + +__API__ int pthread_spin_unlock(pthread_spinlock_t *lock) +{ + TOS_PTR_SANITY_CHECK_RC(lock, EINVAL); + + if (lock->is_destroyed) { + return EPERM; + } + + if (!lock->is_locked) { + return EPERM; + } + + lock->is_locked = K_FALSE; + + return 0; +} + +#endif /* POSIX_CFG_PTHREAD_SPIN_EN */ + +__API__ void pthread_testcancel(void) +{ + if (pthread_is_cancel_pending()) { + pthread_exit(PTHREAD_CANCELD); + } +} + +__API__ void pthread_cleanup_pop(int execute) +{ + pthread_ctl_t *self_ctl; + pthread_cleanup_ctl_t *cleanup_ctl; + + self_ctl = pthread_ctl_self(); + if (!self_ctl) { + /* this is a non-POSIX thread */ + return; + } + + pthread_lock(); + + if (tos_slist_empty(&self_ctl->cleanup_ctl_list)) { + pthread_unlock(); + return; + } + + cleanup_ctl = TOS_SLIST_FIRST_ENTRY(&self_ctl->cleanup_ctl_list, pthread_cleanup_ctl_t, list); + tos_slist_del_head(&self_ctl->cleanup_ctl_list); + + pthread_unlock(); + + if (execute) { + cleanup_ctl->routine(cleanup_ctl->arg); + } + + tos_mmheap_free(cleanup_ctl); +} + +__API__ void pthread_cleanup_push(void (*routine)(void*), void *arg) +{ + pthread_ctl_t *self_ctl; + pthread_cleanup_ctl_t *cleanup_ctl; + + if (!routine) { + return; + } + + self_ctl = pthread_ctl_self(); + if (!self_ctl) { + /* this is a non-POSIX thread */ + return; + } + + cleanup_ctl = (pthread_cleanup_ctl_t *)tos_mmheap_alloc(sizeof(pthread_cleanup_ctl_t)); + if (!cleanup_ctl) { + return; + } + + pthread_lock(); + tos_slist_add_head(&cleanup_ctl->list, &self_ctl->cleanup_ctl_list); + pthread_unlock(); +} + diff --git a/osal/posix/pthread_prv.c b/osal/posix/pthread_prv.c new file mode 100644 index 00000000..be7dbc04 --- /dev/null +++ b/osal/posix/pthread_prv.c @@ -0,0 +1,302 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "tos_k.h" + +#include "pthread.h" +#include "private/pthread.h" + +__STATIC__ k_mutex_t pthread_mutex; + +__STATIC__ pthread_ctl_t *thread_ctl_table[PTHREAD_THREADS_MAX] = { 0 }; + +__STATIC__ pthread_key_ctl_t pthread_key_ctl; + +__KNL__ pthread_ctl_t *pthread_ctl_self(void) +{ + TOS_CPU_CPSR_ALLOC(); + int i = 0; + k_task_t *self_task; + pthread_ctl_t *the_info; + + self_task = tos_task_curr_task_get(); + + TOS_CPU_INT_DISABLE(); + + for (i = 0; i < TOS_COUNT_OF(thread_ctl_table); ++i) { + the_info = thread_ctl_table[i]; + if (the_info && the_info->the_ktask == self_task) { + TOS_CPU_INT_ENABLE(); + return the_info; + } + } + + TOS_CPU_INT_ENABLE(); + return K_NULL; +} + +__KNL__ pthread_ctl_t *pthread_ctl_by_id(pthread_t id) +{ + pthread_ctl_t *the_ctl; + + the_ctl = thread_ctl_table[id]; + + if (!the_ctl) { + return K_NULL; + } + + if (the_ctl->id != id) { + return K_NULL; + } + + if (the_ctl->threadstate == PTHREAD_STATE_EXITED) { + return K_NULL; + } + + return the_ctl; +} + +__KNL__ int pthread_id_add(pthread_t id, pthread_ctl_t *info) +{ + TOS_CPU_CPSR_ALLOC(); + + if (id < 0 || + id >= TOS_COUNT_OF(thread_ctl_table) || + thread_ctl_table[id]) { + return -1; + } + + TOS_CPU_INT_DISABLE(); + + thread_ctl_table[id] = info; + + TOS_CPU_INT_ENABLE(); + + return 0; +} + +__KNL__ pthread_t pthread_id_alloc(void) +{ + TOS_CPU_CPSR_ALLOC(); + int i = 0; + + TOS_CPU_INT_DISABLE(); + + for (i = 0; i < TOS_COUNT_OF(thread_ctl_table); ++i) { + if (!thread_ctl_table[i]) { + TOS_CPU_INT_ENABLE(); + return (pthread_t)i; + } + } + + TOS_CPU_INT_ENABLE(); + return -1; +} + +__KNL__ int pthread_id_free(pthread_t id) +{ + TOS_CPU_CPSR_ALLOC(); + + if (id < 0 || + id >= TOS_COUNT_OF(thread_ctl_table) || + !thread_ctl_table[id]) { + return -1; + } + + TOS_CPU_INT_DISABLE(); + + thread_ctl_table[id] = K_NULL; + + TOS_CPU_INT_ENABLE(); + + return 0; +} + +__KNL__ void pthread_data_clear(pthread_key_t key) +{ + int i = 0; + pthread_ctl_t *the_ctl; + + for (i = 0; i < TOS_COUNT_OF(thread_ctl_table); ++i) { + the_ctl = thread_ctl_table[i]; + if (the_ctl && the_ctl->thread_data) { + the_ctl->thread_data[key] = K_NULL; + } + } +} + +__KNL__ int pthread_key_ctl_init(void) +{ + int i = 0; + + if (tos_bitmap_create_full(&pthread_key_ctl.key_bitmap, + pthread_key_ctl.key_bitmap_tbl, + PTHREAD_KEYS_MAX) != K_ERR_NONE) { + return -1; + } + + for (i = 0; i < PTHREAD_KEYS_MAX; ++i) { + pthread_key_ctl.destructors[i] = K_NULL; + } + + return 0; +} + +__KNL__ pthread_key_t pthread_key_alloc(void) +{ + int lsb; + + lsb = tos_bitmap_lsb(&pthread_key_ctl.key_bitmap); + + if (lsb > PTHREAD_KEYS_MAX) { + return -1; + } + + tos_bitmap_reset(&pthread_key_ctl.key_bitmap, lsb); + + return (pthread_key_t)lsb; +} + +__KNL__ int pthread_key_is_alloc(pthread_key_t key) +{ + if (key > PTHREAD_KEYS_MAX || key < 0) { + return K_FALSE; + } + + return tos_bitmap_is_reset(&pthread_key_ctl.key_bitmap, key); +} + +__KNL__ int pthread_key_free(pthread_key_t key) +{ + if (key > PTHREAD_KEYS_MAX || key < 0) { + return -1; + } + + if (tos_bitmap_is_set(&pthread_key_ctl.key_bitmap, key)) { + /* what we created is a full bitmap, if the bit is set means it is not used */ + return -1; + } + + /* make it avaliable again */ + tos_bitmap_set(&pthread_key_ctl.key_bitmap, key); + + return 0; +} + +__KNL__ int pthread_key_destructor_register(pthread_key_t key, key_destructor_t destructor) +{ + if (key > PTHREAD_KEYS_MAX || key < 0) { + return -1; + } + + if (tos_bitmap_is_set(&pthread_key_ctl.key_bitmap, key)) { + /* what we created is a full bitmap, if the bit is set means it is not used */ + return -1; + } + + pthread_key_ctl.destructors[key] = destructor; + + return 0; +} + +__STATIC__ int pthread_key_destructor_is_register(pthread_key_t key) +{ + if (key > PTHREAD_KEYS_MAX || key < 0) { + return K_FALSE; + } + + if (tos_bitmap_is_set(&pthread_key_ctl.key_bitmap, key)) { + /* what we created is a full bitmap, if the bit is set means it is not used */ + return K_FALSE; + } + + return pthread_key_ctl.destructors[key] != K_NULL; +} + +__KNL__ key_destructor_t pthread_key_destructor_get(pthread_key_t key) +{ + if (!pthread_key_destructor_is_register(key)) { + return K_NULL; + } + + return pthread_key_ctl.destructors[key]; +} + +__KNL__ int pthread_ctl_reap(int pthreads_ready2reap) +{ + int i = 0; + pthread_ctl_t *the_ctl; + int pthreads_reaped = 0; + + if (pthreads_ready2reap == 0) { + return 0; + } + + for (i = 0; pthreads_ready2reap && i < TOS_COUNT_OF(thread_ctl_table); ++i) { + the_ctl = thread_ctl_table[i]; + if (!the_ctl || the_ctl->threadstate != PTHREAD_STATE_EXITED) { + continue; + } + + pthread_id_free((pthread_t)i); + + tos_sem_destroy(&the_ctl->joinner_sem); + + if (the_ctl->stackaddr) { + /* the_ctl is just on this stack */ + tos_mmheap_free(the_ctl->stackaddr); + } + + --pthreads_ready2reap; + ++pthreads_reaped; + } + + return pthreads_reaped; +} + +__KNL__ void pthread_lock(void) +{ + tos_mutex_pend(&pthread_mutex); +} + +__KNL__ void pthread_unlock(void) +{ + tos_mutex_post(&pthread_mutex); +} + +__KNL__ int pthread_lock_init(void) +{ + if (tos_mutex_create(&pthread_mutex) != K_ERR_NONE) { + return -1; + } + + return 0; +} + +__KNL__ int pthread_init(void) +{ + if (pthread_lock_init() != 0) { + return -1; + } + + if (pthread_key_ctl_init() != 0) { + return -1; + } + + return 0; +} + diff --git a/osal/posix/sched.c b/osal/posix/sched.c new file mode 100644 index 00000000..4767ec72 --- /dev/null +++ b/osal/posix/sched.c @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "tos_k.h" + +#include "errno.h" +#include "sched.h" +#include "private/pthread.h" +#include "private/time.h" + +__API__ int sched_get_priority_max(int policy) +{ + return K_TASK_PRIO_IDLE - 1; +} + +__API__ int sched_get_priority_min(int policy) +{ + return 0; +} + +__API__ int sched_getparam(pid_t pid, struct sched_param *param) +{ + pthread_ctl_t *the_ctl; + + TOS_PTR_SANITY_CHECK_RC(param, EINVAL); + + the_ctl = pthread_ctl_by_id(pid); + if (!the_ctl) { + return EINVAL; + } + + *param = the_ctl->attr.schedparam; + + return 0; +} + +__NOTSUPP__ int sched_getscheduler(pid_t pid) +{ + return EOPNOTSUPP; +} + +__API__ int sched_rr_get_interval(pid_t pid, struct timespec *interval) +{ +#if TOS_CFG_ROUND_ROBIN_EN > 0u + k_tick_t ktick; + pthread_ctl_t *the_ctl; + + TOS_PTR_SANITY_CHECK_RC(interval, EINVAL); + + the_ctl = pthread_ctl_by_id(pid); + if (!the_ctl) { + return EINVAL; + } + + ktick = the_ctl->the_ktask->timeslice_reload; + ktick_to_timespec(ktick, interval); + + return 0; +#else + return EOPNOTSUPP; +#endif +} + +__API__ int sched_setparam(pid_t pid, const struct sched_param *param) +{ + pthread_ctl_t *the_ctl; + + TOS_PTR_SANITY_CHECK_RC(param, EINVAL); + + the_ctl = pthread_ctl_by_id(pid); + if (!the_ctl) { + return EINVAL; + } + + the_ctl->attr.schedparam = *param; + + return 0; +} + +__NOTSUPP__ int sched_setscheduler(pid_t pid, int policy, const struct sched_param *param) +{ + return EOPNOTSUPP; +} + +__API__ int sched_yield(void) +{ + tos_task_yield(); + + return 0; +} + diff --git a/osal/posix/semaphore.c b/osal/posix/semaphore.c new file mode 100644 index 00000000..0618d267 --- /dev/null +++ b/osal/posix/semaphore.c @@ -0,0 +1,137 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "private/posix_config.h" + +#include "errno.h" +#include "semaphore.h" +#include "private/time.h" + +#if POSIX_CFG_SEM_EN > 0u + +__NOTSUPP__ int sem_close(sem_t *sem) +{ + return EOPNOTSUPP; +} + +__API__ int sem_destroy(sem_t *sem) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(sem, EINVAL); + + kerr = tos_sem_destroy((k_sem_t *)sem); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int sem_getvalue(sem_t *sem, int *sval) +{ + TOS_PTR_SANITY_CHECK_RC(sem, EINVAL); + TOS_PTR_SANITY_CHECK_RC(sval, EINVAL); + + *sval = ((k_sem_t *)sem)->count; + return 0; +} + +__API__ int sem_init(sem_t *sem, int pshared, unsigned value) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(sem, EINVAL); + + kerr = tos_sem_create((k_sem_t *)sem, value); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__NOTSUPP__ sem_t *sem_open(const char *name, int oflag, ...) +{ + return K_NULL; +} + +__API__ int sem_post(sem_t *sem) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(sem, EINVAL); + + kerr = tos_sem_post((k_sem_t *)sem); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int sem_timedwait(sem_t *sem, const struct timespec *abstime) +{ + k_err_t kerr; + k_tick_t ktick; + + TOS_PTR_SANITY_CHECK_RC(sem, EINVAL); + + + ktick = timespec_to_ktick(abstime); + kerr = tos_sem_pend((k_sem_t *)sem, ktick); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__API__ int sem_trywait(sem_t *sem) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(sem, EINVAL); + + kerr = tos_sem_pend((k_sem_t *)sem, TOS_TIME_NOWAIT); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__NOTSUPP__ int sem_unlink(const char *name) +{ + return EOPNOTSUPP; +} + +__API__ int sem_wait(sem_t *sem) +{ + k_err_t kerr; + + TOS_PTR_SANITY_CHECK_RC(sem, EINVAL); + + kerr = tos_sem_pend((k_sem_t *)sem, TOS_TIME_FOREVER); + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +#endif /* POSIX_CFG_SEM_EN */ diff --git a/osal/posix/time.c b/osal/posix/time.c new file mode 100644 index 00000000..5d6059ad --- /dev/null +++ b/osal/posix/time.c @@ -0,0 +1,180 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "tos_k.h" + +#include "private/posix_config.h" + +#include "errno.h" +#include "time.h" +#include "private/time.h" +#include "private/timer.h" + +__API__ clock_t clock(void) +{ + return tos_systick_get(); +} + +__API__ int clock_gettime(clockid_t clock_id, struct timespec *tp) +{ + k_tick_t ktick; + + TOS_PTR_SANITY_CHECK_RC(tp, EINVAL); + + if (clock_id != CLOCK_REALTIME) { + return EINVAL; + } + + /* use systick rather than rtc now */ + ktick = tos_systick_get(); + + ktick_to_timespec(ktick, tp); + + return 0; +} + +#if POSIX_CFG_TIMER_EN > 0u + +__STATIC__ void timer_callback(void *arg) +{ + ptimer_ctl_t *the_ctl; + + the_ctl = (ptimer_ctl_t *)arg; + + the_ctl->sigev_notify_function(the_ctl->sigev_value); +} + +__API__ int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid) +{ + k_err_t kerr; + timer_t id; + ptimer_ctl_t *the_ctl; + + TOS_PTR_SANITY_CHECK_RC(timerid, EINVAL); + TOS_PTR_SANITY_CHECK_RC(evp, EINVAL); + TOS_PTR_SANITY_CHECK_RC(evp->sigev_notify_function, EINVAL); + + id = timer_id_alloc(); + if (id == -1) { + return ENOMEM; + } + + clockid = clockid; /* make compiler happy */ + + the_ctl = (ptimer_ctl_t *)tos_mmheap_alloc(sizeof(ptimer_ctl_t)); + if (!the_ctl) { + return ENOMEM; + } + + the_ctl->sigev_notify_function = evp->sigev_notify_function; + the_ctl->sigev_value = evp->sigev_value; + + kerr = tos_timer_create((k_timer_t *)&the_ctl->ktimer, 1u, 1u, + timer_callback, the_ctl, + TOS_OPT_TIMER_PERIODIC); + if (kerr != K_ERR_NONE) { + tos_mmheap_free(the_ctl); + return EBUSY; + } + + + the_ctl->id = id; + timer_id_add(id, the_ctl); + + return 0; +} + +__API__ int timer_delete(timer_t timerid) +{ + k_err_t kerr; + ptimer_ctl_t *the_ctl; + + TOS_PTR_SANITY_CHECK_RC(timerid, EINVAL); + + the_ctl = timer_by_id(timerid); + if (!the_ctl) { + return EINVAL; + } + + kerr = tos_timer_destroy(&the_ctl->ktimer); + timer_id_free(timerid); + tos_mmheap_free(the_ctl); + + if (kerr == K_ERR_NONE) { + return 0; + } + + return EINVAL; +} + +__NOTSUPP__ int timer_getoverrun(timer_t timerid) +{ + return EOPNOTSUPP; +} + +__API__ int timer_gettime(timer_t timerid, struct itimerspec *value) +{ + k_tick_t expires, period; + ptimer_ctl_t *the_ctl; + + the_ctl = timer_by_id(timerid); + if (!the_ctl) { + return EINVAL; + } + + if (!value) { + return 0; + } + + expires = the_ctl->ktimer.expires; + period = the_ctl->ktimer.period; + + ktick_to_timespec(expires, &value->it_value); + ktick_to_timespec(period, &value->it_interval); + + return 0; +} + +__API__ int timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue) +{ + k_tick_t delay, period; + ptimer_ctl_t *the_ctl; + + TOS_PTR_SANITY_CHECK_RC(value, EINVAL); + + the_ctl = timer_by_id(timerid); + if (!the_ctl) { + return EINVAL; + } + + if (ovalue) { + timer_gettime(timerid, ovalue); + } + + delay = timespec_to_ktick(&value->it_value); + period = timespec_to_ktick(&value->it_interval); + + tos_timer_stop(&the_ctl->ktimer); + tos_timer_delay_change(&the_ctl->ktimer, delay); + tos_timer_period_change(&the_ctl->ktimer, period); + tos_timer_start(&the_ctl->ktimer); + + return 0; +} + +#endif /* POSIX_CFG_TIMER_EN */ + diff --git a/osal/posix/time_prv.c b/osal/posix/time_prv.c new file mode 100644 index 00000000..935c0bcc --- /dev/null +++ b/osal/posix/time_prv.c @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "time.h" +#include "private/time.h" + +__KNL__ k_tick_t timespec_to_ktick(const struct timespec *tp) +{ + int nsecond, second; + struct timespec curr_tp; + + TOS_PTR_SANITY_CHECK_RC(tp, (k_tick_t)-1); + + clock_gettime(CLOCK_REALTIME, &curr_tp); + + if (tp->tv_nsec - curr_tp.tv_nsec < 0) { + nsecond = NANOSECOND_PER_SECOND - (curr_tp.tv_nsec - tp->tv_nsec); + second = tp->tv_sec - curr_tp.tv_sec - 1; + } else { + nsecond = tp->tv_nsec - curr_tp.tv_nsec; + second = tp->tv_sec - curr_tp.tv_sec; + } + + if (second < 0) { + return (k_tick_t)0u; + } + + return (k_tick_t)(second * TOS_CFG_CPU_TICK_PER_SECOND + nsecond * TOS_CFG_CPU_TICK_PER_SECOND / NANOSECOND_PER_SECOND); +} + +__KNL__ void ktick_to_timespec(k_tick_t ktick, struct timespec *tp) +{ + if (!tp) { + return; + } + + tp->tv_sec = ktick / TOS_CFG_CPU_TICK_PER_SECOND; + tp->tv_nsec = (ktick % TOS_CFG_CPU_TICK_PER_SECOND) * ((long)1000000000 / TOS_CFG_CPU_TICK_PER_SECOND); +} + diff --git a/osal/posix/timer_prv.c b/osal/posix/timer_prv.c new file mode 100644 index 00000000..a66e6ff4 --- /dev/null +++ b/osal/posix/timer_prv.c @@ -0,0 +1,97 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "tos_k.h" + +#include "time.h" +#include "private/timer.h" + +__STATIC__ ptimer_ctl_t *ptimer_ctl_table[TIMERS_MAX] = { 0 }; + +__KNL__ int timer_id_add(timer_t id, ptimer_ctl_t *ptimer_ctl) +{ + TOS_CPU_CPSR_ALLOC(); + + if (id < 0 || + id >= TOS_COUNT_OF(ptimer_ctl_table) || + ptimer_ctl_table[id]) { + return -1; + } + + TOS_CPU_INT_DISABLE(); + + ptimer_ctl_table[id] = ptimer_ctl; + + TOS_CPU_INT_ENABLE(); + + return 0; +} + +__KNL__ timer_t timer_id_alloc(void) +{ + TOS_CPU_CPSR_ALLOC(); + int i = 0; + + TOS_CPU_INT_DISABLE(); + + for (i = 0; i < TOS_COUNT_OF(ptimer_ctl_table); ++i) { + if (!ptimer_ctl_table[i]) { + TOS_CPU_INT_ENABLE(); + return (timer_t)i; + } + } + + TOS_CPU_INT_ENABLE(); + return -1; +} + +__KNL__ int timer_id_free(timer_t id) +{ + TOS_CPU_CPSR_ALLOC(); + + if (id < 0 || + id >= TOS_COUNT_OF(ptimer_ctl_table) || + !ptimer_ctl_table[id]) { + return -1; + } + + TOS_CPU_INT_DISABLE(); + + ptimer_ctl_table[id] = K_NULL; + + TOS_CPU_INT_ENABLE(); + + return 0; +} + +__KNL__ ptimer_ctl_t *timer_by_id(timer_t id) +{ + ptimer_ctl_t *the_ctl; + + the_ctl = ptimer_ctl_table[id]; + + if (!the_ctl) { + return K_NULL; + } + + if (the_ctl->id != id) { + return K_NULL; + } + + return the_ctl; +} + diff --git a/osal/posix/tos_posix.c b/osal/posix/tos_posix.c new file mode 100644 index 00000000..9f6c899e --- /dev/null +++ b/osal/posix/tos_posix.c @@ -0,0 +1,26 @@ +/*---------------------------------------------------------------------------- + * Tencent is pleased to support the open source community by making TencentOS + * available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * If you have downloaded a copy of the TencentOS binary from Tencent, please + * note that the TencentOS binary is licensed under the BSD 3-Clause License. + * + * If you have downloaded a copy of the TencentOS source code from Tencent, + * please note that TencentOS source code is licensed under the BSD 3-Clause + * License, except for the third-party components listed below which are + * subject to different license terms. Your integration of TencentOS into your + * own projects may require compliance with the BSD 3-Clause License, as well + * as the other licenses applicable to the third-party components included + * within TencentOS. + *---------------------------------------------------------------------------*/ + +#include "tos_k.h" + +#include "private/pthread.h" + +__API__ int tos_posix_init(void) +{ + return pthread_init(); +} +