Sfoglia il codice sorgente

Merge pull request #1622 from armink/fix_com_init

[components] Update dfs and lwIP 2.0.2 re-initialization process.
aozima 6 anni fa
parent
commit
6deeb61efb
2 ha cambiato i file con 18 aggiunte e 15 eliminazioni
  1. 11 9
      components/dfs/src/dfs.c
  2. 7 6
      components/net/lwip-2.0.2/src/arch/sys_arch.c

+ 11 - 9
components/dfs/src/dfs.c

@@ -55,15 +55,15 @@ static int  fd_alloc(struct dfs_fdtable *fdt, int startfd);
 /**
 /**
  * this function will initialize device file system.
  * this function will initialize device file system.
  */
  */
-static volatile uint8_t init_ok = 0;
 int dfs_init(void)
 int dfs_init(void)
 {
 {
-    if(init_ok)
+    static rt_bool_t init_ok = RT_FALSE;
+
+    if (init_ok)
     {
     {
         rt_kprintf("dfs already init.\n");
         rt_kprintf("dfs already init.\n");
-        return 0;        
+        return 0;
     }
     }
-    init_ok = 1;	
 
 
     /* clear filesystem operations table */
     /* clear filesystem operations table */
     memset((void *)filesystem_operation_table, 0, sizeof(filesystem_operation_table));
     memset((void *)filesystem_operation_table, 0, sizeof(filesystem_operation_table));
@@ -92,6 +92,8 @@ int dfs_init(void)
     }
     }
 #endif
 #endif
 
 
+    init_ok = RT_TRUE;
+
     return 0;
     return 0;
 }
 }
 INIT_PREV_EXPORT(dfs_init);
 INIT_PREV_EXPORT(dfs_init);
@@ -506,13 +508,13 @@ struct dfs_fdtable* dfs_fdtable_get(void)
 {
 {
     struct dfs_fdtable *fdt;
     struct dfs_fdtable *fdt;
 #ifdef RT_USING_LWP
 #ifdef RT_USING_LWP
-	struct rt_lwp *lwp;
+    struct rt_lwp *lwp;
 
 
-	lwp = (struct rt_lwp *)rt_thread_self()->user_data;
+    lwp = (struct rt_lwp *)rt_thread_self()->user_data;
     if (lwp)
     if (lwp)
-		fdt = &lwp->fdt;
-	else
-		fdt = &_fdtab;
+        fdt = &lwp->fdt;
+    else
+        fdt = &_fdtab;
 #else
 #else
     fdt = &_fdtab;
     fdt = &_fdtab;
 #endif
 #endif

+ 7 - 6
components/net/lwip-2.0.2/src/arch/sys_arch.c

@@ -98,7 +98,7 @@ static void tcpip_init_done_callback(void *arg)
 
 
             /* leave critical */
             /* leave critical */
             rt_exit_critical();
             rt_exit_critical();
-			LOCK_TCPIP_CORE();
+            LOCK_TCPIP_CORE();
 
 
             netif_add(ethif->netif, &ipaddr, &netmask, &gw,
             netif_add(ethif->netif, &ipaddr, &netmask, &gw,
                       ethif, netif_device_init, tcpip_input);
                       ethif, netif_device_init, tcpip_input);
@@ -121,7 +121,7 @@ static void tcpip_init_done_callback(void *arg)
                 netif_set_link_up(ethif->netif);
                 netif_set_link_up(ethif->netif);
             }
             }
 
 
-			UNLOCK_TCPIP_CORE();
+            UNLOCK_TCPIP_CORE();
             /* enter critical */
             /* enter critical */
             rt_enter_critical();
             rt_enter_critical();
         }
         }
@@ -136,18 +136,17 @@ static void tcpip_init_done_callback(void *arg)
  * LwIP system initialization
  * LwIP system initialization
  */
  */
 extern int eth_system_device_init_private(void);
 extern int eth_system_device_init_private(void);
-static volatile uint8_t init_ok = 0;
 int lwip_system_init(void)
 int lwip_system_init(void)
 {
 {
     rt_err_t rc;
     rt_err_t rc;
     struct rt_semaphore done_sem;
     struct rt_semaphore done_sem;
+    static rt_bool_t init_ok = RT_FALSE;
 
 
-    if(init_ok)
+    if (init_ok)
     {
     {
         rt_kprintf("lwip system already init.\n");
         rt_kprintf("lwip system already init.\n");
-        return 0;        
+        return 0;
     }
     }
-    init_ok = 1;
 
 
     eth_system_device_init_private();
     eth_system_device_init_private();
 
 
@@ -189,6 +188,8 @@ int lwip_system_init(void)
 #endif
 #endif
     rt_kprintf("lwIP-%d.%d.%d initialized!\n", LWIP_VERSION_MAJOR, LWIP_VERSION_MINOR, LWIP_VERSION_REVISION);
     rt_kprintf("lwIP-%d.%d.%d initialized!\n", LWIP_VERSION_MAJOR, LWIP_VERSION_MINOR, LWIP_VERSION_REVISION);
 
 
+    init_ok = RT_TRUE;
+
     return 0;
     return 0;
 }
 }
 INIT_PREV_EXPORT(lwip_system_init);
 INIT_PREV_EXPORT(lwip_system_init);