/*
 * Start initial task
 */
LOCAL void knl_init_task_startup( T_CTSK *ctsk )
{
    ER	ercd;

#if TA_GP
    extern int _gp;
    ercd = tk_cre_tsk_impl(ctsk, 0,0,0,0,&_gp);
#else
    ercd = tk_cre_tsk_impl(ctsk);
#endif
    if ( ercd < E_OK ) {
        goto err_exit;
    }

    ercd = tk_sta_tsk_impl((ID)ercd, 0);
    if ( ercd < E_OK ) {
        goto err_exit;
    }

    return;

err_exit:
#if USE_KERNEL_MESSAGE
    tm_putstring((UB*)"init_task can not started\n");
#endif
    tm_monitor();
}
Exemple #2
0
/*
 * End and delete its own task
 */
SYSCALL void _tk_exd_tsk( void )
{
	/* Check context error */
#if CHK_CTX2
	if ( in_indp() ) {
#if USE_KERNEL_MESSAGE
		tm_putstring((UB*)"tk_exd_tsk was called in the task independent\n");
#endif
		tm_monitor(); /* To monitor */
	}
#endif
#if CHK_CTX1
	if ( in_ddsp() ) {
#if USE_KERNEL_MESSAGE
		tm_putstring((UB*)"tk_exd_tsk was called in the dispatch disabled\n");
#endif
	}
#endif

	DISABLE_INTERRUPT;
	_ter_tsk(ctxtsk);
	_del_tsk(ctxtsk);

	force_dispatch();
	/* No return */
}
Exemple #3
0
/*
 * Entry for starting Kernel
 */
