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

@ -72,21 +72,20 @@
/******************************************************************/ /******************************************************************/
.macro portSAVE_CONTEXT .macro portSAVE_CONTEXT
/* Make room for the context. First save the current status so we can /* Make room for the context. First save the current status so it can be
manipulate it, and the cause and EPC registers so we capture their manipulated, and the cause and EPC registers so their original values are
original values in case of interrupt nesting. */ captured. */
mfc0 k0, _CP0_CAUSE mfc0 k0, _CP0_CAUSE
addiu sp, sp, -portCONTEXT_SIZE addiu sp, sp, -portCONTEXT_SIZE
mfc0 k1, _CP0_STATUS mfc0 k1, _CP0_STATUS
/* Also save s6 and s5 so we can use them during this interrupt. Any /* Also save s6 and s5 so they can be used. Any nesting interrupts should
nesting interrupts should maintain the values of these registers maintain the values of these registers across the ISR. */
across the ISR. */
sw s6, 44(sp) sw s6, 44(sp)
sw s5, 40(sp) sw s5, 40(sp)
sw k1, portSTATUS_STACK_LOCATION(sp) sw k1, portSTATUS_STACK_LOCATION(sp)
/* Enable interrupts above the current priority. */ /* Prepare to enable interrupts above the current priority. */
srl k0, k0, 0xa srl k0, k0, 0xa
ins k1, k0, 10, 6 ins k1, k0, 10, 6
ins k1, zero, 1, 4 ins k1, zero, 1, 4
@ -100,7 +99,7 @@
/* If the nesting count is 0 then swap to the the system stack, otherwise /* If the nesting count is 0 then swap to the the system stack, otherwise
the system stack is already being used. */ the system stack is already being used. */
bne s6, zero, .+20 bne s6, zero, 1f
nop nop
/* Swap to the system stack. */ /* Swap to the system stack. */
@ -108,7 +107,7 @@
lw sp, (sp) lw sp, (sp)
/* Increment and save the nesting count. */ /* Increment and save the nesting count. */
addiu s6, s6, 1 1: addiu s6, s6, 1
sw s6, 0(k0) sw s6, 0(k0)
/* s6 holds the EPC value, this is saved after interrupts are re-enabled. */ /* s6 holds the EPC value, this is saved after interrupts are re-enabled. */
@ -151,13 +150,13 @@
la s6, uxInterruptNesting la s6, uxInterruptNesting
lw s6, (s6) lw s6, (s6)
addiu s6, s6, -1 addiu s6, s6, -1
bne s6, zero, .+20 bne s6, zero, 1f
nop nop
/* Save the stack pointer. */ /* Save the stack pointer. */
la s6, uxSavedTaskStackPointer la s6, uxSavedTaskStackPointer
sw s5, (s6) sw s5, (s6)
1:
.endm .endm
/******************************************************************/ /******************************************************************/
@ -168,13 +167,13 @@
la s6, uxInterruptNesting la s6, uxInterruptNesting
lw s6, (s6) lw s6, (s6)
addiu s6, s6, -1 addiu s6, s6, -1
bne s6, zero, .+20 bne s6, zero, 1f
nop nop
la s6, uxSavedTaskStackPointer la s6, uxSavedTaskStackPointer
lw s5, (s6) lw s5, (s6)
/* Restore the context. */ /* Restore the context. */
lw s6, 8(s5) 1: lw s6, 8(s5)
mtlo s6 mtlo s6
lw s6, 12(s5) lw s6, 12(s5)
mthi s6 mthi s6
@ -203,6 +202,7 @@
/* Protect access to the k registers, and others. */ /* Protect access to the k registers, and others. */
di di
ehb
/* Decrement the nesting count. */ /* Decrement the nesting count. */
la k0, uxInterruptNesting la k0, uxInterruptNesting
@ -213,14 +213,15 @@
lw k0, portSTATUS_STACK_LOCATION(s5) lw k0, portSTATUS_STACK_LOCATION(s5)
lw k1, portEPC_STACK_LOCATION(s5) lw k1, portEPC_STACK_LOCATION(s5)
/* Leave the stack how we found it. First load sp from s5, then restore /* Leave the stack in its original state. First load sp from s5, then
s5 from the stack. */ restore s5 from the stack. */
add sp, zero, s5 add sp, zero, s5
lw s5, 40(sp) lw s5, 40(sp)
addiu sp, sp, portCONTEXT_SIZE addiu sp, sp, portCONTEXT_SIZE
mtc0 k0, _CP0_STATUS mtc0 k0, _CP0_STATUS
mtc0 k1, _CP0_EPC mtc0 k1, _CP0_EPC
ehb
eret eret
nop nop

