diff --git a/portable/BCC/16BitDOS/Flsh186/port.c b/portable/BCC/16BitDOS/Flsh186/port.c index 6697de2f9f2..66b8b7b7b2b 100644 --- a/portable/BCC/16BitDOS/Flsh186/port.c +++ b/portable/BCC/16BitDOS/Flsh186/port.c @@ -27,22 +27,22 @@ */ /* - * Changes from V1.00: - * - + Call to taskYIELD() from within tick ISR has been replaced by the more - + efficient portSWITCH_CONTEXT(). - + ISR function definitions renamed to include the prv prefix. - + - + Changes from V2.6.1 - + - + Replaced the sUsingPreemption variable with the configUSE_PREEMPTION - + macro to be consistent with the later ports. - */ +Changes from V1.00: + + + Call to taskYIELD() from within tick ISR has been replaced by the more + efficient portSWITCH_CONTEXT(). + + ISR function definitions renamed to include the prv prefix. + +Changes from V2.6.1 + + + Replaced the sUsingPreemption variable with the configUSE_PREEMPTION + macro to be consistent with the later ports. +*/ /*----------------------------------------------------------- -* Implementation of functions defined in portable.h for the Flashlite 186 -* port. -*----------------------------------------------------------*/ + * Implementation of functions defined in portable.h for the Flashlite 186 + * port. + *----------------------------------------------------------*/ #include #include @@ -54,9 +54,9 @@ /*lint -e950 Non ANSI reserved words okay in this file only. */ -#define portTIMER_EOI_TYPE ( 8 ) -#define portRESET_PIC() portOUTPUT_WORD( ( uint16_t ) 0xff22, portTIMER_EOI_TYPE ) -#define portTIMER_INT_NUMBER 0x12 +#define portTIMER_EOI_TYPE ( 8 ) +#define portRESET_PIC() portOUTPUT_WORD( ( uint16_t ) 0xff22, portTIMER_EOI_TYPE ) +#define portTIMER_INT_NUMBER 0x12 #define portTIMER_1_CONTROL_REGISTER ( ( uint16_t ) 0xff5e ) #define portTIMER_0_CONTROL_REGISTER ( ( uint16_t ) 0xff56 ) @@ -69,16 +69,14 @@ static void prvSetTickFrequency( uint32_t ulTickRateHz ); static void prvExitFunction( void ); /* The ISR used depends on whether the preemptive or cooperative scheduler - * is being used. */ -#if ( configUSE_PREEMPTION == 1 ) - -/* Tick service routine used by the scheduler when preemptive scheduling is - * being used. */ +is being used. */ +#if( configUSE_PREEMPTION == 1 ) + /* Tick service routine used by the scheduler when preemptive scheduling is + being used. */ static void __interrupt __far prvPreemptiveTick( void ); #else - -/* Tick service routine used by the scheduler when cooperative scheduling is - * being used. */ + /* Tick service routine used by the scheduler when cooperative scheduling is + being used. */ static void __interrupt __far prvNonPreemptiveTick( void ); #endif @@ -91,9 +89,9 @@ static void __interrupt __far prvYieldProcessor( void ); static BaseType_t xSchedulerRunning = pdFALSE; /* Points to the original routine installed on the vector we use for manual - * context switches. This is then used to restore the original routine during - * prvExitFunction(). */ -static void( __interrupt __far * pxOldSwitchISR )(); +context switches. This is then used to restore the original routine during +prvExitFunction(). */ +static void ( __interrupt __far *pxOldSwitchISR )(); /* Used to restore the original DOS context when the scheduler is ended. */ static jmp_buf xJumpBuf; @@ -106,14 +104,14 @@ BaseType_t xPortStartScheduler( void ) /* This is called with interrupts already disabled. */ /* Remember what was on the interrupts we are going to use - * so we can put them back later if required. */ + so we can put them back later if required. */ pxOldSwitchISR = _dos_getvect( portSWITCH_INT_NUMBER ); /* Put our manual switch (yield) function on a known - * vector. */ + vector. */ _dos_setvect( portSWITCH_INT_NUMBER, prvYieldProcessor ); - #if ( configUSE_PREEMPTION == 1 ) + #if( configUSE_PREEMPTION == 1 ) { /* Put our tick switch function on the timer interrupt. */ _dos_setvect( portTIMER_INT_NUMBER, prvPreemptiveTick ); @@ -146,8 +144,8 @@ BaseType_t xPortStartScheduler( void ) /*-----------------------------------------------------------*/ /* The ISR used depends on whether the preemptive or cooperative scheduler - * is being used. */ -#if ( configUSE_PREEMPTION == 1 ) +is being used. */ +#if( configUSE_PREEMPTION == 1 ) static void __interrupt __far prvPreemptiveTick( void ) { /* Get the scheduler to update the task states following the tick. */ @@ -160,15 +158,15 @@ BaseType_t xPortStartScheduler( void ) /* Reset the PIC ready for the next time. */ portRESET_PIC(); } -#else /* if ( configUSE_PREEMPTION == 1 ) */ +#else static void __interrupt __far prvNonPreemptiveTick( void ) { /* Same as preemptive tick, but the cooperative scheduler is being used - * so we don't have to switch in the context of the next task. */ + so we don't have to switch in the context of the next task. */ xTaskIncrementTick(); portRESET_PIC(); } -#endif /* if ( configUSE_PREEMPTION == 1 ) */ +#endif /*-----------------------------------------------------------*/ static void __interrupt __far prvYieldProcessor( void ) @@ -181,31 +179,30 @@ static void __interrupt __far prvYieldProcessor( void ) void vPortEndScheduler( void ) { /* Jump back to the processor state prior to starting the - * scheduler. This means we are not going to be using a - * task stack frame so the task can be deleted. */ + scheduler. This means we are not going to be using a + task stack frame so the task can be deleted. */ longjmp( xJumpBuf, 1 ); } /*-----------------------------------------------------------*/ static void prvExitFunction( void ) { - const uint16_t usTimerDisable = 0x0000; - uint16_t usTimer0Control; +const uint16_t usTimerDisable = 0x0000; +uint16_t usTimer0Control; /* Interrupts should be disabled here anyway - but no - * harm in making sure. */ + harm in making sure. */ portDISABLE_INTERRUPTS(); - if( xSchedulerRunning == pdTRUE ) { /* Put back the switch interrupt routines that was in place - * before the scheduler started. */ + before the scheduler started. */ _dos_setvect( portSWITCH_INT_NUMBER, pxOldSwitchISR ); } /* Disable the timer used for the tick to ensure the scheduler is - * not called before restoring interrupts. There was previously nothing - * on this timer so there is no old ISR to restore. */ + not called before restoring interrupts. There was previously nothing + on this timer so there is no old ISR to restore. */ portOUTPUT_WORD( portTIMER_1_CONTROL_REGISTER, usTimerDisable ); /* Restart the DOS tick. */ @@ -220,18 +217,18 @@ static void prvExitFunction( void ) static void prvSetTickFrequency( uint32_t ulTickRateHz ) { - const uint16_t usMaxCountRegister = 0xff5a; - const uint16_t usTimerPriorityRegister = 0xff32; - const uint16_t usTimerEnable = 0xC000; - const uint16_t usRetrigger = 0x0001; - const uint16_t usTimerHighPriority = 0x0000; - uint16_t usTimer0Control; +const uint16_t usMaxCountRegister = 0xff5a; +const uint16_t usTimerPriorityRegister = 0xff32; +const uint16_t usTimerEnable = 0xC000; +const uint16_t usRetrigger = 0x0001; +const uint16_t usTimerHighPriority = 0x0000; +uint16_t usTimer0Control; /* ( CPU frequency / 4 ) / clock 2 max count [inpw( 0xff62 ) = 7] */ - const uint32_t ulClockFrequency = ( uint32_t ) 0x7f31a0UL; +const uint32_t ulClockFrequency = ( uint32_t ) 0x7f31a0UL; - uint32_t ulTimerCount = ulClockFrequency / ulTickRateHz; +uint32_t ulTimerCount = ulClockFrequency / ulTickRateHz; portOUTPUT_WORD( portTIMER_1_CONTROL_REGISTER, usTimerEnable | portTIMER_INTERRUPT_ENABLE | usRetrigger ); portOUTPUT_WORD( usMaxCountRegister, ( uint16_t ) ulTimerCount ); diff --git a/portable/BCC/16BitDOS/Flsh186/prtmacro.h b/portable/BCC/16BitDOS/Flsh186/prtmacro.h index 2fd9f91b2fa..295c0bc736e 100644 --- a/portable/BCC/16BitDOS/Flsh186/prtmacro.h +++ b/portable/BCC/16BitDOS/Flsh186/prtmacro.h @@ -40,61 +40,60 @@ */ /* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE long -#define portLONG long -#define portSHORT int -#define portSTACK_TYPE uint16_t -#define portBASE_TYPE portSHORT +#define portCHAR char +#define portFLOAT float +#define portDOUBLE long +#define portLONG long +#define portSHORT int +#define portSTACK_TYPE uint16_t +#define portBASE_TYPE portSHORT -typedef portSTACK_TYPE StackType_t; -typedef short BaseType_t; -typedef unsigned short UBaseType_t; +typedef portSTACK_TYPE StackType_t; +typedef short BaseType_t; +typedef unsigned short UBaseType_t; -#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) - typedef uint16_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffff +#if( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff #elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) - typedef uint32_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL #else #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width. #endif /*-----------------------------------------------------------*/ /* Critical section handling. */ -#define portENTER_CRITICAL() \ - __asm { pushf } \ - __asm { cli } \ +#define portENTER_CRITICAL() __asm{ pushf } \ + __asm{ cli } \ -#define portEXIT_CRITICAL() __asm { popf } +#define portEXIT_CRITICAL() __asm{ popf } -#define portDISABLE_INTERRUPTS() __asm { cli } +#define portDISABLE_INTERRUPTS() __asm{ cli } -#define portENABLE_INTERRUPTS() __asm { sti } +#define portENABLE_INTERRUPTS() __asm{ sti } /*-----------------------------------------------------------*/ /* Hardware specifics. */ -#define portNOP() __asm { nop } -#define portSTACK_GROWTH ( -1 ) -#define portSWITCH_INT_NUMBER 0x80 -#define portYIELD() __asm { int portSWITCH_INT_NUMBER } -#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) -#define portBYTE_ALIGNMENT 2 -#define portINITIAL_SW ( ( portSTACK_TYPE ) 0x0202 ) /* Start the tasks with interrupts enabled. */ +#define portNOP() __asm{ nop } +#define portSTACK_GROWTH ( -1 ) +#define portSWITCH_INT_NUMBER 0x80 +#define portYIELD() __asm{ int portSWITCH_INT_NUMBER } +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 2 +#define portINITIAL_SW ( ( portSTACK_TYPE ) 0x0202 ) /* Start the tasks with interrupts enabled. */ /*-----------------------------------------------------------*/ /* Compiler specifics. */ -#define portINPUT_BYTE( xAddr ) inp( xAddr ) -#define portOUTPUT_BYTE( xAddr, ucValue ) outp( xAddr, ucValue ) -#define portINPUT_WORD( xAddr ) inpw( xAddr ) -#define portOUTPUT_WORD( xAddr, usValue ) outpw( xAddr, usValue ) +#define portINPUT_BYTE( xAddr ) inp( xAddr ) +#define portOUTPUT_BYTE( xAddr, ucValue ) outp( xAddr, ucValue ) +#define portINPUT_WORD( xAddr ) inpw( xAddr ) +#define portOUTPUT_WORD( xAddr, usValue ) outpw( xAddr, usValue ) /*-----------------------------------------------------------*/ /* Task function macros as described on the FreeRTOS.org WEB site. */ -#define portTASK_FUNCTION_PROTO( vTaskFunction, vParameters ) void vTaskFunction( void * pvParameters ) -#define portTASK_FUNCTION( vTaskFunction, vParameters ) void vTaskFunction( void * pvParameters ) +#define portTASK_FUNCTION_PROTO( vTaskFunction, vParameters ) void vTaskFunction( void *pvParameters ) +#define portTASK_FUNCTION( vTaskFunction, vParameters ) void vTaskFunction( void *pvParameters ) #endif /* PORTMACRO_H */ diff --git a/portable/BCC/16BitDOS/PC/port.c b/portable/BCC/16BitDOS/PC/port.c index e8a14a881aa..6940b1a67e7 100644 --- a/portable/BCC/16BitDOS/PC/port.c +++ b/portable/BCC/16BitDOS/PC/port.c @@ -27,16 +27,16 @@ */ /* - * Changes from V2.6.1 - * - + Replaced the sUsingPreemption variable with the configUSE_PREEMPTION - + macro to be consistent with the later ports. - + - + Changes from V4.0.1 - + - + Add function prvSetTickFrequencyDefault() to set the DOS tick back to - + its proper value when the scheduler exits. - */ +Changes from V2.6.1 + + + Replaced the sUsingPreemption variable with the configUSE_PREEMPTION + macro to be consistent with the later ports. + +Changes from V4.0.1 + + + Add function prvSetTickFrequencyDefault() to set the DOS tick back to + its proper value when the scheduler exits. +*/ #include #include @@ -47,9 +47,9 @@ #include "portasm.h" /*----------------------------------------------------------- -* Implementation of functions defined in portable.h for the industrial -* PC port. -*----------------------------------------------------------*/ + * Implementation of functions defined in portable.h for the industrial + * PC port. + *----------------------------------------------------------*/ /*lint -e950 Non ANSI reserved words okay in this file only. */ @@ -62,21 +62,19 @@ static void prvSetTickFrequency( uint32_t ulTickRateHz ); static void prvExitFunction( void ); /* Either chain to the DOS tick (which itself clears the PIC) or clear the PIC - * directly. We chain to the DOS tick as close as possible to the standard DOS - * tick rate. */ +directly. We chain to the DOS tick as close as possible to the standard DOS +tick rate. */ static void prvPortResetPIC( void ); /* The ISR used depends on whether the preemptive or cooperative - * scheduler is being used. */ -#if ( configUSE_PREEMPTION == 1 ) - -/* Tick service routine used by the scheduler when preemptive scheduling is - * being used. */ +scheduler is being used. */ +#if( configUSE_PREEMPTION == 1 ) + /* Tick service routine used by the scheduler when preemptive scheduling is + being used. */ static void __interrupt __far prvPreemptiveTick( void ); #else - -/* Tick service routine used by the scheduler when cooperative scheduling is - * being used. */ + /* Tick service routine used by the scheduler when cooperative scheduling is + being used. */ static void __interrupt __far prvNonPreemptiveTick( void ); #endif @@ -84,7 +82,7 @@ static void prvPortResetPIC( void ); static void __interrupt __far prvYieldProcessor( void ); /* Set the tick frequency back so the floppy drive works correctly when the - * scheduler exits. */ +scheduler exits. */ static void prvSetTickFrequencyDefault( void ); /*lint -e956 File scopes necessary here. */ @@ -96,10 +94,10 @@ static int16_t sDOSTickCounter; static BaseType_t xSchedulerRunning = pdFALSE; /* Points to the original routine installed on the vector we use for manual context switches. This is then used to restore the original routine during prvExitFunction(). */ -static void( __interrupt __far * pxOldSwitchISR )(); +static void ( __interrupt __far *pxOldSwitchISR )(); /* Points to the original routine installed on the vector we use to chain to the DOS tick. This is then used to restore the original routine during prvExitFunction(). */ -static void( __interrupt __far * pxOldSwitchISRPlus1 )(); +static void ( __interrupt __far *pxOldSwitchISRPlus1 )(); /* Used to restore the original DOS context when the scheduler is ended. */ static jmp_buf xJumpBuf; @@ -109,12 +107,12 @@ static jmp_buf xJumpBuf; /*-----------------------------------------------------------*/ BaseType_t xPortStartScheduler( void ) { - pxISR pxOriginalTickISR; +pxISR pxOriginalTickISR; /* This is called with interrupts already disabled. */ /* Remember what was on the interrupts we are going to use - * so we can put them back later if required. */ + so we can put them back later if required. */ pxOldSwitchISR = _dos_getvect( portSWITCH_INT_NUMBER ); pxOriginalTickISR = _dos_getvect( portTIMER_INT_NUMBER ); pxOldSwitchISRPlus1 = _dos_getvect( portSWITCH_INT_NUMBER + 1 ); @@ -122,16 +120,16 @@ BaseType_t xPortStartScheduler( void ) prvSetTickFrequency( configTICK_RATE_HZ ); /* Put our manual switch (yield) function on a known - * vector. */ + vector. */ _dos_setvect( portSWITCH_INT_NUMBER, prvYieldProcessor ); /* Put the old tick on a different interrupt number so we can - * call it when we want. */ + call it when we want. */ _dos_setvect( portSWITCH_INT_NUMBER + 1, pxOriginalTickISR ); /* The ISR used depends on whether the preemptive or cooperative - * scheduler is being used. */ - #if ( configUSE_PREEMPTION == 1 ) + scheduler is being used. */ + #if( configUSE_PREEMPTION == 1 ) { /* Put our tick switch function on the timer interrupt. */ _dos_setvect( portTIMER_INT_NUMBER, prvPreemptiveTick ); @@ -144,8 +142,8 @@ BaseType_t xPortStartScheduler( void ) #endif /* Setup a counter that is used to call the DOS interrupt as close - * to it's original frequency as can be achieved given our chosen tick - * frequency. */ + to it's original frequency as can be achieved given our chosen tick + frequency. */ sDOSTickCounter = portTICKS_PER_DOS_TICK; /* Clean up function if we want to return to DOS. */ @@ -167,8 +165,8 @@ BaseType_t xPortStartScheduler( void ) /*-----------------------------------------------------------*/ /* The ISR used depends on whether the preemptive or cooperative - * scheduler is being used. */ -#if ( configUSE_PREEMPTION == 1 ) +scheduler is being used. */ +#if( configUSE_PREEMPTION == 1 ) static void __interrupt __far prvPreemptiveTick( void ) { /* Get the scheduler to update the task states following the tick. */ @@ -181,15 +179,15 @@ BaseType_t xPortStartScheduler( void ) /* Reset the PIC ready for the next time. */ prvPortResetPIC(); } -#else /* if ( configUSE_PREEMPTION == 1 ) */ +#else static void __interrupt __far prvNonPreemptiveTick( void ) { /* Same as preemptive tick, but the cooperative scheduler is being used - * so we don't have to switch in the context of the next task. */ + so we don't have to switch in the context of the next task. */ xTaskIncrementTick(); prvPortResetPIC(); } -#endif /* if ( configUSE_PREEMPTION == 1 ) */ +#endif /*-----------------------------------------------------------*/ static void __interrupt __far prvYieldProcessor( void ) @@ -202,22 +200,19 @@ static void __interrupt __far prvYieldProcessor( void ) static void prvPortResetPIC( void ) { /* We are going to call the DOS tick interrupt at as close a - * frequency to the normal DOS tick as possible. */ + frequency to the normal DOS tick as possible. */ /* WE SHOULD NOT DO THIS IF YIELD WAS CALLED. */ --sDOSTickCounter; - if( sDOSTickCounter <= 0 ) { sDOSTickCounter = ( int16_t ) portTICKS_PER_DOS_TICK; - __asm { - int portSWITCH_INT_NUMBER + 1 - }; + __asm{ int portSWITCH_INT_NUMBER + 1 }; } else { /* Reset the PIC as the DOS tick is not being called to - * do it. */ + do it. */ __asm { mov al, 20H @@ -230,20 +225,19 @@ static void prvPortResetPIC( void ) void vPortEndScheduler( void ) { /* Jump back to the processor state prior to starting the - * scheduler. This means we are not going to be using a - * task stack frame so the task can be deleted. */ + scheduler. This means we are not going to be using a + task stack frame so the task can be deleted. */ longjmp( xJumpBuf, 1 ); } /*-----------------------------------------------------------*/ static void prvExitFunction( void ) { - void( __interrupt __far * pxOriginalTickISR )(); +void ( __interrupt __far *pxOriginalTickISR )(); /* Interrupts should be disabled here anyway - but no - * harm in making sure. */ + harm in making sure. */ portDISABLE_INTERRUPTS(); - if( xSchedulerRunning == pdTRUE ) { /* Set the DOS tick back onto the timer ticker. */ @@ -252,29 +246,28 @@ static void prvExitFunction( void ) prvSetTickFrequencyDefault(); /* Put back the switch interrupt routines that was in place - * before the scheduler started. */ + before the scheduler started. */ _dos_setvect( portSWITCH_INT_NUMBER, pxOldSwitchISR ); _dos_setvect( portSWITCH_INT_NUMBER + 1, pxOldSwitchISRPlus1 ); } - /* The tick timer is back how DOS wants it. We can re-enable - * interrupts without the scheduler being called. */ + interrupts without the scheduler being called. */ portENABLE_INTERRUPTS(); } /*-----------------------------------------------------------*/ static void prvSetTickFrequency( uint32_t ulTickRateHz ) { - const uint16_t usPIT_MODE = ( uint16_t ) 0x43; - const uint16_t usPIT0 = ( uint16_t ) 0x40; - const uint32_t ulPIT_CONST = ( uint32_t ) 1193180UL; - const uint16_t us8254_CTR0_MODE3 = ( uint16_t ) 0x36; - uint32_t ulOutput; +const uint16_t usPIT_MODE = ( uint16_t ) 0x43; +const uint16_t usPIT0 = ( uint16_t ) 0x40; +const uint32_t ulPIT_CONST = ( uint32_t ) 1193180UL; +const uint16_t us8254_CTR0_MODE3 = ( uint16_t ) 0x36; +uint32_t ulOutput; /* Setup the 8245 to tick at the wanted frequency. */ portOUTPUT_BYTE( usPIT_MODE, us8254_CTR0_MODE3 ); ulOutput = ulPIT_CONST / ulTickRateHz; - portOUTPUT_BYTE( usPIT0, ( uint16_t ) ( ulOutput & ( uint32_t ) 0xff ) ); + portOUTPUT_BYTE( usPIT0, ( uint16_t )( ulOutput & ( uint32_t ) 0xff ) ); ulOutput >>= 8; portOUTPUT_BYTE( usPIT0, ( uint16_t ) ( ulOutput & ( uint32_t ) 0xff ) ); } @@ -282,13 +275,13 @@ static void prvSetTickFrequency( uint32_t ulTickRateHz ) static void prvSetTickFrequencyDefault( void ) { - const uint16_t usPIT_MODE = ( uint16_t ) 0x43; - const uint16_t usPIT0 = ( uint16_t ) 0x40; - const uint16_t us8254_CTR0_MODE3 = ( uint16_t ) 0x36; +const uint16_t usPIT_MODE = ( uint16_t ) 0x43; +const uint16_t usPIT0 = ( uint16_t ) 0x40; +const uint16_t us8254_CTR0_MODE3 = ( uint16_t ) 0x36; portOUTPUT_BYTE( usPIT_MODE, us8254_CTR0_MODE3 ); - portOUTPUT_BYTE( usPIT0, 0 ); - portOUTPUT_BYTE( usPIT0, 0 ); + portOUTPUT_BYTE( usPIT0,0 ); + portOUTPUT_BYTE( usPIT0,0 ); } diff --git a/portable/BCC/16BitDOS/PC/prtmacro.h b/portable/BCC/16BitDOS/PC/prtmacro.h index e9e7b4ad0a9..5fb4ed6a497 100644 --- a/portable/BCC/16BitDOS/PC/prtmacro.h +++ b/portable/BCC/16BitDOS/PC/prtmacro.h @@ -40,61 +40,60 @@ */ /* Type definitions. */ -#define portCHAR char -#define portFLOAT long -#define portDOUBLE long -#define portLONG long -#define portSHORT int -#define portSTACK_TYPE uint16_t -#define portBASE_TYPE portSHORT +#define portCHAR char +#define portFLOAT long +#define portDOUBLE long +#define portLONG long +#define portSHORT int +#define portSTACK_TYPE uint16_t +#define portBASE_TYPE portSHORT -typedef portSTACK_TYPE StackType_t; -typedef short BaseType_t; -typedef unsigned short UBaseType_t; +typedef portSTACK_TYPE StackType_t; +typedef short BaseType_t; +typedef unsigned short UBaseType_t; -#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) - typedef uint16_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffff +#if( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff #elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) - typedef uint32_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffffffffUL + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffffffffUL #else #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width. #endif /*-----------------------------------------------------------*/ /* Critical section management. */ -#define portENTER_CRITICAL() \ - __asm { pushf } \ - __asm { cli } \ +#define portENTER_CRITICAL() __asm{ pushf } \ + __asm{ cli } \ -#define portEXIT_CRITICAL() __asm { popf } +#define portEXIT_CRITICAL() __asm{ popf } -#define portDISABLE_INTERRUPTS() __asm { cli } +#define portDISABLE_INTERRUPTS() __asm{ cli } -#define portENABLE_INTERRUPTS() __asm { sti } +#define portENABLE_INTERRUPTS() __asm{ sti } /*-----------------------------------------------------------*/ /* Hardware specifics. */ -#define portNOP() __asm { nop } -#define portSTACK_GROWTH ( -1 ) -#define portSWITCH_INT_NUMBER 0x80 -#define portYIELD() __asm { int portSWITCH_INT_NUMBER } -#define portDOS_TICK_RATE ( 18.20648 ) -#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) -#define portTICKS_PER_DOS_TICK ( ( uint16_t ) ( ( ( portDOUBLE ) configTICK_RATE_HZ / portDOS_TICK_RATE ) + 0.5 ) ) -#define portINITIAL_SW ( ( portSTACK_TYPE ) 0x0202 ) /* Start the tasks with interrupts enabled. */ -#define portBYTE_ALIGNMENT ( 2 ) +#define portNOP() __asm{ nop } +#define portSTACK_GROWTH ( -1 ) +#define portSWITCH_INT_NUMBER 0x80 +#define portYIELD() __asm{ int portSWITCH_INT_NUMBER } +#define portDOS_TICK_RATE ( 18.20648 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portTICKS_PER_DOS_TICK ( ( uint16_t ) ( ( ( portDOUBLE ) configTICK_RATE_HZ / portDOS_TICK_RATE ) + 0.5 ) ) +#define portINITIAL_SW ( ( portSTACK_TYPE ) 0x0202 ) /* Start the tasks with interrupts enabled. */ +#define portBYTE_ALIGNMENT ( 2 ) /*-----------------------------------------------------------*/ /* Compiler specifics. */ -#define portINPUT_BYTE( xAddr ) inp( xAddr ) -#define portOUTPUT_BYTE( xAddr, ucValue ) outp( xAddr, ucValue ) +#define portINPUT_BYTE( xAddr ) inp( xAddr ) +#define portOUTPUT_BYTE( xAddr, ucValue ) outp( xAddr, ucValue ) /*-----------------------------------------------------------*/ /* Task function macros as described on the FreeRTOS.org WEB site. */ -#define portTASK_FUNCTION_PROTO( vTaskFunction, pvParameters ) void vTaskFunction( void * pvParameters ) -#define portTASK_FUNCTION( vTaskFunction, pvParameters ) void vTaskFunction( void * pvParameters ) +#define portTASK_FUNCTION_PROTO( vTaskFunction, pvParameters ) void vTaskFunction( void *pvParameters ) +#define portTASK_FUNCTION( vTaskFunction, pvParameters ) void vTaskFunction( void *pvParameters ) #endif /* PORTMACRO_H */ diff --git a/portable/BCC/16BitDOS/common/portasm.h b/portable/BCC/16BitDOS/common/portasm.h index f78147d208f..e53d257c860 100644 --- a/portable/BCC/16BitDOS/common/portasm.h +++ b/portable/BCC/16BitDOS/common/portasm.h @@ -48,40 +48,40 @@ void portSWITCH_CONTEXT( void ); void portFIRST_CONTEXT( void ); /* There are slightly different versions depending on whether you are building - * to include debugger information. If debugger information is used then there - * are a couple of extra bytes left of the ISR stack (presumably for use by the - * debugger). The true stack pointer is then stored in the bp register. We add - * 2 to the stack pointer to remove the extra bytes before we restore our context. */ +to include debugger information. If debugger information is used then there +are a couple of extra bytes left of the ISR stack (presumably for use by the +debugger). The true stack pointer is then stored in the bp register. We add +2 to the stack pointer to remove the extra bytes before we restore our context. */ -#define portSWITCH_CONTEXT() \ - asm { mov ax, seg pxCurrentTCB } \ - asm { mov ds, ax } \ - asm { les bx, pxCurrentTCB } /* Save the stack pointer into the TCB. */ \ - asm { mov es : 0x2[ bx ], ss } \ - asm { mov es:[ bx ], sp } \ - asm { call far ptr vTaskSwitchContext } /* Perform the switch. */ \ - asm { mov ax, seg pxCurrentTCB } /* Restore the stack pointer from the TCB. */ \ - asm { mov ds, ax } \ - asm { les bx, dword ptr pxCurrentTCB } \ - asm { mov ss, es:[ bx + 2 ] } \ - asm { mov sp, es:[ bx ] } +#define portSWITCH_CONTEXT() \ + asm { mov ax, seg pxCurrentTCB } \ + asm { mov ds, ax } \ + asm { les bx, pxCurrentTCB } /* Save the stack pointer into the TCB. */ \ + asm { mov es:0x2[ bx ], ss } \ + asm { mov es:[ bx ], sp } \ + asm { call far ptr vTaskSwitchContext } /* Perform the switch. */ \ + asm { mov ax, seg pxCurrentTCB } /* Restore the stack pointer from the TCB. */ \ + asm { mov ds, ax } \ + asm { les bx, dword ptr pxCurrentTCB } \ + asm { mov ss, es:[ bx + 2 ] } \ + asm { mov sp, es:[ bx ] } -#define portFIRST_CONTEXT() \ - __asm { mov ax, seg pxCurrentTCB } \ - __asm { mov ds, ax } \ - __asm { les bx, dword ptr pxCurrentTCB } \ - __asm { mov ss, es:[ bx + 2 ] } \ - __asm { mov sp, es:[ bx ] } \ - __asm { pop bp } \ - __asm { pop di } \ - __asm { pop si } \ - __asm { pop ds } \ - __asm { pop es } \ - __asm { pop dx } \ - __asm { pop cx } \ - __asm { pop bx } \ - __asm { pop ax } \ - __asm { iret } +#define portFIRST_CONTEXT() \ + __asm { mov ax, seg pxCurrentTCB } \ + __asm { mov ds, ax } \ + __asm { les bx, dword ptr pxCurrentTCB } \ + __asm { mov ss, es:[ bx + 2 ] } \ + __asm { mov sp, es:[ bx ] } \ + __asm { pop bp } \ + __asm { pop di } \ + __asm { pop si } \ + __asm { pop ds } \ + __asm { pop es } \ + __asm { pop dx } \ + __asm { pop cx } \ + __asm { pop bx } \ + __asm { pop ax } \ + __asm { iret } -#endif /* ifndef PORT_ASM_H */ +#endif diff --git a/portable/BCC/16BitDOS/common/portcomn.c b/portable/BCC/16BitDOS/common/portcomn.c index d9a1a43c84b..69ab45ba78e 100644 --- a/portable/BCC/16BitDOS/common/portcomn.c +++ b/portable/BCC/16BitDOS/common/portcomn.c @@ -27,16 +27,16 @@ */ /* - * Changes from V1.00: - * - + pxPortInitialiseStack() now initialises the stack of new tasks to the - + same format used by the compiler. This allows the compiler generated - + interrupt mechanism to be used for context switches. - + - + Changes from V2.6.1 - + - + Move usPortCheckFreeStackSpace() to tasks.c. - */ +Changes from V1.00: + + + pxPortInitialiseStack() now initialises the stack of new tasks to the + same format used by the compiler. This allows the compiler generated + interrupt mechanism to be used for context switches. + +Changes from V2.6.1 + + + Move usPortCheckFreeStackSpace() to tasks.c. +*/ #include @@ -46,14 +46,12 @@ /*-----------------------------------------------------------*/ /* See header file for description. */ -StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, - TaskFunction_t pxCode, - void * pvParameters ) +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) { - StackType_t DS_Reg = 0; +StackType_t DS_Reg = 0; /* Place a few bytes of known values on the bottom of the stack. - * This is just useful for debugging. */ + This is just useful for debugging. */ *pxTopOfStack = 0x1111; pxTopOfStack--; @@ -70,8 +68,8 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, /*lint -e950 -e611 -e923 Lint doesn't like this much - but nothing I can do about it. */ /* We are going to start the scheduler using a return from interrupt - * instruction to load the program counter, so first there would be the - * function call with parameters preamble. */ + instruction to load the program counter, so first there would be the + function call with parameters preamble. */ *pxTopOfStack = FP_SEG( pvParameters ); pxTopOfStack--; @@ -91,8 +89,8 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, pxTopOfStack--; /* The remaining registers would be pushed on the stack by our context - * switch function. These are loaded with values simply to make debugging - * easier. */ + switch function. These are loaded with values simply to make debugging + easier. */ *pxTopOfStack = ( StackType_t ) 0xAAAA; /* AX */ pxTopOfStack--; *pxTopOfStack = ( StackType_t ) 0xBBBB; /* BX */ @@ -105,11 +103,9 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, pxTopOfStack--; /* We need the true data segment. */ - __asm { - MOV DS_Reg, DS - }; + __asm{ MOV DS_Reg, DS }; - *pxTopOfStack = DS_Reg; /* DS */ + *pxTopOfStack = DS_Reg; /* DS */ pxTopOfStack--; *pxTopOfStack = ( StackType_t ) 0x0123; /* SI */ pxTopOfStack--; diff --git a/portable/CodeWarrior/ColdFire_V1/port.c b/portable/CodeWarrior/ColdFire_V1/port.c index dd6d794e90f..d9831384edc 100644 --- a/portable/CodeWarrior/ColdFire_V1/port.c +++ b/portable/CodeWarrior/ColdFire_V1/port.c @@ -31,38 +31,35 @@ #include "task.h" -#define portINITIAL_FORMAT_VECTOR ( ( StackType_t ) 0x4000 ) +#define portINITIAL_FORMAT_VECTOR ( ( StackType_t ) 0x4000 ) /* Supervisor mode set. */ -#define portINITIAL_STATUS_REGISTER ( ( StackType_t ) 0x2000 ) +#define portINITIAL_STATUS_REGISTER ( ( StackType_t ) 0x2000) /* The clock prescale into the timer peripheral. */ -#define portPRESCALE_VALUE ( ( uint8_t ) 10 ) +#define portPRESCALE_VALUE ( ( uint8_t ) 10 ) /* The clock frequency into the RTC. */ -#define portRTC_CLOCK_HZ ( ( uint32_t ) 1000 ) +#define portRTC_CLOCK_HZ ( ( uint32_t ) 1000 ) asm void interrupt VectorNumber_VL1swi vPortYieldISR( void ); static void prvSetupTimerInterrupt( void ); /* Used to keep track of the number of nested calls to taskENTER_CRITICAL(). This - * will be set to 0 prior to the first task being started. */ +will be set to 0 prior to the first task being started. */ static uint32_t ulCriticalNesting = 0x9999UL; /*-----------------------------------------------------------*/ -StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, - TaskFunction_t pxCode, - void * pvParameters ) +StackType_t *pxPortInitialiseStack( StackType_t * pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) { - uint32_t ulOriginalA5; - __asm { - MOVE.L A5, ulOriginalA5 - }; +uint32_t ulOriginalA5; + __asm{ MOVE.L A5, ulOriginalA5 }; - *pxTopOfStack = ( StackType_t ) 0xDEADBEEF; + + *pxTopOfStack = (StackType_t) 0xDEADBEEF; pxTopOfStack--; /* Exception stack frame starts with the return address. */ @@ -73,7 +70,7 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, pxTopOfStack--; *pxTopOfStack = ( StackType_t ) 0x0; /*FP*/ - pxTopOfStack -= 14; /* A5 to D0. */ + pxTopOfStack -= 14; /* A5 to D0. */ /* Parameter in A0. */ *( pxTopOfStack + 8 ) = ( StackType_t ) pvParameters; @@ -87,7 +84,7 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, BaseType_t xPortStartScheduler( void ) { - extern void vPortStartFirstTask( void ); +extern void vPortStartFirstTask( void ); ulCriticalNesting = 0UL; @@ -110,7 +107,7 @@ static void prvSetupTimerInterrupt( void ) RTCMOD = portRTC_CLOCK_HZ / configTICK_RATE_HZ; /* Enable the RTC to generate interrupts - interrupts are already disabled - * when this code executes. */ + when this code executes. */ RTCSC_RTIE = 1; } /*-----------------------------------------------------------*/ @@ -126,20 +123,19 @@ void vPortEnterCritical( void ) if( ulCriticalNesting == 0UL ) { /* Guard against context switches being pended simultaneously with a - * critical section being entered. */ + critical section being entered. */ do { portDISABLE_INTERRUPTS(); - if( INTC_FRC == 0UL ) { break; } portENABLE_INTERRUPTS(); + } while( 1 ); } - ulCriticalNesting++; } /*-----------------------------------------------------------*/ @@ -147,7 +143,6 @@ void vPortEnterCritical( void ) void vPortExitCritical( void ) { ulCriticalNesting--; - if( ulCriticalNesting == 0 ) { portENABLE_INTERRUPTS(); @@ -157,7 +152,7 @@ void vPortExitCritical( void ) void vPortYieldHandler( void ) { - uint32_t ulSavedInterruptMask; +uint32_t ulSavedInterruptMask; ulSavedInterruptMask = portSET_INTERRUPT_MASK_FROM_ISR(); { @@ -171,7 +166,7 @@ void vPortYieldHandler( void ) void interrupt VectorNumber_Vrtc vPortTickISR( void ) { - uint32_t ulSavedInterruptMask; +uint32_t ulSavedInterruptMask; /* Clear the interrupt. */ RTCSC |= RTCSC_RTIF_MASK; diff --git a/portable/CodeWarrior/ColdFire_V1/portmacro.h b/portable/CodeWarrior/ColdFire_V1/portmacro.h index d7263780140..a98093d7237 100644 --- a/portable/CodeWarrior/ColdFire_V1/portmacro.h +++ b/portable/CodeWarrior/ColdFire_V1/portmacro.h @@ -46,34 +46,34 @@ */ /* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE double -#define portLONG long -#define portSHORT short -#define portSTACK_TYPE uint32_t -#define portBASE_TYPE long - -typedef portSTACK_TYPE StackType_t; -typedef long BaseType_t; -typedef unsigned long UBaseType_t; - - -#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) - typedef uint16_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffff +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + + +#if( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff #elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) - typedef uint32_t TickType_t; - #define portMAX_DELAY ( TickType_t ) ( 0xFFFFFFFFUL ) + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) ( 0xFFFFFFFFUL ) #else #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width. #endif /*-----------------------------------------------------------*/ /* Hardware specifics. */ -#define portBYTE_ALIGNMENT 4 -#define portSTACK_GROWTH -1 -#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 4 +#define portSTACK_GROWTH -1 +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) /*-----------------------------------------------------------*/ uint32_t ulPortSetIPL( uint32_t ); @@ -83,29 +83,30 @@ uint32_t ulPortSetIPL( uint32_t ); extern void vPortEnterCritical( void ); extern void vPortExitCritical( void ); -#define portENTER_CRITICAL() vPortEnterCritical() -#define portEXIT_CRITICAL() vPortExitCritical() +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() extern UBaseType_t uxPortSetInterruptMaskFromISR( void ); extern void vPortClearInterruptMaskFromISR( UBaseType_t ); -#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortSetIPL( configMAX_SYSCALL_INTERRUPT_PRIORITY ) -#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusRegister ) ulPortSetIPL( uxSavedStatusRegister ) +#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortSetIPL( configMAX_SYSCALL_INTERRUPT_PRIORITY ) +#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusRegister ) ulPortSetIPL( uxSavedStatusRegister ) /*-----------------------------------------------------------*/ /* Task utilities. */ -#define portNOP() asm volatile ( "nop" ) +#define portNOP() asm volatile ( "nop" ) /* Context switches are requested using the force register. */ -#define portYIELD() INTC_SFRC = 0x3E; portNOP(); portNOP(); portNOP(); portNOP(); portNOP() +#define portYIELD() INTC_SFRC = 0x3E; portNOP(); portNOP(); portNOP(); portNOP(); portNOP() /*-----------------------------------------------------------*/ /* Task function macros as described on the FreeRTOS.org WEB site. */ -#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) __attribute__( ( noreturn ) ) -#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) __attribute__((noreturn)) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) /*-----------------------------------------------------------*/ + #define portEND_SWITCHING_ISR( xSwitchRequired ) \ do \ { \ diff --git a/portable/CodeWarrior/ColdFire_V2/port.c b/portable/CodeWarrior/ColdFire_V2/port.c index a7a78a7e9f6..5bca650fee4 100644 --- a/portable/CodeWarrior/ColdFire_V2/port.c +++ b/portable/CodeWarrior/ColdFire_V2/port.c @@ -31,41 +31,39 @@ #include "task.h" -#define portINITIAL_FORMAT_VECTOR ( ( StackType_t ) 0x4000 ) +#define portINITIAL_FORMAT_VECTOR ( ( StackType_t ) 0x4000 ) /* Supervisor mode set. */ -#define portINITIAL_STATUS_REGISTER ( ( StackType_t ) 0x2000 ) +#define portINITIAL_STATUS_REGISTER ( ( StackType_t ) 0x2000) /* Used to keep track of the number of nested calls to taskENTER_CRITICAL(). This - * will be set to 0 prior to the first task being started. */ +will be set to 0 prior to the first task being started. */ static uint32_t ulCriticalNesting = 0x9999UL; -#define portSAVE_CONTEXT() \ - lea.l( -60, % sp ), % sp; \ - movem.l % d0 - % fp, ( % sp ); \ - move.l pxCurrentTCB, % a0; \ - move.l % sp, ( % a0 ); +#define portSAVE_CONTEXT() \ + lea.l (-60, %sp), %sp; \ + movem.l %d0-%fp, (%sp); \ + move.l pxCurrentTCB, %a0; \ + move.l %sp, (%a0); -#define portRESTORE_CONTEXT() \ - move.l pxCurrentTCB, % a0; \ - move.l( % a0 ), % sp; \ - movem.l( % sp ), % d0 - % fp; \ - lea.l % sp@( 60 ), % sp; \ +#define portRESTORE_CONTEXT() \ + move.l pxCurrentTCB, %a0; \ + move.l (%a0), %sp; \ + movem.l (%sp), %d0-%fp; \ + lea.l %sp@(60), %sp; \ rte /*-----------------------------------------------------------*/ -StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, - TaskFunction_t pxCode, - void * pvParameters ) +StackType_t *pxPortInitialiseStack( StackType_t * pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) { *pxTopOfStack = ( StackType_t ) pvParameters; pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) 0xDEADBEEF; + *pxTopOfStack = (StackType_t) 0xDEADBEEF; pxTopOfStack--; /* Exception stack frame starts with the return address. */ @@ -76,7 +74,7 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, pxTopOfStack--; *pxTopOfStack = ( StackType_t ) 0x0; /*FP*/ - pxTopOfStack -= 14; /* A5 to D0. */ + pxTopOfStack -= 14; /* A5 to D0. */ return pxTopOfStack; } @@ -84,7 +82,7 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, BaseType_t xPortStartScheduler( void ) { - extern void vPortStartFirstTask( void ); +extern void vPortStartFirstTask( void ); ulCriticalNesting = 0UL; @@ -109,20 +107,19 @@ void vPortEnterCritical( void ) if( ulCriticalNesting == 0UL ) { /* Guard against context switches being pended simultaneously with a - * critical section being entered. */ + critical section being entered. */ do { portDISABLE_INTERRUPTS(); - if( MCF_INTC0_INTFRCH == 0UL ) { break; } portENABLE_INTERRUPTS(); + } while( 1 ); } - ulCriticalNesting++; } /*-----------------------------------------------------------*/ @@ -130,7 +127,6 @@ void vPortEnterCritical( void ) void vPortExitCritical( void ) { ulCriticalNesting--; - if( ulCriticalNesting == 0 ) { portENABLE_INTERRUPTS(); @@ -140,12 +136,12 @@ void vPortExitCritical( void ) void vPortYieldHandler( void ) { - uint32_t ulSavedInterruptMask; +uint32_t ulSavedInterruptMask; ulSavedInterruptMask = portSET_INTERRUPT_MASK_FROM_ISR(); - /* Note this will clear all forced interrupts - this is done for speed. */ - MCF_INTC0_INTFRCL = 0; - vTaskSwitchContext(); + /* Note this will clear all forced interrupts - this is done for speed. */ + MCF_INTC0_INTFRCL = 0; + vTaskSwitchContext(); portCLEAR_INTERRUPT_MASK_FROM_ISR( ulSavedInterruptMask ); } /*-----------------------------------------------------------*/ diff --git a/portable/CodeWarrior/ColdFire_V2/portmacro.h b/portable/CodeWarrior/ColdFire_V2/portmacro.h index e367e077466..a59dff9dd77 100644 --- a/portable/CodeWarrior/ColdFire_V2/portmacro.h +++ b/portable/CodeWarrior/ColdFire_V2/portmacro.h @@ -46,33 +46,33 @@ */ /* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE double -#define portLONG long -#define portSHORT short -#define portSTACK_TYPE uint32_t -#define portBASE_TYPE long - -typedef portSTACK_TYPE StackType_t; -typedef long BaseType_t; -typedef unsigned long UBaseType_t; - -#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) - typedef uint16_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffff +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint32_t +#define portBASE_TYPE long + +typedef portSTACK_TYPE StackType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; + +#if( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff #elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) - typedef uint32_t TickType_t; - #define portMAX_DELAY ( TickType_t ) ( 0xFFFFFFFFUL ) + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) ( 0xFFFFFFFFUL ) #else #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width. #endif /*-----------------------------------------------------------*/ /* Hardware specifics. */ -#define portBYTE_ALIGNMENT 4 -#define portSTACK_GROWTH -1 -#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 4 +#define portSTACK_GROWTH -1 +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) /*-----------------------------------------------------------*/ uint32_t ulPortSetIPL( uint32_t ); #define portDISABLE_INTERRUPTS() ulPortSetIPL( configMAX_SYSCALL_INTERRUPT_PRIORITY ) @@ -81,28 +81,28 @@ uint32_t ulPortSetIPL( uint32_t ); extern void vPortEnterCritical( void ); extern void vPortExitCritical( void ); -#define portENTER_CRITICAL() vPortEnterCritical() -#define portEXIT_CRITICAL() vPortExitCritical() +#define portENTER_CRITICAL() vPortEnterCritical() +#define portEXIT_CRITICAL() vPortExitCritical() extern UBaseType_t uxPortSetInterruptMaskFromISR( void ); extern void vPortClearInterruptMaskFromISR( UBaseType_t ); -#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortSetIPL( configMAX_SYSCALL_INTERRUPT_PRIORITY ) -#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusRegister ) ulPortSetIPL( uxSavedStatusRegister ) +#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortSetIPL( configMAX_SYSCALL_INTERRUPT_PRIORITY ) +#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusRegister ) ulPortSetIPL( uxSavedStatusRegister ) /*-----------------------------------------------------------*/ /* Task utilities. */ -#define portNOP() asm volatile ( "nop" ) +#define portNOP() asm volatile ( "nop" ) /* Note this will overwrite all other bits in the force register, it is done this way for speed. */ -#define portYIELD() MCF_INTC0_INTFRCL = ( 1UL << configYIELD_INTERRUPT_VECTOR ); portNOP(); portNOP() /* -32 as we are using the high word of the 64bit mask. */ +#define portYIELD() MCF_INTC0_INTFRCL = ( 1UL << configYIELD_INTERRUPT_VECTOR ); portNOP(); portNOP() /* -32 as we are using the high word of the 64bit mask. */ /*-----------------------------------------------------------*/ /* Task function macros as described on the FreeRTOS.org WEB site. */ -#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) __attribute__( ( noreturn ) ) -#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) __attribute__((noreturn)) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) /*-----------------------------------------------------------*/ #define portEND_SWITCHING_ISR( xSwitchRequired ) \ diff --git a/portable/CodeWarrior/HCS12/port.c b/portable/CodeWarrior/HCS12/port.c index 1b6f5c37dec..e4876125a50 100644 --- a/portable/CodeWarrior/HCS12/port.c +++ b/portable/CodeWarrior/HCS12/port.c @@ -32,8 +32,8 @@ /*----------------------------------------------------------- -* Implementation of functions defined in portable.h for the HCS12 port. -*----------------------------------------------------------*/ + * Implementation of functions defined in portable.h for the HCS12 port. + *----------------------------------------------------------*/ /* @@ -43,29 +43,29 @@ static void prvSetupTimerInterrupt( void ); /* Interrupt service routines have to be in non-banked memory - as does the - * scheduler startup function. */ +scheduler startup function. */ #pragma CODE_SEG __NEAR_SEG NON_BANKED -/* Manual context switch function. This is the SWI ISR. */ -void interrupt vPortYield( void ); + /* Manual context switch function. This is the SWI ISR. */ + void interrupt vPortYield( void ); -/* Tick context switch function. This is the timer ISR. */ -void interrupt vPortTickInterrupt( void ); + /* Tick context switch function. This is the timer ISR. */ + void interrupt vPortTickInterrupt( void ); -/* Simply called by xPortStartScheduler(). xPortStartScheduler() does not - * start the scheduler directly because the header file containing the - * xPortStartScheduler() prototype is part of the common kernel code, and - * therefore cannot use the CODE_SEG pragma. */ -static BaseType_t xBankedStartScheduler( void ); + /* Simply called by xPortStartScheduler(). xPortStartScheduler() does not + start the scheduler directly because the header file containing the + xPortStartScheduler() prototype is part of the common kernel code, and + therefore cannot use the CODE_SEG pragma. */ + static BaseType_t xBankedStartScheduler( void ); #pragma CODE_SEG DEFAULT /* Calls to portENTER_CRITICAL() can be nested. When they are nested the - * critical section should not be left (i.e. interrupts should not be re-enabled) - * until the nesting depth reaches 0. This variable simply tracks the nesting - * depth. Each task maintains it's own critical nesting depth variable so - * uxCriticalNesting is saved and restored from the task stack during a context - * switch. */ +critical section should not be left (i.e. interrupts should not be re-enabled) +until the nesting depth reaches 0. This variable simply tracks the nesting +depth. Each task maintains it's own critical nesting depth variable so +uxCriticalNesting is saved and restored from the task stack during a context +switch. */ volatile UBaseType_t uxCriticalNesting = 0xff; /*-----------------------------------------------------------*/ @@ -73,33 +73,31 @@ volatile UBaseType_t uxCriticalNesting = 0xff; /* * See header file for description. */ -StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, - TaskFunction_t pxCode, - void * pvParameters ) +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) { /* - * Place a few bytes of known values on the bottom of the stack. - * This can be uncommented to provide useful stack markers when debugging. - * - * pxTopOfStack = ( StackType_t ) 0x11; - * pxTopOfStack--; - * pxTopOfStack = ( StackType_t ) 0x22; - * pxTopOfStack--; - * pxTopOfStack = ( StackType_t ) 0x33; - * pxTopOfStack--; - */ + Place a few bytes of known values on the bottom of the stack. + This can be uncommented to provide useful stack markers when debugging. + + *pxTopOfStack = ( StackType_t ) 0x11; + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x22; + pxTopOfStack--; + *pxTopOfStack = ( StackType_t ) 0x33; + pxTopOfStack--; + */ /* Setup the initial stack of the task. The stack is set exactly as - * expected by the portRESTORE_CONTEXT() macro. In this case the stack as - * expected by the HCS12 RTI instruction. */ + expected by the portRESTORE_CONTEXT() macro. In this case the stack as + expected by the HCS12 RTI instruction. */ /* The address of the task function is placed in the stack byte at a time. */ - *pxTopOfStack = ( StackType_t ) *( ( ( StackType_t * ) ( &pxCode ) ) + 1 ); + *pxTopOfStack = ( StackType_t ) *( ((StackType_t *) (&pxCode) ) + 1 ); pxTopOfStack--; - *pxTopOfStack = ( StackType_t ) *( ( ( StackType_t * ) ( &pxCode ) ) + 0 ); + *pxTopOfStack = ( StackType_t ) *( ((StackType_t *) (&pxCode) ) + 0 ); pxTopOfStack--; /* Next are all the registers that form part of the task context. */ @@ -117,15 +115,15 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, pxTopOfStack--; /* A register contains parameter high byte. */ - *pxTopOfStack = ( StackType_t ) *( ( ( StackType_t * ) ( &pvParameters ) ) + 0 ); + *pxTopOfStack = ( StackType_t ) *( ((StackType_t *) (&pvParameters) ) + 0 ); pxTopOfStack--; /* B register contains parameter low byte. */ - *pxTopOfStack = ( StackType_t ) *( ( ( StackType_t * ) ( &pvParameters ) ) + 1 ); + *pxTopOfStack = ( StackType_t ) *( ((StackType_t *) (&pvParameters) ) + 1 ); pxTopOfStack--; /* CCR: Note that when the task starts interrupts will be enabled since - * "I" bit of CCR is cleared */ + "I" bit of CCR is cleared */ *pxTopOfStack = ( StackType_t ) 0x00; pxTopOfStack--; @@ -136,7 +134,7 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, #endif /* Finally the critical nesting depth is initialised with 0 (not within - * a critical section). */ + a critical section). */ *pxTopOfStack = ( StackType_t ) 0x00; return pxTopOfStack; @@ -159,10 +157,10 @@ static void prvSetupTimerInterrupt( void ) BaseType_t xPortStartScheduler( void ) { /* xPortStartScheduler() does not start the scheduler directly because - * the header file containing the xPortStartScheduler() prototype is part - * of the common kernel code, and therefore cannot use the CODE_SEG pragma. - * Instead it simply calls the locally defined xBankedStartScheduler() - - * which does use the CODE_SEG pragma. */ + the header file containing the xPortStartScheduler() prototype is part + of the common kernel code, and therefore cannot use the CODE_SEG pragma. + Instead it simply calls the locally defined xBankedStartScheduler() - + which does use the CODE_SEG pragma. */ return xBankedStartScheduler(); } @@ -173,7 +171,7 @@ BaseType_t xPortStartScheduler( void ) static BaseType_t xBankedStartScheduler( void ) { /* Configure the timer that will generate the RTOS tick. Interrupts are - * disabled when this function is called. */ + disabled when this function is called. */ prvSetupTimerInterrupt(); /* Restore the context of the first task. */ @@ -224,15 +222,15 @@ void interrupt vPortTickInterrupt( void ) TFLG1 = 1; /* Restore the context of a task - which may be a different task - * to that interrupted. */ + to that interrupted. */ portRESTORE_CONTEXT(); } - #else /* if configUSE_PREEMPTION == 1 */ + #else { xTaskIncrementTick(); TFLG1 = 1; } - #endif /* if configUSE_PREEMPTION == 1 */ + #endif } #pragma CODE_SEG DEFAULT diff --git a/portable/CodeWarrior/HCS12/portmacro.h b/portable/CodeWarrior/HCS12/portmacro.h index f2f89934672..d0d0a140eb4 100644 --- a/portable/CodeWarrior/HCS12/portmacro.h +++ b/portable/CodeWarrior/HCS12/portmacro.h @@ -41,40 +41,40 @@ */ /* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE double -#define portLONG long -#define portSHORT short -#define portSTACK_TYPE uint8_t -#define portBASE_TYPE char - -typedef portSTACK_TYPE StackType_t; -typedef signed char BaseType_t; -typedef unsigned char UBaseType_t; - -#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) - typedef uint16_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffff +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT short +#define portSTACK_TYPE uint8_t +#define portBASE_TYPE char + +typedef portSTACK_TYPE StackType_t; +typedef signed char BaseType_t; +typedef unsigned char UBaseType_t; + +#if( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff #elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) - typedef uint32_t TickType_t; - #define portMAX_DELAY ( TickType_t ) ( 0xFFFFFFFFUL ) + typedef uint32_t TickType_t; + #define portMAX_DELAY ( TickType_t ) ( 0xFFFFFFFFUL ) #else #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width. #endif /*-----------------------------------------------------------*/ /* Hardware specifics. */ -#define portBYTE_ALIGNMENT 1 -#define portSTACK_GROWTH ( -1 ) -#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) -#define portYIELD() __asm( "swi" ); -#define portNOP() __asm( "nop" ); +#define portBYTE_ALIGNMENT 1 +#define portSTACK_GROWTH ( -1 ) +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portYIELD() __asm( "swi" ); +#define portNOP() __asm( "nop" ); /*-----------------------------------------------------------*/ /* Critical section handling. */ -#define portENABLE_INTERRUPTS() __asm( "cli" ) -#define portDISABLE_INTERRUPTS() __asm( "sei" ) +#define portENABLE_INTERRUPTS() __asm( "cli" ) +#define portDISABLE_INTERRUPTS() __asm( "sei" ) /* * Disable interrupts before incrementing the count of critical section nesting. @@ -82,29 +82,29 @@ typedef unsigned char UBaseType_t; * re-enabled. Once interrupts are disabled the nesting count can be accessed * directly. Each task maintains its own nesting count. */ -#define portENTER_CRITICAL() \ - { \ - extern volatile UBaseType_t uxCriticalNesting; \ - \ - portDISABLE_INTERRUPTS(); \ - uxCriticalNesting++; \ - } +#define portENTER_CRITICAL() \ +{ \ + extern volatile UBaseType_t uxCriticalNesting; \ + \ + portDISABLE_INTERRUPTS(); \ + uxCriticalNesting++; \ +} /* * Interrupts are disabled so we can access the nesting count directly. If the * nesting is found to be 0 (no nesting) then we are leaving the critical * section and interrupts can be re-enabled. */ -#define portEXIT_CRITICAL() \ - { \ - extern volatile UBaseType_t uxCriticalNesting; \ - \ - uxCriticalNesting--; \ - if( uxCriticalNesting == 0 ) \ - { \ - portENABLE_INTERRUPTS(); \ - } \ - } +#define portEXIT_CRITICAL() \ +{ \ + extern volatile UBaseType_t uxCriticalNesting; \ + \ + uxCriticalNesting--; \ + if( uxCriticalNesting == 0 ) \ + { \ + portENABLE_INTERRUPTS(); \ + } \ +} /*-----------------------------------------------------------*/ /* Task utilities. */ @@ -120,71 +120,70 @@ typedef unsigned char UBaseType_t; */ #ifdef BANKED_MODEL - -/* - * Load the stack pointer for the task, then pull the critical nesting - * count and PPAGE register from the stack. The remains of the - * context are restored by the RTI instruction. - */ - #define portRESTORE_CONTEXT() \ - { \ - extern volatile void * pxCurrentTCB; \ - extern volatile UBaseType_t uxCriticalNesting; \ - \ - __asm( "ldx pxCurrentTCB" ); \ - __asm( "lds 0, x" ); \ - __asm( "pula" ); \ - __asm( "staa uxCriticalNesting" ); \ - __asm( "pula" ); \ - __asm( "staa 0x30" ); /* 0x30 = PPAGE */ \ + /* + * Load the stack pointer for the task, then pull the critical nesting + * count and PPAGE register from the stack. The remains of the + * context are restored by the RTI instruction. + */ + #define portRESTORE_CONTEXT() \ + { \ + extern volatile void * pxCurrentTCB; \ + extern volatile UBaseType_t uxCriticalNesting; \ + \ + __asm( "ldx pxCurrentTCB" ); \ + __asm( "lds 0, x" ); \ + __asm( "pula" ); \ + __asm( "staa uxCriticalNesting" ); \ + __asm( "pula" ); \ + __asm( "staa 0x30" ); /* 0x30 = PPAGE */ \ } -/* - * By the time this macro is called the processor has already stacked the - * registers. Simply stack the nesting count and PPAGE value, then save - * the task stack pointer. - */ - #define portSAVE_CONTEXT() \ - { \ - extern volatile void * pxCurrentTCB; \ - extern volatile UBaseType_t uxCriticalNesting; \ - \ - __asm( "ldaa 0x30" ); /* 0x30 = PPAGE */ \ - __asm( "psha" ); \ - __asm( "ldaa uxCriticalNesting" ); \ - __asm( "psha" ); \ - __asm( "ldx pxCurrentTCB" ); \ - __asm( "sts 0, x" ); \ + /* + * By the time this macro is called the processor has already stacked the + * registers. Simply stack the nesting count and PPAGE value, then save + * the task stack pointer. + */ + #define portSAVE_CONTEXT() \ + { \ + extern volatile void * pxCurrentTCB; \ + extern volatile UBaseType_t uxCriticalNesting; \ + \ + __asm( "ldaa 0x30" ); /* 0x30 = PPAGE */ \ + __asm( "psha" ); \ + __asm( "ldaa uxCriticalNesting" ); \ + __asm( "psha" ); \ + __asm( "ldx pxCurrentTCB" ); \ + __asm( "sts 0, x" ); \ } -#else /* ifdef BANKED_MODEL */ - -/* - * These macros are as per the BANKED versions above, but without saving - * and restoring the PPAGE register. - */ +#else - #define portRESTORE_CONTEXT() \ - { \ - extern volatile void * pxCurrentTCB; \ - extern volatile UBaseType_t uxCriticalNesting; \ - \ - __asm( "ldx pxCurrentTCB" ); \ - __asm( "lds 0, x" ); \ - __asm( "pula" ); \ - __asm( "staa uxCriticalNesting" ); \ + /* + * These macros are as per the BANKED versions above, but without saving + * and restoring the PPAGE register. + */ + + #define portRESTORE_CONTEXT() \ + { \ + extern volatile void * pxCurrentTCB; \ + extern volatile UBaseType_t uxCriticalNesting; \ + \ + __asm( "ldx pxCurrentTCB" ); \ + __asm( "lds 0, x" ); \ + __asm( "pula" ); \ + __asm( "staa uxCriticalNesting" ); \ } - #define portSAVE_CONTEXT() \ - { \ - extern volatile void * pxCurrentTCB; \ - extern volatile UBaseType_t uxCriticalNesting; \ - \ - __asm( "ldaa uxCriticalNesting" ); \ - __asm( "psha" ); \ - __asm( "ldx pxCurrentTCB" ); \ - __asm( "sts 0, x" ); \ + #define portSAVE_CONTEXT() \ + { \ + extern volatile void * pxCurrentTCB; \ + extern volatile UBaseType_t uxCriticalNesting; \ + \ + __asm( "ldaa uxCriticalNesting" ); \ + __asm( "psha" ); \ + __asm( "ldx pxCurrentTCB" ); \ + __asm( "sts 0, x" ); \ } -#endif /* ifdef BANKED_MODEL */ +#endif /* * Utility macro to call macros above in correct order in order to perform a @@ -192,14 +191,14 @@ typedef unsigned char UBaseType_t; * the ISR does not use any local (stack) variables. If the ISR uses stack * variables portYIELD() should be used in it's place. */ -#define portTASK_SWITCH_FROM_ISR() \ - portSAVE_CONTEXT(); \ - vTaskSwitchContext(); \ +#define portTASK_SWITCH_FROM_ISR() \ + portSAVE_CONTEXT(); \ + vTaskSwitchContext(); \ portRESTORE_CONTEXT(); /* Task function macros as described on the FreeRTOS.org WEB site. */ -#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) -#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) #endif /* PORTMACRO_H */ diff --git a/portable/Paradigm/Tern_EE/large_untested/port.c b/portable/Paradigm/Tern_EE/large_untested/port.c index fdb275f2bcd..4ecffe01a1e 100644 --- a/portable/Paradigm/Tern_EE/large_untested/port.c +++ b/portable/Paradigm/Tern_EE/large_untested/port.c @@ -28,9 +28,9 @@ /*----------------------------------------------------------- -* Implementation of functions defined in portable.h for the Tern EE 186 -* port. -*----------------------------------------------------------*/ + * Implementation of functions defined in portable.h for the Tern EE 186 + * port. + *----------------------------------------------------------*/ /* Library includes. */ #include @@ -42,29 +42,27 @@ #include "portasm.h" /* The timer increments every four clocks, hence the divide by 4. */ -#define portTIMER_COMPARE ( uint16_t ) ( ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) / ( uint32_t ) 4 ) +#define portTIMER_COMPARE ( uint16_t ) ( ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) / ( uint32_t ) 4 ) /* From the RDC data sheet. */ -#define portENABLE_TIMER_AND_INTERRUPT ( uint16_t ) 0xe001 +#define portENABLE_TIMER_AND_INTERRUPT ( uint16_t ) 0xe001 /* Interrupt control. */ -#define portEIO_REGISTER 0xff22 -#define portCLEAR_INTERRUPT 0x0008 +#define portEIO_REGISTER 0xff22 +#define portCLEAR_INTERRUPT 0x0008 /* Setup the hardware to generate the required tick frequency. */ static void prvSetupTimerInterrupt( void ); /* The ISR used depends on whether the preemptive or cooperative scheduler - * is being used. */ -#if ( configUSE_PREEMPTION == 1 ) - -/* Tick service routine used by the scheduler when preemptive scheduling is - * being used. */ +is being used. */ +#if( configUSE_PREEMPTION == 1 ) + /* Tick service routine used by the scheduler when preemptive scheduling is + being used. */ static void __interrupt __far prvPreemptiveTick( void ); #else - -/* Tick service routine used by the scheduler when cooperative scheduling is - * being used. */ + /* Tick service routine used by the scheduler when cooperative scheduling is + being used. */ static void __interrupt __far prvNonPreemptiveTick( void ); #endif @@ -72,20 +70,18 @@ static void prvSetupTimerInterrupt( void ); static void __interrupt __far prvYieldProcessor( void ); /* The timer initialisation functions leave interrupts enabled, - * which is not what we want. This ISR is installed temporarily in case - * the timer fires before we get a change to disable interrupts again. */ +which is not what we want. This ISR is installed temporarily in case +the timer fires before we get a change to disable interrupts again. */ static void __interrupt __far prvDummyISR( void ); /*-----------------------------------------------------------*/ /* See header file for description. */ -StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, - TaskFunction_t pxCode, - void * pvParameters ) +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) { - StackType_t DS_Reg = 0; +StackType_t DS_Reg = 0; /* Place a few bytes of known values on the bottom of the stack. - * This is just useful for debugging. */ + This is just useful for debugging. */ *pxTopOfStack = 0x1111; pxTopOfStack--; @@ -95,8 +91,8 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, pxTopOfStack--; /* We are going to start the scheduler using a return from interrupt - * instruction to load the program counter, so first there would be the - * function call with parameters preamble. */ + instruction to load the program counter, so first there would be the + function call with parameters preamble. */ *pxTopOfStack = FP_SEG( pvParameters ); pxTopOfStack--; @@ -116,8 +112,8 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, pxTopOfStack--; /* The remaining registers would be pushed on the stack by our context - * switch function. These are loaded with values simply to make debugging - * easier. */ + switch function. These are loaded with values simply to make debugging + easier. */ *pxTopOfStack = ( StackType_t ) 0xAAAA; /* AX */ pxTopOfStack--; *pxTopOfStack = ( StackType_t ) 0xBBBB; /* BX */ @@ -130,11 +126,9 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, pxTopOfStack--; /* We need the true data segment. */ - __asm { - MOV DS_Reg, DS - }; + __asm{ MOV DS_Reg, DS }; - *pxTopOfStack = DS_Reg; /* DS */ + *pxTopOfStack = DS_Reg; /* DS */ pxTopOfStack--; *pxTopOfStack = ( StackType_t ) 0x0123; /* SI */ pxTopOfStack--; @@ -151,7 +145,7 @@ BaseType_t xPortStartScheduler( void ) /* This is called with interrupts already disabled. */ /* Put our manual switch (yield) function on a known - * vector. */ + vector. */ setvect( portSWITCH_INT_NUMBER, prvYieldProcessor ); /* Setup the tick interrupt. */ @@ -168,15 +162,15 @@ BaseType_t xPortStartScheduler( void ) static void __interrupt __far prvDummyISR( void ) { /* The timer initialisation functions leave interrupts enabled, - * which is not what we want. This ISR is installed temporarily in case - * the timer fires before we get a change to disable interrupts again. */ + which is not what we want. This ISR is installed temporarily in case + the timer fires before we get a change to disable interrupts again. */ outport( portEIO_REGISTER, portCLEAR_INTERRUPT ); } /*-----------------------------------------------------------*/ /* The ISR used depends on whether the preemptive or cooperative scheduler - * is being used. */ -#if ( configUSE_PREEMPTION == 1 ) +is being used. */ +#if( configUSE_PREEMPTION == 1 ) static void __interrupt __far prvPreemptiveTick( void ) { /* Get the scheduler to update the task states following the tick. */ @@ -189,17 +183,17 @@ static void __interrupt __far prvDummyISR( void ) /* Reset interrupt. */ outport( portEIO_REGISTER, portCLEAR_INTERRUPT ); } -#else /* if ( configUSE_PREEMPTION == 1 ) */ +#else static void __interrupt __far prvNonPreemptiveTick( void ) { /* Same as preemptive tick, but the cooperative scheduler is being used - * so we don't have to switch in the context of the next task. */ + so we don't have to switch in the context of the next task. */ xTaskIncrementTick(); /* Reset interrupt. */ outport( portEIO_REGISTER, portCLEAR_INTERRUPT ); } -#endif /* if ( configUSE_PREEMPTION == 1 ) */ +#endif /*-----------------------------------------------------------*/ static void __interrupt __far prvYieldProcessor( void ) @@ -217,25 +211,23 @@ void vPortEndScheduler( void ) static void prvSetupTimerInterrupt( void ) { - const uint16_t usTimerACompare = portTIMER_COMPARE, usTimerAMode = portENABLE_TIMER_AND_INTERRUPT; - const uint16_t usT2_IRQ = 0x13; +const uint16_t usTimerACompare = portTIMER_COMPARE, usTimerAMode = portENABLE_TIMER_AND_INTERRUPT; +const uint16_t usT2_IRQ = 0x13; /* Configure the timer, the dummy handler is used here as the init - * function leaves interrupts enabled. */ + function leaves interrupts enabled. */ t2_init( usTimerAMode, usTimerACompare, prvDummyISR ); /* Disable interrupts again before installing the real handlers. */ portDISABLE_INTERRUPTS(); - #if ( configUSE_PREEMPTION == 1 ) - + #if( configUSE_PREEMPTION == 1 ) /* Tick service routine used by the scheduler when preemptive scheduling is - * being used. */ + being used. */ setvect( usT2_IRQ, prvPreemptiveTick ); #else - /* Tick service routine used by the scheduler when cooperative scheduling is - * being used. */ + being used. */ setvect( usT2_IRQ, prvNonPreemptiveTick ); #endif } diff --git a/portable/Paradigm/Tern_EE/large_untested/portasm.h b/portable/Paradigm/Tern_EE/large_untested/portasm.h index e0321a8b036..c3c7456a386 100644 --- a/portable/Paradigm/Tern_EE/large_untested/portasm.h +++ b/portable/Paradigm/Tern_EE/large_untested/portasm.h @@ -44,32 +44,32 @@ void portSWITCH_CONTEXT( void ); */ void portFIRST_CONTEXT( void ); -#define portSWITCH_CONTEXT() \ - asm { mov ax, seg pxCurrentTCB } \ - asm { mov ds, ax } \ - asm { les bx, pxCurrentTCB } /* Save the stack pointer into the TCB. */ \ - asm { mov es : 0x2[ bx ], ss } \ - asm { mov es:[ bx ], sp } \ - asm { call far ptr vTaskSwitchContext } /* Perform the switch. */ \ - asm { mov ax, seg pxCurrentTCB } /* Restore the stack pointer from the TCB. */ \ - asm { mov ds, ax } \ - asm { les bx, dword ptr pxCurrentTCB } \ - asm { mov ss, es:[ bx + 2 ] } \ - asm { mov sp, es:[ bx ] } +#define portSWITCH_CONTEXT() \ + asm { mov ax, seg pxCurrentTCB } \ + asm { mov ds, ax } \ + asm { les bx, pxCurrentTCB } /* Save the stack pointer into the TCB. */ \ + asm { mov es:0x2[ bx ], ss } \ + asm { mov es:[ bx ], sp } \ + asm { call far ptr vTaskSwitchContext } /* Perform the switch. */ \ + asm { mov ax, seg pxCurrentTCB } /* Restore the stack pointer from the TCB. */ \ + asm { mov ds, ax } \ + asm { les bx, dword ptr pxCurrentTCB } \ + asm { mov ss, es:[ bx + 2 ] } \ + asm { mov sp, es:[ bx ] } -#define portFIRST_CONTEXT() \ - asm { mov ax, seg pxCurrentTCB } \ - asm { mov ds, ax } \ - asm { les bx, dword ptr pxCurrentTCB } \ - asm { mov ss, es:[ bx + 2 ] } \ - asm { mov sp, es:[ bx ] } \ - asm { pop bp } \ - asm { pop di } \ - asm { pop si } \ - asm { pop ds } \ - asm { pop es } \ - asm { pop dx } \ - asm { pop cx } \ - asm { pop bx } \ - asm { pop ax } \ - asm { iret } +#define portFIRST_CONTEXT() \ + asm { mov ax, seg pxCurrentTCB } \ + asm { mov ds, ax } \ + asm { les bx, dword ptr pxCurrentTCB } \ + asm { mov ss, es:[ bx + 2 ] } \ + asm { mov sp, es:[ bx ] } \ + asm { pop bp } \ + asm { pop di } \ + asm { pop si } \ + asm { pop ds } \ + asm { pop es } \ + asm { pop dx } \ + asm { pop cx } \ + asm { pop bx } \ + asm { pop ax } \ + asm { iret } diff --git a/portable/Paradigm/Tern_EE/large_untested/portmacro.h b/portable/Paradigm/Tern_EE/large_untested/portmacro.h index 2027213a116..292c9e260d6 100644 --- a/portable/Paradigm/Tern_EE/large_untested/portmacro.h +++ b/portable/Paradigm/Tern_EE/large_untested/portmacro.h @@ -46,24 +46,24 @@ */ /* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE long -#define portLONG long -#define portSHORT int -#define portSTACK_TYPE uint16_t -#define portBASE_TYPE short - -typedef portSTACK_TYPE StackType_t; -typedef short BaseType_t; -typedef unsigned short UBaseType_t; - - -#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) - typedef uint16_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffff -#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) - typedef uint32_t TickType_t; +#define portCHAR char +#define portFLOAT float +#define portDOUBLE long +#define portLONG long +#define portSHORT int +#define portSTACK_TYPE uint16_t +#define portBASE_TYPE short + +typedef portSTACK_TYPE StackType_t; +typedef short BaseType_t; +typedef unsigned short UBaseType_t; + + +#if( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) + typedef uint32_t TickType_t; #define portMAX_DELAY ( TickType_t ) 0xffffffffUL #else #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width. @@ -71,37 +71,36 @@ typedef unsigned short UBaseType_t; /*-----------------------------------------------------------*/ /* Critical section handling. */ -#define portENTER_CRITICAL() \ - __asm { pushf } \ - __asm { cli } \ +#define portENTER_CRITICAL() __asm{ pushf } \ + __asm{ cli } \ -#define portEXIT_CRITICAL() __asm { popf } +#define portEXIT_CRITICAL() __asm{ popf } -#define portDISABLE_INTERRUPTS() __asm { cli } +#define portDISABLE_INTERRUPTS() __asm{ cli } -#define portENABLE_INTERRUPTS() __asm { sti } +#define portENABLE_INTERRUPTS() __asm{ sti } /*-----------------------------------------------------------*/ /* Hardware specifics. */ -#define portNOP() __asm { nop } -#define portSTACK_GROWTH ( -1 ) -#define portSWITCH_INT_NUMBER 0x80 -#define portYIELD() __asm { int portSWITCH_INT_NUMBER } -#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) -#define portBYTE_ALIGNMENT 2 -#define portINITIAL_SW ( ( portSTACK_TYPE ) 0x0202 ) /* Start the tasks with interrupts enabled. */ +#define portNOP() __asm{ nop } +#define portSTACK_GROWTH ( -1 ) +#define portSWITCH_INT_NUMBER 0x80 +#define portYIELD() __asm{ int portSWITCH_INT_NUMBER } +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 2 +#define portINITIAL_SW ( ( portSTACK_TYPE ) 0x0202 ) /* Start the tasks with interrupts enabled. */ /*-----------------------------------------------------------*/ /* Compiler specifics. */ -#define portINPUT_BYTE( xAddr ) inp( xAddr ) -#define portOUTPUT_BYTE( xAddr, ucValue ) outp( xAddr, ucValue ) -#define portINPUT_WORD( xAddr ) inpw( xAddr ) -#define portOUTPUT_WORD( xAddr, usValue ) outpw( xAddr, usValue ) +#define portINPUT_BYTE( xAddr ) inp( xAddr ) +#define portOUTPUT_BYTE( xAddr, ucValue ) outp( xAddr, ucValue ) +#define portINPUT_WORD( xAddr ) inpw( xAddr ) +#define portOUTPUT_WORD( xAddr, usValue ) outpw( xAddr, usValue ) /*-----------------------------------------------------------*/ /* Task function macros as described on the FreeRTOS.org WEB site. */ -#define portTASK_FUNCTION_PROTO( vTaskFunction, vParameters ) void vTaskFunction( void * pvParameters ) -#define portTASK_FUNCTION( vTaskFunction, vParameters ) void vTaskFunction( void * pvParameters ) +#define portTASK_FUNCTION_PROTO( vTaskFunction, vParameters ) void vTaskFunction( void *pvParameters ) +#define portTASK_FUNCTION( vTaskFunction, vParameters ) void vTaskFunction( void *pvParameters ) /* *INDENT-OFF* */ #ifdef __cplusplus diff --git a/portable/Paradigm/Tern_EE/small/port.c b/portable/Paradigm/Tern_EE/small/port.c index 6d27ba991cd..2a1c0d962f6 100644 --- a/portable/Paradigm/Tern_EE/small/port.c +++ b/portable/Paradigm/Tern_EE/small/port.c @@ -28,9 +28,9 @@ /*----------------------------------------------------------- -* Implementation of functions defined in portable.h for the Tern EE 186 -* port. -*----------------------------------------------------------*/ + * Implementation of functions defined in portable.h for the Tern EE 186 + * port. + *----------------------------------------------------------*/ /* Library includes. */ #include @@ -42,31 +42,29 @@ #include "portasm.h" /* The timer increments every four clocks, hence the divide by 4. */ -#define portPRESCALE_VALUE ( 16 ) -#define portTIMER_COMPARE ( configCPU_CLOCK_HZ / ( configTICK_RATE_HZ * 4UL ) ) +#define portPRESCALE_VALUE ( 16 ) +#define portTIMER_COMPARE ( configCPU_CLOCK_HZ / ( configTICK_RATE_HZ * 4UL ) ) /* From the RDC data sheet. */ -#define portENABLE_TIMER_AND_INTERRUPT ( uint16_t ) 0xe00b -#define portENABLE_TIMER ( uint16_t ) 0xC001 +#define portENABLE_TIMER_AND_INTERRUPT ( uint16_t ) 0xe00b +#define portENABLE_TIMER ( uint16_t ) 0xC001 /* Interrupt control. */ -#define portEIO_REGISTER 0xff22 -#define portCLEAR_INTERRUPT 0x0008 +#define portEIO_REGISTER 0xff22 +#define portCLEAR_INTERRUPT 0x0008 /* Setup the hardware to generate the required tick frequency. */ static void prvSetupTimerInterrupt( void ); /* The ISR used depends on whether the preemptive or cooperative scheduler - * is being used. */ -#if ( configUSE_PREEMPTION == 1 ) - -/* Tick service routine used by the scheduler when preemptive scheduling is - * being used. */ +is being used. */ +#if( configUSE_PREEMPTION == 1 ) + /* Tick service routine used by the scheduler when preemptive scheduling is + being used. */ static void __interrupt __far prvPreemptiveTick( void ); #else - -/* Tick service routine used by the scheduler when cooperative scheduling is - * being used. */ + /* Tick service routine used by the scheduler when cooperative scheduling is + being used. */ static void __interrupt __far prvNonPreemptiveTick( void ); #endif @@ -75,19 +73,15 @@ static void __interrupt __far prvYieldProcessor( void ); /*-----------------------------------------------------------*/ /* See header file for description. */ -StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, - TaskFunction_t pxCode, - void * pvParameters ) +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) { - StackType_t DS_Reg = 0; +StackType_t DS_Reg = 0; /* We need the true data segment. */ - __asm { - MOV DS_Reg, DS - }; + __asm{ MOV DS_Reg, DS }; /* Place a few bytes of known values on the bottom of the stack. - * This is just useful for debugging. */ + This is just useful for debugging. */ *pxTopOfStack = 0x1111; pxTopOfStack--; @@ -97,8 +91,8 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, pxTopOfStack--; /* We are going to start the scheduler using a return from interrupt - * instruction to load the program counter, so first there would be the - * function call with parameters preamble. */ + instruction to load the program counter, so first there would be the + function call with parameters preamble. */ *pxTopOfStack = FP_OFF( pvParameters ); pxTopOfStack--; @@ -114,8 +108,8 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, pxTopOfStack--; /* The remaining registers would be pushed on the stack by our context - * switch function. These are loaded with values simply to make debugging - * easier. */ + switch function. These are loaded with values simply to make debugging + easier. */ *pxTopOfStack = ( StackType_t ) 0xAAAA; /* AX */ pxTopOfStack--; *pxTopOfStack = ( StackType_t ) 0xBBBB; /* BX */ @@ -127,7 +121,7 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, *pxTopOfStack = ( StackType_t ) 0xEEEE; /* ES */ pxTopOfStack--; - *pxTopOfStack = DS_Reg; /* DS */ + *pxTopOfStack = DS_Reg; /* DS */ pxTopOfStack--; *pxTopOfStack = ( StackType_t ) 0x0123; /* SI */ pxTopOfStack--; @@ -144,7 +138,7 @@ BaseType_t xPortStartScheduler( void ) /* This is called with interrupts already disabled. */ /* Put our manual switch (yield) function on a known - * vector. */ + vector. */ setvect( portSWITCH_INT_NUMBER, prvYieldProcessor ); /* Setup the tick interrupt. */ @@ -159,8 +153,8 @@ BaseType_t xPortStartScheduler( void ) /*-----------------------------------------------------------*/ /* The ISR used depends on whether the preemptive or cooperative scheduler - * is being used. */ -#if ( configUSE_PREEMPTION == 1 ) +is being used. */ +#if( configUSE_PREEMPTION == 1 ) static void __interrupt __far prvPreemptiveTick( void ) { /* Get the scheduler to update the task states following the tick. */ @@ -173,17 +167,17 @@ BaseType_t xPortStartScheduler( void ) /* Reset interrupt. */ outport( portEIO_REGISTER, portCLEAR_INTERRUPT ); } -#else /* if ( configUSE_PREEMPTION == 1 ) */ +#else static void __interrupt __far prvNonPreemptiveTick( void ) { /* Same as preemptive tick, but the cooperative scheduler is being used - * so we don't have to switch in the context of the next task. */ + so we don't have to switch in the context of the next task. */ xTaskIncrementTick(); /* Reset interrupt. */ outport( portEIO_REGISTER, portCLEAR_INTERRUPT ); } -#endif /* if ( configUSE_PREEMPTION == 1 ) */ +#endif /*-----------------------------------------------------------*/ static void __interrupt __far prvYieldProcessor( void ) @@ -201,21 +195,19 @@ void vPortEndScheduler( void ) static void prvSetupTimerInterrupt( void ) { - const uint32_t ulCompareValue = portTIMER_COMPARE; - uint16_t usTimerCompare; +const uint32_t ulCompareValue = portTIMER_COMPARE; +uint16_t usTimerCompare; usTimerCompare = ( uint16_t ) ( ulCompareValue >> 4 ); t2_init( portENABLE_TIMER, portPRESCALE_VALUE, NULL ); - #if ( configUSE_PREEMPTION == 1 ) - + #if( configUSE_PREEMPTION == 1 ) /* Tick service routine used by the scheduler when preemptive scheduling is - * being used. */ + being used. */ t1_init( portENABLE_TIMER_AND_INTERRUPT, usTimerCompare, usTimerCompare, prvPreemptiveTick ); #else - /* Tick service routine used by the scheduler when cooperative scheduling is - * being used. */ + being used. */ t1_init( portENABLE_TIMER_AND_INTERRUPT, usTimerCompare, usTimerCompare, prvNonPreemptiveTick ); #endif } diff --git a/portable/Paradigm/Tern_EE/small/portasm.h b/portable/Paradigm/Tern_EE/small/portasm.h index 2acba2443b2..930da20b099 100644 --- a/portable/Paradigm/Tern_EE/small/portasm.h +++ b/portable/Paradigm/Tern_EE/small/portasm.h @@ -47,26 +47,26 @@ void portEND_SWITCHING_ISR( void ); */ void portFIRST_CONTEXT( void ); -#define portEND_SWITCHING_ISR() \ - asm { mov bx, [ pxCurrentTCB ] } \ - asm { mov word ptr[ bx ], sp } \ - asm { call far ptr vTaskSwitchContext } \ - asm { mov bx, [ pxCurrentTCB ] } \ - asm { mov sp, [ bx ] } +#define portEND_SWITCHING_ISR() \ + asm { mov bx, [pxCurrentTCB] } \ + asm { mov word ptr [bx], sp } \ + asm { call far ptr vTaskSwitchContext } \ + asm { mov bx, [pxCurrentTCB] } \ + asm { mov sp, [bx] } -#define portFIRST_CONTEXT() \ - asm { mov bx, [ pxCurrentTCB ] } \ - asm { mov sp, [ bx ] } \ - asm { pop bp } \ - asm { pop di } \ - asm { pop si } \ - asm { pop ds } \ - asm { pop es } \ - asm { pop dx } \ - asm { pop cx } \ - asm { pop bx } \ - asm { pop ax } \ - asm { iret } +#define portFIRST_CONTEXT() \ + asm { mov bx, [pxCurrentTCB] } \ + asm { mov sp, [bx] } \ + asm { pop bp } \ + asm { pop di } \ + asm { pop si } \ + asm { pop ds } \ + asm { pop es } \ + asm { pop dx } \ + asm { pop cx } \ + asm { pop bx } \ + asm { pop ax } \ + asm { iret } -#endif /* ifndef PORT_ASM_H */ +#endif diff --git a/portable/Paradigm/Tern_EE/small/portmacro.h b/portable/Paradigm/Tern_EE/small/portmacro.h index 393e6faa5b7..ff0b34b2065 100644 --- a/portable/Paradigm/Tern_EE/small/portmacro.h +++ b/portable/Paradigm/Tern_EE/small/portmacro.h @@ -46,26 +46,26 @@ */ /* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE long -#define portLONG long -#define portSHORT int -#define portSTACK_TYPE uint16_t -#define portBASE_TYPE short - -typedef portSTACK_TYPE StackType_t; -typedef short BaseType_t; -typedef unsigned short UBaseType_t; - - -typedef void ( __interrupt __far * pxISR )(); - -#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) - typedef uint16_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffff -#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) - typedef uint32_t TickType_t; +#define portCHAR char +#define portFLOAT float +#define portDOUBLE long +#define portLONG long +#define portSHORT int +#define portSTACK_TYPE uint16_t +#define portBASE_TYPE short + +typedef portSTACK_TYPE StackType_t; +typedef short BaseType_t; +typedef unsigned short UBaseType_t; + + +typedef void ( __interrupt __far *pxISR )(); + +#if( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) + typedef uint32_t TickType_t; #define portMAX_DELAY ( TickType_t ) 0xffffffffUL #else #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width. @@ -73,37 +73,36 @@ typedef void ( __interrupt __far * pxISR )(); /*-----------------------------------------------------------*/ /* Critical section handling. */ -#define portENTER_CRITICAL() \ - __asm { pushf } \ - __asm { cli } \ +#define portENTER_CRITICAL() __asm{ pushf } \ + __asm{ cli } \ -#define portEXIT_CRITICAL() __asm { popf } +#define portEXIT_CRITICAL() __asm{ popf } -#define portDISABLE_INTERRUPTS() __asm { cli } +#define portDISABLE_INTERRUPTS() __asm{ cli } -#define portENABLE_INTERRUPTS() __asm { sti } +#define portENABLE_INTERRUPTS() __asm{ sti } /*-----------------------------------------------------------*/ /* Hardware specifics. */ -#define portNOP() __asm { nop } -#define portSTACK_GROWTH ( -1 ) -#define portSWITCH_INT_NUMBER 0x80 -#define portYIELD() __asm { int portSWITCH_INT_NUMBER } -#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) -#define portBYTE_ALIGNMENT 2 -#define portINITIAL_SW ( ( portSTACK_TYPE ) 0x0202 ) /* Start the tasks with interrupts enabled. */ +#define portNOP() __asm{ nop } +#define portSTACK_GROWTH ( -1 ) +#define portSWITCH_INT_NUMBER 0x80 +#define portYIELD() __asm{ int portSWITCH_INT_NUMBER } +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 2 +#define portINITIAL_SW ( ( portSTACK_TYPE ) 0x0202 ) /* Start the tasks with interrupts enabled. */ /*-----------------------------------------------------------*/ /* Compiler specifics. */ -#define portINPUT_BYTE( xAddr ) inp( xAddr ) -#define portOUTPUT_BYTE( xAddr, ucValue ) outp( xAddr, ucValue ) -#define portINPUT_WORD( xAddr ) inpw( xAddr ) -#define portOUTPUT_WORD( xAddr, usValue ) outpw( xAddr, usValue ) +#define portINPUT_BYTE( xAddr ) inp( xAddr ) +#define portOUTPUT_BYTE( xAddr, ucValue ) outp( xAddr, ucValue ) +#define portINPUT_WORD( xAddr ) inpw( xAddr ) +#define portOUTPUT_WORD( xAddr, usValue ) outpw( xAddr, usValue ) /*-----------------------------------------------------------*/ /* Task function macros as described on the FreeRTOS.org WEB site. */ -#define portTASK_FUNCTION_PROTO( vTaskFunction, vParameters ) void vTaskFunction( void * pvParameters ) -#define portTASK_FUNCTION( vTaskFunction, vParameters ) void vTaskFunction( void * pvParameters ) +#define portTASK_FUNCTION_PROTO( vTaskFunction, vParameters ) void vTaskFunction( void *pvParameters ) +#define portTASK_FUNCTION( vTaskFunction, vParameters ) void vTaskFunction( void *pvParameters ) /* *INDENT-OFF* */ #ifdef __cplusplus diff --git a/portable/oWatcom/16BitDOS/Flsh186/port.c b/portable/oWatcom/16BitDOS/Flsh186/port.c index 03feb21e681..cc8863d1dd5 100644 --- a/portable/oWatcom/16BitDOS/Flsh186/port.c +++ b/portable/oWatcom/16BitDOS/Flsh186/port.c @@ -27,27 +27,27 @@ */ /* - * Changes from V1.00: - * - + Call to taskYIELD() from within tick ISR has been replaced by the more - + efficient portSWITCH_CONTEXT(). - + ISR function definitions renamed to include the prv prefix. - + - + Changes from V1.2.0: - + - + portRESET_PIC() is now called last thing before the end of the preemptive - + tick routine. - + - + Changes from V2.6.1 - + - + Replaced the sUsingPreemption variable with the configUSE_PREEMPTION - + macro to be consistent with the later ports. - */ +Changes from V1.00: + + + Call to taskYIELD() from within tick ISR has been replaced by the more + efficient portSWITCH_CONTEXT(). + + ISR function definitions renamed to include the prv prefix. + +Changes from V1.2.0: + + + portRESET_PIC() is now called last thing before the end of the preemptive + tick routine. + +Changes from V2.6.1 + + + Replaced the sUsingPreemption variable with the configUSE_PREEMPTION + macro to be consistent with the later ports. +*/ /*----------------------------------------------------------- -* Implementation of functions defined in portable.h for the Flashlite 186 -* port. -*----------------------------------------------------------*/ + * Implementation of functions defined in portable.h for the Flashlite 186 + * port. + *----------------------------------------------------------*/ #include #include @@ -60,9 +60,9 @@ /*lint -e950 Non ANSI reserved words okay in this file only. */ -#define portTIMER_EOI_TYPE ( 8 ) -#define portRESET_PIC() portOUTPUT_WORD( ( uint16_t ) 0xff22, portTIMER_EOI_TYPE ) -#define portTIMER_INT_NUMBER 0x12 +#define portTIMER_EOI_TYPE ( 8 ) +#define portRESET_PIC() portOUTPUT_WORD( ( uint16_t ) 0xff22, portTIMER_EOI_TYPE ) +#define portTIMER_INT_NUMBER 0x12 #define portTIMER_1_CONTROL_REGISTER ( ( uint16_t ) 0xff5e ) #define portTIMER_0_CONTROL_REGISTER ( ( uint16_t ) 0xff56 ) @@ -75,14 +75,12 @@ static void prvSetTickFrequency( uint32_t ulTickRateHz ); static void prvExitFunction( void ); #if configUSE_PREEMPTION == 1 - -/* Tick service routine used by the scheduler when preemptive scheduling is - * being used. */ + /* Tick service routine used by the scheduler when preemptive scheduling is + being used. */ static void __interrupt __far prvPreemptiveTick( void ); #else - -/* Tick service routine used by the scheduler when cooperative scheduling is - * being used. */ + /* Tick service routine used by the scheduler when cooperative scheduling is + being used. */ static void __interrupt __far prvNonPreemptiveTick( void ); #endif @@ -95,7 +93,7 @@ static void __interrupt __far prvYieldProcessor( void ); static int16_t sSchedulerRunning = pdFALSE; /* Points to the original routine installed on the vector we use for manual context switches. This is then used to restore the original routine during prvExitFunction(). */ -static void( __interrupt __far * pxOldSwitchISR )(); +static void ( __interrupt __far *pxOldSwitchISR )(); /* Used to restore the original DOS context when the scheduler is ended. */ static jmp_buf xJumpBuf; @@ -108,11 +106,11 @@ BaseType_t xPortStartScheduler( void ) /* This is called with interrupts already disabled. */ /* Remember what was on the interrupts we are going to use - * so we can put them back later if required. */ + so we can put them back later if required. */ pxOldSwitchISR = _dos_getvect( portSWITCH_INT_NUMBER ); /* Put our manual switch (yield) function on a known - * vector. */ + vector. */ _dos_setvect( portSWITCH_INT_NUMBER, prvYieldProcessor ); #if configUSE_PREEMPTION == 1 @@ -148,7 +146,7 @@ BaseType_t xPortStartScheduler( void ) /*-----------------------------------------------------------*/ /* The tick ISR used depend on whether or not the preemptive or cooperative - * kernel is being used. */ +kernel is being used. */ #if configUSE_PREEMPTION == 1 static void __interrupt __far prvPreemptiveTick( void ) { @@ -162,15 +160,15 @@ BaseType_t xPortStartScheduler( void ) /* Reset the PIC ready for the next time. */ portRESET_PIC(); } -#else /* if configUSE_PREEMPTION == 1 */ +#else static void __interrupt __far prvNonPreemptiveTick( void ) { /* Same as preemptive tick, but the cooperative scheduler is being used - * so we don't have to switch in the context of the next task. */ + so we don't have to switch in the context of the next task. */ xTaskIncrementTick(); portRESET_PIC(); } -#endif /* if configUSE_PREEMPTION == 1 */ +#endif /*-----------------------------------------------------------*/ static void __interrupt __far prvYieldProcessor( void ) @@ -183,31 +181,30 @@ static void __interrupt __far prvYieldProcessor( void ) void vPortEndScheduler( void ) { /* Jump back to the processor state prior to starting the - * scheduler. This means we are not going to be using a - * task stack frame so the task can be deleted. */ + scheduler. This means we are not going to be using a + task stack frame so the task can be deleted. */ longjmp( xJumpBuf, 1 ); } /*-----------------------------------------------------------*/ static void prvExitFunction( void ) { - const uint16_t usTimerDisable = 0x0000; - uint16_t usTimer0Control; +const uint16_t usTimerDisable = 0x0000; +uint16_t usTimer0Control; /* Interrupts should be disabled here anyway - but no - * harm in making sure. */ + harm in making sure. */ portDISABLE_INTERRUPTS(); - if( sSchedulerRunning == pdTRUE ) { /* Put back the switch interrupt routines that was in place - * before the scheduler started. */ + before the scheduler started. */ _dos_setvect( portSWITCH_INT_NUMBER, pxOldSwitchISR ); } /* Disable the timer used for the tick to ensure the scheduler is - * not called before restoring interrupts. There was previously nothing - * on this timer so there is no old ISR to restore. */ + not called before restoring interrupts. There was previously nothing + on this timer so there is no old ISR to restore. */ portOUTPUT_WORD( portTIMER_1_CONTROL_REGISTER, usTimerDisable ); /* Restart the DOS tick. */ @@ -222,18 +219,18 @@ static void prvExitFunction( void ) static void prvSetTickFrequency( uint32_t ulTickRateHz ) { - const uint16_t usMaxCountRegister = 0xff5a; - const uint16_t usTimerPriorityRegister = 0xff32; - const uint16_t usTimerEnable = 0xC000; - const uint16_t usRetrigger = 0x0001; - const uint16_t usTimerHighPriority = 0x0000; - uint16_t usTimer0Control; +const uint16_t usMaxCountRegister = 0xff5a; +const uint16_t usTimerPriorityRegister = 0xff32; +const uint16_t usTimerEnable = 0xC000; +const uint16_t usRetrigger = 0x0001; +const uint16_t usTimerHighPriority = 0x0000; +uint16_t usTimer0Control; /* ( CPU frequency / 4 ) / clock 2 max count [inpw( 0xff62 ) = 7] */ - const uint32_t ulClockFrequency = 0x7f31a0; +const uint32_t ulClockFrequency = 0x7f31a0; - uint32_t ulTimerCount = ulClockFrequency / ulTickRateHz; +uint32_t ulTimerCount = ulClockFrequency / ulTickRateHz; portOUTPUT_WORD( portTIMER_1_CONTROL_REGISTER, usTimerEnable | portTIMER_INTERRUPT_ENABLE | usRetrigger ); portOUTPUT_WORD( usMaxCountRegister, ( uint16_t ) ulTimerCount ); diff --git a/portable/oWatcom/16BitDOS/Flsh186/portmacro.h b/portable/oWatcom/16BitDOS/Flsh186/portmacro.h index 0488fd8b7cf..952e3f68021 100644 --- a/portable/oWatcom/16BitDOS/Flsh186/portmacro.h +++ b/portable/oWatcom/16BitDOS/Flsh186/portmacro.h @@ -47,24 +47,24 @@ /* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE long -#define portLONG long -#define portSHORT int -#define portSTACK_TYPE uint16_t -#define portBASE_TYPE short - -typedef portSTACK_TYPE StackType_t; -typedef short BaseType_t; -typedef unsigned short UBaseType_t; - - -#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) - typedef uint16_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffff -#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) - typedef uint32_t TickType_t; +#define portCHAR char +#define portFLOAT float +#define portDOUBLE long +#define portLONG long +#define portSHORT int +#define portSTACK_TYPE uint16_t +#define portBASE_TYPE short + +typedef portSTACK_TYPE StackType_t; +typedef short BaseType_t; +typedef unsigned short UBaseType_t; + + +#if( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) + typedef uint32_t TickType_t; #define portMAX_DELAY ( TickType_t ) 0xffffffffUL #else #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width. @@ -74,7 +74,7 @@ typedef unsigned short UBaseType_t; /* Critical section management. */ void portENTER_CRITICAL( void ); #pragma aux portENTER_CRITICAL = "pushf" \ - "cli"; + "cli"; void portEXIT_CRITICAL( void ); #pragma aux portEXIT_CRITICAL = "popf"; @@ -87,25 +87,25 @@ void portENABLE_INTERRUPTS( void ); /*-----------------------------------------------------------*/ /* Architecture specifics. */ -#define portSTACK_GROWTH ( -1 ) -#define portSWITCH_INT_NUMBER 0x80 -#define portYIELD() __asm { int portSWITCH_INT_NUMBER } -#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) -#define portBYTE_ALIGNMENT 2 -#define portINITIAL_SW ( ( portSTACK_TYPE ) 0x0202 ) /* Start the tasks with interrupts enabled. */ -#define portNOP() __asm { nop } +#define portSTACK_GROWTH ( -1 ) +#define portSWITCH_INT_NUMBER 0x80 +#define portYIELD() __asm{ int portSWITCH_INT_NUMBER } +#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) +#define portBYTE_ALIGNMENT 2 +#define portINITIAL_SW ( ( portSTACK_TYPE ) 0x0202 ) /* Start the tasks with interrupts enabled. */ +#define portNOP() __asm{ nop } /*-----------------------------------------------------------*/ /* Compiler specifics. */ -#define portINPUT_BYTE( xAddr ) inp( xAddr ) -#define portOUTPUT_BYTE( xAddr, ucValue ) outp( xAddr, ucValue ) -#define portINPUT_WORD( xAddr ) inpw( xAddr ) -#define portOUTPUT_WORD( xAddr, usValue ) outpw( xAddr, usValue ) +#define portINPUT_BYTE( xAddr ) inp( xAddr ) +#define portOUTPUT_BYTE( xAddr, ucValue ) outp( xAddr, ucValue ) +#define portINPUT_WORD( xAddr ) inpw( xAddr ) +#define portOUTPUT_WORD( xAddr, usValue ) outpw( xAddr, usValue ) /*-----------------------------------------------------------*/ /* Task function macros as described on the FreeRTOS.org WEB site. */ -#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters ) -#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters ) +#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters ) +#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) /* *INDENT-OFF* */ #ifdef __cplusplus diff --git a/portable/oWatcom/16BitDOS/PC/port.c b/portable/oWatcom/16BitDOS/PC/port.c index 4c4011aa994..6cb2de9e89f 100644 --- a/portable/oWatcom/16BitDOS/PC/port.c +++ b/portable/oWatcom/16BitDOS/PC/port.c @@ -27,27 +27,27 @@ */ /* - * Changes from V1.00: - * - + Call to taskYIELD() from within tick ISR has been replaced by the more - + efficient portSWITCH_CONTEXT(). - + ISR function definitions renamed to include the prv prefix. - + - + Changes from V1.2.0: - + - + prvPortResetPIC() is now called last thing before the end of the - + preemptive tick routine. - + - + Changes from V2.6.1 - + - + Replaced the sUsingPreemption variable with the configUSE_PREEMPTION - + macro to be consistent with the later ports. - + - + Changes from V4.0.1 - + - + Add function prvSetTickFrequencyDefault() to set the DOS tick back to - + its proper value when the scheduler exits. - */ +Changes from V1.00: + + + Call to taskYIELD() from within tick ISR has been replaced by the more + efficient portSWITCH_CONTEXT(). + + ISR function definitions renamed to include the prv prefix. + +Changes from V1.2.0: + + + prvPortResetPIC() is now called last thing before the end of the + preemptive tick routine. + +Changes from V2.6.1 + + + Replaced the sUsingPreemption variable with the configUSE_PREEMPTION + macro to be consistent with the later ports. + +Changes from V4.0.1 + + + Add function prvSetTickFrequencyDefault() to set the DOS tick back to + its proper value when the scheduler exits. +*/ #include #include @@ -60,9 +60,9 @@ #include "portasm.h" /*----------------------------------------------------------- -* Implementation of functions defined in portable.h for the industrial -* PC port. -*----------------------------------------------------------*/ + * Implementation of functions defined in portable.h for the industrial + * PC port. + *----------------------------------------------------------*/ /*lint -e950 Non ANSI reserved words okay in this file only. */ @@ -75,28 +75,26 @@ static void prvSetTickFrequency( uint32_t ulTickRateHz ); static void prvExitFunction( void ); /* Either chain to the DOS tick (which itself clears the PIC) or clear the PIC - * directly. We chain to the DOS tick as close as possible to the standard DOS - * tick rate. */ +directly. We chain to the DOS tick as close as possible to the standard DOS +tick rate. */ static void prvPortResetPIC( void ); /* The tick ISR used depends on whether the preemptive or cooperative scheduler - * is being used. */ +is being used. */ #if configUSE_PREEMPTION == 1 - -/* Tick service routine used by the scheduler when preemptive scheduling is - * being used. */ + /* Tick service routine used by the scheduler when preemptive scheduling is + being used. */ static void __interrupt __far prvPreemptiveTick( void ); #else - -/* Tick service routine used by the scheduler when cooperative scheduling is - * being used. */ + /* Tick service routine used by the scheduler when cooperative scheduling is + being used. */ static void __interrupt __far prvNonPreemptiveTick( void ); #endif /* Trap routine used by taskYIELD() to manually cause a context switch. */ static void __interrupt __far prvYieldProcessor( void ); /* Set the tick frequency back so the floppy drive works correctly when the - * scheduler exits. */ +scheduler exits. */ static void prvSetTickFrequencyDefault( void ); /*lint -e956 File scopes necessary here. */ @@ -108,10 +106,10 @@ static int16_t sDOSTickCounter; static int16_t sSchedulerRunning = pdFALSE; /* Points to the original routine installed on the vector we use for manual context switches. This is then used to restore the original routine during prvExitFunction(). */ -static void( __interrupt __far * pxOldSwitchISR )(); +static void ( __interrupt __far *pxOldSwitchISR )(); /* Points to the original routine installed on the vector we use to chain to the DOS tick. This is then used to restore the original routine during prvExitFunction(). */ -static void( __interrupt __far * pxOldSwitchISRPlus1 )(); +static void ( __interrupt __far *pxOldSwitchISRPlus1 )(); /* Used to restore the original DOS context when the scheduler is ended. */ static jmp_buf xJumpBuf; @@ -121,12 +119,12 @@ static jmp_buf xJumpBuf; /*-----------------------------------------------------------*/ BaseType_t xPortStartScheduler( void ) { - pxISR pxOriginalTickISR; +pxISR pxOriginalTickISR; /* This is called with interrupts already disabled. */ /* Remember what was on the interrupts we are going to use - * so we can put them back later if required. */ + so we can put them back later if required. */ pxOldSwitchISR = _dos_getvect( portSWITCH_INT_NUMBER ); pxOriginalTickISR = _dos_getvect( portTIMER_INT_NUMBER ); pxOldSwitchISRPlus1 = _dos_getvect( portSWITCH_INT_NUMBER + 1 ); @@ -134,11 +132,11 @@ BaseType_t xPortStartScheduler( void ) prvSetTickFrequency( configTICK_RATE_HZ ); /* Put our manual switch (yield) function on a known - * vector. */ + vector. */ _dos_setvect( portSWITCH_INT_NUMBER, prvYieldProcessor ); /* Put the old tick on a different interrupt number so we can - * call it when we want. */ + call it when we want. */ _dos_setvect( portSWITCH_INT_NUMBER + 1, pxOriginalTickISR ); #if configUSE_PREEMPTION == 1 @@ -154,8 +152,8 @@ BaseType_t xPortStartScheduler( void ) #endif /* Setup a counter that is used to call the DOS interrupt as close - * to it's original frequency as can be achieved given our chosen tick - * frequency. */ + to it's original frequency as can be achieved given our chosen tick + frequency. */ sDOSTickCounter = portTICKS_PER_DOS_TICK; /* Clean up function if we want to return to DOS. */ @@ -177,11 +175,10 @@ BaseType_t xPortStartScheduler( void ) /*-----------------------------------------------------------*/ /* The tick ISR used depends on whether the preemptive or cooperative scheduler - * is being used. */ +is being used. */ #if configUSE_PREEMPTION == 1 - -/* Tick service routine used by the scheduler when preemptive scheduling is - * being used. */ + /* Tick service routine used by the scheduler when preemptive scheduling is + being used. */ static void __interrupt __far prvPreemptiveTick( void ) { /* Get the scheduler to update the task states following the tick. */ @@ -194,15 +191,15 @@ BaseType_t xPortStartScheduler( void ) /* Reset the PIC ready for the next time. */ prvPortResetPIC(); } -#else /* if configUSE_PREEMPTION == 1 */ +#else static void __interrupt __far prvNonPreemptiveTick( void ) { /* Same as preemptive tick, but the cooperative scheduler is being used - * so we don't have to switch in the context of the next task. */ + so we don't have to switch in the context of the next task. */ xTaskIncrementTick(); prvPortResetPIC(); } -#endif /* if configUSE_PREEMPTION == 1 */ +#endif /*-----------------------------------------------------------*/ @@ -216,22 +213,19 @@ static void __interrupt __far prvYieldProcessor( void ) static void prvPortResetPIC( void ) { /* We are going to call the DOS tick interrupt at as close a - * frequency to the normal DOS tick as possible. */ + frequency to the normal DOS tick as possible. */ /* WE SHOULD NOT DO THIS IF YIELD WAS CALLED. */ --sDOSTickCounter; - if( sDOSTickCounter <= 0 ) { sDOSTickCounter = ( int16_t ) portTICKS_PER_DOS_TICK; - __asm { - int portSWITCH_INT_NUMBER + 1 - }; + __asm{ int portSWITCH_INT_NUMBER + 1 }; } else { /* Reset the PIC as the DOS tick is not being called to - * do it. */ + do it. */ __asm { mov al, 20H @@ -244,20 +238,19 @@ static void prvPortResetPIC( void ) void vPortEndScheduler( void ) { /* Jump back to the processor state prior to starting the - * scheduler. This means we are not going to be using a - * task stack frame so the task can be deleted. */ + scheduler. This means we are not going to be using a + task stack frame so the task can be deleted. */ longjmp( xJumpBuf, 1 ); } /*-----------------------------------------------------------*/ static void prvExitFunction( void ) { - void( __interrupt __far * pxOriginalTickISR )(); +void ( __interrupt __far *pxOriginalTickISR )(); /* Interrupts should be disabled here anyway - but no - * harm in making sure. */ + harm in making sure. */ portDISABLE_INTERRUPTS(); - if( sSchedulerRunning == pdTRUE ) { /* Set the DOS tick back onto the timer ticker. */ @@ -266,30 +259,29 @@ static void prvExitFunction( void ) prvSetTickFrequencyDefault(); /* Put back the switch interrupt routines that was in place - * before the scheduler started. */ + before the scheduler started. */ _dos_setvect( portSWITCH_INT_NUMBER, pxOldSwitchISR ); _dos_setvect( portSWITCH_INT_NUMBER + 1, pxOldSwitchISRPlus1 ); } - /* The tick timer is back how DOS wants it. We can re-enable - * interrupts without the scheduler being called. */ + interrupts without the scheduler being called. */ portENABLE_INTERRUPTS(); } /*-----------------------------------------------------------*/ static void prvSetTickFrequency( uint32_t ulTickRateHz ) { - const uint16_t usPIT_MODE = ( uint16_t ) 0x43; - const uint16_t usPIT0 = ( uint16_t ) 0x40; - const uint32_t ulPIT_CONST = ( uint32_t ) 1193180; - const uint16_t us8254_CTR0_MODE3 = ( uint16_t ) 0x36; - uint32_t ulOutput; +const uint16_t usPIT_MODE = ( uint16_t ) 0x43; +const uint16_t usPIT0 = ( uint16_t ) 0x40; +const uint32_t ulPIT_CONST = ( uint32_t ) 1193180; +const uint16_t us8254_CTR0_MODE3 = ( uint16_t ) 0x36; +uint32_t ulOutput; /* Setup the 8245 to tick at the wanted frequency. */ portOUTPUT_BYTE( usPIT_MODE, us8254_CTR0_MODE3 ); ulOutput = ulPIT_CONST / ulTickRateHz; - portOUTPUT_BYTE( usPIT0, ( uint16_t ) ( ulOutput & ( uint32_t ) 0xff ) ); + portOUTPUT_BYTE( usPIT0, ( uint16_t )( ulOutput & ( uint32_t ) 0xff ) ); ulOutput >>= 8; portOUTPUT_BYTE( usPIT0, ( uint16_t ) ( ulOutput & ( uint32_t ) 0xff ) ); } @@ -297,13 +289,13 @@ static void prvSetTickFrequency( uint32_t ulTickRateHz ) static void prvSetTickFrequencyDefault( void ) { - const uint16_t usPIT_MODE = ( uint16_t ) 0x43; - const uint16_t usPIT0 = ( uint16_t ) 0x40; - const uint16_t us8254_CTR0_MODE3 = ( uint16_t ) 0x36; +const uint16_t usPIT_MODE = ( uint16_t ) 0x43; +const uint16_t usPIT0 = ( uint16_t ) 0x40; +const uint16_t us8254_CTR0_MODE3 = ( uint16_t ) 0x36; portOUTPUT_BYTE( usPIT_MODE, us8254_CTR0_MODE3 ); - portOUTPUT_BYTE( usPIT0, 0 ); - portOUTPUT_BYTE( usPIT0, 0 ); + portOUTPUT_BYTE( usPIT0,0 ); + portOUTPUT_BYTE( usPIT0,0 ); } diff --git a/portable/oWatcom/16BitDOS/PC/portmacro.h b/portable/oWatcom/16BitDOS/PC/portmacro.h index f2c585a1482..2fb7534117a 100644 --- a/portable/oWatcom/16BitDOS/PC/portmacro.h +++ b/portable/oWatcom/16BitDOS/PC/portmacro.h @@ -46,24 +46,24 @@ */ /* Type definitions. */ -#define portCHAR char -#define portFLOAT float -#define portDOUBLE double -#define portLONG long -#define portSHORT int -#define portSTACK_TYPE uint16_t -#define portBASE_TYPE short - -typedef portSTACK_TYPE StackType_t; -typedef short BaseType_t; -typedef unsigned short UBaseType_t; - - -#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) - typedef uint16_t TickType_t; - #define portMAX_DELAY ( TickType_t ) 0xffff -#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) - typedef uint32_t TickType_t; +#define portCHAR char +#define portFLOAT float +#define portDOUBLE double +#define portLONG long +#define portSHORT int +#define portSTACK_TYPE uint16_t +#define portBASE_TYPE short + +typedef portSTACK_TYPE StackType_t; +typedef short BaseType_t; +typedef unsigned short UBaseType_t; + + +#if( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) + typedef uint16_t TickType_t; + #define portMAX_DELAY ( TickType_t ) 0xffff +#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS ) + typedef uint32_t TickType_t; #define portMAX_DELAY ( TickType_t ) 0xffffffffUL #else #error configTICK_TYPE_WIDTH_IN_BITS set to unsupported tick type width. @@ -71,11 +71,11 @@ typedef unsigned short UBaseType_t; /*-----------------------------------------------------------*/ /* Critical section definitions. portENTER_CRITICAL() must be defined as a - * macro for portable.h to work properly. */ +macro for portable.h to work properly. */ void portLOCAL_ENTER_CRITICAL( void ); #pragma aux portLOCAL_ENTER_CRITICAL = "pushf" \ - "cli"; -#define portENTER_CRITICAL() portLOCAL_ENTER_CRITICAL() + "cli"; +#define portENTER_CRITICAL() portLOCAL_ENTER_CRITICAL() void portEXIT_CRITICAL( void ); #pragma aux portEXIT_CRITICAL = "popf"; @@ -88,25 +88,25 @@ void portENABLE_INTERRUPTS( void ); /*-----------------------------------------------------------*/ /* Architecture specifics. */ -#define portSTACK_GROWTH ( -1 ) -#define portSWITCH_INT_NUMBER 0x80 -#define portYIELD() __asm { int portSWITCH_INT_NUMBER } -#define portDOS_TICK_RATE ( 18.20648 ) +#define portSTACK_GROWTH ( -1 ) +#define portSWITCH_INT_NUMBER 0x80 +#define portYIELD() __asm{ int portSWITCH_INT_NUMBER } +#define portDOS_TICK_RATE ( 18.20648 ) #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) -#define portTICKS_PER_DOS_TICK ( ( uint16_t ) ( ( ( portDOUBLE ) configTICK_RATE_HZ / portDOS_TICK_RATE ) + 0.5 ) ) -#define portINITIAL_SW ( ( portSTACK_TYPE ) 0x0202 ) /* Start the tasks with interrupts enabled. */ -#define portBYTE_ALIGNMENT ( 2 ) +#define portTICKS_PER_DOS_TICK ( ( uint16_t ) ( ( ( portDOUBLE ) configTICK_RATE_HZ / portDOS_TICK_RATE ) + 0.5 ) ) +#define portINITIAL_SW ( ( portSTACK_TYPE ) 0x0202 ) /* Start the tasks with interrupts enabled. */ +#define portBYTE_ALIGNMENT ( 2 ) /*-----------------------------------------------------------*/ /* Compiler specifics. */ -#define portINPUT_BYTE( xAddr ) inp( xAddr ) -#define portOUTPUT_BYTE( xAddr, ucValue ) outp( xAddr, ucValue ) -#define portNOP() __asm { nop } +#define portINPUT_BYTE( xAddr ) inp( xAddr ) +#define portOUTPUT_BYTE( xAddr, ucValue ) outp( xAddr, ucValue ) +#define portNOP() __asm{ nop } /*-----------------------------------------------------------*/ /* Task function macros as described on the FreeRTOS.org WEB site. */ -#define portTASK_FUNCTION_PROTO( vTaskFunction, pvParameters ) void vTaskFunction( void * pvParameters ) -#define portTASK_FUNCTION( vTaskFunction, pvParameters ) void vTaskFunction( void * pvParameters ) +#define portTASK_FUNCTION_PROTO( vTaskFunction, pvParameters ) void vTaskFunction( void *pvParameters ) +#define portTASK_FUNCTION( vTaskFunction, pvParameters ) void vTaskFunction( void *pvParameters ) /* *INDENT-OFF* */ #ifdef __cplusplus diff --git a/portable/oWatcom/16BitDOS/common/portasm.h b/portable/oWatcom/16BitDOS/common/portasm.h index 9972432931d..f77e2b55327 100644 --- a/portable/oWatcom/16BitDOS/common/portasm.h +++ b/portable/oWatcom/16BitDOS/common/portasm.h @@ -45,65 +45,65 @@ void portSWITCH_CONTEXT( void ); void portFIRST_CONTEXT( void ); /* There are slightly different versions depending on whether you are building - * to include debugger information. If debugger information is used then there - * are a couple of extra bytes left of the ISR stack (presumably for use by the - * debugger). The true stack pointer is then stored in the bp register. We add - * 2 to the stack pointer to remove the extra bytes before we restore our context. */ +to include debugger information. If debugger information is used then there +are a couple of extra bytes left of the ISR stack (presumably for use by the +debugger). The true stack pointer is then stored in the bp register. We add +2 to the stack pointer to remove the extra bytes before we restore our context. */ #ifdef DEBUG_BUILD - #pragma aux portSWITCH_CONTEXT = "mov ax, seg pxCurrentTCB" \ - "mov ds, ax" \ - "les bx, pxCurrentTCB" /* Save the stack pointer into the TCB. */ \ - "mov es:0x2[ bx ], ss" \ - "mov es:[ bx ], sp" \ - "call vTaskSwitchContext" /* Perform the switch. */ \ - "mov ax, seg pxCurrentTCB" /* Restore the stack pointer from the TCB. */ \ - "mov ds, ax" \ - "les bx, dword ptr pxCurrentTCB" \ - "mov ss, es:[ bx + 2 ]" \ - "mov sp, es:[ bx ]" \ - "mov bp, sp" /* Prepair the bp register for the restoration of the SP in the compiler generated portion of the ISR */ \ - "add bp, 0x0002" + #pragma aux portSWITCH_CONTEXT = "mov ax, seg pxCurrentTCB" \ + "mov ds, ax" \ + "les bx, pxCurrentTCB" /* Save the stack pointer into the TCB. */ \ + "mov es:0x2[ bx ], ss" \ + "mov es:[ bx ], sp" \ + "call vTaskSwitchContext" /* Perform the switch. */ \ + "mov ax, seg pxCurrentTCB" /* Restore the stack pointer from the TCB. */ \ + "mov ds, ax" \ + "les bx, dword ptr pxCurrentTCB" \ + "mov ss, es:[ bx + 2 ]" \ + "mov sp, es:[ bx ]" \ + "mov bp, sp" /* Prepair the bp register for the restoration of the SP in the compiler generated portion of the ISR */ \ + "add bp, 0x0002" - #pragma aux portFIRST_CONTEXT = "mov ax, seg pxCurrentTCB" \ - "mov ds, ax" \ - "les bx, dword ptr pxCurrentTCB" \ - "mov ss, es:[ bx + 2 ]" \ - "mov sp, es:[ bx ]" \ - "add sp, 0x0002" /* Remove the extra bytes that exist in debug builds before restoring the context. */ \ - "pop ax" \ - "pop ax" \ - "pop es" \ - "pop ds" \ - "popa" \ - "iret" -#else /* ifdef DEBUG_BUILD */ + #pragma aux portFIRST_CONTEXT = "mov ax, seg pxCurrentTCB" \ + "mov ds, ax" \ + "les bx, dword ptr pxCurrentTCB" \ + "mov ss, es:[ bx + 2 ]" \ + "mov sp, es:[ bx ]" \ + "add sp, 0x0002" /* Remove the extra bytes that exist in debug builds before restoring the context. */ \ + "pop ax" \ + "pop ax" \ + "pop es" \ + "pop ds" \ + "popa" \ + "iret" +#else - #pragma aux portSWITCH_CONTEXT = "mov ax, seg pxCurrentTCB" \ - "mov ds, ax" \ - "les bx, pxCurrentTCB" /* Save the stack pointer into the TCB. */ \ - "mov es:0x2[ bx ], ss" \ - "mov es:[ bx ], sp" \ - "call vTaskSwitchContext" /* Perform the switch. */ \ - "mov ax, seg pxCurrentTCB" /* Restore the stack pointer from the TCB. */ \ - "mov ds, ax" \ - "les bx, dword ptr pxCurrentTCB" \ - "mov ss, es:[ bx + 2 ]" \ - "mov sp, es:[ bx ]" + #pragma aux portSWITCH_CONTEXT = "mov ax, seg pxCurrentTCB" \ + "mov ds, ax" \ + "les bx, pxCurrentTCB" /* Save the stack pointer into the TCB. */ \ + "mov es:0x2[ bx ], ss" \ + "mov es:[ bx ], sp" \ + "call vTaskSwitchContext" /* Perform the switch. */ \ + "mov ax, seg pxCurrentTCB" /* Restore the stack pointer from the TCB. */ \ + "mov ds, ax" \ + "les bx, dword ptr pxCurrentTCB" \ + "mov ss, es:[ bx + 2 ]" \ + "mov sp, es:[ bx ]" - #pragma aux portFIRST_CONTEXT = "mov ax, seg pxCurrentTCB" \ - "mov ds, ax" \ - "les bx, dword ptr pxCurrentTCB" \ - "mov ss, es:[ bx + 2 ]" \ - "mov sp, es:[ bx ]" \ - "pop ax" \ - "pop ax" \ - "pop es" \ - "pop ds" \ - "popa" \ - "iret" -#endif /* ifdef DEBUG_BUILD */ + #pragma aux portFIRST_CONTEXT = "mov ax, seg pxCurrentTCB" \ + "mov ds, ax" \ + "les bx, dword ptr pxCurrentTCB" \ + "mov ss, es:[ bx + 2 ]" \ + "mov sp, es:[ bx ]" \ + "pop ax" \ + "pop ax" \ + "pop es" \ + "pop ds" \ + "popa" \ + "iret" +#endif diff --git a/portable/oWatcom/16BitDOS/common/portcomn.c b/portable/oWatcom/16BitDOS/common/portcomn.c index 54c06f675ec..2a7b666379f 100644 --- a/portable/oWatcom/16BitDOS/common/portcomn.c +++ b/portable/oWatcom/16BitDOS/common/portcomn.c @@ -27,21 +27,21 @@ */ /* - * Changes from V1.00: - * - + pxPortInitialiseStack() now initialises the stack of new tasks to the - + same format used by the compiler. This allows the compiler generated - + interrupt mechanism to be used for context switches. - + - + Changes from V2.4.2: - + - + pvPortMalloc and vPortFree have been removed. The projects now use - + the definitions from the source/portable/MemMang directory. - + - + Changes from V2.6.1: - + - + usPortCheckFreeStackSpace() has been moved to tasks.c. - */ +Changes from V1.00: + + + pxPortInitialiseStack() now initialises the stack of new tasks to the + same format used by the compiler. This allows the compiler generated + interrupt mechanism to be used for context switches. + +Changes from V2.4.2: + + + pvPortMalloc and vPortFree have been removed. The projects now use + the definitions from the source/portable/MemMang directory. + +Changes from V2.6.1: + + + usPortCheckFreeStackSpace() has been moved to tasks.c. +*/ @@ -51,15 +51,13 @@ /*-----------------------------------------------------------*/ /* See header file for description. */ -StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, - TaskFunction_t pxCode, - void * pvParameters ) +StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) { - StackType_t DS_Reg = 0; - StackType_t * pxOriginalSP; +StackType_t DS_Reg = 0; +StackType_t * pxOriginalSP; /* Place a few bytes of known values on the bottom of the stack. - * This is just useful for debugging. */ + This is just useful for debugging. */ *pxTopOfStack = 0x1111; pxTopOfStack--; @@ -76,9 +74,9 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, /*lint -e950 -e611 -e923 Lint doesn't like this much - but nothing I can do about it. */ /* We are going to start the scheduler using a return from interrupt - * instruction to load the program counter, so first there would be the - * status register and interrupt return address. We make this the start - * of the task. */ + instruction to load the program counter, so first there would be the + status register and interrupt return address. We make this the start + of the task. */ *pxTopOfStack = portINITIAL_SW; pxTopOfStack--; *pxTopOfStack = FP_SEG( pxCode ); @@ -87,24 +85,24 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, pxTopOfStack--; /* We are going to setup the stack for the new task to look like - * the stack frame was setup by a compiler generated ISR. We need to know - * the address of the existing stack top to place in the SP register within - * the stack frame. pxOriginalSP holds SP before (simulated) pusha was - * called. */ + the stack frame was setup by a compiler generated ISR. We need to know + the address of the existing stack top to place in the SP register within + the stack frame. pxOriginalSP holds SP before (simulated) pusha was + called. */ pxOriginalSP = pxTopOfStack; /* The remaining registers would be pushed on the stack by our context - * switch function. These are loaded with values simply to make debugging - * easier. */ - *pxTopOfStack = FP_OFF( pvParameters ); /* AX */ + switch function. These are loaded with values simply to make debugging + easier. */ + *pxTopOfStack = FP_OFF( pvParameters ); /* AX */ pxTopOfStack--; *pxTopOfStack = ( StackType_t ) 0xCCCC; /* CX */ pxTopOfStack--; - *pxTopOfStack = FP_SEG( pvParameters ); /* DX */ + *pxTopOfStack = FP_SEG( pvParameters ); /* DX */ pxTopOfStack--; *pxTopOfStack = ( StackType_t ) 0xBBBB; /* BX */ pxTopOfStack--; - *pxTopOfStack = FP_OFF( pxOriginalSP ); /* SP */ + *pxTopOfStack = FP_OFF( pxOriginalSP ); /* SP */ pxTopOfStack--; *pxTopOfStack = ( StackType_t ) 0xBBBB; /* BP */ pxTopOfStack--; @@ -113,9 +111,7 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, *pxTopOfStack = ( StackType_t ) 0xDDDD; /* DI */ /* We need the true data segment. */ - __asm { - MOV DS_Reg, DS - }; + __asm{ MOV DS_Reg, DS }; pxTopOfStack--; *pxTopOfStack = DS_Reg; /* DS */ @@ -125,17 +121,16 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack, /* The AX register is pushed again twice - don't know why. */ pxTopOfStack--; - *pxTopOfStack = FP_OFF( pvParameters ); /* AX */ + *pxTopOfStack = FP_OFF( pvParameters ); /* AX */ pxTopOfStack--; - *pxTopOfStack = FP_OFF( pvParameters ); /* AX */ + *pxTopOfStack = FP_OFF( pvParameters ); /* AX */ #ifdef DEBUG_BUILD - /* The compiler adds space to each ISR stack if building to - * include debug information. Presumably this is used by the - * debugger - we don't need to initialise it to anything just - * make sure it is there. */ + include debug information. Presumably this is used by the + debugger - we don't need to initialise it to anything just + make sure it is there. */ pxTopOfStack--; #endif