fastipc初版

This commit is contained in:
zhangzheng
2024-12-27 08:23:26 +08:00
parent 90407a8777
commit a1f149e2f3
19 changed files with 536 additions and 141 deletions

View File

@@ -16,4 +16,9 @@ msg_tag_t task_unmap(obj_handler_t task_han, vpage_t vpage);
msg_tag_t task_alloc_ram_base(obj_handler_t task_han, umword_t size, addr_t *alloc_addr);
msg_tag_t task_copy_data(obj_handler_t task_obj, void *st_addr, umword_t size);
msg_tag_t task_copy_data_to(obj_handler_t task_obj, obj_handler_t dst_task_obj, void *st_addr, void *dst_addr, umword_t size);
msg_tag_t task_set_com_point(obj_handler_t task_obj, void *com_point_func, addr_t stack);
msg_tag_t task_set_com_point(obj_handler_t task_obj, void *com_point_func,
addr_t stack, umword_t stack_size,
void *bitmap, int bitmap_len,
void *msg_buf);
msg_tag_t task_com_unlock(obj_handler_t task_obj);
msg_tag_t task_com_lock(obj_handler_t task_obj);

View File

@@ -7,9 +7,9 @@
#define MSG_BUF_RECV_R_FLAGS 0x02U //!< 接收上次发送数据的接收者
#define MSG_BUF_REPLY_FLAGS 0x04U //!<
#define IPC_MSG_SIZE (CONFIG_THREAD_IPC_MSG_LEN * sizeof(void*))
#define MAP_BUF_SIZE (CONFIG_THREAD_MAP_BUF_LEN * sizeof(void*))
#define IPC_USER_SIZE (CONFIG_THREAD_USER_BUF_LEN * sizeof(void*))
#define IPC_MSG_SIZE (CONFIG_THREAD_IPC_MSG_LEN * sizeof(void *))
#define MAP_BUF_SIZE (CONFIG_THREAD_MAP_BUF_LEN * sizeof(void *))
#define IPC_USER_SIZE (CONFIG_THREAD_USER_BUF_LEN * sizeof(void *))
#if IS_ENABLED(CONFIG_VCPU)
#define IPC_VPUC_MSG_OFFSET (3 * 1024) //!< vcpu 传递消息的偏移量
@@ -71,8 +71,8 @@ msg_tag_t thread_ipc_wait(ipc_timeout_t timeout, umword_t *obj, obj_handler_t ip
msg_tag_t thread_ipc_reply(msg_tag_t in_tag, ipc_timeout_t timeout);
msg_tag_t thread_ipc_send(msg_tag_t in_tag, obj_handler_t target_th_obj, ipc_timeout_t timeout);
msg_tag_t thread_ipc_call(msg_tag_t in_tag, obj_handler_t target_th_obj, ipc_timeout_t timeout);
msg_tag_t thread_ipc_fast_call(msg_tag_t in_tag, obj_handler_t target_obj);
msg_tag_t thread_ipc_fast_replay(obj_handler_t target_obj);
msg_tag_t thread_ipc_fast_call(msg_tag_t in_tag, obj_handler_t target_obj, umword_t arg0, umword_t arg1, umword_t arg2);
msg_tag_t thread_ipc_fast_replay(msg_tag_t in_tag, obj_handler_t target_obj, int unlock_bitmap);
static inline ipc_msg_t *thread_get_cur_ipc_msg(void)
{

View File

@@ -14,7 +14,9 @@ enum task_op_code
TASK_COPY_DATA,
TASK_SET_OBJ_NAME,
TASK_COPY_DATA_TO, //!< 从当前task拷贝数据到目的task
TASK_SET_COM_POINT
TASK_SET_COM_POINT,
TASK_COM_UNLOCK,
TASK_COM_LOCK,
};
msg_tag_t task_set_obj_name(obj_handler_t dst_task, obj_handler_t obj, const char *name)
@@ -196,13 +198,50 @@ msg_tag_t task_copy_data_to(obj_handler_t task_obj, obj_handler_t dst_task_obj,
return msg_tag_init(r0);
}
msg_tag_t task_set_com_point(obj_handler_t task_obj, void *com_point_func, addr_t stack)
msg_tag_t task_set_com_point(obj_handler_t task_obj, void *com_point_func, addr_t stack, umword_t stack_size, void *bitmap, int bitmap_len, void *msg_buf)
{
register volatile umword_t r0 asm(ARCH_REG_0);
mk_syscall(syscall_prot_create(TASK_SET_COM_POINT, TASK_PROT, task_obj).raw,
com_point_func,
stack,
stack_size,
bitmap,
bitmap_len,
msg_buf);
asm __volatile__(""
:
:
: ARCH_REG_0, ARCH_REG_1);
return msg_tag_init(r0);
}
msg_tag_t task_com_unlock(obj_handler_t task_obj)
{
register volatile umword_t r0 asm(ARCH_REG_0);
mk_syscall(syscall_prot_create(TASK_COM_UNLOCK, TASK_PROT, task_obj).raw,
0,
0,
0,
0,
0,
0);
asm __volatile__(""
:
:
: ARCH_REG_0, ARCH_REG_1);
return msg_tag_init(r0);
}
msg_tag_t task_com_lock(obj_handler_t task_obj)
{
register volatile umword_t r0 asm(ARCH_REG_0);
mk_syscall(syscall_prot_create(TASK_COM_LOCK, TASK_PROT, task_obj).raw,
0,
0,
0,
0,
0,

View File

@@ -92,15 +92,15 @@ msg_tag_t thread_ipc_call(msg_tag_t in_tag, obj_handler_t target_th_obj, ipc_tim
: ARCH_REG_0);
return msg_tag_init(r0);
}
msg_tag_t thread_ipc_fast_call(msg_tag_t in_tag, obj_handler_t target_obj)
msg_tag_t thread_ipc_fast_call(msg_tag_t in_tag, obj_handler_t target_obj, umword_t arg0, umword_t arg1, umword_t arg2)
{
register volatile umword_t r0 asm(ARCH_REG_0);
mk_syscall(syscall_prot_create4(DO_IPC, THREAD_PROT, target_obj, TRUE).raw,
in_tag.raw,
IPC_FAST_CALL,
0,
0,
0,
arg0,
arg1,
arg2,
0);
asm __volatile__(""
:
@@ -108,13 +108,13 @@ msg_tag_t thread_ipc_fast_call(msg_tag_t in_tag, obj_handler_t target_obj)
: ARCH_REG_0);
return msg_tag_init(r0);
}
msg_tag_t thread_ipc_fast_replay(obj_handler_t target_obj)
msg_tag_t thread_ipc_fast_replay(msg_tag_t in_tag, obj_handler_t target_obj, int unlock_bitmap)
{
register volatile umword_t r0 asm(ARCH_REG_0);
mk_syscall(syscall_prot_create4(DO_IPC, THREAD_PROT, target_obj, TRUE).raw,
0,
in_tag.raw,
IPC_FAST_REPLAY,
0,
unlock_bitmap,
0,
0,
0);
@@ -147,7 +147,7 @@ msg_tag_t thread_msg_buf_set(obj_handler_t obj, void *msg)
register volatile umword_t r1 asm(ARCH_REG_1);
register volatile umword_t r2 asm(ARCH_REG_2);
mk_syscall(syscall_prot_create(MSG_BUG_SET, THREAD_PROT, obj).raw,
mk_syscall(syscall_prot_create4(MSG_BUG_SET, THREAD_PROT, obj, TRUE).raw,
0,
msg,
0,