Browse Source

move: 移动freertos和mbedtls到顶层的components目录

Wendal Chen 4 years ago
parent
commit
f998a099bd
100 changed files with 1236 additions and 7 deletions
  1. 29 7
      bsp/win32/CMakeLists.txt
  2. 16 0
      bsp/win32/main.lua
  3. 396 0
      bsp/win32/module_test/sys.lua
  4. 0 0
      components/freertos/croutine.c
  5. 0 0
      components/freertos/event_groups.c
  6. 0 0
      components/freertos/heap_4.c
  7. 0 0
      components/freertos/include/FreeRTOS.h
  8. 0 0
      components/freertos/include/FreeRTOSConfig.h
  9. 0 0
      components/freertos/include/StackMacros.h
  10. 0 0
      components/freertos/include/atomic.h
  11. 0 0
      components/freertos/include/croutine.h
  12. 0 0
      components/freertos/include/deprecated_definitions.h
  13. 0 0
      components/freertos/include/event_groups.h
  14. 0 0
      components/freertos/include/list.h
  15. 0 0
      components/freertos/include/message_buffer.h
  16. 0 0
      components/freertos/include/mpu_prototypes.h
  17. 0 0
      components/freertos/include/mpu_wrappers.h
  18. 0 0
      components/freertos/include/portable.h
  19. 0 0
      components/freertos/include/projdefs.h
  20. 0 0
      components/freertos/include/queue.h
  21. 0 0
      components/freertos/include/semphr.h
  22. 0 0
      components/freertos/include/stack_macros.h
  23. 0 0
      components/freertos/include/stdint.readme
  24. 0 0
      components/freertos/include/stream_buffer.h
  25. 0 0
      components/freertos/include/task.h
  26. 0 0
      components/freertos/include/timers.h
  27. 0 0
      components/freertos/list.c
  28. 0 0
      components/freertos/portable/MSVC-MingW/port.c
  29. 0 0
      components/freertos/portable/MSVC-MingW/portmacro.h
  30. 5 0
      components/freertos/portable/ThirdParty/GCC/Posix/FreeRTOS-simulator-for-Linux.url
  31. 562 0
      components/freertos/portable/ThirdParty/GCC/Posix/port.c
  32. 134 0
      components/freertos/portable/ThirdParty/GCC/Posix/portmacro.h
  33. 76 0
      components/freertos/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c
  34. 18 0
      components/freertos/portable/ThirdParty/GCC/Posix/utils/wait_for_event.h
  35. 0 0
      components/freertos/queue.c
  36. 0 0
      components/freertos/stream_buffer.c
  37. 0 0
      components/freertos/tasks.c
  38. 0 0
      components/freertos/timers.c
  39. 0 0
      components/mbedtls/3rdparty/.gitignore
  40. 0 0
      components/mbedtls/3rdparty/CMakeLists.txt
  41. 0 0
      components/mbedtls/3rdparty/Makefile.inc
  42. 0 0
      components/mbedtls/3rdparty/everest/.gitignore
  43. 0 0
      components/mbedtls/3rdparty/everest/CMakeLists.txt
  44. 0 0
      components/mbedtls/3rdparty/everest/Makefile.inc
  45. 0 0
      components/mbedtls/3rdparty/everest/README.md
  46. 0 0
      components/mbedtls/3rdparty/everest/include/everest/Hacl_Curve25519.h
  47. 0 0
      components/mbedtls/3rdparty/everest/include/everest/everest.h
  48. 0 0
      components/mbedtls/3rdparty/everest/include/everest/kremlib.h
  49. 0 0
      components/mbedtls/3rdparty/everest/include/everest/kremlib/FStar_UInt128.h
  50. 0 0
      components/mbedtls/3rdparty/everest/include/everest/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.h
  51. 0 0
      components/mbedtls/3rdparty/everest/include/everest/kremlin/c_endianness.h
  52. 0 0
      components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/builtin.h
  53. 0 0
      components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/callconv.h
  54. 0 0
      components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/compat.h
  55. 0 0
      components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/debug.h
  56. 0 0
      components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/target.h
  57. 0 0
      components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/types.h
  58. 0 0
      components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/wasmsupport.h
  59. 0 0
      components/mbedtls/3rdparty/everest/include/everest/vs2010/Hacl_Curve25519.h
  60. 0 0
      components/mbedtls/3rdparty/everest/include/everest/vs2010/inttypes.h
  61. 0 0
      components/mbedtls/3rdparty/everest/include/everest/vs2010/stdbool.h
  62. 0 0
      components/mbedtls/3rdparty/everest/include/everest/x25519.h
  63. 0 0
      components/mbedtls/3rdparty/everest/library/Hacl_Curve25519.c
  64. 0 0
      components/mbedtls/3rdparty/everest/library/Hacl_Curve25519_joined.c
  65. 0 0
      components/mbedtls/3rdparty/everest/library/everest.c
  66. 0 0
      components/mbedtls/3rdparty/everest/library/kremlib/FStar_UInt128_extracted.c
  67. 0 0
      components/mbedtls/3rdparty/everest/library/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.c
  68. 0 0
      components/mbedtls/3rdparty/everest/library/legacy/Hacl_Curve25519.c
  69. 0 0
      components/mbedtls/3rdparty/everest/library/x25519.c
  70. 0 0
      components/mbedtls/CMakeLists.txt
  71. 0 0
      components/mbedtls/configs/README.txt
  72. 0 0
      components/mbedtls/configs/config-ccm-psk-tls1_2.h
  73. 0 0
      components/mbedtls/configs/config-mini-tls1_1.h
  74. 0 0
      components/mbedtls/configs/config-no-entropy.h
  75. 0 0
      components/mbedtls/configs/config-psa-crypto.h
  76. 0 0
      components/mbedtls/configs/config-suite-b.h
  77. 0 0
      components/mbedtls/configs/config-symmetric-only.h
  78. 0 0
      components/mbedtls/configs/config-thread.h
  79. 0 0
      components/mbedtls/include/.gitignore
  80. 0 0
      components/mbedtls/include/CMakeLists.txt
  81. 0 0
      components/mbedtls/include/mbedtls/aes.h
  82. 0 0
      components/mbedtls/include/mbedtls/aesni.h
  83. 0 0
      components/mbedtls/include/mbedtls/arc4.h
  84. 0 0
      components/mbedtls/include/mbedtls/aria.h
  85. 0 0
      components/mbedtls/include/mbedtls/asn1.h
  86. 0 0
      components/mbedtls/include/mbedtls/asn1write.h
  87. 0 0
      components/mbedtls/include/mbedtls/base64.h
  88. 0 0
      components/mbedtls/include/mbedtls/bignum.h
  89. 0 0
      components/mbedtls/include/mbedtls/blowfish.h
  90. 0 0
      components/mbedtls/include/mbedtls/bn_mul.h
  91. 0 0
      components/mbedtls/include/mbedtls/camellia.h
  92. 0 0
      components/mbedtls/include/mbedtls/ccm.h
  93. 0 0
      components/mbedtls/include/mbedtls/certs.h
  94. 0 0
      components/mbedtls/include/mbedtls/chacha20.h
  95. 0 0
      components/mbedtls/include/mbedtls/chachapoly.h
  96. 0 0
      components/mbedtls/include/mbedtls/check_config.h
  97. 0 0
      components/mbedtls/include/mbedtls/cipher.h
  98. 0 0
      components/mbedtls/include/mbedtls/cipher_internal.h
  99. 0 0
      components/mbedtls/include/mbedtls/cmac.h
  100. 0 0
      components/mbedtls/include/mbedtls/compat-1.3.h

