Exemplo n.º 1
0
void mailbox_test() {
	BaseType_t ret;
	rx = mailbox_init(MAILBOX0_ID);
	CONFIG_ASSERT(rx != NULL);
	tx = mailbox_init(MAILBOX0_ID);
	CONFIG_ASSERT(tx != NULL);
	ret = OS_CREATE_TASK(mailbox_testTask, "Mailbox Test Task", 512, NULL, 1, task);
	CONFIG_ASSERT(ret == pdPASS);
}
Exemplo n.º 2
0
LUALIB_API int luaopen_blocks(lua_State *L) {
	mailbox_t *mailbox;
	luaL_newlib(L, blocks_functions);
	lua_setglobal(L, "blocks");
	l_blocks_init(L);

	/* Mailbox reference meta-table */
	luaL_newmetatable(L, MAILBOX_REF_TYPE_NAME);
	lua_pushstring(L, "__index");
	lua_pushvalue(L, -2);
	lua_settable(L, -3);
	lua_pushstring(L, "send");
	lua_pushcfunction(L, l_message_send);
	lua_settable(L, -3);
	lua_pushstring(L, "state");
	lua_pushcfunction(L, l_mailbox_state);
	lua_settable(L, -3);
	lua_pushstring(L, "__metadata");
	lua_pushstring(L, "restricted");
	lua_settable(L, -3);
	lua_pushstring(L, "__type");
	lua_pushstring(L, MAILBOX_REF_TYPE_NAME);
	lua_settable(L, -3);
	lua_pushstring(L, "__tostring");
	lua_pushcfunction(L, l_mailbox_tostring);
	lua_settable(L, -3);
	lua_pushstring(L, "__gc");
	lua_pushcfunction(L, l_mailbox_ref_destroy);
	lua_settable(L, -3);

        /* Message reference meta-table */
	luaL_newmetatable(L, MESSAGE_REF_TYPE_NAME);
	lua_pushstring(L, "__index");
	lua_pushvalue(L, -2);
	lua_settable(L, -3);
	lua_pushstring(L, "get");
	lua_pushcfunction(L, l_mailbox_message_get);
	lua_settable(L, -3);
	lua_pushstring(L, "__metadata");
	lua_pushstring(L, "restricted");
	lua_settable(L, -3);
	lua_pushstring(L, "__type");
	lua_pushstring(L, MESSAGE_REF_TYPE_NAME);
	lua_settable(L, -3);
	lua_pushstring(L, "__tostring");
	lua_pushcfunction(L, l_message_tostring);
	lua_settable(L, -3);
	lua_pushstring(L, "__gc");
	lua_pushcfunction(L, l_mailbox_message_destroy);
	lua_settable(L, -3);

	lua_settop(L, 0);

	/* Register mail box per Lua state */
	mailbox = mailbox_init(L);
	return 0;
}
Exemplo n.º 3
0
int xs::socket_base_t::init ()
{
    xs_assert (!initialised);
    int rc = mailbox_init (&mailbox);
    if (rc != 0) {
        destroyed = true;
        delete this;
        return -1;
    }
    initialised = true;
    return 0;
}
Exemplo n.º 4
0
static int __init p500_multicore_init(void)
{
    unsigned int ret = 0;

    printk("p500_multicore_init start\n");

    BSP_DRV_IPCIntInit();

    BSP_UDI_Init();

    mailbox_init();

    printk("p500_multicore_init end\n");

    printk("NV_ACoreInitSync begin.\n");
    NV_ACoreInitSync();
    printk("NV_ACoreInitSync end.\n");

    return ret;
}
Exemplo n.º 5
0
/*----------------------------------------------------------------------------*/
void main(void)
{
	char temp[16];
	fb_t* display;
	/** initialize gpio */
	gpio_init();
	gpio_config(ERROR_LED,GPIO_OUTPUT);
	timer_init();
	/** initialize video stuff - mailbox before that! */
	mailbox_init();
	do
	{
		blink_error(2);
		timer_wait(TIMER_S);
		display = video_init(VIDEO_RES_VGA);
	}
	while (!display);
	video_set_bgcolor(COLOR_BLUE);
	video_clear();
	/** write something */
	video_text_char('H');
	video_text_char('E');
	video_text_char('L');
	video_text_char('L');
	video_text_char('O');
	video_text_char('!');
	video_text_string("\nHAHA!");
	video_text_cursor(3,1);
	video_text_string("Welcome!");
	/* display info */
	video_text_newline();
	video_text_string("DISPX: ");
	int2str(temp,display->screen.xres);
	video_text_string(temp);
	video_text_string(", ");
	video_text_string("DISPY: ");
	int2str(temp,display->screen.yres);
	video_text_string(temp);
	video_text_string(", ");
	video_text_string("VDISPX: ");
	int2str(temp,display->screen.xout);
	video_text_string(temp);
	video_text_string(", ");
	video_text_string("VDISPY: ");
	int2str(temp,display->screen.yout);
	video_text_string(temp);
	video_text_char('\n');
	video_text_string("OFFX: ");
	int2str(temp,display->screen.xoff);
	video_text_string(temp);
	video_text_string(", ");
	video_text_string("OFFY: ");
	int2str(temp,display->screen.yoff);
	video_text_string(temp);
	video_text_string(", ");
	video_text_string("XMAX: ");
	int2str(temp,display->cursor.xmax);
	video_text_string(temp);
	video_text_string(", ");
	video_text_string("YMAX: ");
	int2str(temp,display->cursor.ymax);
	video_text_string(temp);
	video_text_char('\n');
	video_text_string("PITCH: ");
	int2str(temp,display->screen.pskip);
	video_text_string(temp);
	video_text_string(", ");
	video_text_string("DEPTH: ");
	int2str(temp,display->screen.depth);
	video_text_string(temp);
	/* test col overflow */
	video_text_cursor(display->cursor.y+1,display->cursor.xmax-5);
	video_text_string("Continue next line!");
	/* test line drawing */
	video_draw_line(100,100,200,100);
	video_draw_line(200,100,100,200);
	video_draw_line(100,200,100,100);
	video_text_string("\nWait for it...");
	blink_error(3);
	/* test row overflow */
	video_text_cursor(display->cursor.ymax-1,display->cursor.xmax-5);
	video_text_string("Scroll this!");
	/** sticking around */
	while(1);
}
Exemplo n.º 6
0
// the tcpConnection_task_proc handles the connection to one client
void tcpConnection_task_proc(void *arg)
{
    tims_msg_head*        tcpMsg;
    connection_t*         con = (connection_t*)arg;
    tims_msg_head         replyMsg;
    int                   forwardConIndex;
    int                   ret, idx;

    signal(SIGHUP,  signal_handler);
    signal(SIGINT,  signal_handler);
    signal(SIGTERM, signal_handler);
    signal(SIGPIPE, signal_handler);

    idx = con->index;

    tims_dbg("con[%02d]: %s: starting TCP/IP connection task\n",
             idx, inet_ntoa(con->addr.sin_addr));

    tcpMsg = malloc(maxMsgSize);
    if (!tcpMsg)
    {
        tims_print("con[%02d] %s error: Can't allocate memory for tcpTimsMsg\n",
                   idx, inet_ntoa(con->addr.sin_addr));
        connection_close(con);
        return;
    }

    while (!terminate)
    {
        if (con->socket < 0)    // invalid socket
            break;

        ret = recvTcpTimsMsg(con, tcpMsg); // waiting for new command
        if (ret < 0)
            break;

        if ( !tcpMsg->dest &&
             !tcpMsg->src )  // handle TiMS command (internal)
        {
            switch (tcpMsg->type)
            {
                case TIMS_MSG_OK:        // watchdog lifesign reply
                    con->watchdog = 0;
                    break;

                case TIMS_MSG_ROUTER_LOGIN:
                    break;

                case TIMS_MSG_ROUTER_MBX_INIT:
                    mailbox_init(con, tcpMsg, NULL);
                    break;

                case TIMS_MSG_ROUTER_MBX_DELETE:
                    mailbox_cleanup(con, tcpMsg, NULL);
                    break;

                case TIMS_MSG_ROUTER_MBX_INIT_WITH_REPLY:
                    mailbox_init(con, tcpMsg, &replyMsg);
                    break;

                case TIMS_MSG_ROUTER_MBX_DELETE_WITH_REPLY:
                    mailbox_cleanup(con, tcpMsg, &replyMsg);
                    break;

                case TIMS_MSG_ROUTER_MBX_PURGE:
                    mailbox_purge(con);
                    break;

                default:
                    tims_print("con[%02d]: %s: received unexpected TiMS "
                               "Message %x -> %x type %i msglen %i\n", idx,
                               inet_ntoa(con->addr.sin_addr), tcpMsg->src,
                               tcpMsg->dest, tcpMsg->type, tcpMsg->msglen);
            }
        }
        else // ( tcpMsg->dest || tcpMsg->src )
        {

            // forward tims message
            forwardConIndex = mailbox_get(tcpMsg->dest);

            if (forwardConIndex >= 0) // mbx is available
            {
                sndTcpTimsMsg(&conList[forwardConIndex], tcpMsg);
            }
            else // mbx is not available
            {
                if (tcpMsg->type > 0)
                {
                    tims_fillhead(&replyMsg, TIMS_MSG_NOT_AVAILABLE, tcpMsg->src,
                                  tcpMsg->dest, tcpMsg->priority, tcpMsg->seq_nr,
                                  0, TIMS_HEADLEN);
                    sndTcpTimsMsg(con, &replyMsg);
                }
            }
        }
    }

    tims_print("con[%02d]: %s: logout\n", idx, inet_ntoa(con->addr.sin_addr));
    mailbox_delete_all(con->index);

    if (con->socket != -1)
        connection_close(con);

    if (tcpMsg)
    {
        free(tcpMsg);
        tcpMsg = NULL;
        tims_dbgdetail("con[%02d]: %s: free tcp message buffer\n", con->index,
                       inet_ntoa(con->addr.sin_addr));
    }

    con->index = -1;
    return;
}
Exemplo n.º 7
0
void BSP_DRV_Init()
{
#ifdef CONFIG_MODULE_VIC
    s32 ret = 0;
#endif

/***********************基础模块初始化***************************/
#ifdef CONFIG_BALONG_CCLK
    hi6930_clock_init();
#endif
#ifdef CONFIG_CCORE_PM
		 bsp_dpm_init();
#endif
#ifdef K3_TIMER_FEATURE
	k3_timer_init();
#endif
    adp_timer_init();
    timer_dpm_init();

    if(0 != BSP_UDI_Init())
        logMsg("BSP_UDI_Init fail\n",0,0,0,0,0,0);

    bsp_ipc_init();

	bsp_icc_init();

#ifdef CONFIG_K3V3_CLK_CRG /*CONFIG_K3V3_CLK_CRG*/
    gps_refclk_icc_read_cb_init();
#endif
	/* Cshell init if magic number is set to PRT_FLAG_EN_MAGIC_M */
#ifdef CONFIG_CSHELL
    if(0 != cshell_init())
    {
            logMsg("cshell init fail\n",0,0,0,0,0,0);
    }
#endif

#ifdef CONFIG_NVIM
     if(0 != bsp_nvm_init())
        logMsg("nv init fail\n",0,0,0,0,0,0);
#endif

    /* axi monitor监控初始化 */
    (void)bsp_amon_init();

	/*此初始化必须放置在MSP/OAM/PS初始化之前,请不要随意改动顺序*/
    tcxo_init_configure();

    if(0 != bsp_rfile_init())
        logMsg("rfile init fail\n",0,0,0,0,0,0);

	/* version inits */
    bsp_productinfo_init();

    hwspinlock_init();

    bsp_hkadc_init();

    bsp_version_init();
    bsp_lowpower_mntn_init();

#ifdef CONFIG_MODULE_VIC
    ret = bsp_vic_init();
    if(ret != OK)
    {
        logMsg("bsp_vic_init error\n", 0, 0, 0, 0, 0, 0);
    }
#endif

	(void)bsp_softtimer_init();

#ifdef CONFIG_BALONG_EDMA
    if(0 != bsp_edma_init())
    {
        logMsg("edma init fail \n",0,0,0,0,0,0);
    }
#endif

    /*C core init ipc module*/
    if(0 != socp_init())
        logMsg("socp init fail\n",0,0,0,0,0,0);

     if(0 != bsp_om_server_init())
        logMsg("om init fail\n",0,0,0,0,0,0);
	 if(0 != bsp_dual_modem_init())
	     logMsg("dual modem uart init fail\n",0,0,0,0,0,0);

/***********************外设模块初始化***************************/
    bsp_dsp_init();

#ifdef CONFIG_BBP_INT
	bbp_int_init();/*此处需要放在dsp初始化之后,放在pastar/abb之前*/
#endif

    bsp_spi_init();
    bsp_pmu_init();
	regulator_init();

#if defined(CONFIG_PMIC_HI6559)
    if(bsp_pa_rf_init())   /* 依赖于regulator_init */
    {
        logMsg("bsp_pa_rf_init fail\n",0,0,0,0,0,0);
    }
#endif

	/*init mipi*/
#ifdef CONFIG_MIPI
	bsp_mipi_init();
#endif

#ifdef CONFIG_TUNER
    bsp_tuner_init();
#endif

#ifdef CONFIG_PASTAR
	/*此函数的位置不可以向后移动,为pastar上电后,提供足够的稳定时间*/
    pmu_hi6561_init_phase1();
#endif

     if(0 != hi6930_wdt_init())
        logMsg("wdt init fail\n",0,0,0,0,0,0);

#ifdef CONFIG_CCORE_I2C

	if(0!=bsp_i2c_initial())
		logMsg("i2c init fail\n",0,0,0,0,0,0);
#endif


    if(0 != bsp_gpio_init())
        logMsg("gpio init fail\n",0,0,0,0,0,0);
#ifdef CONFIG_EFUSE
	if(0 != efuse_init())
	{
		logMsg("efuse init fail \n",0,0,0,0,0,0);
    }
#endif

#ifdef CONFIG_LEDS_CCORE
    if(0 != bsp_led_init())
    {
        logMsg("led init fail\n",0,0,0,0,0,0);
    }
#endif

/***********************通信支撑模块初始化***************************/
#ifdef CONFIG_CIPHER
    if(0 != cipher_init())
    {
        logMsg("cipher init fail \n",0,0,0,0,0,0);
    }
	if(0 != bsp_acc_init())
	{
		logMsg("acc init fail \n",0,0,0,0,0,0);
	}
#endif

#ifdef CONFIG_IPF
    if(0 != ipf_init())
        logMsg("ipf init fail\n",0,0,0,0,0,0);
#endif

#ifdef CONFIG_MODULE_BUSSTRESS
	 ipf_ul_stress_test_start(10);
#endif

#ifdef FEATURE_TLPHY_MAILBOX
    bsp_mailbox_init();
#endif

    mailbox_init();

#ifdef CONFIG_ANTEN
    if(0 != bsp_anten_init())
        logMsg("anten init fail.\n",0,0,0,0,0,0);
#endif

	bsp_sci_cfg_init();

    bsp_abb_init();

    bsp_on_off_init();

	cpufreq_init();

    /*初始化醒来的时间戳*/
    update_awake_time_stamp();

#ifdef CONFIG_CCORE_BALONG_PM
    balong_pm_init();
#endif

#ifdef CONFIG_AUDIO
    audio_init();
#endif

#ifdef CONFIG_BALONG_MODEM_RESET
	bsp_reset_init();
#endif

    (void)bsp_rf_rse_init();
#ifdef CONFIG_PASTAR
	/*勿动!此处需要放置在该函数最后,确保pastar上电后稳定后,进行初始化配置*/
	pmu_hi6561_init_phase2();
#endif

	(void)bsp_antn_sw_init();

}