瀏覽代碼

[lwp] save virtual addr in shm structure

wangxiaoyao 2 年之前
父節點
當前提交
fef2607764
共有 1 個文件被更改,包括 3 次插入4 次删除
  1. 3 4
      components/lwp/lwp_shm.c

+ 3 - 4
components/lwp/lwp_shm.c

@@ -101,7 +101,7 @@ static int _lwp_shmget(size_t key, size_t size, int create)
     int id = -1;
     int id = -1;
     struct lwp_avl_struct *node_key = 0;
     struct lwp_avl_struct *node_key = 0;
     struct lwp_avl_struct *node_pa = 0;
     struct lwp_avl_struct *node_pa = 0;
-    void *page_addr = 0, *page_addr_p = RT_NULL;
+    void *page_addr = 0;
     uint32_t bit = 0;
     uint32_t bit = 0;
 
 
     /* try to locate the item with the key in the binary tree */
     /* try to locate the item with the key in the binary tree */
@@ -134,11 +134,10 @@ static int _lwp_shmget(size_t key, size_t size, int create)
         {
         {
             goto err;
             goto err;
         }
         }
-        page_addr_p = (void *)((char *)page_addr + PV_OFFSET);    /* physical address */
 
 
         /* initialize the shared memory structure */
         /* initialize the shared memory structure */
         p = _shm_ary + id;
         p = _shm_ary + id;
-        p->addr = (size_t)page_addr_p;
+        p->addr = (size_t)page_addr;
         p->size = (1UL << (bit + ARCH_PAGE_SHIFT));
         p->size = (1UL << (bit + ARCH_PAGE_SHIFT));
         p->ref = 0;
         p->ref = 0;
         p->key = key;
         p->key = key;
@@ -236,7 +235,7 @@ static int _lwp_shmrm(int id)
         return 0;
         return 0;
     }
     }
     bit = rt_page_bits(p->size);
     bit = rt_page_bits(p->size);
-    rt_pages_free((void *)((char *)p->addr - PV_OFFSET), bit);
+    rt_pages_free((void *)p->addr, bit);
     lwp_avl_remove(node_key, &shm_tree_key);
     lwp_avl_remove(node_key, &shm_tree_key);
     node_pa = node_key + 1;
     node_pa = node_key + 1;
     lwp_avl_remove(node_pa, &shm_tree_pa);
     lwp_avl_remove(node_pa, &shm_tree_pa);