Add ehb instructions back into PIC32 port layer (upon advice).

Add configCLEAR_TICK_TIMER_INTERRUPT into PIC32 port layer to allow the timer configuration to be changed without any edits to the port layer being required.
Add prvTaskExitError() into the PIC32 port layer to trap tasks that attempt to exit from their implementing function.
Provide the ability to trap interrupt stack overflows in the PIC32 port.
Radically improve the timing in the Win32 simulator port layer.
This commit is contained in:
Richard Barry 2013-11-07 14:16:32 +00:00
parent 40d2e74417
commit 30bc6c01a9
5 changed files with 218 additions and 80 deletions

View file

@ -68,6 +68,12 @@
#include "task.h"
#include <stdio.h>
#ifdef __GNUC__
#include "mmsystem.h"
#else
#pragma comment(lib, "winmm.lib")
#endif
#define portMAX_INTERRUPTS ( ( unsigned long ) sizeof( unsigned long ) * 8UL ) /* The number of bits in an unsigned long. */
#define portNO_CRITICAL_NESTING ( ( unsigned long ) 0 )
@ -92,6 +98,12 @@ static void prvProcessSimulatedInterrupts( void );
static unsigned long prvProcessYieldInterrupt( void );
static unsigned long prvProcessTickInterrupt( void );
/*
* Called when the process exits to let Windows know the high timer resolution
* is no longer required.
*/
static BOOL WINAPI prvEndProcess( DWORD dwCtrlType );
/*-----------------------------------------------------------*/
/* The WIN32 simulator runs each task in a thread. The context switching is
@ -140,7 +152,23 @@ extern void *pxCurrentTCB;
static DWORD WINAPI prvSimulatedPeripheralTimer( LPVOID lpParameter )
{
portTickType xMinimumWindowsBlockTime = ( portTickType ) 20;
portTickType xMinimumWindowsBlockTime;
TIMECAPS xTimeCaps;
/* Set the timer resolution to the maximum possible. */
if( timeGetDevCaps( &xTimeCaps, sizeof( xTimeCaps ) ) == MMSYSERR_NOERROR )
{
xMinimumWindowsBlockTime = ( portTickType ) xTimeCaps.wPeriodMin;
timeBeginPeriod( xTimeCaps.wPeriodMin );
/* Register an exit handler so the timeBeginPeriod() function can be
matched with a timeEndPeriod() when the application exits. */
SetConsoleCtrlHandler( prvEndProcess, TRUE );
}
else
{
xMinimumWindowsBlockTime = ( portTickType ) 20;
}
/* Just to prevent compiler warnings. */
( void ) lpParameter;
@ -184,6 +212,23 @@ portTickType xMinimumWindowsBlockTime = ( portTickType ) 20;
}
/*-----------------------------------------------------------*/
static BOOL WINAPI prvEndProcess( DWORD dwCtrlType )
{
TIMECAPS xTimeCaps;
( void ) dwCtrlType;
if( timeGetDevCaps( &xTimeCaps, sizeof( xTimeCaps ) ) == MMSYSERR_NOERROR )
{
/* Match the call to timeBeginPeriod( xTimeCaps.wPeriodMin ) made when
the process started with a timeEndPeriod() as the process exits. */
timeEndPeriod( xTimeCaps.wPeriodMin );
}
return pdPASS;
}
/*-----------------------------------------------------------*/
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
{
xThreadState *pxThreadState = NULL;