riscv: add generic way to detect if inside interrupt context

This commit is contained in:
brendan 2026-08-27 11:16:48 +08:00
parent 8be86d4a24
commit 50013cf591
4 changed files with 33 additions and 2 deletions

View file

@ -97,6 +97,12 @@ volatile uint64_t * pullMachineTimerCompareRegister = NULL;
size_t xCriticalNesting = ( size_t ) 0xaaaaaaaa;
size_t * pxCriticalNesting = &xCriticalNesting;
/*
* Counts the interrupt nesting depth.
*/
size_t xInterruptNesting = 0;
size_t * pxInterruptNesting = &xInterruptNesting;
/* Used to catch tasks that attempt to return from their implementing function. */
size_t xTaskReturnAddress = ( size_t ) portTASK_RETURN_ADDRESS;
@ -205,3 +211,9 @@ void vPortEndScheduler( void )
}
}
/*-----------------------------------------------------------*/
BaseType_t xPortIsInsideInterrupt( void )
{
return ( xInterruptNesting == 0 ) ? pdFALSE : pdTRUE;
}
/*-----------------------------------------------------------*/