+ 29 - 7
bsp/win32/CMakeLists.txt

@@ -15,14 +15,26 @@ project (luatos)
 # 一定一定要先添加本地的头文件
 include_directories(./include)
 
-include_directories(${TOPROOT}/lua/include ${TOPROOT}/luat/include ./freertos/include ./freertos/portable/MSVC-MingW)
+include_directories(${TOPROOT}/lua/include 
+                    ${TOPROOT}/luat/include 
+                    ${TOPROOT}/components/freertos/include 
+                    )
+IF (WIN32)
+     include_directories(${TOPROOT}/components/freertos/portable/MSVC-MingW)
+     aux_source_directory(${TOPROOT}/components/freertos/portable/MSVC-MingW MM_SRCS)
+ELSE ()
+     include_directories(${TOPROOT}/components/freertos/portable/ThirdParty/GCC/Posix)
+     include_directories(${TOPROOT}/components/freertos/portable/ThirdParty/GCC/Posix/utils)
+     aux_source_directory(${TOPROOT}/components/freertos/portable/ThirdParty/GCC/Posix 
+                          ${TOPROOT}/components/freertos/portable/ThirdParty/GCC/Posix/utils
+                          MM_SRCS)
+ENDIF ()
 
 aux_source_directory(./port PORT_SRCS)
 aux_source_directory(${TOPROOT}/lua/src LUA_SRCS)
 #aux_source_directory(${TOPROOT}/luat/freertos FTOS_T_SRCS)
-aux_source_directory(./freertos RTOS_SRCS)
-aux_source_directory(./freertos/port RTOS_PORT_SRCS)
-aux_source_directory(./freertos/portable/MSVC-MingW MM_SRCS)
+aux_source_directory(${TOPROOT}/components/freertos RTOS_SRCS)
+aux_source_directory(${TOPROOT}/components/freertos/port RTOS_PORT_SRCS)
 aux_source_directory(${TOPROOT}/luat/packages/lua-cjson CJSON_SRCS)
 
 add_library(freertos10 ${PORT_SRCS} ${RTOS_SRCS} ${RTOS_PORT_SRCS} ${MM_SRCS})
@@ -44,6 +56,7 @@ add_library(luat ${TOPROOT}/luat/modules/luat_main.c
                  ${TOPROOT}/luat/modules/luat_luadb.c
             )
 
+IF (WIN32)
 #-----------------------
 # LuaFileSystem --> lfs
 aux_source_directory(./rock/LuaFileSystem ROCK_LFS_SRCS)
@@ -57,13 +70,22 @@ aux_source_directory(./rock/librs232/src ROCK_LIB_RS232_SRCS)
 add_library(rock_librs232 ${ROCK_LIB_RS232_SRCS} ./rock/librs232/bindings/lua/luars232.c)
 #------------------------
 
+ENDIF ()
+
 #-----------------------
-# LuaFileSystem --> lfs
-include_directories(./rock/mbedtls/include)
-add_subdirectory(rock/mbedtls)
+# mbedtls
+include_directories(${TOPROOT}/components/mbedtls/include)
+add_subdirectory(${TOPROOT}/components/mbedtls mbedtls.out)
 #-----------------------
 
+
+IF (WIN32)
 # 指定生成目标
 add_executable(luatos src/main_win32.c)
 target_link_libraries(luat freertos10 winmm)
 target_link_libraries(luatos freertos10 lua luatos_msys luat winmm cjson rock_lfs rock_librs232 mbedtls)
+ELSE ()
+add_executable(luatos src/main_posix.c)
+target_link_libraries(luat freertos10 pthread)
+target_link_libraries(luatos freertos10 lua luatos_msys luat pthread cjson mbedtls)
+ENDIF ()

+ 16 - 0
bsp/win32/main.lua

@@ -0,0 +1,16 @@
+
+
+local sys = require "sys"
+
+log.info("sys", "from win32")
+
+sys.taskInit(function ()
+    while true do
+        log.info("hi", os.date())
+        log.info("sys", rtos.meminfo("sys"))
+        log.info("lua", rtos.meminfo("lua"))
+        sys.wait(1000)
+    end
+end)
+
+sys.run()

+ 396 - 0
bsp/win32/module_test/sys.lua

