tkernel_2/lib/libtk/src/libinit.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/01/12. 11: * Modified by TRON Forum(http://www.tron.org/) at 2015/06/01. 12: * 13: *---------------------------------------------------------------------- 14: */ 15: 16: /* 17: * @(#)libinit.c (libtk) 18: * 19: * libker library initialization 20: * 21: * _InitLibtk() is always linked as it is called from the 22: * startup part. 23: * Note that adding too many processing can make the program 24: * quite large. 25: */ 26: 27: #include "libtk.h" 28: #include <sys/util.h> 29: #include <sys/memalloc.h> 30: #include <tk/util.h> 31: 32: EXPORT MACB _Kmacb; /* Kmalloc management information */ 33: EXPORT MACB _Vmacb; /* Vmalloc management information */ 34: EXPORT MACB _Smacb; /* Smalloc management information */ 35: 36: LOCAL BOOL libtk_init_done = FALSE; 37: 38: /* 39: * Library initialization 40: */ 41: EXPORT void _InitLibtk( void ) 42: { 43: INT rng; 44: 45: if ( libtk_init_done ) { 46: return; /* Initialized */ 47: } 48: 49: /* Kernel utility initialization */ 50: KnlInit(); 51: 52: /* Lowest protection level where system calls can be issued */ 53: if ( tk_get_cfn((UB*)"TSVCLimit", &rng, 1) < 1 ) { 54: rng = 2; 55: } 56: rng <<= 8; 57: 58: /* Create exclusive control lock for library sharing */ 59: _init_liblock(); 60: 61: /* malloc initialization */ 62: _tkm_init((UINT)rng, &_Kmacb); /* Kmalloc init */ 63: _tkm_init((UINT)rng|TA_NORESIDENT, &_Vmacb); /* Vmalloc init */ 64: _tkm_init(TA_RNG3|TA_NORESIDENT, &_Smacb); /* Smalloc init */ 65: 66: libtk_init_done = TRUE; /* Initialization complete */ 67: } 68: 69: /* 70: * Library finalization 71: */ 72: EXPORT void _FinishLibtk( void ) 73: { 74: if ( !libtk_init_done ) { 75: return; 76: } 77: 78: _delete_liblock(); 79: }