void prvTickISR( void ) { /* Increment the tick, and perform any processing the new tick value necessitates. */ set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY ); { vTaskIncrementTick(); } set_ipl( configKERNEL_INTERRUPT_PRIORITY ); /* Only select a new task if the preemptive scheduler is being used. */ #if( configUSE_PREEMPTION == 1 ) { taskYIELD(); } #endif #if configUSE_TICKLESS_IDLE == 1 { /* The CPU woke because of a tick. */ ulTickFlag = pdTRUE; /* If this is the first tick since exiting tickless mode then the CMT compare match value needs resetting. */ CMT0.CMCOR = ( unsigned short ) ulMatchValueForOneTick; } #endif }
/* Removes the head of the buffer and returns the associated ScanCode. */ UINT8 pop_head( ) { UINT8 bReturnCode = BREAK_MASK; int old_ssp = Super( 1 ); int old_ipl; if( USER_MODE == old_ssp ) old_ssp = Super( 0 ); old_ipl = set_ipl( KEYBOARD_INTERRUPT_MASK ); if( cBffrHead != cBffrTail ) { cFill -= 1; bReturnCode = cKYBDBuffer[ cBffrHead ].bScanCode; cBffrHead++; } set_ipl( old_ipl ); if( SUPER_MODE != old_ssp ) Super( old_ssp ); return bReturnCode; }
/* Adds a key to the buffer based on the passed in scancode. */ void add_key( SCANCODE bCode ) { int old_ssp = Super( 1 ); int old_ipl; if( USER_MODE == old_ssp ) old_ssp = Super( 0 ); old_ipl = set_ipl( KEYBOARD_INTERRUPT_MASK ); if( cFill < MAX_BUFFER_SIZE ) { cKYBDBuffer[ cBffrTail ].bScanCode = bCode; cKYBDBuffer[ cBffrTail ].bValid = true; cFill++; cBffrTail++; cMakeTable[ bCode ].bMakeReceived = true; cMakeTable[ bCode ].wDuration = STARTING_DURATION; } set_ipl( old_ipl ); if( SUPER_MODE != old_ssp ) Super( old_ssp ); }
/* Function for updating the keyboard buffer and pushing back codes that haven't received a break code yet. */ void update_input_buffer( UINT8 bTimeElapsed ) { UINT8 bIndex = 0; int old_ssp = Super( 1 ); int old_ipl; if( USER_MODE == old_ssp ) old_ssp = Super( 0 ); old_ipl = set_ipl( KEYBOARD_INTERRUPT_MASK ); for( bIndex; bIndex < cHotKeyCount; bIndex++ ) { if( cMakeTable[ bHotKeys[ bIndex ] ].bMakeReceived ) { cMakeTable[ bHotKeys[ bIndex ] ].wDuration -= bTimeElapsed; if( cMakeTable[ bHotKeys[ bIndex ] ].wDuration == 0 || cMakeTable[ bHotKeys[ bIndex ] ].wDuration > STARTING_DURATION ) { add_key( bHotKeys[ bIndex ] ); cMakeTable[ bHotKeys[ bIndex ] ].wDuration = SUBSEQUENT_DURATION; } } } set_ipl( old_ipl ); if( SUPER_MODE != old_ssp ) Super( old_ssp ); }
/* * �v���^�X�N�t�b�N�̌Ăяo�� */ void call_pretaskhook(void) { callevel = TCL_PREPOST; set_ipl(ipl_maxisr2); unlock_cpu(); PreTaskHook(); lock_cpu(); set_ipl(IPL_ENA_ALL); callevel = TCL_TASK; }
/* * リソースの獲得 */ StatusType GetResource(ResourceType resid) { StatusType ercd = E_OK; Priority ceilpri, curpri; LOG_GETRES_ENTER(resid); CHECK_CALLEVEL(TCL_TASK | TCL_ISR2); CHECK_RESID(resid); ceilpri = resinib_ceilpri[resid]; if (callevel == TCL_TASK) { CHECK_ACCESS(tinib_inipri[runtsk] <= ceilpri); lock_cpu(); D_CHECK_ACCESS(rescb_prevpri[resid] == TPRI_NULL); curpri = tcb_curpri[runtsk]; rescb_prevpri[resid] = curpri; rescb_prevres[resid] = tcb_lastres[runtsk]; tcb_lastres[runtsk] = resid; if (ceilpri > curpri) { tcb_curpri[runtsk] = ceilpri; if (ceilpri >= TPRI_MINISR) { set_ipl(ceilpri - TPRI_MINISR); } } } else { CHECK_ACCESS(isrinib_intpri[runisr] <= ceilpri); lock_cpu(); D_CHECK_ACCESS(rescb_prevpri[resid] == TPRI_NULL); curpri = current_ipl() + TPRI_MINISR; rescb_prevpri[resid] = curpri; rescb_prevres[resid] = isrcb_lastres[runisr]; isrcb_lastres[runisr] = resid; if (ceilpri > curpri) { set_ipl(ceilpri - TPRI_MINISR); } } exit: unlock_cpu(); LOG_GETRES_LEAVE(ercd); return(ercd); error_exit: lock_cpu(); d_error_exit: _errorhook_par1.resid = resid; call_errorhook(ercd, OSServiceId_GetResource); goto exit; }
void vTickISR( void ) { /* Increment the tick, and perform any processing the new tick value necessitates. */ set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY ); { if( xTaskIncrementTick() != pdFALSE ) { taskYIELD(); } } set_ipl( configKERNEL_INTERRUPT_PRIORITY ); }
/* * リソースの返却 */ StatusType ReleaseResource(ResourceType resid) { StatusType ercd = E_OK; LOG_RELRES_ENTER(resid); CHECK_CALLEVEL(TCL_TASK | TCL_ISR2); CHECK_RESID(resid); if (callevel == TCL_TASK) { CHECK_ACCESS(tinib_inipri[runtsk] <= resinib_ceilpri[resid]); CHECK_NOFUNC(tcb_lastres[runtsk] == resid); lock_cpu(); if (rescb_prevpri[resid] >= TPRI_MINISR) { set_ipl(rescb_prevpri[resid] - TPRI_MINISR); } else{ if (tcb_curpri[runtsk] >= TPRI_MINISR) { set_ipl(IPL_ENA_ALL); } } tcb_curpri[runtsk] = rescb_prevpri[resid]; tcb_lastres[runtsk] = rescb_prevres[resid]; rescb_prevpri[resid] = TPRI_NULL; if (tcb_curpri[runtsk] < nextpri) { preempt(); dispatch(); } } else { CHECK_ACCESS(isrinib_intpri[runisr] <= resinib_ceilpri[resid]); CHECK_NOFUNC(isrcb_lastres[runisr] == resid); lock_cpu(); set_ipl(rescb_prevpri[resid] - TPRI_MINISR); isrcb_lastres[runisr] = rescb_prevres[resid]; rescb_prevpri[resid] = TPRI_NULL; } exit: unlock_cpu(); LOG_RELRES_LEAVE(ercd); return(ercd); error_exit: lock_cpu(); _errorhook_par1.resid = resid; call_errorhook(ercd, OSServiceId_ReleaseResource); goto exit; }
void vTickISR( void ) { /* Increment the tick, and perform any processing the new tick value necessitates. */ set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY ); { vTaskIncrementTick(); } set_ipl( configKERNEL_INTERRUPT_PRIORITY ); /* Only select a new task if the preemptive scheduler is being used. */ #if( configUSE_PREEMPTION == 1 ) taskYIELD(); #endif }
/* Returns whether there is pending input or not. */ bool inputPending( ) { int old_ssp = Super( 1 ); int old_ipl; if( USER_MODE == old_ssp ) old_ssp = Super( 0 ); old_ipl = set_ipl( KEYBOARD_INTERRUPT_MASK ); while( cBffrHead != cBffrTail && !cKYBDBuffer[ cBffrHead ].bValid ) pop_head( ); set_ipl( old_ipl ); if( SUPER_MODE != old_ssp ) Super( old_ssp ); return EMPTY != cFill; }
/* * �G���[�t�b�N�̌Ăяo�� */ void call_errorhook(StatusType ercd, OSServiceIdType svcid) { UINT8 saved_callevel; IPL saved_ipl; volatile FP errorhook_adr; /* * C�����̋K�i�ł͊��̃A�h���X��0�ɂȂ��Ȃ��Ƃ����O��, * �R���p�C���̍œK���ɂ���ErrorHook�̃A�h���X���蕪���� * �폜�����Ă��܂��ꍇ�����邽��, volatile�w�肵�����[�J���ϐ��� * �A�h���X���������Ă��画�肵�Ă����D */ errorhook_adr = (FP)ErrorHook; if (sus_all_cnt > 0) { if ((errorhook_adr != NULL) && (callevel != TCL_ERROR)) { _errorhook_svcid = svcid; ErrorHook(ercd); } ShutdownOS(E_OS_CALLEVEL); /* �s�\ */ } else { if (( errorhook_adr != NULL) && (callevel != TCL_ERROR)) { _errorhook_svcid = svcid; saved_callevel = callevel; callevel = TCL_ERROR; saved_ipl = current_ipl(); if (saved_ipl < ipl_maxisr2) { set_ipl(ipl_maxisr2); } unlock_cpu(); ErrorHook(ercd); lock_cpu(); if (saved_ipl < ipl_maxisr2) { set_ipl(saved_ipl); } callevel = saved_callevel; } } }
/* * エラーフックの呼び出し */ void call_errorhook(StatusType ercd, OSServiceIdType svcid) { UINT8 saved_callevel; IPL saved_ipl; volatile FP errorhook_adr; /* * C言語の規格では関数のアドレスは0にならないという前提から, * コンパイラの最適化によりErrorHookのアドレス判定分岐が * 削除されてしまう場合があるため, volatile指定したローカル変数に * アドレスを代入してから判定している. */ errorhook_adr = (FP)ErrorHook; if (sus_all_cnt > 0) { if ((errorhook_adr != NULL) && (callevel != TCL_ERROR)) { _errorhook_svcid = svcid; ErrorHook(ercd); } ShutdownOS(E_OS_CALLEVEL); /* 回復不可能 */ } else { if (( errorhook_adr != NULL) && (callevel != TCL_ERROR)) { _errorhook_svcid = svcid; saved_callevel = callevel; callevel = TCL_ERROR; saved_ipl = current_ipl(); if (saved_ipl < ipl_maxisr2) { set_ipl(ipl_maxisr2); } unlock_cpu(); ErrorHook(ercd); lock_cpu(); if (saved_ipl < ipl_maxisr2) { set_ipl(saved_ipl); } callevel = saved_callevel; } } }
void prvTickISR( void ) { /* Increment the tick, and perform any processing the new tick value necessitates. */ set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY ); { if( xTaskIncrementTick() != pdFALSE ) { taskYIELD(); } } set_ipl( configKERNEL_INTERRUPT_PRIORITY ); #if configUSE_TICKLESS_IDLE == 1 { /* The CPU woke because of a tick. */ ulTickFlag = pdTRUE; /* If this is the first tick since exiting tickless mode then the CMT compare match value needs resetting. */ CMT0.CMCOR = ( uint16_t ) ulMatchValueForOneTick; } #endif }
/*********************************************************************************************************************** * Function Name: R_BSP_CpuInterruptLevelWrite * Description : Writes the processor interrupt priority level. * Arguments : level - * The level to set the processor's IPL to. * Return Value : true - * The level was set successfully. * false - * Invalid level input. ***********************************************************************************************************************/ bool R_BSP_CpuInterruptLevelWrite (uint32_t level) { #if (BSP_CFG_PARAM_CHECKING_ENABLE == 1) /* Check for valid level. */ if (level > BSP_MCU_IPL_MAX) { return false; } #endif #if defined(__RENESAS__) /* Use the compiler intrinsic function to set the CPU IPL. This function is available with for the Renesas RX compiler. This may need to be changed for other compilers. */ set_ipl((signed long)level); #endif return true; }