Browse Source

[Kernel] Use rt_object_get_information to get object chain

Bernard Xiong 7 years ago
parent
commit
2f409c85f1

+ 2 - 3
components/dfs/filesystems/devfs/devfs.c

@@ -150,13 +150,12 @@ int dfs_device_fs_open(struct dfs_fd *file)
         struct device_dirent *root_dirent;
         rt_uint32_t count = 0;
         
-        extern struct rt_object_information rt_object_container[];
-
         /* lock scheduler */
         rt_enter_critical();
 
         /* traverse device object */
-        information = &rt_object_container[RT_Object_Class_Device];
+        information = rt_object_get_information(RT_Object_Class_Device);
+        RT_ASSERT(information != RT_NULL);
         for (node = information->object_list.next; node != &(information->object_list); node = node->next)
         {
             count ++;

+ 3 - 3
components/net/lwip-1.3.2/src/arch/sys_arch_init.c

@@ -41,8 +41,6 @@ static void tcpip_init_done_callback(void *arg)
 	struct rt_object* object;
 	struct rt_object_information *information;
 
-	extern struct rt_object_information rt_object_container[];
-
 	LWIP_ASSERT("invalid arg.\n",arg);
 
 	IP4_ADDR(&gw, 0,0,0,0);
@@ -53,7 +51,9 @@ static void tcpip_init_done_callback(void *arg)
 	rt_enter_critical();
 
 	/* for each network interfaces */
-	information = &rt_object_container[RT_Object_Class_Device];
+    information = rt_object_get_information(RT_Object_Class_Device);
+    RT_ASSERT(information != RT_NULL);
+
 	for (node = information->object_list.next; node != &(information->object_list); node = node->next)
 	{
 		object = rt_list_entry(node, struct rt_object, list);

+ 2 - 3
components/net/lwip-1.4.1/src/arch/sys_arch.c

@@ -72,8 +72,6 @@ static void tcpip_init_done_callback(void *arg)
     struct rt_object* object;
     struct rt_object_information *information;
 
-    extern struct rt_object_information rt_object_container[];
-
     LWIP_ASSERT("invalid arg.\n",arg);
 
     IP4_ADDR(&gw, 0,0,0,0);
@@ -84,7 +82,8 @@ static void tcpip_init_done_callback(void *arg)
     rt_enter_critical();
 
     /* for each network interfaces */
-    information = &rt_object_container[RT_Object_Class_Device];
+    information = rt_object_get_information(RT_Object_Class_Device);
+    RT_ASSERT(information != RT_NULL);
     for (node = information->object_list.next;
          node != &(information->object_list);
          node = node->next)

+ 2 - 3
components/net/lwip-2.0.2/src/arch/sys_arch.c

@@ -74,8 +74,6 @@ static void tcpip_init_done_callback(void *arg)
     struct rt_object* object;
     struct rt_object_information *information;
 
-    extern struct rt_object_information rt_object_container[];
-
     LWIP_ASSERT("invalid arg.\n",arg);
 
     IP4_ADDR(&gw, 0,0,0,0);
@@ -86,7 +84,8 @@ static void tcpip_init_done_callback(void *arg)
     rt_enter_critical();
 
     /* for each network interfaces */
-    information = &rt_object_container[RT_Object_Class_Device];
+    information = rt_object_get_information(RT_Object_Class_Device);
+    RT_ASSERT(information != RT_NULL);
     for (node = information->object_list.next;
          node != &(information->object_list);
          node = node->next)

+ 2 - 2
src/memheap.c

@@ -620,10 +620,10 @@ void *rt_malloc(rt_size_t size)
         struct rt_list_node *node;
         struct rt_memheap *heap;
         struct rt_object_information *information;
-        extern struct rt_object_information rt_object_container[];
 
         /* try to allocate on other memory heap */
-        information = &rt_object_container[RT_Object_Class_MemHeap];
+        information = rt_object_get_information(RT_Object_Class_MemHeap);
+        RT_ASSERT(information != RT_NULL);
         for (node  = information->object_list.next;
              node != &(information->object_list);
              node  = node->next)

+ 2 - 3
src/thread.c

@@ -750,14 +750,13 @@ rt_thread_t rt_thread_find(char *name)
     struct rt_object *object;
     struct rt_list_node *node;
 
-    extern struct rt_object_information rt_object_container[];
-
     /* enter critical */
     if (rt_thread_self() != RT_NULL)
         rt_enter_critical();
 
     /* try to find device object */
-    information = &rt_object_container[RT_Object_Class_Thread];
+    information = rt_object_get_information(RT_Object_Class_Thread);
+    RT_ASSERT(information != RT_NULL);
     for (node  = information->object_list.next;
          node != &(information->object_list);
          node  = node->next)