Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不穿格子衫的农民
TencentOS Tiny
提交
f63d2d4e
T
TencentOS Tiny
项目概览
不穿格子衫的农民
/
TencentOS Tiny
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TencentOS Tiny
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
f63d2d4e
编写于
10月 30, 2019
作者:
S
Supowang1989
提交者:
GitHub
10月 30, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #56 from thelittlehan/master
linux port更新
上级
d64e7f1e
514a4200
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
49 addition
and
13 deletion
+49
-13
arch/linux/common/tos_cpu.c
arch/linux/common/tos_cpu.c
+1
-1
arch/linux/posix/gcc/port.c
arch/linux/posix/gcc/port.c
+17
-8
arch/linux/posix/gcc/port.h
arch/linux/posix/gcc/port.h
+1
-1
board/Linux_Posix/mqtt_demo/src/socket_wrapper.c
board/Linux_Posix/mqtt_demo/src/socket_wrapper.c
+30
-3
未找到文件。
arch/linux/common/tos_cpu.c
浏览文件 @
f63d2d4e
...
...
@@ -78,6 +78,7 @@ __API__ void tos_cpu_cpsr_restore(cpu_cpsr_t cpsr)
__KERNEL__
void
cpu_init
(
void
)
{
port_init
();
k_cpu_cycle_per_tick
=
TOS_CFG_CPU_CLOCK
/
k_cpu_tick_per_second
;
cpu_systick_init
(
k_cpu_cycle_per_tick
);
...
...
@@ -108,7 +109,6 @@ __KERNEL__ void cpu_irq_context_switch(void)
__KERNEL__
void
cpu_systick_init
(
k_cycle_t
cycle_per_tick
)
{
port_systick_priority_set
(
TOS_CFG_CPU_SYSTICK_PRIO
);
port_systick_config
(
cycle_per_tick
);
}
...
...
arch/linux/posix/gcc/port.c
浏览文件 @
f63d2d4e
...
...
@@ -81,17 +81,23 @@ interrupt_manager _int_manager={
};
static
uint64_t
tick_ms
=
0
;
static
pthread_t
main_thread_id
;
static
pthread_mutex_t
cpsr_mutex
;
#define CHECK_IS_MAIN_THREAD(main_thread_id) \
if(main_thread_id != pthread_self()) return
__PORT__
void
port_int_disable
(
void
)
{
sigset_t
signal_mask
,
*
manager_mask
=
NULL
;
if
(
_int_manager
.
count
==
0
){
pthread_mutex_lock
(
&
cpsr_mutex
);
manager_mask
=
&
(
_int_manager
.
signal_mask
);
sigfillset
(
&
signal_mask
);
_filter_signal
(
&
signal_mask
);
pthread_sigmask
(
SIG_BLOCK
,
&
signal_mask
,
manager_mask
);
}
_int_manager
.
count
++
;
sigfillset
(
&
signal_mask
);
_filter_signal
(
&
signal_mask
);
pthread_sigmask
(
SIG_BLOCK
,
&
signal_mask
,
manager_mask
);
}
__PORT__
void
port_int_enable
(
void
)
...
...
@@ -102,6 +108,7 @@ __PORT__ void port_int_enable(void)
if
(
_int_manager
.
count
==
0
){
sigaddset
(
&
(
_int_manager
.
signal_mask
),
SIG_RESUME
);
//ensure SIG_RESUME is blocked
_filter_signal
(
&
(
_int_manager
.
signal_mask
));
pthread_mutex_unlock
(
&
cpsr_mutex
);
pthread_sigmask
(
SIG_SETMASK
,
&
(
_int_manager
.
signal_mask
),
NULL
);
}
}
...
...
@@ -126,10 +133,6 @@ __PORT__ pthread_t port_create_thread(void *arg)
__PORT__
void
port_sched_start
(
void
)
{
_install_signal
(
SIG_SUSPEND
,
_handle_suspend_thread
);
_install_signal
(
SIG_RESUME
,
_handle_resume_thread
);
_install_signal
(
SIG_CONTEXT_SWITCH
,
_handle_context_switch
);
k_curr_task
=
k_next_task
;
_resume_task
(
k_curr_task
);
...
...
@@ -184,8 +187,13 @@ __PORT__ void port_systick_config(uint32_t cycle_per_tick)
}
}
__PORT__
void
port_
systick_priority_set
(
uint32_t
prio
)
__PORT__
void
port_
init
(
void
)
{
main_thread_id
=
pthread_self
();
pthread_mutex_init
(
&
cpsr_mutex
,
NULL
);
_install_signal
(
SIG_SUSPEND
,
_handle_suspend_thread
);
_install_signal
(
SIG_RESUME
,
_handle_resume_thread
);
_install_signal
(
SIG_CONTEXT_SWITCH
,
_handle_context_switch
);
}
__PORT__
void
port_delay_ms
(
uint32_t
ms
)
...
...
@@ -224,6 +232,7 @@ __PORT__ void _install_signal(int sig,void (*func)(int))
__PORT__
void
_handle_tick_signal
()
{
CHECK_IS_MAIN_THREAD
(
main_thread_id
);
tick_ms
++
;
if
(
tos_knl_is_running
())
{
tos_knl_irq_enter
();
...
...
arch/linux/posix/gcc/port.h
浏览文件 @
f63d2d4e
...
...
@@ -89,7 +89,7 @@ __PORT__ void port_irq_context_switch(void);
__PORT__
void
port_systick_config
(
uint32_t
cycle_per_tick
);
__PORT__
void
port_
systick_priority_set
(
uint32_t
prio
);
//ok
__PORT__
void
port_
init
(
void
);
__PORT__
pthread_t
port_create_thread
(
void
*
arg
);
...
...
board/Linux_Posix/mqtt_demo/src/socket_wrapper.c
浏览文件 @
f63d2d4e
...
...
@@ -12,12 +12,25 @@ static osMutexId socket_send_lock, socket_recv_lock;
osMutexDef
(
socket_send_lock
);
osMutexDef
(
socket_recv_lock
);
static
osSemaphoreId
socket_recv_event
;
osSemaphoreDef
(
socket_recv_event
);
int
socket_init
(
void
)
{
socket_send_lock
=
osMutexCreate
(
osMutex
(
socket_send_lock
));
socket_recv_lock
=
osMutexCreate
(
osMutex
(
socket_recv_lock
));
socket_recv_event
=
osSemaphoreCreate
(
osSemaphore
(
socket_recv_event
),
0
);
return
(
(
socket_recv_event
!=
NULL
)
&&
(
socket_recv_lock
!=
NULL
)
&&
(
socket_send_lock
!=
NULL
)
);
}
return
((
socket_recv_lock
!=
NULL
)
&&
(
socket_send_lock
!=
NULL
));
void
io_signal_handle
(
int
signal
)
{
osSemaphoreRelease
(
socket_recv_event
);
}
int
socket_connect
(
const
char
*
ip
,
const
char
*
port
,
sal_proto_t
proto
)
...
...
@@ -26,6 +39,7 @@ int socket_connect(const char *ip, const char *port, sal_proto_t proto)
.
sin_family
=
AF_INET
,
.
sin_port
=
htons
(
atoi
(
port
))};
int
socket_proto
=
0
;
struct
sigaction
sig_install
;
inet_pton
(
AF_INET
,
ip
,
&
addr
.
sin_addr
);
...
...
@@ -43,6 +57,19 @@ int socket_connect(const char *ip, const char *port, sal_proto_t proto)
}
int
socket_id
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
fcntl
(
socket_id
,
__F_SETOWN
,
getpid
()
);
fcntl
(
socket_id
,
__F_SETSIG
,
SIGIO
);
fcntl
(
socket_id
,
F_SETFL
,
O_ASYNC
);
sig_install
.
sa_flags
=
0
;
sig_install
.
sa_handler
=
io_signal_handle
;
sigfillset
(
&
sig_install
.
sa_mask
);
if
(
0
!=
sigaction
(
SIGIO
,
&
sig_install
,
NULL
)
)
{
printf
(
"socket problem installing %d
\n
"
,
SIGIO
);
}
connect
(
socket_id
,
&
addr
,
sizeof
(
addr
));
return
socket_id
;
...
...
@@ -63,7 +90,7 @@ int socket_send(int sock, const void *buf, size_t len)
}
if
(
send_len
!=
len
)
{
os
Delay
(
5
);
os
SemaphoreWait
(
socket_recv_event
,
100
);
}
}
while
(
len
!=
send_len
);
osMutexRelease
(
socket_send_lock
);
...
...
@@ -85,7 +112,7 @@ int socket_recv(int sock, void *buf, size_t len)
}
if
(
recv_len
!=
len
)
{
os
Delay
(
5
);
os
SemaphoreWait
(
socket_recv_event
,
100
);
}
}
while
(
len
!=
recv_len
);
osMutexRelease
(
socket_recv_lock
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录