/* * Library initialization */ EXPORT void _InitLibtk( void ) { INT rng; if ( libtk_init_done ) { return; /* Initialized */ } /* Kernel utility initialization */ KnlInit(); /* Lowest protection level where system calls can be issued */ if ( tk_get_cfn((UB*)"TSVCLimit", &rng, 1) < 1 ) { rng = 2; } rng <<= 8; /* Create exclusive control lock for library sharing */ _init_liblock(); /* malloc initialization */ _tkm_init((UINT)rng, &_Kmacb); /* Kmalloc init */ _tkm_init((UINT)rng|TA_NORESIDENT, &_Vmacb); /* Vmalloc init */ _tkm_init(TA_RNG3|TA_NORESIDENT, &_Smacb); /* Smalloc init */ libtk_init_done = TRUE; /* Initialization complete */ }
/* * Library initialization */ EXPORT void _InitLibtk( void ) { INT rng; if ( libtk_init_done ) { return; /* Initialized */ } /* Kernel utility initialization */ KnlInit(); #ifdef T2EX /* T2EX API protected level */ if ( tk_get_cfn("TSVCLimit", &t2ex_call_limit, 1) < 1 ) { t2ex_call_limit = 2; } /* Kmalloc/Vmalloc memory protection level */ if ( tk_get_cfn("TKmallocLvl", &rng, 1) < 1 ) { rng = t2ex_call_limit; } #else /* Lowest protection level where system calls can be issued */ if ( tk_get_cfn("TSVCLimit", &rng, 1) < 1 ) { rng = 2; } #endif rng <<= 8; /* Create exclusive control lock for library sharing */ _init_liblock(); #ifdef T2EX_MM CreateULock(&_SmacbLock, "ultk"); #endif /* malloc initialization */ _tkm_init((UINT)rng, &_Kmacb); /* Kmalloc init */ _tkm_init((UINT)rng|TA_NORESIDENT, &_Vmacb); /* Vmalloc init */ _tkm_init(TA_RNG3|TA_NORESIDENT, &_Smacb); /* Smalloc init */ libtk_init_done = TRUE; /* Initialization complete */ }
EXPORT ER tkn_lwp_init(void) { int i; int error; ER ercd; error = mutex_init(&spc_lock, 0, IPL_NONE); if ( error != 0 ) { ercd = ERRNOtoER(error); goto err_ret0; } if (tk_get_cfn("TMaxTskId", &tskid_lwp_table_maxid, 1) < 1) { ercd = E_SYS; goto err_ret1; } tskid_lwp_table = (lwp_t *)malloc(sizeof(lwp_t)*tskid_lwp_table_maxid, M_KMEM, M_NOWAIT | M_ZERO); if (tskid_lwp_table == NULL) { ercd = E_NOMEM; goto err_ret1; } for(i = 0; i < tskid_lwp_table_maxid; i++) { tskid_lwp_table[i].l_proc = &proc; tskid_lwp_table[i].l_mutex = &spc_lock; callout_init(&tskid_lwp_table[i].l_timeout_ch, 0); callout_setfunc(&tskid_lwp_table[i].l_timeout_ch, sleepq_timeout, &tskid_lwp_table[i]); } return E_OK; err_ret1: mutex_destroy(&spc_lock); err_ret0: return ercd; }