lwip arch优化

This commit is contained in:
zhangzheng
2025-02-13 13:28:16 +08:00
parent f86daa3169
commit fe4e4a377d
27 changed files with 611 additions and 666 deletions

4
.vscode/launch.json vendored
View File

@@ -71,8 +71,8 @@
// "miDebuggerPath": "/home/zhangzheng/gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf/bin/aarch64-none-elf-gdb",
// "miDebuggerPath": "/home/mkrtos-smart/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gdb",
// "miDebuggerPath": "/home/toolchains/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf/bin/aarch64-none-elf-gdb",
"miDebuggerPath": "/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb",
// "miDebuggerPath": "/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb",
// "miDebuggerPath": "/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb",
"miDebuggerPath": "/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb",
"miDebuggerServerAddress": "127.0.0.1:33333",
"MIMode": "gdb",
"setupCommands": [

View File

@@ -160,7 +160,6 @@ static void thread_release_stage1_impl(thread_t *th)
if (th->status == THREAD_READY)
{
thread_suspend(th);
preemption();
}
th->ipc_status = THREAD_IPC_ABORT;
thread_sleep_del(th); //!< 从休眠中删除

View File

@@ -1,10 +1,10 @@
#!/bin/bash
# export TOOLCHAIN=/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/bin/
# export TOOLCHAIN_LIB=/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
export TOOLCHAIN=/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/bin/
export TOOLCHAIN_LIB=/home/zhangzheng/toolchain/gcc-arm-10.3-2021.07-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
# export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
# export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
# export TOOLCHAIN=/d/GNUArmEmbeddedToolchain/102021.10/bin/
# export TOOLCHAIN_LIB=/d/GNUArmEmbeddedToolchain/102021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp

View File

@@ -42,7 +42,7 @@
#define MEMP_NUM_TCP_PCB_LISTEN 4 // MEMP_NUM_TCP_PCB_LISTEN:能够监听的TCP连接数量
#define MEMP_NUM_TCP_SEG 64 // MEMP_NUM_TCP_SEG:最多同时在队列中的TCP段数量
#define MEMP_NUM_SYS_TIMEOUT 4 // MEMP_NUM_SYS_TIMEOUT:能够同时激活的timeout个数
#define LWIP_NETCONN_SEM_PER_THREAD 0
// pbuf选项
#define PBUF_POOL_SIZE 32 // PBUF_POOL_SIZE:pbuf内存池个数
#define PBUF_POOL_BUFSIZE 1600 // PBUF_POOL_BUFSIZE:每个pbuf内存池大小

File diff suppressed because it is too large Load Diff

View File

@@ -135,7 +135,7 @@ struct sys_sem {
};
struct sys_mutex {
pthread_mutex_t mutex;
u_mutex_t mutex;
};
struct sys_thread {

View File

@@ -23,7 +23,7 @@ typedef struct ipc_msg
{
umword_t msg_buf[CONFIG_THREAD_IPC_MSG_LEN];
umword_t map_buf[CONFIG_THREAD_MAP_BUF_LEN];
umword_t user[CONFIG_THREAD_USER_BUF_LEN]; // 0 pthread使用 1驱动使用 2 ipc通信时存储目标的pid
umword_t user[CONFIG_THREAD_USER_BUF_LEN]; // 0 pthread使用 1驱动使用 2 ipc通信时存储目标的pid 3虚拟化或者用户自定义
};
uint8_t data[MSG_BUG_LEN];
};

View File

@@ -15,6 +15,7 @@ typedef unsigned long obj_addr_t;
typedef long obj_handler_t;
typedef umword_t addr_t;
typedef umword_t paddr_t;
typedef umword_t mk_pid_t;
/**
* @brief 资源描述符定义

View File

@@ -23,4 +23,4 @@ void cons_svr_obj_init(cons_t *cons);
int console_write(uint8_t *data, size_t len);
int console_read(uint8_t *data, size_t len);
void console_active(pid_t pid, obj_handler_t sem);
void console_active(mk_pid_t pid, obj_handler_t sem);

View File

@@ -1,4 +1,5 @@
#pragma once
#include <u_types.h>
int u_fast_ipc_init(uint8_t *stack_array, uint8_t *msg_buf_array, int stack_msgbuf_array_num, size_t stack_size);
int u_fast_ipc_init(uint8_t *stack_array, uint8_t *msg_buf_array, int stack_msgbuf_array_num, size_t stack_size,
obj_handler_t *threads_obj);

View File

@@ -1,14 +1,14 @@
#include <u_task.h>
#include <u_types.h>
#include <u_thread.h>
#include <u_prot.h>
#include <u_rpc_svr.h>
#include <u_rpc_buf.h>
#include <u_hd_man.h>
#include <errno.h>
#include <rpc_prot.h>
#include <string.h>
#include <errno.h>
#include <u_hd_man.h>
#include <u_prot.h>
#include <u_rpc_buf.h>
#include <u_rpc_svr.h>
#include <u_task.h>
#include <u_thread.h>
#include <u_types.h>
#define MAGIC_NS_USERPID 0xbabababa
@@ -16,14 +16,20 @@ int fast_ipc_setsp(int i, void *stack);
#define FAST_IPC_MAIN_STACK_SIZE 512
static ATTR_ALIGN(8) uint8_t com_stack[FAST_IPC_MAIN_STACK_SIZE];
/*内核接收消息用*/
static uint8_t cons_msg_buf_main[MSG_BUG_LEN + CONFIG_THREAD_MAP_BUF_LEN * WORD_BYTES];
static umword_t *cons_map_buf = (umword_t *)(cons_msg_buf_main + MSG_BUG_LEN);
static umword_t *cons_map_buf = (umword_t *)(cons_msg_buf_main + MSG_BUG_LEN); // 映射buf缓存
static volatile umword_t cons_stack_bitmap;
static uint8_t fake_pthread[256/*FIXME:*/];
static uint8_t fake_pthread[256 /*FIXME:*/];
/*栈个数代表并发个数*/
static int stack_array_nr;
static size_t stack_item_size;
static uint8_t *cons_stack;
static uint8_t *cons_msg_buf;
static obj_handler_t *cons_thread_th;
static int fast_ipc_dat_copy(ipc_msg_t *dst_ipc, ipc_msg_t *src_ipc, msg_tag_t tag)
{
@@ -37,10 +43,8 @@ static int fast_ipc_dat_copy(ipc_msg_t *dst_ipc, ipc_msg_t *src_ipc, msg_tag_t t
}
static void update_map_buf(void)
{
for (int i = 0; i < CONFIG_THREAD_MAP_BUF_LEN; i++)
{
if (cons_map_buf[i] == 0)
{
for (int i = 0; i < CONFIG_THREAD_MAP_BUF_LEN; i++) {
if (cons_map_buf[i] == 0) {
cons_map_buf[i] = vpage_create_raw3(0, 0, handler_alloc()).raw; /*TODO:申请失败检查*/
}
}
@@ -55,23 +59,19 @@ static msg_tag_t process_ipc(int j, umword_t obj, long tag)
msg = (ipc_msg_t *)(&cons_msg_buf[j * MSG_BUG_LEN]);
ret_tag = msg_tag_init4(0, 0, 0, -EIO);
svr_obj = (rpc_svr_obj_t *)obj;
if (svr_obj == NULL)
{
if (svr_obj == NULL) {
ret_tag = msg_tag_init4(0, 0, 0, -EACCES);
goto end;
}
if (svr_obj == (void *)MAGIC_NS_USERPID)
{
if (svr_obj == (void *)MAGIC_NS_USERPID) {
/*获取ns的user id*/
svr_obj = meta_find_svr_obj(NS_PROT);
}
if (svr_obj == NULL)
{
if (svr_obj == NULL) {
ret_tag = msg_tag_init4(0, 0, 0, -EACCES);
goto end;
}
if (svr_obj->dispatch)
{
if (svr_obj->dispatch) {
ret_tag = svr_obj->dispatch(svr_obj, msg_tag_init(tag), msg);
}
end:
@@ -79,13 +79,10 @@ end:
}
static void update_map_buf_last(void)
{
for (int i = 0; i < CONFIG_THREAD_MAP_BUF_LEN; i++)
{
for (int i = 0; i < CONFIG_THREAD_MAP_BUF_LEN; i++) {
vpage_t vpage = vpage_create_raw(cons_map_buf[i]);
if (handler_is_used(vpage.addr))
{
if (task_obj_valid(TASK_THIS, vpage.addr, 0).prot == 1)
{
if (handler_is_used(vpage.addr)) {
if (task_obj_valid(TASK_THIS, vpage.addr, 0).prot == 1) {
cons_map_buf[i] = vpage_create_raw3(0, 0, handler_alloc()).raw;
}
}
@@ -94,8 +91,12 @@ static void update_map_buf_last(void)
static void fast_ipc_goto_process(int j, long tag, umword_t obj, umword_t arg1, umword_t arg2)
{
msg_tag_t ret_tag;
thread_msg_buf_set(-1, (void *)(&cons_msg_buf[j * MSG_BUG_LEN]));
ipc_msg_t *msg;
msg = (void *)(&cons_msg_buf[j * MSG_BUG_LEN]);
thread_msg_buf_set(-1, msg);
update_map_buf();
msg->user[3] = cons_thread_th[j];//设置私有变量FIXME: 一种更加通用的方法
task_com_unlock(TASK_THIS);
ret_tag = process_ipc(j, obj, tag);
task_com_lock(TASK_THIS);
@@ -106,10 +107,8 @@ static void fast_ipc_goto_process(int j, long tag, umword_t obj, umword_t arg1,
static __attribute__((optimize(0))) void fast_ipc_com_point(msg_tag_t tag, umword_t arg0, umword_t arg1, umword_t arg2)
{
int i;
for (i = 0; i < stack_array_nr; i++)
{
if ((cons_stack_bitmap & (1 << i)) == 0)
{
for (i = 0; i < stack_array_nr; i++) {
if ((cons_stack_bitmap & (1 << i)) == 0) {
cons_stack_bitmap |= (1 << i);
break;
}
@@ -117,7 +116,7 @@ static __attribute__((optimize(0))) void fast_ipc_com_point(msg_tag_t tag, umwor
fast_ipc_dat_copy((void *)&cons_msg_buf[i * MSG_BUG_LEN], (void *)cons_msg_buf_main, tag);
fast_ipc_goto_process(fast_ipc_setsp(i, &cons_stack[(i + 1) * stack_item_size - 8]), tag.raw, arg0, arg1, arg2);
}
int u_fast_ipc_init(uint8_t *stack_array, uint8_t *msg_buf_array, int stack_msgbuf_array_num, size_t stack_size)
int u_fast_ipc_init(uint8_t *stack_array, uint8_t *msg_buf_array, int stack_msgbuf_array_num, size_t stack_size, obj_handler_t *threads_obj)
{
msg_tag_t tag;
@@ -125,9 +124,9 @@ int u_fast_ipc_init(uint8_t *stack_array, uint8_t *msg_buf_array, int stack_msgb
cons_stack = stack_array;
stack_item_size = stack_size;
cons_msg_buf = msg_buf_array;
cons_thread_th = threads_obj;
ipc_msg_t *msg = (void *)cons_msg_buf_main;
for (int i = 0; i < CONFIG_THREAD_MAP_BUF_LEN; i++)
{
for (int i = 0; i < CONFIG_THREAD_MAP_BUF_LEN; i++) {
cons_map_buf[i] = vpage_create_raw3(0, 0, handler_alloc()).raw;
msg->map_buf[i] = cons_map_buf[i];
}
@@ -136,8 +135,7 @@ int u_fast_ipc_init(uint8_t *stack_array, uint8_t *msg_buf_array, int stack_msgb
tag = task_set_com_point(TASK_THIS, &fast_ipc_com_point, (addr_t)com_stack,
sizeof(com_stack), (void *)(&cons_stack_bitmap),
stack_msgbuf_array_num, cons_msg_buf_main);
if (msg_tag_get_val(tag) < 0)
{
if (msg_tag_get_val(tag) < 0) {
return msg_tag_get_val(tag);
}
return msg_tag_get_val(tag);

View File

@@ -18,15 +18,18 @@
#include "hw_block.h"
#include "appfs_open.h"
#include "u_sleep.h"
#include "u_hd_man.h"
#define STACK_COM_ITME_SIZE (2 * 1024)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static obj_handler_t com_th_obj;
static fs_info_t fs_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
com_th_obj = handler_alloc();
assert(com_th_obj != HANDLER_INVALID);
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
}
int main(int argc, char *argv[])
{

View File

@@ -1,25 +1,29 @@
#include <stdio.h>
#include "u_log.h"
#include "ns_cli.h"
#include "u_rpc_svr.h"
#include "u_prot.h"
#include "u_env.h"
#include "u_task.h"
#include "cons_cli.h"
#include "fs_rpc.h"
#include <stdio.h>
#include "ns_cli.h"
#include "u_env.h"
#include "u_hd_man.h"
#include "u_log.h"
#include "u_prot.h"
#include "u_rpc_svr.h"
#include "u_task.h"
#include <assert.h>
#include <stdlib.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <u_fast_ipc.h>
#define STACK_COM_ITME_SIZE (2*1024)
#define STACK_COM_ITME_SIZE (2 * 1024)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static obj_handler_t com_th_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
com_th_obj = handler_alloc();
assert(com_th_obj != HANDLER_INVALID);
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
}
int main(int argc, char *argv[])
{
@@ -29,17 +33,14 @@ int main(int argc, char *argv[])
task_set_obj_name(TASK_THIS, TASK_THIS, "tk_cpio");
task_set_obj_name(TASK_THIS, THREAD_MAIN, "th_cpio");
for (int i = 0; i < argc; i++)
{
for (int i = 0; i < argc; i++) {
printf("args[%d]:%s\n", i, argv[i]);
}
fast_ipc_init();
int o;
const char *optstring = "m:"; // 有三个选项-abc其中c选项后有冒号所以后面必须有参数
while ((o = getopt(argc, argv, optstring)) != -1)
{
switch (o)
{
while ((o = getopt(argc, argv, optstring)) != -1) {
switch (o) {
case 'm':
printf("mount path:%s\n", optarg);
mount_path = optarg;

View File

@@ -1,22 +1,29 @@
#include "u_log.h"
#include "ns_cli.h"
#include "u_rpc_svr.h"
#include "u_prot.h"
#include "u_env.h"
#include "cons_cli.h"
#include "fs_rpc.h"
#include "ns_cli.h"
#include "u_env.h"
#include "u_hd_man.h"
#include "u_log.h"
#include "u_prot.h"
#include "u_rpc_svr.h"
#include <assert.h>
#include <ff.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include "u_hd_man.h"
#include <u_fast_ipc.h>
#define STACK_COM_ITME_SIZE (2048)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static obj_handler_t com_th_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
com_th_obj = handler_alloc();
assert(com_th_obj != HANDLER_INVALID);
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
}
static FATFS fs;
@@ -35,20 +42,15 @@ int main(int args, char *argv[])
FRESULT res = f_mount(&fs, "0:", 1);
if (res != FR_OK)
{
if (res != FR_OK) {
assert(sizeof(fs.win) >= FF_MAX_SS);
res = f_mkfs("0:", &defopt, (void *)(fs.win), FF_MAX_SS); // 第三个参数可以设置成NULL默认使用heap memory
if (res != FR_OK)
{
if (res != FR_OK) {
cons_write_str("f_mkfs err.\n");
exit(-1);
}
else
{
} else {
res = f_mount(&fs, "0:", 1);
if (res != FR_OK)
{
if (res != FR_OK) {
cons_write_str("f_mount err.\n");
exit(-1);
}

View File

@@ -137,7 +137,7 @@ int console_read(uint8_t *data, size_t len)
* @brief 激活控制台为发送者进程
*
*/
void console_active(pid_t pid, obj_handler_t sem)
void console_active(mk_pid_t pid, obj_handler_t sem)
{
cons_obj.active_pid = pid;
if (sem)

View File

@@ -1,4 +1,4 @@
#pragma once
#include <u_types.h>
void console_init(void);
void console_active(pid_t pid, obj_handler_t sem);
void console_active(mk_pid_t pid, obj_handler_t sem);

View File

@@ -8,39 +8,41 @@
* @copyright Copyright (c) 2023
*
*/
#include "u_log.h"
#include "u_prot.h"
#include "u_factory.h"
#include "u_thread.h"
#include "u_task.h"
#include "u_sleep.h"
#include "u_ipc.h"
#include "u_hd_man.h"
#include "u_irq_sender.h"
#include "u_app_loader.h"
#include "u_rpc_svr.h"
#include "pm.h"
#include "cons.h"
#include "test/test.h"
#include "u_rpc_svr.h"
#include "namespace.h"
#include "ns_svr.h"
#include "syscall_backend.h"
#include "parse_cfg.h"
#include "pm.h"
#include "syscall_backend.h"
#include "test/test.h"
#include "u_app_loader.h"
#include "u_factory.h"
#include "u_hd_man.h"
#include "u_ipc.h"
#include "u_irq_sender.h"
#include "u_log.h"
#include "u_prot.h"
#include "u_rpc_svr.h"
#include "u_sleep.h"
#include "u_task.h"
#include "u_thread.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <u_fast_ipc.h>
#define DEFAULT_INIT_CFG "init.cfg"
#define STACK_COM_ITME_SIZE (3 * 1024)
#define DEFAULT_INIT_CFG "init.cfg"
#define STACK_COM_ITME_SIZE (2 * 1024)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static obj_handler_t com_th_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
com_th_obj = handler_alloc();
assert(com_th_obj != HANDLER_INVALID);
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
}
int main(int argc, char *args[])
{
@@ -70,9 +72,8 @@ int main(int argc, char *args[])
ret = parse_cfg(DEFAULT_INIT_CFG, env);
printf("run app num is %d.\n", ret);
// namespace_loop();
while (1)
{
// task_unmap(TASK_THIS, vpage_create_raw3(KOBJ_DELETE_RIGHT, 0, THREAD_MAIN));
while (1) {
u_sleep_ms((umword_t)(-1));
}
return 0;

View File

@@ -1,43 +1,42 @@
#include "cons_cli.h"
#include "netconf.h"
#include <unistd.h>
#include <stdio.h>
#include <assert.h>
#include "u_sleep.h"
#include "lwiperf.h"
#include "netconf.h"
#include "u_prot.h"
#include "u_sleep.h"
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <u_hd_man.h>
#include <u_task.h>
#include <u_factory.h>
#include <u_share_mem.h>
#include <u_sema.h>
#include <blk_drv_cli.h>
#include <ns_cli.h>
#include "fs_rpc.h"
#include "net_rpc.h"
#include "u_fast_ipc.h"
#include "net_test.h"
#include "u_fast_ipc.h"
#include <blk_drv_cli.h>
#include <ns_cli.h>
#include <u_factory.h>
#include <u_hd_man.h>
#include <u_sema.h>
#include <u_share_mem.h>
#include <u_task.h>
static umword_t addr;
static umword_t size;
obj_handler_t net_drv_hd;
#define STACK_COM_ITME_SIZE (2 * 1024 + 512 /*sizeof(struct pthread) + TP_OFFSET*/)
#define STACK_NUM 4
#define STACK_NUM 4
ATTR_ALIGN(8)
static uint8_t stack_coms[STACK_COM_ITME_SIZE * STACK_NUM];
static uint8_t msg_buf_coms[MSG_BUG_LEN * STACK_NUM];
static obj_handler_t com_th_obj[STACK_NUM];
static void fast_ipc_init(void)
{
// ipc_msg_t *ipc_msg = (ipc_msg_t *)msg_buf_coms;
// for (int i = 0; i < STACK_NUM; i++)
// {
// ipc_msg->user[0] = (umword_t)(stack_coms + (i * STACK_COM_ITME_SIZE) + 2 * 1024);
// }
for (int i = 0; i < STACK_NUM; i++) {
com_th_obj[i] = handler_alloc();
assert(com_th_obj[i] != HANDLER_INVALID);
}
u_fast_ipc_init(stack_coms,
msg_buf_coms, STACK_NUM, STACK_COM_ITME_SIZE);
msg_buf_coms, STACK_NUM, STACK_COM_ITME_SIZE, com_th_obj);
}
int main(int args, char *argv[])
{
@@ -48,15 +47,13 @@ int main(int args, char *argv[])
printf("net startup..\n");
fast_ipc_init();
ret = rpc_meta_init(THREAD_MAIN, &hd);
if (ret < 0)
{
if (ret < 0) {
printf("rpc meta init failed\n");
return -1;
}
again:
ret = ns_query("/eth", &net_drv_hd, 0x1);
if (ret < 0)
{
if (ret < 0) {
u_sleep_ms(50);
goto again;
}
@@ -72,50 +69,42 @@ again:
obj_handler_t sem_hd;
if (blk_drv_cli_map(net_drv_hd, &sem_hd) < 0)
{
if (blk_drv_cli_map(net_drv_hd, &sem_hd) < 0) {
printf("net drv sem map error.\n");
return -1;
}
obj_handler_t shm_hd = handler_alloc();
if (shm_hd == HANDLER_INVALID)
{
if (shm_hd == HANDLER_INVALID) {
printf("handler alloc failed.\n");
return -1;
}
tag = facotry_create_share_mem(FACTORY_PROT, vpage_create_raw3(KOBJ_ALL_RIGHTS, 0, shm_hd),
SHARE_MEM_CNT_BUDDY_CNT, 2048);
if (msg_tag_get_val(tag) < 0)
{
if (msg_tag_get_val(tag) < 0) {
printf("share mem create failed.\n");
return -1;
}
tag = share_mem_map(shm_hd, vma_addr_create(VPAGE_PROT_RW, VMA_ADDR_RESV, 0), &addr, &size);
if (msg_tag_get_val(tag) < 0)
{
if (msg_tag_get_val(tag) < 0) {
printf("share mem map failed.\n");
return -1;
}
ret = ns_register("/net", hd, MOUNT_NODE);
if (ret < 0)
{
if (ret < 0) {
printf("ns reg failed.\n");
return -1;
}
cons_write_str("net mount success\n");
net_test();
while (1)
{
if (msg_tag_get_prot(u_sema_down(sem_hd, 0, NULL)) < 0)
{
while (1) {
if (msg_tag_get_prot(u_sema_down(sem_hd, 0, NULL)) < 0) {
printf("error.\n");
}
int ret = blk_drv_cli_read(net_drv_hd, shm_hd, 0, 0);
if (ret > 0)
{
if (ret > 0) {
lwip_pkt_handle_raw((uint8_t *)addr, ret);
}
}

View File

@@ -11,15 +11,20 @@
#include <u_env.h>
#include <pthread.h>
#include <u_fast_ipc.h>
#define STACK_COM_ITME_SIZE (1024+512)
#include "u_hd_man.h"
#define STACK_COM_ITME_SIZE (2048)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static obj_handler_t com_th_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
com_th_obj = handler_alloc();
assert(com_th_obj != HANDLER_INVALID);
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
}
void *test_func(void *arg)
{
msg_tag_t tag;

View File

@@ -16,13 +16,18 @@
#include <u_sys.h>
#include <u_task.h>
#include <u_thread.h>
#define STACK_COM_ITME_SIZE (1024 + 512)
#include "u_hd_man.h"
#define STACK_COM_ITME_SIZE (2048)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static obj_handler_t com_th_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
com_th_obj = handler_alloc();
assert(com_th_obj != HANDLER_INVALID);
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
}
static blk_drv_t blk_drv;
int blk_drv_write(obj_handler_t obj, int len, int inx)

View File

@@ -15,13 +15,18 @@
#include <u_fast_ipc.h>
#include "mk_display_drv_impl.h"
#define STACK_COM_ITME_SIZE (1024+512)
#include "u_hd_man.h"
#define STACK_COM_ITME_SIZE (2048)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static obj_handler_t com_th_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
com_th_obj = handler_alloc();
assert(com_th_obj != HANDLER_INVALID);
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
}
int main(int argc, char *argv[])
{

View File

@@ -21,14 +21,19 @@
#include <errno.h>
#include "at_surf_f437_board_emac.h"
#include "u_hd_man.h"
static blk_drv_t net_drv; //!< 网络驱动的协议
#define STACK_COM_ITME_SIZE (2048)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static obj_handler_t com_th_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
com_th_obj = handler_alloc();
assert(com_th_obj != HANDLER_INVALID);
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
}
int blk_drv_write(obj_handler_t obj, int len, int inx)
{

View File

@@ -15,13 +15,18 @@
#include <u_fast_ipc.h>
#include "mk_i2c_drv_impl.h"
#define STACK_COM_ITME_SIZE (1024+512)
#include "u_hd_man.h"
#define STACK_COM_ITME_SIZE (2048)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static obj_handler_t com_th_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
com_th_obj = handler_alloc();
assert(com_th_obj != HANDLER_INVALID);
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
}
int main(int argc, char *argv[])
{

View File

@@ -15,13 +15,18 @@
#include <u_fast_ipc.h>
#include "mk_pca9555_drv_impl.h"
#define STACK_COM_ITME_SIZE (1024+512)
#include "u_hd_man.h"
#define STACK_COM_ITME_SIZE (2048)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static obj_handler_t com_th_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
com_th_obj = handler_alloc();
assert(com_th_obj != HANDLER_INVALID);
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
}
int main(int argc, char *argv[])
{

View File

@@ -14,13 +14,18 @@
#include "mk_pin_drv_impl.h"
#include <u_task.h>
#include <u_fast_ipc.h>
#define STACK_COM_ITME_SIZE (1024+512)
#include "u_hd_man.h"
#define STACK_COM_ITME_SIZE (2048)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static obj_handler_t com_th_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
com_th_obj = handler_alloc();
assert(com_th_obj != HANDLER_INVALID);
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
}
int main(int argc, char *argv[])
{

View File

@@ -20,14 +20,19 @@
#include <u_fast_ipc.h>
#include "mk_snd_drv_impl.h"
#include "u_hd_man.h"
static blk_drv_t snd_drv; //!< 网络驱动的协议
#define STACK_COM_ITME_SIZE (1024 + 512)
#define STACK_COM_ITME_SIZE (2048)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static obj_handler_t com_th_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
com_th_obj = handler_alloc();
assert(com_th_obj != HANDLER_INVALID);
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
}
int blk_drv_write(obj_handler_t obj, int len, int inx)
{

View File

@@ -16,13 +16,18 @@
#include <u_sys.h>
#include <u_task.h>
#include <u_thread.h>
#define STACK_COM_ITME_SIZE (1024 + 512)
#include "u_hd_man.h"
#define STACK_COM_ITME_SIZE (2048)
ATTR_ALIGN(8)
uint8_t stack_coms[STACK_COM_ITME_SIZE];
uint8_t msg_buf_coms[MSG_BUG_LEN];
static obj_handler_t com_th_obj;
void fast_ipc_init(void)
{
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE);
com_th_obj = handler_alloc();
assert(com_th_obj != HANDLER_INVALID);
u_fast_ipc_init(stack_coms, msg_buf_coms, 1, STACK_COM_ITME_SIZE, &com_th_obj);
}
static blk_drv_t blk_drv;
int blk_drv_write(obj_handler_t obj, int len, int inx)