forked from xuos/xiuos
已经可以运行,但是还有一个隐藏的很深的BUG还没有来得及改
This commit is contained in:
parent
58ee6ad53b
commit
255d7464f7
|
@ -83,6 +83,11 @@
|
||||||
*/
|
*/
|
||||||
#define PRECISION_DEFAULT (INT_MAX)
|
#define PRECISION_DEFAULT (INT_MAX)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* max data number of fifi data reg
|
||||||
|
*/
|
||||||
|
static const uint32_t SCIF_UART_TX_FIFO_STAGES = 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum for storing width modifier.
|
* Enum for storing width modifier.
|
||||||
*/
|
*/
|
||||||
|
@ -785,7 +790,6 @@ int mbed_minimal_formatted_string(char *buffer, size_t length, const char *forma
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t xSerialPortInitialized = 0;
|
static uint32_t xSerialPortInitialized = 0;
|
||||||
static uint32_t tx_data_empty = 1;
|
|
||||||
static uint32_t rx_data_full = 0;
|
static uint32_t rx_data_full = 0;
|
||||||
|
|
||||||
static void uart_callback(uart_callback_args_t *const p_arg)
|
static void uart_callback(uart_callback_args_t *const p_arg)
|
||||||
|
@ -820,17 +824,26 @@ static void uart_callback(uart_callback_args_t *const p_arg)
|
||||||
}
|
}
|
||||||
if (p_arg->event & UART_EVENT_TX_DATA_EMPTY)
|
if (p_arg->event & UART_EVENT_TX_DATA_EMPTY)
|
||||||
{
|
{
|
||||||
tx_data_empty = 1;
|
__NOP();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void outbyte1(console_t console, char c)
|
static void outbyte1(console_t console, char c)
|
||||||
{
|
{
|
||||||
scif_uart_instance_ctrl_t * p_ctrl = (scif_uart_instance_ctrl_t *)g_uart2.p_ctrl;
|
scif_uart_instance_ctrl_t * p_ctrl = (scif_uart_instance_ctrl_t *)g_uart2.p_ctrl;
|
||||||
|
uint32_t no_send_data_count = 0;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
// 获取还未发送的数据数量
|
||||||
|
no_send_data_count = (uint32_t) p_ctrl->p_reg->FDR_b.T;
|
||||||
|
// 还存在可以发送数据的空间
|
||||||
|
if (no_send_data_count < SCIF_UART_TX_FIFO_STAGES)
|
||||||
|
{
|
||||||
p_ctrl->p_reg->FTDR = c;
|
p_ctrl->p_reg->FTDR = c;
|
||||||
|
break;
|
||||||
for (int i = 0; i < 200; i++){}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void outbyte(console_t console, char c)
|
void outbyte(console_t console, char c)
|
||||||
|
|
|
@ -297,12 +297,12 @@ void platform_release_rpmsg_vdev (void * platform, struct rpmsg_device * rpdev)
|
||||||
struct rpmsg_virtio_device * rpmsg_vdev;
|
struct rpmsg_virtio_device * rpmsg_vdev;
|
||||||
struct remoteproc_priv * prproc = rproc->priv;
|
struct remoteproc_priv * prproc = rproc->priv;
|
||||||
|
|
||||||
KTaskDelete(ipi_tsk_id[prproc->notify_id]);
|
|
||||||
ipi_tsk_id[prproc->notify_id] = -1;
|
|
||||||
|
|
||||||
KMutexDelete(ipi.ipi_mutx_id[prproc->notify_id]);
|
KMutexDelete(ipi.ipi_mutx_id[prproc->notify_id]);
|
||||||
ipi.ipi_mutx_id[prproc->notify_id] = -1;
|
ipi.ipi_mutx_id[prproc->notify_id] = -1;
|
||||||
|
|
||||||
|
KTaskDelete(ipi_tsk_id[prproc->notify_id]);
|
||||||
|
ipi_tsk_id[prproc->notify_id] = -1;
|
||||||
|
|
||||||
rpmsg_vdev = metal_container_of(rpdev, struct rpmsg_virtio_device, rdev);
|
rpmsg_vdev = metal_container_of(rpdev, struct rpmsg_virtio_device, rdev);
|
||||||
rpmsg_deinit_vdev(rpmsg_vdev);
|
rpmsg_deinit_vdev(rpmsg_vdev);
|
||||||
remoteproc_remove_virtio(rproc, rpmsg_vdev->vdev);
|
remoteproc_remove_virtio(rproc, rpmsg_vdev->vdev);
|
||||||
|
@ -378,7 +378,7 @@ static void* IpiTask (void * exinf)
|
||||||
// KPrintf("IpiTask: after remoteproc_get_notification\n");
|
// KPrintf("IpiTask: after remoteproc_get_notification\n");
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
LPRINTF("remoteproc_get_notification() failed with %d", ret);
|
KPrintf("remoteproc_get_notification() failed with %d", ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ static void start_ipi_task (void * platform)
|
||||||
}
|
}
|
||||||
ipi.ipi_mutx_id[prproc->notify_id] = mutx_id;
|
ipi.ipi_mutx_id[prproc->notify_id] = mutx_id;
|
||||||
|
|
||||||
KPrintf("start_ipi_task: prproc->notify_id = %d, ipi.ipi_mutx_id[prproc->notify_id] = %d \n",prproc->notify_id,ipi.ipi_mutx_id[prproc->notify_id]);
|
// KPrintf("start_ipi_task: prproc->notify_id = %d, ipi.ipi_mutx_id[prproc->notify_id] = %d \n",prproc->notify_id,ipi.ipi_mutx_id[prproc->notify_id]);
|
||||||
|
|
||||||
int32 ipi_task_id = -1;
|
int32 ipi_task_id = -1;
|
||||||
ipi_task_id = KTaskCreate("ipi_task",IpiTask,platform,4096,SHELL_TASK_PRIORITY + 1);
|
ipi_task_id = KTaskCreate("ipi_task",IpiTask,platform,4096,SHELL_TASK_PRIORITY + 1);
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
#include <openamp/open_amp.h>
|
|
||||||
#include "rpmsg_task.h"
|
|
||||||
#include "platform_info.h"
|
|
||||||
#include <xizi.h>
|
|
||||||
|
|
||||||
extern int init_system (void);
|
|
||||||
extern void cleanup_system (void);
|
|
||||||
extern int app (struct rpmsg_device * rdev, void * platform, unsigned long svcno);
|
|
||||||
|
|
||||||
void* RPMsgTask_Entry(void* param)
|
|
||||||
{
|
|
||||||
unsigned long proc_id = 0UL;
|
|
||||||
unsigned long rsc_id = 0UL;
|
|
||||||
struct rpmsg_device * rpdev;
|
|
||||||
void * platform;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = init_system();
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
LPERROR("Failed to init remoteproc device.\n");
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = platform_init(proc_id, rsc_id, &platform);
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
LPERROR("Failed to create remoteproc device.\n");
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
/* RTOS is Master, but this setting must remote in this release. */
|
|
||||||
rpdev = platform_create_rpmsg_vdev(platform, 0x0U, VIRTIO_DEV_SLAVE, NULL, NULL);
|
|
||||||
if (!rpdev)
|
|
||||||
{
|
|
||||||
LPERROR("Fail, platform_create_rpmsg_vdev.\n");
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
// KPrintf("RPMsgTask_Entry: Success platform_create_rpmsg_vdev.\n");
|
|
||||||
/* Kick the application */
|
|
||||||
(void) app(rpdev, platform, proc_id);
|
|
||||||
|
|
||||||
platform_release_rpmsg_vdev(platform, rpdev);
|
|
||||||
KPrintf("RPMsgTask_Entry: Success platform_release_rpmsg_vdev.\n");
|
|
||||||
|
|
||||||
DelayKTask(RECONNECT_DLY);
|
|
||||||
} while (RECONNECT_FLG);
|
|
||||||
}
|
|
||||||
|
|
||||||
err:
|
|
||||||
KPrintf("RPMsgTask_Entry: err \n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreateRPMsgTask(void)
|
|
||||||
{
|
|
||||||
// 创建的任务优先级与SHELL终端一致,防止该任务无法执行
|
|
||||||
int32 rpmsg_task_id = KTaskCreate("rpmsg_task",RPMsgTask_Entry,NULL,2048,SHELL_TASK_PRIORITY);
|
|
||||||
|
|
||||||
if (rpmsg_task_id < 0)
|
|
||||||
{
|
|
||||||
KPrintf("CreateRPMsgTask: create rpmsg task fail!\n");
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 将该任务放入调用
|
|
||||||
StartupKTask(rpmsg_task_id);
|
|
||||||
}
|
|
||||||
|
|
|
@ -9,19 +9,6 @@
|
||||||
void R_BSP_WarmStart(bsp_warm_start_event_t event);
|
void R_BSP_WarmStart(bsp_warm_start_event_t event);
|
||||||
// FSP_CPP_FOOTER
|
// FSP_CPP_FOOTER
|
||||||
|
|
||||||
void* TaskSample(void * args)
|
|
||||||
{
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 100000; i++)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
KPrintf("TaskSample: %s\n",(char*)args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void XiZi_SysTick_Handler(void)
|
void XiZi_SysTick_Handler(void)
|
||||||
{
|
{
|
||||||
x_base lock = DISABLE_INTERRUPT();
|
x_base lock = DISABLE_INTERRUPT();
|
||||||
|
@ -41,7 +28,8 @@ void hal_entry(void)
|
||||||
SysInitIsrManager();
|
SysInitIsrManager();
|
||||||
|
|
||||||
InitBoardMemory((void *)HEAP_START, (void *)HEAP_END);
|
InitBoardMemory((void *)HEAP_START, (void *)HEAP_END);
|
||||||
KPrintf("hal_entry: InitBoardMemory -- HEAP_START = %p, HEAP_END = %p, Size = %dKB !\n",HEAP_START,HEAP_END,(HEAP_END - HEAP_START) / 1024);
|
KPrintf("hal_entry: InitBoardMemory -- HEAP_START = %p, HEAP_END = %p, Size = %dKB !\n"
|
||||||
|
,(void *)HEAP_START,(void *)HEAP_END,(((void *)HEAP_END) - ((void *)HEAP_START)) / 1024);
|
||||||
|
|
||||||
#ifdef KERNEL_QUEUEMANAGE
|
#ifdef KERNEL_QUEUEMANAGE
|
||||||
QueuemanagerDoneRegister();
|
QueuemanagerDoneRegister();
|
||||||
|
@ -54,26 +42,16 @@ void hal_entry(void)
|
||||||
CreateKServiceKTask();
|
CreateKServiceKTask();
|
||||||
|
|
||||||
CreateEnvInitTask();
|
CreateEnvInitTask();
|
||||||
|
|
||||||
// RPMsg 任务入口
|
|
||||||
CreateRPMsgTask();
|
|
||||||
|
|
||||||
// StartupKTask(KTaskCreate("test-task-a",TaskSample,"test-task-a",512,20));
|
|
||||||
// StartupKTask(KTaskCreate("test-task-b",TaskSample,"test-task-b",512,20));
|
|
||||||
// StartupKTask(KTaskCreate("test-task-c",TaskSample,"test-task-c",512,20));
|
|
||||||
|
|
||||||
KPrintf("hal_entry: init kernel envirement final!\n");
|
KPrintf("hal_entry: init kernel envirement final!\n");
|
||||||
|
|
||||||
x_base lock = DISABLE_INTERRUPT();
|
DISABLE_INTERRUPT();
|
||||||
KPrintf("hal_entry: disable interrupt now!\n");
|
KPrintf("hal_entry: disable interrupt now!\n");
|
||||||
|
|
||||||
g_timer2.p_api->open(g_timer2.p_ctrl, g_timer2.p_cfg);
|
g_timer2.p_api->open(g_timer2.p_ctrl, g_timer2.p_cfg);
|
||||||
g_timer2.p_api->callbackSet(g_timer2.p_ctrl, XiZi_SysTick_Handler, NULL, NULL);
|
g_timer2.p_api->callbackSet(g_timer2.p_ctrl, XiZi_SysTick_Handler, NULL, NULL);
|
||||||
g_timer2.p_api->start(g_timer2.p_ctrl);
|
g_timer2.p_api->start(g_timer2.p_ctrl);
|
||||||
|
|
||||||
ENABLE_INTERRUPT(lock);
|
|
||||||
KPrintf("hal_entry: enable interrupt!\n");
|
KPrintf("hal_entry: enable interrupt!\n");
|
||||||
|
|
||||||
StartupOsAssign();
|
StartupOsAssign();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ extern void cleanup_system(void);
|
||||||
*-----------------------------------------------------------------------------*/
|
*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* Local variables */
|
/* Local variables */
|
||||||
|
|
||||||
static struct rpmsg_endpoint rp_ept[CFG_RPMSG_SVCNO] = {0};
|
static struct rpmsg_endpoint rp_ept[CFG_RPMSG_SVCNO] = {0};
|
||||||
|
|
||||||
volatile static int evt_svc_unbind[CFG_RPMSG_SVCNO] = {0};
|
volatile static int evt_svc_unbind[CFG_RPMSG_SVCNO] = {0};
|
||||||
|
@ -67,19 +66,18 @@ static int rpmsg_endpoint_cb0 (struct rpmsg_endpoint * cb_rp_ept, void * data, s
|
||||||
/* service 0 */
|
/* service 0 */
|
||||||
(void) priv;
|
(void) priv;
|
||||||
(void) src;
|
(void) src;
|
||||||
|
|
||||||
/* On reception of a shutdown we signal the application to terminate */
|
/* On reception of a shutdown we signal the application to terminate */
|
||||||
if ((*(unsigned int *) data) == SHUTDOWN_MSG)
|
if ((*(unsigned int *) data) == SHUTDOWN_MSG)
|
||||||
{
|
{
|
||||||
evt_svc_unbind[0] = 1;
|
evt_svc_unbind[0] = 1;
|
||||||
|
|
||||||
return RPMSG_SUCCESS;
|
return RPMSG_SUCCESS;
|
||||||
}
|
}
|
||||||
KPrintf("rpmsg_endpoint_cb0: recv data = %p, *data = %d,len = %d\n",data,*((int*)(data)),len);
|
KPrintf("rpmsg_endpoint_cb0: recv &data = %p, *data = %d,len = %d\n",data,*((int*)(data)),len);
|
||||||
/* Send data back to master */
|
/* Send data back to master */
|
||||||
if (rpmsg_send(cb_rp_ept, data, (int) len) < 0)
|
if (rpmsg_send(cb_rp_ept, data, (int) len) < 0)
|
||||||
{
|
{
|
||||||
LPERROR("rpmsg_send failed\n");
|
KPrintf("rpmsg_endpoint_cb0: rpmsg_send back failed\n");
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return RPMSG_SUCCESS;
|
return RPMSG_SUCCESS;
|
||||||
|
@ -145,40 +143,26 @@ int app (struct rpmsg_device * rdev, void * platform, unsigned long svcno)
|
||||||
|
|
||||||
if (svcno == 0UL)
|
if (svcno == 0UL)
|
||||||
{
|
{
|
||||||
ret = rpmsg_create_ept(&rp_ept[0],
|
ret = rpmsg_create_ept(&rp_ept[0],rdev,CFG_RPMSG_SVC_NAME0,APP_EPT_ADDR,RPMSG_ADDR_ANY,rpmsg_endpoint_cb0,rpmsg_service_unbind0);
|
||||||
rdev,
|
|
||||||
CFG_RPMSG_SVC_NAME0,
|
|
||||||
APP_EPT_ADDR,
|
|
||||||
RPMSG_ADDR_ANY,
|
|
||||||
rpmsg_endpoint_cb0,
|
|
||||||
rpmsg_service_unbind0);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
LPERROR("Failed to create endpoint.\n");
|
KPrintf("app: fail to create endpoint[0]\n");
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
KPrintf("app: Success to create endpoint[0]\n");
|
||||||
KPrintf("app: Success to create endpoint rp_ept[0]\n");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = rpmsg_create_ept(&rp_ept[1],
|
ret = rpmsg_create_ept(&rp_ept[1],rdev,CFG_RPMSG_SVC_NAME1,APP_EPT_ADDR,RPMSG_ADDR_ANY,rpmsg_endpoint_cb1,rpmsg_service_unbind1);
|
||||||
rdev,
|
|
||||||
CFG_RPMSG_SVC_NAME1,
|
|
||||||
APP_EPT_ADDR,
|
|
||||||
RPMSG_ADDR_ANY,
|
|
||||||
rpmsg_endpoint_cb1,
|
|
||||||
rpmsg_service_unbind1);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
LPERROR("Failed to create endpoint.\n");
|
KPrintf("app: fail to create endpoint[1]\n");
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
KPrintf("app: success to create endpoint[1]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
LPRINTF("Waiting for events...\n");
|
LPRINTF("Waiting for master data ...\n");
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -187,6 +171,8 @@ int app (struct rpmsg_device * rdev, void * platform, unsigned long svcno)
|
||||||
/* we got a shutdown request, exit */
|
/* we got a shutdown request, exit */
|
||||||
if (evt_svc_unbind[svcno])
|
if (evt_svc_unbind[svcno])
|
||||||
{
|
{
|
||||||
|
// 销毁该节点
|
||||||
|
rpmsg_destroy_ept(&rp_ept[svcno]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
#include <openamp/open_amp.h>
|
||||||
|
#include "rpmsg_task.h"
|
||||||
|
#include "platform_info.h"
|
||||||
|
#include <xizi.h>
|
||||||
|
#include <shell.h>
|
||||||
|
|
||||||
|
extern int init_system (void);
|
||||||
|
extern void cleanup_system (void);
|
||||||
|
extern int app (struct rpmsg_device * rdev, void * platform, unsigned long svcno);
|
||||||
|
|
||||||
|
void* RPMsgTask_Entry(void* param)
|
||||||
|
{
|
||||||
|
unsigned long proc_id = 0UL;
|
||||||
|
unsigned long rsc_id = 0UL;
|
||||||
|
struct rpmsg_device * rpdev;
|
||||||
|
void * platform;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
result = init_system();
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
KPrintf("RPMsgTask_Entry: fail to init remoteproc device\n");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
KPrintf("RPMsgTask_Entry: success to init remoteproc device\n");
|
||||||
|
|
||||||
|
|
||||||
|
result = platform_init(proc_id, rsc_id, &platform);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
KPrintf("RPMsgTask_Entry: fail to create remoteproc device\n");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
KPrintf("RPMsgTask_Entry: success to create remoteproc device\n");
|
||||||
|
|
||||||
|
|
||||||
|
/* RTOS is Master, but this setting must remote in this release. */
|
||||||
|
rpdev = platform_create_rpmsg_vdev(platform, 0x0U, VIRTIO_DEV_SLAVE, NULL, NULL);
|
||||||
|
if (!rpdev)
|
||||||
|
{
|
||||||
|
LPERROR("Fail, platform_create_rpmsg_vdev.\n");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
KPrintf("RPMsgTask_Entry: success platform_create_rpmsg_vdev\n");
|
||||||
|
|
||||||
|
// 进入APP代码
|
||||||
|
(void) app(rpdev, platform, proc_id);
|
||||||
|
|
||||||
|
platform_release_rpmsg_vdev(platform, rpdev);
|
||||||
|
KPrintf("RPMsgTask_Entry: success platform_release_rpmsg_vdev\n");
|
||||||
|
|
||||||
|
platform_cleanup(platform);
|
||||||
|
KPrintf("RPMsgTask_Entry: success platform_cleanup\n");
|
||||||
|
|
||||||
|
cleanup_system();
|
||||||
|
KPrintf("RPMsgTask_Entry: success cleanup_system\n");
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
err:
|
||||||
|
KPrintf("RPMsgTask_Entry: something err!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateRPMsgTask(void)
|
||||||
|
{
|
||||||
|
int32 rpmsg_task_id = KTaskCreate("rpmsg_task",RPMsgTask_Entry,NULL,2048,SHELL_TASK_PRIORITY + 1);
|
||||||
|
|
||||||
|
if (rpmsg_task_id < 0)
|
||||||
|
{
|
||||||
|
KPrintf("CreateRPMsgTask: create rpmsg task fail!\n");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
KPrintf("CreateRPMsgTask: create rpmsg task success!\n");
|
||||||
|
|
||||||
|
int32 start_up_result = StartupKTask(rpmsg_task_id);
|
||||||
|
|
||||||
|
if (start_up_result != 0)
|
||||||
|
{
|
||||||
|
KPrintf("CreateRPMsgTask: startup rpmsg task fail\n");
|
||||||
|
}
|
||||||
|
KPrintf("CreateRPMsgTask: startup rpmsg task success\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, CreateRPMsgTask, CreateRPMsgTask, create rpmsg listener task);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue