Browse Source

[sal] add draft for docking winsock

Meco Man 3 years ago
parent
commit
b793b6427a

+ 5 - 0
bsp/simulator/Kconfig

@@ -29,6 +29,11 @@ config RT_USING_DFS_WINSHAREDIR
     select RT_USING_POSIX_FS
     default n
 
+config BSP_USING_SAL_WINSOCK
+    bool "Enable Windows socket (winsock) with SAL"
+    select RT_USING_SAL
+    default n
+
 config BSP_USING_LVGL
     bool "Enable LVGL for LCD"
     select PKG_USING_LVGL

+ 2 - 2
components/libc/compilers/common/sys/time.h

@@ -43,14 +43,14 @@ struct timezone
     int tz_dsttime;       /* type of dst correction */
 };
 
-#if !defined(_TIMEVAL_DEFINED)
+#ifndef _TIMEVAL_DEFINED
 #define _TIMEVAL_DEFINED
 struct timeval
 {
     time_t      tv_sec;     /* seconds */
     suseconds_t tv_usec;    /* and microseconds */
 };
-#endif /* !defined(_TIMEVAL_DEFINED) && !defined(_WIN32) */
+#endif /* _TIMEVAL_DEFINED */
 
 #if defined(__ARMCC_VERSION) || defined(_WIN32) || (defined(__ICCARM__) && (__VER__ < 8010001))
 struct timespec

+ 22 - 21
components/net/sal/Kconfig

@@ -12,27 +12,28 @@ if RT_USING_SAL
         help
             The ability that check internet status is provided by RT-Thread.
 
-    if RT_USING_LWIP || AT_USING_SOCKET
-
-        menu "protocol stack implement"
-
-            config SAL_USING_LWIP
-                bool "Support lwIP stack"
-                default y
-                depends on RT_USING_LWIP
-
-            config SAL_USING_AT
-                bool "Support AT Commands stack"
-                default y
-                depends on AT_USING_SOCKET
-
-            config SAL_USING_TLS
-                bool "Support MbedTLS protocol"
-                default y
-                depends on PKG_USING_MBEDTLS
-        endmenu
-
-    endif
+    menu "Docking with protocol stacks"
+
+        config SAL_USING_LWIP
+            bool "Docking with lwIP stack"
+            default y
+            depends on RT_USING_LWIP
+
+        config SAL_USING_AT
+            bool "Docking with AT commands stack"
+            default y
+            depends on AT_USING_SOCKET
+
+        config SAL_USING_WINSOCK
+            bool "Docking with Windows socket (winsock)"
+            default y
+            depends on BSP_USING_SAL_WINSOCK
+
+        config SAL_USING_TLS
+            bool "Docking with MbedTLS protocol"
+            default y
+            depends on PKG_USING_MBEDTLS
+    endmenu
 
     config SAL_USING_POSIX
         bool

+ 7 - 4
components/net/sal/SConscript

@@ -11,16 +11,19 @@ CPPPATH = [cwd + '/include']
 CPPPATH += [cwd + '/include/socket']
 
 if GetDepend('SAL_USING_LWIP'):
-    src += Glob('impl/af_inet_lwip.c')
+    src += Glob('docking/af_inet_lwip.c')
 
 if GetDepend('SAL_USING_AT'):
-    src += Glob('impl/af_inet_at.c')
+    src += Glob('docking/af_inet_at.c')
 
 if GetDepend('SAL_USING_LWIP') or GetDepend('SAL_USING_AT'):
-    CPPPATH += [cwd + '/impl']
+    CPPPATH += [cwd + '/docking']
+
+if GetDepend('SAL_USING_WINSOCK'):
+    src += Glob('docking/af_inet_winsock.c')
 
 if GetDepend('SAL_USING_TLS'):
-    src += Glob('impl/proto_mbedtls.c')
+    src += Glob('docking/proto_mbedtls.c')
 
 if GetDepend('SAL_USING_POSIX'):
     CPPPATH += [cwd + '/include/dfs_net']

+ 0 - 0
components/net/sal/impl/af_inet.h → components/net/sal/docking/af_inet.h


+ 0 - 0
components/net/sal/impl/af_inet_at.c → components/net/sal/docking/af_inet_at.c


+ 0 - 0
components/net/sal/impl/af_inet_lwip.c → components/net/sal/docking/af_inet_lwip.c


+ 12 - 0
components/net/sal/docking/af_inet_winsock.c

@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ */
+
+#include <winsock.h>
+
+/* Do NOT include sys/time.h in this file */

+ 0 - 0
components/net/sal/impl/proto_mbedtls.c → components/net/sal/docking/proto_mbedtls.c