📄 misc_calls.c
字号:
/* *---------------------------------------------------------------------- * T-Kernel * * Copyright (C) 2004 by Ken Sakamura. All rights reserved. * T-Kernel is distributed under the T-License. *---------------------------------------------------------------------- * * Version: 1.01.00 * Released by T-Engine Forum(http://www.t-engine.org) at 2004/6/28. * *---------------------------------------------------------------------- *//* * misc_calls.c (T-Kernel/OS) * Other System Calls */#include "kernel.h"#include "task.h"#include "check.h"IMPORT const T_RVER kernel_version;/* * Refer system state */SYSCALL ER _tk_ref_sys( T_RSYS *pk_rsys ){ if ( in_indp() ) { pk_rsys->sysstat = TSS_INDP; } else { if ( in_qtsk() ) { pk_rsys->sysstat = TSS_QTSK; } else { pk_rsys->sysstat = TSS_TSK; } if ( in_loc() ) { pk_rsys->sysstat |= TSS_DINT; } if ( in_ddsp() ) { pk_rsys->sysstat |= TSS_DDSP; } } pk_rsys->runtskid = ( ctxtsk != NULL )? ctxtsk->tskid: 0; pk_rsys->schedtskid = ( schedtsk != NULL )? schedtsk->tskid: 0; return E_OK;}/* * Refer version information */SYSCALL ER _tk_ref_ver( T_RVER *pk_rver ){ INT n, prver; memcpy(pk_rver, &kernel_version, sizeof(T_RVER)); n = _tk_get_cfn("OS-Ver", &prver, 1); if ( n >= 1 ) pk_rver->prver = prver; return E_OK;}/* * Number of times for disabling power-saving mode switch * If it is 0, the mode switch is enabled. */EXPORT UINT lowpow_discnt = 0;#define LOWPOW_LIMIT 0x7fff /* Maximum number for disabling *//* * Set Power-saving mode */SYSCALL ER _tk_set_pow( UINT pwmode ){IMPORT void off_pow( void ); /* T-Kernel/SM */ ER ercd = E_OK; CHECK_INTSK(); BEGIN_CRITICAL_SECTION; switch ( pwmode ) { case TPW_DOSUSPEND: off_pow(); break; case TPW_DISLOWPOW: if ( lowpow_discnt >= LOWPOW_LIMIT ) ercd = E_QOVR; else lowpow_discnt++; break; case TPW_ENALOWPOW: if ( lowpow_discnt <= 0 ) ercd = E_OBJ; else lowpow_discnt--; break; default: ercd = E_PAR; } END_CRITICAL_SECTION; return ercd;}/* ------------------------------------------------------------------------ *//* * Debugger support function */#if USE_DBGSPT/* * Hook routine address */EXPORT FP hook_enterfn;EXPORT FP hook_leavefn;EXPORT FP hook_execfn;EXPORT FP hook_stopfn;EXPORT FP hook_ienterfn;EXPORT FP hook_ileavefn;#if TA_GPEXPORT VP hook_svc_gp;EXPORT VP hook_dsp_gp;EXPORT VP hook_int_gp;#endif/* * Hook enable/disable setting */IMPORT void hook_svc( void );IMPORT void unhook_svc( void );IMPORT void hook_dsp( void );IMPORT void unhook_dsp( void );IMPORT void hook_int( void );IMPORT void unhook_int( void );/* * Set/Cancel system call/extended SVC hook routine */SYSCALL ER _td_hok_svc P1( TD_HSVC *hsvc ){ BEGIN_DISABLE_INTERRUPT; if ( hsvc == NULL ) { /* Cancel system call hook routine */ /* Cancel */ unhook_svc(); } else { /* Set */ hook_enterfn = hsvc->enter; hook_leavefn = hsvc->leave;#if TA_GP hook_svc_gp = gp;#endif hook_svc(); } END_DISABLE_INTERRUPT; return E_OK;}/* * Set/Cancel dispatcher hook routine */SYSCALL ER _td_hok_dsp P1( TD_HDSP *hdsp ){ BEGIN_DISABLE_INTERRUPT; if ( hdsp == NULL ) { /* Cancel dispatcher hook routine */ /* Cancel */ unhook_dsp(); } else { /* Set */ hook_execfn = hdsp->exec; hook_stopfn = hdsp->stop;#if TA_GP hook_dsp_gp = gp;#endif hook_dsp(); } END_DISABLE_INTERRUPT; return E_OK;}/* * Set/Cancel EIT handler hook routine */SYSCALL ER _td_hok_int P1( TD_HINT *hint ){ BEGIN_DISABLE_INTERRUPT; if ( hint == NULL ) { /* Cancel interrupt handler hook routine */ /* Cancel */ unhook_int(); } else { /* Set */ hook_ienterfn = hint->enter; hook_ileavefn = hint->leave;#if TA_GP hook_int_gp = gp;#endif hook_int(); } END_DISABLE_INTERRUPT; return E_OK;}/* * Refer system state */SYSCALL ER _td_ref_sys( TD_RSYS *pk_rsys ){ if ( in_indp() ) { pk_rsys->sysstat = TSS_INDP; } else { if ( in_qtsk() ) { pk_rsys->sysstat = TSS_QTSK; } else { pk_rsys->sysstat = TSS_TSK; } if ( in_loc() ) { pk_rsys->sysstat |= TSS_DINT; } if ( in_ddsp() ) { pk_rsys->sysstat |= TSS_DDSP; } } pk_rsys->runtskid = ( ctxtsk != NULL )? ctxtsk->tskid: 0; pk_rsys->schedtskid = ( schedtsk != NULL )? schedtsk->tskid: 0; return E_OK;}#endif /* USE_DBGSPT */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -