nobody wrote on Friday, September 01, 2006:
it works:
tasks.c
/*-----------------------------------------------------------*/
#if 1
// — JU
extern void kprintfFromISR(const char *format,…);
static void prvListTaskWithinSingleListPrintf(xList *pxList, signed portCHAR cStatus )
{
volatile tskTCB *pxNextTCB, *pxFirstTCB;
unsigned portSHORT usStackRemaining;
/* Write the details of all the TCB’s in pxList into the buffer. */
listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList );
do {
listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );
usStackRemaining = usTaskCheckFreeStackSpace( ( unsigned portCHAR * ) pxNextTCB->pxStack );
kprintfFromISR("%s\t\t%c\t%u\t%u\t\t%u\r\n",
pxNextTCB->pcTaskName, cStatus,
( unsigned int ) pxNextTCB->uxPriority,
usStackRemaining, ( unsigned int ) pxNextTCB->uxTCBNumber );
} while( pxNextTCB != pxFirstTCB );
}
void vTaskPrintCurrentFromISR()
{
unsigned portBASE_TYPE uxQueue; // vTaskList
if ( pxCurrentTCB == NULL ) {
kprintfFromISR(“there is no tasks!\n”);
return;
}
kprintfFromISR("current task %s, number 0x%x, priority %d\n",
pxCurrentTCB->pcTaskName,
pxCurrentTCB->uxTCBNumber,
pxCurrentTCB->uxPriority);
kprintfFromISR("top of stack 0x%x, start of stack 0x%x, depth 0x%x\n",
pxCurrentTCB->pxTopOfStack,
pxCurrentTCB->pxStack,
pxCurrentTCB->usStackDepth);
// only for ARM7
kprintfFromISR("R15(PC) = 0x%08x+instr, R14(LR) = 0x%08x\n", *pxCurrentTCB->pxTopOfStack, *(pxCurrentTCB->pxTopOfStack-1));
kprintfFromISR("R13(SP) = 0x%08x, R12 = 0x%08x\n", *(pxCurrentTCB->pxTopOfStack-2), *(pxCurrentTCB->pxTopOfStack-3));
kprintfFromISR(" R11 = 0x%08x, R10 = 0x%08x, ", *(pxCurrentTCB->pxTopOfStack-4), *(pxCurrentTCB->pxTopOfStack-5));
kprintfFromISR(" R9 = 0x%08x, R8 = 0x%08x\n", *(pxCurrentTCB->pxTopOfStack-6), *(pxCurrentTCB->pxTopOfStack-7));
kprintfFromISR(" R7 = 0x%08x, R6 = 0x%08x, ", *(pxCurrentTCB->pxTopOfStack-8), *(pxCurrentTCB->pxTopOfStack-9));
kprintfFromISR(" R5 = 0x%08x, R4 = 0x%08x\n", *(pxCurrentTCB->pxTopOfStack-10), *(pxCurrentTCB->pxTopOfStack-11));
kprintfFromISR(" R3 = 0x%08x, R2 = 0x%08x, ", *(pxCurrentTCB->pxTopOfStack-12), *(pxCurrentTCB->pxTopOfStack-13));
kprintfFromISR(" R1 = 0x%08x, R0 = 0x%08x\n", *(pxCurrentTCB->pxTopOfStack-14), *(pxCurrentTCB->pxTopOfStack-15));
kprintfFromISR("SPSR = 0x%08x, critical nesting = 0x%08x\n", *(pxCurrentTCB->pxTopOfStack-16), *(pxCurrentTCB->pxTopOfStack-17));
// vTaskList
/* This is a VERY costly function that should be used for debug only.
It leaves interrupts disabled for a LONG time. */
/* Run through all the lists that could potentially contain a TCB and
report the task name, state and stack high water mark. */
kprintfFromISR("\ntask name\tstatus\tprior\tstack remaining\ttask number\n");
uxQueue = uxTopUsedPriority + 1;
do {
uxQueue–;
if( !listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxQueue ] ) ) )
{
prvListTaskWithinSingleListPrintf(( xList * ) &( pxReadyTasksLists[ uxQueue ] ), tskREADY_CHAR );
}
} while( uxQueue > ( unsigned portSHORT ) tskIDLE_PRIORITY );
if( !listLIST_IS_EMPTY( pxDelayedTaskList ) )
{
prvListTaskWithinSingleListPrintf(( xList * ) pxDelayedTaskList, tskBLOCKED_CHAR );
}
if( !listLIST_IS_EMPTY( pxOverflowDelayedTaskList ) )
{
prvListTaskWithinSingleListPrintf(( xList * ) pxOverflowDelayedTaskList, tskBLOCKED_CHAR );
}
if( !listLIST_IS_EMPTY( &xTasksWaitingTermination ) )
{
prvListTaskWithinSingleListPrintf(( xList * ) &xTasksWaitingTermination, tskDELETED_CHAR );
}
if( !listLIST_IS_EMPTY( &xSuspendedTaskList ) )
{
prvListTaskWithinSingleListPrintf(( xList * ) &xSuspendedTaskList, tskSUSPENDED_CHAR );
}
}
#endif
void vTaskSwitchContext( void )
{
#if 1
// JU - debug
if ((pxCurrentTCB->pxTopOfStack - pxCurrentTCB->pxStack > pxCurrentTCB->usStackDepth) ||
(pxCurrentTCB->pxStack > pxCurrentTCB->pxTopOfStack)) {
portENTER_CRITICAL();
kprintfFromISR("\nKernel panic: stack overflow\n");
vTaskPrintCurrentFromISR();
while(1); // halt
}
#endif
if( uxSchedulerSuspended != ( unsigned portBASE_TYPE ) pdFALSE )
{
/* The scheduler is currently suspended - do not allow a context
switch. */
xMissedYield = pdTRUE;
return;
}
/* Find the highest priority queue that contains ready tasks. */
while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) )
{
--uxTopReadyPriority;
}
/* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the tasks of the
same priority get an equal share of the processor time. */
listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );
vWriteTraceToBuffer();
}
/*-----------------------------------------------------------*/
portISR.c
//---------------------------------------------------------------------------------- interrupt exceptions (JU) -------------------------------------------------------------------------
void Undef_Handler( void ) __attribute__((naked));
void PAbt_Handler( void ) __attribute__((naked));
void DAbt_Handler( void ) __attribute__((naked));
void Undef_Handler( void ) {
portENTER_CRITICAL();
kprintfFromISR("\nKernel panic: Undef handler\n");
vTaskPrintCurrentFromISR();
while(1); // halt
}
void PAbt_Handler( void ) {
portENTER_CRITICAL();
kprintfFromISR("\nKernel panic: Program Abort handler\n");
vTaskPrintCurrentFromISR();
while(1); // halt
}
void DAbt_Handler( void ) {
portENTER_CRITICAL();
kprintfFromISR("\nKernel panic: Data Abort handler\n");
vTaskPrintCurrentFromISR();
while(1); // halt
}
maybe it will be useful for you
Janusz