tkernel_2/kernel/sysinit/src/sysinit_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 TRON Forum(http://www.tron.org/) at 2015/06/01. 11: * 12: *---------------------------------------------------------------------- 13: */ 14: 15: /* 16: * sysinit_main.c (sysinit) 17: * Initialize System 18: */ 19: 20: #include "sysinit.h" 21: #include "patch.h" 22: #include <tk/util.h> 23: #include <sys/rominfo.h> 24: #include <sys/debug.h> 25: 26: /* 27: * Initialize sequence before T-Kernel starts 28: * Perform preparation necessary to start T-Kernel. 29: */ 30: IMPORT void init_system( void ); 31: 32: /* 33: * Start T-Kernel 34: * Start T-Kernel/OS and the initial task specified by 'ctsk'. 35: * 36: * T-Kernel/SM doesn't start when the initial task starts, 37: * so services of T-Kernel/SM are not available at this point. 38: * Never return from this function. 39: */ 40: IMPORT void t_kernel_main( T_CTSK *ctsk ); 41: 42: /* 43: * Start System 44: * Start following steps. 45: * 1. Start T-Kernel/SM. 46: * 2. Make the task priority to '138'. 47: * 3. Call start_subsystems(). 48: * At this point, start each subsystem and each device driver. 49: * Return from function after starting. 50: */ 51: IMPORT void start_system( void ); 52: 53: /* 54: * Stop System 55: * 1. Call finish_subsystems(). 56: * At this point, stop each subsystem and each device driver. 57: * 2. Stop T-Kernel/SM and T-Kernel/OS. 58: * 3. Do power down or re-start according to 'fin'. 59: * Never return from this function. 60: * 61: * fin = 0 : Power off 62: * -1 : reset and re-start (Reset -> Boot -> Start) 63: * -2 : fast re-start (Start) 64: * -3 : Normal re-start (Boot -> Start) 65: * 66: * fin = -2 or -3 are not always supported. 67: */ 68: IMPORT void shutdown_system( INT fin ); 69: 70: /* 71: * Main initial task sequence (sysmain) 72: */ 73: IMPORT INT init_task_main( void ); 74: 75: /* ------------------------------------------------------------------------ */ 76: 77: /* 78: * Initial task 79: */ 80: EXPORT void init_task(void) 81: { 82: INT fin; 83: 84: #if USE_SYSDEPEND_PATCH1 85: /* System-dependent processes (before start_system) */ 86: sysdepend_patch1(); 87: #endif 88: 89: /* Start system */ 90: start_system(); 91: 92: #if USE_SYSDEPEND_PATCH2 93: /* System-dependent processes (after start_system) */ 94: sysdepend_patch2(); 95: #endif 96: 97: /* Initial task main */ 98: fin = init_task_main(); 99: 100: /* Stop System */ 101: shutdown_system(fin); /* Never return */ 102: } 103: 104: /* 105: * Initial task creation parameter 106: */ 107: IMPORT const T_CTSK c_init_task; 108: 109: /* 110: * Entry for starting Kernel 111: */ 112: EXPORT int main( void ) 113: { 114: DO_DEBUG( tm_monitor(); ) 115: 116: /* Initialize sequence before T-Kernel starts */ 117: init_system(); 118: 119: /* Start T-Kernel */ 120: t_kernel_main((T_CTSK *)&c_init_task); /* Never return */ 121: 122: return 0; 123: }