2727 */
2828
2929/*
30- * Changes from V1.00:
31- *
32- + Call to taskYIELD() from within tick ISR has been replaced by the more
33- + efficient portSWITCH_CONTEXT().
34- + ISR function definitions renamed to include the prv prefix.
35- +
36- + Changes from V1.2.0:
37- +
38- + portRESET_PIC() is now called last thing before the end of the preemptive
39- + tick routine.
40- +
41- + Changes from V2.6.1
42- +
43- + Replaced the sUsingPreemption variable with the configUSE_PREEMPTION
44- + macro to be consistent with the later ports.
45- */
30+ Changes from V1.00:
31+
32+ + Call to taskYIELD() from within tick ISR has been replaced by the more
33+ efficient portSWITCH_CONTEXT().
34+ + ISR function definitions renamed to include the prv prefix.
35+
36+ Changes from V1.2.0:
37+
38+ + portRESET_PIC() is now called last thing before the end of the preemptive
39+ tick routine.
40+
41+ Changes from V2.6.1
42+
43+ + Replaced the sUsingPreemption variable with the configUSE_PREEMPTION
44+ macro to be consistent with the later ports.
45+ */
4646
4747/*-----------------------------------------------------------
48- * Implementation of functions defined in portable.h for the Flashlite 186
49- * port.
50- *----------------------------------------------------------*/
48+ * Implementation of functions defined in portable.h for the Flashlite 186
49+ * port.
50+ *----------------------------------------------------------*/
5151
5252#include <stdlib.h>
5353#include <i86.h>
6060
6161/*lint -e950 Non ANSI reserved words okay in this file only. */
6262
63- #define portTIMER_EOI_TYPE ( 8 )
64- #define portRESET_PIC () portOUTPUT_WORD( ( uint16_t ) 0xff22, portTIMER_EOI_TYPE )
65- #define portTIMER_INT_NUMBER 0x12
63+ #define portTIMER_EOI_TYPE ( 8 )
64+ #define portRESET_PIC () portOUTPUT_WORD( ( uint16_t ) 0xff22, portTIMER_EOI_TYPE )
65+ #define portTIMER_INT_NUMBER 0x12
6666
6767#define portTIMER_1_CONTROL_REGISTER ( ( uint16_t ) 0xff5e )
6868#define portTIMER_0_CONTROL_REGISTER ( ( uint16_t ) 0xff56 )
@@ -75,14 +75,12 @@ static void prvSetTickFrequency( uint32_t ulTickRateHz );
7575static void prvExitFunction ( void );
7676
7777#if configUSE_PREEMPTION == 1
78-
79- /* Tick service routine used by the scheduler when preemptive scheduling is
80- * being used. */
78+ /* Tick service routine used by the scheduler when preemptive scheduling is
79+ being used. */
8180 static void __interrupt __far prvPreemptiveTick ( void );
8281#else
83-
84- /* Tick service routine used by the scheduler when cooperative scheduling is
85- * being used. */
82+ /* Tick service routine used by the scheduler when cooperative scheduling is
83+ being used. */
8684 static void __interrupt __far prvNonPreemptiveTick ( void );
8785#endif
8886
@@ -95,7 +93,7 @@ static void __interrupt __far prvYieldProcessor( void );
9593static int16_t sSchedulerRunning = pdFALSE ;
9694
9795/* 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(). */
98- static void ( __interrupt __far * pxOldSwitchISR )();
96+ static void ( __interrupt __far * pxOldSwitchISR )();
9997
10098/* Used to restore the original DOS context when the scheduler is ended. */
10199static jmp_buf xJumpBuf ;
@@ -108,11 +106,11 @@ BaseType_t xPortStartScheduler( void )
108106 /* This is called with interrupts already disabled. */
109107
110108 /* Remember what was on the interrupts we are going to use
111- * so we can put them back later if required. */
109+ so we can put them back later if required. */
112110 pxOldSwitchISR = _dos_getvect ( portSWITCH_INT_NUMBER );
113111
114112 /* Put our manual switch (yield) function on a known
115- * vector. */
113+ vector. */
116114 _dos_setvect ( portSWITCH_INT_NUMBER , prvYieldProcessor );
117115
118116 #if configUSE_PREEMPTION == 1
@@ -148,7 +146,7 @@ BaseType_t xPortStartScheduler( void )
148146/*-----------------------------------------------------------*/
149147
150148/* The tick ISR used depend on whether or not the preemptive or cooperative
151- * kernel is being used. */
149+ kernel is being used. */
152150#if configUSE_PREEMPTION == 1
153151 static void __interrupt __far prvPreemptiveTick ( void )
154152 {
@@ -162,15 +160,15 @@ BaseType_t xPortStartScheduler( void )
162160 /* Reset the PIC ready for the next time. */
163161 portRESET_PIC ();
164162 }
165- #else /* if configUSE_PREEMPTION == 1 */
163+ #else
166164 static void __interrupt __far prvNonPreemptiveTick ( void )
167165 {
168166 /* Same as preemptive tick, but the cooperative scheduler is being used
169- * so we don't have to switch in the context of the next task. */
167+ so we don't have to switch in the context of the next task. */
170168 xTaskIncrementTick ();
171169 portRESET_PIC ();
172170 }
173- #endif /* if configUSE_PREEMPTION == 1 */
171+ #endif
174172/*-----------------------------------------------------------*/
175173
176174static void __interrupt __far prvYieldProcessor ( void )
@@ -183,31 +181,30 @@ static void __interrupt __far prvYieldProcessor( void )
183181void vPortEndScheduler ( void )
184182{
185183 /* Jump back to the processor state prior to starting the
186- * scheduler. This means we are not going to be using a
187- * task stack frame so the task can be deleted. */
184+ scheduler. This means we are not going to be using a
185+ task stack frame so the task can be deleted. */
188186 longjmp ( xJumpBuf , 1 );
189187}
190188/*-----------------------------------------------------------*/
191189
192190static void prvExitFunction ( void )
193191{
194- const uint16_t usTimerDisable = 0x0000 ;
195- uint16_t usTimer0Control ;
192+ const uint16_t usTimerDisable = 0x0000 ;
193+ uint16_t usTimer0Control ;
196194
197195 /* Interrupts should be disabled here anyway - but no
198- * harm in making sure. */
196+ harm in making sure. */
199197 portDISABLE_INTERRUPTS ();
200-
201198 if ( sSchedulerRunning == pdTRUE )
202199 {
203200 /* Put back the switch interrupt routines that was in place
204- * before the scheduler started. */
201+ before the scheduler started. */
205202 _dos_setvect ( portSWITCH_INT_NUMBER , pxOldSwitchISR );
206203 }
207204
208205 /* Disable the timer used for the tick to ensure the scheduler is
209- * not called before restoring interrupts. There was previously nothing
210- * on this timer so there is no old ISR to restore. */
206+ not called before restoring interrupts. There was previously nothing
207+ on this timer so there is no old ISR to restore. */
211208 portOUTPUT_WORD ( portTIMER_1_CONTROL_REGISTER , usTimerDisable );
212209
213210 /* Restart the DOS tick. */
@@ -222,18 +219,18 @@ static void prvExitFunction( void )
222219
223220static void prvSetTickFrequency ( uint32_t ulTickRateHz )
224221{
225- const uint16_t usMaxCountRegister = 0xff5a ;
226- const uint16_t usTimerPriorityRegister = 0xff32 ;
227- const uint16_t usTimerEnable = 0xC000 ;
228- const uint16_t usRetrigger = 0x0001 ;
229- const uint16_t usTimerHighPriority = 0x0000 ;
230- uint16_t usTimer0Control ;
222+ const uint16_t usMaxCountRegister = 0xff5a ;
223+ const uint16_t usTimerPriorityRegister = 0xff32 ;
224+ const uint16_t usTimerEnable = 0xC000 ;
225+ const uint16_t usRetrigger = 0x0001 ;
226+ const uint16_t usTimerHighPriority = 0x0000 ;
227+ uint16_t usTimer0Control ;
231228
232229/* ( CPU frequency / 4 ) / clock 2 max count [inpw( 0xff62 ) = 7] */
233230
234- const uint32_t ulClockFrequency = 0x7f31a0 ;
231+ const uint32_t ulClockFrequency = 0x7f31a0 ;
235232
236- uint32_t ulTimerCount = ulClockFrequency / ulTickRateHz ;
233+ uint32_t ulTimerCount = ulClockFrequency / ulTickRateHz ;
237234
238235 portOUTPUT_WORD ( portTIMER_1_CONTROL_REGISTER , usTimerEnable | portTIMER_INTERRUPT_ENABLE | usRetrigger );
239236 portOUTPUT_WORD ( usMaxCountRegister , ( uint16_t ) ulTimerCount );
0 commit comments