Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
混口饭吃,
rt-thread
提交
672966cc
R
rt-thread
项目概览
混口饭吃,
/
rt-thread
与 Fork 源项目一致
Fork自
Mr_Pangza / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
672966cc
编写于
3月 09, 2023
作者:
W
wangxiaoyao
提交者:
guo
3月 11, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[lwp] arch should recycle resource it allocated
上级
0275b236
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
67 addition
and
22 deletion
+67
-22
components/lwp/arch/aarch64/cortex-a/lwp_arch.c
components/lwp/arch/aarch64/cortex-a/lwp_arch.c
+21
-6
components/lwp/arch/arm/cortex-a/lwp_arch.c
components/lwp/arch/arm/cortex-a/lwp_arch.c
+21
-6
components/lwp/arch/risc-v/rv64/lwp_arch.c
components/lwp/arch/risc-v/rv64/lwp_arch.c
+23
-7
components/lwp/lwp_arch_comm.h
components/lwp/lwp_arch_comm.h
+1
-1
components/lwp/lwp_user_mm.c
components/lwp/lwp_user_mm.c
+1
-2
未找到文件。
components/lwp/arch/aarch64/cortex-a/lwp_arch.c
浏览文件 @
672966cc
...
...
@@ -13,6 +13,10 @@
#ifdef ARCH_MM_MMU
#define DBG_TAG "lwp.arch"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#include <lwp_arch.h>
#include <lwp_user_mm.h>
...
...
@@ -25,10 +29,11 @@ int arch_user_space_init(struct rt_lwp *lwp)
mmu_table
=
(
size_t
*
)
rt_pages_alloc
(
0
);
if
(
!
mmu_table
)
{
return
-
1
;
return
-
RT_ENOMEM
;
}
lwp
->
end_heap
=
USER_HEAP_VADDR
;
memset
(
mmu_table
,
0
,
ARCH_PAGE_SIZE
);
rt_hw_cpu_dcache_ops
(
RT_HW_CACHE_FLUSH
,
mmu_table
,
ARCH_PAGE_SIZE
);
...
...
@@ -36,7 +41,7 @@ int arch_user_space_init(struct rt_lwp *lwp)
(
void
*
)
USER_VADDR_START
,
USER_VADDR_TOP
-
USER_VADDR_START
,
mmu_table
);
if
(
!
lwp
->
aspace
)
{
return
-
1
;
return
-
RT_ERROR
;
}
return
0
;
...
...
@@ -47,12 +52,22 @@ void *arch_kernel_mmu_table_get(void)
return
(
void
*
)
NULL
;
}
void
arch_user_space_
vtable_
free
(
struct
rt_lwp
*
lwp
)
void
arch_user_space_free
(
struct
rt_lwp
*
lwp
)
{
if
(
lwp
&&
lwp
->
aspace
->
page_table
)
if
(
lwp
)
{
RT_ASSERT
(
lwp
->
aspace
);
void
*
pgtbl
=
lwp
->
aspace
->
page_table
;
rt_aspace_delete
(
lwp
->
aspace
);
/* must be freed after aspace delete, pgtbl is required for unmap */
rt_pages_free
(
pgtbl
,
0
);
lwp
->
aspace
=
NULL
;
}
else
{
rt_pages_free
(
lwp
->
aspace
->
page_table
,
0
);
lwp
->
aspace
->
page_table
=
NULL
;
LOG_W
(
"%s: NULL lwp as parameter"
,
__func__
);
RT_ASSERT
(
0
)
;
}
}
...
...
components/lwp/arch/arm/cortex-a/lwp_arch.c
浏览文件 @
672966cc
...
...
@@ -14,6 +14,10 @@
#ifdef ARCH_MM_MMU
#define DBG_TAG "lwp.arch"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#include <lwp_arch.h>
#include <lwp_user_mm.h>
...
...
@@ -26,7 +30,7 @@ int arch_user_space_init(struct rt_lwp *lwp)
mmu_table
=
(
size_t
*
)
rt_pages_alloc
(
2
);
if
(
!
mmu_table
)
{
return
-
1
;
return
-
RT_ENOMEM
;
}
lwp
->
end_heap
=
USER_HEAP_VADDR
;
...
...
@@ -34,10 +38,11 @@ int arch_user_space_init(struct rt_lwp *lwp)
rt_memcpy
(
mmu_table
+
KPTE_START
,
(
size_t
*
)
rt_kernel_space
.
page_table
+
KPTE_START
,
ARCH_PAGE_SIZE
);
rt_memset
(
mmu_table
,
0
,
3
*
ARCH_PAGE_SIZE
);
rt_hw_cpu_dcache_ops
(
RT_HW_CACHE_FLUSH
,
mmu_table
,
4
*
ARCH_PAGE_SIZE
);
lwp
->
aspace
=
rt_aspace_create
((
void
*
)
USER_VADDR_START
,
USER_VADDR_TOP
-
USER_VADDR_START
,
mmu_table
);
if
(
!
lwp
->
aspace
)
{
return
-
1
;
return
-
RT_ERROR
;
}
return
0
;
...
...
@@ -68,12 +73,22 @@ void arch_kuser_init(rt_aspace_t aspace, void *vectors)
rt_hw_cpu_icache_ops
(
RT_HW_CACHE_INVALIDATE
,
(
void
*
)((
char
*
)
vectors
+
0x1000
-
kuser_sz
),
kuser_sz
);
}
void
arch_user_space_
vtable_
free
(
struct
rt_lwp
*
lwp
)
void
arch_user_space_free
(
struct
rt_lwp
*
lwp
)
{
if
(
lwp
&&
lwp
->
aspace
->
page_table
)
if
(
lwp
)
{
RT_ASSERT
(
lwp
->
aspace
);
void
*
pgtbl
=
lwp
->
aspace
->
page_table
;
rt_aspace_delete
(
lwp
->
aspace
);
/* must be freed after aspace delete, pgtbl is required for unmap */
rt_pages_free
(
pgtbl
,
2
);
lwp
->
aspace
=
RT_NULL
;
}
else
{
rt_pages_free
(
lwp
->
aspace
->
page_table
,
2
);
lwp
->
aspace
->
page_table
=
NULL
;
LOG_W
(
"%s: NULL lwp as parameter"
,
__func__
);
RT_ASSERT
(
0
)
;
}
}
...
...
components/lwp/arch/risc-v/rv64/lwp_arch.c
浏览文件 @
672966cc
...
...
@@ -22,6 +22,10 @@
#ifdef ARCH_MM_MMU
#define DBG_TAG "lwp.arch"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#include <lwp.h>
#include <lwp_arch.h>
#include <lwp_user_mm.h>
...
...
@@ -90,18 +94,19 @@ int arch_user_space_init(struct rt_lwp *lwp)
mmu_table
=
(
rt_ubase_t
*
)
rt_pages_alloc
(
0
);
if
(
!
mmu_table
)
{
return
-
1
;
return
-
RT_ENOMEM
;
}
lwp
->
end_heap
=
USER_HEAP_VADDR
;
rt_memcpy
(
mmu_table
,
MMUT
able
,
ARCH_PAGE_SIZE
);
rt_memcpy
(
mmu_table
,
rt_kernel_space
.
page_t
able
,
ARCH_PAGE_SIZE
);
rt_hw_cpu_dcache_ops
(
RT_HW_CACHE_FLUSH
,
mmu_table
,
ARCH_PAGE_SIZE
);
lwp
->
aspace
=
rt_aspace_create
(
(
void
*
)
USER_VADDR_START
,
USER_VADDR_TOP
-
USER_VADDR_START
,
mmu_table
);
if
(
!
lwp
->
aspace
)
{
return
-
1
;
return
-
RT_ERROR
;
}
return
0
;
...
...
@@ -112,12 +117,23 @@ void *arch_kernel_mmu_table_get(void)
return
(
void
*
)((
char
*
)
MMUTable
);
}
void
arch_user_space_
vtable_
free
(
struct
rt_lwp
*
lwp
)
void
arch_user_space_free
(
struct
rt_lwp
*
lwp
)
{
if
(
lwp
&&
lwp
->
aspace
->
page_table
)
if
(
lwp
)
{
RT_ASSERT
(
lwp
->
aspace
);
void
*
pgtbl
=
lwp
->
aspace
->
page_table
;
rt_aspace_delete
(
lwp
->
aspace
);
/* must be freed after aspace delete, pgtbl is required for unmap */
rt_pages_free
(
pgtbl
,
0
);
lwp
->
aspace
=
RT_NULL
;
}
else
{
rt_pages_free
(
lwp
->
aspace
->
page_table
,
0
);
lwp
->
aspace
->
page_table
=
NULL
;
LOG_W
(
"%s: NULL lwp as parameter"
,
__func__
);
RT_ASSERT
(
0
)
;
}
}
...
...
components/lwp/lwp_arch_comm.h
浏览文件 @
672966cc
...
...
@@ -44,7 +44,7 @@ void *arch_get_user_sp(void);
/* user space setup and control */
int
arch_user_space_init
(
struct
rt_lwp
*
lwp
);
void
arch_user_space_
vtable_
free
(
struct
rt_lwp
*
lwp
);
void
arch_user_space_free
(
struct
rt_lwp
*
lwp
);
void
*
arch_kernel_mmu_table_get
(
void
);
void
arch_kuser_init
(
rt_aspace_t
aspace
,
void
*
vectors
);
int
arch_expand_user_stack
(
void
*
addr
);
...
...
components/lwp/lwp_user_mm.c
浏览文件 @
672966cc
...
...
@@ -78,9 +78,8 @@ void lwp_aspace_switch(struct rt_thread *thread)
void
lwp_unmap_user_space
(
struct
rt_lwp
*
lwp
)
{
arch_user_space_free
(
lwp
);
rt_free
(
lwp
->
lwp_obj
);
rt_aspace_delete
(
lwp
->
aspace
);
arch_user_space_vtable_free
(
lwp
);
}
static
const
char
*
user_get_name
(
rt_varea_t
varea
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录