EXPORT int main( void )
{
	int err;
	
	DO_DEBUG( tm_monitor(); )

	/* Initialize sequence before T-Kernel starts */
	if (err = init_system()) {
Exemple #4
0
/*
 * Start system
 */
EXPORT void start_system( void )
{
	ER	ercd;

	/* Initialize segment manager */
	DispProgress(0x30);
	ercd = start_segmgr();
	if ( ercd < E_OK ) {
		goto err_ret;
	}

	/* Start memory manager */
	DispProgress(0x31);
	ercd = start_memmgr();
	if ( ercd < E_OK ) {
		goto err_ret;
	}

	/* Initialize system manager */
	DispProgress(0x32);
	ercd = SystemManager(0, NULL);
	if ( ercd < E_OK ) {
		goto err_ret;
	}

	/* Initialize library (libtk)
	   V/K/Smalloc is available after this. */
	DispProgress(0x33);
	_InitLibtk();

	/* Lower the initial task priority to initialize sequence
	   for the subsystem task at first. */
	tk_chg_pri(TSK_SELF, InitTaskPri);

	/* Start system dependent sequence */
	DispProgress(0x34);
	ercd = start_device();
	if ( ercd < E_OK ) {
		goto err_ret;
	}

	/* Start subsystem */
	DispProgress(0x35);
	ercd = start_subsystems();
	if ( ercd < E_OK ) {
		goto err_ret;
	}

	return;

err_ret:
#if USE_KERNEL_MESSAGE
	tm_putstring((UB*)"!ERROR! start_system\n");
#endif
	tm_monitor();	/* Stop */
}
Exemple #5
0
/*
 * Target system-dependent finalization
 *	Normally jump to ROM monitor.
 *	No return from this function.
 */
EXPORT void tkdev_exit( void )
{
	disint();
	tm_exit(0);	/* Turn off power and exit */

	/* Not suppose to return from 'tm_exit,' but just in case */
	for ( ;; ) {
		tm_monitor();  /* To T-Monitor */
	}
}
/*
 * Call module initialization
 */
LOCAL void knl_init_module( ER (*initfunc)( void ), UB *name )
{
    ER	ercd;

    ercd = (*initfunc)();
    if ( ercd < E_OK ) {
#if USE_KERNEL_MESSAGE
        tm_putstring(name);
        tm_putstring((UB*)" : module initialize error\n");
#endif
        tm_monitor();
    }
}
/* |------------------+-------------------------------------------------------------| */
StatusType ChainTask ( TaskType xTaskID )
{
	StatusType ercd;
#ifdef DORMANT_STACK_SIZE
	/* To avoid destroying stack used in 'knl_make_dormant',
	   allocate the dummy area on the stack. */
	volatile VB _dummy[DORMANT_STACK_SIZE];
#endif

	/* Check context error */
#if CHK_CTX2
	if ( in_indp() ) {
#if USE_KERNEL_MESSAGE
		tm_putstring((UB*)"ChainTask was called in the task independent\n");
#endif
		tm_monitor(); /* To monitor */
	}
#endif
#if CHK_CTX1
	if ( in_ddsp() ) {
#if USE_KERNEL_MESSAGE
		tm_putstring((UB*)"ChainTask was called in the dispatch disabled\n");
#endif
	}
#endif

	DISABLE_INTERRUPT;
	ercd = tk_sta_tsk(xTaskID,xTaskID);
	if(ercd < E_OK)
	{
		ENABLE_INTERRUPT;
		return ercd;
	}
	knl_ter_tsk(knl_ctxtsk);
	knl_make_dormant(knl_ctxtsk);

	OsekStartHighReadyTask();
	/* No return */

#ifdef DORMANT_STACK_SIZE
	/* for WARNING */
	_dummy[0] = 0;
#endif
}
Exemple #8
0
/*
 * End its own task
 */
SYSCALL void _tk_ext_tsk( void )
{
#ifdef DORMANT_STACK_SIZE
	/* To avoid destroying stack used in 'make_dormant',
	   allocate the dummy area on the stack. */
	volatile VB _dummy[DORMANT_STACK_SIZE];
	MEMSET((void *)_dummy, 0xCC, DORMANT_STACK_SIZE);
#endif

	/* Check context error */
#if CHK_CTX2
	if ( in_indp() ) {
#if USE_KERNEL_MESSAGE
		tm_putstring((UB*)"tk_ext_tsk was called in the task independent\n");
#endif
		tm_monitor(); /* To monitor */
	}
#endif
#if CHK_CTX1
	if ( in_ddsp() ) {
#if USE_KERNEL_MESSAGE
		tm_putstring((UB*)"tk_ext_tsk was called in the dispatch disabled\n");
#endif
	}
#endif

	DISABLE_INTERRUPT;
	_ter_tsk(ctxtsk);
	make_dormant(ctxtsk);

	force_dispatch();
	/* No return */

#ifdef DORMANT_STACK_SIZE
	/* for WARNING */
	_dummy[0] = 0;
#endif
}
Exemple #9
0
/*
 * Initialize sequence before T-Kernel starts
 */
EXPORT void init_system( void )
{
	ER	ercd;

	/* if i'm first processor, execution */
	if ( get_prid() == 0 ) {
		/* Platform dependent initialize sequence */
		DispProgress(0x10);
		ercd = init_device();
		if ( ercd < E_OK ) {
			goto err_ret;
		}

		/* Initialize subsystem */
		DispProgress(0x11);
		ercd = init_subsystems();
		if ( ercd < E_OK ) {
			goto err_ret;
		}

		/* Initialize segment manager */
		DispProgress(0x12);
		ercd = init_segmgr();
		if ( ercd < E_OK ) {
			goto err_ret;
		}

		/* Initialize memory manager */
		DispProgress(0x13);
		ercd = init_memmgr();
		if ( ercd < E_OK ) {
			goto err_ret;
		}

		/* Initialize Imalloc */
		DispProgress(0x14);
		ercd = init_Imalloc();
		if ( ercd < E_OK ) {
			goto err_ret;
		}
	} else {
		/* Platform dependent initialize sequence */
		DispProgress(0x10);
		ercd = init_device();
		if ( ercd < E_OK ) {
			goto err_ret;
		}

		/* Initialize segment manager */
		DispProgress(0x12);
		ercd = init_segmgr();
		if ( ercd < E_OK ) {
			goto err_ret;
		}
	}

	return;

err_ret:
#if USE_KERNEL_MESSAGE
	tm_putstring((UB*)"!ERROR! init_kernel\n");
#endif
	tm_monitor(); /* Stop */
}