Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
7d3af8e9
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / 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看板
提交
7d3af8e9
编写于
6月 29, 2018
作者:
H
heyuanjie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
给lwp传递参数
上级
0f3820f1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
77 addition
and
30 deletion
+77
-30
components/lwp/arch/arm/cortex-m3/lwp_rvds.S
components/lwp/arch/arm/cortex-m3/lwp_rvds.S
+7
-7
components/lwp/arch/arm/cortex-m4/lwp_rvds.S
components/lwp/arch/arm/cortex-m4/lwp_rvds.S
+7
-7
components/lwp/arch/arm/cortex-m7/lwp_rvds.S
components/lwp/arch/arm/cortex-m7/lwp_rvds.S
+6
-7
components/lwp/lwp.c
components/lwp/lwp.c
+56
-9
components/lwp/lwp.h
components/lwp/lwp.h
+1
-0
未找到文件。
components/lwp/arch/arm/cortex-m3/lwp_rvds.S
浏览文件 @
7d3af8e9
...
...
@@ -34,33 +34,33 @@
IMPORT
lwp_set_kernel_sp
;/*
; * void lwp_user_entry(
u32 R0_text_addr, u32 R1_data_addr
);
; * void lwp_user_entry(
args, text, data
);
; */
lwp_user_entry
PROC
EXPORT
lwp_user_entry
PUSH
{
R0
-
R
1
}
; push text&data addr.
PUSH
{
R0
-
R
3
}
; push text&data addr.
MOV
R0
,
SP
; v1 = SP
BL
lwp_set_kernel_sp
; lwp_set_kernel_sp(v1)
POP
{
R0
-
R1
}
; pop app address to R1.
; set CPU to user-thread mode.
MRS
R2
,
CONTROL
ORR
R2
,
R2
,
#
0x03
; use PSP, user-thread mode.
MSR
CONTROL
,
R2
POP
{
R0
-
R3
}
; pop app address to R1.
; set data address.
MOV
R9
,
R
1
MOV
R9
,
R
2
; run app, only Thumb-mode.
ORR
R
0
,
R0
,
#
0x01
BX
R
0
ORR
R
1
,
R1
,
#
0x01
BX
R
1
; never reach here!
ENDP
;/*
; * void SVC_Handler(void);
; */
...
...
components/lwp/arch/arm/cortex-m4/lwp_rvds.S
浏览文件 @
7d3af8e9
...
...
@@ -34,33 +34,33 @@
IMPORT
lwp_set_kernel_sp
;/*
; * void lwp_user_entry(
u32 R0_text_addr, u32 R1_data_addr
);
; * void lwp_user_entry(
args, text, data
);
; */
lwp_user_entry
PROC
EXPORT
lwp_user_entry
PUSH
{
R0
-
R
1
}
; push text&data addr.
PUSH
{
R0
-
R
3
}
; push text&data addr.
MOV
R0
,
SP
; v1 = SP
BL
lwp_set_kernel_sp
; lwp_set_kernel_sp(v1)
POP
{
R0
-
R1
}
; pop app address to R1.
; set CPU to user-thread mode.
MRS
R2
,
CONTROL
ORR
R2
,
R2
,
#
0x03
; use PSP, user-thread mode.
MSR
CONTROL
,
R2
POP
{
R0
-
R3
}
; pop app address to R1.
; set data address.
MOV
R9
,
R
1
MOV
R9
,
R
2
; run app, only Thumb-mode.
ORR
R
0
,
R0
,
#
0x01
BX
R
0
ORR
R
1
,
R1
,
#
0x01
BX
R
1
; never reach here!
ENDP
;/*
; * void SVC_Handler(void);
; */
...
...
components/lwp/arch/arm/cortex-m7/lwp_rvds.S
浏览文件 @
7d3af8e9
...
...
@@ -34,29 +34,28 @@
IMPORT
lwp_set_kernel_sp
;/*
; * void lwp_user_entry(
u32 R0_text_addr, u32 R1_data_addr
);
; * void lwp_user_entry(
args, text, data
);
; */
lwp_user_entry
PROC
EXPORT
lwp_user_entry
PUSH
{
R0
-
R
1
}
; push text&data addr.
PUSH
{
R0
-
R
3
}
; push text&data addr.
MOV
R0
,
SP
; v1 = SP
BL
lwp_set_kernel_sp
; lwp_set_kernel_sp(v1)
POP
{
R0
-
R1
}
; pop app address to R1.
; set CPU to user-thread mode.
MRS
R2
,
CONTROL
ORR
R2
,
R2
,
#
0x03
; use PSP, user-thread mode.
MSR
CONTROL
,
R2
POP
{
R0
-
R3
}
; pop app address to R1.
; set data address.
MOV
R9
,
R
1
MOV
R9
,
R
2
; run app, only Thumb-mode.
ORR
R
0
,
R0
,
#
0x01
BX
R
0
ORR
R
1
,
R1
,
#
0x01
BX
R
1
; never reach here!
ENDP
...
...
components/lwp/lwp.c
浏览文件 @
7d3af8e9
...
...
@@ -25,10 +25,6 @@
#include <rthw.h>
#include <dfs_posix.h>
#ifdef RT_USING_FINSH
#include <finsh.h>
#endif
#ifndef RT_USING_DFS
#error "lwp need file system(RT_USING_DFS)"
#endif
...
...
@@ -42,7 +38,7 @@
#include <rtdbg.h>
extern
rt_thread_t
rt_current_thread
;
extern
void
lwp_user_entry
(
const
void
*
text
,
void
*
data
);
extern
void
lwp_user_entry
(
void
*
args
,
const
void
*
text
,
void
*
data
);
/**
* RT-Thread light-weight process
...
...
@@ -62,6 +58,43 @@ uint32_t *lwp_get_kernel_sp(void)
return
user_data
->
kernel_sp
;
}
static
int
lwp_argscopy
(
struct
rt_lwp
*
lwp
,
int
argc
,
char
**
argv
)
{
int
size
=
sizeof
(
int
)
*
3
;
/* store argc, argv, NULL */
int
*
args
;
char
*
str
;
char
**
new_argv
;
int
i
;
int
len
;
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
size
+=
(
rt_strlen
(
argv
[
i
])
+
1
);
}
size
+=
(
sizeof
(
int
)
*
argc
);
args
=
(
int
*
)
rt_malloc
(
size
);
if
(
args
==
RT_NULL
)
return
-
1
;
str
=
(
char
*
)((
int
)
args
+
(
argc
+
3
)
*
sizeof
(
int
));
new_argv
=
(
char
**
)
&
args
[
2
];
args
[
0
]
=
argc
;
args
[
1
]
=
(
int
)
new_argv
;
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
len
=
rt_strlen
(
argv
[
i
])
+
1
;
new_argv
[
i
]
=
str
;
rt_memcpy
(
str
,
argv
[
i
],
len
);
str
+=
len
;
}
new_argv
[
i
]
=
0
;
lwp
->
args
=
args
;
return
0
;
}
static
int
lwp_load
(
const
char
*
filename
,
struct
rt_lwp
*
lwp
,
uint8_t
*
load_addr
,
size_t
addr_size
)
{
int
fd
;
...
...
@@ -76,8 +109,6 @@ static int lwp_load(const char *filename, struct rt_lwp *lwp, uint8_t *load_addr
/* check lwp control block */
RT_ASSERT
(
lwp
!=
RT_NULL
);
memset
(
lwp
,
0x00
,
sizeof
(
struct
rt_lwp
));
if
(
load_addr
!=
RT_NULL
)
{
lwp
->
lwp_type
=
LWP_TYPE_FIX_ADDR
;
...
...
@@ -279,6 +310,15 @@ static void lwp_cleanup(struct rt_thread *tid)
dbg_log
(
DBG_LOG
,
"lwp free memory pages
\n
"
);
rt_lwp_mem_deinit
(
lwp
);
/* cleanup fd table */
while
(
lwp
->
fdt
.
maxfd
>
0
)
{
lwp
->
fdt
.
maxfd
--
;
close
(
lwp
->
fdt
.
maxfd
);
}
rt_free
(
lwp
->
fdt
.
fds
);
rt_free
(
lwp
->
args
);
dbg_log
(
DBG_LOG
,
"lwp free: %p
\n
"
,
lwp
);
rt_free
(
lwp
);
...
...
@@ -299,7 +339,7 @@ static void lwp_thread(void *parameter)
tid
->
user_data
=
(
rt_uint32_t
)
lwp
;
tid
->
cleanup
=
lwp_cleanup
;
lwp_user_entry
(
lwp
->
text_entry
,
lwp
->
data
);
lwp_user_entry
(
lwp
->
args
,
lwp
->
text_entry
,
lwp
->
data
);
}
struct
rt_lwp
*
rt_lwp_self
(
void
)
...
...
@@ -307,7 +347,7 @@ struct rt_lwp *rt_lwp_self(void)
return
(
struct
rt_lwp
*
)
rt_thread_self
()
->
user_data
;
}
int
exec
(
char
*
filename
)
int
exec
(
char
*
filename
,
int
argc
,
char
**
argv
)
{
struct
rt_lwp
*
lwp
;
int
result
;
...
...
@@ -324,6 +364,12 @@ int exec(char *filename)
dbg_log
(
DBG_INFO
,
"lwp malloc : %p, size: %d!
\n
"
,
lwp
,
sizeof
(
struct
rt_lwp
));
rt_memset
(
lwp
,
0
,
sizeof
(
*
lwp
));
if
(
lwp_argscopy
(
lwp
,
argc
,
argv
)
!=
0
)
{
rt_free
(
lwp
);
return
-
ENOMEM
;
}
result
=
lwp_load
(
filename
,
lwp
,
RT_NULL
,
0
);
if
(
result
==
RT_EOK
)
{
...
...
@@ -348,6 +394,7 @@ int exec(char *filename)
}
}
rt_free
(
lwp
->
args
);
rt_free
(
lwp
);
return
-
RT_ERROR
;
...
...
components/lwp/lwp.h
浏览文件 @
7d3af8e9
...
...
@@ -52,6 +52,7 @@ struct rt_lwp
uint32_t
*
kernel_sp
;
/**< kernel stack point */
struct
dfs_fdtable
fdt
;
void
*
args
;
};
struct
lwp_header
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录