View file

@ -91,23 +91,67 @@
the first task is being restored. */ the first task is being restored. */
#define portINITIAL_SR ( portIE_BIT | portEXL_BIT ) #define portINITIAL_SR ( portIE_BIT | portEXL_BIT )
/*
By default port.c generates its tick interrupt from TIMER1. The user can
override this behaviour by:
1: Providing their own implementation of vApplicationSetupTickTimerInterrupt(),
which is the function that configures the timer. The function is defined
as a weak symbol in this file so if the same function name is used in the
application code then the version in the application code will be linked
into the application in preference to the version defined in this file.
2: Define configTICK_INTERRUPT_VECTOR to the vector number of the timer used
to generate the tick interrupt. For example, when timer 1 is used then
configTICK_INTERRUPT_VECTOR is set to _TIMER_1_VECTOR.
configTICK_INTERRUPT_VECTOR should be defined in FreeRTOSConfig.h.
3: Define configCLEAR_TICK_TIMER_INTERRUPT() to clear the interrupt in the
timer used to generate the tick interrupt. For example, when timer 1 is
used configCLEAR_TICK_TIMER_INTERRUPT() is defined to
IFS0CLR = _IFS0_T1IF_MASK.
*/
#ifndef configTICK_INTERRUPT_VECTOR #ifndef configTICK_INTERRUPT_VECTOR
#define configTICK_INTERRUPT_VECTOR _TIMER_1_VECTOR #define configTICK_INTERRUPT_VECTOR _TIMER_1_VECTOR
#define configCLEAR_TICK_TIMER_INTERRUPT() IFS0CLR = _IFS0_T1IF_MASK
#else
#ifndef configCLEAR_TICK_TIMER_INTERRUPT
#error If configTICK_INTERRUPT_VECTOR is defined in application code then configCLEAR_TICK_TIMER_INTERRUPT must also be defined in application code.
#endif
#endif #endif
/* Records the interrupt nesting depth. This starts at one as it will be /* Let the user override the pre-loading of the initial RA with the address of
decremented to 0 when the first task starts. */ prvTaskExitError() in case is messes up unwinding of the stack in the
volatile unsigned portBASE_TYPE uxInterruptNesting = 0x01; debugger - in which case configTASK_RETURN_ADDRESS can be defined as 0 (NULL). */
#ifdef configTASK_RETURN_ADDRESS
#define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS
#else
#define portTASK_RETURN_ADDRESS prvTaskExitError
#endif
/* Stores the task stack pointer when a switch is made to use the system stack. */ /* Set configCHECK_FOR_STACK_OVERFLOW to 3 to add ISR stack checking to task
unsigned portBASE_TYPE uxSavedTaskStackPointer = 0; stack checking. A problem in the ISR stack will trigger an assert, not call the
stack overflow hook function (because the stack overflow hook is specific to a
task stack, not the ISR stack). */
#if( configCHECK_FOR_STACK_OVERFLOW > 2 )
/* The stack used by interrupt service routines that cause a context switch. */ /* Don't use 0xa5 as the stack fill bytes as that is used by the kernerl for
portSTACK_TYPE xISRStack[ configISR_STACK_SIZE ] = { 0 }; the task stacks, and so will legitimately appear in many positions within
the ISR stack. */
#define portISR_STACK_FILL_BYTE 0xee
static const unsigned char ucExpectedStackBytes[] = {
portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, \
portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, \
portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, \
portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, \
portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE, portISR_STACK_FILL_BYTE }; \
#define portCHECK_ISR_STACK() configASSERT( ( memcmp( ( void * ) xISRStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) == 0 ) )
#else
/* Define the function away. */
#define portCHECK_ISR_STACK()
#endif /* configCHECK_FOR_STACK_OVERFLOW > 2 */
/*-----------------------------------------------------------*/
/* The top of stack value ensures there is enough space to store 6 registers on
the callers stack, as some functions seem to want to do this. */
const portSTACK_TYPE * const xISRStackTop = &( xISRStack[ configISR_STACK_SIZE - 7 ] );
/* /*
* Place the prototype here to ensure the interrupt vector is correctly installed. * Place the prototype here to ensure the interrupt vector is correctly installed.
@ -125,6 +169,27 @@ extern void __attribute__( (interrupt(ipl1), vector( configTICK_INTERRUPT_VECTOR
*/ */
void __attribute__( (interrupt(ipl1), vector(_CORE_SOFTWARE_0_VECTOR))) vPortYieldISR( void ); void __attribute__( (interrupt(ipl1), vector(_CORE_SOFTWARE_0_VECTOR))) vPortYieldISR( void );
/*
* Used to catch tasks that attempt to return from their implementing function.
*/
static void prvTaskExitError( void );
/*-----------------------------------------------------------*/
/* Records the interrupt nesting depth. This is initialised to one as it is
decremented to 0 when the first task starts. */
volatile unsigned portBASE_TYPE uxInterruptNesting = 0x01;
/* Stores the task stack pointer when a switch is made to use the system stack. */
unsigned portBASE_TYPE uxSavedTaskStackPointer = 0;
/* The stack used by interrupt service routines that cause a context switch. */
portSTACK_TYPE xISRStack[ configISR_STACK_SIZE ] = { 0 };
/* The top of stack value ensures there is enough space to store 6 registers on
the callers stack, as some functions seem to want to do this. */
const portSTACK_TYPE * const xISRStackTop = &( xISRStack[ configISR_STACK_SIZE - 7 ] );
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* /*
@ -144,25 +209,36 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
*pxTopOfStack = (portSTACK_TYPE) _CP0_GET_CAUSE(); *pxTopOfStack = (portSTACK_TYPE) _CP0_GET_CAUSE();
pxTopOfStack--; pxTopOfStack--;
*pxTopOfStack = (portSTACK_TYPE) portINITIAL_SR; /* CP0_STATUS */ *pxTopOfStack = (portSTACK_TYPE) portINITIAL_SR;/* CP0_STATUS */
pxTopOfStack--; pxTopOfStack--;
*pxTopOfStack = (portSTACK_TYPE) pxCode; /* CP0_EPC */ *pxTopOfStack = (portSTACK_TYPE) pxCode; /* CP0_EPC */
pxTopOfStack--; pxTopOfStack--;
*pxTopOfStack = (portSTACK_TYPE) NULL; /* ra */ *pxTopOfStack = (portSTACK_TYPE) portTASK_RETURN_ADDRESS; /* ra */
pxTopOfStack -= 15; pxTopOfStack -= 15;
*pxTopOfStack = (portSTACK_TYPE) pvParameters; /* Parameters to pass in */ *pxTopOfStack = (portSTACK_TYPE) pvParameters; /* Parameters to pass in. */
pxTopOfStack -= 14; pxTopOfStack -= 15;
*pxTopOfStack = (portSTACK_TYPE) 0x00000000; /* critical nesting level - no longer used. */
pxTopOfStack--;
return pxTopOfStack; return pxTopOfStack;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static void prvTaskExitError( void )
{
/* A function that implements a task must not exit or attempt to return to
its caller as there is nothing to return to. If a task wants to exit it
should instead call vTaskDelete( NULL ).
Artificially force an assert() to be triggered if configASSERT() is
defined, then stop here so application writers can catch the error. */
configASSERT( uxSavedTaskStackPointer == 0UL );
portDISABLE_INTERRUPTS();
for( ;; );
}
/*-----------------------------------------------------------*/
/* /*
* Setup a timer for a regular tick. This function uses peripheral timer 1. * Setup a timer for a regular tick. This function uses peripheral timer 1.
* The function is declared weak so an application writer can use a different * The function is declared weak so an application writer can use a different
@ -206,6 +282,13 @@ portBASE_TYPE xPortStartScheduler( void )
extern void vPortStartFirstTask( void ); extern void vPortStartFirstTask( void );
extern void *pxCurrentTCB; extern void *pxCurrentTCB;
#if ( configCHECK_FOR_STACK_OVERFLOW > 2 )
{
/* Fill the ISR stack to make it easy to asses how much is being used. */
memset( ( void * ) xISRStack, portISR_STACK_FILL_BYTE, sizeof( xISRStack ) );
}
#endif /* configCHECK_FOR_STACK_OVERFLOW > 2 */
/* Clear the software interrupt flag. */ /* Clear the software interrupt flag. */
IFS0CLR = _IFS0_CS0IF_MASK; IFS0CLR = _IFS0_CS0IF_MASK;
@ -226,7 +309,12 @@ extern void *pxCurrentTCB;
uxSavedTaskStackPointer = *( unsigned portBASE_TYPE * ) pxCurrentTCB; uxSavedTaskStackPointer = *( unsigned portBASE_TYPE * ) pxCurrentTCB;
vPortStartFirstTask(); vPortStartFirstTask();
/* Should never get here as the tasks will now be executing. */ /* Should never get here as the tasks will now be executing! Call the task
exit error function to prevent compiler warnings about a static function
not being called in the case that the application writer overrides this
functionality by defining configTASK_RETURN_ADDRESS. */
prvTaskExitError();
return pdFALSE; return pdFALSE;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -245,8 +333,11 @@ unsigned portBASE_TYPE uxSavedStatus;
} }
vPortClearInterruptMaskFromISR( uxSavedStatus ); vPortClearInterruptMaskFromISR( uxSavedStatus );
/* Clear timer 1 interrupt. */ /* Look for the ISR stack getting near or past its limit. */
IFS0CLR = _IFS0_T1IF_MASK; portCHECK_ISR_STACK();
/* Clear timer interrupt. */
configCLEAR_TICK_TIMER_INTERRUPT();
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -254,7 +345,7 @@ unsigned portBASE_TYPE uxPortSetInterruptMaskFromISR( void )
{ {
unsigned portBASE_TYPE uxSavedStatusRegister; unsigned portBASE_TYPE uxSavedStatusRegister;
asm volatile ( "di" ); __builtin_disable_interrupts();
uxSavedStatusRegister = _CP0_GET_STATUS() | 0x01; uxSavedStatusRegister = _CP0_GET_STATUS() | 0x01;
/* This clears the IPL bits, then sets them to /* This clears the IPL bits, then sets them to
configMAX_SYSCALL_INTERRUPT_PRIORITY. This function should not be called configMAX_SYSCALL_INTERRUPT_PRIORITY. This function should not be called

View file

@ -125,20 +125,18 @@ vPortYieldISR:
/* Make room for the context. First save the current status so it can be /* Make room for the context. First save the current status so it can be
manipulated, and the cause and EPC registers so thier original values are manipulated, and the cause and EPC registers so thier original values are
captured. */ captured. */
mfc0 k0, _CP0_CAUSE
addiu sp, sp, -portCONTEXT_SIZE addiu sp, sp, -portCONTEXT_SIZE
mfc0 k1, _CP0_STATUS mfc0 k1, _CP0_STATUS
/* Also save s6 and s5 so we can use them during this interrupt. Any /* Also save s6 and s5 so they can be used. Any nesting interrupts should
nesting interrupts should maintain the values of these registers maintain the values of these registers across the ISR. */
across the ISR. */
sw s6, 44(sp) sw s6, 44(sp)
sw s5, 40(sp) sw s5, 40(sp)
sw k1, portSTATUS_STACK_LOCATION(sp) sw k1, portSTATUS_STACK_LOCATION(sp)
/* Interrupts above the kernel priority are going to be re-enabled. */ /* Prepare to re-enabled interrupt above the kernel priority. */
srl k0, k0, 0xa ins k1, zero, 10, 6
ins k1, k0, 10, 6 ori k1, k1, ( configMAX_SYSCALL_INTERRUPT_PRIORITY << 10 )
ins k1, zero, 1, 4 ins k1, zero, 1, 4
/* s5 is used as the frame pointer. */ /* s5 is used as the frame pointer. */
@ -159,7 +157,7 @@ vPortYieldISR:
after interrupts are enabled. */ after interrupts are enabled. */
mfc0 s6, _CP0_EPC mfc0 s6, _CP0_EPC
/* Re-enable interrupts. */ /* Re-enable interrupts above configMAX_SYSCALL_INTERRUPT_PRIORITY. */
mtc0 k1, _CP0_STATUS mtc0 k1, _CP0_STATUS
/* Save the context into the space just created. s6 is saved again /* Save the context into the space just created. s6 is saved again
@ -209,18 +207,21 @@ vPortYieldISR:
is below configMAX_SYSCALL_INTERRUPT_PRIORITY - so this can only ever is below configMAX_SYSCALL_INTERRUPT_PRIORITY - so this can only ever
raise the IPL value and never lower it. */ raise the IPL value and never lower it. */
di di
ehb
mfc0 s7, _CP0_STATUS mfc0 s7, _CP0_STATUS
ins s7, $0, 10, 6 ins s7, zero, 10, 6
ori s6, s7, ( configMAX_SYSCALL_INTERRUPT_PRIORITY << 10 ) | 1 ori s6, s7, ( configMAX_SYSCALL_INTERRUPT_PRIORITY << 10 ) | 1
/* This mtc0 re-enables interrupts, but only above /* This mtc0 re-enables interrupts, but only above
configMAX_SYSCALL_INTERRUPT_PRIORITY. */ configMAX_SYSCALL_INTERRUPT_PRIORITY. */
mtc0 s6, _CP0_STATUS mtc0 s6, _CP0_STATUS
ehb
/* Clear the software interrupt in the core. */ /* Clear the software interrupt in the core. */
mfc0 s6, _CP0_CAUSE mfc0 s6, _CP0_CAUSE
ins s6, zero, 8, 1 ins s6, zero, 8, 1
mtc0 s6, _CP0_CAUSE mtc0 s6, _CP0_CAUSE
ehb
/* Clear the interrupt in the interrupt controller. */ /* Clear the interrupt in the interrupt controller. */
la s6, IFS0CLR la s6, IFS0CLR
@ -232,6 +233,7 @@ vPortYieldISR:
/* Clear the interrupt mask again. The saved status value is still in s7. */ /* Clear the interrupt mask again. The saved status value is still in s7. */
mtc0 s7, _CP0_STATUS mtc0 s7, _CP0_STATUS
ehb
/* Restore the stack pointer from the TCB. */ /* Restore the stack pointer from the TCB. */
la s0, pxCurrentTCB la s0, pxCurrentTCB
@ -273,6 +275,7 @@ vPortYieldISR:
/* Protect access to the k registers, and others. */ /* Protect access to the k registers, and others. */
di di
ehb
/* Set nesting back to zero. As the lowest priority interrupt this /* Set nesting back to zero. As the lowest priority interrupt this
interrupt cannot have nested. */ interrupt cannot have nested. */
@ -294,6 +297,7 @@ vPortYieldISR:
mtc0 k1, _CP0_STATUS mtc0 k1, _CP0_STATUS
mtc0 k0, _CP0_EPC mtc0 k0, _CP0_EPC
ehb
eret eret
nop nop

View file

@ -200,13 +200,10 @@ unsigned long ulCause; \
_CP0_SET_CAUSE( ulCause ); \ _CP0_SET_CAUSE( ulCause ); \
} }
#ifdef configASSERT #define portCURRENT_INTERRUPT_PRIORITY ( ( _CP0_GET_STATUS() & portALL_IPL_BITS ) >> portIPL_SHIFT )
#define portCURRENT_INTERRUPT_PRIORITY ( ( _CP0_GET_STATUS() & portALL_IPL_BITS ) >> portIPL_SHIFT ) #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() configASSERT( portCURRENT_INTERRUPT_PRIORITY <= configMAX_SYSCALL_INTERRUPT_PRIORITY )
#define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() configASSERT( portCURRENT_INTERRUPT_PRIORITY <= configMAX_SYSCALL_INTERRUPT_PRIORITY )
#endif /* configASSERT */
#define portNOP() __asm volatile ( "nop" )
#define portNOP() asm volatile ( "nop" )
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/

View file

@ -68,6 +68,12 @@
#include "task.h" #include "task.h"
#include <stdio.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 portMAX_INTERRUPTS ( ( unsigned long ) sizeof( unsigned long ) * 8UL ) /* The number of bits in an unsigned long. */
#define portNO_CRITICAL_NESTING ( ( unsigned long ) 0 ) #define portNO_CRITICAL_NESTING ( ( unsigned long ) 0 )
@ -92,6 +98,12 @@ static void prvProcessSimulatedInterrupts( void );
static unsigned long prvProcessYieldInterrupt( void ); static unsigned long prvProcessYieldInterrupt( void );
static unsigned long prvProcessTickInterrupt( 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 /* 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 ) 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. */ /* Just to prevent compiler warnings. */
( void ) lpParameter; ( 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 ) portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
{ {
xThreadState *pxThreadState = NULL; xThreadState *pxThreadState = NULL;