修复一些bug
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#define USER_ISR_START_NO 16
|
||||
|
||||
bool_t irq_check_usability(int inx);
|
||||
void irq_alloc(int inx, irq_sender_t *irq, void (*irq_tigger_func)(irq_entry_t *irq));
|
||||
bool_t irq_alloc(int inx, irq_sender_t *irq,
|
||||
void (*irq_tigger_func)(irq_entry_t *irq));
|
||||
void irq_free(int inx);
|
||||
irq_entry_t *irq_get(int inx);
|
||||
|
||||
@@ -14,7 +14,6 @@ typedef struct mem_heap
|
||||
union
|
||||
{
|
||||
char name[MEM_HEAP_NAME];
|
||||
// pid_t pid;
|
||||
};
|
||||
struct mem_heap *next;
|
||||
struct mem_heap *prev;
|
||||
@@ -29,7 +28,6 @@ typedef struct mem
|
||||
struct mem_heap *heap_start; //!< 开始位置
|
||||
struct mem_heap *heap_end; //!< 结束位置
|
||||
struct mem_heap *l_heap; //!< 空闲位置
|
||||
// uint16_t blong_user; //!< 属于用户
|
||||
spinlock_t lock;
|
||||
} mem_t;
|
||||
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file app.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "app.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file cpulock.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "arch.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file factory.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "factory.h"
|
||||
#include "kobject.h"
|
||||
#include "prot.h"
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
/*
|
||||
* @Author: zhangzheng
|
||||
* @Date: 2023-08-14 09:47:54
|
||||
* @LastEditors: zhangzheng 1358745329@qq.com
|
||||
* @FilePath: /mkrtos-real/mkrtos_knl/inc/knl/globals.h
|
||||
* @Description:
|
||||
/**
|
||||
* @file globals.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "globals.h"
|
||||
#include "types.h"
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file init.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "init.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file ipc.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "ipc.h"
|
||||
#include "types.h"
|
||||
#include "init.h"
|
||||
@@ -30,7 +40,7 @@ typedef struct ipc
|
||||
kobject_t kobj; //!< 内核对象
|
||||
spinlock_t lock; //!< 操作的锁 TODO: 使用内核对象锁
|
||||
slist_head_t wait_send; //!< 发送等待队列
|
||||
slist_head_t recv_send; //!< 发送等待队列
|
||||
slist_head_t recv_send; //!< 接收等待队列
|
||||
slist_head_t node; //!< 超时检查链表
|
||||
thread_t *svr_th; //!< 服务端 TODO:增加引用计数
|
||||
thread_t *last_cli_th; //!< 上一次发送数据的客户端TODO:增加引用计数
|
||||
@@ -49,39 +59,82 @@ enum ipc_op
|
||||
static void wake_up_th(ipc_t *ipc);
|
||||
static slist_head_t wait_list;
|
||||
|
||||
/**
|
||||
* @brief 初始化一个超时等待队列
|
||||
*
|
||||
*/
|
||||
void timeout_wait_list_init(void)
|
||||
{
|
||||
slist_init(&wait_list);
|
||||
}
|
||||
INIT_KOBJ(timeout_wait_list_init);
|
||||
|
||||
/**
|
||||
* @brief 检查超时队列
|
||||
*
|
||||
*/
|
||||
void timeout_times_tick(void)
|
||||
{
|
||||
ipc_t *ipc;
|
||||
|
||||
slist_foreach(ipc, &wait_list, node)
|
||||
slist_foreach(ipc, &wait_list, node) //!< 第一次循环等待的ipc
|
||||
{
|
||||
umword_t status = spinlock_lock(&ipc->lock);
|
||||
ipc_wait_item_t *item;
|
||||
|
||||
slist_foreach(item, &ipc->wait_send, node)
|
||||
slist_foreach(item, &ipc->wait_send, node) //!< 第二次循环等待irq里面的等待者
|
||||
{
|
||||
if (item->sleep_times != 0 && (--item->sleep_times) == 0)
|
||||
{
|
||||
// slist_del(&item->node);
|
||||
//!< 超时时间满后直接唤醒等待者
|
||||
thread_ready(item->th, TRUE);
|
||||
}
|
||||
}
|
||||
spinlock_set(&ipc->lock, status);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief 唤醒某个ipc的所有等待者
|
||||
*
|
||||
* @param ipc
|
||||
*/
|
||||
static void timeout_times_wake_ipc(ipc_t *ipc)
|
||||
{
|
||||
assert(ipc);
|
||||
ipc_wait_item_t *item;
|
||||
|
||||
slist_foreach(item, &ipc->wait_send, node) //!< 第二次循环等待irq里面的等待者
|
||||
{
|
||||
//!< 超时时间满后直接唤醒等待者
|
||||
thread_ready(item->th, TRUE);
|
||||
}
|
||||
thread_sched();
|
||||
}
|
||||
/**
|
||||
* @brief ipc_wait_item_t结构体初始化
|
||||
*
|
||||
* @param item
|
||||
* @param ipc
|
||||
* @param th
|
||||
* @param times
|
||||
*/
|
||||
static void ipc_wait_item_init(ipc_wait_item_t *item, ipc_t *ipc, thread_t *th, umword_t times)
|
||||
{
|
||||
slist_init(&item->node);
|
||||
item->th = th;
|
||||
item->sleep_times = times;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 添加到一个等待队列,并进行解锁
|
||||
*
|
||||
* @param ipc
|
||||
* @param head
|
||||
* @param th
|
||||
* @param times 超时时间,为0代表一直超时
|
||||
* @param lock
|
||||
* @param status
|
||||
* @return int
|
||||
*/
|
||||
static int add_wait_unlock(ipc_t *ipc, slist_head_t *head, thread_t *th, umword_t times, spinlock_t *lock, int status)
|
||||
{
|
||||
ipc_wait_item_t item;
|
||||
@@ -111,6 +164,11 @@ static int add_wait_unlock(ipc_t *ipc, slist_head_t *head, thread_t *th, umword_
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* @brief 拿出等待队列中的第一个并唤醒
|
||||
*
|
||||
* @param ipc
|
||||
*/
|
||||
static void wake_up_th(ipc_t *ipc)
|
||||
{
|
||||
slist_head_t *mslist = slist_first(&ipc->wait_send);
|
||||
@@ -118,7 +176,14 @@ static void wake_up_th(ipc_t *ipc)
|
||||
|
||||
thread_ready(item->th, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ipc传输时的数据拷贝
|
||||
*
|
||||
* @param dst_th
|
||||
* @param src_th
|
||||
* @param tag
|
||||
* @return int
|
||||
*/
|
||||
static int ipc_data_copy(thread_t *dst_th, thread_t *src_th, msg_tag_t tag)
|
||||
{
|
||||
void *src = src_th->msg.msg;
|
||||
@@ -177,7 +242,8 @@ __check:
|
||||
status = spinlock_lock(&ipc->lock);
|
||||
if (ipc->svr_th->status != THREAD_SUSPEND)
|
||||
{
|
||||
if (add_wait_unlock(ipc, &ipc->wait_send, th, timeout.send_timeout, &ipc->lock, status) < 0)
|
||||
if (add_wait_unlock(ipc, &ipc->wait_send, th,
|
||||
timeout.send_timeout, &ipc->lock, status) < 0)
|
||||
{
|
||||
return msg_tag_init4(MSG_TAG_KNL_ERR, 0, 0, -EWTIMEDOUT);
|
||||
}
|
||||
@@ -193,15 +259,14 @@ __check:
|
||||
}
|
||||
ipc->svr_th->msg.tag = tag;
|
||||
thread_ready(ipc->svr_th, TRUE); //!< 直接唤醒接受者
|
||||
// thread_suspend(th); //!< 发送后客户端直接进入等待状态
|
||||
ipc->last_cli_th = th; //!< 设置上一次发送的客户端
|
||||
ipc->last_cli_th = th; //!< 设置上一次发送的客户端
|
||||
if (add_wait_unlock(ipc, &ipc->recv_send, th, timeout.recv_timeout, &ipc->lock, status) < 0)
|
||||
{
|
||||
ipc->last_cli_th = NULL;
|
||||
ref_counter_dec_and_release(&ipc->last_cli_th->ref, &ipc->last_cli_th->kobj);
|
||||
return msg_tag_init4(MSG_TAG_KNL_ERR, 0, 0, -ERTIMEDOUT);
|
||||
}
|
||||
spinlock_set(&ipc->lock, status);
|
||||
|
||||
// spinlock_set(&ipc->lock, status);
|
||||
tmp_tag = th->msg.tag;
|
||||
ipc->last_cli_th = NULL;
|
||||
return tmp_tag;
|
||||
@@ -226,8 +291,9 @@ static int ipc_reply(ipc_t *ipc, thread_t *th, entry_frame_t *f, msg_tag_t tag)
|
||||
//!< 发送数据给svr_th
|
||||
int ret = ipc_data_copy(ipc->last_cli_th, th, tag); //!< 拷贝数据
|
||||
|
||||
if (ret < 0) {
|
||||
spinlock_set(&ipc->lock, status);;
|
||||
if (ret < 0)
|
||||
{
|
||||
spinlock_set(&ipc->lock, status);
|
||||
return ret;
|
||||
}
|
||||
ipc->last_cli_th->msg.tag = tag;
|
||||
@@ -289,7 +355,9 @@ static void ipc_syscall(kobject_t *kobj, syscall_prot_t sys_p, msg_tag_t in_tag,
|
||||
}
|
||||
else
|
||||
{
|
||||
tag = ipc_call(ipc, th, f, in_tag, ipc_timeout_create(f->r[1]));
|
||||
ref_counter_inc(&th->ref); //!< 引用计数+1
|
||||
tag = ipc_call(ipc, th, f, in_tag, ipc_timeout_create(f->r[1])); //!< ipc call
|
||||
ref_counter_dec_and_release(&th->ref, &th->kobj); //!< 引用计数-1
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -301,7 +369,9 @@ static void ipc_syscall(kobject_t *kobj, syscall_prot_t sys_p, msg_tag_t in_tag,
|
||||
}
|
||||
else
|
||||
{
|
||||
tag = ipc_wait(ipc, th, f, in_tag);
|
||||
ref_counter_inc(&th->ref); //!< 引用计数+1
|
||||
tag = ipc_wait(ipc, th, f, in_tag); //!< 进入等待
|
||||
ref_counter_dec_and_release(&th->ref, &th->kobj); //!< 引用计数-1
|
||||
f->r[1] = ipc->user_id;
|
||||
}
|
||||
}
|
||||
@@ -314,7 +384,9 @@ static void ipc_syscall(kobject_t *kobj, syscall_prot_t sys_p, msg_tag_t in_tag,
|
||||
}
|
||||
else
|
||||
{
|
||||
ref_counter_inc(&th->ref); //!< 引用计数+1
|
||||
int ret = ipc_reply(ipc, th, f, in_tag);
|
||||
ref_counter_dec_and_release(&th->ref, &th->kobj); //!< 引用计数-1
|
||||
tag = msg_tag_init4(0, 0, 0, ret);
|
||||
}
|
||||
}
|
||||
@@ -330,7 +402,10 @@ static void ipc_syscall(kobject_t *kobj, syscall_prot_t sys_p, msg_tag_t in_tag,
|
||||
tag = msg_tag_init4(0, 0, 0, -ENOENT);
|
||||
break;
|
||||
}
|
||||
ipc->svr_th = container_of(source_kobj, thread_t, kobj);
|
||||
thread_t *srv_th = container_of(source_kobj, thread_t, kobj);
|
||||
|
||||
ref_counter_inc(&srv_th->ref);
|
||||
ipc->svr_th = srv_th;
|
||||
ipc->user_id = f->r[2];
|
||||
tag = msg_tag_init4(0, 0, 0, 0);
|
||||
}
|
||||
@@ -361,16 +436,19 @@ static void ipc_release_stage1(kobject_t *kobj)
|
||||
ipc_t *ipc = container_of(kobj, ipc_t, kobj);
|
||||
|
||||
kobject_invalidate(kobj);
|
||||
timeout_times_wake_ipc(ipc);
|
||||
if (ipc->svr_th)
|
||||
{
|
||||
ref_counter_dec_and_release(&ipc->svr_th->ref, &ipc->svr_th->kobj);
|
||||
}
|
||||
|
||||
}
|
||||
static void ipc_release_stage2(kobject_t *kobj)
|
||||
{
|
||||
ipc_t *ipc = container_of(kobj, ipc_t, kobj);
|
||||
|
||||
mm_limit_free(ipc->lim, kobj);
|
||||
printk("ipc 0x%x\n", kobj);
|
||||
}
|
||||
static void ipc_init(ipc_t *ipc, ram_limit_t *lim)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
|
||||
/**
|
||||
* @file irq.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include <arch.h>
|
||||
#include <types.h>
|
||||
#include <kobject.h>
|
||||
@@ -13,6 +22,12 @@
|
||||
static irq_entry_t irqs[IRQ_REG_TAB_SIZE] = {0};
|
||||
static void irq_tigger(irq_entry_t *irq);
|
||||
|
||||
/**
|
||||
* @brief 检查指定的irq号是否可用
|
||||
*
|
||||
* @param inx
|
||||
* @return bool_t
|
||||
*/
|
||||
bool_t irq_check_usability(int inx)
|
||||
{
|
||||
if (inx >= IRQ_REG_TAB_SIZE)
|
||||
@@ -21,17 +36,40 @@ bool_t irq_check_usability(int inx)
|
||||
}
|
||||
return irqs[inx].irq_tigger_func == NULL;
|
||||
}
|
||||
void irq_alloc(int inx, irq_sender_t *irq, void (*irq_tigger_func)(irq_entry_t *irq))
|
||||
/**
|
||||
* @brief 分配一个可用的irq
|
||||
*
|
||||
* @param inx
|
||||
* @param irq
|
||||
* @param irq_tigger_func
|
||||
* @return bool_t
|
||||
*/
|
||||
bool_t irq_alloc(int inx, irq_sender_t *irq, void (*irq_tigger_func)(irq_entry_t *irq))
|
||||
{
|
||||
assert(irqs[inx].irq_tigger_func == NULL);
|
||||
if (irqs[inx].irq_tigger_func != NULL)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
irqs[inx].irq = irq;
|
||||
irqs[inx].irq_tigger_func = irq_tigger_func;
|
||||
return TRUE;
|
||||
}
|
||||
/**
|
||||
* @brief 释放一个irq
|
||||
*
|
||||
* @param inx
|
||||
*/
|
||||
void irq_free(int inx)
|
||||
{
|
||||
assert(inx < IRQ_REG_TAB_SIZE);
|
||||
irqs[inx].irq_tigger_func = NULL;
|
||||
}
|
||||
/**
|
||||
* @brief 获取一个irq
|
||||
*
|
||||
* @param inx
|
||||
* @return irq_entry_t*
|
||||
*/
|
||||
irq_entry_t *irq_get(int inx)
|
||||
{
|
||||
assert(inx < IRQ_REG_TAB_SIZE);
|
||||
@@ -45,7 +83,7 @@ void entry_handler(void)
|
||||
{
|
||||
umword_t isr_no = arch_get_isr_no();
|
||||
|
||||
isr_no -= USER_ISR_START_NO;
|
||||
isr_no -= USER_ISR_START_NO; //!< 系统用的irq偏移
|
||||
|
||||
// printk("%d.\n", isr_no);
|
||||
if (!irq_check_usability(isr_no))
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
|
||||
/**
|
||||
* @file irq_sender.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include <arch.h>
|
||||
#include <types.h>
|
||||
#include <kobject.h>
|
||||
@@ -8,7 +17,11 @@
|
||||
#include <mm_wrap.h>
|
||||
#include <factory.h>
|
||||
#include <irq.h>
|
||||
|
||||
#include <task.h>
|
||||
/**
|
||||
* @brief irq sender的操作号
|
||||
*
|
||||
*/
|
||||
enum irq_sender_op
|
||||
{
|
||||
BIND_IRQ, //!< 绑定一个中断号
|
||||
@@ -23,19 +36,26 @@ enum irq_sender_op
|
||||
*/
|
||||
static void irq_tigger(irq_entry_t *irq)
|
||||
{
|
||||
arch_disable_irq(irq->irq->irq_id);
|
||||
if (irq->irq->wait_thread && thread_get_status(irq->irq->wait_thread) == THREAD_SUSPEND)
|
||||
arch_disable_irq(irq->irq->irq_id); //!< 触发中断时关闭中断
|
||||
if (irq->irq->wait_thread &&
|
||||
thread_get_status(irq->irq->wait_thread) == THREAD_SUSPEND) //!< 线程在休眠时才能唤醒
|
||||
{
|
||||
thread_ready(irq->irq->wait_thread, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
irq->irq->irq_cn++;
|
||||
irq->irq->irq_cn++; //!< 否则中断计数+1
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief 等待一个中断的来临
|
||||
*
|
||||
* @param irq
|
||||
* @param th
|
||||
* @return int
|
||||
*/
|
||||
int irq_sender_wait(irq_sender_t *irq, thread_t *th)
|
||||
{
|
||||
// TODO:临界保护
|
||||
umword_t status = cpulock_lock();
|
||||
|
||||
if (!irq->wait_thread)
|
||||
@@ -48,10 +68,8 @@ int irq_sender_wait(irq_sender_t *irq, thread_t *th)
|
||||
}
|
||||
else
|
||||
{
|
||||
ref_counter_inc(&irq->wait_thread->ref); //! 线程引用计数+1
|
||||
thread_suspend(irq->wait_thread);
|
||||
cpulock_set(status);
|
||||
ref_counter_dec(&irq->wait_thread->ref); //! 线程引用计数+1
|
||||
irq->wait_thread = NULL;
|
||||
}
|
||||
irq->irq_cn = 0;
|
||||
@@ -64,6 +82,21 @@ int irq_sender_wait(irq_sender_t *irq, thread_t *th)
|
||||
return -EACCES;
|
||||
}
|
||||
}
|
||||
static bool_t irq_sender_unbind(irq_sender_t *irq, int irq_no)
|
||||
{
|
||||
assert(irq);
|
||||
if (!irq_check_usability(irq_no) &&
|
||||
irq_get(irq_no)->irq == irq) //!< 是否能够解绑检查
|
||||
{
|
||||
irq_free(irq_no);
|
||||
ref_counter_dec(&irq->ref);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
void irq_sender_syscall(kobject_t *kobj, syscall_prot_t sys_p, msg_tag_t in_tag, entry_frame_t *f)
|
||||
{
|
||||
assert(kobj);
|
||||
@@ -77,65 +110,95 @@ void irq_sender_syscall(kobject_t *kobj, syscall_prot_t sys_p, msg_tag_t in_tag,
|
||||
f->r[0] = msg_tag_init4(0, 0, 0, -EPROTO).raw;
|
||||
return;
|
||||
}
|
||||
ref_counter_inc(&irq->wait_thread->ref); //! 引用计数+1
|
||||
switch (sys_p.op)
|
||||
{
|
||||
case BIND_IRQ:
|
||||
{
|
||||
umword_t irq_no = f->r[1];
|
||||
if (irq_check_usability(irq_no))
|
||||
|
||||
if (irq_alloc(irq_no, irq, irq_tigger) == FALSE)
|
||||
{
|
||||
irq->irq_id = irq_no;
|
||||
irq_alloc(irq_no, irq, irq_tigger);
|
||||
ref_counter_inc(&irq->ref);
|
||||
arch_set_enable_irq_prio(irq_no, f->r[2] & 0xffff, f->r[2] >> 16);
|
||||
tag = msg_tag_init4(0, 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
tag = msg_tag_init4(0, 0, 0, -EACCES);
|
||||
//!< 分配失败则返回错误
|
||||
tag = msg_tag_init4(0, 0, 0, -ENOENT);
|
||||
break;
|
||||
}
|
||||
irq->irq_id = irq_no; //!< 设置绑定后的irq号
|
||||
ref_counter_inc(&irq->ref); //!< 绑定后引用计数+1
|
||||
arch_set_enable_irq_prio(irq_no, f->r[2] & 0xffff, f->r[2] >> 16); //!< 绑定时设置优先级
|
||||
tag = msg_tag_init4(0, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
case UNBIND_IRQ:
|
||||
{
|
||||
umword_t irq_no = f->r[1];
|
||||
if (!irq_check_usability(irq_no) && irq_get(irq_no)->irq == irq)
|
||||
{
|
||||
irq_free(irq_no);
|
||||
ref_counter_dec(&irq->ref);
|
||||
tag = msg_tag_init4(0, 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
tag = msg_tag_init4(0, 0, 0, -EACCES);
|
||||
}
|
||||
bool_t suc = irq_sender_unbind(irq, irq_no);
|
||||
|
||||
tag = msg_tag_init4(0, 0, 0, suc ? 0 : -EACCES);
|
||||
}
|
||||
break;
|
||||
case WAIT_IRQ:
|
||||
{
|
||||
int ret = irq_sender_wait(irq, th);
|
||||
msg_tag_init4(0, 0, 0, ret);
|
||||
tag = msg_tag_init4(0, 0, 0, ret);
|
||||
}
|
||||
break;
|
||||
case ACK_IRQ:
|
||||
{
|
||||
arch_enable_irq(irq->irq_id);
|
||||
tag = msg_tag_init4(0, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ref_counter_dec_and_release(&irq->wait_thread->ref, &irq->kobj); //! 引用计数+1
|
||||
|
||||
f->r[0] = tag.raw;
|
||||
}
|
||||
static bool_t irq_sender_put(kobject_t *kobj)
|
||||
{
|
||||
irq_sender_t *irq = container_of(kobj, irq_sender_t, kobj);
|
||||
|
||||
return ref_counter_dec(&irq->ref) == 1;
|
||||
}
|
||||
static void irq_sender_stage1(kobject_t *kobj)
|
||||
{
|
||||
irq_sender_t *irq = container_of(kobj, irq_sender_t, kobj);
|
||||
kobject_invalidate(kobj); //!< 设置kobj为无效
|
||||
irq_sender_unbind(irq, irq->irq_id); //!< 解除绑定
|
||||
}
|
||||
static void irq_sender_stage2(kobject_t *kobj)
|
||||
{
|
||||
irq_sender_t *th = container_of(kobj, irq_sender_t, kobj);
|
||||
task_t *cur_task = thread_get_current_task();
|
||||
|
||||
mm_limit_free(cur_task->lim, th);
|
||||
printk("irq_sender 0x%x\n", kobj);
|
||||
}
|
||||
/**
|
||||
* @brief 初始化
|
||||
*
|
||||
* @param irq
|
||||
*/
|
||||
void irq_sender_init(irq_sender_t *irq)
|
||||
{
|
||||
kobject_init(&irq->kobj);
|
||||
ref_counter_init(&irq->ref);
|
||||
ref_counter_inc(&irq->ref);
|
||||
irq->kobj.invoke_func = irq_sender_syscall;
|
||||
irq->kobj.stage_1_func = irq_sender_stage1;
|
||||
irq->kobj.stage_2_func = irq_sender_stage2;
|
||||
irq->kobj.put_func = irq_sender_put;
|
||||
irq->irq_id = IRQ_INVALID_NO;
|
||||
irq->irq_cn = 0;
|
||||
}
|
||||
/**
|
||||
* @brief 创建一个irq_sender_t
|
||||
*
|
||||
* @param lim
|
||||
* @return irq_sender_t*
|
||||
*/
|
||||
static irq_sender_t *irq_create(ram_limit_t *lim)
|
||||
{
|
||||
irq_sender_t *irq = mm_limit_alloc(lim, sizeof(irq_sender_t));
|
||||
@@ -147,6 +210,16 @@ static irq_sender_t *irq_create(ram_limit_t *lim)
|
||||
irq_sender_init(irq);
|
||||
return irq;
|
||||
}
|
||||
/**
|
||||
* @brief 创建函数
|
||||
*
|
||||
* @param lim
|
||||
* @param arg0
|
||||
* @param arg1
|
||||
* @param arg2
|
||||
* @param arg3
|
||||
* @return kobject_t*
|
||||
*/
|
||||
static kobject_t *irq_create_func(ram_limit_t *lim, umword_t arg0, umword_t arg1,
|
||||
umword_t arg2, umword_t arg3)
|
||||
{
|
||||
|
||||
@@ -43,6 +43,9 @@ static void log_reg(void)
|
||||
// kobject_init(&log.kobj);
|
||||
irq_sender_init(&log.kobj);
|
||||
log.kobj.kobj.invoke_func = log_syscall;
|
||||
log.kobj.kobj.stage_1_func = kobject_release_stage1;
|
||||
log.kobj.kobj.stage_2_func = kobject_release_stage2;
|
||||
log.kobj.kobj.put_func = kobject_put;
|
||||
global_reg_kobj(&log.kobj.kobj, LOG_PROT);
|
||||
irq_alloc(37 /*USART1_IRQn*/, &log.kobj, log_trigger);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file map.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "map.h"
|
||||
#include "types.h"
|
||||
#include "obj_space.h"
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
|
||||
/**
|
||||
* @file misc.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "mm_wrap.h"
|
||||
#include "mm.h"
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file mm.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "mm.h"
|
||||
|
||||
void mem_init(mem_t *_this)
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file mm_man.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "kobject.h"
|
||||
#include "init.h"
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file mm_page.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "mm_space.h"
|
||||
#include "mm_wrap.h"
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
|
||||
/**
|
||||
* @file mm_space.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "util.h"
|
||||
#include "mm_space.h"
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file mm_wrap.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "mm_wrap.h"
|
||||
#include "types.h"
|
||||
#include "mm.h"
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
|
||||
/**
|
||||
* @file obj_space.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "obj_space.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* @file printk.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-14
|
||||
*
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include "printk.h"
|
||||
#include "stdarg.h"
|
||||
@@ -53,7 +53,7 @@ void printk(const char *fmt, ...)
|
||||
va_list args;
|
||||
umword_t state = 0;
|
||||
|
||||
spinlock_lock(&lock);
|
||||
state = spinlock_lock(&lock);
|
||||
va_start(args, fmt);
|
||||
xvsprintf(print_cache, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file ram_limit.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "ram_limit.h"
|
||||
#include "types.h"
|
||||
void ram_limit_init(ram_limit_t *limit, size_t max)
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file ref.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "ref.h"
|
||||
#include <assert.h>
|
||||
int ref_counter_dec_and_release(ref_counter_t *ref, kobject_t *kobj)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
/*
|
||||
* @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
|
||||
* @Date: 2023-08-14 09:47:54
|
||||
* @LastEditors: zhangzheng 1358745329@qq.com
|
||||
* @LastEditTime: 2023-08-18 15:50:09
|
||||
* @FilePath: /mkrtos-real/mkrtos_knl/knl/scheduler.c
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
/**
|
||||
* @file scheduler.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "scheduler.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file spinlock.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "cpulock.h"
|
||||
#include "spinlock.h"
|
||||
@@ -9,7 +19,7 @@ void spinlock_invalidate(spinlock_t *lock)
|
||||
{
|
||||
// TODO:原子操作
|
||||
umword_t status = 0;
|
||||
cpulock_lock();
|
||||
status = cpulock_lock();
|
||||
lock->val |= 1UL;
|
||||
cpulock_set(status);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ typedef struct sys
|
||||
kobject_t kobj;
|
||||
} sys_t;
|
||||
|
||||
static sys_t sys_boj;
|
||||
static sys_t sys_obj;
|
||||
|
||||
enum sys_op
|
||||
{
|
||||
@@ -34,9 +34,9 @@ static void sys_syscall(kobject_t *kobj, syscall_prot_t sys_p, msg_tag_t in_tag,
|
||||
|
||||
static void sys_reg(void)
|
||||
{
|
||||
kobject_init(&sys_boj.kobj);
|
||||
sys_boj.kobj.invoke_func = sys_syscall;
|
||||
global_reg_kobj(&sys_boj.kobj, SYS_PROT);
|
||||
kobject_init(&sys_obj.kobj);
|
||||
sys_obj.kobj.invoke_func = sys_syscall;
|
||||
global_reg_kobj(&sys_obj.kobj, SYS_PROT);
|
||||
}
|
||||
INIT_KOBJ(sys_reg);
|
||||
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
/**
|
||||
* @file task.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
|
||||
#include "task.h"
|
||||
#include "kobject.h"
|
||||
#include "factory.h"
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
/*
|
||||
* @Author: zhangzheng 1358745329@qq.com
|
||||
* @Date: 2023-08-14 09:47:54
|
||||
* @LastEditors: zhangzheng 1358745329@qq.com
|
||||
* @LastEditTime: 2023-08-18 16:21:20
|
||||
* @FilePath: /mkrtos-real/mkrtos_knl/knl/thread.c
|
||||
* @Description: 线程管理相关
|
||||
/**
|
||||
* @file thread.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
|
||||
#include "types.h"
|
||||
@@ -54,17 +56,18 @@ static void thread_release_stage1(kobject_t *kobj)
|
||||
{
|
||||
thread_t *th = container_of(kobj, thread_t, kobj);
|
||||
kobject_invalidate(kobj);
|
||||
thread_unbind(th);
|
||||
if (th->status == THREAD_READY)
|
||||
{
|
||||
thread_suspend(th);
|
||||
}
|
||||
thread_unbind(th);
|
||||
}
|
||||
static void thread_release_stage2(kobject_t *kobj)
|
||||
{
|
||||
thread_t *th = container_of(kobj, thread_t, kobj);
|
||||
thread_t *cur_th = thread_get_current();
|
||||
|
||||
printk("thread 0x%x\n", kobj);
|
||||
mm_limit_free_align(th->lim, kobj, THREAD_BLOCK_SIZE);
|
||||
|
||||
if (cur_th == th)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
/*
|
||||
* @Author: zhangzheng 1358745329@qq.com
|
||||
* @Date: 2023-08-18 15:03:16
|
||||
* @LastEditors: zhangzheng 1358745329@qq.com
|
||||
* @LastEditTime: 2023-08-18 16:22:11
|
||||
* @FilePath: /mkrtos-real/mkrtos_knl/knl/thread_armv7m.c
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
/**
|
||||
* @file thread_armv7m.c
|
||||
* @author zhangzheng (135874329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
|
||||
#include "types.h"
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
/*
|
||||
* @Author: zhangzheng 1358745329@qq.com
|
||||
* @Date: 2023-08-14 09:47:54
|
||||
* @LastEditors: zhangzheng 1358745329@qq.com
|
||||
* @LastEditTime: 2023-08-18 16:21:58
|
||||
* @FilePath: /mkrtos-real/mkrtos_knl/knl/thread_knl.c
|
||||
* @Description: 内核线程初始化
|
||||
/**
|
||||
* @file thread_knl.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
|
||||
#include "types.h"
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @file util.c
|
||||
* @author zhangzheng (1358745329@qq.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-29
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#include "types.h"
|
||||
|
||||
int ffs(int x)
|
||||
|
||||
@@ -59,119 +59,10 @@ RPC_GENERATION_CALL2(ns_t, NS_REGISTER_OP, register,
|
||||
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, path,
|
||||
rpc_obj_handler_t_t, rpc_obj_handler_t_t, RPC_DIR_IN, RPC_TYPE_BUF, svr_hd)
|
||||
|
||||
// RPC_GENERATION_CALL2(ns_t, NS_QUERY_OP, query,
|
||||
// rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, path,
|
||||
// rpc_obj_handler_t_t, rpc_obj_handler_t_t, RPC_DIR_INOUT, RPC_TYPE_BUF, cli_hd)
|
||||
msg_tag_t ns_t_query_call(obj_handler_t hd, rpc_ref_array_uint32_t_uint8_t_32_t *var0, rpc_obj_handler_t_t *var1)
|
||||
{
|
||||
void *buf;
|
||||
ipc_msg_t *msg_ipc;
|
||||
thread_msg_buf_get(2, (umword_t *)(&buf), ((void *)0));
|
||||
msg_ipc = (ipc_msg_t *)buf;
|
||||
int off = 0;
|
||||
int off_buf = 0;
|
||||
int ret = -1;
|
||||
size_t op_val = ((uint16_t)1);
|
||||
rpc_memcpy(msg_ipc->msg_buf, &op_val, sizeof(op_val));
|
||||
off += rpc_align(sizeof(op_val), __alignof(((uint16_t)1)));
|
||||
do
|
||||
{
|
||||
if (1 == 1)
|
||||
{
|
||||
if (1 == 1 || 1 == 4)
|
||||
{
|
||||
int ret = rpc_cli_msg_to_buf_rpc_ref_array_uint32_t_uint8_t_32_t(var0, (uint8_t *)((uint8_t *)msg_ipc->msg_buf), off);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ((msg_tag_t){.flags = (0), .msg_buf_len = (0), .map_buf_len = (0), .prot = (ret)});
|
||||
}
|
||||
off = ret;
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
do
|
||||
{
|
||||
if (1 == 2)
|
||||
{
|
||||
if (1 == 1 || 1 == 4)
|
||||
{
|
||||
int ret = rpc_cli_msg_to_buf_rpc_ref_array_uint32_t_uint8_t_32_t(var0, (uint8_t *)((uint8_t *)msg_ipc->map_buf), off_buf);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ((msg_tag_t){.flags = (0), .msg_buf_len = (0), .map_buf_len = (0), .prot = (ret)});
|
||||
}
|
||||
off_buf = ret;
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
do
|
||||
{
|
||||
if (2 == 1)
|
||||
{
|
||||
if (4 == 1 || 4 == 4)
|
||||
{
|
||||
int ret = rpc_cli_msg_to_buf_rpc_obj_handler_t_t(var1, (uint8_t *)((uint8_t *)msg_ipc->msg_buf), off);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ((msg_tag_t){.flags = (0), .msg_buf_len = (0), .map_buf_len = (0), .prot = (ret)});
|
||||
}
|
||||
off = ret;
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
do
|
||||
{
|
||||
if (2 == 2)
|
||||
{
|
||||
if (4 == 1 || 4 == 4)
|
||||
{
|
||||
int ret = rpc_cli_msg_to_buf_rpc_obj_handler_t_t(var1, (uint8_t *)((uint8_t *)msg_ipc->map_buf), off_buf);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ((msg_tag_t){.flags = (0), .msg_buf_len = (0), .map_buf_len = (0), .prot = (ret)});
|
||||
}
|
||||
off_buf = ret;
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
msg_tag_t tag = ipc_call(hd, ((msg_tag_t){.flags = (0), .msg_buf_len = ((((off) / ((sizeof(void *)))) + (((off) % ((sizeof(void *)))) ? 1 : 0))), .map_buf_len = (0), .prot = (0)}), ipc_timeout_create2(0, 0));
|
||||
if (((int16_t)((tag).prot)) < 0)
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
off = 0;
|
||||
do
|
||||
{
|
||||
if (1 == 1)
|
||||
{
|
||||
if (1 == 2 || 1 == 4)
|
||||
{
|
||||
int ret = rpc_cli_buf_to_msg_rpc_ref_array_uint32_t_uint8_t_32_t(var0, (uint8_t *)((uint8_t *)msg_ipc->msg_buf), off, tag.msg_buf_len * (sizeof(void *)));
|
||||
if (ret < 0)
|
||||
{
|
||||
return ((msg_tag_t){.flags = (0), .msg_buf_len = (0), .map_buf_len = (0), .prot = (ret)});
|
||||
}
|
||||
off = ret;
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
do
|
||||
{
|
||||
if (2 == 1)
|
||||
{
|
||||
if (4 == 2 || 4 == 4)
|
||||
{
|
||||
int ret = rpc_cli_buf_to_msg_rpc_obj_handler_t_t(var1, (uint8_t *)((uint8_t *)msg_ipc->msg_buf), off, tag.msg_buf_len * (sizeof(void *)));
|
||||
if (ret < 0)
|
||||
{
|
||||
return ((msg_tag_t){.flags = (0), .msg_buf_len = (0), .map_buf_len = (0), .prot = (ret)});
|
||||
}
|
||||
off = ret;
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
return tag;
|
||||
}
|
||||
RPC_GENERATION_CALL2(ns_t, NS_QUERY_OP, query,
|
||||
rpc_ref_array_uint32_t_uint8_t_32_t, rpc_array_uint32_t_uint8_t_32_t, RPC_DIR_IN, RPC_TYPE_DATA, path,
|
||||
rpc_obj_handler_t_t, rpc_obj_handler_t_t, RPC_DIR_INOUT, RPC_TYPE_BUF, cli_hd)
|
||||
|
||||
int ns_register(const char *path, obj_handler_t svr_hd)
|
||||
{
|
||||
assert(path);
|
||||
|
||||
@@ -15,11 +15,11 @@ RPC_GENERATION_OP2(ns_t, NS_REGISTER_OP, register,
|
||||
int ret = namespace_register((char *)(path->data), obj->hd);
|
||||
if (ret >= 0)
|
||||
{
|
||||
printf("注册服务[%s]成功.\n", (char *)(path->data));
|
||||
printf("register [%s] success.\n", (char *)(path->data));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("注册服务[%s]失败.\n", (char *)(path->data));
|
||||
printf("register [%s] fail.\n", (char *)(path->data));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -29,12 +29,12 @@ int main(int argc, char *args[])
|
||||
printf_test();
|
||||
thread_test();
|
||||
thread_exit_test();
|
||||
ipc_test();
|
||||
map_test();
|
||||
ipc_timeout_test();
|
||||
mm_test();
|
||||
app_test();
|
||||
#endif
|
||||
ipc_test();
|
||||
uenv_t env = *u_get_global_env();
|
||||
obj_handler_t ipc_hd;
|
||||
int ret = rpc_creaite_bind_ipc(THREAD_MAIN, NULL, &ipc_hd);
|
||||
@@ -47,14 +47,14 @@ int main(int argc, char *args[])
|
||||
// printf("app load fail, 0x%x\n", ret);
|
||||
// }
|
||||
|
||||
ret = app_load("app", &env);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("app load fail, 0x%x\n", ret);
|
||||
}
|
||||
namespace_init(ipc_hd);
|
||||
// ret = app_load("app", &env);
|
||||
// if (ret < 0)
|
||||
// {
|
||||
// printf("app load fail, 0x%x\n", ret);
|
||||
// }
|
||||
// namespace_init(ipc_hd);
|
||||
|
||||
namespace_loop();
|
||||
// namespace_loop();
|
||||
task_unmap(TASK_THIS, vpage_create_raw3(KOBJ_DELETE_RIGHT, 0, TASK_THIS)); // 删除当前task,以及申请得所有对象
|
||||
printf("exit init.\n");
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user