@@ -0,0 +1,396 @@
+--- 模块功能:Luat协程调度框架
+--module(..., package.seeall)
+
+local sys = {}
+
+local table = _G.table
+local unpack = table.unpack
+local rtos = _G.rtos
+local coroutine = _G.coroutine
+local log = _G.log
+
+-- lib脚本版本号,只要lib中的任何一个脚本做了修改,都需要更新此版本号
+SCRIPT_LIB_VER = "1.0.0"
+
+-- TaskID最大值
+local TASK_TIMER_ID_MAX = 0x1FFFFF
+-- msgId 最大值(请勿修改否则会发生msgId碰撞的危险)
+local MSG_TIMER_ID_MAX = 0x7FFFFF
+
+-- 任务定时器id
+local taskTimerId = 0
+-- 消息定时器id
+local msgId = TASK_TIMER_ID_MAX
+-- 定时器id表
+local timerPool = {}
+local taskTimerPool = {}
+--消息定时器参数表
+local para = {}
+--定时器是否循环表
+local loop = {}
+--lua脚本运行出错时,是否回退为本地烧写的版本
+local sRollBack = true
+
+_G.COROUTINE_ERROR_ROLL_BACK = true
+_G.COROUTINE_ERROR_RESTART = true
+
+-- 对coroutine.resume加一个修饰器用于捕获协程错误
+local rawcoresume = coroutine.resume
+sys.coresume = function(...)
+    function wrapper(co,...)
+        local arg = {...}
+        if not arg[1] then
+            local traceBack = debug.traceback(co)
+            traceBack = (traceBack and traceBack~="") and (arg[2].."\r\n"..traceBack) or arg[2]
+            log.error("coroutine.resume",traceBack)
+            if errDump and type(errDump.appendErr)=="function" then
+                errDump.appendErr(traceBack)
+            end
+            if _G.COROUTINE_ERROR_ROLL_BACK then
+                sys.timerStart(assert,500,false,traceBack)
+            elseif _G.COROUTINE_ERROR_RESTART then
+                rtos.reboot()
+            end
+        end
+        return ...
+    end
+    local arg = {...}
+    return wrapper(arg[1], rawcoresume(...))
+end
+
+--- Task任务延时函数,只能用于任务函数中
+-- @number ms  整数,最大等待126322567毫秒
+-- @return 定时结束返回nil,被其他线程唤起返回调用线程传入的参数
+-- @usage sys.wait(30)
+function sys.wait(ms)
+    -- 参数检测,参数不能为负值
+    --assert(ms > 0, "The wait time cannot be negative!")
+    -- 选一个未使用的定时器ID给该任务线程
+    if taskTimerId >= TASK_TIMER_ID_MAX then taskTimerId = 0 end
+    taskTimerId = taskTimerId + 1
+    local timerid = taskTimerId
+    taskTimerPool[coroutine.running()] = timerid
+    timerPool[timerid] = coroutine.running()
+    -- 调用core的rtos定时器
+    if 1 ~= rtos.timer_start(timerid, ms) then log.debug("rtos.timer_start error") return end
+    -- 挂起调用的任务线程
+    local message = {coroutine.yield()}
+    if #message ~= 0 then
+        rtos.timer_stop(timerid)
+        taskTimerPool[coroutine.running()] = nil
+        timerPool[timerid] = nil
+        return unpack(message)
+    end
+end
+
+--- Task任务的条件等待函数(包括事件消息和定时器消息等条件),只能用于任务函数中。
+-- @param id 消息ID
+-- @number ms 等待超时时间,单位ms,最大等待126322567毫秒
+-- @return result 接收到消息返回true,超时返回false
+-- @return data 接收到消息返回消息参数
+-- @usage result, data = sys.waitUntil("SIM_IND", 120000)
+function sys.waitUntil(id, ms)
+    sys.subscribe(id, coroutine.running())
+    local message = ms and {sys.wait(ms)} or {coroutine.yield()}
+    sys.unsubscribe(id, coroutine.running())
+    return message[1] ~= nil, unpack(message, 2, #message)
+end
+
+--- Task任务的条件等待函数扩展(包括事件消息和定时器消息等条件),只能用于任务函数中。
+-- @param id 消息ID
+-- @number ms 等待超时时间,单位ms,最大等待126322567毫秒
+-- @return message 接收到消息返回message,超时返回false
+-- @return data 接收到消息返回消息参数
+-- @usage result, data = sys.waitUntilExt("SIM_IND", 120000)
+function sys.waitUntilExt(id, ms)
+    sys.subscribe(id, coroutine.running())
+    local message = ms and {sys.wait(ms)} or {coroutine.yield()}
+    sys.unsubscribe(id, coroutine.running())
+    if message[1] ~= nil then return unpack(message) end
+    return false
+end
+
+--- 创建一个任务线程,在模块最末行调用该函数并注册模块中的任务函数,main.lua导入该模块即可
+-- @param fun 任务函数名,用于resume唤醒时调用
+-- @param ... 任务函数fun的可变参数
+-- @return co  返回该任务的线程号
+-- @usage sys.taskInit(task1,'a','b')
+function sys.taskInit(fun, ...)
+    local co = coroutine.create(fun)
+    sys.coresume(co, ...)
+    return co
+end
+
+------------------------------------------ rtos消息回调处理部分 ------------------------------------------
+--[[
+函数名:cmpTable
+功能  :比较两个table的内容是否相同,注意:table中不能再包含table
+参数  :
+t1:第一个table
+t2:第二个table
+返回值:相同返回true,否则false
+]]
+local function cmpTable(t1, t2)
+    if not t2 then return #t1 == 0 end
+    if #t1 == #t2 then
+        for i = 1, #t1 do
+            if unpack(t1, i, i) ~= unpack(t2, i, i) then
+                return false
+            end
+        end
+        return true
+    end
+    return false
+end
+
+--- 关闭定时器
+-- @param val 值为number时,识别为定时器ID,值为回调函数时,需要传参数
+-- @param ... val值为函数时,函数的可变参数
+-- @return 无
+-- @usage timerStop(1)
+function sys.timerStop(val, ...)
+    -- val 为定时器ID
+    if type(val) == 'number' then
+        timerPool[val], para[val] = nil
+        rtos.timer_stop(val)
+    else
+        for k, v in pairs(timerPool) do
+            -- 回调函数相同
+            if type(v) == 'table' and v.cb == val or v == val then
+                -- 可变参数相同
+                if cmpTable({...}, para[k]) then
+                    rtos.timer_stop(k)
+                    timerPool[k], para[k] = nil
+                    break
+                end
+            end
+        end
+    end
+end
+
+--- 关闭同一回调函数的所有定时器
+-- @param fnc 定时器回调函数
+-- @return 无
+-- @usage timerStopAll(cbFnc)
+function sys.timerStopAll(fnc)
+    for k, v in pairs(timerPool) do
+        if type(v) == "table" and v.cb == fnc or v == fnc then
+            rtos.timer_stop(k)
+            timerPool[k], para[k] = nil
+        end
+    end
+end
+
+function sys.timerAdvStart(fnc, ms, _repeat, ...)
+    --回调函数和时长检测
+    --assert(fnc ~= nil, "sys.timerStart(first param) is nil !")
+    --assert(ms > 0, "sys.timerStart(Second parameter) is <= zero !")
+    -- 关闭完全相同的定时器
+    local arg = {...}
+    if #arg == 0 then
+        sys.timerStop(fnc)
+    else
+        sys.timerStop(fnc, ...)
+    end
+    -- 为定时器申请ID,ID值 1-20 留给任务,20-30留给消息专用定时器
+    while true do
+        if msgId >= MSG_TIMER_ID_MAX then msgId = TASK_TIMER_ID_MAX end
+        msgId = msgId + 1
+        if timerPool[msgId] == nil then
+            timerPool[msgId] = fnc
+            break
+        end
+    end
+    --调用底层接口启动定时器
+    if rtos.timer_start(msgId, ms, _repeat) ~= 1 then return end
+    --如果存在可变参数,在定时器参数表中保存参数
+    if #arg ~= 0 then
+        para[msgId] = arg
+    end
+    --返回定时器id
+    return msgId
+end
+
+--- 开启一个定时器
+-- @param fnc 定时器回调函数
+-- @number ms 整数,最大定时126322567毫秒
+-- @param ... 可变参数 fnc的参数
+-- @return number 定时器ID,如果失败,返回nil
+function sys.timerStart(fnc, ms, ...)
+    return sys.timerAdvStart(fnc, ms, 0, ...)
+end
+
+--- 开启一个循环定时器
+-- @param fnc 定时器回调函数
+-- @number ms 整数,最大定时126322567毫秒
+-- @param ... 可变参数 fnc的参数
+-- @return number 定时器ID,如果失败,返回nil
+function sys.timerLoopStart(fnc, ms, ...)
+    return sys.timerAdvStart(fnc, ms, -1, ...)
+end
+
+--- 判断某个定时器是否处于开启状态
+-- @param val 有两种形式
+--一种是开启定时器时返回的定时器id,此形式时不需要再传入可变参数...就能唯一标记一个定时器
+--另一种是开启定时器时的回调函数,此形式时必须再传入可变参数...才能唯一标记一个定时器
+-- @param ... 可变参数
+-- @return number 开启状态返回true,否则nil
+function sys.timerIsActive(val, ...)
+    if type(val) == "number" then
+        return timerPool[val]
+    else
+        for k, v in pairs(timerPool) do
+            if v == val then
+                if cmpTable({...}, para[k]) then return true end
+            end
+        end
+    end
+end
+
+
+------------------------------------------ LUA应用消息订阅/发布接口 ------------------------------------------
+-- 订阅者列表
+local subscribers = {}
+--内部消息队列
+local messageQueue = {}
+
+--- 订阅消息
+-- @param id 消息id
+-- @param callback 消息回调处理
+-- @usage subscribe("NET_STATUS_IND", callback)
+function sys.subscribe(id, callback)
+    --if not id or type(id) == "boolean" or (type(callback) ~= "function" and type(callback) ~= "thread") then
+    --    log.warn("warning: sys.subscribe invalid parameter", id, callback)
+    --    return
+    --end
+    --log.debug("sys", "subscribe", id, callback)
+    if type(id) == "table" then
+        -- 支持多topic订阅
+        for _, v in pairs(id) do sys.subscribe(v, callback) end
+        return
+    end
+    if not subscribers[id] then subscribers[id] = {} end
+    subscribers[id][callback] = true
+end
+--- 取消订阅消息
+-- @param id 消息id
+-- @param callback 消息回调处理
+-- @usage unsubscribe("NET_STATUS_IND", callback)
+function sys.unsubscribe(id, callback)
+    --if not id or type(id) == "boolean" or (type(callback) ~= "function" and type(callback) ~= "thread") then
+    --    log.warn("warning: sys.unsubscribe invalid parameter", id, callback)
+    --    return
+    --end
+    --log.debug("sys", "unsubscribe", id, callback)
+    if type(id) == "table" then
+        -- 支持多topic订阅
+        for _, v in pairs(id) do sys.unsubscribe(v, callback) end
+        return
+    end
+    if subscribers[id] then subscribers[id][callback] = nil end
+    -- 判断消息是否无其他订阅
+    for k, _ in pairs(subscribers[id]) do
+        return
+    end
+    subscribers[id] = nil
+end
+
+--- 发布内部消息,存储在内部消息队列中
+-- @param ... 可变参数,用户自定义
+-- @return 无
+-- @usage publish("NET_STATUS_IND")
+function sys.publish(...)
+    table.insert(messageQueue, {...})
+end
+
+-- 分发消息
+local function dispatch()
+    while true do
+        if #messageQueue == 0 then
+            break
+        end
+        local message = table.remove(messageQueue, 1)
+        if subscribers[message[1]] then
+            for callback, _ in pairs(subscribers[message[1]]) do
+                if type(callback) == "function" then
+                    callback(unpack(message, 2, #message))
+                elseif type(callback) == "thread" then
+                    sys.coresume(callback, unpack(message))
+                end
+            end
+        end
+    end
+end
+
+-- rtos消息回调
+--local handlers = {}
+--setmetatable(handlers, {__index = function() return function() end end, })
+
+--- 注册rtos消息回调处理函数
+-- @number id 消息类型id
+-- @param handler 消息处理函数
+-- @return 无
+-- @usage rtos.on(rtos.MSG_KEYPAD, function(param) handle keypad message end)
+--function sys.on(id, handler)
+--    handlers[id] = handler
+--end
+
+------------------------------------------ Luat 主调度框架  ------------------------------------------
+local function safeRun()
+    -- 分发内部消息
+    dispatch()
+    -- 阻塞读取外部消息
+    local msg, param, exparam = rtos.receive(rtos.INF_TIMEOUT)
+    --log.info("sys", msg, param, exparam, tableNSize(timerPool), tableNSize(para), tableNSize(taskTimerPool), tableNSize(subscribers))
+    -- 空消息?
+    if not msg or msg == 0 then
+        -- 无任何操作
+    -- 判断是否为定时器消息,并且消息是否注册
+    elseif msg == rtos.MSG_TIMER and timerPool[param] then
+        if param < TASK_TIMER_ID_MAX then
+            local taskId = timerPool[param]
+            timerPool[param] = nil
+            if taskTimerPool[taskId] == param then
+                taskTimerPool[taskId] = nil
+                sys.coresume(taskId)
+            end
+        else
+            local cb = timerPool[param]
+            --如果不是循环定时器,从定时器id表中删除此定时器
+            if exparam == 0 then timerPool[param] = nil end
+            if para[param] ~= nil then
+                cb(unpack(para[param]))
+                if exparam == 0 then para[param] = nil end
+            else
+                cb()
+            end
+            --如果是循环定时器,继续启动此定时器
+            --if loop[param] then rtos.timer_start(param, loop[param]) end
+        end
+    --其他消息(音频消息、充电管理消息、按键消息等)
+    --elseif type(msg) == "number" then
+    --    handlers[msg](param, exparam)
+    --else
+    --    handlers[msg.id](msg)
+    end
+end
+
+--- run()从底层获取core消息并及时处理相关消息,查询定时器并调度各注册成功的任务线程运行和挂起
+-- @return 无
+-- @usage sys.run()
+function sys.run()
+    local result, err
+    while true do
+        --if sRollBack then
+            safeRun()
+        --else
+        --    result, err = pcall(safeRun)
+        --    if not result then rtos.restart(err) end
+        --end
+    end
+end
+
+_G.sys_pub = sys.publish
+
+return sys
+----------------------------

+ 0 - 0
bsp/win32/freertos/croutine.c → components/freertos/croutine.c


+ 0 - 0
bsp/win32/freertos/event_groups.c → components/freertos/event_groups.c


+ 0 - 0
bsp/win32/freertos/heap_4.c → components/freertos/heap_4.c


+ 0 - 0
bsp/win32/freertos/include/FreeRTOS.h → components/freertos/include/FreeRTOS.h


+ 0 - 0
bsp/win32/freertos/include/FreeRTOSConfig.h → components/freertos/include/FreeRTOSConfig.h


+ 0 - 0
bsp/win32/freertos/include/StackMacros.h → components/freertos/include/StackMacros.h


+ 0 - 0
bsp/win32/freertos/include/atomic.h → components/freertos/include/atomic.h


+ 0 - 0
bsp/win32/freertos/include/croutine.h → components/freertos/include/croutine.h


+ 0 - 0
bsp/win32/freertos/include/deprecated_definitions.h → components/freertos/include/deprecated_definitions.h


+ 0 - 0
bsp/win32/freertos/include/event_groups.h → components/freertos/include/event_groups.h


+ 0 - 0
bsp/win32/freertos/include/list.h → components/freertos/include/list.h


+ 0 - 0
bsp/win32/freertos/include/message_buffer.h → components/freertos/include/message_buffer.h


+ 0 - 0
bsp/win32/freertos/include/mpu_prototypes.h → components/freertos/include/mpu_prototypes.h


+ 0 - 0
bsp/win32/freertos/include/mpu_wrappers.h → components/freertos/include/mpu_wrappers.h


+ 0 - 0
bsp/win32/freertos/include/portable.h → components/freertos/include/portable.h


+ 0 - 0
bsp/win32/freertos/include/projdefs.h → components/freertos/include/projdefs.h


+ 0 - 0
bsp/win32/freertos/include/queue.h → components/freertos/include/queue.h


+ 0 - 0
bsp/win32/freertos/include/semphr.h → components/freertos/include/semphr.h


+ 0 - 0
bsp/win32/freertos/include/stack_macros.h → components/freertos/include/stack_macros.h


+ 0 - 0
bsp/win32/freertos/include/stdint.readme → components/freertos/include/stdint.readme


+ 0 - 0
bsp/win32/freertos/include/stream_buffer.h → components/freertos/include/stream_buffer.h


+ 0 - 0
bsp/win32/freertos/include/task.h → components/freertos/include/task.h


+ 0 - 0
bsp/win32/freertos/include/timers.h → components/freertos/include/timers.h


+ 0 - 0
bsp/win32/freertos/list.c → components/freertos/list.c


+ 0 - 0
bsp/win32/freertos/portable/MSVC-MingW/port.c → components/freertos/portable/MSVC-MingW/port.c


+ 0 - 0
bsp/win32/freertos/portable/MSVC-MingW/portmacro.h → components/freertos/portable/MSVC-MingW/portmacro.h


+ 5 - 0
components/freertos/portable/ThirdParty/GCC/Posix/FreeRTOS-simulator-for-Linux.url

@@ -0,0 +1,5 @@
+[{000214A0-0000-0000-C000-000000000046}]
+Prop3=19,11
+[InternetShortcut]
+IDList=
+URL=https://www.freertos.org/FreeRTOS-simulator-for-Linux.html

+ 562 - 0
components/freertos/portable/ThirdParty/GCC/Posix/port.c

@@ -0,0 +1,562 @@
+/*
+ * FreeRTOS Kernel V10.4.3
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * https://www.FreeRTOS.org
+ * https://github.com/FreeRTOS
+ *
+ */
+
+/*-----------------------------------------------------------
+ * Implementation of functions defined in portable.h for the Posix port.
+ *
+ * Each task has a pthread which eases use of standard debuggers
+ * (allowing backtraces of tasks etc). Threads for tasks that are not
+ * running are blocked in sigwait().
+ *
+ * Task switch is done by resuming the thread for the next task by
+ * signaling the condition variable and then waiting on a condition variable
+ * with the current thread.
+ *
+ * The timer interrupt uses SIGALRM and care is taken to ensure that
+ * the signal handler runs only on the thread for the current task.
+ *
+ * Use of part of the standard C library requires care as some
+ * functions can take pthread mutexes internally which can result in
+ * deadlocks as the FreeRTOS kernel can switch tasks while they're
+ * holding a pthread mutex.
+ *
+ * stdio (printf() and friends) should be called from a single task
+ * only or serialized with a FreeRTOS primitive such as a binary
+ * semaphore or mutex.
+ *----------------------------------------------------------*/
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/times.h>
+#include <time.h>
+
+/* Scheduler includes. */
+#include "FreeRTOS.h"
+#include "task.h"
+#include "timers.h"
+#include "utils/wait_for_event.h"
+/*-----------------------------------------------------------*/
+
+#define SIG_RESUME SIGUSR1
+
+typedef struct THREAD
+{
+    pthread_t pthread;
+    pdTASK_CODE pxCode;
+    void *pvParams;
+    BaseType_t xDying;
+    struct event *ev;
+} Thread_t;
+
+/*
+ * The additional per-thread data is stored at the beginning of the
+ * task's stack.
+ */
+static inline Thread_t *prvGetThreadFromTask(TaskHandle_t xTask)
+{
+StackType_t *pxTopOfStack = *(StackType_t **)xTask;
+
+    return (Thread_t *)(pxTopOfStack + 1);
+}
+
+/*-----------------------------------------------------------*/
+
+static pthread_once_t hSigSetupThread = PTHREAD_ONCE_INIT;
+static sigset_t xResumeSignals;
+static sigset_t xAllSignals;
+static sigset_t xSchedulerOriginalSignalMask;
+static pthread_t hMainThread = ( pthread_t )NULL;
+static volatile portBASE_TYPE uxCriticalNesting;
+/*-----------------------------------------------------------*/
+
+static portBASE_TYPE xSchedulerEnd = pdFALSE;
+/*-----------------------------------------------------------*/
+
+static void prvSetupSignalsAndSchedulerPolicy( void );
+static void prvSetupTimerInterrupt( void );
+static void *prvWaitForStart( void * pvParams );
+static void prvSwitchThread( Thread_t * xThreadToResume,
+                             Thread_t *xThreadToSuspend );
+static void prvSuspendSelf( Thread_t * thread);
+static void prvResumeThread( Thread_t * xThreadId );
+static void vPortSystemTickHandler( int sig );
+static void vPortStartFirstTask( void );
+/*-----------------------------------------------------------*/
+
+static void prvFatalError( const char *pcCall, int iErrno )
+{
+    fprintf( stderr, "%s: %s\n", pcCall, strerror( iErrno ) );
+    abort();
+}
+
+/*
+ * See header file for description.
+ */
+portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack,
+                                       portSTACK_TYPE *pxEndOfStack,
+                                       pdTASK_CODE pxCode, void *pvParameters )
+{
+Thread_t *thread;
+pthread_attr_t xThreadAttributes;
+size_t ulStackSize;
+int iRet;
+
+    (void)pthread_once( &hSigSetupThread, prvSetupSignalsAndSchedulerPolicy );
+
+    /*
+     * Store the additional thread data at the start of the stack.
+     */
+    thread = (Thread_t *)(pxTopOfStack + 1) - 1;
+    pxTopOfStack = (portSTACK_TYPE *)thread - 1;
+    ulStackSize = (pxTopOfStack + 1 - pxEndOfStack) * sizeof(*pxTopOfStack);
+
+    thread->pxCode = pxCode;
+    thread->pvParams = pvParameters;
+    thread->xDying = pdFALSE;
+
+    pthread_attr_init( &xThreadAttributes );
+    pthread_attr_setstack( &xThreadAttributes, pxEndOfStack, ulStackSize );
+
+    thread->ev = event_create();
+
+    vPortEnterCritical();
+
+    iRet = pthread_create( &thread->pthread, &xThreadAttributes,
+                           prvWaitForStart, thread );
+    if ( iRet )
+    {
+        prvFatalError( "pthread_create", iRet );
+    }
+
+    vPortExitCritical();
+
+    return pxTopOfStack;
+}
+/*-----------------------------------------------------------*/
+
+void vPortStartFirstTask( void )
+{
+Thread_t *pxFirstThread = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
+
+    /* Start the first task. */
+    prvResumeThread( pxFirstThread );
+}
+/*-----------------------------------------------------------*/
+
+/*
+ * See header file for description.
+ */
+portBASE_TYPE xPortStartScheduler( void )
+{
+int iSignal;
+sigset_t xSignals;
+
+    hMainThread = pthread_self();
+
+    /* Start the timer that generates the tick ISR(SIGALRM).
+       Interrupts are disabled here already. */
+    prvSetupTimerInterrupt();
+
+    /* Start the first task. */
+    vPortStartFirstTask();
+
+    /* Wait until signaled by vPortEndScheduler(). */
+    sigemptyset( &xSignals );
+    sigaddset( &xSignals, SIG_RESUME );
+
+    while ( !xSchedulerEnd )
+    {
+        sigwait( &xSignals, &iSignal );
+    }
+
+    /* Cancel the Idle task and free its resources */
+#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
+    vPortCancelThread( xTaskGetIdleTaskHandle() );
+#endif
+
+#if ( configUSE_TIMERS == 1 )
+    /* Cancel the Timer task and free its resources */
+    vPortCancelThread( xTimerGetTimerDaemonTaskHandle() );
+#endif /* configUSE_TIMERS */
+
+    /* Restore original signal mask. */
+    (void)pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask,  NULL );
+
+    return 0;
+}
+/*-----------------------------------------------------------*/
+
+void vPortEndScheduler( void )
+{
+struct itimerval itimer;
+struct sigaction sigtick;
+Thread_t *xCurrentThread;
+
+    /* Stop the timer and ignore any pending SIGALRMs that would end
+     * up running on the main thread when it is resumed. */
+    itimer.it_value.tv_sec = 0;
+    itimer.it_value.tv_usec = 0;
+
+    itimer.it_interval.tv_sec = 0;
+    itimer.it_interval.tv_usec = 0;
+    (void)setitimer( ITIMER_REAL, &itimer, NULL );
+
+    sigtick.sa_flags = 0;
+    sigtick.sa_handler = SIG_IGN;
+    sigemptyset( &sigtick.sa_mask );
+    sigaction( SIGALRM, &sigtick, NULL );
+
+    /* Signal the scheduler to exit its loop. */
+    xSchedulerEnd = pdTRUE;
+    (void)pthread_kill( hMainThread, SIG_RESUME );
+
+    xCurrentThread = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
+    prvSuspendSelf(xCurrentThread);
+}
+/*-----------------------------------------------------------*/
+
+void vPortEnterCritical( void )
+{
+    if ( uxCriticalNesting == 0 )
+    {
+        vPortDisableInterrupts();
+    }
+    uxCriticalNesting++;
+}
+/*-----------------------------------------------------------*/
+
+void vPortExitCritical( void )
+{
+    uxCriticalNesting--;
+
+    /* If we have reached 0 then re-enable the interrupts. */
+    if( uxCriticalNesting == 0 )
+    {
+        vPortEnableInterrupts();
+    }
+}
+/*-----------------------------------------------------------*/
+
+void vPortYieldFromISR( void )
+{
+Thread_t *xThreadToSuspend;
+Thread_t *xThreadToResume;
+
+    xThreadToSuspend = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
+
+    vTaskSwitchContext();
+
+    xThreadToResume = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
+
+    prvSwitchThread( xThreadToResume, xThreadToSuspend );
+}
+/*-----------------------------------------------------------*/
+
+void vPortYield( void )
+{
+    vPortEnterCritical();
+
+    vPortYieldFromISR();
+
+    vPortExitCritical();
+}
+/*-----------------------------------------------------------*/
+
+void vPortDisableInterrupts( void )
+{
+    pthread_sigmask( SIG_BLOCK, &xAllSignals, NULL );
+}
+/*-----------------------------------------------------------*/
+
+void vPortEnableInterrupts( void )
+{
+    pthread_sigmask( SIG_UNBLOCK, &xAllSignals, NULL );
+}
+/*-----------------------------------------------------------*/
+
+portBASE_TYPE xPortSetInterruptMask( void )
+{
+    /* Interrupts are always disabled inside ISRs (signals
+       handlers). */
+    return pdTRUE;
+}
+/*-----------------------------------------------------------*/
+
+void vPortClearInterruptMask( portBASE_TYPE xMask )
+{
+}
+/*-----------------------------------------------------------*/
+
+static uint64_t prvGetTimeNs(void)
+{
+struct timespec t;
+
+    clock_gettime(CLOCK_MONOTONIC, &t);
+
+    return t.tv_sec * 1000000000ull + t.tv_nsec;
+}
+
+static uint64_t prvStartTimeNs;
+/* commented as part of the code below in vPortSystemTickHandler,
+ * to adjust timing according to full demo requirements */
+/* static uint64_t prvTickCount; */
+
+/*
+ * Setup the systick timer to generate the tick interrupts at the required
+ * frequency.
+ */
+void prvSetupTimerInterrupt( void )
+{
+struct itimerval itimer;
+int iRet;
+
+    /* Initialise the structure with the current timer information. */
+    iRet = getitimer( ITIMER_REAL, &itimer );
+    if ( iRet )
+    {
+        prvFatalError( "getitimer", errno );
+    }
+
+    /* Set the interval between timer events. */
+    itimer.it_interval.tv_sec = 0;
+    itimer.it_interval.tv_usec = portTICK_RATE_MICROSECONDS;
+
+    /* Set the current count-down. */
+    itimer.it_value.tv_sec = 0;
+    itimer.it_value.tv_usec = portTICK_RATE_MICROSECONDS;
+
+    /* Set-up the timer interrupt. */
+    iRet = setitimer( ITIMER_REAL, &itimer, NULL );
+    if ( iRet )
+    {
+        prvFatalError( "setitimer", errno );
+    }
+
+    prvStartTimeNs = prvGetTimeNs();
+}
+/*-----------------------------------------------------------*/
+
+static void vPortSystemTickHandler( int sig )
+{
+Thread_t *pxThreadToSuspend;
+Thread_t *pxThreadToResume;
+/* uint64_t xExpectedTicks; */
+
+    uxCriticalNesting++; /* Signals are blocked in this signal handler. */
+
+#if ( configUSE_PREEMPTION == 1 )
+    pxThreadToSuspend = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
+#endif
+
+    /* Tick Increment, accounting for any lost signals or drift in
+     * the timer. */
+/*
+ *      Comment code to adjust timing according to full demo requirements
+ *      xExpectedTicks = (prvGetTimeNs() - prvStartTimeNs)
+ *        / (portTICK_RATE_MICROSECONDS * 1000);
+ * do { */
+        xTaskIncrementTick();
+/*        prvTickCount++;
+ *    } while (prvTickCount < xExpectedTicks);
+*/
+
+#if ( configUSE_PREEMPTION == 1 )
+    /* Select Next Task. */
+    vTaskSwitchContext();
+
+    pxThreadToResume = prvGetThreadFromTask( xTaskGetCurrentTaskHandle() );
+
+    prvSwitchThread(pxThreadToResume, pxThreadToSuspend);
+#endif
+
+    uxCriticalNesting--;
+}
+/*-----------------------------------------------------------*/
+
+void vPortThreadDying( void *pxTaskToDelete, volatile BaseType_t *pxPendYield )
+{
+Thread_t *pxThread = prvGetThreadFromTask( pxTaskToDelete );
+
+    pxThread->xDying = pdTRUE;
+}
+
+void vPortCancelThread( void *pxTaskToDelete )
+{
+Thread_t *pxThreadToCancel = prvGetThreadFromTask( pxTaskToDelete );
+
+    /*
+     * The thread has already been suspended so it can be safely cancelled.
+     */
+    pthread_cancel( pxThreadToCancel->pthread );
+    pthread_join( pxThreadToCancel->pthread, NULL );
+    event_delete( pxThreadToCancel->ev );
+}
+/*-----------------------------------------------------------*/
+
+static void *prvWaitForStart( void * pvParams )
+{
+Thread_t *pxThread = pvParams;
+
+    prvSuspendSelf(pxThread);
+
+    /* Resumed for the first time, unblocks all signals. */
+    uxCriticalNesting = 0;
+    vPortEnableInterrupts();
+
+    /* Call the task's entry point. */
+    pxThread->pxCode( pxThread->pvParams );
+
+    /* A function that implements a task must not exit or attempt to return to
+    * its caller as there is nothing to return to. If a task wants to exit it
+    * should instead call vTaskDelete( NULL ). Artificially force an assert()
+    * to be triggered if configASSERT() is defined, so application writers can
+        * catch the error. */
+    configASSERT( pdFALSE );
+
+    return NULL;
+}
+/*-----------------------------------------------------------*/
+
+static void prvSwitchThread( Thread_t *pxThreadToResume,
+                             Thread_t *pxThreadToSuspend )
+{
+BaseType_t uxSavedCriticalNesting;
+
+    if ( pxThreadToSuspend != pxThreadToResume )
+    {
+        /*
+         * Switch tasks.
+         *
+         * The critical section nesting is per-task, so save it on the
+         * stack of the current (suspending thread), restoring it when
+         * we switch back to this task.
+         */
+        uxSavedCriticalNesting = uxCriticalNesting;
+
+        prvResumeThread( pxThreadToResume );
+        if ( pxThreadToSuspend->xDying )
+        {
+            pthread_exit( NULL );
+        }
+        prvSuspendSelf( pxThreadToSuspend );
+
+        uxCriticalNesting = uxSavedCriticalNesting;
+    }
+}
+/*-----------------------------------------------------------*/
+
+static void prvSuspendSelf( Thread_t *thread )
+{
+    /*
+     * Suspend this thread by waiting for a pthread_cond_signal event.
+     *
+     * A suspended thread must not handle signals (interrupts) so
+     * all signals must be blocked by calling this from:
+     *
+     * - Inside a critical section (vPortEnterCritical() /
+     *   vPortExitCritical()).
+     *
+     * - From a signal handler that has all signals masked.
+     *
+     * - A thread with all signals blocked with pthread_sigmask().
+        */
+    event_wait(thread->ev);
+}
+
+/*-----------------------------------------------------------*/
+
+static void prvResumeThread( Thread_t *xThreadId )
+{
+    if ( pthread_self() != xThreadId->pthread )
+    {
+        event_signal(xThreadId->ev);
+    }
+}
+/*-----------------------------------------------------------*/
+
+static void prvSetupSignalsAndSchedulerPolicy( void )
+{
+struct sigaction sigresume, sigtick;
+int iRet;
+
+    hMainThread = pthread_self();
+
+    /* Initialise common signal masks. */
+    sigemptyset( &xResumeSignals );
+    sigaddset( &xResumeSignals, SIG_RESUME );
+    sigfillset( &xAllSignals );
+    /* Don't block SIGINT so this can be used to break into GDB while
+     * in a critical section. */
+    sigdelset( &xAllSignals, SIGINT );
+
+    /*
+     * Block all signals in this thread so all new threads
+     * inherits this mask.
+     *
+     * When a thread is resumed for the first time, all signals
+     * will be unblocked.
+     */
+    (void)pthread_sigmask( SIG_SETMASK, &xAllSignals,
+                           *&xSchedulerOriginalSignalMask );
+
+    /* SIG_RESUME is only used with sigwait() so doesn't need a
+       handler. */
+    sigresume.sa_flags = 0;
+    sigresume.sa_handler = SIG_IGN;
+    sigfillset( &sigresume.sa_mask );
+
+    sigtick.sa_flags = 0;
+    sigtick.sa_handler = vPortSystemTickHandler;
+    sigfillset( &sigtick.sa_mask );
+
+    iRet = sigaction( SIG_RESUME, &sigresume, NULL );
+    if ( iRet )
+    {
+        prvFatalError( "sigaction", errno );
+    }
+
+    iRet = sigaction( SIGALRM, &sigtick, NULL );
+    if ( iRet )
+    {
+        prvFatalError( "sigaction", errno );
+    }
+}
+/*-----------------------------------------------------------*/
+
+unsigned long ulPortGetRunTime( void )
+{
+struct tms xTimes;
+
+    times( &xTimes );
+
+    return ( unsigned long ) xTimes.tms_utime;
+}
+/*-----------------------------------------------------------*/

+ 134 - 0
components/freertos/portable/ThirdParty/GCC/Posix/portmacro.h

@@ -0,0 +1,134 @@
+/*
+ * FreeRTOS Kernel V10.4.3
+ * Copyright 2020 Cambridge Consultants Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * https://www.FreeRTOS.org
+ * https://github.com/FreeRTOS
+ *
+ * 1 tab == 4 spaces!
+ */
+
+
+#ifndef PORTMACRO_H
+#define PORTMACRO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <limits.h>
+
+/*-----------------------------------------------------------
+ * Port specific definitions.
+ *
+ * The settings in this file configure FreeRTOS correctly for the
+ * given hardware and compiler.
+ *
+ * These settings should not be altered.
+ *-----------------------------------------------------------
+ */
+
+/* Type definitions. */
+#define portCHAR		char
+#define portFLOAT		float
+#define portDOUBLE		double
+#define portLONG		long
+#define portSHORT		short
+#define portSTACK_TYPE	unsigned long
+#define portBASE_TYPE	long
+#define portPOINTER_SIZE_TYPE intptr_t
+
+typedef portSTACK_TYPE StackType_t;
+typedef long BaseType_t;
+typedef unsigned long UBaseType_t;
+
+typedef unsigned long TickType_t;
+#define portMAX_DELAY ( TickType_t ) ULONG_MAX
+
+#define portTICK_TYPE_IS_ATOMIC 1
+
+/*-----------------------------------------------------------*/
+
+/* Architecture specifics. */
+#define portSTACK_GROWTH			( -1 )
+#define portHAS_STACK_OVERFLOW_CHECKING	( 1 )
+#define portTICK_PERIOD_MS			( ( TickType_t ) 1000 / configTICK_RATE_HZ )
+#define portTICK_RATE_MICROSECONDS	( ( portTickType ) 1000000 / configTICK_RATE_HZ )
+#define portBYTE_ALIGNMENT			8
+/*-----------------------------------------------------------*/
+
+/* Scheduler utilities. */
+extern void vPortYield( void );
+
+#define portYIELD() vPortYield()
+
+#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) vPortYield()
+#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
+/*-----------------------------------------------------------*/
+
+/* Critical section management. */
+extern void vPortDisableInterrupts( void );
+extern void vPortEnableInterrupts( void );
+#define portSET_INTERRUPT_MASK()        ( vPortDisableInterrupts() )
+#define portCLEAR_INTERRUPT_MASK()      ( vPortEnableInterrupts() )
+
+extern portBASE_TYPE xPortSetInterruptMask( void );
+extern void vPortClearInterruptMask( portBASE_TYPE xMask );
+
+extern void vPortEnterCritical( void );
+extern void vPortExitCritical( void );
+#define portSET_INTERRUPT_MASK_FROM_ISR()		xPortSetInterruptMask()
+#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x)	vPortClearInterruptMask(x)
+#define portDISABLE_INTERRUPTS()				portSET_INTERRUPT_MASK()
+#define portENABLE_INTERRUPTS()					portCLEAR_INTERRUPT_MASK()
+#define portENTER_CRITICAL()					vPortEnterCritical()
+#define portEXIT_CRITICAL()						vPortExitCritical()
+
+/*-----------------------------------------------------------*/
+
+extern void vPortThreadDying( void *pxTaskToDelete, volatile BaseType_t *pxPendYield );
+extern void vPortCancelThread( void *pxTaskToDelete );
+#define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortThreadDying( ( pvTaskToDelete ), ( pxPendYield ) )
+#define portCLEAN_UP_TCB( pxTCB )	vPortCancelThread( pxTCB )
+/*-----------------------------------------------------------*/
+
+#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
+#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
+/*-----------------------------------------------------------*/
+
+/*
+ * Tasks run in their own pthreads and context switches between them
+ * are always a full memory barrier. ISRs are emulated as signals
+ * which also imply a full memory barrier.
+ *
+ * Thus, only a compilier barrier is needed to prevent the compiler
+ * reordering.
+ */
+#define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" )
+
+extern unsigned long ulPortGetRunTime( void );
+#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* no-op */
+#define portGET_RUN_TIME_COUNTER_VALUE()         ulPortGetRunTime()
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PORTMACRO_H */

+ 76 - 0
components/freertos/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c

@@ -0,0 +1,76 @@
+#include <pthread.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "wait_for_event.h"
+
+struct event
+{
+    pthread_mutex_t mutex;
+    pthread_cond_t cond;
+    bool event_triggered;
+};
+
+struct event * event_create()
+{
+    struct event * ev = malloc( sizeof( struct event ) );
+
+    ev->event_triggered = false;
+    pthread_mutex_init( &ev->mutex, NULL );
+    pthread_cond_init( &ev->cond, NULL );
+    return ev;
+}
+
+void event_delete( struct event * ev )
+{
+    pthread_mutex_destroy( &ev->mutex );
+    pthread_cond_destroy( &ev->cond );
+    free( ev );
+}
+
+bool event_wait( struct event * ev )
+{
+    pthread_mutex_lock( &ev->mutex );
+
+    while( ev->event_triggered == false )
+    {
+        pthread_cond_wait( &ev->cond, &ev->mutex );
+    }
+
+    ev->event_triggered = false;
+    pthread_mutex_unlock( &ev->mutex );
+    return true;
+}
+bool event_wait_timed( struct event * ev,
+                       time_t ms )
+{
+    struct timespec ts;
+    int ret = 0;
+
+    clock_gettime( CLOCK_REALTIME, &ts );
+    //ts.tv_sec += ms;
+    ts.tv_nsec += (ms * 1000000);
+    pthread_mutex_lock( &ev->mutex );
+
+    while( (ev->event_triggered == false) && (ret == 0) )
+    {
+        ret = pthread_cond_timedwait( &ev->cond, &ev->mutex, &ts );
+
+        if( ( ret == -1 ) && ( errno == ETIMEDOUT ) )
+        {
+            return false;
+        }
+    }
+
+    ev->event_triggered = false;
+    pthread_mutex_unlock( &ev->mutex );
+    return true;
+}
+
+void event_signal( struct event * ev )
+{
+    pthread_mutex_lock( &ev->mutex );
+    ev->event_triggered = true;
+    pthread_cond_signal( &ev->cond );
+    pthread_mutex_unlock( &ev->mutex );
+}

+ 18 - 0
components/freertos/portable/ThirdParty/GCC/Posix/utils/wait_for_event.h

@@ -0,0 +1,18 @@
+#ifndef _WAIT_FOR_EVENT_H_
+#define _WAIT_FOR_EVENT_H_
+
+#include <stdbool.h>
+#include <time.h>
+
+struct event;
+
+struct event * event_create();
+void event_delete( struct event * );
+bool event_wait( struct event * ev );
+bool event_wait_timed( struct event * ev,
+                       time_t ms );
+void event_signal( struct event * ev );
+
+
+
+#endif /* ifndef _WAIT_FOR_EVENT_H_ */

+ 0 - 0
bsp/win32/freertos/queue.c → components/freertos/queue.c


+ 0 - 0
bsp/win32/freertos/stream_buffer.c → components/freertos/stream_buffer.c


+ 0 - 0
bsp/win32/freertos/tasks.c → components/freertos/tasks.c


+ 0 - 0
bsp/win32/freertos/timers.c → components/freertos/timers.c


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/.gitignore → components/mbedtls/3rdparty/.gitignore


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/CMakeLists.txt → components/mbedtls/3rdparty/CMakeLists.txt


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/Makefile.inc → components/mbedtls/3rdparty/Makefile.inc


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/.gitignore → components/mbedtls/3rdparty/everest/.gitignore


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/CMakeLists.txt → components/mbedtls/3rdparty/everest/CMakeLists.txt


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/Makefile.inc → components/mbedtls/3rdparty/everest/Makefile.inc


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/README.md → components/mbedtls/3rdparty/everest/README.md


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/Hacl_Curve25519.h → components/mbedtls/3rdparty/everest/include/everest/Hacl_Curve25519.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/everest.h → components/mbedtls/3rdparty/everest/include/everest/everest.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/kremlib.h → components/mbedtls/3rdparty/everest/include/everest/kremlib.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/kremlib/FStar_UInt128.h → components/mbedtls/3rdparty/everest/include/everest/kremlib/FStar_UInt128.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.h → components/mbedtls/3rdparty/everest/include/everest/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/kremlin/c_endianness.h → components/mbedtls/3rdparty/everest/include/everest/kremlin/c_endianness.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/kremlin/internal/builtin.h → components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/builtin.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/kremlin/internal/callconv.h → components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/callconv.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/kremlin/internal/compat.h → components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/compat.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/kremlin/internal/debug.h → components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/debug.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/kremlin/internal/target.h → components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/target.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/kremlin/internal/types.h → components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/types.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/kremlin/internal/wasmsupport.h → components/mbedtls/3rdparty/everest/include/everest/kremlin/internal/wasmsupport.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/vs2010/Hacl_Curve25519.h → components/mbedtls/3rdparty/everest/include/everest/vs2010/Hacl_Curve25519.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/vs2010/inttypes.h → components/mbedtls/3rdparty/everest/include/everest/vs2010/inttypes.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/vs2010/stdbool.h → components/mbedtls/3rdparty/everest/include/everest/vs2010/stdbool.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/include/everest/x25519.h → components/mbedtls/3rdparty/everest/include/everest/x25519.h


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/library/Hacl_Curve25519.c → components/mbedtls/3rdparty/everest/library/Hacl_Curve25519.c


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/library/Hacl_Curve25519_joined.c → components/mbedtls/3rdparty/everest/library/Hacl_Curve25519_joined.c


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/library/everest.c → components/mbedtls/3rdparty/everest/library/everest.c


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/library/kremlib/FStar_UInt128_extracted.c → components/mbedtls/3rdparty/everest/library/kremlib/FStar_UInt128_extracted.c


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/library/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.c → components/mbedtls/3rdparty/everest/library/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.c


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/library/legacy/Hacl_Curve25519.c → components/mbedtls/3rdparty/everest/library/legacy/Hacl_Curve25519.c


+ 0 - 0
bsp/win32/rock/mbedtls/3rdparty/everest/library/x25519.c → components/mbedtls/3rdparty/everest/library/x25519.c


+ 0 - 0
bsp/win32/rock/mbedtls/CMakeLists.txt → components/mbedtls/CMakeLists.txt


+ 0 - 0
bsp/win32/rock/mbedtls/configs/README.txt → components/mbedtls/configs/README.txt


+ 0 - 0
bsp/win32/rock/mbedtls/configs/config-ccm-psk-tls1_2.h → components/mbedtls/configs/config-ccm-psk-tls1_2.h


+ 0 - 0
bsp/win32/rock/mbedtls/configs/config-mini-tls1_1.h → components/mbedtls/configs/config-mini-tls1_1.h


+ 0 - 0
bsp/win32/rock/mbedtls/configs/config-no-entropy.h → components/mbedtls/configs/config-no-entropy.h


+ 0 - 0
bsp/win32/rock/mbedtls/configs/config-psa-crypto.h → components/mbedtls/configs/config-psa-crypto.h


+ 0 - 0
bsp/win32/rock/mbedtls/configs/config-suite-b.h → components/mbedtls/configs/config-suite-b.h


+ 0 - 0
bsp/win32/rock/mbedtls/configs/config-symmetric-only.h → components/mbedtls/configs/config-symmetric-only.h


+ 0 - 0
bsp/win32/rock/mbedtls/configs/config-thread.h → components/mbedtls/configs/config-thread.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/.gitignore → components/mbedtls/include/.gitignore


+ 0 - 0
bsp/win32/rock/mbedtls/include/CMakeLists.txt → components/mbedtls/include/CMakeLists.txt


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/aes.h → components/mbedtls/include/mbedtls/aes.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/aesni.h → components/mbedtls/include/mbedtls/aesni.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/arc4.h → components/mbedtls/include/mbedtls/arc4.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/aria.h → components/mbedtls/include/mbedtls/aria.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/asn1.h → components/mbedtls/include/mbedtls/asn1.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/asn1write.h → components/mbedtls/include/mbedtls/asn1write.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/base64.h → components/mbedtls/include/mbedtls/base64.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/bignum.h → components/mbedtls/include/mbedtls/bignum.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/blowfish.h → components/mbedtls/include/mbedtls/blowfish.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/bn_mul.h → components/mbedtls/include/mbedtls/bn_mul.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/camellia.h → components/mbedtls/include/mbedtls/camellia.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/ccm.h → components/mbedtls/include/mbedtls/ccm.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/certs.h → components/mbedtls/include/mbedtls/certs.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/chacha20.h → components/mbedtls/include/mbedtls/chacha20.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/chachapoly.h → components/mbedtls/include/mbedtls/chachapoly.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/check_config.h → components/mbedtls/include/mbedtls/check_config.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/cipher.h → components/mbedtls/include/mbedtls/cipher.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/cipher_internal.h → components/mbedtls/include/mbedtls/cipher_internal.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/cmac.h → components/mbedtls/include/mbedtls/cmac.h


+ 0 - 0
bsp/win32/rock/mbedtls/include/mbedtls/compat-1.3.h → components/mbedtls/include/mbedtls/compat-1.3.h


Some files were not shown because too many files changed in this diff