Exemple #1
0
void Thread::waitForThreadExit(Thread *thread) {
    const int sMaxRetries = 10000000;
    int retryCount = 0;

    while (!thread->exited)
    {
        if (retryCount++ == sMaxRetries)
        {
            retryCount = 0;
            if(thread->exited)
                return;

            __os_sleep(1);
        }
    }
}
Exemple #2
0
void Thread::terminateAndWaitForThreadExit(Thread *thread) {
    const int sMaxRetries = 10000000;
    int retryCount = 0;

    thread->term();
    while (!thread->exited)
    {
        if (retryCount++ == sMaxRetries)
        {
            retryCount = 0;
            if(thread->exited)
                return;

            __os_sleep(1);
        }

        thread->state = THREAD_KILLED;
    }
}
Exemple #3
0
int Thread::waitForThread(Thread *thread) {
    const int sMaxRetries = 100000000;
    const int sMaxSpinCount = 25;

    int spinCount = 0;
    int retryCount = 0;

    while (thread->state == THREAD_CREATED
           || thread->state == THREAD_SUSPENDED)
    {
        if (retryCount++ == sMaxRetries)
        {
            retryCount = 0;
            if(++spinCount >= sMaxSpinCount)
            {
                return -255; // give up
            }
            __os_sleep(1);
        }
    }
    return 0;
}
Exemple #4
0
int main(int argc, char ** argv)
{
	int ret;

	DCC_LOG_INIT();
	DCC_LOG_CONNECT();

	stdio_init();
	printf("\n---\n");

	cm3_udelay_calibrate();
	thinkos_init(THINKOS_OPT_PRIORITY(0) | THINKOS_OPT_ID(0));
	trace_init();

	tracef("## YARD-ICE " VERSION_NUM " - " VERSION_DATE " ##");

	stm32f_nvram_env_init();

	bsp_io_ini();

	rtc_init();

	supervisor_init();
	__os_sleep(10);

#if ENABLE_NETWORK
	DCC_LOG(LOG_TRACE, "network_config().");
	network_config();
#endif

	DCC_LOG(LOG_TRACE, "modules_init().");
	modules_init();

	tracef("* Starting system module ...");
	DCC_LOG(LOG_TRACE, "sys_start().");
	sys_start();

	tracef("* Initializing YARD-ICE debugger...");
	DCC_LOG(LOG_TRACE, "debugger_init().");
	debugger_init();

	tracef("* Initializing JTAG module ...");
	DCC_LOG(LOG_TRACE, "jtag_start().");
	if ((ret = jtag_start()) < 0) {
		tracef("jtag_start() failed! [ret=%d]", ret);
		debugger_except("JTAG driver fault");
	}

#if (ENABLE_NAND)
	tracef("* Initializing NAND module...");
	if (mod_nand_start() < 0) {
		tracef("mod_nand_start() failed!");
		return 0;
	}
#endif

#if (ENABLE_I2C)
	tracef("* starting I2C module ... ");
	i2c_init();
#endif

	tracef("* configuring initial target ... ");
	init_target();

#if (ENABLE_VCOM)
	tracef("* starting VCOM daemon ... ");
	/* connect the UART to the JTAG auxiliary pins */
	jtag3ctrl_aux_uart(true);
	vcom_start();
#endif

#if (ENABLE_COMM)
	tracef("* starting COMM daemon ... ");
	comm_tcp_start(&debugger.comm);
#endif

#if (ENABLE_TFTP)
	tracef("* starting TFTP server ... ");
	tftpd_start();
#endif

#if (ENABLE_GDB)
	tracef("* starting GDB daemon ... ");
	gdb_rspd_start();
#endif

#if ENABLE_USB
	tracef("* starting USB shell ... ");
	usb_shell();
#endif

#if ENABLE_TELNET
	tracef("* starting TELNET server ... ");
	telnet_shell();
#endif

	return console_shell();
}