gonzui


Format: Advanced Search

mtkernel_3/kernel/sysdepend/cpu/core/rxv2/cpu_status.hbare sourcepermlink (0.00 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    micro T-Kernel 3.00.03
    4:  *
    5:  *    Copyright (C) 2006-2021 by Ken Sakamura.
    6:  *    This software is distributed under the T-License 2.2.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by TRON Forum(http://www.tron.org) at 2021/03/31.
   10:  *
   11:  *----------------------------------------------------------------------
   12:  */
   13: 
   14: /*
   15:  *      cpu_status.h (RXv2)
   16:  *      CPU-Dependent Status Definition
   17:  */
   18: 
   19: #ifndef _SYSDEPEND_CPU_CORE_STATUS_
   20: #define _SYSDEPEND_CPU_CORE_STATUS_
   21: 
   22: #include <tk/syslib.h>
   23: #include <sys/sysdef.h>
   24: 
   25: #include "sysdepend.h"
   26: /*
   27:  * Start/End critical section
   28:  */
   29: #define BEGIN_CRITICAL_SECTION  { UINT _sr_ = disint();
   30: #define END_CRITICAL_SECTION    if ( !isDI(_sr_)                   \
   31:                                   && knl_ctxtsk != knl_schedtsk             \
   32:                                   && !knl_isTaskIndependent()               \
   33:                                   && !knl_dispatch_disabled ) {             \
   34:                                         knl_dispatch();                    \
   35:                                 }                                   \
   36:                                 setint(_sr_); }
   37: /*
   38:  * Start/End interrupt disable section
   39:  */
   40: #define BEGIN_DISABLE_INTERRUPT { UINT _sr_ = disint();
   41: #define END_DISABLE_INTERRUPT   setint(_sr_); }
   42: 
   43: /*
   44:  * Interrupt enable/disable
   45:  */
   46: #define ENABLE_INTERRUPT        { setint(0); }
   47: #define DISABLE_INTERRUPT       { disint(); }
   48: 
   49: /*
   50:  * Enable interrupt nesting
   51:  *      Enable the interrupt that has a higher priority than 'level.'
   52:  */
   53: #define ENABLE_INTERRUPT_UPTO(level)    { setint(level); }
   54: 
   55: /*
   56:  *  Task-independent control
   57:  */
   58: IMPORT  W        knl_taskindp;          /* Task independent status */
   59: 
   60: /*
   61:  * If it is the task-independent part, TRUE
   62:  */
   63: Inline BOOL knl_isTaskIndependent( void )
   64: {
   65:         return ( knl_taskindp > 0 )? TRUE: FALSE;
   66: }
   67: /*
   68:  * Move to/Restore task independent part
   69:  */
   70: Inline void knl_EnterTaskIndependent( void )
   71: {
   72:         knl_taskindp++;
   73: }
   74: 
   75: Inline void knl_LeaveTaskIndependent( void )
   76: {
   77:         knl_taskindp--;
   78: }
   79: 
   80: /*
   81:  * Move to/Restore task independent part
   82:  */
   83: #define ENTER_TASK_INDEPENDENT  { knl_EnterTaskIndependent(); }
   84: #define LEAVE_TASK_INDEPENDENT  { knl_LeaveTaskIndependent(); }
   85: 
   86: /* ----------------------------------------------------------------------- */
   87: /*
   88:  *      Check system state
   89:  */
   90: 
   91: /*
   92:  * When a system call is called from the task independent part, TRUE
   93:  */
   94: #define in_indp()       ( knl_isTaskIndependent() || knl_ctxtsk == NULL )
   95: 
   96: /*
   97:  * When a system call is called during dispatch disable, TRUE
   98:  * Also include the task independent part as during dispatch disable.
   99:  */
  100: #define in_ddsp()       ( knl_dispatch_disabled       \
  101:                         || in_indp()         \
  102:                         || isDI( GetCpuIntLevel()-1) )
  103: 
  104: /*
  105:  * When a system call is called during CPU lock (interrupt disable), TRUE
  106:  * Also include the task independent part as during CPU lock.
  107:  */
  108: #define in_loc()        (  isDI( GetCpuIntLevel()-1)   \
  109:                         || in_indp() )
  110: 
  111: /*
  112:  * When a system call is called during executing the quasi task part, TRUE
  113:  * Valid only when in_indp() == FALSE because it is not discriminated from 
  114:  * the task independent part. 
  115:  */
  116: #define in_qtsk()       ( knl_ctxtsk->sysmode > knl_ctxtsk->isysmode )
  117: 
  118: 
  119: #endif /* _SYSDEPEND_CPU_CORE_STATUS_ */