tkernel_2/kernel/sysmain/src/inittask_main.c | bare source | permlink (0.00 seconds) |
1: /* 2: *---------------------------------------------------------------------- 3: * T-Kernel 2.0 Software Package 4: * 5: * Copyright 2011 by Ken Sakamura. 6: * This software is distributed under the latest version of T-License 2.x. 7: *---------------------------------------------------------------------- 8: * 9: * Released by T-Engine Forum(http://www.t-engine.org/) at 2011/05/17. 10: * Modified by T-Engine Forum at 2013/02/28. 11: * Modified by TRON Forum(http://www.tron.org/) at 2015/06/01. 12: * 13: *---------------------------------------------------------------------- 14: */ 15: 16: /* 17: * inittask_main.c (sysmain) 18: * Initial Task 19: */ 20: 21: #include "sysmain.h" 22: #include "kernel.h" 23: #include <sys/rominfo.h> 24: #include <sys/debug.h> 25: 26: typedef INT (*MAIN_FP)(INT, UB **); 27: 28: /* ------------------------------------------------------------------------ */ 29: 30: /* 31: * Initial task Main 32: * The available stack size is slightly less than 8KB. 33: * The initial task is the system task, 34: * so it should not be deleted. 35: */ 36: EXPORT INT init_task_main( void ) 37: { 38: INT fin; 39: MAIN_FP adr; 40: 41: /* Start message */ 42: #if USE_KERNEL_MESSAGE 43: tm_putstring((UB*)BOOT_MESSAGE); 44: #endif 45: 46: fin = 1; 47: adr = (MAIN_FP)ROMInfo->userinit; 48: if ( adr != NULL ) { 49: /* Perform user defined initialization sequence */ 50: fin = (*adr)(0, NULL); 51: } 52: if ( fin > 0 ) { 53: /* Perform user main */ 54: fin = usermain(); 55: } 56: if ( adr != NULL ) { 57: /* Perform user defined finalization sequence */ 58: (*adr)(-1, NULL); 59: } 60: 61: return fin; 62: }