tkernel_2/kernel/sysmgr/src/smmain.c | bare source | permlink (0.03 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: * smmain.c (T-Kernel/SM) 17: * T-Kernel/System Manager 18: */ 19: 20: #include "sysmgr.h" 21: 22: /* 23: * Get resource management block 24: * Get the resource management block of subsystem of the 25: * local task 'ssid' 26: */ 27: EXPORT void* GetResBlk( ID ssid, ID tskid ) 28: { 29: ID resid; 30: void* resblk; 31: ER ercd; 32: 33: resid = tk_get_rid(tskid); 34: if ( resid < E_OK ) { 35: ercd = resid; 36: goto err_ret; 37: } 38: 39: ercd = tk_get_res(resid, ssid, &resblk); 40: if ( ercd < E_OK ) { 41: goto err_ret; 42: } 43: 44: return resblk; 45: 46: err_ret: 47: DEBUG_PRINT(("GetResBlk ercd = %d\n", ercd)); 48: return NULL; 49: } 50: 51: /* ------------------------------------------------------------------------- */ 52: 53: /* 54: * Initialization sequence 55: */ 56: LOCAL ER initialize( void ) 57: { 58: ER ercd; 59: 60: /* system management */ 61: ercd = initialize_sysmgr(); 62: if ( ercd < E_OK ) { 63: goto err_ret; 64: } 65: 66: /* Device management */ 67: ercd = initialize_devmgr(); 68: if ( ercd < E_OK ) { 69: goto err_ret; 70: } 71: 72: return E_OK; 73: 74: err_ret: 75: DEBUG_PRINT(("initialize ercd = %d\n", ercd)); 76: return ercd; 77: } 78: 79: /* 80: * Finalization sequence 81: */ 82: LOCAL ER finish( void ) 83: { 84: ER ercd; 85: 86: /* Device management */ 87: ercd = finish_devmgr(); 88: #ifdef DEBUG 89: if ( ercd < E_OK ) { 90: DEBUG_PRINT(("1. finish -> finish_devmgr ercd = %d\n", ercd)); 91: } 92: #endif 93: 94: /* system management */ 95: ercd = finish_sysmgr(); 96: #ifdef DEBUG 97: if ( ercd < E_OK ) { 98: DEBUG_PRINT(("2. finish -> finish_sysmgr ercd = %d\n", ercd)); 99: } 100: #endif 101: 102: return ercd; 103: } 104: 105: /* 106: * T-Kernel/System Manager Entrance 107: */ 108: EXPORT ER SystemManager( INT ac, UB *av[] ) 109: { 110: ER ercd; 111: 112: if ( ac >= 0 ) { 113: /* Initialization sequence */ 114: ercd = initialize(); 115: if ( ercd < E_OK ) { 116: finish(); 117: } 118: } else { 119: /* Finalization sequence */ 120: ercd = finish(); 121: } 122: 123: #ifdef DEBUG 124: if ( ercd < E_OK ) { 125: DEBUG_PRINT(("SystemManager ercd = %d\n", ercd)); 126: } 127: #endif 128: return ercd; 129: }